lexical_html 1.7.4 copy "lexical_html: ^1.7.4" to clipboard
lexical_html: ^1.7.4 copied to clipboard

HTML import and export for lexical_core: render a document to HTML, and parse pasted HTML back into nodes. Pure Dart.

lexical_html

lexical_html #

HTML import and export for lexical_core. Pure Dart.

dependencies:
  lexical_html: ^1.0.0
final html = editor.read($generateHtmlFromNodes);

editor.update(() {
  final selection = $getSelection();
  if (selection is RangeSelection) {
    selection.insertNodes($generateNodesFromHtml(pasted));
  }
});

Export writes HTML, not a private dialect #

<strong>, not <span class="lexical-bold">. Text that leaves the editor has to be readable by a mail client, a CMS, or a browser that has never heard of Lexical — that is the entire point of an HTML export.

Import never drops content #

An unrecognized tag contributes its text. A paste that silently loses part of what the user copied is the one outcome worth designing against, so anything this package cannot map to a node type still arrives as words.

Tables are converted as their text rather than as a grid. Reproducing a browser's table model — colspan, rowspan, implied sections — inside a paste path is a great deal of code that fails in ways nobody can predict from a screenshot.

Two things to know before you ship it #

The clipboard. Flutter's built-in Clipboard carries plain text only. Putting HTML on the system clipboard needs a platform plugin, which this package deliberately does not pull in: it converts whatever HTML the host hands it and leaves the transport to the host.

Trust. Neither direction sanitizes. Import keeps a URL verbatim because validating it belongs where the link is made tappable, and export escapes every value it writes but does not filter what a document contains. An application that renders the result as live HTML must sanitize it, exactly as it must for any HTML it did not author.

Parsing is bounded — nesting depth, node count and text length — because pasted markup is untrusted input.

Licence #

MIT. Portions derived from Lexical, © Meta Platforms, Inc. See the repository.

0
likes
160
points
425
downloads

Documentation

API reference

Publisher

verified publisherahmadre.com

Weekly Downloads

HTML import and export for lexical_core: render a document to HTML, and parse pasted HTML back into nodes. Pure Dart.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

html, lexical_code, lexical_core, lexical_link, lexical_list, lexical_rich_text, meta

More

Packages that depend on lexical_html