Repository navigation
|
Is it possible to insert a line that preserves the status of the previous line when a new line is inserted with the enter key? If you have a sample code, could you please let me know? That is not the behavior in Lexical's Playground. Also, the Draft.js demo has that behavior. |
Replies: 5 comments 1 reply
You can try line break node or import {
$createTextNode,
$createParagraphNode,
$insertNodes,
} from 'lexical';
...
const textNode = $createTextNode('\n');
const paragraphNode = $createParagraphNode();
paragraphNode.append(textNode);
$insertNodes([paragraphNode]); |
When you say "preserves the status" what do you mean, exactly? |
|
@zignis editor.registerUpdateListener(({ editorState }) => {
・・・
});
・・・
editor.update(() => {
・・・
}); |
|
@acywatson |
Yes, you may want to take a look at how the |
Yes, you may want to take a look at how the
@lexical/codepackage does it: https://github.com/facebook/lexical/blob/main/packages/lexical-code/src/CodeHighlighter.ts#L515