// Make the HTML editor's default break is <br>
document.execCommand("defaultParagraphSeparator", false, "br");
editor.innerHTML = "<div>abc<br><br></div>def";
// Collapse selection at the end of the first text node.
window.getSelection().collapse(editor.firstChild.firstChild, 3);
// Then, typing Enter should insert <br> for <div> container.
// This is necessary for backward compatibility. When we change default
// value of "defaultParagraphSeparator" to "div" or "p", it may be possible
// to remove this hack.
synthesizeKey("KEY_Enter");
is(editor.innerHTML, "<div>abc<br><br><br></div>def", "Enter key press at end of a text node followed by a visible <br> shouldn't split <div> container when defaultParagraphSeparator is 'br'");
// Check also the case of <p> as container.
editor.innerHTML = "<p>abc<br><br></p>def";
// Collapse selection at the end of the first text node.
window.getSelection().collapse(editor.firstChild.firstChild, 3);
// Then, typing Enter should splitting <p> container and remove the visible
// <br> element next to the caret position.
// This is not consistent with <div> container, but this is better behavior
// and keep using this behavior.
synthesizeKey("KEY_Enter");
is(editor.innerHTML, "<p>abc</p><p><br></p>def", "Enter key press at end of a text node followed by a visible <br> should split <p> container and remove the visible <br> when defaultParagraphSeparator is 'br'");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.