Socket
Socket
Sign inDemoInstall

@lexical/html

Package Overview
Dependencies
1
Maintainers
7
Versions
60
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @lexical/html

This package contains HTML helpers and functionality for Lexical.


Version published
Maintainers
7
Created

Changelog

Source

v0.8.1 (2023-02-22)

  • Clone objects from the CSS cache before mutating them (#3945) Brian Birtles
  • added docsfeature-button in lexical playground issue#3918 (#3935) Mohan Sai Potla
  • fix: change from to (#3942) Asim Kattum Thazha
  • Added Chinese character support for native webkit (#3846) Annabelle Almås
  • Fix autocapitalization (#3881) Gerard Rovira
  • Expand the actionable empty playground editor text area via flex (#3883) Brandon
  • Fix toggling styles on collapsed selections with (#3922) Brian Birtles
  • Remove condition for history merge on null prev selection (#3914) Acy Watson
  • fix: change tablecell return type for TableCellNode (#3925) Sebastien Ahkrin
  • Align types for createEditor APIs (#3928) Acy Watson
  • Remove instanceof type checks against HTMLElement and subtypes (#3913) Acy Watson
  • Fix small lint error breaking main (#3924) John Flockton
  • Update plugins.md (#3926) dimitarbikov
  • Added support for Java & C++ (#3884) Vignesh gupta
  • Add fixme annotation to flaky collab tests (#3916) Acy Watson
  • Playground: fix issue with floating link editor plugin not closing (#3904) Rich
  • Further tweaks to format/style selection (#3895) Dominic Gannaway
  • Add KEY_DOWN_COMMAND (#3878) Dominic Gannaway
  • Remove draggable block plugin on mobile devices (#3875) John Flockton
  • Close color pickers on select (#3874) John Flockton
  • Fix ContentEditable types for internal use (#3868) John Flockton
  • Fix v0.8.9 typo in changelog, should be v0.8.0 (#3869) Joel Besada

Readme

Source

@lexical/html

HTML

This package exports utility functions for converting Lexical -> HTML and HTML -> Lexical. These same functions are also used in the lexical-clipboard package for copy and paste.

Full documentation can be found here.

Exporting

// When converting to HTML you can pass in a selection object to narrow it
// down to a certain part of the editor's contents.
const htmlString = $generateHtmlFromNodes(editor, selection | null);

Importing

First we need to parse the HTML string into a DOM instance.

// In the browser you can use the native DOMParser API to parse the HTML string.
const parser = new DOMParser();
const dom = parser.parseFromString(htmlString, textHtmlMimeType);

// In a headless environment you can use a package such as JSDom to parse the HTML string.
const dom = new JSDOM(htmlString);

And once you have the DOM instance.

const nodes = $generateNodesFromDOM(editor, dom);

// Once you have the lexical nodes you can initialize an editor instance with the parsed nodes.
const editor = createEditor({ ...config, nodes });

// Or insert them at a selection.
$insertNodes(nodes);

Keywords

FAQs

Last updated on 23 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc