@tato30/vue-pdf
Advanced tools
Comparing version 1.5.1 to 1.6.0
@@ -1,2 +0,1 @@ | ||
import 'pdfjs-dist/web/pdf_viewer.css'; | ||
import type { AnnotationEventPayload } from '../types'; | ||
@@ -7,4 +6,7 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{ | ||
document: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | null; | ||
filter: string[] | undefined; | ||
map: Function | undefined; | ||
filter?: string[] | undefined; | ||
map?: Function | undefined; | ||
imageResourcesPath?: string | undefined; | ||
hideForms?: boolean | undefined; | ||
enableScripting?: boolean | undefined; | ||
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, { | ||
@@ -16,4 +18,7 @@ annotation: (payload: AnnotationEventPayload) => void; | ||
document: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | null; | ||
filter: string[] | undefined; | ||
map: Function | undefined; | ||
filter?: string[] | undefined; | ||
map?: Function | undefined; | ||
imageResourcesPath?: string | undefined; | ||
hideForms?: boolean | undefined; | ||
enableScripting?: boolean | undefined; | ||
}>>> & { | ||
@@ -20,0 +25,0 @@ onAnnotation?: ((payload: AnnotationEventPayload) => any) | undefined; |
@@ -1,2 +0,1 @@ | ||
import 'pdfjs-dist/web/pdf_viewer.css'; | ||
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{ | ||
@@ -3,0 +2,0 @@ page: import("pdfjs-dist/types/src/display/api.js").PDFPageProxy | null; |
@@ -0,1 +1,2 @@ | ||
import type { DocumentInitParameters, PDFDataRangeTransport, TypedArray } from 'pdfjs-dist/types/src/display/api'; | ||
import type { UsePDFInfo, UsePDFOptions } from './types'; | ||
@@ -20,3 +21,3 @@ /** | ||
*/ | ||
export declare function usePDF(src: string, options?: UsePDFOptions): { | ||
export declare function usePDF(src: string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters, options?: UsePDFOptions): { | ||
pdf: import("vue").ShallowRef<import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask | undefined>; | ||
@@ -23,0 +24,0 @@ pages: import("vue").ShallowRef<number>; |
@@ -5,2 +5,2 @@ import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
declare function annotationEventsHandler(evt: Event, PDFDoc: PDFDocumentProxy, Annotations: Object[]): AnnotationEventPayload | Promise<AnnotationEventPayload | undefined> | undefined; | ||
export { annotationEventsHandler, EVENTS_TO_HANDLER, }; | ||
export { EVENTS_TO_HANDLER, annotationEventsHandler }; |
@@ -0,1 +1,2 @@ | ||
import 'pdfjs-dist/web/pdf_viewer.css'; | ||
import type { AnnotationEventPayload } from './types'; | ||
@@ -42,2 +43,4 @@ declare function reload(): void; | ||
textLayer?: boolean | undefined; | ||
imageResourcesPath?: string | undefined; | ||
hideForms?: boolean | undefined; | ||
annotationLayer?: boolean | undefined; | ||
@@ -63,2 +66,4 @@ annotationsFilter?: string[] | undefined; | ||
textLayer?: boolean | undefined; | ||
imageResourcesPath?: string | undefined; | ||
hideForms?: boolean | undefined; | ||
annotationLayer?: boolean | undefined; | ||
@@ -65,0 +70,0 @@ annotationsFilter?: string[] | undefined; |
{ | ||
"name": "@tato30/vue-pdf", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "PDF viewer for Vue 3", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -6,2 +6,3 @@ import * as PDFJS from 'pdfjs-dist' | ||
import type { PDFDocumentLoadingTask } from 'pdfjs-dist' | ||
import type { DocumentInitParameters, PDFDataRangeTransport, TypedArray } from 'pdfjs-dist/types/src/display/api' | ||
import type { OnPasswordCallback, UsePDFInfo, UsePDFOptions } from './types' | ||
@@ -32,3 +33,3 @@ | ||
*/ | ||
export function usePDF(src: string, options: UsePDFOptions = { | ||
export function usePDF(src: string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters, options: UsePDFOptions = { | ||
onProgress: undefined, | ||
@@ -35,0 +36,0 @@ onPassword: undefined, |
@@ -128,2 +128,14 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
function mergePopupArgs(annotation: HTMLElement) { | ||
for (const spanElement of annotation.getElementsByTagName('span')) { | ||
let content = spanElement.textContent | ||
const args = JSON.parse(spanElement.dataset.l10nArgs ?? '{}') as PopupArgs | ||
if (content) { | ||
for (const key in args) | ||
content = content.replace(`{{${key}}}`, args[key]) | ||
} | ||
spanElement.textContent = content | ||
} | ||
} | ||
// Use this function to handle annotation events | ||
@@ -142,19 +154,12 @@ function annotationEventsHandler(evt: Event, PDFDoc: PDFDocumentProxy, Annotations: Object[]) { | ||
} | ||
else if (['popupAnnotation', 'textAnnotation', 'fileAttachmentAnnotation'].includes(annotation.className)) { | ||
for (const spanElement of annotation.getElementsByTagName('span')) { | ||
let content = spanElement.textContent | ||
const args = JSON.parse(spanElement.dataset.l10nArgs ?? '{}') as PopupArgs | ||
if (content) { | ||
for (const key in args) | ||
content = content.replace(`{{${key}}}`, args[key]) | ||
} | ||
spanElement.textContent = content | ||
} | ||
if (annotation.className === 'fileAttachmentAnnotation' && evt.type === 'dblclick') { | ||
const id = annotation.dataset.annotationId | ||
if (id) | ||
return fileAnnotation(getAnnotationsByKey('id', id, Annotations)[0]) | ||
} | ||
else if (annotation.className.includes('popupAnnotation') || annotation.className.includes('textAnnotation')) { | ||
mergePopupArgs(annotation) | ||
} | ||
else if (annotation.className === 'textWidgetAnnotation' && evt.type === 'input') { | ||
else if (annotation.className.includes('fileAttachmentAnnotation')) { | ||
mergePopupArgs(annotation) | ||
const id = annotation.dataset.annotationId | ||
if (id && evt.type === 'dblclick') | ||
return fileAnnotation(getAnnotationsByKey('id', id, Annotations)[0]) | ||
} | ||
else if (annotation.className.includes('textWidgetAnnotation') && evt.type === 'input') { | ||
let inputElement: HTMLInputElement | HTMLTextAreaElement = annotation.getElementsByTagName('input')[0] | ||
@@ -165,9 +170,9 @@ if (!inputElement) | ||
} | ||
else if (annotation.className === 'choiceWidgetAnnotation' && evt.type === 'input') { | ||
else if (annotation.className.includes('choiceWidgetAnnotation') && evt.type === 'input') { | ||
return inputAnnotation(annotation.getElementsByTagName('select')[0]) | ||
} | ||
else if (annotation.className === 'buttonWidgetAnnotation checkBox' && evt.type === 'change') { | ||
else if (annotation.className.includes('buttonWidgetAnnotation checkBox') && evt.type === 'change') { | ||
return inputAnnotation(annotation.getElementsByTagName('input')[0]) | ||
} | ||
else if (annotation.className === 'buttonWidgetAnnotation radioButton' && evt.type === 'change') { | ||
else if (annotation.className.includes('buttonWidgetAnnotation radioButton') && evt.type === 'change') { | ||
const id = annotation.dataset.annotationId | ||
@@ -188,3 +193,3 @@ if (id) { | ||
} | ||
else if (annotation.className === 'linkAnnotation buttonWidgetAnnotation pushButton' && evt.type === 'click') { | ||
else if (annotation.className.includes('buttonWidgetAnnotation pushButton') && evt.type === 'click') { | ||
const id = annotation.dataset.annotationId | ||
@@ -210,4 +215,5 @@ if (id) { | ||
export { | ||
annotationEventsHandler, | ||
EVENTS_TO_HANDLER, | ||
annotationEventsHandler | ||
} | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5278169
21654