Преглед на файлове

add handler to set caret line

Yuki Takei преди 2 години
родител
ревизия
f7e3e2ef05
променени са 1 файла, в които са добавени 13 реда и са изтрити 0 реда
  1. 13 0
      apps/app/src/components/PageEditor/PageEditor.tsx

+ 13 - 0
apps/app/src/components/PageEditor/PageEditor.tsx

@@ -390,6 +390,19 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
     }
   }, [initialValue, isIndentSizeForced, mutateCurrentIndentSize]);
 
+  // set handler to set caret line
+  useEffect(() => {
+    const handler = (lineNumber?: number) => {
+      codeMirrorEditor?.setCaretLine(lineNumber);
+
+      // TODO: scroll to the caret line
+    };
+    globalEmitter.on('setCaretLine', handler);
+
+    return function cleanup() {
+      globalEmitter.removeListener('setCaretLine', handler);
+    };
+  }, [codeMirrorEditor]);
 
   // TODO: Check the reproduction conditions that made this code necessary and confirm reproduction
   // // when transitioning to a different page, if the initialValue is the same,