0.15.0 • Published 11 days ago

@lexical/headless v0.15.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days 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', await (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.15.0

11 days ago

0.14.5

1 month ago

0.14.4

1 month ago

0.14.3

2 months ago

0.14.2

2 months ago

0.14.0

2 months ago

0.14.1

2 months ago

0.13.1

4 months ago

0.13.0

4 months ago

0.12.6

4 months ago

0.12.5

6 months ago

0.11.2

11 months ago

0.11.3

10 months ago

0.12.0

10 months ago

0.12.1

9 months ago

0.12.2

9 months ago

0.12.3

6 months ago

0.12.4

6 months ago

0.11.0

12 months ago

0.11.1

12 months ago

0.10.0

1 year ago

0.9.0

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

0.7.9

1 year ago

0.7.8

1 year ago

0.7.7

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.7.6

1 year ago

0.7.5

1 year ago

0.7.2

1 year ago

0.6.3

1 year ago

0.7.1

1 year ago

0.6.2

1 year ago

0.7.4

1 year ago

0.6.5

1 year ago

0.7.3

1 year ago

0.6.4

1 year ago

0.7.0

1 year ago

0.6.1-next.0

2 years ago

0.5.1-next.1

2 years ago

0.5.1-next.0

2 years ago

0.5.1-next.2

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.9

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago