Skip to content

How to load a simple markdown with headings #3638

Answered by vnugent
vnugent asked this question in Q&A
Discussion options

You must be logged in to vote

Found the solution. It's not obvious but you'll need to explicitly tell the editor how to handle all the default "nodes".

import { HeadingNode, QuoteNode } from '@lexical/rich-text'
import { LinkNode } from '@lexical/link'
import { ListItemNode, ListNode } from '@lexical/list'
import { MarkNode } from '@lexical/mark'

import ExampleTheme from './themes/ExampleTheme'

const editorConfig = (initialValue: string): InitialConfigType => {
  return {
    editorState: () => $convertFromMarkdownString(initialValue, TRANSFORMERS),
    namespace: 'editor',
    theme: ExampleTheme,
    onError (error) {
      throw error
    },
    nodes: [MarkNode, HeadingNode, QuoteNode, LinkNode, ListNode, ListIt…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@yes-oo
Comment options

@yes-oo
Comment options

Answer selected by vnugent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants