Skip to content

Commit

Permalink
🎨 fix #33 fix #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jan 5, 2020
1 parent 6f6cf5b commit 78cc8ed
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

### v2.0.12 / 2020-01-05

* [32](https://github.com/Vanessa219/vditor/issues/32) 反斜杠转义处理 `修复缺陷`
* [33](https://github.com/Vanessa219/vditor/issues/33) 插入链接优化 `improvement`
* [30](https://github.com/Vanessa219/vditor/issues/30) 添加 option.value `enhancement`
* [29](https://github.com/Vanessa219/vditor/issues/29) 添加 debugger,为开发时显示日志 `enhancement`
Expand Down
6 changes: 6 additions & 0 deletions src/assets/scss/_wysiwyg.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@
details {
white-space: initial;
}

span[data-type="backslash"] > span {
display: none;
color: rgba($toolbarIcon, .36);
}

}
18 changes: 17 additions & 1 deletion src/ts/wysiwyg/highlightToolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import {enableToolbar} from "../toolbar/enableToolbar";
import {removeCurrentToolbar} from "../toolbar/removeCurrentToolbar";
import {setCurrentToolbar} from "../toolbar/setCurrentToolbar";
import {getText} from "../util/getText";
import {hasClosestByClassName, hasClosestByMatchTag, hasClosestByTag, hasTopClosestByTag} from "../util/hasClosest";
import {
hasClosestByAttribute,
hasClosestByClassName,
hasClosestByMatchTag,
hasClosestByTag,
hasTopClosestByTag,
} from "../util/hasClosest";
import {processCodeRender} from "./processCodeRender";

export const highlightToolbar = (vditor: IVditor) => {
Expand Down Expand Up @@ -495,6 +501,16 @@ export const highlightToolbar = (vditor: IVditor) => {
if (!vditor.wysiwyg.element.contains(vditor.wysiwyg.popover)) {
vditor.wysiwyg.element.insertAdjacentElement("beforeend", vditor.wysiwyg.popover);
}

// 反斜杠特殊处理
vditor.wysiwyg.element.querySelectorAll('span[data-type="backslash"] > span').forEach((item: HTMLElement) => {
item.style.display = "none";
});
const backslashElement = hasClosestByAttribute(range.startContainer, "data-type", "backslash");
if (backslashElement) {
backslashElement.querySelector("span").style.display = "inline";
}

}, 500);
};

Expand Down
1 change: 1 addition & 0 deletions src/ts/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ class WYSIWYG {
&& event.key !== "ArrowLeft" && event.key !== "ArrowUp") {
return;
}

// 上下左右遇到块预览的处理
const range = getSelection().getRangeAt(0);
const previewElement = hasClosestByClassName(range.startContainer, "vditor-wysiwyg__preview");
Expand Down

0 comments on commit 78cc8ed

Please sign in to comment.