reiji-h 2 лет назад
Родитель
Сommit
736c538352
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      apps/app/src/components/PageEditor/PageEditor.tsx

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

@@ -5,6 +5,7 @@ import React, {
 import EventEmitter from 'events';
 import nodePath from 'path';
 
+import { indentUnit } from '@codemirror/language';
 import { keymap } from '@codemirror/view';
 import type { IPageHasId } from '@growi/core';
 import { pathUtils } from '@growi/core/dist/utils';
@@ -549,6 +550,17 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
     }
   }, [initialValue, isIndentSizeForced, mutateCurrentIndentSize]);
 
+  // Change indentUnit size
+  useEffect(() => {
+    const extension = indentUnit.of(' '.repeat(currentIndentSize ?? 4));
+
+    const cleanupFunction = codeMirrorEditor?.appendExtension(extension);
+
+    return cleanupFunction;
+
+  }, [codeMirrorEditor, saveWithShortcut, currentIndentSize]);
+
+
   // when transitioning to a different page, if the initialValue is the same,
   // UnControlled CodeMirror value does not reset, so explicitly set the value to initialValue
   const onRouterChangeComplete = useCallback(() => {