Skip to content

Commit

Permalink
🐛 fix #681
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Aug 5, 2020
1 parent 2d9c7b2 commit 8853a31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

### v3.4.4 / 2020-08-xx

* [681](https://github.com/Vanessa219/vditor/pull/681) 修正 ExpandMarker 规则,避免无法取消选中区域 `修复缺陷`

### v3.4.3 / 2020-08-03

Expand Down
5 changes: 5 additions & 0 deletions src/ts/ir/expandMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export const expandMarker = (range: Range, vditor: IVditor) => {
vditor.ir.element.querySelectorAll(".vditor-ir__node--expand").forEach((item) => {
item.classList.remove("vditor-ir__node--expand");
});

if (!range.collapsed) {
return;
}

const nodeElement = hasTopClosestByClassName(range.startContainer, "vditor-ir__node");
if (nodeElement) {
nodeElement.classList.add("vditor-ir__node--expand");
Expand Down
10 changes: 9 additions & 1 deletion src/ts/ir/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,15 @@ class IR {
}
}

expandMarker(range, vditor);
if (range.toString() === "") {
expandMarker(range, vditor);
} else {
// 当点击选中区域时 eventTarget 与 range 不一致,需延迟等待 range 发生变化
setTimeout(() => {
expandMarker(getEditorRange(this.element), vditor);
});
}

highlightToolbarIR(vditor);
});

Expand Down

0 comments on commit 8853a31

Please sign in to comment.