Repository navigation
Conversation
… and import ## Description The Rust port's `html` feature had a DOM (`lexical_editor::dom`) but no node rendered into it, so `html/export` and `html/import` had no suite. This adds, behind the same feature: - `createDOM`, `exportDOM` and the static `importDOM` as `LexicalNode` hooks, with `ElementNode.exportDOM` (indent and direction) and `TextNode`'s behavior as their defaults, and the types they exchange (`DOMExportOutput`, `DOMConversionOutput`, `DOMConversionMap`, ...) in `lexical_editor::lexical_dom`, ported from `LexicalNode.ts`, `LexicalEditor.ts` and the DOM helpers of `LexicalUtils.ts`. - `createEditor`'s `theme` (always) and `html` config (export overrides and extra import conversions), `editor._config`, the conversion cache, and `DEFAULT_EDITOR_DOM_CONFIG`. - The DOM code of the core nodes: `TextNode` (`createDOM` with the theme's class names and the style, `exportDOM`, and the `#text`, `b`, `span` and format-element conversions), `TabNode`, `LineBreakNode`, `ParagraphNode` (with its `extractWithChild`), and `ArtificialNode__DO_NOT_USE`, which the core now registers as JS does. - `LexicalNode.isSelected`. - `lexical_editor::html`, ported from `packages/lexical-html/src/index.ts`: `generate_html_from_nodes`, `generate_dom_from_nodes`, `generate_dom_from_root`, `append_node_to_html` (with `$sliceSelectedTextNodeContent` for a selection) and `generate_nodes_from_dom`. - Conformance suites for `html/export` and `html/import`. `$inlineStylesFromStyleSheets` and the `DOMImportExtension` and `DOMRenderExtension` pipelines are not ported (rust/PARITY.md); no vector needs them. The node packages' DOM parts come next. ## Test plan ### Before ``` $ cargo run -q -p lexical-conformance --release -- html/ | `html/entities` | 2125 | 2125 | 0 | 0 | 0 | pass | | `html/export` | – | – | – | – | – | not implemented | | `html/import` | – | – | – | – | – | not implemented | | `html/parse` | 37 | 37 | 0 | 0 | 0 | pass | | **Total** | 2162 | 2162 | 0 | 0 | 0 | | ``` ### After ``` $ cargo run -q -p lexical-conformance --release -- html/ | `html/entities` | 2125 | 2125 | 0 | 0 | 0 | pass | | `html/export` | 42 | 42 | 0 | 0 | 0 | pass | | `html/import` | 68 | 68 | 0 | 0 | 0 | pass | | `html/parse` | 37 | 37 | 0 | 0 | 0 | pass | | **Total** | 2272 | 2272 | 0 | 0 | 0 | | $ cargo run -q -p lexical-conformance --release | **Total** | 3643 | 3643 | 0 | 0 | 0 | | ``` `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 --features <f>` for each feature are clean. Amp-Thread-ID: https://ampcode.com/threads/T-506c8fa1-4309-40f1-9810-732b311eaeab
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Rust port's
htmlfeature had a DOM (lexical_editor::dom) but nonode rendered into it, so
html/exportandhtml/importhad no suite.This adds, behind the same feature:
createDOM,exportDOMand the staticimportDOMasLexicalNodehooks, with
ElementNode.exportDOM(indent and direction) andTextNode's behavior as their defaults, and the types they exchange(
DOMExportOutput,DOMConversionOutput,DOMConversionMap, ...) inlexical_editor::lexical_dom, ported fromLexicalNode.ts,LexicalEditor.tsand the DOM helpers ofLexicalUtils.ts.createEditor'stheme(always) andhtmlconfig (export overridesand extra import conversions),
editor._config, the conversion cache,and
DEFAULT_EDITOR_DOM_CONFIG.TextNode(createDOMwith the theme'sclass names and the style,
exportDOM, and the#text,b,spanandformat-element conversions),
TabNode,LineBreakNode,ParagraphNode(with itsextractWithChild), andArtificialNode__DO_NOT_USE, which the core now registers as JS does.LexicalNode.isSelected.lexical_editor::html, ported frompackages/lexical-html/src/index.ts:generate_html_from_nodes,generate_dom_from_nodes,generate_dom_from_root,append_node_to_html(with$sliceSelectedTextNodeContentfor a selection) andgenerate_nodes_from_dom.html/exportandhtml/import.$inlineStylesFromStyleSheetsand theDOMImportExtensionandDOMRenderExtensionpipelines are not ported (rust/PARITY.md); no vectorneeds them. The node packages' DOM parts come next.
Test plan
Before
After
cargo fmt --all --check,cargo clippy --workspace --all-targets --all-features --locked -- -D warnings,cargo test --workspace --all-features --locked,cargo docwith-D warnings, andcargo check -p lexical-editor --no-default-features --features <f>foreach feature are clean.