Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
range.setStart(range.startContainer, this.wordStart);
range.setEnd(range.startContainer, nextWordEnd);
// Instead, insert our own version of it.
// TODO: Not sure why, but using <span> tag doens't work here
const element = this.document.createElement(this.tagName);
element.classList.add(this.triggerClassName);
if (this.extraTriggerClassName) {
element.classList.add(this.extraTriggerClassName);
}
this.activeMentionAt = element;
//
range.surroundContents(element);
selection.removeAllRanges();
selection.addRange(range);
//
MediumEditor.selection.select(
this.document,
this.activeMentionAt.firstChild,
this.word.length
);
}
this.activeMentionAt.classList.add(this.activeTriggerClassName);
if (this.extraActiveTriggerClassName) {
this.activeMentionAt.classList.add(this.extraActiveTriggerClassName);
}
},
</span>
}
const lastEmptyWord = last(firstChild.textContent);
const hasLastEmptyWord = lastEmptyWord.trim().length === 0;
if (hasLastEmptyWord) {
const { textContent } = firstChild;
firstChild.textContent = textContent.substr(0, textContent.length - 1);
textNode.textContent = `${lastEmptyWord}${textNode.textContent}`;
} else {
if (textNode.textContent.length === 0 && firstChild.textContent.length > 1) {
textNode.textContent = `\u00A0`;
}
}
if (isArrowTowardsLeft) {
MediumEditor.selection.select(this.document, textNode, textNode.length);
} else {
MediumEditor.selection.select(this.document, textNode, Math.min(textNode.length, 1));
}
if (firstChild.textContent.length <= 1) {
// LIKE core#execAction
this.base.saveSelection();
unwrapForTextNode(this.activeMentionAt, this.document);
this.base.restoreSelection();
}
//
this.activeMentionAt = null;
}
},