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
fix: editor & title doesn't update for new notes
thecodrr2b2da1609d47
diff --git a/apps/web/src/common/toolbar-config.ts b/apps/web/src/common/toolbar-config.tsindex 470ee55b9..5df00ac4c 100644--- a/apps/web/src/common/toolbar-config.ts+++ b/apps/web/src/common/toolbar-config.ts@@ -9,7 +9,7 @@ export type Preset = {tools: ToolbarGroupDefinition[];};const presets: Record<PresetId, Preset> = {- default: { id: "default", title: "Default", tools: DEFAULT_TOOLS.slice(1) },+ default: { id: "default", title: "Default", tools: DEFAULT_TOOLS },minimal: {id: "minimal",title: "Minimal",diff --git a/apps/web/src/components/dialogs/toolbar-config-dialog.tsx b/apps/web/src/components/dialogs/toolbar-config-dialog.tsxindex eac4ab68d..a3b93eebb 100644--- a/apps/web/src/components/dialogs/toolbar-config-dialog.tsx+++ b/apps/web/src/components/dialogs/toolbar-config-dialog.tsx@@ -58,7 +58,11 @@ export function ToolbarConfigDialog(props: ToolbarConfigDialogProps) {const { setToolbarConfig } = useToolbarConfig();useEffect(() => {- const items = flatten(currentPreset.tools);+ const items = flatten(+ currentPreset.id === "default"+ ? currentPreset.tools.slice(1)+ : currentPreset.tools+ );items.push(createTrash());setItems(items);}, [currentPreset]);diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsxindex ebd59da4d..6db6490b8 100644--- a/apps/web/src/components/editor/index.tsx+++ b/apps/web/src/components/editor/index.tsx@@ -61,7 +61,9 @@ export default function EditorManager({const isOldSession = !nonce && !!noteId;const [content, setContent] = useState<string>("");+ const [timestamp, setTimestamp] = useState<number>(0);const [title, setTitle] = useState<string>("");+const arePropertiesVisible = useStore((store) => store.arePropertiesVisible);const toggleProperties = useStore((store) => store.toggleProperties);const isPreviewMode = useStore(@@ -76,10 +78,13 @@ export default function EditorManager({useEffect(() => {if (!isNewSession) return;+(async function () {await editorstore.newSession(nonce);+setContent("");setTitle("");+ setTimestamp(Date.now());})();}, [isNewSession, nonce]);@@ -89,6 +94,7 @@ export default function EditorManager({(async function () {const content = await editorstore.get().getSessionContent();setContent(content?.data);+ setTimestamp(Date.now());if (noteId && content) await db.attachments?.downloadImages(noteId);})();}, [noteId, isPreviewMode]);@@ -104,6 +110,7 @@ export default function EditorManager({setTitle(session.title);setContent(content?.data);+ setTimestamp(Date.now());if (noteId && content) await db.attachments?.downloadImages(noteId);})();}, [noteId, isOldSession]);@@ -122,6 +129,7 @@ export default function EditorManager({>{isPreviewMode && <PreviewModeNotice />}<Editor+ nonce={timestamp}title={title}content={content}readonly={isReadonly}@@ -137,11 +145,12 @@ type EditorProps = {title: string;readonly?: boolean;focusMode?: boolean;+ nonce?: number;content: string;onRequestFocus?: () => void;};function Editor(props: EditorProps) {- const { content, readonly, focusMode, onRequestFocus, title } = props;+ const { content, readonly, focusMode, onRequestFocus, title, nonce } = props;const editor = useEditorInstance();const isMobile = useMobile();@@ -215,6 +224,7 @@ function Editor(props: EditorProps) {/>)}<Titlebox+ nonce={nonce}readonly={readonly || false}setTitle={(title) => {const { sessionId, id } = editorstore.get().session;@@ -224,6 +234,7 @@ function Editor(props: EditorProps) {/><Header readonly={readonly} /><Tiptap+ nonce={nonce}readonly={readonly}toolbarContainerId="editorToolbar"content={content}diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsxindex aad46d83c..4ad00301d 100644--- a/apps/web/src/components/editor/tiptap.tsx+++ b/apps/web/src/components/editor/tiptap.tsx@@ -21,6 +21,7 @@ type TipTapProps = {content?: string;toolbarContainerId?: string;readonly?: boolean;+ nonce?: number;};function TipTap(props: TipTapProps) {@@ -33,6 +34,7 @@ function TipTap(props: TipTapProps) {toolbarContainerId,editorContainer,readonly,+ nonce,} = props;const theme: Theme = useTheme();@@ -85,7 +87,7 @@ function TipTap(props: TipTapProps) {return true;},},- [content, readonly]+ [readonly, nonce]);useEffect(() => {diff --git a/apps/web/src/components/editor/title-box.tsx b/apps/web/src/components/editor/title-box.tsxindex eed73d02a..0dcf74a36 100644--- a/apps/web/src/components/editor/title-box.tsx+++ b/apps/web/src/components/editor/title-box.tsx@@ -2,20 +2,19 @@ import React, { useEffect, useState } from "react";import { Input } from "@rebass/forms";type TitleBoxProps = {+ nonce?: number;readonly: boolean;title: string;setTitle: (title: string) => void;};function TitleBox(props: TitleBoxProps) {- const { readonly, setTitle, title } = props;+ const { readonly, setTitle, title, nonce } = props;const [currentTitle, setCurrentTitle] = useState<string>();useEffect(() => {- // if (currentTitle !== title) setPlaceholder(title);- // We do not want to update when currentTitle changes.setCurrentTitle(title);- }, [title]);+ }, [nonce]);return (<Input@@ -43,7 +42,6 @@ function TitleBox(props: TitleBoxProps) {export default React.memo(TitleBox, (prevProps, nextProps) => {return (prevProps.readonly === nextProps.readonly &&- prevProps.title === nextProps.title &&- prevProps.setTitle === nextProps.setTitle+ prevProps.nonce === nextProps.nonce);});