Currently the editor works just like the demo
I don't like when we select one of the toolbar, it keeps the same effect even after we hit the "enter/return key"
What i want is:
//typing headline using bold effect
This is headline
//after enter
it automaticallya remove the "bold effect"
what happen now, it keeps the bold effect even on the new line
anyone know how to do this?
After peeked some of the code code, here is my current solution
In this case, i'm checking if the cursor currenly in "CODE" or "PRE" tag, then i want "ENTER" function to move outside and create a new paragraph. To continue using the selection tag, just use "SHIFT+ENTER".
You can change the CODE or PRE in if/else part, hope it helps
/*
Custom meditum-editor function
On event "ENTER", by pre or CODE
make a new line
*/
editor.subscribe("editableKeydownEnter", function (event, element) {
//allow shift + enter to continue behaviour
if (event.shiftKey)
return
let currentNode = MediumEditor.selection.getSelectionStart(editor.options.ownerDocument)
if(currentNode.nodeName == "PRE" || currentNode.nodeName == "CODE") {
//then go outside pre, make a normal paragraph tag
newP = editor.options.ownerDocument.createElement('p');
newP.innerHTML = '<br>';
currentNode.parentElement.insertBefore(newP, currentNode.nextSibling);
// move the cursor into the new paragraph
MediumEditor.selection.moveCursor(editor.options.ownerDocument, newP);
}
}.bind(this))
Most helpful comment
After peeked some of the code code, here is my current solution
In this case, i'm checking if the cursor currenly in "CODE" or "PRE" tag, then i want "ENTER" function to move outside and create a new paragraph. To continue using the selection tag, just use "SHIFT+ENTER".
You can change the CODE or PRE in if/else part, hope it helps