Conversation
…ine formatting in markdown shortcuts Per CommonMark spec, code spans (backticks) should take precedence over other inline formatting. Previously, typing `__bold__` would trigger the bold transformer before the closing backtick could complete the code span. Now, text format transformers skip matches that fall inside an unclosed code span.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
left a comment
There was a problem hiding this comment.
would be great to add some tests to this to confirm that it fixes the issue
| let sibling = node.getPreviousSibling(); | ||
| while (sibling !== null) { | ||
| if ($isLineBreakNode(sibling)) { | ||
| break; | ||
| } | ||
| if ($isTextNode(sibling)) { | ||
| const siblingText = sibling.getTextContent(); | ||
| for (let i = 0; i < siblingText.length; i++) { | ||
| if (siblingText[i] === '`') { | ||
| backtickCount++; | ||
| } | ||
| } | ||
| } | ||
| sibling = sibling.getPreviousSibling(); | ||
| } |
There was a problem hiding this comment.
Do we really need to look at adjacent TextNodes?
There was a problem hiding this comment.
hello etrepum, yes, the opening tag search at line 261-283 walks previous TextNode siblings to find the open tag, so openNode may be a different node than anchorNode. Consider: a user types `code which creates a code-formatted TextNode, then continues typing bold. The backtick is in a previous sibling TextNode. Without checking siblings, $isInsideUnclosedCodeSpan would miss the opening backtick and incorrectly allow the bold transform.
There was a problem hiding this comment.
yeah but that's a different TextNode and the bold formatting will go away if we treat it as markdown, I think it would work as expected if the shortcut only cared about the current node
There was a problem hiding this comment.
thanks for the comment! yea agree it isnt needed, removed
…rmatting in shortcuts (#8381)
commit 5d1bc33 Author: Sathvik Veerapaneni <98241593+Sathvik-Chowdary-Veerapaneni@users.noreply.github.com> Date: Thu Apr 23 13:12:21 2026 -0400 [lexical-list] Bug Fix: Merge nested list into parent <li> during HTML export (facebook#8313) Co-authored-by: Bob Ippolito <bob@redivi.com> commit 2c37dc2 Author: Bob Ippolito <bob@redivi.com> Date: Thu Apr 23 07:14:14 2026 -0700 [lexical-clipboard][lexical-rich-text][lexical-plain-text] Bug Fix: Drag-and-drop within the same block (facebook#8373) Co-authored-by: Claude <noreply@anthropic.com> commit ca2aa31 Author: Bob Ippolito <bob@redivi.com> Date: Thu Apr 23 07:12:43 2026 -0700 [lexical][lexical-utils][lexical-list] Bug Fix: Clean up and test $insertNodeToNearestRootAtCaret edge cases (facebook#8384) commit 207648e Author: Bob Ippolito <bob@redivi.com> Date: Thu Apr 23 07:11:52 2026 -0700 [lexical-html][lexical-playground] Feature: Implement a well-defined ordering for DOMRenderExtension overrides and add $decorateDOM (facebook#8368) commit 1ca42f1 Author: Agyei Holy <agyeiholy978@gmail.com> Date: Wed Apr 22 15:39:37 2026 -0500 [lexical][lexical-code-core][lexical-list][lexical-table][lexical-yjs] Refactor: make runtime style updates CSP-safe (facebook#8372) commit ca0ce82 Author: Bob Ippolito <bob@redivi.com> Date: Wed Apr 22 12:57:28 2026 -0700 [lexical-list] Bug Fix: Ensure that ListItemNode always has a ListItem parent (facebook#8382) commit f4c44e1 Author: Sherry <potatowagon@meta.com> Date: Thu Apr 23 00:28:54 2026 +0530 [lexical-markdown] Bug Fix: Code spans take precedence over inline formatting in shortcuts (facebook#8381) commit 4a43cb0 Author: Sergey Gorbachev <grbchv.s@gmail.com> Date: Wed Apr 22 18:31:21 2026 +0300 [lexical-playground] Feature: HTML conversion button (facebook#8379)
commit 5d1bc33 Author: Sathvik Veerapaneni <98241593+Sathvik-Chowdary-Veerapaneni@users.noreply.github.com> Date: Thu Apr 23 13:12:21 2026 -0400 [lexical-list] Bug Fix: Merge nested list into parent <li> during HTML export (facebook#8313) Co-authored-by: Bob Ippolito <bob@redivi.com> commit 2c37dc2 Author: Bob Ippolito <bob@redivi.com> Date: Thu Apr 23 07:14:14 2026 -0700 [lexical-clipboard][lexical-rich-text][lexical-plain-text] Bug Fix: Drag-and-drop within the same block (facebook#8373) Co-authored-by: Claude <noreply@anthropic.com> commit ca2aa31 Author: Bob Ippolito <bob@redivi.com> Date: Thu Apr 23 07:12:43 2026 -0700 [lexical][lexical-utils][lexical-list] Bug Fix: Clean up and test $insertNodeToNearestRootAtCaret edge cases (facebook#8384) commit 207648e Author: Bob Ippolito <bob@redivi.com> Date: Thu Apr 23 07:11:52 2026 -0700 [lexical-html][lexical-playground] Feature: Implement a well-defined ordering for DOMRenderExtension overrides and add $decorateDOM (facebook#8368) commit 1ca42f1 Author: Agyei Holy <agyeiholy978@gmail.com> Date: Wed Apr 22 15:39:37 2026 -0500 [lexical][lexical-code-core][lexical-list][lexical-table][lexical-yjs] Refactor: make runtime style updates CSP-safe (facebook#8372) commit ca0ce82 Author: Bob Ippolito <bob@redivi.com> Date: Wed Apr 22 12:57:28 2026 -0700 [lexical-list] Bug Fix: Ensure that ListItemNode always has a ListItem parent (facebook#8382) commit f4c44e1 Author: Sherry <potatowagon@meta.com> Date: Thu Apr 23 00:28:54 2026 +0530 [lexical-markdown] Bug Fix: Code spans take precedence over inline formatting in shortcuts (facebook#8381) commit 4a43cb0 Author: Sergey Gorbachev <grbchv.s@gmail.com> Date: Wed Apr 22 18:31:21 2026 +0300 [lexical-playground] Feature: HTML conversion button (facebook#8379)
Description
Per CommonMark spec, code spans (backticks) should take precedence over other inline formatting. Previously, typing
__bold__would trigger the bold transformer before the closing backtick could complete the code span. Now, text format transformers skip matches that fall inside an unclosed code span.Test plan
Before
Screen.Recording.2026-04-22.at.2.06.38.PM.mov
After
Screen.Recording.2026-04-22.at.2.05.56.PM.mov