Skip to content

Commit

Permalink
fix issue:避免 nodeElement 内的文本无法被选中
Browse files Browse the repository at this point in the history
  • Loading branch information
zTreeAPI authored and Vanessa219 committed Aug 7, 2020
1 parent c6ab3b2 commit 1edf8e1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ts/ir/expandMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ export const expandMarker = (range: Range, vditor: IVditor) => {
item.classList.remove("vditor-ir__node--expand");
});

if (!range.collapsed) {

const nodeElement = hasTopClosestByClassName(range.startContainer, "vditor-ir__node");
const nodeElementEnd = !range.collapsed && hasTopClosestByClassName(range.endContainer, "vditor-ir__node");
// 选中文本为同一个 nodeElement 内时,需要展开
if (!range.collapsed && (!nodeElement || nodeElement !== nodeElementEnd)) {
return;
}

const nodeElement = hasTopClosestByClassName(range.startContainer, "vditor-ir__node");

if (nodeElement) {
nodeElement.classList.add("vditor-ir__node--expand");
nodeElement.classList.remove("vditor-ir__node--hidden");
Expand Down

0 comments on commit 1edf8e1

Please sign in to comment.