Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

spec(AST-062): a rich paste into a code block lands as plain text (#10417)

Cindy Zhang4962d932dd6a
diff --git a/docs/specs/AST-062-richtext-lossless-markdown/spec.md b/docs/specs/AST-062-richtext-lossless-markdown/spec.md
index f98acc0271..718df6b6e5 100644
--- a/docs/specs/AST-062-richtext-lossless-markdown/spec.md
+++ b/docs/specs/AST-062-richtext-lossless-markdown/spec.md
@@ -31,8 +31,8 @@ No source text disappears because the editor could not represent it.
- Which editor engine serves document editing, and the stored value an editor
reads and writes. This record governs what RichText's Markdown import and
- export return, not whether a product stores Markdown, editor state, or
- something else.
+ export return, and what a code block holds after a paste (FR3), not whether
+ a product stores Markdown, editor state, or something else.
- Which constructs render as structures. `spec:AST-061` owns how supported
constructs look and what they mean once rendered.
- The form of content a person writes or changes. Regenerated Markdown uses the
@@ -58,7 +58,9 @@ No source text disappears because the editor could not represent it.
- **FR3 — Regenerated Markdown means what the editor showed.** A regenerated
block's Markdown imports again as the same structure the editor showed: text
that was literal stays literal, so an edited paragraph that begins with an
- escaped `\#` never reloads as a heading.
+ escaped `\#` never reloads as a heading. A code block holds only code, so a
+ rich paste into a code block lands as plain text: no heading, list, table,
+ formatting, or plugin node nests inside it.
- **FR4 — The document's envelope and line endings survive.** A byte order
mark and anything before the first block are kept exactly, and the bytes
after the last block are kept with it. A regenerated block keeps the line
@@ -79,7 +81,9 @@ No source text disappears because the editor could not represent it.
- Supported feature/engine floor: wherever RichText's Markdown import and
export run, including headless in Node.
- Unsupported behavior: none; FR1 and FR5 cover every input.
-- Browser evidence: not required; the contract is string in, string out.
+- Browser evidence: not required. Import and export are string in, string
+ out. FR3's paste clause is proven in a mounted editor that receives the
+ editor's paste commands in jsdom.
## Current-state impact
@@ -89,14 +93,14 @@ form until it is imported again.
## Verification
-| Contract | Verification | Representative states | Mutation or failure expectation |
-| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
-| FR1 | Conformance corpus of at least 30 documents, imported and exported with no edit, headless and through a mounted editor with the shipped plugins | Nested lists at 2- and 3-space indentation; backslash escapes such as `\#`; character references such as `©`; fenced code with an info string and metadata; tables; unsupported HTML, reference definitions, and setext headings; trailing whitespace and missing final newline; a bare URL under the autolink plugin | Exporting any block in canonical form instead of its authored bytes fails |
-| FR2 | The same corpus with one block edited | An edit in the first, a middle, and the last block; a new block inserted; a block deleted | Any untouched block changing a byte fails |
-| FR3 | Edited blocks exported and imported again | An edited paragraph that starts with an escaped `\#`, contains escaped `*` and `[`, or starts with `1.` | A regenerated block that imports as a different structure fails |
-| FR4 | Envelope and line endings, untouched and edited | A byte order mark; leading blank lines; CRLF, LF, and a missing final newline, with the first, a middle, and the last block edited and a block added | A dropped envelope byte, or an LF inside a CRLF document, fails |
-| FR5 | Unsupported constructs edited and untouched | Raw HTML block; reference definition; footnote | A character the edit did not delete missing from the export fails |
-| FR6 | The corpus run with the default transformers and shipped plugins, including tables and autolinks | Every shipped transformer represented | A shipped transformer that bypasses preservation fails |
+| Contract | Verification | Representative states | Mutation or failure expectation |
+| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
+| FR1 | Conformance corpus of at least 30 documents, imported and exported with no edit, headless and through a mounted editor with the shipped plugins | Nested lists at 2- and 3-space indentation; backslash escapes such as `\#`; character references such as `©`; fenced code with an info string and metadata; tables; unsupported HTML, reference definitions, and setext headings; trailing whitespace and missing final newline; a bare URL under the autolink plugin | Exporting any block in canonical form instead of its authored bytes fails |
+| FR2 | The same corpus with one block edited | An edit in the first, a middle, and the last block; a new block inserted; a block deleted | Any untouched block changing a byte fails |
+| FR3 | Edited blocks exported and imported again; rich pastes into a code block in a mounted editor | An edited paragraph that starts with an escaped `\#`, contains escaped `*` and `[`, or starts with `1.`; a paste with HTML and plain text, an HTML-only paste, blocks copied from an editor, and a Markdown plugin node | A regenerated block that imports as a different structure, or a paste that leaves an element, a decorator, or formatted text in the code block, fails |
+| FR4 | Envelope and line endings, untouched and edited | A byte order mark; leading blank lines; CRLF, LF, and a missing final newline, with the first, a middle, and the last block edited and a block added | A dropped envelope byte, or an LF inside a CRLF document, fails |
+| FR5 | Unsupported constructs edited and untouched | Raw HTML block; reference definition; footnote | A character the edit did not delete missing from the export fails |
+| FR6 | The corpus run with the default transformers and shipped plugins, including tables and autolinks | Every shipped transformer represented | A shipped transformer that bypasses preservation fails |
## Decision log