Renders a lexical editor state string to a HTML string.
npm install @tryghost/kg-lexical-html-rendererRenders a lexical editor state string to a HTML string.
This library differs from Lexical's own lexical-html package in a few ways:
1. it's output target is not an editor but rendered web pages or emails which means the handling of nodes (especially custom DecoratorNodes) will differ to the node's built-in editor-focused rendering or Basic usage: `` const lexicalState = '{...}'; Options can be passed in as the second argument to .render() ` | Option | Values | This is a mono repository, managed with lerna. Follow the instructions for the top-level repo. - yarn lint Copyright (c) 2013-2026 Ghost Foundation - Released under the MIT license.
2. render output will vary based on supplied options and targets, e.g. when rendering for email the output may use elements in place of modern HTML structure
3. it's primary usage environment is server-sideInstall
npm install @tryghost/kg-lexical-html-renderer --saveyarn add @tryghost/kg-lexical-html-rendererUsage
js
const LexicalHTMLRenderer = require('@tryghost/kg-lexical-html-renderer');
const renderer = new Renderer();
const html = await renderer.render(lexicalState);
`.js`
const html = await renderer.render(lexicalState, {target: 'email'});
| -------- | ------ |
| target | 'html' (default), 'email' |Develop
1. git clone this repo & cd into it as usualyarn
2. Run to install top-level dependencies.Test
run just eslintyarn test
- run lint and testsRunning in Ghost Admin
In order to run local changes, perform the following:
1. Run yarn link within kg-lexical-html-rendereryarn link @tryghost/kg-lexical-html-renderer
2. Run within ghost/corekg-default-nodes` must also be linked when linking this package as they are codependencies.Copyright & License