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

+ 5 - 3
packages/editor/src/services/list-util/markdown-list-util.ts

@@ -1,7 +1,9 @@
 import type { EditorView } from '@codemirror/view';
 import type { EditorView } from '@codemirror/view';
 
 
-// https://regex101.com/r/7BN2fR/5
-const indentAndMarkRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/;
+// https://regex101.com/r/r9plEA/1
+const indentAndMarkRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]\s))(\s*)/;
+// https://regex101.com/r/HFYoFN/1
+const indentAndMarkOnlyRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/;
 
 
 const getBol = (editor: EditorView) => {
 const getBol = (editor: EditorView) => {
   const curPos = editor.state.selection.main.head;
   const curPos = editor.state.selection.main.head;
@@ -26,7 +28,7 @@ export const adjustPasteData = (strFromBol: string, text: string): string => {
 
 
     const replacedLines = lines?.map((line, index) => {
     const replacedLines = lines?.map((line, index) => {
 
 
-      if (index === 0 && strFromBol.match(indentAndMarkRE)) {
+      if (index === 0 && strFromBol.match(indentAndMarkOnlyRE)) {
         return line.replace(indentAndMarkRE, '');
         return line.replace(indentAndMarkRE, '');
       }
       }