|
|
@@ -5,8 +5,6 @@ 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';
|
|
|
import { CodeMirrorEditorMain, GlobalCodeMirrorEditorKey, useCodeMirrorEditorIsolated } from '@growi/editor';
|
|
|
@@ -21,6 +19,7 @@ import { toastError, toastSuccess } from '~/client/util/toastr';
|
|
|
import { OptionsToSave } from '~/interfaces/page-operation';
|
|
|
import { SocketEventName } from '~/interfaces/websocket';
|
|
|
import {
|
|
|
+ useDefaultIndentSize,
|
|
|
useCurrentPathname, useIsEnabledAttachTitleHeader,
|
|
|
useIsEditable, useIsUploadableFile, useIsUploadableImage, useIsIndentSizeForced,
|
|
|
} from '~/stores/context';
|
|
|
@@ -105,6 +104,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
const { data: isSlackEnabled } = useIsSlackEnabled();
|
|
|
const { data: isIndentSizeForced } = useIsIndentSizeForced();
|
|
|
const { data: currentIndentSize, mutate: mutateCurrentIndentSize } = useCurrentIndentSize();
|
|
|
+ const { data: defaultIndentSize } = useDefaultIndentSize();
|
|
|
const { data: isUploadableFile } = useIsUploadableFile();
|
|
|
const { data: isUploadableImage } = useIsUploadableImage();
|
|
|
const { data: conflictDiffModalStatus, close: closeConflictDiffModal } = useConflictDiffModal();
|
|
|
@@ -532,17 +532,6 @@ 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, 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(() => {
|
|
|
@@ -585,6 +574,7 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
<CodeMirrorEditorMain
|
|
|
onChange={markdownChangedHandler}
|
|
|
onSave={saveWithShortcut}
|
|
|
+ indentSize={currentIndentSize ?? defaultIndentSize}
|
|
|
/>
|
|
|
</div>
|
|
|
<div className="page-editor-preview-container flex-expand-vert d-none d-lg-flex">
|