瀏覽代碼

add conditional branches

kosei-n 2 年之前
父節點
當前提交
e94d9aeb6c
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      packages/editor/src/services/paste-util/paste-markdown-util.ts

+ 9 - 1
packages/editor/src/services/paste-util/paste-markdown-util.ts

@@ -35,7 +35,15 @@ export const adjustPasteData = (strFromBol: string, text: string): string => {
       return indent + line;
     });
 
-    adjusted = replacedLines ? replacedLines.join('\n') : '';
+    if (replacedLines == null) {
+      adjusted = '';
+    }
+    else if (replacedLines.length === 1 && !matchResult) {
+      adjusted = `${replacedLines.join('')}\n`;
+    }
+    else {
+      adjusted = replacedLines.join('\n');
+    }
   }
 
   else if (strFromBol.match(indentAndMarkRE)) {