# @embedpdf/angular — ./interaction Cursor [TypeAliasDeclaration] (from packages/plugin/interaction/src/contract.ts): export type Cursor = string; EpdfInteraction [ClassDeclaration] (from packages/framework/angular/interaction/src/interaction.ts): @Injectable({ providedIn: 'root'} ) export class EpdfInteraction extends pluginService({ name: 'EpdfInteraction', feature: 'withInteraction()', token: InteractionToken, state: interactionState, methods: [ 'getActiveTool', 'getActiveToolId', 'getDefaultToolId', 'listTools', 'getTool', 'hasTool', 'activateTool', 'activateDefaultTool', 'pushTool', 'popTool', 'setToolCursor', 'registerTool', ], events: ['onToolChanged', 'onGestureStarted', 'onGestureEnded', 'onGestureCancelled'], } ){ overrideCursor(spec: () => ToolCursorSpec | null): void{ const current = computed(spec, { equal: sameSpec} ); effect((onCleanup) =>{ const cursorSpec = current(); const interaction = this.binding.capability(); if (!cursorSpec || !interaction) return; interaction.setToolCursor(cursorSpec.toolId, toolCursorsOf(cursorSpec.cursors)); onCleanup(() => interaction.setToolCursor(cursorSpec.toolId, null)); } ); } } EpdfPagePointerSource [ClassDeclaration] (from packages/framework/angular/interaction/src/page-pointer-source.ts): @Component({ selector: 'epdf-page-pointer-source', changeDetection: ChangeDetectionStrategy.OnPush, host:{ style: 'position: absolute; inset: 0; display: block; touch-action: none', '[style.cursor]': 'cursor()', } , template: '', } ) export class EpdfPagePointerSource{ private readonly page = injectPage(''); private readonly interaction = new CapabilityBinding( injectKernelHost(''), () => InteractionHostToken, () => this.page.documentId, ); protected readonly cursor = this.interaction.select( (interaction) => interaction.getCursor(), 'default', ); constructor(){ if (!isPlatformBrowser(inject(PLATFORM_ID))) return; const element = inject>(ElementRef).nativeElement; const page = this.page; effect((onCleanup) =>{ const interaction = this.interaction.capability(); if (!interaction) return; onCleanup( untracked(() => attachPagePointer(element, interaction, () => ({ ref: page.ref, transform: untracked(page.transform), toPagePoint: page.toPagePoint, } )), ), ); } ); } } FeedbackPluginOptions [InterfaceDeclaration] (from packages/plugin/interaction/src/feedback.types.ts): export interface FeedbackPluginOptions{ provider?: PlatformFeedback; } FeedbackToken [VariableDeclaration] (from packages/plugin/interaction/src/feedback.types.ts): FeedbackToken = createCapabilityToken('feedback') GestureCancelledEvent [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface GestureCancelledEvent{ readonly toolId: ToolId; readonly page: PageRef | null; readonly pointerType: PointerKind; } GestureEndedEvent [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface GestureEndedEvent{ readonly toolId: ToolId; readonly page: PageRef | null; readonly pointerType: PointerKind; } GestureStartedEvent [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface GestureStartedEvent{ readonly toolId: ToolId; readonly page: PageRef | null; readonly pointerType: PointerKind; } INTERACTION_DEFAULTS [VariableDeclaration] (from packages/plugin/interaction/src/contract.ts): INTERACTION_DEFAULTS: InteractionSettings ={ defaultTool: 'pointer', tools: []} InteractionCapability [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface InteractionCapability extends SettingsApi{ getActiveTool(): Tool; getActiveToolId(): ToolId; getDefaultToolId(): ToolId; listTools(): readonly Tool[]; getTool(id: ToolId): Tool | null; hasTool(id: ToolId): boolean; canUseTool(id: ToolId): boolean; activateTool(id: ToolId): void; activateDefaultTool(): void; pushTool(id: ToolId): void; popTool(): void; setToolCursor(id: ToolId, cursors: ToolCursors | null): void; registerTool(tool: Tool, options?: RegisterToolOptions): Unsubscribe; readonly onToolChanged: EventHook; readonly onGestureStarted: EventHook; readonly onGestureEnded: EventHook; readonly onGestureCancelled: EventHook; } InteractionConfig [TypeAliasDeclaration] (from packages/plugin/interaction/src/contract.ts): export type InteractionConfig = DeepPartial; InteractionSettings [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface InteractionSettings{ readonly defaultTool: ToolId; readonly tools: readonly Tool[]; } InteractionState [InterfaceDeclaration] (from packages/plugin/interaction/src/state.ts): export interface InteractionState{ readonly activeToolId: ToolId | null; readonly tools: readonly Tool[]; } InteractionToken [VariableDeclaration] (from packages/plugin/interaction/src/token.ts): InteractionToken = createCapabilityToken('interaction', { hint: `add interactionPlugin() from '@embedpdf/plugin-interaction' to your plugins list`, } ) Modifiers [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface Modifiers{ readonly shift: boolean; readonly alt: boolean; readonly ctrl: boolean; readonly meta: boolean; } PlatformFeedback [InterfaceDeclaration] (from packages/plugin/interaction/src/feedback.types.ts): export interface PlatformFeedback{ selection(): void; impact(weight?: 'light' | 'medium' | 'heavy'): void; notify(kind: 'success' | 'warning' | 'error'): void; } PointerKind [TypeAliasDeclaration] (from packages/plugin/interaction/src/contract.ts): export type PointerKind = 'mouse' | 'pen' | 'touch'; RegisterToolOptions [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface RegisterToolOptions{ readonly replace?: boolean; } SvgCursorOptions [InterfaceDeclaration] (from packages/framework/web/src/cursor.ts): export interface SvgCursorOptions{ svg: string; hotspot?:{ x: number; y: number} ; fallback?: string; } Tool [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface Tool{ readonly id: ToolId; readonly cursor: Cursor; readonly touch?: ToolTouch; canUse?(): boolean; onPointerDown?(event: ToolPointerEvent): boolean | void; onPointerMove?(event: ToolPointerEvent): void; onPointerUp?(event: ToolPointerEvent): void; onHover?(event: ToolPointerEvent): void; } ToolChangedEvent [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface ToolChangedEvent{ readonly toolId: ToolId; readonly previousToolId: ToolId; } ToolCursorImage [TypeAliasDeclaration] (from packages/framework/web/src/cursor.ts): export type ToolCursorImage = SvgCursorOptions | string; ToolCursorSpec [InterfaceDeclaration] (from packages/framework/web/src/cursor.ts): export interface ToolCursorSpec{ toolId: string; cursors: Record; } ToolCursors [TypeAliasDeclaration] (from packages/plugin/interaction/src/contract.ts): export type ToolCursors = Readonly>; ToolId [TypeAliasDeclaration] (from packages/plugin/interaction/src/contract.ts): export type ToolId = string; ToolPointerEvent [InterfaceDeclaration] (from packages/plugin/interaction/src/contract.ts): export interface ToolPointerEvent{ readonly page: PageRef; readonly point: Point; readonly modifiers: Modifiers; readonly pointerType: PointerKind; } ToolTouch [TypeAliasDeclaration] (from packages/plugin/interaction/src/contract.ts): export type ToolTouch = 'draw' | 'tap'; feedbackPlugin [VariableDeclaration] (from packages/plugin/interaction/src/feedback.ts): feedbackPlugin = (options: FeedbackPluginOptions ={ } ) => definePlugin({ id: 'feedback', scope: 'workspace', token: FeedbackToken, create: () => ({ api: options.provider ?? NOOP} ), } ) interactionCommands [VariableDeclaration] (from packages/framework/angular/interaction/src/commands.ts): interactionCommands = createInteractionCommands() interactionPlugin [VariableDeclaration] (from packages/plugin/interaction/src/interaction.plugin.ts): interactionPlugin = (config?: InteractionConfig) => definePlugin({ id: 'interaction', token: InteractionToken, scope: 'document', state: initialInteractionModel, settings:{ defaults: INTERACTION_DEFAULTS, registered: config} , create: (ctx) => createInteractionController(ctx, builtinTools()), } ) interactionState [VariableDeclaration] (from packages/plugin/interaction/src/state.ts): interactionState = defineState(InteractionToken, { read: (interaction): InteractionState => ({ activeToolId: interaction.getActiveToolId(), tools: interaction.listTools(), } ), empty:{ activeToolId: null, tools: []} , } ) svgCursor [FunctionDeclaration] (from packages/framework/web/src/cursor.ts): export function svgCursor({ svg, hotspot, fallback = 'crosshair'} : SvgCursorOptions): string{ const tagStart = svg.indexOf('= 0 ? svg.indexOf('>', tagStart) : -1; const openTag = tagEnd >= 0 ? svg.slice(tagStart, tagEnd + 1) : ''; if (!/\swidth\s*=/.test(openTag) || !/\sheight\s*=/.test(openTag)){ throw new Error( '[web] svgCursor: the needs explicit width/height attributes — ' + 'browsers ignore cursor images without an intrinsic size', ); } const uri = `data:image/svg+xml, ${ encodeURIComponent(svg)} `; const spot = hotspot ? ` ${ Math.round(hotspot.x)} ${ Math.round(hotspot.y)} ` : ''; return `url("${ uri} ")${ spot} , ${ fallback} `; } toolCommand [VariableDeclaration] (from packages/plugin/interaction/src/commands.ts): toolCommand = (toolId: string): Omit => ({ labelKey: `commands.tool.${ toolId} `, label: toolId, icon: toolId, categories: ['tool'], run: (context) => interactionOf(context)?.activateTool(toolId), active: (context) => interactionOf(context)?.getActiveToolId() === toolId, visible: (context) => interactionOf(context)?.hasTool(toolId) ?? false, enabled: (context) => interactionOf(context)?.canUseTool(toolId) ?? true, } ) vibrationFeedback [VariableDeclaration] (from packages/framework/web/src/feedback.ts): vibrationFeedback: WebPlatformFeedback ={ selection: () => vibrate(8), impact: (weight = 'light') => vibrate(weight === 'heavy' ? 30 : weight === 'medium' ? 20 : 10), notify: (kind) => vibrate( kind === 'error' ? [12, 60, 12, 60, 12] : kind === 'warning' ? [15, 70, 15] : [10, 50, 10], ), } withFeedback [FunctionDeclaration] (from packages/framework/angular/interaction/src/interaction.ts): export function withFeedback(options?: FeedbackPluginOptions): EmbedPdfFeature{ return{ plugins: [feedbackPlugin(options)]} ; } withInteraction [FunctionDeclaration] (from packages/framework/angular/interaction/src/interaction.ts): export function withInteraction(options?: InteractionConfig): EmbedPdfFeature{ return{ plugins: [interactionPlugin(options)], services: [EpdfInteraction]} ; } wkFeedback [VariableDeclaration] (from packages/framework/web/src/feedback.ts): wkFeedback = ( handlerName: string, fallback: WebPlatformFeedback = vibrationFeedback, ): WebPlatformFeedback =>{ const handler = (): WKMessageHandler | undefined =>{ if (typeof window === 'undefined') return undefined; const webkitWindow = window as Window &{ webkit?:{ messageHandlers?: Record} ; } ; return webkitWindow.webkit?.messageHandlers?.[handlerName]; } ; return{ selection: () =>{ const messageHandler = handler(); if (messageHandler) messageHandler.postMessage({ family: 'selection'} ); else fallback.selection(); } , impact: (weight = 'light') =>{ const messageHandler = handler(); if (messageHandler) messageHandler.postMessage({ family: 'impact', weight} ); else fallback.impact(weight); } , notify: (kind) =>{ const messageHandler = handler(); if (messageHandler) messageHandler.postMessage({ family: 'notify', kind} ); else fallback.notify(kind); } , } ; }