Skip to content

Commit

Permalink
#1917 add the inital value of the form values stored in the PDF to th…
Browse files Browse the repository at this point in the history
…e `(annotationLayerRendered)` event
  • Loading branch information
stephanrauh committed Apr 21, 2024
1 parent f97668f commit 4cb0dd0
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10647,7 +10647,7 @@ function getDocument(src) {
}
const fetchDocParams = {
docId,
apiVersion: "4.1.887",
apiVersion: "4.1.889",
data,
password,
disableAutoFetch,
Expand Down Expand Up @@ -12416,8 +12416,8 @@ class InternalRenderTask {
}
}
}
const version = "4.1.887";
const build = "70d58e4f8";
const version = "4.1.889";
const build = "7b57d8c1a";

;// CONCATENATED MODULE: ./src/shared/scripting_utils.js
function makeColorComp(n) {
Expand Down Expand Up @@ -12486,10 +12486,11 @@ class XfaLayer {
if (angularData.value) {
storage.setValue(id, angularData);
}
const storedData = angularData.value ? angularData : storage.getValue(id, {
const initialValue = storage.getValue(id, {
value: null
});
window.registerXFAField(html, storedData);
const storedData = angularData.value ? angularData : initialValue;
window.registerXFAField(html, storedData, initialValue);
html.addEventListener("updateFromAngular", value => storage.setValue(id, {
value: value.detail
}));
Expand Down Expand Up @@ -13709,7 +13710,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
}
event.target.scrollLeft = 0;
};
window.registerAcroformField(id, element, storedData.value);
window.registerAcroformField(id, element, storedData.value, undefined, this.data.fieldValue);
element.addEventListener("updateFromAngular", newvalue => storage.setValue(id, {
value: newvalue.detail
}));
Expand Down Expand Up @@ -14029,7 +14030,7 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
const defaultValue = data.defaultFieldValue || "Off";
event.target.checked = defaultValue === data.exportValue;
});
window.registerAcroformField(id, element, value ? data.exportValue : false);
window.registerAcroformField(id, element, value ? data.exportValue : false, undefined, this.data.fieldValue);
element.addEventListener("updateFromAngular", newvalue => storage.setValue(id, {
value: newvalue.detail
}));
Expand Down Expand Up @@ -14130,7 +14131,7 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
const defaultValue = data.defaultFieldValue;
event.target.checked = defaultValue !== null && defaultValue !== undefined && defaultValue === data.buttonValue;
});
window.registerAcroformField(id, element, value ? data.buttonValue : undefined, data.buttonValue);
window.registerAcroformField(id, element, value ? data.buttonValue : undefined, data.buttonValue, this.data.fieldValue);
element.addEventListener("updateFromAngular", newvalue => storage.setValue(id, {
value: newvalue.detail
}));
Expand Down Expand Up @@ -14266,7 +14267,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
exportValue: option.value
}));
};
window.registerAcroformField(id, selectElement, selectedValues);
window.registerAcroformField(id, selectElement, selectedValues, undefined, this.data.fieldValue);
selectElement.addEventListener("updateFromAngular", newvalue => storage.setValue(id, {
value: newvalue.detail
}));
Expand Down Expand Up @@ -19303,8 +19304,8 @@ class DrawLayer {



const pdfjsVersion = "4.1.887";
const pdfjsBuild = "70d58e4f8";
const pdfjsVersion = "4.1.889";
const pdfjsBuild = "7b57d8c1a";

var __webpack_exports__AbortException = __webpack_exports__.AbortException;
var __webpack_exports__AnnotationEditorLayer = __webpack_exports__.AnnotationEditorLayer;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56858,7 +56858,7 @@ class WorkerMessageHandler {
docId,
apiVersion
} = docParams;
const workerVersion = "4.1.887";
const workerVersion = "4.1.889";
if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
}
Expand Down Expand Up @@ -57433,8 +57433,8 @@ if (typeof window === "undefined" && typeof self !== "undefined" && isMessagePor

;// CONCATENATED MODULE: ./src/pdf.worker.js

const pdfjsVersion = "4.1.887";
const pdfjsBuild = "70d58e4f8";
const pdfjsVersion = "4.1.889";
const pdfjsBuild = "7b57d8c1a";

var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler;
export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler };
Original file line number Diff line number Diff line change
Expand Up @@ -6933,7 +6933,7 @@ const GenericL10n = null;
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ ngxExtendedPdfViewerVersion: () => (/* binding */ ngxExtendedPdfViewerVersion)
/* harmony export */ });
const ngxExtendedPdfViewerVersion = '20.0.0-alpha.2';
const ngxExtendedPdfViewerVersion = '20.0.0-alpha.3';

/***/ }),

