1
0
Эх сурвалжийг харах

:bug: fix https://github.com/Vanessa219/vditor/issues/1356

Vanessa 2 жил өмнө
parent
commit
7588bfb4bd

+ 1 - 0
CHANGELOG.md

@@ -107,6 +107,7 @@
 
 ### v3.9.1 / 2023-03
 
+* [代码块下一行的标题前输入中文时内容会跑到代码块里面](https://github.com/Vanessa219/vditor/issues/1356) `修复缺陷`
 * [连续插入多个列表,控制台报错](https://github.com/Vanessa219/vditor/issues/1343) `修复缺陷`
 * [IR 模式选择内容设置为代码块时异常](https://github.com/Vanessa219/vditor/issues/1354) `修复缺陷`
 

+ 3 - 0
src/ts/markdown/codeRender.ts

@@ -1,4 +1,5 @@
 import {code160to32} from "../util/code160to32";
+import {Constants} from "../constants";
 
 export const codeRender = (element: HTMLElement) => {
     element.querySelectorAll("pre > code").forEach((e: HTMLElement, index: number) => {
@@ -51,5 +52,7 @@ onclick="this.previousElementSibling.select();document.execCommand('copy');this.
 
         e.before(divElement);
         e.style.maxHeight = (window.outerHeight - 40) + "px";
+        // https://github.com/Vanessa219/vditor/issues/1356
+        e.insertAdjacentHTML("afterend", `<span style="position: absolute">${Constants.ZWSP}</span>`)
     });
 };

+ 1 - 0
src/ts/util/processCode.ts

@@ -64,6 +64,7 @@ export const processCodeRender = (previewPanel: HTMLElement, vditor: IVditor) =>
     }
     const language = previewPanel.firstElementChild.className.replace("language-", "");
     if (!language) {
+        codeRender(previewPanel);
         return;
     }
     if (language === "abc") {