From c255558b2d4f2be6453c67df81bb702a1a586909 Mon Sep 17 00:00:00 2001
From: Nick Perez
Date: Fri, 15 May 2026 10:06:22 +0200
Subject: [PATCH] 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 ` ` 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 `
` 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 ` `.
Co-Authored-By: Claude Opus 4.7 (1M context)
* 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)
* 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 `` spans, which is the actual HTML output.
---------
Co-authored-by: Claude Opus 4.7 (1M context)
---
.../clipboard/toClipboard/copyExtension.ts | 13 +++-
.../html/util/serializeBlocksExternalHTML.ts | 16 +++--
.../text/html/codeBlockFullContent.html | 3 +
.../text/html/codeBlockPartialSelection.html | 3 +
.../__snapshots__/text/plain/basicBlocks.md | 24 +++++++
.../text/plain/basicBlocksWithProps.md | 24 +++++++
.../__snapshots__/text/plain/childToParent.md | 3 +
.../text/plain/childrenToNextParent.md | 7 +++
.../plain/childrenToNextParentsChildren.md | 13 ++++
.../text/plain/codeBlockFullContent.md | 2 +
.../text/plain/codeBlockPartialSelection.md | 2 +
.../copy/__snapshots__/text/plain/image.md | 1 +
.../text/plain/mentionWithBackgroundColor.md | 5 ++
.../text/plain/multipleChildren.md | 5 ++
.../text/plain/multipleStyledText.md | 1 +
.../__snapshots__/text/plain/nestedImage.md | 5 ++
.../text/plain/partialChildToParent.md | 3 +
.../__snapshots__/text/plain/styledText.md | 1 +
.../__snapshots__/text/plain/tableAllCells.md | 4 ++
.../__snapshots__/text/plain/tableCell.md | 3 +
.../__snapshots__/text/plain/tableCellText.md | 1 +
.../copy/__snapshots__/text/plain/tableCol.md | 4 ++
.../copy/__snapshots__/text/plain/tableRow.md | 3 +
.../__snapshots__/text/plain/unstyledText.md | 1 +
.../core/clipboard/copy/copyTestInstances.ts | 62 ++++++++++++++++++-
.../unit/core/clipboard/copy/runTests.test.ts | 15 ++++-
.../codeBlock/contains-newlines.html | 4 +-
.../blocknoteHTML/codeBlock/empty.html | 4 +-
.../blocknoteHTML/style/mixedInParagraph.html | 2 +-
.../html/codeBlock/contains-newlines.html | 9 +--
.../html/style/mixedInParagraph.html | 2 +-
.../copyPasteEqualityTestExecutors.ts | 4 +-
.../export/exportTestExecutors.ts | 12 ++--
33 files changed, 234 insertions(+), 27 deletions(-)
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/html/codeBlockFullContent.html
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/html/codeBlockPartialSelection.html
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/basicBlocks.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/basicBlocksWithProps.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childToParent.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childrenToNextParent.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childrenToNextParentsChildren.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/codeBlockFullContent.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/codeBlockPartialSelection.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/image.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/mentionWithBackgroundColor.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/multipleChildren.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/multipleStyledText.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/nestedImage.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/partialChildToParent.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/styledText.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableAllCells.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCell.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCellText.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCol.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableRow.md
create mode 100644 tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/unstyledText.md
diff --git a/packages/core/src/api/clipboard/toClipboard/copyExtension.ts b/packages/core/src/api/clipboard/toClipboard/copyExtension.ts
index 7812ae3c2e..e150af1309 100644
--- a/packages/core/src/api/clipboard/toClipboard/copyExtension.ts
+++ b/packages/core/src/api/clipboard/toClipboard/copyExtension.ts
@@ -140,7 +140,18 @@ export function selectedFragmentToHTML<
editor,
);
- const markdown = cleanHTMLToMarkdown(externalHTML);
+ // Code blocks are treated differently for copying: text/plain is the raw
+ // selected text instead of markdown.
+ const { $from, $to } = view.state.selection;
+ const parentBlockType = $from.parent.type.name;
+ const parentBlockSpec = editor.blockImplementations[parentBlockType as any];
+ const isPurelyInsideCodeBlock =
+ $from.sameParent($to) &&
+ parentBlockSpec?.implementation.meta?.code === true;
+
+ const markdown = isPurelyInsideCodeBlock
+ ? view.state.doc.textBetween($from.pos, $to.pos)
+ : cleanHTMLToMarkdown(externalHTML);
return { clipboardHTML, externalHTML, markdown };
}
diff --git a/packages/core/src/api/exporters/html/util/serializeBlocksExternalHTML.ts b/packages/core/src/api/exporters/html/util/serializeBlocksExternalHTML.ts
index 894c0f1c1b..72569ffced 100644
--- a/packages/core/src/api/exporters/html/util/serializeBlocksExternalHTML.ts
+++ b/packages/core/src/api/exporters/html/util/serializeBlocksExternalHTML.ts
@@ -37,7 +37,7 @@ export function serializeInlineContentExternalHTML<
editor: BlockNoteEditor,
blockContent: PartialBlock["content"],
serializer: DOMSerializer,
- options?: { document?: Document },
+ options?: { document?: Document; blockType?: string },
) {
let nodes: Node[];
@@ -45,9 +45,17 @@ export function serializeInlineContentExternalHTML<
if (!blockContent) {
throw new Error("blockContent is required");
} else if (typeof blockContent === "string") {
- nodes = inlineContentToNodes([blockContent], editor.pmSchema);
+ nodes = inlineContentToNodes(
+ [blockContent],
+ editor.pmSchema,
+ options?.blockType,
+ );
} else if (Array.isArray(blockContent)) {
- nodes = inlineContentToNodes(blockContent, editor.pmSchema);
+ nodes = inlineContentToNodes(
+ blockContent,
+ editor.pmSchema,
+ options?.blockType,
+ );
} else if (blockContent.type === "tableContent") {
nodes = tableContentToNodes(blockContent, editor.pmSchema);
} else {
@@ -262,7 +270,7 @@ function serializeBlock<
editor,
block.content as any, // TODO
serializer,
- options,
+ { ...options, blockType: block.type },
);
ret.contentDOM.appendChild(ic);
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/codeBlockFullContent.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/codeBlockFullContent.html
new file mode 100644
index 0000000000..2d3784f358
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/codeBlockFullContent.html
@@ -0,0 +1,3 @@
+const a = 1;
+
+const b = 2;
\ No newline at end of file
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/codeBlockPartialSelection.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/codeBlockPartialSelection.html
new file mode 100644
index 0000000000..8ff30e3da7
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/codeBlockPartialSelection.html
@@ -0,0 +1,3 @@
+onst a = 1;
+
+const b = 2
\ No newline at end of file
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/basicBlocks.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/basicBlocks.md
new file mode 100644
index 0000000000..59e94f2356
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/basicBlocks.md
@@ -0,0 +1,24 @@
+Paragraph 1
+
+# Heading 1
+
+1. Numbered List Item 1
+
+* Bullet List Item 1
+* [ ] Check List Item 1
+* Toggle List Item 1
+
+```text
+console.log("Hello World");
+```
+
+| | |
+| ------------ | ------------ |
+| Table Cell 1 | Table Cell 2 |
+| Table Cell 3 | Table Cell 4 |
+
+
+
+***
+
+Paragraph 2
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/basicBlocksWithProps.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/basicBlocksWithProps.md
new file mode 100644
index 0000000000..906cfc560e
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/basicBlocksWithProps.md
@@ -0,0 +1,24 @@
+Paragraph 1
+
+## Heading 1
+
+2. Numbered List Item 1
+
+* Bullet List Item 1
+* [x] Check List Item 1
+* Toggle List Item 1
+
+```typescript
+console.log("Hello World");
+```
+
+| | |
+| ------------ | ------------ |
+| Table Cell 1 | Table Cell 2 |
+| Table Cell 3 | Table Cell 4 |
+
+Placeholder
+
+***
+
+Paragraph 2
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childToParent.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childToParent.md
new file mode 100644
index 0000000000..c843d3b34c
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childToParent.md
@@ -0,0 +1,3 @@
+Paragraph 1
+
+Nested Paragraph 1
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childrenToNextParent.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childrenToNextParent.md
new file mode 100644
index 0000000000..a1c8bcb403
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childrenToNextParent.md
@@ -0,0 +1,7 @@
+Nested Paragraph 1
+
+Nested Paragraph 2
+
+Nested Paragraph 3
+
+Paragraph 2
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childrenToNextParentsChildren.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childrenToNextParentsChildren.md
new file mode 100644
index 0000000000..3350bf4006
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/childrenToNextParentsChildren.md
@@ -0,0 +1,13 @@
+Nested Paragraph 1
+
+Nested Paragraph 2
+
+Nested Paragraph 3
+
+Paragraph 2
+
+Nested Paragraph 4
+
+Nested Paragraph 5
+
+Nested Paragraph 6
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/codeBlockFullContent.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/codeBlockFullContent.md
new file mode 100644
index 0000000000..781d5f3999
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/codeBlockFullContent.md
@@ -0,0 +1,2 @@
+const a = 1;
+const b = 2;
\ No newline at end of file
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/codeBlockPartialSelection.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/codeBlockPartialSelection.md
new file mode 100644
index 0000000000..b911c40cba
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/codeBlockPartialSelection.md
@@ -0,0 +1,2 @@
+onst a = 1;
+const b = 2
\ No newline at end of file
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/image.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/image.md
new file mode 100644
index 0000000000..02f1b078b9
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/image.md
@@ -0,0 +1 @@
+
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/mentionWithBackgroundColor.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/mentionWithBackgroundColor.md
new file mode 100644
index 0000000000..430c08db48
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/mentionWithBackgroundColor.md
@@ -0,0 +1,5 @@
+Paragraph 1
+
+@User
+
+Paragraph 2
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/multipleChildren.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/multipleChildren.md
new file mode 100644
index 0000000000..cfb1e11c1c
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/multipleChildren.md
@@ -0,0 +1,5 @@
+Nested Paragraph 1
+
+Nested Paragraph 2
+
+Nested Paragraph 3
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/multipleStyledText.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/multipleStyledText.md
new file mode 100644
index 0000000000..2a9e4dfd67
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/multipleStyledText.md
@@ -0,0 +1 @@
+Unstyled TextItalic TextBold Text
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/nestedImage.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/nestedImage.md
new file mode 100644
index 0000000000..8ac9591d8a
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/nestedImage.md
@@ -0,0 +1,5 @@
+Paragraph 1
+
+
+
+Nested Paragraph 1
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/partialChildToParent.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/partialChildToParent.md
new file mode 100644
index 0000000000..d8e105dbc6
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/partialChildToParent.md
@@ -0,0 +1,3 @@
+aragraph 1
+
+N
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/styledText.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/styledText.md
new file mode 100644
index 0000000000..e0c33d6a00
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/styledText.md
@@ -0,0 +1 @@
+Italic Text
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableAllCells.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableAllCells.md
new file mode 100644
index 0000000000..4cce45d6ef
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableAllCells.md
@@ -0,0 +1,4 @@
+| | |
+| ------------ | ------------ |
+| Table Cell 1 | Table Cell 2 |
+| Table Cell 3 | Table Cell 4 |
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCell.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCell.md
new file mode 100644
index 0000000000..e4a55e08be
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCell.md
@@ -0,0 +1,3 @@
+| |
+| ------------ |
+| Table Cell 1 |
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCellText.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCellText.md
new file mode 100644
index 0000000000..bd5288ec6d
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCellText.md
@@ -0,0 +1 @@
+Table Cell 1
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCol.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCol.md
new file mode 100644
index 0000000000..54fa7b06a2
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableCol.md
@@ -0,0 +1,4 @@
+| |
+| ------------ |
+| Table Cell 1 |
+| Table Cell 3 |
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableRow.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableRow.md
new file mode 100644
index 0000000000..4489a26e88
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/tableRow.md
@@ -0,0 +1,3 @@
+| | |
+| ------------ | ------------ |
+| Table Cell 1 | Table Cell 2 |
diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/unstyledText.md b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/unstyledText.md
new file mode 100644
index 0000000000..44a4f52867
--- /dev/null
+++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/plain/unstyledText.md
@@ -0,0 +1 @@
+Unstyled Text
diff --git a/tests/src/unit/core/clipboard/copy/copyTestInstances.ts b/tests/src/unit/core/clipboard/copy/copyTestInstances.ts
index 17fa89e08d..4bd34489c0 100644
--- a/tests/src/unit/core/clipboard/copy/copyTestInstances.ts
+++ b/tests/src/unit/core/clipboard/copy/copyTestInstances.ts
@@ -7,7 +7,10 @@ import {
TestStyleSchema,
} from "../../testSchema.js";
import { CopyTestCase } from "../../../shared/clipboard/copy/copyTestCase.js";
-import { testCopyHTML } from "../../../shared/clipboard/copy/copyTestExecutors.js";
+import {
+ testCopyHTML,
+ testCopyMarkdown,
+} from "../../../shared/clipboard/copy/copyTestExecutors.js";
import {
getPosOfTableCellNode,
getPosOfTextNode,
@@ -676,4 +679,61 @@ export const copyTestInstancesHTML: TestInstance<
},
executeTest: testCopyHTML,
},
+ {
+ testCase: {
+ name: "codeBlockFullContent",
+ document: [
+ {
+ type: "codeBlock",
+ props: { language: "javascript" },
+ content: "const a = 1;\nconst b = 2;",
+ },
+ ],
+ getCopySelection: (doc) => {
+ const text = "const a = 1;\nconst b = 2;";
+ const startPos = getPosOfTextNode(doc, text);
+ const endPos = getPosOfTextNode(doc, text, true);
+
+ return TextSelection.create(doc, startPos, endPos);
+ },
+ },
+ executeTest: testCopyHTML,
+ },
+ {
+ testCase: {
+ name: "codeBlockPartialSelection",
+ document: [
+ {
+ type: "codeBlock",
+ props: { language: "javascript" },
+ content: "const a = 1;\nconst b = 2;",
+ },
+ ],
+ getCopySelection: (doc) => {
+ const text = "const a = 1;\nconst b = 2;";
+ const startPos = getPosOfTextNode(doc, text);
+ // Select `onst a = 1;\nconst b = 2` — partial, spans a newline.
+ return TextSelection.create(
+ doc,
+ startPos + "c".length,
+ startPos + text.length - ";".length,
+ );
+ },
+ },
+ executeTest: testCopyHTML,
+ },
];
+
+// text/plain payloads — exercises the same selections as above but snapshots
+// the markdown output. Code-block selections should emit raw text (no markdown
+// fences or `\` line-break escaping) so the clipboard round-trips back into a
+// code block without leaving leftover syntax.
+export const copyTestInstancesMarkdown: TestInstance<
+ CopyTestCase,
+ TestBlockSchema,
+ TestInlineContentSchema,
+ TestStyleSchema
+>[] = copyTestInstancesHTML.map(({ testCase }) => ({
+ testCase,
+ executeTest: testCopyMarkdown,
+}));
diff --git a/tests/src/unit/core/clipboard/copy/runTests.test.ts b/tests/src/unit/core/clipboard/copy/runTests.test.ts
index f7f2474d03..eb2770b4ab 100644
--- a/tests/src/unit/core/clipboard/copy/runTests.test.ts
+++ b/tests/src/unit/core/clipboard/copy/runTests.test.ts
@@ -2,7 +2,10 @@ import { describe, it } from "vitest";
import { createTestEditor } from "../../createTestEditor.js";
import { testSchema } from "../../testSchema.js";
-import { copyTestInstancesHTML } from "./copyTestInstances.js";
+import {
+ copyTestInstancesHTML,
+ copyTestInstancesMarkdown,
+} from "./copyTestInstances.js";
// Tests for verifying content that gets put on the clipboard when copying
// within the editor. Used for as many cases as possible to ensure each block or
@@ -16,3 +19,13 @@ describe("Copy tests (HTML)", () => {
});
}
});
+
+describe("Copy tests (Markdown)", () => {
+ const getEditor = createTestEditor(testSchema);
+
+ for (const { testCase, executeTest } of copyTestInstancesMarkdown) {
+ it(`${testCase.name}`, async () => {
+ await executeTest(getEditor(), testCase);
+ });
+ }
+});
diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html
index f169947d1e..bf789c1a7d 100644
--- a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html
+++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html
@@ -13,7 +13,9 @@