Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleInput: function (e) {
const sel = MediumEditor.selection.getSelectionRange(this.document);
const start = sel.startContainer;
const node = getOuter(start);
const offset = MediumEditor.selection.exportSelection(node, document).start;
const lastChar = node.textContent.charAt(offset - 1);
for(let t of this.triggers) {
if(t.key === lastChar) {
t.handler(node, offset);
break;
}
}
},
});
handleInput: function (e) {
const sel = MediumEditor.selection.getSelectionRange(this.document);
const start = sel.startContainer;
const node = getOuter(start);
const offset = MediumEditor.selection.exportSelection(node, document).start;
const lastChar = node.textContent.charAt(offset - 1);
for(let t of this.triggers) {
if(t.key === lastChar) {
t.handler(node, offset);
break;
}
}
},
});
handleBeforeInput(e) {
if (e.ctrlKey || e.metaKey || e.altKey || e.keyCode !== 222) {
return;
};
e.preventDefault();
const sel = MediumEditor.selection.getSelectionRange(this.medium.options.ownerDocument);
if (sel.collapsed && sel.startOffset === sel.endOffset) {
let pastable = '';
const nodeText = sel.startContainer.textContent.replace(/\u00a0/g, " ");
if (sel.startContainer.textContent === '' || sel.startOffset === 0 || nodeText[sel.startOffset - 1] === ' ') {
if (e.shiftKey) {
pastable = '“';
} else {
pastable = '‘';
}
} else if (nodeText[sel.startOffset - 1] !== ' ') {
if (e.shiftKey) {
pastable = '”';
} else {
pastable = '’';
}
} else {