JS -- Send events to the sandbox from annotation layer

This commit is contained in:
Calixte Denizet 2020-11-18 14:59:57 +01:00
parent 640a08444c
commit 6502ae889d
11 changed files with 647 additions and 113 deletions

View file

@ -79,6 +79,7 @@ const DEFAULT_CACHE_SIZE = 10;
* @property {IL10n} l10n - Localization service.
* @property {boolean} [enableScripting] - Enable embedded script execution.
* The default value is `false`.
* @property {Object} [mouseState] - The mouse button state.
*/
function PDFPageViewBuffer(size) {
@ -194,6 +195,7 @@ class BaseViewer {
this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n || NullL10n;
this.enableScripting = options.enableScripting || false;
this.mouseState = options.mouseState || null;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
@ -533,6 +535,7 @@ class BaseViewer {
maxCanvasPixels: this.maxCanvasPixels,
l10n: this.l10n,
enableScripting: this.enableScripting,
mouseState: this.mouseState,
});
this._pages.push(pageView);
}
@ -1265,6 +1268,7 @@ class BaseViewer {
* @param {IL10n} l10n
* @param {boolean} [enableScripting]
* @param {Promise<boolean>} [hasJSActionsPromise]
* @param {Object} [mouseState]
* @returns {AnnotationLayerBuilder}
*/
createAnnotationLayerBuilder(
@ -1275,7 +1279,8 @@ class BaseViewer {
renderInteractiveForms = false,
l10n = NullL10n,
enableScripting = false,
hasJSActionsPromise = null
hasJSActionsPromise = null,
mouseState = null
) {
return new AnnotationLayerBuilder({
pageDiv,
@ -1290,6 +1295,7 @@ class BaseViewer {
enableScripting,
hasJSActionsPromise:
hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
mouseState,
});
}