0.19.0 • Published 6 months ago

@lexical/markdown v0.19.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@lexical/markdown

See API Documentation

This package contains markdown helpers for Lexical: import, export and shortcuts.

Import and export

import {
  $convertFromMarkdownString,
  $convertToMarkdownString,
  TRANSFORMERS,
} from '@lexical/markdown';

editor.update(() => {
  const markdown = $convertToMarkdownString(TRANSFORMERS);
  ...
});

editor.update(() => {
  $convertFromMarkdownString(markdown, TRANSFORMERS);
});

It can also be used for initializing editor's state from markdown string. Here's an example with react <RichTextPlugin>

<LexicalComposer initialConfig={{
  editorState: () => $convertFromMarkdownString(markdown, TRANSFORMERS)
}}>
  <RichTextPlugin />
</LexicalComposer>

Shortcuts

Can use <MarkdownShortcutPlugin> if using React

import { TRANSFORMERS } from '@lexical/markdown';
import {MarkdownShortcutPlugin} from '@lexical/react/LexicalMarkdownShortcutPlugin';

<LexicalComposer>
  <MarkdownShortcutPlugin transformers={TRANSFORMERS} />
</LexicalComposer>

Or registerMarkdownShortcuts to register it manually:

import {
  registerMarkdownShortcuts,
  TRANSFORMERS,
} from '@lexical/markdown';

const editor = createEditor(...);
registerMarkdownShortcuts(editor, TRANSFORMERS);

Transformers

Markdown functionality relies on transformers configuration. It's an array of objects that define how certain text or nodes are processed during import, export or while typing. @lexical/markdown package provides set of built-in transformers:

// Element transformers
UNORDERED_LIST
CODE
HEADING
ORDERED_LIST
QUOTE

// Text format transformers
BOLD_ITALIC_STAR
BOLD_ITALIC_UNDERSCORE
BOLD_STAR
BOLD_UNDERSCORE
INLINE_CODE
ITALIC_STAR
ITALIC_UNDERSCORE
STRIKETHROUGH

// Text match transformers
LINK

And bundles of commonly used transformers:

  • TRANSFORMERS - all built-in transformers
  • ELEMENT_TRANSFORMERS - all built-in element transformers
  • TEXT_FORMAT_TRANSFORMERS - all built-in text format transformers
  • TEXT_MATCH_TRANSFORMERS - all built-in text match transformers

Transformers are explicitly passed to markdown API allowing application-specific subset of markdown or custom transformers.

There're three types of transformers:

  • Element transformer handles top level elements (lists, headings, quotes, tables or code blocks)
  • Text format transformer applies text range formats defined in TextFormatType (bold, italic, underline, strikethrough, code, subscript and superscript)
  • Text match transformer relies on matching leaf text node content

See MarkdownTransformers.js for transformer implementation examples

blockit-texteditorscribo-markdown@everything-registry/sub-chunk-545veridical@veridical/pluginshrconnect-uisvelte-lexical-devsvelte-lexicalwritlytestpkg777@crystallize/design-system@communi/editor@blocklet/editor@rryando/editor@payloadcms/richtext-lexical@ticketz-oss/mdx-editormirpayloadsurveykrui@anjy7/navbar-cms@betty-blocks/mdxeditor@brikl/design-dashboard@churchapps/apphelper@cmpsr/markdown-editor@bosheski/mdxeditor-editor@denindka/editor-dsd@did-comment/react@copus/editorurdu-web-editor@firaslatrach/tam_editor_nodes@gtplan/react-components@igloo-ui/text-editor@losol/scribo-markdown@lexp/ui@lexp/ui-t@lexical/react@lukaprsina/mdxeditor@lxzmo/drum@mibjs/cubes@mrwan2546/editor@nagwa-limited/html-editor-v2@equinor/ioc-common-frontend@enlightngo/iwe@mdxeditor/editor@maketribe/ms-app@jitera/jitera-web-ui-library@jaceapp/jace-node@joshcena/lexical-editor@jpmorganchase/mosaic-content-editor-plugin@piscale/editor@paddim8/svelte-lexical@solace-health/ui@sourcegraph/lexical__react@soundryhealth/payload-richtext-lexical@shubasish/mdx-editor@seolhun/root-editor@sinups/editor-dsdmuitailwindmusaenavbar-cmspeers-uipayload-plugin-lexicalrti-tek-helpers31-editorpix0-ed-uirexicalrex-editorpsusmars-richtext-lexicalreact-sliteshepherd-editorsofty-editorgsoc-projectshr-integra-uilexical-markdown-vuelexical-preactlexical-solidlexical-svelte-runeslexical-vuelexical-vue-testinglexical-wysiwyglexitormdx-floatmdxeditor-editor-react17mdxeditor-editor-react18-developmentmdxeditor-newlines-editor@sveltia/ui@tyzo/library-standard@uniformdev/design-system@wattanx/lexical-vue@webtech0321/mdx-editor-collab@wingnpm/lexical-vue@workwave-tidal/core@wiztype/react@zalastax/nolb-_lexcommonwealth-editorcommonwealth-mdxeditorcreate-exo-frontend-templateemail-scribeeditor-react-seventeenevents-cms
0.19.0

6 months ago

0.18.0

7 months ago

0.17.1

8 months ago

0.17.0

9 months ago

0.16.0

11 months ago

0.16.1

10 months ago

0.15.0

12 months ago

0.14.5

1 year ago

0.14.4

1 year ago

0.14.3

1 year ago

0.14.2

1 year ago

0.14.1

1 year ago

0.13.1

1 year ago

0.13.0

1 year ago

0.12.6

1 year ago

0.12.5

1 year ago

0.11.2

2 years ago

0.11.3

2 years ago

0.12.0

2 years ago

0.12.1

2 years ago

0.12.2

2 years ago

0.12.3

1 year ago

0.12.4

1 year ago

0.11.0

2 years ago

0.11.1

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.10.0

2 years ago

0.7.9

2 years ago

0.7.8

2 years ago

0.7.7

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.2

2 years ago

0.6.3

2 years ago

0.7.1

2 years ago

0.6.2

2 years ago

0.7.4

2 years ago

0.6.5

2 years ago

0.7.3

2 years ago

0.6.4

2 years ago

0.7.0

2 years ago

0.6.1-next.0

2 years ago

0.5.1-next.1

3 years ago

0.5.1-next.0

3 years ago

0.5.1-next.2

2 years ago

0.6.0

2 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.9

3 years ago

0.3.11

3 years ago

0.3.10

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.4

3 years ago

0.3.0

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.3

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago