Skip to content

Commit

Permalink
🎨 fix #744
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Sep 6, 2020
1 parent dae3694 commit 818760f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 数学公式会抖动 `改进功能`
Expand Down
2 changes: 1 addition & 1 deletion src/ts/ir/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
7 changes: 5 additions & 2 deletions src/ts/ir/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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("<div><wbr><br></div>", "<li><p><wbr><br></p></li>");
} 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();
Expand Down

0 comments on commit 818760f

Please sign in to comment.