Jelajahi Sumber

currentIndent can change indent size

reiji-h 2 tahun lalu
induk
melakukan
742e1682c7
1 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 6 1
      apps/app/src/components/PageEditor/PageEditor.tsx

+ 6 - 1
apps/app/src/components/PageEditor/PageEditor.tsx

@@ -116,7 +116,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
   const { mutate: mutateRemoteRevisionLastUpdateUser } = useRemoteRevisionLastUpdateUser();
 
   const { data: codemirrorEditor } = useCodeMirrorEditorMain(codeMirrorEditorContainerRef.current);
-  const { initDoc, focus: focusToEditor, setCaretLine } = codemirrorEditor ?? {};
+  const { initDoc, focus: focusToEditor, setCaretLine, setIndentSize } = codemirrorEditor ?? {};
 
   const { data: rendererOptions } = usePreviewOptions();
   const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
@@ -527,6 +527,11 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
     }
   }, [editorMode, focusToEditor]);
 
+  // Set indent size by current indent
+  useEffect(() => {
+    setIndentSize(currentIndentSize);
+  }, [setIndentSize, currentIndentSize]);
+
   // Detect indent size from contents (only when users are allowed to change it)
   useEffect(() => {
     // do nothing if the indent size fixed