import { ChangeDetectionStrategy, Component, computed, effect, inject, untracked, viewChild, ViewEncapsulation, } from '@angular/core'; import { EpdfDocumentGate, provideEmbedPdf } from '@embedpdf/angular/runtime'; import type { OpenInput } from '@embedpdf/angular/runtime'; import { EpdfPageTemplate, EpdfStage, withStage } from '@embedpdf/angular/stage'; import { EpdfRenderLayer, withRender } from '@embedpdf/angular/render'; import { EpdfSelectionLayer, withSelection } from '@embedpdf/angular/selection'; import { withInteraction } from '@embedpdf/angular/interaction'; import { EpdfAnnotation, EpdfAnnotationLayer, EpdfAnnotationMenu, withAnnotation, } from '@embedpdf/angular/annotation'; import { cloudEngine } from '@cloudpdf/engine'; const notice: OpenInput = { kind: 'grant', grant: 'shr_LfeeUer1ogBI9mz8eYkWXa0d' }; // What's in the menu depends on what's selected: text boxes get Bold and Edit. @Component({ selector: 'demo-selection-actions', changeDetection: ChangeDetectionStrategy.OnPush, template: `
`, }) export class SelectionActions { protected readonly annotation = inject(EpdfAnnotation); protected readonly selected = this.annotation.selected; protected readonly allText = computed(() => this.selected().every((a) => a.subtype === 'free-text'), ); protected edit() { const [first] = this.selected(); if (first) this.annotation.text.begin(first.ref); } } @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, EpdfAnnotationMenu, SelectionActions, ], providers: [ provideEmbedPdf( { engine: () => cloudEngine(), initialDocuments: [{ source: notice }] }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './menu.css', encapsulation: ViewEncapsulation.None, template: `Loading…