Skip to content

fix(editor): preserve rich HTML paste formatting - #645

Merged
murongg merged 3 commits into
v2from
fix/issue-631-rich-html-paste
Aug 5, 2026
Merged

fix(editor): preserve rich HTML paste formatting#645
murongg merged 3 commits into
v2from
fix/issue-631-rich-html-paste

Conversation

@murongg

@murongg murongg commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • prefer authored structured HTML over Markdown-looking clipboard fallback text
  • normalize styled preformatted regions into fenced code blocks while preserving line breaks and language metadata
  • preserve compact Codex-style file badges as inline Markdown links
  • limit badge normalization to single-line preformatted div/p wrappers without semantic code content
  • pass both HTML and plain text through the desktop context-menu paste path
  • add regression coverage for ChatGPT/Codex-style mixed rich content and native clipboard handling

Why

Rich content copied from ChatGPT, Codex, and similar sources can include incidental Markdown-looking text alongside valid HTML. The editor previously selected the plain-text fallback or flattened the whole payload when it encountered a styled code region. Block-styled file badges inside anchors could also be parsed as empty links plus detached code blocks. Desktop right-click paste discarded HTML entirely.

Validation

  • pnpm --filter @markra/editor test — 447 tests passed
  • pnpm --filter @markra/app test -- context-menu-items.test.ts — 14 tests passed
  • pnpm --filter @markra/app test — 1,489 tests passed
  • pnpm --filter @markra/desktop test — 149 tests passed
  • cargo test in apps/desktop/src-tauri — 271 tests passed
  • editor, app, and desktop builds passed
  • editor, app, and desktop test typechecks passed
  • cargo fmt --check passed
  • git diff --check passed

Risk

The change is scoped to clipboard HTML conversion and native context-menu paste. Plain text and raw Markdown fallback behavior remains covered. Styled link normalization requires a compact single-line div/p wrapper with monospace or preformatted whitespace evidence. Ordinary linked cards, semantic pre/code content, multiline links, and code blocks outside links remain on their existing conversion paths. Proprietary class-only rich text without semantic markup or inline preformatted styles remains best-effort.

Related Issues

Refs #631

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
markra-web Ready Ready Preview Aug 5, 2026 12:48am

@murongg
murongg merged commit cc57430 into v2 Aug 5, 2026
21 checks passed
@murongg
murongg deleted the fix/issue-631-rich-html-paste branch August 5, 2026 07:55
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