Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleEditableMouseover: function (event) {
const target = MediumEditor.util.getClosestTag(event.target, 'a');
if (target === false) {
return null
}
// Detect empty href attributes
// The browser will make href="" or href="#top"
// into absolute urls when accessed as event.target.href, so check the html
if (!this.showOnEmptyLinks && (!/href=["']\S+["']/.test(target.outerHTML) || /href=["']#\S+["']/.test(target.outerHTML))) {
return true
}
// only show when toolbar is not present
const toolbar = this.base.getExtensionByName('toolbar');
if (!this.showWhenToolbarIsVisible && toolbar && toolbar.isDisplayed && toolbar.isDisplayed()) {
return true
}
// detach handler for other anchor in case we hovered multiple anchors quickly
})
};
if (insertButtons.length) {
options.extensions.insertMedia = new InsertMedia();
options.extensions.insert = new Insert({
buttons: insertButtons
});
}
self._lock = true;
let editor = new MediumEditor(this._element, options);
// allows use of section for editing to function properly
MediumEditor.util.blockContainerElementNames.splice(MediumEditor.util.blockContainerElementNames.indexOf('section'), 1);
editor.subscribe('editableKeydownEnter', function (event) {
if (event.shiftKey) {
//var node = MediumEditor.selection.getSelectionStart(editor.options.ownerDocument);
MediumEditor.util.insertHTMLCommand(editor.options.ownerDocument, '[BR]');
self._element.innerHTML = self._element.innerHTML.replace(/\[BR\]/g, '<br>');
self._element.dispatchEvent(new Event('change'));
event.preventDefault();
} else if (self._element.hasAttribute('data-lky-singleline')) {
event.preventDefault();
}
});
Array.prototype.slice
.call(this._element.querySelectorAll('img, video'))
.forEach(element => Wysiwyg.initInTextMedia(new Media(element, true)));
editor.subscribe('editableKeydownEnter', function (event) {
if (event.shiftKey) {
//var node = MediumEditor.selection.getSelectionStart(editor.options.ownerDocument);
MediumEditor.util.insertHTMLCommand(editor.options.ownerDocument, '[BR]');
self._element.innerHTML = self._element.innerHTML.replace(/\[BR\]/g, '<br>');
self._element.dispatchEvent(new Event('change'));
event.preventDefault();
} else if (self._element.hasAttribute('data-lky-singleline')) {
event.preventDefault();
}
});