Repository navigation
Conversation
…n Firefox When a dead key is composed on an empty paragraph, lexical inserts a COMPOSITION_START_CHAR placeholder into a new text node and the reconciler appends a COMPOSITION_SUFFIX to its DOM. With dead keys the committed character only arrives via the composition `data` and is never written into the DOM text node, so the placeholder DOM text is COMPOSITION_START_CHAR + COMPOSITION_SUFFIX. The placeholder check in $updateSelectedTextFromDOM compared against COMPOSITION_START_CHAR exactly, missed the trailing suffix, fell through, stripped both characters to an empty string and removed the node entirely (losing the typed character). Strip a trailing COMPOSITION_SUFFIX before comparing against the placeholder so the composition `data` is used to set the text content instead of the node being removed. Fixes meta#8697
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
pushed a commit
that referenced
this pull request
Oct 6, 2026
…eader cell and keep raw HTML whitespace and pipes in cells ## Description Fixes from a /code-review of `MdastTableExtension`: - A column took the alignment most of its cells had, so inserting rows with no format into an aligned column cleared it (one of two centered cells isn't a majority). A column now takes the alignment of its header cell, the cell the GFM delimiter row sits under, and only when that has none the alignment most of its cells have, so aligning one body cell still doesn't align its column and a row inserted above the header still doesn't clear it. - Raw HTML in a cell was put on one line by turning each newline and the whitespace around it into a space, which changed the text of a `<pre>` or `<textarea>` and attribute values. And a `|` in raw HTML (`<span title="a|b">`) split the row, since gfm-table writes HTML as is and micromark doesn't unescape `\|` in HTML. Now a newline inside a tag becomes a space, and every other newline and every pipe becomes a character reference (` `, `&meta#124;`), which reads back as the same character. - The docs describe the alignment rule, the HTML encoding, and what the upstream review asked about the migration of the old table-level alignment: it is moved only onto cells with no format of their own, so a cell already formatted, including `justify`, `start` or `end`, which GFM can't write, keeps its format (covered by the existing legacy-state tests). ## Test plan ### Before ``` $ vitest run --project unit packages/lexical-mdast × keeps a column aligned when rows are inserted below the header 12ms × aligns a column by its header cell alone 3ms × keeps the newlines and pipes of raw HTML in a cell (HTML extension: false) 45ms × keeps the newlines and pipes of raw HTML in a cell (HTML extension: true) 6ms AssertionError: expected '| a |\n| - |\n| x |\n| y |\n| z |\n| …' to be '| a |\n| :-: |\n| x |\n| y |\n|…' // Object.is equality AssertionError: expected '| a |\n| - |\n| 1 |\n| 2 |' to be '| a |\n| -: |\n| 1 |\n| 2 |' // Object.is equality AssertionError: expected '<pre>a|b c</pre><span title="x|y z">w…' to be '<pre>a&meta#124;b c</pre><span titl…' // Object.is equality ``` ### After ``` $ vitest run --project unit packages/lexical-mdast Tests 238 passed (238) $ vitest run --project browser dev-examples/mdast-editor packages/lexical-mdast packages/lexical-playground Tests 187 passed | 1 skipped (188) ``` Browser tests ran in Chromium only; Firefox and WebKit were not exercised. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 6, 2026
…a tokenizer would, and take column alignment from the majority before the header row ## Description Fixes from a /code-review of the previous commit on `MdastTableExtension`: - Raw HTML in a cell treated any quote inside something tag-like as an attribute quote, so an apostrophe in a comment (`<!-- don't -->`) left the scan in a quote, and a later newline inside a tag became ` `, which broke the tag. The encoder now scans comments and declarations to their end and opens a quote only for an attribute value after `=`. - A newline between tags became ` `, which Markdown decodes into a real newline that the next export writes as `<br>`. Only a newline in a quoted attribute value or in the text of a `<pre>`, `<textarea>` or `<listing>` is now a reference; any other newline, with the whitespace around it, is one space, as before the previous commit. - The encoding now runs in the Markdown writer (an `html` handler that applies inside a `tableCell`), so it covers every HTML node a cell writes, without the extra copy of each cell's content on export. An `htmlBlock` (`rawHtmlBlock`, from `MdastHtmlExtension`) in a cell is now written as one line of its HTML around its Markdown children; before, its HTML was dropped and its children flattened into lines. - A pipe in a comment stays `&meta#124;`: a comment takes no character references and GFM splits the row on a bare pipe, so no spelling keeps it. The docs say so. - A column took its header cell's alignment even when all its other cells had another, the header was the first row a selection's export included rather than the table's header row, and an empty first row hid the header. A column now takes the alignment a strict majority of its cells have, or else that of the cell in the table's first row of cells, so rows inserted into an aligned column still don't clear it. ## Test plan ### Before ``` $ vitest run --project unit packages/lexical-mdast × aligns a column by most of its cells over its header cell 15ms × takes the header from the table's first row with cells 4ms × takes no header alignment from a selection without the header row 8ms × writes a newline as a space outside a <pre> and ignores quotes in comments (HTML extension: false) 20ms × writes a newline as a space outside a <pre> and ignores quotes in comments (HTML extension: true) 8ms × adds no lines to raw HTML in a cell that is read and written again 18ms × writes an htmlBlock in a cell on one line 6ms AssertionError: expected '| a |\n| -: |\n| 1 |\n| 2 |' to be '| a |\n| :-: |\n| 1 |\n| 2 |' // Object.is equality AssertionError: expected '| |\n| - |\n| a |\n| 1 |\n| 2 |' to be '| |\n| -: |\n| a |\n| 1 |\n| 2 |' // Object.is equality AssertionError: expected '| 1 |\n| -: |\n| 2 |\n| 3 |' to be '| 1 |\n| - |\n| 2 |\n| 3 |' // Object.is equality AssertionError: expected '<!-- don\'t --> <div>x<span c…' to be '<!-- don\'t --> <div>x<span class=\'a…' // Object.is equality AssertionError: expected 's\|t<br>b' to be '<details><summary> s\|t </summary> b …' // Object.is equality Tests 7 failed | 238 passed (245) ``` ### After ``` $ vitest run --project unit packages/lexical-mdast Tests 245 passed (245) $ vitest run --project browser dev-examples/mdast-editor packages/lexical-mdast Tests 44 passed (44) $ pnpm run ci-check # exit 0 ``` Browser tests ran in Chromium only; Firefox and WebKit were not exercised. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 6, 2026
…ext in a cell, read raw text elements whole, and keep paragraphs in an htmlBlock apart ## Description Fixes from a /code-review of the previous commit on `MdastTableExtension`: - Newlines in raw HTML text were kept only inside `<pre>`, `<textarea>` and `<listing>`, so CSS-preserved whitespace (`white-space: pre-wrap`) and `<xmp>` lost them, the whitespace after a newline was matched with `\s`, which deleted a following no-break space, and trimming the result at every newline was quadratic. Every newline in text or a quoted attribute value is now ` `, which reads back as the same newline; a newline between attributes or in a comment is a space; nothing is trimmed or skipped. - `<textarea>a<b` opened a tag inside the textarea's text. The text of RCDATA elements (`textarea`, `title`) and raw text elements (`script`, `style`, `xmp` and the like) is now read to its end tag; a newline in RCDATA is ` `, and in raw text, which takes no references, a space. - An `htmlBlock` in a cell ran each placeholder child through `flowHtml` alone, so two paragraphs in it ran together. Children with only whitespace between them are now one run, separated by `<br>` as elsewhere. - The cell encoding moves back from a global `html` writer handler, which any other extension's `html` handler would replace and which had no `peek`, to the cell's mdast, now copied only when the cell holds raw HTML. - The `htmlBlock` placeholder format and its splitter move to `htmlBlockParts.ts`, shared by `MdastHtmlExtension` and the cell export. Not changed: a column whose cells mostly have another alignment than its header cell's takes the majority's. GFM gives a column one alignment, so when its cells disagree some cell's alignment is lost either way, and the majority loses the fewest; the docs describe the rule. ## Test plan ### Before ``` $ vitest run --project unit packages/lexical-mdast × writes raw HTML "<!-- don't -->\n<b\nclass='a b'>y</b>" in a cell on one line 13ms × writes raw HTML "<div style=\"white-space: pre-wrap\">a\n b</div>" in a cell on one line 5ms × writes raw HTML "<textarea>a<b\nc</textarea><script>a||b\nc</script>" in a cell on one line 5ms × writes an htmlBlock in a cell on one line 8ms AssertionError: expected '<!-- don\'t --> <b class=\'a b\'>y</b>' to be '<!-- don\'t --> <b class=\'a b\'>…' // Object.is equality AssertionError: expected '<div style="white-space: pre-wrap">a …' to be '<div style="white-space: pre-wrap">a&…' // Object.is equality AssertionError: expected '<textarea>a<b c</textarea><script>a&#…' to be '<textarea>a<b c</textarea><script…' // Object.is equality AssertionError: expected '<details><summary> s\|t </summary> b …' to be '<details><summary> s\|t </sum…' // Object.is equality Tests 4 failed | 241 passed (245) ``` ### After ``` $ vitest run --project unit packages/lexical-mdast Tests 245 passed (245) $ vitest run --project browser dev-examples/mdast-editor packages/lexical-mdast Tests 44 passed (44) $ vitest run --project scripts-unit scripts/__tests__/unit/treeShakingSource.test.ts Tests 341 passed (341) $ pnpm run ci-check # exit 0 ``` Browser tests ran in Chromium only; Firefox and WebKit were not exercised. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 21, 2026
…d raw HTML in a table cell ## Description Raw HTML in a table cell is written on one line, and its line ends were written as spaces, so `<pre>a\nb</pre>` or an attribute value with a line end came back on one line. A line end is now written as the reference ` `, which HTML reads as the same line end in text, `<pre>` and attribute values, and as a space between a tag's attributes, where it is written as a space. Line ends beside embedded Markdown are still removed. The cellContent doc comment moves back above its function, and a `@lexical/table` test now checks that a body cell's alignment comes back on its paragraphs after an HTML round trip. ## Test plan ### Before ``` $ ./node_modules/.bin/vitest run --project unit packages/lexical-mdast -t "raw HTML in a cell as a reference" × writes a line end in raw HTML in a cell as a reference Tests 1 failed | 248 skipped (249) ``` ### After ``` $ ./node_modules/.bin/vitest run --project unit packages/lexical-mdast Tests 249 passed (249) $ ./node_modules/.bin/vitest run --project unit packages/lexical-table/src/__tests__/unit/LexicalTableCellNode.test.ts Tests 16 passed (16) ``` Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 21, 2026
…arlier table review rounds ## Description - A v0.52 table's alignment was only moved onto its cells by a transform, so a saved state read without an update (headless export of parsed JSON) lost it. Export reads it from the table again until the transform has run. - Formatting split around two or more line breaks (`**a<br><br>b**`) was written with the breaks outside it, which import read as paragraph boundaries. All the breaks between the two halves now go inside. - Display math in a cell becomes inline math with its line ends as spaces, which turned the rest of a TeX `%` comment's line into math. Comments are now removed first. - Raw HTML line ends in a cell are written as ` `, which a comment or script and style text doesn't read, and a comment with a lone quote wasn't matched as a tag. Line ends in comments and in script and style text are now spaces. - The mdast-editor footnote transform walked the previous state on every update with an empty body before checking the selection; it now checks the selection first. - `@lexical/markdown`'s line restore compares the parent with `is()`. ## Test plan ### Before ``` $ ./node_modules/.bin/vitest run --project unit packages/lexical-mdast × moves the column alignment a v0.52 state kept on the table to its cells × keeps a <br> in formatting a line break in "**a<br><br>b**" × writes a line end in raw HTML in a cell as a reference × keeps {"type":"math","value":"a % c\n+ b\\%"} a block exports to in a cell on its row Tests 4 failed | 247 passed (251) ``` ### After ``` $ ./node_modules/.bin/vitest run --project unit packages/lexical-mdast Tests 251 passed (251) $ ./node_modules/.bin/vitest run --project unit packages/lexical-markdown Tests 721 passed (721) $ ./node_modules/.bin/vitest run --project browser dev-examples/mdast-editor Tests 52 passed (52) ``` Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 21, 2026
## Description Fixes from another review of the branch: - A `<` in a cell's raw HTML that starts no tag (`a < b`) is text, so a line end after it is written as ` ` and kept, rather than being read as inside a tag and written as a space. - Moving v0.52 alignment onto cells only writes the cells of aligned columns. - mdast-editor example: a browser test that selecting the body text and pressing Backspace clears the footnotes. ## Test plan ### After `vitest run packages/lexical-mdast` and `vitest run --project browser dev-examples/mdast-editor` pass, including the new `<pre>a < b` case. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 21, 2026
…en a cell puts them on one line ## Description Reviewing 5409033 found more ways a cell's one-line JavaScript or TeX lost its value: - JSX in an expression was read as code, so `//` in its text was taken for a comment and an apostrophe for a string. JSX tags and children are now read as such: text drops the whitespace of a line end at its edges, as JSX does, and an attribute string writes a line end as ` `. - A `/` after a postfix `++`, a keyword used as a property name (`x.in`) or a non-ASCII identifier was read as a regex literal. - `${'\n'}` for a template's line end gave a tag function different strings and values; `\n` gives it the same ones, and only raw strings differ. - An `mdxTextExpression` already in a cell's paragraph kept its line ends; it now goes through the same path as the flow form. - TeX text groups are now tracked by brace depth, so any nesting, an escaped brace, and a space before the group (`\text {a|b}`) keep `|` as `\textbar{}`, while `\textstyle` (math mode) gets `\vert`. A `%` comment now also removes its line end and the next line's indentation, as TeX does. ## Test plan ### Before ``` $ vitest run --project unit packages/lexical-mdast/src/__tests__/unit/MdastImportExport.test.ts × keeps {"type":"math","value":"a\\\\%b\nc"} a block exports to in a cell on its row × keeps {"type":"mdxFlowExpression","value":"((s, ...v) => JSON.stringify([s, v]))`a\n${1}\nb`"} a block exports to in a cell on its row × keeps {"type":"mdxFlowExpression","value":"[1].map(i => i++ / 2 + \"x/y\"\n+ \"z\")"} a block exports to in a cell on its row × keeps {"type":"mdxFlowExpression","value":"({in: 4}).in / 2 + \"x/y\"\n+ \"z\""} a block exports to in a cell on its row × keeps {"type":"mdxFlowExpression","value":"(é => é / 2 + \"a/b\"\n+ \"c\")(4)"} a block exports to in a cell on its row × keeps {"type":"mdxFlowExpression","value":"<>\n <a href={u} title=\"x\ny\">see http://a.dev\n b {c\n} d</a>\n</>"} a block exports to in a cell on its row × keeps {"children":[{"type":"mdxTextExpression","value":"a +\n b"}],"type":"paragraph"} a block exports to in a cell on its row × keeps {"type":"math","value":"\\text{a {b {c {d|e}}}} \\text {a \\{ b|c} \\textstyle{|x|} \\text{ab%\n cd}"} a block exports to in a cell on its row ``` ### After ``` $ vitest run --project unit packages/lexical-mdast Test Files 7 passed (7) Tests 288 passed (288) ``` Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 21, 2026
…s code, without JSX ## Description The previous change wrote every `<script>` in a cell's raw HTML as MDX code. A data script (`type="application/json"`, an importmap) then got `\x7c` escapes and U+2028 line ends that JSON doesn't accept, a `<` in a script (the legacy `<!--` comment) opened a JSX context whose strings were written as character references, and a script with no closing tag in its HTML node had its line ends written as ` `. Now only a script with no type, or a JavaScript or module type, is written as code, with JSX off; any other script's text is put on one line as style text is, and a script or style that runs to the end of its node is read as one. ## Test plan ### Before ``` pnpm exec vitest run --project unit packages/lexical-mdast/src/__tests__/unit/MdastImportExport.test.ts × writes a line end in raw HTML in a cell as a reference Tests 1 failed | 227 passed (228) ``` ### After ``` pnpm exec vitest run --project unit packages/lexical-mdast/src/__tests__/unit/MdastImportExport.test.ts Tests 228 passed (228) ``` Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 21, 2026
…TML apart in cells and escape nested attributes once ## Description In a table cell: - Two blocks embedded in raw HTML (a callout's two body paragraphs) were written with nothing between them, so they read back as one (`onetwo`); they are now set apart by a `<br>`. Only one of the two line ends `rawHtmlBlock` puts beside embedded blocks was dropped, so the other became a stray ` `; all of them are now dropped. - The phrasing of a directive or an MDX element exported as a block was rewritten twice, so an attribute of an element inside it had its `&` escaped twice and read back as `&`. It is now rewritten once. - `<style-box>` and `<script-x>` were read as raw text elements running to the end of the HTML, a comment closed at once (`<!-->`) ran on to the next `-->`, and an unclosed tag rescanned every later `<`, which took seconds on a long run of them. - Test helpers that take callbacks needing an update context carry the `$` prefix. ## Test plan ### Before ``` pnpm exec vitest run --project unit packages/lexical-mdast × keeps the blocks of a block element apart × keeps {"type":"html","value":"<style-box><pre>a\nb</pre></style-box><!--><pre>c\nd</pre><!---->"} a block exports to in a cell on its row × reads long runs of spaces in a cell in linear time 9489ms × keeps the attributes of what a leafDirective holds × keeps the attributes of what a containerDirective holds × keeps the attributes of what a mdxJsxFlowElement holds AssertionError: expected { title: 'a&b c' } to deeply equal { title: 'a&b\nc' } Tests 6 failed | 344 passed (350) ``` ### After ``` pnpm exec vitest run --project unit packages/lexical-mdast Tests 350 passed (350) ``` Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 29, 2026
…g, add changeset ## Description On top of the line-ending fix for link titles, `LINK.export` escaped the destination and the title with the same three steps written out twice: character references, the shape's own syntax characters, then line endings as ` `/` `. They now go through one `escapeLinkPart(value, syntax)` helper, so the destination and title can't drift apart again, and the comment that explained line endings for the destination alone now covers both. Output is unchanged from the previous commit. Also merges upstream main and adds the changeset for the title fix, with a `Verify:` paragraph since exported Markdown changes for titles that contain a line ending. ## Changeset `.changeset/escape-line-endings-in-link-titles.md`: `[fix]` for `@lexical/markdown`, with `Verify:`. ## Test plan ### After ``` $ vitest run --project unit packages/lexical-markdown Test Files 9 passed (9) Tests 785 passed (785) $ pnpm run check-changesets Changeset check passed: 6 pending changeset(s) valid. ``` Co-Authored-By: Claude Opus 5.5 <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 29, 2026
…g, add changeset ## Description On top of the line-ending fix for link titles, `LINK.export` escaped the destination and the title with the same three steps written out twice: character references, the shape's own syntax characters, then line endings as ` `/` `. They now go through one `escapeLinkPart(value, syntax)` helper, so the destination and title can't drift apart again, and the comment that explained line endings for the destination alone now covers both. Output is unchanged from the previous commit. Also adds the changeset for the title fix, with a `Verify:` paragraph since exported Markdown changes for titles that contain a line ending. ## Changeset `.changeset/escape-line-endings-in-link-titles.md`: `[fix]` for `@lexical/markdown`, with `Verify:`. ## Test plan ### After ``` $ vitest run --project unit packages/lexical-markdown Test Files 9 passed (9) Tests 785 passed (785) $ pnpm run check-changesets Changeset check passed: 6 pending changeset(s) valid. ``` Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch was successfully 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.
When a dead key is composed on an empty paragraph, lexical inserts a
COMPOSITION_START_CHAR placeholder into a new text node and the reconciler
appends a COMPOSITION_SUFFIX to its DOM. With dead keys the committed
character only arrives via the composition
dataand is never written intothe DOM text node, so the placeholder DOM text is COMPOSITION_START_CHAR +
COMPOSITION_SUFFIX. The placeholder check in $updateSelectedTextFromDOM
compared against COMPOSITION_START_CHAR exactly, missed the trailing suffix,
fell through, stripped both characters to an empty string and removed the
node entirely (losing the typed character).
Strip a trailing COMPOSITION_SUFFIX before comparing against the placeholder
so the composition
datais used to set the text content instead of thenode being removed.
Fixes meta#8697