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, EpdfAnnotationTemplate, EpdfRichTextEditor, withAnnotation, type Annotation, } from '@embedpdf/angular/annotation'; import { cloudEngine } from '@cloudpdf/engine'; const notice: OpenInput = { kind: 'grant', grant: 'shr_LfeeUer1ogBI9mz8eYkWXa0d' }; const FORMATS = ['bold', 'italic', 'underline'] as const; // The formatting calls work on your element as they do on the built-in one. @Component({ selector: 'demo-format-buttons', changeDetection: ChangeDetectionStrategy.OnPush, template: `
`, }) export class FormatButtons { protected readonly annotation = inject(EpdfAnnotation); protected readonly formats = FORMATS; protected readonly hasText = computed(() => this.annotation.selected().some((selected) => selected.subtype === 'free-text'), ); } @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, EpdfAnnotationTemplate, EpdfRichTextEditor, FormatButtons, ], providers: [ provideEmbedPdf( { engine: () => cloudEngine(), initialDocuments: [{ source: notice }] }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './branded-text-box.css', encapsulation: ViewEncapsulation.None, template: `Loading…