[Editor] Add a basic stamp editor (bug 1790255)

For now it allows to add a stamp annotation with an image selected from the file system.
This commit is contained in:
Calixte Denizet 2023-06-22 12:16:07 +02:00
parent 2a837ba0b5
commit 37bd78c707
19 changed files with 754 additions and 39 deletions

View file

@ -90,6 +90,18 @@ class Toolbar {
},
},
},
{
element: options.editorStampButton,
eventName: "switchannotationeditormode",
eventDetails: {
get mode() {
const { classList } = options.editorStampButton;
return classList.contains("toggled")
? AnnotationEditorType.NONE
: AnnotationEditorType.STAMP;
},
},
},
];
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
this.buttons.push({ element: options.openFile, eventName: "openfile" });
@ -205,6 +217,7 @@ class Toolbar {
editorFreeTextParamsToolbar,
editorInkButton,
editorInkParamsToolbar,
editorStampButton,
}) {
const editorModeChanged = ({ mode }) => {
toggleCheckedBtn(
@ -217,10 +230,12 @@ class Toolbar {
mode === AnnotationEditorType.INK,
editorInkParamsToolbar
);
toggleCheckedBtn(editorStampButton, mode === AnnotationEditorType.STAMP);
const isDisable = mode === AnnotationEditorType.DISABLE;
editorFreeTextButton.disabled = isDisable;
editorInkButton.disabled = isDisable;
editorStampButton.disabled = isDisable;
};
this.eventBus._on("annotationeditormodechanged", editorModeChanged);