ngx-extended-pdf-viewer
Version:
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
49 lines • 11.5 kB
JavaScript
import { Component, Input, effect } from '@angular/core';
import { PositioningService } from '../../dynamic-css/positioning.service';
import { AnnotationEditorType } from '../../options/editor-annotations';
import * as i0 from "@angular/core";
import * as i1 from "../../pdf-notification-service";
import * as i2 from "../pdf-shy-button/pdf-shy-button.component";
import * as i3 from "../../responsive-visibility";
export class PdfDrawEditorComponent {
cdr;
show = true;
isSelected = false;
PDFViewerApplication;
constructor(notificationService, cdr) {
this.cdr = cdr;
effect(() => {
this.PDFViewerApplication = notificationService.onPDFJSInitSignal();
if (this.PDFViewerApplication) {
this.onPdfJsInit();
}
});
}
onPdfJsInit() {
this.PDFViewerApplication?.eventBus.on('annotationeditormodechanged', ({ mode }) => {
setTimeout(() => {
this.isSelected = mode === 15;
this.cdr.detectChanges();
});
});
}
onClick(event) {
const currentMode = this.PDFViewerApplication?.pdfViewer.annotationEditorMode;
this.PDFViewerApplication?.eventBus.dispatch('switchannotationeditormode', {
source: this,
mode: currentMode === AnnotationEditorType.INK ? AnnotationEditorType.NONE : AnnotationEditorType.INK,
isFromKeyboard: event.detail === 0,
});
const positioningService = new PositioningService();
positioningService.positionPopupBelowItsButton('primaryEditorInk', 'editorInkParamsToolbar');
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PdfDrawEditorComponent, deps: [{ token: i1.PDFNotificationService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: PdfDrawEditorComponent, selector: "pdf-draw-editor", inputs: { show: "show" }, ngImport: i0, template: "<pdf-shy-button\n title=\"Draw\"\n primaryToolbarId=\"primaryEditorInk\"\n [cssClass]=\"show | responsiveCSSClass : 'hiddenTinyView'\"\n l10nId=\"pdfjs-editor-ink-button\"\n l10nLabel=\"pdfjs-editor-ink-button-label\"\n [order]=\"4050\"\n [action]=\"onClick\"\n [toggled]=\"isSelected\"\n [closeOnClick]=\"true\"\n image=\"<svg aria-hidden='true' focusable='false' width='20px' height='20px' version='1.1' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' xmlns:xlink='http://www.w3.org/1999/xlink' enable-background='new 0 0 16 16' fill='currentColor'> <g> <g transform='scale(0.03125)'> <path d='m455.1,137.9l-32.4,32.4-81-81.1 32.4-32.4c6.6-6.6 18.1-6.6 24.7,0l56.3,56.4c6.8,6.8 6.8,17.9 0,24.7zm-270.7,271l-81-81.1 209.4-209.7 81,81.1-209.4,209.7zm-99.7-42l60.6,60.7-84.4,23.8 23.8-84.5zm399.3-282.6l-56.3-56.4c-11-11-50.7-31.8-82.4,0l-285.3,285.5c-2.5,2.5-4.3,5.5-5.2,8.9l-43,153.1c-2,7.1 0.1,14.7 5.2,20 5.2,5.3 15.6,6.2 20,5.2l153-43.1c3.4-0.9 6.4-2.7 8.9-5.2l285.1-285.5c22.7-22.7 22.7-59.7 0-82.5z' /> </g> </g> </svg>\"\n>\n</pdf-shy-button>\n", styles: ["button{padding:0}\n"], dependencies: [{ kind: "component", type: i2.PdfShyButtonComponent, selector: "pdf-shy-button", inputs: ["primaryToolbarId", "secondaryMenuId", "cssClass", "eventBusName", "l10nId", "l10nLabel", "title", "toggled", "disabled", "order", "action", "closeOnClick", "onlySecondaryMenu", "image"] }, { kind: "pipe", type: i3.ResponsiveCSSClassPipe, name: "responsiveCSSClass" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PdfDrawEditorComponent, decorators: [{
type: Component,
args: [{ selector: 'pdf-draw-editor', template: "<pdf-shy-button\n title=\"Draw\"\n primaryToolbarId=\"primaryEditorInk\"\n [cssClass]=\"show | responsiveCSSClass : 'hiddenTinyView'\"\n l10nId=\"pdfjs-editor-ink-button\"\n l10nLabel=\"pdfjs-editor-ink-button-label\"\n [order]=\"4050\"\n [action]=\"onClick\"\n [toggled]=\"isSelected\"\n [closeOnClick]=\"true\"\n image=\"<svg aria-hidden='true' focusable='false' width='20px' height='20px' version='1.1' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' xmlns:xlink='http://www.w3.org/1999/xlink' enable-background='new 0 0 16 16' fill='currentColor'> <g> <g transform='scale(0.03125)'> <path d='m455.1,137.9l-32.4,32.4-81-81.1 32.4-32.4c6.6-6.6 18.1-6.6 24.7,0l56.3,56.4c6.8,6.8 6.8,17.9 0,24.7zm-270.7,271l-81-81.1 209.4-209.7 81,81.1-209.4,209.7zm-99.7-42l60.6,60.7-84.4,23.8 23.8-84.5zm399.3-282.6l-56.3-56.4c-11-11-50.7-31.8-82.4,0l-285.3,285.5c-2.5,2.5-4.3,5.5-5.2,8.9l-43,153.1c-2,7.1 0.1,14.7 5.2,20 5.2,5.3 15.6,6.2 20,5.2l153-43.1c3.4-0.9 6.4-2.7 8.9-5.2l285.1-285.5c22.7-22.7 22.7-59.7 0-82.5z' /> </g> </g> </svg>\"\n>\n</pdf-shy-button>\n", styles: ["button{padding:0}\n"] }]
}], ctorParameters: () => [{ type: i1.PDFNotificationService }, { type: i0.ChangeDetectorRef }], propDecorators: { show: [{
type: Input
}] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGRmLWRyYXctZWRpdG9yLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL25neC1leHRlbmRlZC1wZGYtdmlld2VyL3NyYy9saWIvdG9vbGJhci9wZGYtZHJhdy1lZGl0b3IvcGRmLWRyYXctZWRpdG9yLmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL25neC1leHRlbmRlZC1wZGYtdmlld2VyL3NyYy9saWIvdG9vbGJhci9wZGYtZHJhdy1lZG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