Tweak the new mouseState
parameter, and its usage, in the viewer components and the AnnotationLayer
- Actually remove the `isDown` property when destroying the scripting-instance. - Mark all `mouseState` usage as "private" in the various classes. - Ensure that the `AnnotationLayer` actually treats the parameter as properly *optional*, the same way that the viewer components do. - For now remove the `mouseState` parameter from the `PDFPageView` class, and keep it only on the `BaseViewer`, since it's questionable if all of the scripting-functionality will work all that well without e.g. a full `BaseViewer`. - Append the `mouseState` to the JSDoc for the `AnnotationElement` class, and just move its definition into the base-`AnnotationElement` class.
This commit is contained in:
parent
e6e2809825
commit
6dc39cb873
@ -47,6 +47,7 @@ import { ColorConverters } from "../shared/scripting_utils.js";
|
|||||||
* @property {Object} svgFactory
|
* @property {Object} svgFactory
|
||||||
* @property {boolean} [enableScripting]
|
* @property {boolean} [enableScripting]
|
||||||
* @property {boolean} [hasJSActions]
|
* @property {boolean} [hasJSActions]
|
||||||
|
* @property {Object} [mouseState]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class AnnotationElementFactory {
|
class AnnotationElementFactory {
|
||||||
@ -155,6 +156,7 @@ class AnnotationElement {
|
|||||||
this.annotationStorage = parameters.annotationStorage;
|
this.annotationStorage = parameters.annotationStorage;
|
||||||
this.enableScripting = parameters.enableScripting;
|
this.enableScripting = parameters.enableScripting;
|
||||||
this.hasJSActions = parameters.hasJSActions;
|
this.hasJSActions = parameters.hasJSActions;
|
||||||
|
this._mouseState = parameters.mouseState;
|
||||||
|
|
||||||
if (isRenderable) {
|
if (isRenderable) {
|
||||||
this.container = this._createContainer(ignoreBorder);
|
this.container = this._createContainer(ignoreBorder);
|
||||||
@ -590,7 +592,6 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
parameters.renderInteractiveForms ||
|
parameters.renderInteractiveForms ||
|
||||||
(!parameters.data.hasAppearance && !!parameters.data.fieldValue);
|
(!parameters.data.hasAppearance && !!parameters.data.fieldValue);
|
||||||
super(parameters, { isRenderable });
|
super(parameters, { isRenderable });
|
||||||
this.mouseState = parameters.mouseState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -734,7 +735,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
const _blurListener = blurListener;
|
const _blurListener = blurListener;
|
||||||
blurListener = null;
|
blurListener = null;
|
||||||
element.addEventListener("blur", event => {
|
element.addEventListener("blur", event => {
|
||||||
if (this.mouseState.isDown) {
|
if (this._mouseState.isDown) {
|
||||||
// Focus out using the mouse: data are committed
|
// Focus out using the mouse: data are committed
|
||||||
elementData.userValue = event.target.value;
|
elementData.userValue = event.target.value;
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
@ -1951,7 +1952,7 @@ class AnnotationLayer {
|
|||||||
parameters.annotationStorage || new AnnotationStorage(),
|
parameters.annotationStorage || new AnnotationStorage(),
|
||||||
enableScripting: parameters.enableScripting,
|
enableScripting: parameters.enableScripting,
|
||||||
hasJSActions: parameters.hasJSActions,
|
hasJSActions: parameters.hasJSActions,
|
||||||
mouseState: parameters.mouseState,
|
mouseState: parameters.mouseState || { isDown: false },
|
||||||
});
|
});
|
||||||
if (element.isRenderable) {
|
if (element.isRenderable) {
|
||||||
const rendered = element.render();
|
const rendered = element.render();
|
||||||
|
@ -30,6 +30,7 @@ import { SimpleLinkService } from "./pdf_link_service.js";
|
|||||||
* @property {IL10n} l10n - Localization service.
|
* @property {IL10n} l10n - Localization service.
|
||||||
* @property {boolean} [enableScripting]
|
* @property {boolean} [enableScripting]
|
||||||
* @property {Promise<boolean>} [hasJSActionsPromise]
|
* @property {Promise<boolean>} [hasJSActionsPromise]
|
||||||
|
* @property {Object} [mouseState]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class AnnotationLayerBuilder {
|
class AnnotationLayerBuilder {
|
||||||
|
@ -794,6 +794,7 @@ const PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
events.clear();
|
events.clear();
|
||||||
|
|
||||||
|
delete this._mouseState.isDown;
|
||||||
this._scriptingInstance = null;
|
this._scriptingInstance = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@ const DEFAULT_CACHE_SIZE = 10;
|
|||||||
* @property {IL10n} l10n - Localization service.
|
* @property {IL10n} l10n - Localization service.
|
||||||
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
||||||
* The default value is `false`.
|
* The default value is `false`.
|
||||||
* @property {Object} [mouseState] - The mouse button state.
|
* @property {Object} [mouseState] - The mouse button state. The default value
|
||||||
|
* is `null`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function PDFPageViewBuffer(size) {
|
function PDFPageViewBuffer(size) {
|
||||||
@ -195,7 +196,7 @@ class BaseViewer {
|
|||||||
this.maxCanvasPixels = options.maxCanvasPixels;
|
this.maxCanvasPixels = options.maxCanvasPixels;
|
||||||
this.l10n = options.l10n || NullL10n;
|
this.l10n = options.l10n || NullL10n;
|
||||||
this.enableScripting = options.enableScripting || false;
|
this.enableScripting = options.enableScripting || false;
|
||||||
this.mouseState = options.mouseState || null;
|
this._mouseState = options.mouseState || null;
|
||||||
|
|
||||||
this.defaultRenderingQueue = !options.renderingQueue;
|
this.defaultRenderingQueue = !options.renderingQueue;
|
||||||
if (this.defaultRenderingQueue) {
|
if (this.defaultRenderingQueue) {
|
||||||
@ -540,7 +541,6 @@ class BaseViewer {
|
|||||||
maxCanvasPixels: this.maxCanvasPixels,
|
maxCanvasPixels: this.maxCanvasPixels,
|
||||||
l10n: this.l10n,
|
l10n: this.l10n,
|
||||||
enableScripting: this.enableScripting,
|
enableScripting: this.enableScripting,
|
||||||
mouseState: this.mouseState,
|
|
||||||
});
|
});
|
||||||
this._pages.push(pageView);
|
this._pages.push(pageView);
|
||||||
}
|
}
|
||||||
@ -1301,7 +1301,7 @@ class BaseViewer {
|
|||||||
enableScripting,
|
enableScripting,
|
||||||
hasJSActionsPromise:
|
hasJSActionsPromise:
|
||||||
hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
|
hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
|
||||||
mouseState,
|
mouseState: mouseState || this._mouseState,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,6 @@ import { viewerCompatibilityParams } from "./viewer_compatibility.js";
|
|||||||
* @property {IL10n} l10n - Localization service.
|
* @property {IL10n} l10n - Localization service.
|
||||||
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
* @property {boolean} [enableScripting] - Enable embedded script execution.
|
||||||
* The default value is `false`.
|
* The default value is `false`.
|
||||||
* @property {Object} [mouseState] - The mouse button state.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const MAX_CANVAS_PIXELS = viewerCompatibilityParams.maxCanvasPixels || 16777216;
|
const MAX_CANVAS_PIXELS = viewerCompatibilityParams.maxCanvasPixels || 16777216;
|
||||||
@ -110,7 +109,6 @@ class PDFPageView {
|
|||||||
this.enableWebGL = options.enableWebGL || false;
|
this.enableWebGL = options.enableWebGL || false;
|
||||||
this.l10n = options.l10n || NullL10n;
|
this.l10n = options.l10n || NullL10n;
|
||||||
this.enableScripting = options.enableScripting || false;
|
this.enableScripting = options.enableScripting || false;
|
||||||
this.mouseState = options.mouseState || null;
|
|
||||||
|
|
||||||
this.paintTask = null;
|
this.paintTask = null;
|
||||||
this.paintedViewportMap = new WeakMap();
|
this.paintedViewportMap = new WeakMap();
|
||||||
@ -554,7 +552,7 @@ class PDFPageView {
|
|||||||
this.l10n,
|
this.l10n,
|
||||||
this.enableScripting,
|
this.enableScripting,
|
||||||
/* hasJSActionsPromise = */ null,
|
/* hasJSActionsPromise = */ null,
|
||||||
this.mouseState
|
/* mouseState = */ null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this._renderAnnotationLayer();
|
this._renderAnnotationLayer();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user