Expand Down Expand Up @@ -15083,7 +15083,7 @@ class PDFViewer {
#outerScrollContainer = undefined;
#pageViewMode = "multiple";
constructor(options) {
const viewerVersion = "4.1.887";
const viewerVersion = "4.1.889";
if (pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version !== viewerVersion) {
throw new Error(`The API version "${pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version}" does not match the Viewer version "${viewerVersion}".`);
}
Expand Down Expand Up @@ -18971,8 +18971,8 @@ _app_js__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (a



const pdfjsVersion = "4.1.887";
const pdfjsBuild = "70d58e4f8";
const pdfjsVersion = "4.1.889";
const pdfjsBuild = "7b57d8c1a";
const AppConstants = {
LinkTarget: _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_2__.LinkTarget,
RenderingStates: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10700,7 +10700,7 @@ function getDocument(src) {
}
const fetchDocParams = {
docId,
apiVersion: "4.2.507",
apiVersion: "4.2.517",
data,
password,
disableAutoFetch,
Expand Down Expand Up @@ -12469,8 +12469,8 @@ class InternalRenderTask {
}
}
}
const version = "4.2.507";
const build = "6b97e87e0";
const version = "4.2.517";
const build = "9c42e7e08";

;// CONCATENATED MODULE: ./src/shared/scripting_utils.js
function makeColorComp(n) {
Expand Down Expand Up @@ -12539,10 +12539,11 @@ class XfaLayer {
if (angularData.value) {
storage.setValue(id, angularData);
}
const storedData = angularData.value ? angularData : storage.getValue(id, {
const initialValue = storage.getValue(id, {
value: null
});
window.registerXFAField(html, storedData);
const storedData = angularData.value ? angularData : initialValue;
window.registerXFAField(html, storedData, initialValue);
html.addEventListener("updateFromAngular", value => storage.setValue(id, {
value: value.detail
}));
Expand Down Expand Up @@ -13821,7 +13822,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
}
event.target.scrollLeft = 0;
};
window.registerAcroformField(id, element, storedData.value);
window.registerAcroformField(id, element, storedData.value, undefined, this.data.fieldValue);
element.addEventListener("updateFromAngular", newvalue => storage.setValue(id, {
value: newvalue.detail
}));
Expand Down Expand Up @@ -14141,7 +14142,7 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
const defaultValue = data.defaultFieldValue || "Off";
event.target.checked = defaultValue === data.exportValue;
});
window.registerAcroformField(id, element, value ? data.exportValue : false);
window.registerAcroformField(id, element, value ? data.exportValue : false, undefined, this.data.fieldValue);
element.addEventListener("updateFromAngular", newvalue => storage.setValue(id, {
value: newvalue.detail
}));
Expand Down Expand Up @@ -14242,7 +14243,7 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
const defaultValue = data.defaultFieldValue;
event.target.checked = defaultValue !== null && defaultValue !== undefined && defaultValue === data.buttonValue;
});
window.registerAcroformField(id, element, value ? data.buttonValue : undefined, data.buttonValue);
window.registerAcroformField(id, element, value ? data.buttonValue : undefined, data.buttonValue, this.data.fieldValue);
element.addEventListener("updateFromAngular", newvalue => storage.setValue(id, {
value: newvalue.detail
}));
Expand Down Expand Up @@ -14378,7 +14379,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
exportValue: option.value
}));
};
window.registerAcroformField(id, selectElement, selectedValues);
window.registerAcroformField(id, selectElement, selectedValues, undefined, this.data.fieldValue);
selectElement.addEventListener("updateFromAngular", newvalue => storage.setValue(id, {
value: newvalue.detail
}));
Expand Down Expand Up @@ -19471,8 +19472,8 @@ class DrawLayer {



const pdfjsVersion = "4.2.507";
const pdfjsBuild = "6b97e87e0";
const pdfjsVersion = "4.2.517";
const pdfjsBuild = "9c42e7e08";

var __webpack_exports__AbortException = __webpack_exports__.AbortException;
var __webpack_exports__AnnotationEditorLayer = __webpack_exports__.AnnotationEditorLayer;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -55430,7 +55430,7 @@ class WorkerMessageHandler {
docId,
apiVersion
} = docParams;
const workerVersion = "4.2.507";
const workerVersion = "4.2.517";
if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
}
Expand Down Expand Up @@ -56005,8 +56005,8 @@ if (typeof window === "undefined" && typeof self !== "undefined" && isMessagePor

;// CONCATENATED MODULE: ./src/pdf.worker.js

const pdfjsVersion = "4.2.507";
const pdfjsBuild = "6b97e87e0";
const pdfjsVersion = "4.2.517";
const pdfjsBuild = "9c42e7e08";

var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler;
export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler };
Original file line number Diff line number Diff line change
Expand Up @@ -6930,7 +6930,7 @@ const GenericL10n = null;
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ ngxExtendedPdfViewerVersion: () => (/* binding */ ngxExtendedPdfViewerVersion)
/* harmony export */ });
const ngxExtendedPdfViewerVersion = '20.0.0-alpha.2';
const ngxExtendedPdfViewerVersion = '20.0.0-alpha.3';

