# @embedpdf/viewer-angular — ./component EpdfButton [ClassDeclaration] (from packages/viewer/angular/component/src/viewer-components.ts): @Directive({ selector: 'epdf-button', host:{ '[attr.command]': 'command() ?? null', '[attr.icon]': 'icon() ?? null', '[attr.label]': 'label() ?? null', '[attr.active]': 'activeAttribute()', } , } ) export class EpdfButton{ readonly command = input(); readonly icon = input(); readonly label = input(); readonly active = input(false, { transform: booleanAttribute} ); protected activeAttribute(): '' | null{ return activeOf(this.active()); } } EpdfCommand [ClassDeclaration] (from packages/framework/angular/commands/src/commands.ts): @Directive({ selector: '[epdfCommand]', exportAs: 'epdfCommand', host:{ '(click)': 'onClick()', '[attr.disabled]': 'enabled() ? null : ""', '[attr.aria-pressed]': 'command().pressable ? active() : null', '[attr.aria-expanded]': 'command().menu ? active() : null', '[attr.title]': 'label() || null', '[hidden]': '!visible()', } , } ) export class EpdfCommand{ readonly id = input.required({ alias: 'epdfCommand'} ); readonly command: Signal = inject(EpdfCommands).commandOf(() => this.id()); readonly label: Signal = computed(() => this.command().label); readonly icon: Signal = computed(() => this.command().icon); readonly shortcutLabel: Signal = computed(() => this.command().shortcutLabel); readonly enabled: Signal = computed(() => this.command().enabled); readonly active: Signal = computed(() => this.command().active); readonly visible: Signal = computed(() => this.command().visible); run(): Promise{ return untracked(this.command).run(); } protected onClick(): void{ this.run().catch(() =>{ } ); } } EpdfCommands [ClassDeclaration] (from packages/framework/angular/commands/src/commands.ts): @Injectable({ providedIn: 'root'} ) export class EpdfCommands extends pluginService({ name: 'EpdfCommands', feature: 'withCommands()', token: CommandsToken, methods: [ 'execute', 'canExecute', 'resolveCommand', 'listCommands', 'searchCommands', 'listShortcuts', 'registerCommand', 'registerCommands', 'getCommand', 'hasCommand', 'listCommandIds', 'getDisabledCategories', 'isCategoryDisabled', 'disableCategory', 'enableCategory', 'setDisabledCategories', ], events: ['onExecuted', 'onExecutionFailed'], } ){ commandOf(id: string | (() => string)): Signal{ const idOf = typeof id === 'function' ? id : () => id; const resolved = this.binding.select( (commands) => commands.resolveCommand(idOf()), null, resolvedCommandsEqual, ); const execute = this.binding.method('execute'); return computed(() =>{ const command = resolved(); const requested = idOf(); const commands = this.binding.capability(); if (command === null && commands !== null){ devWarn( `commandOf:${ requested} `, `commandOf(): ${ unknownCommandWarning(requested, commands.listCommandIds())} `, ); } return boundCommandOf(command ?? unregisteredCommand(requested), execute, { isMac: isMacPlatform(), } ); } ); } } EpdfIcon [ClassDeclaration] (from packages/viewer/angular/component/src/viewer-components.ts): @Directive({ selector: 'epdf-icon', host:{ '[attr.name]': 'name()', '[attr.size]': 'size() ?? null', '[attr.label]': 'label() ?? null', } , } ) export class EpdfIcon{ readonly name = input.required(); readonly size = input(undefined, { transform: (size: number | string | undefined) => size === undefined ? undefined : numberAttribute(size), } ); readonly label = input(); } EpdfMenu [ClassDeclaration] (from packages/viewer/angular/component/src/viewer-components.ts): @Directive({ selector: 'epdf-menu', host:{ '[attr.icon]': 'icon() ?? null', '[attr.label]': 'label()', } , } ) export class EpdfMenu{ readonly icon = input(); readonly label = input.required(); } EpdfMenuItem [ClassDeclaration] (from packages/viewer/angular/component/src/viewer-components.ts): @Directive({ selector: 'epdf-menu-item', host:{ '[attr.command]': 'command() ?? null', '[attr.icon]': 'icon() ?? null', '[attr.active]': 'activeAttribute()', } , } ) export class EpdfMenuItem{ readonly command = input(); readonly icon = input(); readonly active = input(false, { transform: booleanAttribute} ); protected activeAttribute(): '' | null{ return activeOf(this.active()); } } EpdfPanel [ClassDeclaration] (from packages/viewer/angular/component/src/slots.ts): @Directive({ selector: 'ng-template[epdfPanel]'} ) export class EpdfPanel{ readonly id = input.required({ alias: 'epdfPanel'} ); readonly template = inject>(TemplateRef); } EpdfPdfViewerBase [ClassDeclaration] (from packages/viewer/angular/component/src/component.ts): @Directive() export abstract class EpdfPdfViewerBase implements EpdfPdfViewerRef, OnInit{ readonly theme: ConfigInput<'theme'> = input(); readonly locale: ConfigInput<'locale'> = input(); readonly features: ConfigInput<'features'> = input(); readonly disable: ConfigInput<'disable'> = input(); readonly readOnly: ConfigInput<'readOnly'> = input(); readonly layout: ConfigInput<'layout'> = input(); readonly size: ConfigInput<'size'> = input(); readonly touch: ConfigInput<'touch'> = input(); readonly commands: ConfigInput<'commands'> = input(); readonly appState: ConfigInput<'appState'> = input(); readonly icons: ConfigInput<'icons'> = input(); readonly strings: ConfigInput<'strings'> = input(); readonly notAllowed: ConfigInput<'notAllowed'> = input(); readonly plugins: ConfigInput<'plugins'> = input(); readonly fonts: ConfigInput<'fonts'> = input(); readonly warnBeforeLeaving: ConfigInput<'warnBeforeLeaving'> = input(); readonly ready = output(); readonly documentChange = output(); readonly panelResize = output(); readonly toolbarItems = contentChildren(EpdfToolbarItem, { descendants: true} ); readonly panels = contentChildren(EpdfPanel, { descendants: true} ); readonly regions = contentChildren(EpdfRegion, { descendants: true} ); private readonly insideState = signal<(ViewerInside &{ injector: DestroyableInjector} ) | null>( null, ); readonly inside: Signal = this.insideState.asReadonly(); readonly viewer: Signal = computed(() => this.inside()?.viewer ?? null); private readonly slots = viewChild.required(EpdfViewerSlots, { read: ElementRef} ); readonly element: Signal = computed( () => this.slots().nativeElement as EmbedPdfViewerElement, ); protected abstract readonly elementConfig: Signal; protected readonly sharedConfig: Signal>> = computed(() => definedOf({ theme: this.theme(), locale: this.locale(), features: this.features(), disable: this.disable(), readOnly: this.readOnly(), layout: this.layout(), size: this.size(), touch: this.touch(), commands: this.commands(), appState: this.appState(), icons: this.icons(), strings: this.strings(), notAllowed: this.notAllowed(), plugins: this.plugins(), fonts: this.fonts(), warnBeforeLeaving: this.warnBeforeLeaving(), } ), ); private readonly injector = inject(Injector); private readonly browser = isPlatformBrowser(inject(PLATFORM_ID)); private started:{ element: EmbedPdfViewerElement; config: ElementConfig} | null = null; private warned = false; private readonly callbacks: Pick< ElementConfig, 'onReady' | 'onDocumentChange' | 'onPanelResize' > ={ onReady: (viewer) =>{ this.ready.emit(viewer); untracked(this.elementConfig).onReady?.(viewer); } , onDocumentChange: (documentId) =>{ this.documentChange.emit(documentId); untracked(this.elementConfig).onDocumentChange?.(documentId); } , onPanelResize: (event) =>{ this.panelResize.emit(event); untracked(this.elementConfig).onPanelResize?.(event); } , } ; constructor(){ inject(DestroyRef).onDestroy(() =>{ this.started?.element.removeEventListener('epdf:ready', this.onViewerReady); untracked(this.insideState)?.injector.destroy(); } ); if (!this.browser) return; effect(() =>{ const config = this.elementConfig(); untracked(() => this.follow(config)); } ); } ngOnInit(): void{ if (!this.browser) return; const element = this.element(); const config = untracked(this.elementConfig); this.started ={ element, config} ; element.addEventListener('epdf:ready', this.onViewerReady); element.config ={ ...config, ...this.callbacks} ; } private follow(config: ElementConfig): void{ if (!this.started) return; const{ element} = this.started; element.src = config.src; element.theme = config.theme; element.locale = config.locale; element.features = config.features; element.disable = config.disable; element.readOnly = config.readOnly; element.fetch = config.fetch; element.appState = config.appState; if (this.warned || !isDevMode()) return; const key = changedReadOnceKey(this.started.config, config); if (key === null) return; this.warned = true; console.warn( `[embedpdf] : \`${ key} \` is read once, when the viewer starts, so the ` + 'change is ignored. Pass a stable value (a field, a signal), or put the viewer in a new ' + '`@if` branch to mount a new one with it.', ); } private readonly onViewerReady = (): void =>{ const viewer = this.started?.element.viewer; if (!viewer) return; untracked(this.insideState)?.injector.destroy(); const kernel = kernelOf(viewer); const injector: DestroyableInjector = Injector.create({ name: '', providers: kernel ? provideViewerServices(kernel) : [], parent: this.injector, } ); this.insideState.set({ viewer, injector} ); } ; } EpdfPdfViewerRef [ClassDeclaration] (from packages/viewer/angular/component/src/viewer-ref.ts): @Injectable({ providedIn: 'root', useFactory: outsideTheViewer} ) export abstract class EpdfPdfViewerRef{ abstract readonly viewer: Signal; abstract readonly element: Signal; } EpdfRegion [ClassDeclaration] (from packages/viewer/angular/component/src/slots.ts): @Directive({ selector: 'ng-template[epdfRegion]'} ) export class EpdfRegion{ readonly name = input.required({ alias: 'epdfRegion'} ); readonly template = inject>(TemplateRef); } EpdfToolbarItem [ClassDeclaration] (from packages/viewer/angular/component/src/slots.ts): @Directive({ selector: 'ng-template[epdfToolbarItem]'} ) export class EpdfToolbarItem{ readonly id = input.required({ alias: 'epdfToolbarItem'} ); readonly template = inject>(TemplateRef); } EpdfToolbarItemContext [ClassDeclaration] (from packages/viewer/angular/component/src/slots.ts): @Injectable({ providedIn: 'root', useFactory: outsideAToolbarItem} ) export abstract class EpdfToolbarItemContext{ abstract readonly orientation: Signal; abstract readonly edge: Signal; abstract readonly variant: Signal; abstract readonly size: Signal; } EpdfViewerSlots [ClassDeclaration] (from packages/viewer/angular/component/src/component.ts): @Component({ selector: 'embedpdf-viewer', imports: [NgTemplateOutlet, EpdfToolbarItemView], changeDetection: ChangeDetectionStrategy.OnPush, host:{ 'data-epdf-wrapped': ''} , template: ` @if (owner().inside(); as inside){ @for (item of owner().toolbarItems(); track item){
} @for (panel of owner().panels(); track panel){
} @for (region of owner().regions(); track region){
} } `, } ) export class EpdfViewerSlots{ readonly owner = input.required(); } RegionName [TypeAliasDeclaration] (from packages/viewer/angular/component/src/slots.ts): export type RegionName = 'header' | 'footer' | 'tabs' | 'empty'; ViewerInside [InterfaceDeclaration] (from packages/viewer/angular/component/src/component.ts): export interface ViewerInside{ readonly viewer: Viewer; readonly injector: Injector; } definedOf [FunctionDeclaration] (from packages/viewer/angular/component/src/component.ts): export function definedOf(keys: Keys): Partial{ return Object.fromEntries( Object.entries(keys).filter(([, value]) => value !== undefined), ) as Partial; }