|
|
@@ -5,7 +5,7 @@ import {
|
|
|
import { AcceptedUploadFileType } from '@growi/core';
|
|
|
import { toast } from 'react-toastify';
|
|
|
|
|
|
-import { GlobalCodeMirrorEditorKey } from '../../consts';
|
|
|
+import { EditorSettings, GlobalCodeMirrorEditorKey } from '../../consts';
|
|
|
import type { EditorTheme, KeyMapMode } from '../../services';
|
|
|
import { useCodeMirrorEditorIsolated } from '../../stores';
|
|
|
import { CodeMirrorEditorMain } from '../CodeMirrorEditorMain';
|
|
|
@@ -18,6 +18,7 @@ export const Playground = (): JSX.Element => {
|
|
|
const [markdownToPreview, setMarkdownToPreview] = useState('');
|
|
|
const [editorTheme, setEditorTheme] = useState<EditorTheme>('defaultlight');
|
|
|
const [editorKeymap, setEditorKeymap] = useState<KeyMapMode>('default');
|
|
|
+ const [editorSettings, setEditorSettings] = useState<EditorSettings>();
|
|
|
|
|
|
const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(GlobalCodeMirrorEditorKey.MAIN);
|
|
|
|
|
|
@@ -34,6 +35,15 @@ export const Playground = (): JSX.Element => {
|
|
|
codeMirrorEditor?.setCaretLine();
|
|
|
}, [codeMirrorEditor]);
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ setEditorSettings({
|
|
|
+ theme: editorTheme,
|
|
|
+ keymapMode: editorKeymap,
|
|
|
+ styleActiveLine: true,
|
|
|
+ autoFormatMarkdownTable: true,
|
|
|
+ });
|
|
|
+ }, [setEditorSettings, editorKeymap, editorTheme]);
|
|
|
+
|
|
|
// set handler to save with shortcut key
|
|
|
const saveHandler = useCallback(() => {
|
|
|
// eslint-disable-next-line no-console
|
|
|
@@ -65,8 +75,7 @@ export const Playground = (): JSX.Element => {
|
|
|
onUpload={uploadHandler}
|
|
|
indentSize={4}
|
|
|
acceptedUploadFileType={AcceptedUploadFileType.ALL}
|
|
|
- editorTheme={editorTheme}
|
|
|
- editorKeymap={editorKeymap}
|
|
|
+ editorSettings={editorSettings}
|
|
|
/>
|
|
|
</div>
|
|
|
<div className="flex-expand-vert d-none d-lg-flex bg-light text-dark border-start border-dark-subtle p-3">
|