/***/ }),

Expand Down Expand Up @@ -15090,7 +15090,7 @@ class PDFViewer {
#outerScrollContainer = undefined;
#pageViewMode = "multiple";
constructor(options) {
const viewerVersion = "4.2.507";
const viewerVersion = "4.2.517";
if (pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version !== viewerVersion) {
throw new Error(`The API version "${pdfjs_lib__WEBPACK_IMPORTED_MODULE_0__.version}" does not match the Viewer version "${viewerVersion}".`);
}
Expand Down Expand Up @@ -18981,8 +18981,8 @@ _app_js__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (a



const pdfjsVersion = "4.2.507";
const pdfjsBuild = "6b97e87e0";
const pdfjsVersion = "4.2.517";
const pdfjsBuild = "9c42e7e08";
const AppConstants = {
LinkTarget: _pdf_link_service_js__WEBPACK_IMPORTED_MODULE_2__.LinkTarget,
RenderingStates: _ui_utils_js__WEBPACK_IMPORTED_MODULE_0__.RenderingStates,
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-extended-pdf-viewer/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,4 @@
- 20.0.0-alpha.0 make Sonarcloud happy by shortening an if statement; #2279 fix the highlight editor toolbar in rtl languages; #2282 improved compatibility to ng-zorro; #2293 improve the CSS encapsulation; #2294 make sure that the highlight editor can be closed again; #2295 Checkboxes with non-boolean export values can now be set by default from Angular
- 20.0.0-alpha.1 #2282 improved compatibility to ng-zorro; #2293 improve the CSS encapsulation (the text layer was broken in version 20.0.0-alpha.0)
- 20.0.0-alpha.2 #2274 now ngx add ngx-extended-pdf-viewer also supports stand-alone components
- 20.0.0-alpha.3 #2196 make sure that only the file ending of old configurations is converted from _.js to _.mjs; before the bugfix, it might also rename the domain "jsdelivr" to "mjsdelivr"
- 20.0.0-alpha.3 #2196 make sure that only the file ending of old configurations is converted from _.js to _.mjs; before the bugfix, it might also rename the domain "jsdelivr" to "mjsdelivr"; #2301 support browser that don't implement `Promise.withResolvers()`; #1917 add the inital value of the form values stored in the PDF to the `(annotationLayerRendered)` event
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { FormDataType } from '../ngx-extended-pdf-viewer.component';
import { PDFPageView } from '../options/pdf_page_view';

export interface AnnotationLayerRenderedEvent {
source: PDFPageView;
pageNumber: number;
error?: any;
initialFormDataStoredInThePDF?: FormDataType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -995,12 +995,12 @@ export class NgxExtendedPdfViewerComponent implements OnInit, AfterViewInit, OnC
if (needsES5 || isIE || isEdge || isIOs13OrBelow || this.forceUsingLegacyES5) {
return true;
}
return !(await this.supportsOptionalChaining());
return !(await this.ngxExtendedPdfViewerCanRunModernJSCode());
}

private supportsOptionalChaining(): Promise<boolean> {
private ngxExtendedPdfViewerCanRunModernJSCode(): Promise<boolean> {
return new Promise((resolve) => {
const support = (<any>window).supportsOptionalChaining;
const support = (<any>window).ngxExtendedPdfViewerCanRunModernJSCode;
support !== undefined ? resolve(support) : resolve(this.addScriptOpChainingSupport());
});
}
Expand All @@ -1010,11 +1010,11 @@ export class NgxExtendedPdfViewerComponent implements OnInit, AfterViewInit, OnC
const script = this.createScriptElement(pdfDefaultOptions.assetsFolder + '/op-chaining-support.js');
script.onload = () => {
script.remove();
resolve((<any>window).supportsOptionalChaining as boolean);
resolve((<any>window).ngxExtendedPdfViewerCanRunModernJSCode as boolean);
};
script.onerror = () => {
script.remove();
(<any>window).supportsOptionalChaining = false;
(<any>window).ngxExtendedPdfViewerCanRunModernJSCode = false;
resolve(false);
};

Expand Down Expand Up @@ -1819,6 +1819,7 @@ export class NgxExtendedPdfViewerComponent implements OnInit, AfterViewInit, OnC
PDFViewerApplication.eventBus.on('annotationlayerrendered', (event: AnnotationLayerRenderedEvent) => {
const div = event.source.div;
this.ngZone.run(() => {
event.initialFormDataStoredInThePDF = this.formSupport.initialFormDataStoredInThePDF;
this.annotationLayerRendered.emit(event);
this.enableOrDisableForms(div, true);
});
Expand Down
Loading

0 comments on commit 4cb0dd0

Please sign in to comment.