Skip to content

Make slide text easy to copy: no nav on selection + 'c' copies slide markdown#37

Merged
natolambert merged 2 commits into
mainfrom
copy-text-without-nav
Jun 20, 2026
Merged

Make slide text easy to copy: no nav on selection + 'c' copies slide markdown#37
natolambert merged 2 commits into
mainfrom
copy-text-without-nav

Conversation

@natolambert

@natolambert natolambert commented Jun 20, 2026

Copy link
Copy Markdown
Owner

What

Two related improvements for getting text/content out of slides:

  1. Selection no longer advances the slide. A click-drag (highlight gesture) or a live text selection no longer triggers next/prev, so you can highlight and copy slide text normally.
  2. Press c to copy the current slide's markdown source to the clipboard, with a small toast confirmation.

How

Selection guard (_bindClick): record the pointer-down position on mousedown; on click skip navigation when the pointer moved >8px (a drag), when there's a live non-empty selection, or on a multi-click (e.detail > 1, i.e. double/triple-click word/paragraph select). A plain click still advances exactly as before.

Copy as markdown: at build time each slide's to_markdown() source is embedded in its <section> as data-colloquium-md (base64 of UTF-8 — sidesteps HTML-escaping and unicode pitfalls). Pressing plain c decodes it and writes to the clipboard via the async Clipboard API, with an execCommand textarea fallback for insecure contexts (file://). Cmd/Ctrl+C is deliberately left alone so selecting and copying text still works. The toast is hidden in capture mode.

Note on double-click (review feedback)

The first click of a double-click can't be distinguished from a navigation click without deferring all single-click navigation ~250ms, which would make clicking through slides feel laggy. Since drag-to-select (the common copy gesture) is fully handled and e.detail blocks the later clicks of a multi-click, we accept that the very first click of a double-click may still advance rather than degrade the primary interaction.

Testing

  • 233 passed, 1 skipped; node -c syntax check + example build pass
  • Markdown round-trip verified (base64 decode of embedded attribute matches source)
  • Manual: drag-highlight and Cmd+C copy text without nav; c copies slide markdown with toast

🤖 Generated with Claude Code

A click on the slide body advances to the next slide. Previously this
fired even at the end of a text-selection drag, so highlighting text to
copy it would also jump to the next slide.

Track the pointer-down position and skip navigation on click when either:
- the pointer moved more than a small threshold between down and up
  (a drag, i.e. a highlight gesture), or
- there is a live non-empty text selection (e.g. double-click word select).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c308dcd25e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +441 to +442
const selection = window.getSelection();
if (selection && !selection.isCollapsed && selection.toString().trim()) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve double-click text selection before advancing

When a user double-clicks a word to select/copy it, the first click event has no drag distance and no live selection yet, so these guards fall through and call next()/prev() before the second click can create the selection. This means the double-click selection case still changes slides instead of selecting text; consider detecting multi-clicks (e.detail) or otherwise deferring single-click navigation long enough to distinguish it.

Useful? React with 👍 / 👎.

Add a "copy current slide as markdown" affordance: each slide's markdown
source is embedded in its <section> (base64 of UTF-8, avoiding HTML and
unicode escaping pitfalls), and pressing 'c' copies it to the clipboard
with a toast confirmation. Cmd/Ctrl+C is left alone so selected text still
copies normally. Falls back to execCommand for insecure contexts.

Also address PR review: skip navigation on multi-click (e.detail > 1) so
double/triple-click word/paragraph selection doesn't advance on the later
clicks. The first click of a double-click can't be distinguished without
deferring all navigation, which we avoid to keep slide clicks snappy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@natolambert natolambert changed the title Don't advance slides when selecting/copying text Make slide text easy to copy: no nav on selection + 'c' copies slide markdown Jun 20, 2026
@natolambert natolambert merged commit d871d21 into main Jun 20, 2026
2 checks passed
@natolambert natolambert mentioned this pull request Jun 20, 2026
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