Mobile: no way to select text at all — request for a proper native-like mobile selection mode

Aperta
#706 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start by reading PanPluginConfig.defaultMode, PanMode, SelectionPlugin, createTextSelectionHandler, and notifyPage to map how touch input and selection rendering currently interact. Define the mobile selection mode's API and interaction boundaries before implementation. Done should include documented long-press selection, adjustable selection handles, edge auto-scroll, continued one-finger panning, and coverage for the reported visibility and pointer-event cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Core ask: long-press to select text on mobile, while still being able to pan/scroll the page — matching how native mobile PDF/document viewers behave. Right now neither is fully possible together.

On touch devices, PanPluginConfig.defaultMode defaults to 'mobile', which auto-activates pan-only mode via the PanMode utility. This means out of the box, mobile users cannot select text at all — dragging on the page only pans/scrolls, since text selection is only enabled for pointerMode by default, and pan mode's own wantsRawTouch:false hands touch gestures entirely to native scrolling.

For an app that needs mobile text selection (copy text, highlight annotations, etc.), this is a significant gap. We tried to work around it ourselves (long-press-to-select-word, then drag handles to extend the selection, like native OS text selection), but ran into real limitations of the current architecture:

  1. No public API to drive a selection programmatically (only SelectionPlugin's private beginSelection/updateSelection/endSelection/selectWord do this, not meant for external use).
  2. The built-in click-drag selection handler (createTextSelectionHandler) clears the selection on every new pointerdown, which makes any custom "drag an existing selection's endpoint" gesture built via simulated pointer events fall apart immediately.
  3. notifyPage() only renders selection rects when enabledModesPerDoc has showSelectionRects configured for the currently active interaction mode — since panMode has no selection config by default, a selection created via selectWord() while panning is silently invisible unless you configure this yourself.
  4. Since PDFs are rendered as bitmap/tiles (no native text layer), there's no way to get free native browser text-selection UX (long-press, drag handles, auto-scroll) — everything has to be hand-built against the plugin's internals.

Who else this would help: any embedPDF-based app that targets mobile browsers/PWAs and needs users to copy text or create text-anchored annotations (highlight, underline, comments) — which is a pretty core PDF-viewer use case, not a niche one. Right now those apps either ship mobile as pan-only/read-only (no way to select or annotate text), or have to hand-build the same workaround we did against private internals. A first-class mobile selection mode would remove that whole category of custom, fragile code for anyone building on top of embedPDF.

What we'd love to see: a first-class, documented "mobile selection mode" shipped by the library itself — long-press to select a word, drag handles to extend the selection across lines/pages, with auto-scroll near viewport edges, all while normal one-finger drag still pans the page. Similar to what native OS text views provide.

Happy to share more details about our specific attempt/findings if useful for design discussion.

Lingua principale
TypeScript
Stelle
4.5k
Fork
317
Merge medio
10h 16m
PR unite (30g)
174

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di embedpdf/embed-pdf-viewer

Tutte le issue di embedpdf/embed-pdf-viewer

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.