npm.io
0.3.9 • Published 1 year ago

lexical-remark

Licence
MIT
Version
0.3.9
Deps
8
Size
181 kB
Vulns
0
Weekly
0

Lexical Remark

First attempt at integrating the remark ecosystem with lexical to perform markdown conversion.

Usage

Lexical to Markdown

import { createRemarkExport } from 'lexical-remark';

function exportLexicalToMarkdown(editor: LexicalEditor): string {
  return editor.getEditorState().read(createRemarkExport());
}
Markdown to Lexical
import { createRemarkImport} from 'lexical-remark';

function importMarkdownToLexical(editor: LexicalEditor, markdown: string): void {
  editor.update(
      () => createRemarkImport()(markdown),
      {
        discrete: true,
      },
  );
}

Keywords