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

restore code that handle different line breaks

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

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

@@ -16,6 +16,8 @@ export const getStrFromBol = (editor: EditorView): string => {
 
 
 export const adjustPasteData = (indentAndMark: string, text: string): string => {
 export const adjustPasteData = (indentAndMark: string, text: string): string => {
 
 
+  let adjusted;
+
   if (text.match(indentAndMarkRE)) {
   if (text.match(indentAndMarkRE)) {
     const matchResult = indentAndMark.match(indentAndMarkRE);
     const matchResult = indentAndMark.match(indentAndMarkRE);
     const indent = matchResult ? matchResult[1] : '';
     const indent = matchResult ? matchResult[1] : '';
@@ -31,10 +33,14 @@ export const adjustPasteData = (indentAndMark: string, text: string): string =>
       return indent + line;
       return indent + line;
     });
     });
 
 
-    const adjusted = replacedLines ? replacedLines.join('\n') : '';
+    adjusted = replacedLines ? replacedLines.join('\n') : '';
+  }
+
+  else {
+    const replacedText = text.replace(/(\r\n|\r|\n)/g, `$1${indentAndMark}`);
 
 
-    return adjusted;
+    adjusted = replacedText;
   }
   }
 
 
-  return text;
+  return adjusted;
 };
 };