diff --git a/CHANGELOG.md b/CHANGELOG.md index 547c70edb..4925284f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ ### v3.5.2 / 2020-09-xx +* [744](https://github.com/Vanessa219/vditor/issues/744) IR 模式代码块闪烁 `修复缺陷` * [748](https://github.com/Vanessa219/vditor/issues/748) 数学公式中出现中文不能渲染问题 `修复缺陷` * [738](https://github.com/Vanessa219/vditor/issues/738) IR 模式标题变大变小快捷键及光标位置 `修复缺陷` * [736](https://github.com/Vanessa219/vditor/issues/736) MathJax 数学公式会抖动 `改进功能` diff --git a/src/ts/ir/index.ts b/src/ts/ir/index.ts index feb8744b6..4a54233f8 100644 --- a/src/ts/ir/index.ts +++ b/src/ts/ir/index.ts @@ -90,7 +90,7 @@ class IR { if (this.composingLock) { return; } - input(vditor, getSelection().getRangeAt(0).cloneRange()); + input(vditor, getSelection().getRangeAt(0).cloneRange(), false, event); }); this.element.addEventListener("click", (event: MouseEvent & { target: HTMLInputElement }) => { diff --git a/src/ts/ir/input.ts b/src/ts/ir/input.ts index d31474c61..68d045e45 100644 --- a/src/ts/ir/input.ts +++ b/src/ts/ir/input.ts @@ -9,8 +9,9 @@ import {log} from "../util/log"; import {processCodeRender} from "../util/processCode"; import {getSelectPosition, setRangeByWbr} from "../util/selection"; import {processAfterRender} from "./process"; +import {Constants} from "../constants"; -export const input = (vditor: IVditor, range: Range, ignoreSpace = false) => { +export const input = (vditor: IVditor, range: Range, ignoreSpace = false, event?: InputEvent) => { let blockElement = hasClosestBlock(range.startContainer); // 前后可以输入空格 if (blockElement && !ignoreSpace && blockElement.getAttribute("data-type") !== "code-block") { @@ -132,7 +133,9 @@ export const input = (vditor: IVditor, range: Range, ignoreSpace = false) => { } // firefox 列表回车不会产生新的 list item https://github.com/Vanessa219/vditor/issues/194 html = html.replace("

", "

  • "); - } else if (blockElement.previousElementSibling && blockElement.previousElementSibling.textContent !== "") { + } else if (blockElement.previousElementSibling && + blockElement.previousElementSibling.textContent.replace(Constants.ZWSP, "") !== "" && + event && event.inputType === "insertParagraph") { // 换行时需要处理上一段落 html = blockElement.previousElementSibling.outerHTML + html; blockElement.previousElementSibling.remove();