0.19.0 • Published 8 months ago

@lexical/headless v0.19.0

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

@lexical/headless

See API Documentation

This package allows you to interact with Lexical in a headless environment (one that does not rely on DOM, e.g. for Node.js environment), and use its main features like editor.update(), editor.registerNodeTransform(), editor.registerUpdateListener() to create, update or traverse state.

Install @lexical/headless:

npm install --save @lexical/headless
const { createHeadlessEditor } = require('@lexical/headless');

const editor = createHeadlessEditor({
  nodes: [],
  onError: () => {},
});

editor.update(() => {
  $getRoot().append(
    $createParagraphNode().append(
      $createTextNode('Hello world')
    )
  )
});

Any plugins that do not rely on DOM could also be used. Here's an example of how you can convert lexical editor state to markdown on server:

const { createHeadlessEditor } = require('@lexical/headless');
const { $convertToMarkdownString, TRANSFORMERS } = require('@lexical/markdown');

app.get('article/:id/markdown', async (req, res) => {
  const editor = createHeadlessEditor({
    nodes: [],
    onError: () => {},
  });

  const articleEditorStateJSON = await loadArticleBody(req.query.id);
  editor.setEditorState(editor.parseEditorState(articleEditorStateJSON));

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

8 months ago

0.18.0

9 months ago

0.17.1

10 months ago

0.17.0

11 months ago

0.16.0

1 year ago

0.16.1

12 months ago

0.15.0

1 year 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.0

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

2 years 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

2 years ago

0.12.4

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

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

3 years ago

0.7.2

3 years ago

0.6.3

3 years ago

0.7.1

3 years ago

0.6.2

3 years ago

0.7.4

3 years ago

0.6.5

3 years ago

0.7.3

3 years ago

0.6.4

3 years ago

0.7.0

3 years ago

0.6.1-next.0

3 years ago

0.5.1-next.1

3 years ago

0.5.1-next.0

3 years ago

0.5.1-next.2

3 years ago

0.6.0

3 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.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago