Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Primer script for rendering lexical editor state to html

Notifications You must be signed in to change notification settings

vadimkantorov/lexical-cli-render

Repository files navigation

lexical-cli-render

Renders Facebook Lexical's EditorState serialized to JSON (see sample ./samples/playground.lexical.json and ./samples/playground-without-emoji.lexical.json) produced by exporting to JSON default content of https://playground.lexical.dev

Usage

# nodejs starting with version 22 supports native execution of TypeScript without prior transpilation: https://nodejs.org/en/learn/typescript/run-natively
cat samples/playground.lexical.json | npx ts-node lexical-cli-render.ts

# if does not use JSX/TSX imports, can use node instea of npx ts-node:
cat samples/playground-without-emoji.lexical.json | node lexical-cli-render-without-emoji.ts

Future work

  • How to style the produced HTML tags? At the very least, how to ask lexical to add css classes to preserve the original node types?
  • How to replace the produed style="white-space: pre-wrap;" with some CSS class?

References

About

Primer script for rendering lexical editor state to html

Topics

Resources

Stars

Watchers

Forks