Skip to content

Commit

Permalink
🐛 fix #1263
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Aug 4, 2022
1 parent e88288a commit e7a4f6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -105,6 +105,7 @@

### v3.8.16 / 2022-08

* [1263](https://github.com/Vanessa219/vditor/issues/1263) 所见即所得和即使渲染只有空格输入时,不会触发 input 事件 `修复缺陷`
* [1264](https://github.com/Vanessa219/vditor/issues/1264) 链接中,会强制将&reg解析为 ® 字符 `修复缺陷`
* [1242](https://github.com/Vanessa219/vditor/issues/1242) 在即时渲染模式下表格源文件未对齐 `改进功能`

Expand Down
7 changes: 7 additions & 0 deletions src/ts/ir/input.ts
Expand Up @@ -11,6 +11,7 @@ import {processCodeRender} from "../util/processCode";
import {getSelectPosition, setRangeByWbr} from "../util/selection";
import {renderToc} from "../util/toc";
import {processAfterRender} from "./process";
import {getMarkdown} from "../markdown/getMarkdown";

export const input = (vditor: IVditor, range: Range, ignoreSpace = false, event?: InputEvent) => {
let blockElement = hasClosestBlock(range.startContainer);
Expand Down Expand Up @@ -51,6 +52,9 @@ export const input = (vditor: IVditor, range: Range, ignoreSpace = false, event?
}

if (startSpace) {
if (typeof vditor.options.input === "function") {
vditor.options.input(getMarkdown(vditor));
}
return;
}
if (endSpace) {
Expand All @@ -63,6 +67,9 @@ export const input = (vditor: IVditor, range: Range, ignoreSpace = false, event?
// FireFox https://github.com/Vanessa219/vditor/issues/239
previousNode.classList.remove("vditor-ir__node--expand");
}
if (typeof vditor.options.input === "function") {
vditor.options.input(getMarkdown(vditor));
}
return;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/ts/wysiwyg/index.ts
Expand Up @@ -28,6 +28,7 @@ import {genImagePopover, genLinkRefPopover, highlightToolbarWYSIWYG} from "./hig
import {getRenderElementNextNode, modifyPre} from "./inlineTag";
import {input} from "./input";
import {showCode} from "./showCode";
import {getMarkdown} from "../markdown/getMarkdown";

class WYSIWYG {
public range: Range;
Expand Down Expand Up @@ -389,6 +390,9 @@ class WYSIWYG {
if ((startSpace && blockElement.getAttribute("data-type") !== "code-block")
|| endSpace || isHeadingMD(blockElement.innerHTML) ||
(isHrMD(blockElement.innerHTML) && blockElement.previousElementSibling)) {
if (typeof vditor.options.input === "function") {
vditor.options.input(getMarkdown(vditor));
}
return;
}

Expand Down

0 comments on commit e7a4f6a

Please sign in to comment.