Skip to content

fix(text-editor): allow inline code inside other marks in markdown - #4066

Merged
JammingBen merged 1 commit into
mainfrom
fix/text-editor-mark-order
Oct 29, 2026
Merged

JammingBen merged 1 commit into
mainfrom
fix/text-editor-mark-order

Conversation

@JammingBen

@JammingBen JammingBen commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Description

Markdown files with inline code inside other marks, e.g. **`Sharing`** or [`config.json`](url), could not be opened in the text editor. Tiptap's Code mark excludes all other marks, but @tiptap/markdown parses these constructs into text carrying both, so the document failed the schema check.

Changes:

  • New MarkdownCode extension that replaces StarterKit's code mark. It only excludes itself, so code can carry bold, italic, strike and links.
  • Its priority is below the default so code always ranks innermost among the marks. Mark rank decides the nesting when serializing, so it writes **`foo`** instead of `**foo**`.
  • Markdown can only wrap a whole code span. Marks covering only part of a run of code text are removed, otherwise their syntax would be saved as literal text inside the backticks. This runs on every edit (appendTransaction) and once when the initial content is loaded, since that is parsed without a transaction. As a consequence, adjacent code spans with different marks, e.g. `a`**`b`**, load as `ab`.

The root cause is upstream in tiptap, reported in ueberdosis/tiptap#8637 (related: ueberdosis/tiptap#8568, ueberdosis/tiptap#8569). This extension can be reduced or dropped once that is fixed.

Known limitations:

  • Applying bold, italic, strike or a link to only part of a code span is silently a no-op.
  • Adjacent code spans with different links (e.g. [`a`](https://x.y)[`b`](https://z.w)) are merged into a single code span and both links are dropped, so the URLs are lost on the next save.

Related Issue

@JammingBen JammingBen self-assigned this Oct 29, 2026
@JammingBen
JammingBen marked this pull request as ready for review October 29, 2026 08:56
@JammingBen
JammingBen requested a review from kulmann October 29, 2026 08:56
@JammingBen
JammingBen merged commit bbf06fb into main Oct 29, 2026
29 checks passed
@JammingBen
JammingBen deleted the fix/text-editor-mark-order branch October 29, 2026 13:22
@openclouders openclouders mentioned this pull request Nov 2, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

text-editor: inline code inside bold makes the whole file unopenable

2 participants