'How ckeditor5 enters to insert a tag in a block<p>
I made some changes based on the ckeditor5-code-block plugin and implemented the ckeditor5-container-block plugin,
It is used to insert a quoteblock with class style, but there is currently a problem, that is, only the <br/> tag will be generated when the carriage returns, and a new <p> tag will not be generated. When it is saved to the database and read again, it will be It becomes a line, so I want to realize the carriage return to generate a new <p> tag, but I don't know how to do it
I researched the code and found that at line 196 of the containerblockediting.js file
function breakLineOnEnter(editor) {
const model = editor.model;
const modelDoc = model.document;
const lastSelectionPosition = modelDoc.selection.getLastPosition();
const node = lastSelectionPosition.nodeBefore || lastSelectionPosition.textNode;
let leadingWhiteSpaces;
if (node && node.is('$text')) {
leadingWhiteSpaces = getLeadingWhiteSpaces(node);
}
editor.model.change(writer => {
editor.execute('shiftEnter');
if (leadingWhiteSpaces) {
writer.insertText(leadingWhiteSpaces, modelDoc.selection.anchor);
}
});
}
editor.execute('shiftEnter'); may be to generate <br/>, but I don't know how to modify it, I don't know who will, can you help me?
preview [email protected]:liwuming/ckeditor5-container-block.git
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
