Skip to content
Discussion options

You must be logged in to vote

replace LineBreakNode with ParagraphNode

const editorConfig = {
  nodes: [
    {
      replace: LineBreakNode,
      with: () => new ParagraphNode(),
    },
  ],
}

thanks for #4464

import { useEffect } from 'react'
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
import {
  $getSelection,
  $isRangeSelection,
  COMMAND_PRIORITY_CRITICAL,
  INSERT_PARAGRAPH_COMMAND,
  KEY_ENTER_COMMAND,
} from 'lexical'

function EnterListenerPlugin() {
  const [editor] = useLexicalComposerContext()

  useEffect(() => {
    editor.registerCommand(
      KEY_ENTER_COMMAND,
      event => {
        const selection = $getSelection()
        if (!$isRangeSelection(selection)) …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tonyhsiehwork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant