Repository navigation
Conversation
…ete empties the document
## Description
In the mdast-editor dev example, selecting all of the rich text and
pressing Backspace can remove every child of the root (the footnotes
slot keeps its content) and leave the selection anchored on the root
element itself. `ToolbarStateExtension` then fell back to
`anchorNode.getTopLevelElementOrThrow()`, which throws for the root
("root nodes are not top level elements") from inside the editor-state
signal, surfacing as an uncaught exception.
The toolbar now uses only `$findMatchingParent` to find the top level
block and treats a root-anchored selection as a paragraph.
## Test plan
New unit test `dev-examples/mdast-editor/src/__tests__/unit/ToolbarState.test.ts`
watches the toolbar's `blockType` signal, runs select all + delete on a
document with a footnote and a code block, checks the selection lands on
an empty root, then types into it.
### Before
```
$ npx vitest run --project unit dev-examples/mdast-editor/src/__tests__/unit/ToolbarState.test.ts
Error: getTopLevelElementOrThrow: root nodes are not top level elements
❯ RootNode.getTopLevelElementOrThrow packages/lexical/src/nodes/LexicalRootNode.ts:40:5
❯ $readSelectionState dev-examples/mdast-editor/src/extensions/ToolbarStateExtension.ts:56:22
Tests 1 failed (1)
```
### After
```
$ npx vitest run --project unit dev-examples/mdast-editor
Tests 44 passed (44)
```
Not exercised by hand in a browser.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Deploying lexical with
|
| Latest commit: |
85f718d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9a5c0481.lexical-a1o.pages.dev |
| Branch Preview URL: | https://claude-fix-mdast-editor-sele.lexical-a1o.pages.dev |
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 22, 2026
…d escape only real references ## Description The hard line break marker was set apart only for a line attached to the root, so `$generateNodesFromMarkdownString`, which builds nodes outside it, kept `foo\` and `baz ` as text with no break. It is now set apart for any line with a parent, as the rest of the import does. Export escaped the `&` of any `&name;` and of numbers of any length, in text (`\&`) and in link destinations and titles (`&`), though only real HTML entity names and numbers of up to seven decimal or six hex digits read as references; now both escape only those, as import reads them. ## Test plan ### Before ``` npx vitest run --project unit packages/lexical-markdown/src/__tests__/unit/EscapedBackslashHardLineBreak.test.ts packages/lexical-markdown/src/__tests__/unit/CodeSpanEscapes.test.ts packages/lexical-markdown/src/__tests__/unit/LexicalMarkdown.test.ts × reads a hard line break in nodes generated outside the root 10ms × escapes the & of text ["&nosuch; � �"] only where it reads as a reference 7ms × preserves "https://example.com/?a&nosuch;�" 12ms Tests 3 failed | 647 passed (650) ``` ### After ``` npx vitest run --project unit packages/lexical-markdown packages/lexical-playground/__tests__/unit Tests 1050 passed (1050) ``` Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
etrepum
pushed a commit
that referenced
this pull request
Oct 28, 2026
…rmats closed in inline elements, and match custom patterns after an escaped character ## Description - Export writes a character reference instead of a backslash right after a format closed by text inside or before an inline element such as a mark, as it already did between sibling text nodes, so `*Q&A.*&copy;` keeps its italic when the italic text is highlighted. When preserving newlines, a literal backslash there is written as `&meta#92;` for the same reason. - When an import pattern's match starts at an escaped character, matching starts again from the character after it as if the text began there. A custom pattern that matches the character before its syntax, such as `(^|[^\w])#(\w+)` on `\(#x)`, matches again as it did before. The `importRegExp` docs describe the skipping. - The playground's image transformer no longer reads `` as an image. - The nested list escaping test asserts the whole export, and a custom transformer test is named for what it checks. ## Test plan ### After `vitest run --project unit packages/lexical-markdown packages/lexical-playground/__tests__/unit` ``` Tests 1007 passed (1007) ``` Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Requested by Bob · project thread
Description
In the mdast-editor dev example, selecting all of the rich text and pressing Backspace can remove every child of the root (the footnotes slot keeps its content) and leave the selection anchored on the root element itself.
ToolbarStateExtensionthen fell back toanchorNode.getTopLevelElementOrThrow(), which throws for the root ("root nodes are not top level elements") from inside the editor-state signal, surfacing as an uncaught exception.The toolbar now uses only
$findMatchingParentto find the top level block and treats a root-anchored selection as a paragraph.Test plan
New unit test
dev-examples/mdast-editor/src/__tests__/unit/ToolbarState.test.tswatches the toolbar'sblockTypesignal, runs select all + delete on a document with a footnote and a code block, checks the selection lands on an empty root, then types into it.Before
After
Not exercised by hand in a browser.
🤖 Generated with Claude Code
Generated by Claude Code