-
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. |
Beta Was this translation helpful? Give feedback.
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]); |
Beta Was this translation helpful? Give feedback.
-
When you say "preserves the status" what do you mean, exactly? |
Beta Was this translation helpful? Give feedback.
-
@zignis editor.registerUpdateListener(({ editorState }) => {
・・・
});
・・・
editor.update(() => {
・・・
}); |
Beta Was this translation helpful? Give feedback.
-
@acywatson |
Beta Was this translation helpful? Give feedback.
-
Yes, you may want to take a look at how the |
Beta Was this translation helpful? Give feedback.
Yes, you may want to take a look at how the
@lexical/code
package does it: https://github.com/facebook/lexical/blob/main/packages/lexical-code/src/CodeHighlighter.ts#L515