Browse Source

add a side effect to initialize caret line

Yuki Takei 3 years ago
parent
commit
8f3bd20315
1 changed files with 7 additions and 0 deletions
  1. 7 0
      packages/app/src/components/PageEditor.tsx

+ 7 - 0
packages/app/src/components/PageEditor.tsx

@@ -300,6 +300,13 @@ const PageEditor = (props: Props): JSX.Element => {
     appContainer.registerComponentInstance('PageEditor', pageEditorInstance);
   }, [appContainer, markdown]);
 
+  // initial caret line
+  useEffect(() => {
+    if (editorRef.current != null) {
+      editorRef.current.setCaretLine(0);
+    }
+  }, []);
+
   // set handler to set caret line
   useEffect(() => {
     const handler = (line) => {