Skip to content

Commit

Permalink
🐛 #100 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Feb 4, 2020
1 parent d9534fb commit 145b210
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
### v2.1.9 / 2020-02-04

* [101](https://github.com/Vanessa219/vditor/issues/101) 提供 setTheme(theme: "dark" | "classic") 方法 `改进功能`
* [100](https://github.com/Vanessa219/vditor/issues/100) inline-math `修复缺陷`
* [99](https://github.com/Vanessa219/vditor/issues/99) a 中斜体/粗体时 toolbar 不显示 `修复缺陷`
* [96](https://github.com/Vanessa219/vditor/issues/96) 所见即所得模式下的任务列表Bug `修复缺陷`
* [95](https://github.com/Vanessa219/vditor/issues/95) setVaule 和 初始化时,不触发 input 事件 `改进功能`
Expand Down
14 changes: 0 additions & 14 deletions src/ts/wysiwyg/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@ export const input = (event: IHTMLInputEvent, vditor: IVditor, range: Range) =>
blockElement = vditor.wysiwyg.element;
}

// 修正光标位于 inline math/html 前,按下删除按钮 code 中内容会被删除
blockElement.querySelectorAll('.vditor-wysiwyg__block[data-type$="-inline"]').forEach((item) => {
if (!item.querySelector("code")) {
const previewElement = item.querySelector(".vditor-wysiwyg__preview");
if (item.getAttribute("data-type") === "html-inline") {
previewElement.insertAdjacentHTML("beforebegin", `<code data-type="html-inline">${
item.querySelector(".vditor-wysiwyg__preview").getAttribute("data-html")}</code>`);
} else {
previewElement.insertAdjacentHTML("beforebegin", `<code data-type="math-inline">${
item.querySelector(".vditor-math").getAttribute("data-math")}</code>`);
}
}
});

const renderElement = hasClosestByClassName(range.startContainer, "vditor-wysiwyg__block");
const codeElement = hasClosestByTag(range.startContainer, "CODE");
if (codeElement && renderElement && renderElement.getAttribute("data-block") === "0") {
Expand Down
11 changes: 11 additions & 0 deletions src/ts/wysiwyg/processKeydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,17 @@ export const processKeydown = (vditor: IVditor, event: KeyboardEvent) => {
return true;
}
}

if (blockElement) {
const inlineCodeRenderElements = blockElement.querySelectorAll("span.vditor-wysiwyg__block");
if (inlineCodeRenderElements.length > 0) {
// 修正光标位于 inline math/html 前,按下删除按钮 code 中内容会被删除
inlineCodeRenderElements.forEach((item) => {
(item.firstElementChild as HTMLElement).style.display = "inline";
(item.lastElementChild as HTMLElement).style.display = "none";
});
}
}
}

// 除 table 自动完成、cell 内换行、table 添加新行/列、代码块语言切换、block render 换行、跳出/逐层跳出 blockquote、h6 换行、
Expand Down
3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ module.exports = [
filename: '[name].css',
}),
new WebpackOnBuildPlugin(() => {
fs.unlinkSync('./dist/index.classic.js')
fs.unlinkSync('./dist/index.dark.js')
fs.unlinkSync('./dist/index.js')
}),
new CopyPlugin([
{from: 'src/images', to: 'images'},
Expand Down

0 comments on commit 145b210

Please sign in to comment.