feat(DataTable): copy as text/html so paste into rich-text editors keeps the table - #274
Merged
Merged
Conversation
DataTable copy currently writes only text/plain (TSV) and application/json. Pasting into rich-text editors (ELN, Google Docs, Notion) flattens the data into raw lines instead of a table. handleCopyHelper now also attaches an HTML <table> built from the same TSV string via tsvToHtmlTable, so any clipboard consumer that prefers text/html renders a real table. Spreadsheets keep splitting on tabs because text/plain is unchanged, and the application/json payload used for in-app paste is untouched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🚀 PR Previews Deployed! (Note: It might take a minute for GitHub Pages to update) |
Release the text/html clipboard support added in this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DataTablecopy currently writes onlytext/plain(TSV) andapplication/jsonto the clipboard. Pasting into rich-text editors (LIMS ELN, Google Docs, Notion, Word) flattens the data into raw lines instead of a table.text/htmlpayload to the clipboard inside the existingonCopycallback inhandleCopyHelper, built from the same TSV string the caller already produces.handleCopyRows,handleCopyColumn,handleCopyTable, and the in-componenthandleCopySelectedCells.Motivation
Tracked by TeselaGen/lims#13380 (board: USP). Repro: copy a few rows from a DataTable record view → paste into an ELN entry → only raw lines, no table.
Changes
packages/ui/src/DataTable/utils/handleCopyHelper.js— also callclipboardData.setData("text/html", tsvToHtmlTable(stringToCopy)).text/plainandapplication/jsonare unchanged.packages/ui/src/DataTable/utils/tsvToHtmlTable.js— new helper that splits the TSV string by\n/\t, HTML-escapes& < > ", and wraps the cells in<table><tr><td>…</td></tr></table>.packages/ui/src/DataTable/utils/tsvToHtmlTable.test.js— unit tests for single/multi row, HTML escaping, empty cells/rows, and null/undefined input.Behavior matrix
\t(works)text/plainTSV still wins<table>application/json)Test plan
bun test packages/ui/src/DataTable/utils/→ 78 pass.bun test packages/ui→ 96 pass.npx eslinton the three changed files → clean.Notes
<table><tr><td>) — no<thead>/<tbody>/<th>— to keep the helper format-agnostic. The TSV doesn't carry header semantics today; if needed, headers can be wired in later.!window.Cypressguard still short-circuits copy in test runs.🤖 Generated with Claude Code