MeldUI

Plugin: Selection

Text selection on the page and copy-to-clipboard.

The Selection plugin enables text selection on PDF pages and provides the underlying selection state used by the highlight tool.

Enabling flag

The Selection plugin is always registereduseSelection is always available. features.selection controls whether the SelectionLayer (drag-to-select on the page) is rendered. It’s also effectively required by features.annotations, since highlights need to know what text was selected.

What it does

  • Native text selection via drag — the engine reconstructs text runs from PDFium and lets the user select across them
  • Ctrl/Cmd + C copies the selected text to clipboard
  • Selection state is consumed by the annotation plugin to create highlights from a drag-selected region
  • Selection persists across scroll until cleared

Composable

useSelection(documentId) from @embedpdf/plugin-selection/vue. Returns reactive selection state including the selected text and bounding rectangles per page.

Events

onEndSelection callback — fires when a selection completes. DocumentViewer uses this to capture selectedText on newly-created highlights.

Dependencies

  • viewport
  • interaction-manager (always registered)

Configuration

No featureConfig.

When you’d touch it directly

To build a custom “copy as quote” action that includes the page number alongside the selected text:

import { useSelectionCapability } from '@embedpdf/plugin-selection/vue'

const cap = useSelectionCapability()
cap.provides.value?.onEndSelection((text, pageRanges) => {
  copyToClipboard(`"${text}" — page ${pageRanges[0].pageIndex + 1}`)
})

See also