Skip to content

fix(core): write clipboard plain text without markdown escapes - #3384

Closed
YousefED wants to merge 1 commit into
mainfrom
fix/clipboard-plain-text-escapes
Closed

YousefED wants to merge 1 commit into
mainfrom
fix/clipboard-plain-text-escapes

Conversation

@YousefED

@YousefED YousefED commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A copy, a cut or a drag of more than one block writes markdown escapes into the text/plain data: Array<string> becomes Array\<string>. This is on main since #3194 (release 0.57.0), which made the markdown export escape a < that a markdown parser reads as HTML.

The markdown serializer gets an option, escapes. Copy and drag use escapes: "none". The default is the behavior before this change, so blocksToMarkdownLossy gives the same markdown.

Testing

  • New copy test markdownSyntaxText. It fails on main.
  • The unit and format tests pass. The drag with the side menu handle has no test: its tests are browser tests.

Notes

  • cleanHTMLToMarkdown is a public export, so its new optional parameter is an addition to the public API. An alternative without it: the clipboard code calls the serializer directly.
  • The plain text stays markdown for the structure (styles, links, lists, tables). A hard break is still a backslash and a line end, and a | in a table cell is still \|.

The fault: a copy or a drag of blocks with the text `a <b> c` writes
`a \<b> c` to the `text/plain` data. The backslash is not in the document.
A paste into another application shows it.

The cause: copy and drag make the plain text with the markdown exporter.
The exporter puts a backslash before a `<` that a markdown parser reads as
HTML (since #3194). That is correct for a markdown file, but the plain text
is for a person to read.

The fix: the markdown serializer has a new option, `escapes`. With
`escapes: "none"`, it writes the text of the blocks as it is. The copy code
and the drag code use this option. The default (`"markdown"`) is the
behavior before this change, so `blocksToMarkdownLossy` gives the same
markdown.

The option changes only the text. The backslashes that are a part of the
markdown structure stay as before: a hard break, a `|` in a table cell, and
the URL of a link.
@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
blocknote Ready Ready Preview Nov 21, 2026 6:35pm UTC
blocknote-website Ready Ready Preview Nov 21, 2026 6:35pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@3384

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@3384

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@3384

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@3384

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@3384

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@3384

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@3384

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@3384

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@3384

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@3384

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@3384

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@3384

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@3384

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@3384

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@3384

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3384

commit: a6e1cbe

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-3384/

Built to branch gh-pages at 2026-11-21 19:15 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@YousefED

Copy link
Copy Markdown
Collaborator Author

Closed: text/plain stays the markdown export, which is also the form that a paste reads. So the escape of < is correct there.

@YousefED YousefED closed this Nov 21, 2026

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — a6e1cbec Deployed Nov 21, 2026 by vercel[bot]
Preview – blocknote — a6e1cbec Deployed Nov 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant