A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: tiny -> tiptap migration
thecodrr8ab89a1aa7a6
diff --git a/apps/web/src/components/diff-viewer/index.js b/apps/web/src/components/diff-viewer/index.jsindex be8650b67..423af223f 100644--- a/apps/web/src/components/diff-viewer/index.js+++ b/apps/web/src/components/diff-viewer/index.js@@ -37,7 +37,7 @@ function DiffViewer(props) {await db.content.add({id: conflictedNote.contentId,data: toKeep,- type: "tiny",+ type: "tiptap",dateResolved,conflicted: false,sessionId: Date.now(),@@ -46,7 +46,7 @@ function DiffViewer(props) {if (toCopy) {const toCopyContent = {data: toCopy,- type: "tiny",+ type: "tiptap",};await db.notes.add({content: toCopyContent,diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsxindex 64d05a4b0..9a303ac29 100644--- a/apps/web/src/components/editor/index.tsx+++ b/apps/web/src/components/editor/index.tsx@@ -37,7 +37,7 @@ function onEditorChange(noteId: string, sessionId: string, content: string) {if (!content) return;editorstore.get().saveSessionContent(noteId, sessionId, {- type: "tiny",+ type: "tiptap",data: content,});}@@ -62,9 +62,9 @@ export default function EditorManager({const isNewSession = !!nonce && noteId === 0;const isOldSession = !nonce && !!noteId;- const [content, setContent] = useState<string>("");+ const content = useRef<string>("");+ const title = useRef<string>("");const [timestamp, setTimestamp] = useState<number>(0);- const [title, setTitle] = useState<string>("");const arePropertiesVisible = useStore((store) => store.arePropertiesVisible);const toggleProperties = useStore((store) => store.toggleProperties);@@ -84,22 +84,25 @@ export default function EditorManager({(async function () {await editorstore.newSession(nonce);- setContent("");- setTitle("");+ title.current = "";+ content.current = "";setTimestamp(Date.now());+ console.log("Updating timestamp (new)");})();}, [isNewSession, nonce]);useEffect(() => {- if (!noteId) return;+ if (!noteId || isOldSession) return;(async function () {- const content = await editorstore.get().getSessionContent();- setContent(content?.data);+ const sessionContent = await editorstore.get().getSessionContent();+ content.current = sessionContent?.data;setTimestamp(Date.now());- if (noteId && content) await db.attachments?.downloadImages(noteId);+ if (noteId && sessionContent)+ await db.attachments?.downloadImages(noteId);+ console.log("Updating timestamp (preview)");})();- }, [noteId, isPreviewMode]);+ }, [noteId, isPreviewMode, isOldSession]);useEffect(() => {if (!isOldSession) return;@@ -108,12 +111,14 @@ export default function EditorManager({await editorstore.get().openSession(noteId);const { getSessionContent, session } = editorstore.get();- const content = await getSessionContent();+ const sessionContent = await getSessionContent();- setTitle(session.title);- setContent(content?.data);+ title.current = session.title;+ content.current = sessionContent?.data;setTimestamp(Date.now());- if (noteId && content) await db.attachments?.downloadImages(noteId);+ if (noteId && sessionContent)+ await db.attachments?.downloadImages(noteId);+ console.log("Updating timestamp (old)");})();}, [noteId, isOldSession]);@@ -132,8 +137,8 @@ export default function EditorManager({{isPreviewMode && <PreviewModeNotice />}<Editornonce={timestamp}- title={title}- content={content}+ title={title.current}+ content={content.current}options={{readonly: isReadonly,onRequestFocus: () => toggleProperties(false),@@ -192,6 +197,7 @@ export function Editor(props: EditorProps) {hash: string;src: string;}) => {+ console.log(hash, src);if (groupId?.startsWith("monograph")) return;editor.loadImage(hash, src);}diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.jsindex d547c9579..d06eca16f 100644--- a/apps/web/src/stores/editor-store.js+++ b/apps/web/src/stores/editor-store.js@@ -7,7 +7,6 @@ import { db } from "../common/db";import BaseStore from ".";import { EV, EVENTS } from "notes-core/common";import { hashNavigate } from "../navigation";-import { Mutex } from "async-mutex";const SESSION_STATES = {stale: "stale",diff --git a/apps/web/src/utils/importer.js b/apps/web/src/utils/importer.jsindex 8cf137c4b..bb3c11a06 100644--- a/apps/web/src/utils/importer.js+++ b/apps/web/src/utils/importer.js@@ -39,7 +39,7 @@ async function getNotesFromImport(files) {}async function importNote(note) {- if (note.content.type === "html") note.content.type = "tiny";+ if (note.content.type === "html") note.content.type = "tiptap";else throw new Error("Invalid content type: " + note.content.type);if (note.attachments) await importAttachments(note.attachments);