[Editor] Dispatch an event when some global states are changing

- this way the context menu in Firefox can take into account what we
  have in the clipboard, if an editor is selected, ...
- when the user will click on a context menu item, an action will be
  triggered, hence this patch adds what is required to handle it;
- some tests will be added in the Firefox' patch.
This commit is contained in:
Calixte Denizet 2022-07-04 18:04:32 +02:00
parent a1ac1a61b7
commit ec0f9f6dcf
8 changed files with 278 additions and 28 deletions

View file

@ -186,6 +186,10 @@ class DefaultExternalServices {
static get isInAutomation() {
return shadow(this, "isInAutomation", false);
}
static updateEditorStates(data) {
throw new Error("Not implemented: updateEditorStates");
}
}
const PDFViewerApplication = {
@ -1954,6 +1958,12 @@ const PDFViewerApplication = {
eventBus._on("fileinputchange", webViewerFileInputChange);
eventBus._on("openfile", webViewerOpenFile);
}
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
eventBus._on(
"annotationeditorstateschanged",
webViewerAnnotationEditorStatesChanged
);
}
},
bindWindowEvents() {
@ -3076,6 +3086,10 @@ function beforeUnload(evt) {
return false;
}
function webViewerAnnotationEditorStatesChanged(data) {
PDFViewerApplication.externalServices.updateEditorStates(data);
}
/* Abstract factory for the print service. */
const PDFPrintServiceFactory = {
instance: {