Skip to content

Commit

Permalink
🐛 #361
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 5, 2020
1 parent 44dcebb commit 7bf742d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ts/ir/expandMarker.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import {hasClosestByClassName, hasTopClosestByClassName} from "../util/hasClosest";

const nextIsNode = (range: Range) => {
if (range.startContainer.nodeType === 3 && range.startContainer.nodeValue.length !== range.startOffset) {
const startContainer = range.startContainer;
if (startContainer.nodeType === 3 && startContainer.nodeValue.length !== range.startOffset) {
return false;
}
let nextNode: HTMLElement = range.startContainer.nextSibling as HTMLElement;

let nextNode: HTMLElement = startContainer.nextSibling as HTMLElement;

while (nextNode && nextNode.textContent === "") {
nextNode = nextNode.nextSibling as HTMLElement;
}

if (!nextNode) {
// *em*|**string**
const markerElement = hasClosestByClassName(range.startContainer, "vditor-ir__marker");
const markerElement = hasClosestByClassName(startContainer, "vditor-ir__marker");
if (markerElement && !markerElement.nextSibling) {
const parentNextNode = range.startContainer.parentElement.parentElement.nextSibling as HTMLElement;
const parentNextNode = startContainer.parentElement.parentElement.nextSibling as HTMLElement;
if (parentNextNode && parentNextNode.nodeType !== 3 &&
parentNextNode.classList.contains("vditor-ir__node")) {
return parentNextNode;
}
}
return false;
} else if (nextNode && nextNode.nodeType !== 3 && nextNode.classList.contains("vditor-ir__node")) {
} else if (nextNode && nextNode.nodeType !== 3 && nextNode.classList.contains("vditor-ir__node") &&
!nextNode.getAttribute("data-block")) {
// test|*em*
return nextNode;
}
Expand Down

0 comments on commit 7bf742d

Please sign in to comment.