// @vitest-environment jsdom // // The text/plain paste path: when the clipboard carries no usable HTML, the // paste handler runs the text through markdownToHtml and then through the same // block builder the HTML path uses. import { describe, expect, test } from "vitest"; import { markdownToHtml } from "src/htmlMarkdownParsers"; import { outline, paste } from "./testHelpers"; const pasteText = (text: string) => paste(markdownToHtml(text)); describe("text/plain", () => { test.each<[string, string, string[]]>([ [ "every line becomes its own block", "Line one\nLine two\n\nNew para", ["text: Line one", "text: Line two", "text: New para"], ], [ "a setext heading is not split from its underline", "Title\n=====", ["h1: Title"], ], [ "a multi-line blockquote stays one blockquote", "> quoted line one\n> quoted line two", ["blockquote: quoted line one quoted line two"], ], [ "a GFM table parses as a table, not literal pipes", "| a | b |\n| - | - |\n| 1 | 2 |", ["text: a | b", "text: 1 | 2"], ], [ "nested lists keep their depth and style", "- one\n- two\n 1. nested", ["ul-li: one", "ul-li: two", " ol-li: nested"], ], [ "task list state lands on the block", "- [ ] todo\n- [x] done", ["ul-li[ ]: todo", "ul-li[x]: done"], ], [ "a horizontal rule becomes its own block", "above\n\n---\n\nbelow", ["text: above", "horizontal-rule: ", "text: below"], ], [ // remarkRehype drops raw HTML nodes, so this used to convert to an empty // string and the paste silently did nothing. "text that is entirely HTML markup still pastes", "