Browse Source

fix behavior when line breaks occur at indented locations

kosei-n 2 years ago
parent
commit
f2a696ecaf
1 changed files with 4 additions and 1 deletions
  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 curPos = editor.state.selection.main.head;
   const firstLineNumToGet = editor.state.doc.lineAt(curPos).number - lineNumBeforeCursor;
   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;
   const firstLineToGet = editor.state.doc.line(fixedFirstLineNumToGet).from;
 
 
@@ -37,6 +37,9 @@ export const useNewlineAndIndentContinueMarkdownList = (editor?: EditorView): Ne
       const indentAndMark = matchResult[0];
       const indentAndMark = matchResult[0];
       insertText(indentAndMark, lineStartPos, curPos);
       insertText(indentAndMark, lineStartPos, curPos);
     }
     }
+    else {
+      insertText('', lineStartPos, curPos);
+    }
   }, [insertText]);
   }, [insertText]);
 
 
   if (editor == null) {
   if (editor == null) {