mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
JS -- Send events to the sandbox from annotation layer
This commit is contained in:
parent
640a08444c
commit
6502ae889d
11 changed files with 647 additions and 113 deletions
13
web/app.js
13
web/app.js
|
@ -258,6 +258,7 @@ const PDFViewerApplication = {
|
|||
_wheelUnusedTicks: 0,
|
||||
_idleCallbacks: new Set(),
|
||||
_scriptingInstance: null,
|
||||
_mouseState: Object.create(null),
|
||||
|
||||
// Called once when the document is loaded.
|
||||
async initialize(appConfig) {
|
||||
|
@ -501,6 +502,7 @@ const PDFViewerApplication = {
|
|||
useOnlyCssZoom: AppOptions.get("useOnlyCssZoom"),
|
||||
maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
|
||||
enableScripting: AppOptions.get("enableScripting"),
|
||||
mouseState: this._mouseState,
|
||||
});
|
||||
pdfRenderingQueue.setViewer(this.pdfViewer);
|
||||
pdfLinkService.setViewer(this.pdfViewer);
|
||||
|
@ -1538,6 +1540,17 @@ const PDFViewerApplication = {
|
|||
dispatchEventInSandbox
|
||||
);
|
||||
|
||||
const mouseDown = event => {
|
||||
this._mouseState.isDown = true;
|
||||
};
|
||||
const mouseUp = event => {
|
||||
this._mouseState.isDown = false;
|
||||
};
|
||||
window.addEventListener("mousedown", mouseDown);
|
||||
this._scriptingInstance.events.set("mousedown", mouseDown);
|
||||
window.addEventListener("mouseup", mouseUp);
|
||||
this._scriptingInstance.events.set("mouseup", mouseUp);
|
||||
|
||||
const dispatchEventName = generateRandomStringForSandbox(objects);
|
||||
|
||||
if (!this._contentLength) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue