Skip to content

docs(website): align clipboard page with the @public copy API#159

Merged
blove merged 1 commit into
mainfrom
docs-clipboard-api-alignment
Jun 6, 2026
Merged

docs(website): align clipboard page with the @public copy API#159
blove merged 1 commit into
mainfrom
docs-clipboard-api-alignment

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented Jun 5, 2026

Summary

The grid Clipboard docs page already exists, but its onCopy example was broken — it referenced functions that don't exist (serializeAsTsv / serializeAsHtmlTable) and the wrong argument shape ({ ranges, snapshot }). It also claimed onCopy could return a bare string, which the type doesn't allow.

This aligns the page with the actual @public copy API (the symbols PR 3 committed to as stable).

The real API (verified in packages/react/src/copy.ts + pretable-surface.tsx)

onCopy?: (args: SerializeRangesArgs<TRow>) => CopyPayload | null;
copyToClipboard?: (payload: CopyPayload) => void | Promise<void>;

interface SerializeRangesArgs<TRow> {
  ranges: readonly PretableCellRange[];
  visibleRows: readonly PretableVisibleRow<TRow>[];
  columns: readonly PretableColumn<TRow>[];
  copyWithHeaders?: boolean;
}
interface CopyPayload { text: string; html?: string }
function defaultCoerceForCopy(value: unknown): string;
function serializeRangesAsTsv<TRow>(args: SerializeRangesArgs<TRow>): CopyPayload | null;

Changes

  • Fix the onCopy example → real serializeRangesAsTsv + correct SerializeRangesArgs shape (a working TSV→CSV override).
  • Correct the return-type docsCopyPayload | null, not a bare string.
  • New "Building your own serializer" section → documents SerializeRangesArgs's fields and defaultCoerceForCopy (both @public, previously undocumented).
  • Document the copyToClipboard prop (also @public, previously undocumented).

Gates

  • Website docs-validation tests pass (lib/docs enumerate/load/search-index + llms.txt build) — 21 passed
  • prettier --check clean
  • Internal anchor (#default-tsv-format) and cross-links verified to exist

🤖 Generated with Claude Code

The grid clipboard page's onCopy example referenced functions that don't exist
(serializeAsTsv / serializeAsHtmlTable) and an arg shape that's wrong
(`{ ranges, snapshot }`). The real onCopy signature is
`(args: SerializeRangesArgs) => CopyPayload | null` where SerializeRangesArgs is
`{ ranges, visibleRows, columns, copyWithHeaders }`, and the return is a
CopyPayload (`{ text, html? }`) or null — never a bare string.

- Rewrite the onCopy example to use the real `serializeRangesAsTsv` and the
  correct args shape (a working TSV→CSV override).
- Correct the documented return type (CopyPayload | null, not string).
- Add a "Building your own serializer" section documenting SerializeRangesArgs's
  fields and `defaultCoerceForCopy` (both @public, previously undocumented).
- Document the `copyToClipboard` prop (also @public).

Closes the clipboard-docs-alignment follow-up from the PR 3 @public commitment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@blove blove enabled auto-merge (squash) June 5, 2026 23:59
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

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

Project Deployment Actions Updated (UTC)
pretable Ready Ready Preview, Comment Jun 6, 2026 12:00am

@blove blove merged commit a663427 into main Jun 6, 2026
13 checks passed
@blove blove deleted the docs-clipboard-api-alignment branch June 6, 2026 00:01
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Vercel preview ready

Preview: https://pretable-dd5m810xq-cacheplane.vercel.app
Commit: 1ad4c9cd58df10c19c86ce877a5189a060ce9554

Updated automatically by the deploy-preview job.

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