⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
small change
daniel31x1381e9b276832b
diff --git a/components/ModalContent/NewNoteModal.tsx b/components/ModalContent/NewNoteModal.tsxindex 110a838b..5b6978cb 100644--- a/components/ModalContent/NewNoteModal.tsx+++ b/components/ModalContent/NewNoteModal.tsx@@ -1,4 +1,3 @@-// NewNoteModal.tsximport React, { useEffect, useState, useRef } from "react";import CollectionSelection from "@/components/InputSelect/CollectionSelection";import TagSelection from "@/components/InputSelect/TagSelection";@@ -84,29 +83,24 @@ export default function NewNoteModal({ onClose }: Props) {const editor = editorRef.current?.getEditor();if (!editor) throw new Error("Editor not initialized");- // Get the sanitized HTML content from the editorconst sanitizedHTML = DOMPurify.sanitize(editor.getHTML());- // Create a DOM parser to parse the sanitized HTML stringconst parser = new DOMParser();const doc = parser.parseFromString(sanitizedHTML, "text/html");- // Extract the first <h1> element as the titleconst h1 = doc.querySelector("h1");const title = h1 ? h1.textContent?.trim() : link.name;- // Remove the first <h1> from the content to isolate the main contentif (h1) {h1.remove();}- const contentWithoutTitle = doc.body.innerHTML.trim();- // Prepare the file content, optionally including the title+ const contentWithoutTitle = doc.body.innerHTML || "";+const file = new File([contentWithoutTitle], title || "Untitled Note", {type: "text/plain",});- // Perform the file upload mutationawait uploadFile.mutateAsync({ link, file },{@@ -134,7 +128,6 @@ export default function NewNoteModal({ onClose }: Props) {<Modal toggleModal={onClose}><p className="text-xl font-thin">{t("write_new_note")}</p><div className="divider mb-2 mt-1"></div>- {/* Pass the ref to TextEditor */}<TextEditor ref={editorRef} editable /><div className={"mt-2"}>{optionsExpanded && (diff --git a/components/TextEditor.tsx b/components/TextEditor.tsxindex 5e98eeeb..6509b00a 100644--- a/components/TextEditor.tsx+++ b/components/TextEditor.tsx@@ -14,7 +14,6 @@ import { useRouter } from "next/router";import { useTranslation } from "next-i18next";import clsx from "clsx";import usePermissions from "@/hooks/usePermissions";-import { useUpdateFile } from "@/hooks/store/links";import { EditorContent, useEditor } from "@tiptap/react";import StarterKit from "@tiptap/starter-kit";import Image from "@tiptap/extension-image";@@ -29,7 +28,6 @@ import Placeholder from "@tiptap/extension-placeholder";import Document from "@tiptap/extension-document";type Props = {- onSave?: () => void;link?: LinkIncludingShortenedCollectionAndTags;className?: string;editable?: boolean;@@ -40,7 +38,7 @@ export type TextEditorRef = {};const TextEditor = forwardRef<TextEditorRef, Props>(- ({ onSave, link, className, editable }, ref) => {+ ({ link, className, editable }, ref) => {const { t } = useTranslation();const [linkContent, setLinkContent] = useState("");