import { ChangeDetectionStrategy, Component, computed, inject, input, 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 { annotationKey, EpdfAnnotationLayer, EpdfComments, withAnnotation, type CommentThreadView, } from '@embedpdf/angular/annotation'; import { localEngine } from '@embedpdf/engine'; // [!doc-source proposal] const proposal = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/proposal.pdf'); return { kind: 'bytes', id: 'proposal', bytes: new Uint8Array(await response.arrayBuffer()) }; }; // [!/doc-source] // A thread's verdict, its check mark, and the buttons the user may use. @Component({ selector: 'article[demoReview]', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'thread' }, template: `

{{ thread().root.author }} {{ thread().root.contents }}

{{ verdict() }} @if (marked()) { ✓ checked off }

`, }) export class Review { readonly thread = input.required(); protected readonly comments = inject(EpdfComments); protected readonly ref = computed(() => this.thread().root.ref); protected readonly verdict = computed(() => this.thread().review.lastChange?.state ?? 'none'); protected readonly marked = computed(() => this.thread().review.markedBy.length > 0); } @Component({ selector: 'div[demoReviews]', imports: [Review], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'panel threads' }, template: ` @for (thread of comments.threads(); track key(thread.root.ref)) {
} @empty {

No comments

} `, }) export class Reviews { protected readonly comments = inject(EpdfComments); protected readonly key = annotationKey; } @Component({ selector: 'demo-root', imports: [ EpdfDocumentGate, EpdfStage, EpdfPageTemplate, EpdfRenderLayer, EpdfSelectionLayer, EpdfAnnotationLayer, Reviews, ], providers: [ provideEmbedPdf( { engine: () => localEngine(), identity: { userId: 'u_381', displayName: 'Dana Smith' }, initialDocuments: [{ source: proposal }], }, withStage(), withRender(), withInteraction(), withSelection(), withAnnotation(), ), ], changeDetection: ChangeDetectionStrategy.OnPush, styleUrl: './review.css', encapsulation: ViewEncapsulation.None, template: `

Loading…

`, }) export class App {}