You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.
TL;DR
medium-editor-insert-plugin v2.4.0 and medium-editor v5.22.1 has a bug which isn't present when using medium-editor v5.10.0.
Playing around with the example in medium-editor-insert-plugin v2.4.0 and medium-editor v5.22.1 causes no new <p> tag to be spawned when the last <p> of the editor is backspaced, giving the following DOM structure:
Which looks like:
(No blinking cursor as there are no <p> children.)
This bug does not occur on the official hosted example, running medium-editor v5.10.0 + medium-editor-insert-plugin v2.2.3.
SOLUTION v5.22.0 of medium-editor introduced a change to how they handle removal of first empty paragraph on backspace: yabwe/medium-editor#1187
} else if (MediumEditor.util.isKey(event, MediumEditor.util.keyCode.BACKSPACE) &&
MediumEditor.util.isMediumEditorElement(node.parentElement) &&
!node.previousElementSibling &&
node.nextElementSibling &&
isEmpty.test(node.innerHTML)) {
// when cursor is in the first element, it's empty and user presses backspace,
// do delete action instead to get rid of the first element and move caret to 2nd
event.preventDefault();
MediumEditor.selection.moveCursor(this.options.ownerDocument, node.nextSibling);
node.parentElement.removeChild(node);
}
As there is a nextElementSibling (medium-insert-buttons) this check passes and the <p> is deleted.
The text was updated successfully, but these errors were encountered:
you can use the code below to prevent this problem
let that = this;
this.editor.subscribe('editableKeyup', function (e, editable) {
// watch the content and solve this problem
let allContents = that.editor.serialize();
let content = allContents["element-0"].value;
if(!content) {
that.editor.setContent('<p><br></p>');
}
});
TL;DR
medium-editor-insert-plugin
v2.4.0
and medium-editorv5.22.1
has a bug which isn't present when using medium-editorv5.10.0
.Playing around with the example in medium-editor-insert-plugin
v2.4.0
and medium-editorv5.22.1
causes no new<p>
tag to be spawned when the last<p>
of the editor is backspaced, giving the following DOM structure:Which looks like:
(No blinking cursor as there are no
<p>
children.)This bug does not occur on the official hosted example, running medium-editor
v5.10.0
+ medium-editor-insert-pluginv2.2.3
.SOLUTION
v5.22.0
of medium-editor introduced a change to how they handle removal of first empty paragraph on backspace: yabwe/medium-editor#1187As there is a
nextElementSibling
(medium-insert-buttons
) this check passes and the<p>
is deleted.The text was updated successfully, but these errors were encountered: