mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
[JS] Run the named actions before running the format when the file is open (issue #15818)
It's a follow-up of #14950: some format actions are ran when the document is open but we must be sure we've everything ready for that, hence we have to run some named actions before runnig the global format. In playing with the form, I discovered that the blur event wasn't triggered when JS called `setFocus` (because in such a case the mouse was never down). So I removed the mouseState thing to just use the correct commitKey when blur is triggered by a TAB key.
This commit is contained in:
parent
2d596045d1
commit
2ebf8745a2
11 changed files with 182 additions and 159 deletions
|
@ -101,27 +101,33 @@ class Doc extends PDFObject {
|
|||
this._disableSaving = false;
|
||||
}
|
||||
|
||||
_initActions() {
|
||||
const dontRun = new Set([
|
||||
"WillClose",
|
||||
"WillSave",
|
||||
"DidSave",
|
||||
"WillPrint",
|
||||
"DidPrint",
|
||||
"OpenAction",
|
||||
]);
|
||||
// When a pdf has just been opened it doesn't really make sense
|
||||
// to save it: it's up to the user to decide if they want to do that.
|
||||
// A pdf can contain an action /FooBar which will trigger a save
|
||||
// even if there are no WillSave/DidSave (which are themselves triggered
|
||||
// after a save).
|
||||
this._disableSaving = true;
|
||||
for (const actionName of this._actions.keys()) {
|
||||
if (!dontRun.has(actionName)) {
|
||||
this._runActions(actionName);
|
||||
}
|
||||
}
|
||||
this._runActions("OpenAction");
|
||||
this._disableSaving = false;
|
||||
}
|
||||
|
||||
_dispatchDocEvent(name) {
|
||||
if (name === "Open") {
|
||||
const dontRun = new Set([
|
||||
"WillClose",
|
||||
"WillSave",
|
||||
"DidSave",
|
||||
"WillPrint",
|
||||
"DidPrint",
|
||||
"OpenAction",
|
||||
]);
|
||||
// When a pdf has just been opened it doesn't really make sense
|
||||
// to save it: it's up to the user to decide if they want to do that.
|
||||
// A pdf can contain an action /FooBar which will trigger a save
|
||||
// even if there are no WillSave/DidSave (which are themselves triggered
|
||||
// after a save).
|
||||
this._disableSaving = true;
|
||||
for (const actionName of this._actions.keys()) {
|
||||
if (!dontRun.has(actionName)) {
|
||||
this._runActions(actionName);
|
||||
}
|
||||
}
|
||||
this._runActions("OpenAction");
|
||||
this._disableSaving = false;
|
||||
} else if (name === "WillPrint") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue