Просмотр исходного кода

fix behavior when line breaks occur at indented locations

kosei-n 2 лет назад
Родитель
Сommit
f2a696ecaf
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      packages/editor/src/services/list-util/markdown-list-util.ts

+ 4 - 1
packages/editor/src/services/list-util/markdown-list-util.ts

@@ -14,7 +14,7 @@ export const getLineToCursor = (editor: EditorView, lineNumBeforeCursor = 0): st
   const curPos = editor.state.selection.main.head;
   const firstLineNumToGet = editor.state.doc.lineAt(curPos).number - lineNumBeforeCursor;
 
-  const fixedFirstLineNumToGet = Math.max(firstLineNumToGet, 0);
+  const fixedFirstLineNumToGet = Math.max(firstLineNumToGet, 1);
 
   const firstLineToGet = editor.state.doc.line(fixedFirstLineNumToGet).from;
 
@@ -37,6 +37,9 @@ export const useNewlineAndIndentContinueMarkdownList = (editor?: EditorView): Ne
       const indentAndMark = matchResult[0];
       insertText(indentAndMark, lineStartPos, curPos);
     }
+    else {
+      insertText('', lineStartPos, curPos);
+    }
   }, [insertText]);
 
   if (editor == null) {