Skip to content

🐛 Add optional automatic copying for highlighted PDF text - #201

Open
JFWooten4 wants to merge 1 commit into
mainfrom
selection-auto-copy-toggle-20261018
Open

JFWooten4 wants to merge 1 commit into
mainfrom
selection-auto-copy-toggle-20261018

Conversation

@JFWooten4

Copy link
Copy Markdown
Member

Summary

Add More PDF tools → Automatically copy selected text, a persistent, off-by-default preference for the PDF viewer.

  • Disabled: PDF text selection only displays its highlight; the clipboard stays untouched until an explicit Copy action.
  • Enabled: after a primary-button text selection finishes inside the PDF text layer, automatically trigger the same browser Copy action used by Ctrl/Cmd+C. This preserves the selected highlight while honoring the existing Copy selection as Markdown, tagged-paragraph reflow, and footnote behavior introduced in 🖌️ Add opt-in Markdown copying for PDF selections #175.
  • Ignore toolbar and external-page selections, secondary-button gestures, collapsed or empty selections, canceled drags, and focus-loss interruptions.
  • If the native Copy command is denied, fall back to clipboard text writing using the selected text (and existing formatting where available); report failure if writing also fails.

Tests

Added tests/auto-copy-selection.test.mjs and registered it in npm test to cover default-off behavior, valid selected PDF text, foreign or secondary-button selection, collapsed or out-of-layer selection, pointer cancellation, blur, and failed-command fallback.

Verification: Compared branch against main: one nonempty commit, with exactly the seven intended file changes and no unrelated modifications. Browser/runtime tests were not executed locally in this environment; CI and interactive manual verification remain necessary.

Manual verification

  1. Select words with the toggle off; the highlight should appear without changing the clipboard.
  2. Enable the toggle and drag-select words (including the end of a line); paste into another application. The copied text should correspond to the selected text and the visual selection should stay highlighted.
  3. With Markdown copying enabled, repeat on italic/bold passages and passages with footnotes; paste to confirm the normal Copy formatting is reused.
  4. Confirm selections in toolbar fields and right-click gestures do not overwrite the clipboard.

Add a persisted auto-copy preference that copies selected PDF text on pointer release, preserving the existing highlight and manual copy formatting behavior. Cover disabled mode, pointer gesture boundaries, cancellation, and clipboard fallback with regression tests.

Co-authored-by: Codex Web <noreply@openai.com>
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