Skip to content

Prefer markdown tables on paste#1188

Draft
makhnatkin wants to merge 1 commit into
mainfrom
fix/markdown-paste-detect
Draft

Prefer markdown tables on paste#1188
makhnatkin wants to merge 1 commit into
mainfrom
fix/markdown-paste-detect

Conversation

@makhnatkin

@makhnatkin makhnatkin commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary by Sourcery

Prefer pasting detected markdown content (currently tables) from text/plain data when available, instead of falling back to HTML clipboard content.

New Features:

  • Add markdown detection utility that parses plain text clipboard content and identifies documents containing tables.
  • Handle paste events by detecting markdown tables in text/plain clipboard data and inserting them as structured content when appropriate.

Tests:

  • Add unit tests for markdown detection logic to distinguish markdown tables from plain text or raw HTML.
  • Add integration-style test to verify that clipboard paste prefers markdown tables from text/plain over equivalent HTML table content.

@sourcery-ai

sourcery-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds markdown-aware paste handling that prefers markdown tables from text/plain clipboard data over HTML, along with detection utilities and tests around table parsing.

File-Level Changes

Change Details Files
Introduce markdown detection during paste to prioritize markdown tables from text/plain clipboard data.
  • Import markdown detection helper into clipboard behavior module.
  • Add early paste handler that checks text/plain clipboard content with the existing markdown parser.
  • Skip markdown detection for YFM-formatted clipboard data and when inside code blocks.
  • Parse detected markdown into a ProseMirror slice and dispatch a tracked paste transaction with additional metrics.
  • Log a dedicated paste-detected-markdown event including the detection reason.
packages/editor/src/extensions/behavior/Clipboard/clipboard.ts
Add markdown detection utility that uses the existing parser to identify documents containing table nodes.
  • Define types for markdown detection reason and result to describe parser output and detection cause.
  • Implement detectMarkdown helper that parses text and returns a structured result only when a table node is present.
  • Implement a hasTableNode traversal that short-circuits once a table node is found, using shared table-utils helpers.
packages/editor/src/extensions/behavior/Clipboard/markdown-detect.ts
Add tests validating markdown table detection and clipboard behavior preference for markdown over HTML.
  • Set up a test schema and extensions that include base, markdown table, YFM table, and clipboard behavior.
  • Add tests for detectMarkdown to ensure it detects markdown tables and ignores plain text and raw HTML input.
  • Add an integration test that simulates a paste with both text/plain markdown table and text/html table, asserting that the resulting document matches the markdown-parsed table structure.
  • Provide a helper for the expected table document structure used across tests.
packages/editor/src/extensions/behavior/Clipboard/markdown-detect.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gravity-ui

gravity-ui Bot commented Jul 23, 2026

Copy link
Copy Markdown

Storybook Deployed

@gravity-ui

gravity-ui Bot commented Jul 23, 2026

Copy link
Copy Markdown

🎭 Playwright Report

@makhnatkin
makhnatkin force-pushed the fix/markdown-paste-detect branch from 4f54b86 to 00aff70 Compare July 23, 2026 15:22
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