# @embedpdf/vue — ./selection ArmedSelectionHandle [InterfaceDeclaration] (from packages/plugin/selection/src/handles.ts): export interface ArmedSelectionHandle{ base: Point; drag: SelectionHandleDragSession; } HANDLE_BAR [VariableDeclaration] (from packages/plugin/selection/src/handles.ts): HANDLE_BAR = 2 HANDLE_HEAD [VariableDeclaration] (from packages/plugin/selection/src/handles.ts): HANDLE_HEAD = 12 HANDLE_PAD [VariableDeclaration] (from packages/plugin/selection/src/handles.ts): HANDLE_PAD = 14 SELECTION_DEFAULTS [VariableDeclaration] (from packages/plugin/selection/src/contract.ts): SELECTION_DEFAULTS: SelectionSettings ={ dragThresholdPx: 4, color: null, handles:{ color: null, shadow: '0 1px 4px rgb(0 0 0 / 0.35)'} , } SelectionAnchor [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface SelectionAnchor{ readonly page: PageRef; readonly bounds: Rect; } SelectionCapability [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface SelectionCapability extends SettingsApi{ canSelect(): boolean; canCopy(): boolean; select(range: SelectionRangeInput): void; selectAll(): void; selectPage(page: PageRef | number): void; selectWordAt(page: PageRef | number, point: Point): boolean; selectLineAt(page: PageRef | number, point: Point): boolean; extendTo(page: PageRef | number, point: Point): void; clear(): void; hasSelection(): boolean; isSelecting(): boolean; getSnapshot(): SelectionSnapshot; getRange(): TextRange | null; listSelectedPages(): readonly PageRef[]; listSegments(page: PageRef | number): readonly SelectionSegment[]; listRects(page: PageRef | number): readonly Rect[]; getAnchor(): SelectionAnchor | null; readText(options?: OperationOptions): Promise; readTextInRange(range: TextRange, options?: OperationOptions): Promise; readonly onChanged: EventHook; readonly onCommitted: EventHook; readonly onCleared: EventHook; } SelectionChangedEvent [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface SelectionChangedEvent{ readonly range: TextRange | null; readonly pages: readonly PageRef[]; } SelectionClearedEvent [TypeAliasDeclaration] (from packages/plugin/selection/src/contract.ts): export type SelectionClearedEvent = Record; SelectionClipboard [VueComponent] (from packages/framework/vue/src/selection/SelectionClipboard.vue): props { prefetch?: boolean; target?: MaybeRefOrGetter; }; defaults { prefetch: true}; emits { refused: []; } SelectionCommittedEvent [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface SelectionCommittedEvent{ readonly range: TextRange; } SelectionConfig [TypeAliasDeclaration] (from packages/plugin/selection/src/contract.ts): export type SelectionConfig = DeepPartial; SelectionEndpoint [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface SelectionEndpoint{ readonly page: PageRef; readonly glyphQuad: Quad; readonly advance: 1 | -1; readonly rect: Rect; } SelectionHandleDragSession [InterfaceDeclaration] (from packages/plugin/selection/src/handles.ts): export interface SelectionHandleDragSession{ move(overlay: Point): void; end(): void; } SelectionHandleEndpoint [InterfaceDeclaration] (from packages/plugin/selection/src/handles.ts): export interface SelectionHandleEndpoint{ page: PageRef; glyphQuad: Quad; advance: 1 | -1; } SelectionHandleEndpoints [InterfaceDeclaration] (from packages/plugin/selection/src/handles.ts): export interface SelectionHandleEndpoints{ start: SelectionHandleEndpoint; end: SelectionHandleEndpoint; } SelectionHandleGeometry [InterfaceDeclaration] (from packages/plugin/selection/src/handles.ts): export interface SelectionHandleGeometry{ bar:{ from: Point; to: Point} ; length: number; rotation: number; upright: boolean; head: Point; } SelectionHandleStage [InterfaceDeclaration] (from packages/plugin/selection/src/handles.ts): export interface SelectionHandleStage{ pageToViewport(page: PageRef, point: Point): Point | null; getPageAt(point: Point):{ ref: PageRef; point: Point} | null; viewportToPage(page: PageRef, point: Point): Point | null; } SelectionHandleTarget [InterfaceDeclaration] (from packages/plugin/selection/src/handles.ts): export interface SelectionHandleTarget{ beginGestureAt(page: PageRef, point: Point): boolean; extendTo(page: PageRef, point: Point): void; endGesture(): void; } SelectionHandleView [InterfaceDeclaration] (from packages/plugin/selection/src/handles.ts): export interface SelectionHandleView{ toOverlay(page: PageRef, point: Point): Point | null; pageAt(overlay: Point):{ ref: PageRef; point: Point} | null; pointOnPage(page: PageRef, overlay: Point): Point | null; } SelectionHandles [VueComponent] (from packages/framework/vue/src/selection/SelectionHandles.vue): props { token?: StageTokenProp; } SelectionLayer [VueComponent] (from packages/framework/vue/src/selection/SelectionLayer.vue): no props SelectionMenu [VueComponent] (from packages/framework/vue/src/selection/SelectionMenu.vue): props { gap?: number; placement?: AnchoredPlacement; }; defaults { gap: 8, placement: 'top'}; slots { default?(): unknown; } SelectionRangeInput [TypeAliasDeclaration] (from packages/plugin/selection/src/contract.ts): export type SelectionRangeInput = TextRange |{ page: PageRef; start: number; count: number} ; SelectionSegment [TypeAliasDeclaration] (from packages/plugin/selection/src/geometry.ts): export type SelectionSegment = PdfTextSegment; SelectionSettings [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface SelectionSettings{ readonly dragThresholdPx: number; readonly color: string | null; readonly handles:{ readonly color: string | null; readonly shadow: string; } ; } SelectionSnapshot [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface SelectionSnapshot{ readonly pages: readonly{ page: PageRef; segments: readonly SelectionSegment[]} []; readonly start: SelectionEndpoint | null; readonly end: SelectionEndpoint | null; readonly direction: 'forward' | 'backward'; readonly range: TextRange | null; } SelectionState [InterfaceDeclaration] (from packages/plugin/selection/src/state.ts): export interface SelectionState{ readonly hasSelection: boolean; readonly isSelecting: boolean; readonly range: TextRange | null; readonly pages: readonly PageRef[]; } SelectionToken [VariableDeclaration] (from packages/plugin/selection/src/token.ts): SelectionToken = createCapabilityToken('selection', { hint: `add selectionPlugin() from '@embedpdf/plugin-selection' to your plugins list`, promises:{ readText: true, readTextInRange: true, } , } ) TextPosition [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface TextPosition{ readonly page: PageRef; readonly index: number; } TextRange [InterfaceDeclaration] (from packages/plugin/selection/src/contract.ts): export interface TextRange{ readonly start: TextPosition; readonly end: TextPosition; } armSelectionHandle [FunctionDeclaration] (from packages/plugin/selection/src/handles.ts): export function armSelectionHandle( selection: SelectionHandleTarget, view: SelectionHandleView, endpoints: SelectionHandleEndpoints, role: 'start' | 'end', ): ArmedSelectionHandle | null{ const geometry = selectionHandleGeometry(view, endpoints[role], role); if (!geometry) return null; const opposite = endpoints[role === 'start' ? 'end' : 'start']; return{ base: midpoint(geometry.bar.from, geometry.bar.to), drag: createSelectionHandleDrag(selection, view, opposite, endpoints[role].page), } ; } copySelection [FunctionDeclaration] (from packages/framework/web/src/clipboard.ts): export async function copySelection( selection: Pick, ): Promise{ const text = await selection.readText(); if (text !== '') await navigator.clipboard.writeText(text); return text; } createSelectionHandleDrag [FunctionDeclaration] (from packages/plugin/selection/src/handles.ts): export function createSelectionHandleDrag( selection: SelectionHandleTarget, view: SelectionHandleView, opposite: SelectionHandleEndpoint, draggedPage: PageRef, ): SelectionHandleDragSession{ const quad = opposite.glyphQuad; const anchorPoint = midpoint( midpoint(quad.upperLeft, quad.lowerRight), midpoint(quad.upperRight, quad.lowerLeft), ); let begun = false; let lastPage = draggedPage; return{ move: (overlay) =>{ if (!begun){ if (!selection.beginGestureAt(opposite.page, anchorPoint)) return; begun = true; } const hit = view.pageAt(overlay); if (hit){ lastPage = hit.ref; selection.extendTo(hit.ref, hit.point); } else{ const point = view.pointOnPage(lastPage, overlay); if (point) selection.extendTo(lastPage, point); } } , end: () =>{ if (begun) selection.endGesture(); } , } ; } selectionCommands [VariableDeclaration] (from packages/framework/vue/src/command-lists.ts): selectionCommands = createSelectionCommands(standardCommandsBrowser) selectionHandleEndpointsOf [FunctionDeclaration] (from packages/plugin/selection/src/handles.ts): export function selectionHandleEndpointsOf( snapshot: Pick, ): SelectionHandleEndpoints | null{ const{ start, end} = snapshot; if (!start || !end) return null; return{ start:{ page: start.page, glyphQuad: start.glyphQuad, advance: start.advance} , end:{ page: end.page, glyphQuad: end.glyphQuad, advance: end.advance} , } ; } selectionHandleGeometry [FunctionDeclaration] (from packages/plugin/selection/src/handles.ts): export function selectionHandleGeometry( view: SelectionHandleView, endpoint: SelectionHandleEndpoint, role: 'start' | 'end', ): SelectionHandleGeometry | null{ const leading = role === 'start' ? endpoint.advance > 0 : endpoint.advance < 0; const [upperPage, lowerPage] = quadEdge(endpoint.glyphQuad, leading ? 'left' : 'right'); const upper = view.toOverlay(endpoint.page, upperPage); const lower = view.toOverlay(endpoint.page, lowerPage); if (!upper || !lower) return null; const dx = lower.x - upper.x; const dy = lower.y - upper.y; const length = Math.hypot(dx, dy); if (length === 0) return null; const rotation = (Math.atan2(dy, dx) * 180) / Math.PI - 90; const upright = Math.abs(rotation) < HANDLE_ROT_EPSILON; const ux = dx / length; const uy = dy / length; const head = role === 'start' ?{ x: upper.x - (ux * HANDLE_HEAD) / 2, y: upper.y - (uy * HANDLE_HEAD) / 2} :{ x: lower.x + (ux * HANDLE_HEAD) / 2, y: lower.y + (uy * HANDLE_HEAD) / 2} ; return{ bar:{ from: upper, to: lower} , length, rotation, upright, head} ; } selectionHandleViewOf [FunctionDeclaration] (from packages/plugin/selection/src/handles.ts): export function selectionHandleViewOf(stage: SelectionHandleStage): SelectionHandleView{ return{ toOverlay: (page, point) => stage.pageToViewport(page, point), pageAt: (overlay) => stage.getPageAt(overlay), pointOnPage: (page, overlay) => stage.viewportToPage(page, overlay), } ; } selectionPlugin [VariableDeclaration] (from packages/plugin/selection/src/selection.plugin.ts): selectionPlugin = (config?: SelectionConfig) => definePlugin({ id: 'selection', token: SelectionToken, scope: 'document', requires: [InteractionToken], optional: [FeedbackToken], state: initialSelectionModel, settings:{ defaults: SELECTION_DEFAULTS, registered: config} , create: createSelectionController, } ) selectionState [VariableDeclaration] (from packages/plugin/selection/src/state.ts): selectionState = defineState(SelectionToken, { read: (selection): SelectionState => ({ hasSelection: selection.hasSelection(), isSelecting: selection.isSelecting(), range: selection.getRange(), pages: selection.listSelectedPages(), } ), empty:{ hasSelection: false, isSelecting: false, range: null, pages: [], } , } ) useSelection [FunctionDeclaration] (from packages/framework/vue/src/selection/composables.ts): export function useSelection(): SelectionCapability{ return useCapability(SelectionToken); } useSelectionEvent [FunctionDeclaration] (from packages/framework/vue/src/selection/composables.ts): export function useSelectionEvent( select: (selection: SelectionCapability) => EventHook, handler: (event: Event) => void, ): void{ useCapabilityEvent(SelectionToken, select, handler); } useSelectionSettings [VariableDeclaration] (from packages/framework/vue/src/selection/composables.ts): useSelectionSettings = settingsComposable(SelectionToken) useSelectionState [VariableDeclaration] (from packages/framework/vue/src/selection/composables.ts): useSelectionState = stateComposable(selectionState)