|
@@ -11,7 +11,7 @@ import { GlobalCodeMirrorEditorKey, AcceptedUploadFileType } from '../../consts'
|
|
|
import { useFileDropzone, FileDropzoneOverlay, AllEditorTheme } from '../../services';
|
|
import { useFileDropzone, FileDropzoneOverlay, AllEditorTheme } from '../../services';
|
|
|
import {
|
|
import {
|
|
|
getLineToCursor, adjustPasteData,
|
|
getLineToCursor, adjustPasteData,
|
|
|
- newlineAndIndentContinueMarkdownList,
|
|
|
|
|
|
|
+ useNewlineAndIndentContinueMarkdownList,
|
|
|
} from '../../services/list-util/markdown-list-util';
|
|
} from '../../services/list-util/markdown-list-util';
|
|
|
import { useCodeMirrorEditorIsolated } from '../../stores';
|
|
import { useCodeMirrorEditorIsolated } from '../../stores';
|
|
|
|
|
|
|
@@ -56,17 +56,18 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
|
|
|
}, [onChange]);
|
|
}, [onChange]);
|
|
|
const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(editorKey, containerRef.current, cmProps);
|
|
const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(editorKey, containerRef.current, cmProps);
|
|
|
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- const editor = codeMirrorEditor?.view;
|
|
|
|
|
|
|
+ const editor = codeMirrorEditor?.view;
|
|
|
|
|
+
|
|
|
|
|
+ const newlineAndIndentContinueMarkdownList = useNewlineAndIndentContinueMarkdownList(editor);
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
const handleEnterKey = (event: KeyboardEvent) => {
|
|
const handleEnterKey = (event: KeyboardEvent) => {
|
|
|
if (event.key === 'Enter') {
|
|
if (event.key === 'Enter') {
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
- const editor = codeMirrorEditor?.view;
|
|
|
|
|
if (editor == null) {
|
|
if (editor == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- newlineAndIndentContinueMarkdownList(editor);
|
|
|
|
|
|
|
+ newlineAndIndentContinueMarkdownList?.(editor);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -75,7 +76,7 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
|
|
|
return () => {
|
|
return () => {
|
|
|
editor?.dom.removeEventListener('keydown', handleEnterKey);
|
|
editor?.dom.removeEventListener('keydown', handleEnterKey);
|
|
|
};
|
|
};
|
|
|
- }, [codeMirrorEditor]);
|
|
|
|
|
|
|
+ }, [codeMirrorEditor, editor, newlineAndIndentContinueMarkdownList]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (indentSize == null) {
|
|
if (indentSize == null) {
|