Commit c255558
fix: backslash newlines when copying from a code block (#2709)
* fix: backslash newlines when copying from a code block
When copying inline content from inside a code block, the text/plain
clipboard payload had a backslash before every newline (markdown's
hard-break syntax) and the text/html had `<br>` separators inside the
code instead of literal newlines.
Two changes fix this:
- copyExtension routes selections inside a code block through the
block-export path so the code block's own toExternalHTML produces
the proper `<pre><code>` wrapper.
- serializeInlineContentExternalHTML now plumbs blockType through to
inlineContentToNodes (mirroring the internal HTML serializer) so
`\n` in code-block content stays as literal text instead of being
split into hardBreak nodes that render as `<br>`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: drop `as const` from PRETTIFY_OPTIONS to satisfy htmlfy types
`as const` typed `ignore` as a readonly tuple, which doesn't match
`UserConfig.ignore: string[]`, breaking CI typecheck.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test: integrate code-block copy regression into existing copy test suite
Address PR review:
- Drop standalone codeBlockMarkdown.test.ts; add `codeBlockFullContent` and
`codeBlockPartialSelection` cases to copyTestInstances.ts and snapshot
text/plain markdown for all copy test instances via a new
`Copy tests (Markdown)` describe block (mirrors the export test pattern).
- Trim verbose comments in copyExtension and serializeBlocksExternalHTML.
- copyPasteEquality executor now passes the actual markdown payload as the
text/plain MIME instead of a literal "text" placeholder, so paste handlers
that prefer text/plain (e.g. inside code blocks) round-trip correctly.
- Update mixedInParagraph snapshots: prettify's `ignore: ["code"]` preserves
trailing whitespace inside `<code>` spans, which is the actual HTML output.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8a03b69 commit c255558
33 files changed
Lines changed: 234 additions & 27 deletions
File tree
- packages/core/src/api
- clipboard/toClipboard
- exporters/html/util
- tests/src/unit
- core
- clipboard/copy
- __snapshots__/text
- html
- plain
- formatConversion/export/__snapshots__
- blocknoteHTML
- codeBlock
- style
- html
- codeBlock
- style
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
144 | 155 | | |
145 | 156 | | |
146 | 157 | | |
| |||
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
| |||
262 | 270 | | |
263 | 271 | | |
264 | 272 | | |
265 | | - | |
| 273 | + | |
266 | 274 | | |
267 | 275 | | |
268 | 276 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments