Răsfoiți Sursa

remove unrelated changes

kosei-n 2 ani în urmă
părinte
comite
1243f70696

+ 0 - 23
packages/editor/src/components/CodeMirrorEditor/CodeMirrorEditor.tsx

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

+ 5 - 9
packages/editor/src/services/codemirror-editor/use-codemirror-editor/utils/insert-text.ts

@@ -1,24 +1,20 @@
 import { useCallback } from 'react';
 
-import { type EditorView } from '@codemirror/view';
+import { EditorView } from '@codemirror/view';
 
-export type InsertText = (text: string, from?: number, to?: number) => void;
+export type InsertText = (text: string) => void;
 
 
 export const useInsertText = (view?: EditorView): InsertText => {
-  return useCallback((text, from?, to?) => {
+  return useCallback((text) => {
     if (view == null) {
       return;
     }
     const insertPos = view.state.selection.main.head;
-
-    const fromPos = from ?? insertPos;
-    const toPos = to ?? insertPos;
-
     view.dispatch({
       changes: {
-        from: fromPos,
-        to: toPos,
+        from: insertPos,
+        to: insertPos,
         insert: text,
       },
       selection: { anchor: insertPos },

+ 0 - 2
packages/editor/src/services/list-util/markdown-list-util.ts

@@ -1,7 +1,5 @@
 import { EditorView } from '@codemirror/view';
 
-export type NewlineAndIndentContinueMarkdownList = ((editor: EditorView) => void) | undefined;
-
 // https://regex101.com/r/7BN2fR/5
 const indentAndMarkRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/;