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

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

@@ -46,19 +46,19 @@ export const useNewlineAndIndentContinueMarkdownList = (editor?: EditorView): Ne
   return () => { NewlineAndIndentContinueMarkdownList(editor) };
 };
 
-export const adjustPasteData = (indentAndMark: string, text: string): string => {
+export const adjustPasteData = (strFromBol: string, text: string): string => {
 
-  let adjusted;
+  let adjusted = text;
 
   if (text.match(indentAndMarkRE)) {
-    const matchResult = indentAndMark.match(indentAndMarkRE);
+    const matchResult = strFromBol.match(indentAndMarkRE);
     const indent = matchResult ? matchResult[1] : '';
 
     const lines = text.match(/[^\r\n]+/g);
 
     const replacedLines = lines?.map((line, index) => {
 
-      if (index === 0 && indentAndMark.match(indentAndMarkRE)) {
+      if (index === 0 && strFromBol.match(indentAndMarkRE)) {
         return line.replace(indentAndMarkRE, '');
       }
 
@@ -68,8 +68,8 @@ export const adjustPasteData = (indentAndMark: string, text: string): string =>
     adjusted = replacedLines ? replacedLines.join('\n') : '';
   }
 
-  else {
-    const replacedText = text.replace(/(\r\n|\r|\n)/g, `$1${indentAndMark}`);
+  else if (strFromBol.match(indentAndMarkRE)) {
+    const replacedText = text.replace(/(\r\n|\r|\n)/g, `$1${strFromBol}`);
 
     adjusted = replacedText;
   }