Skip to content

feat(rust): the node packages' DOM parts, checked by property/documents' HTML and html/import-nodes - #160

Open
tmm wants to merge 1 commit into
rust-htmlfrom
rust-html-nodes
Open

tmm wants to merge 1 commit into
rust-htmlfrom
rust-html-nodes

Conversation

@tmm

@tmm tmm commented Nov 14, 2026

Copy link
Copy Markdown
Member

Description

With html on, the Rust port rendered and imported only the core nodes:
every other node threw from createDOM, so property/documents' HTML
couldn't be checked, and no import vector registered a node package.

With html and a package's feature both on, its nodes now have
createDOM, exportDOM and importDOM, ported from upstream:

  • @lexical/rich-text: HeadingNode (with the Google Docs title) and
    QuoteNode.
  • @lexical/list: ListNode and ListItemNode, with their theme class
    names, check lists, HTMLOListElement.start, the nested item's after
    and the GitHub, Joplin and Google Docs check list and alignment imports.
  • @lexical/link: LinkNode (with sanitizeUrl, whose new URL
    check follows Swift's model of the WHATWG parser) and AutoLinkNode.
  • @lexical/code-core: CodeNode (<code>, exported as <pre>; the
    pre, multi-line code, monospace div and GitHub table importers)
    and CodeHighlightNode.
  • OverflowNode, HashtagNode, HorizontalRuleNode and
    DecoratorTextNode, with applyFormatFromStyle and applyFormatToDom.

The property/documents suite now also checks $generateHtmlFromNodes.
A new JS-recorded vector, html/import-nodes, imports curated HTML for
those importers plus every property/documents HTML export with the
property/documents nodes and HorizontalRuleNode; the Rust and Swift
runners both replay it, and Swift already matched.

Test plan

Before

$ cargo run -q -p lexical-conformance --release -- property/documents
| `property/documents` (JSON and text) | 121 | 9 | 0 | 0 | 112 | **FAIL** |
- `property/documents`: seed 20261105 #1: html: Rust None, JS Some("<ul start=\"0\" dir=\"ltr\"><li value=\"0\" style=\"text-align: start;\" dir=\"ltr\">...")

(with the HTML check added and the nodes' DOM parts not yet ported)

After

$ cargo run -q -p lexical-conformance --release
| `html/import-nodes` | 140 | 140 | 0 | 0 | 0 | pass |
| `property/documents` (JSON, text and HTML) | 121 | 121 | 0 | 0 | 0 | pass |
| **Total** | 3783 | 3783 | 0 | 0 | 0 | |

$ swift test --skip-build --filter ConformanceTests.HTMLImportTests
✔ Test run with 3 tests in 1 suite passed after 0.067 seconds.

$ npx vitest run src/html.test.ts   # packages/lexical-conformance
      Tests  3 passed (3)

cargo fmt --all --check, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, cargo test --workspace --all-features --locked, cargo doc with -D warnings, and
cargo check -p lexical-editor --no-default-features with each feature
alone and with html are clean. Swift was run on Linux only.

…ts' HTML and html/import-nodes

## Description

With `html` on, the Rust port rendered and imported only the core nodes:
every other node threw from `createDOM`, so `property/documents`' HTML
couldn't be checked, and no import vector registered a node package.

With `html` and a package's feature both on, its nodes now have
`createDOM`, `exportDOM` and `importDOM`, ported from upstream:

- `@lexical/rich-text`: `HeadingNode` (with the Google Docs title) and
  `QuoteNode`.
- `@lexical/list`: `ListNode` and `ListItemNode`, with their theme class
  names, check lists, `HTMLOListElement.start`, the nested item's `after`
  and the GitHub, Joplin and Google Docs check list and alignment imports.
- `@lexical/link`: `LinkNode` (with `sanitizeUrl`, whose `new URL`
  check follows Swift's model of the WHATWG parser) and `AutoLinkNode`.
- `@lexical/code-core`: `CodeNode` (`<code>`, exported as `<pre>`; the
  `pre`, multi-line `code`, monospace `div` and GitHub table importers)
  and `CodeHighlightNode`.
- `OverflowNode`, `HashtagNode`, `HorizontalRuleNode` and
  `DecoratorTextNode`, with `applyFormatFromStyle` and `applyFormatToDom`.

The `property/documents` suite now also checks `$generateHtmlFromNodes`.
A new JS-recorded vector, `html/import-nodes`, imports curated HTML for
those importers plus every `property/documents` HTML export with the
`property/documents` nodes and `HorizontalRuleNode`; the Rust and Swift
runners both replay it, and Swift already matched.

## Test plan

### Before

```
$ cargo run -q -p lexical-conformance --release -- property/documents
| `property/documents` (JSON and text) | 121 | 9 | 0 | 0 | 112 | **FAIL** |
- `property/documents`: seed 20261105 #1: html: Rust None, JS Some("<ul start=\"0\" dir=\"ltr\"><li value=\"0\" style=\"text-align: start;\" dir=\"ltr\">...")
```

(with the HTML check added and the nodes' DOM parts not yet ported)

### After

```
$ cargo run -q -p lexical-conformance --release
| `html/import-nodes` | 140 | 140 | 0 | 0 | 0 | pass |
| `property/documents` (JSON, text and HTML) | 121 | 121 | 0 | 0 | 0 | pass |
| **Total** | 3783 | 3783 | 0 | 0 | 0 | |

$ swift test --skip-build --filter ConformanceTests.HTMLImportTests
✔ Test run with 3 tests in 1 suite passed after 0.067 seconds.

$ npx vitest run src/html.test.ts   # packages/lexical-conformance
      Tests  3 passed (3)
```

`cargo fmt --all --check`, `cargo clippy --workspace --all-targets
--all-features --locked -- -D warnings`, `cargo test --workspace
--all-features --locked`, `cargo doc` with `-D warnings`, and
`cargo check -p lexical-editor --no-default-features` with each feature
alone and with `html` are clean. Swift was run on Linux only.

Amp-Thread-ID: https://ampcode.com/threads/T-506c8fa1-4309-40f1-9810-732b311eaeab

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants