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: updating title placeholder on save note
Ammar Ahmedfa35ba919004
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsxindex d7911aa7f..f8a14149d 100644--- a/packages/editor-mobile/src/components/editor.tsx+++ b/packages/editor-mobile/src/components/editor.tsx@@ -118,6 +118,7 @@ const Tiptap = () => {const update = () => {setTick((tick) => tick + 1);setLayout(false);+ controller.setTitlePlaceholder("Note title");setImmediate(() => setLayout(true));};@@ -167,6 +168,7 @@ const Tiptap = () => {<><Tags /><Title+ titlePlaceholder={controller.titlePlaceholder}readonly={settings.readonly}controller={controllerRef}title={controller.title}diff --git a/packages/editor-mobile/src/components/title.tsx b/packages/editor-mobile/src/components/title.tsxindex 218e9e6fe..91b9ea7fa 100644--- a/packages/editor-mobile/src/components/title.tsx+++ b/packages/editor-mobile/src/components/title.tsx@@ -5,10 +5,12 @@ import styles from "./styles.module.css";function Title({controller,title,+ titlePlaceholder,readonly,}: {controller: RefObject<EditorController>;title: string;+ titlePlaceholder: string;readonly: boolean;}) {const titleRef = useRef<HTMLInputElement>(null);@@ -46,13 +48,14 @@ function Title({if (!emitUpdate.current) return;controller.current?.titleChange(event.target.value);}}- placeholder="Note title"+ placeholder={titlePlaceholder}/>);}export default React.memo(Title, (prev, next) => {if (prev.title !== next.title) return false;+ if (prev.titlePlaceholder !== next.titlePlaceholder) return false;if (prev.readonly !== next.readonly) return false;return true;});diff --git a/packages/editor-mobile/src/hooks/useEditorController.ts b/packages/editor-mobile/src/hooks/useEditorController.tsindex 312d714cd..cae78f2fe 100644--- a/packages/editor-mobile/src/hooks/useEditorController.ts+++ b/packages/editor-mobile/src/hooks/useEditorController.ts@@ -43,6 +43,8 @@ export type EditorController = {downloadAttachment: (attachment: Attachment) => void;content: MutableRefObject<string | null>;onUpdate: () => void;+ titlePlaceholder: string;+ setTitlePlaceholder: React.Dispatch<React.SetStateAction<string>>;};export function useEditorController(@@ -50,6 +52,7 @@ export function useEditorController(update: () => void): EditorController {const [title, setTitle] = useState("");+ const [titlePlaceholder, setTitlePlaceholder] = useState("Note title");const htmlContentRef = useRef<string | null>(null);const timers = useRef<Timers>({selectionChange: null,@@ -141,6 +144,7 @@ export function useEditorController(setTitle(value);break;case "native:titleplaceholder":+ setTitlePlaceholder(value);break;case "native:status":break;@@ -191,6 +195,8 @@ export function useEditorController(scroll,title,setTitle,+ titlePlaceholder,+ setTitlePlaceholder,openFilePicker,downloadAttachment,content: htmlContentRef,