Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jun 21, 2017
1 parent e824bd5 commit 2ae58c8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions blots/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ class InlineEmbed extends Embed {
}

restore(node) {
let range, text, textNode;
let range, textNode;
let text = node.data.split(GUARD_TEXT).join('');
if (node === this.leftGuard) {
text = this.leftGuard.data.split(GUARD_TEXT).join('');
if (this.prev instanceof TextBlot) {
this.prev.insertAt(this.prev.length(), text);
let prevLength = this.prev.length();
this.prev.insertAt(prevLength, text);
range = {
startNode: this.prev.domNode,
startOffset: this.prev.domNode.data.length
startOffset: prevLength + text.length
};
} else {
textNode = document.createTextNode(text);
Expand All @@ -46,9 +47,7 @@ class InlineEmbed extends Embed {
startOffset: text.length
};
}
this.leftGuard.data = GUARD_TEXT;
} else if (node === this.rightGuard) {
text = this.rightGuard.data.split(GUARD_TEXT).join('');
if (this.next instanceof TextBlot) {
this.next.insertAt(0, text);
range = {
Expand All @@ -63,8 +62,8 @@ class InlineEmbed extends Embed {
startOffset: text.length
};
}
this.rightGuard.data = GUARD_TEXT;
}
node.data = GUARD_TEXT;
return range;
}

Expand Down

0 comments on commit 2ae58c8

Please sign in to comment.