add redo/undo buttons.

This commit is contained in:
legraina 2025-08-24 21:58:13 -04:00
parent 649a03f817
commit d58b6cdd44
No known key found for this signature in database
GPG Key ID: 1B9D3DE90074C751
8 changed files with 47 additions and 0 deletions

View File

@ -2051,6 +2051,8 @@ const PDFViewerApplication = {
eventBus._on("lastpage", () => (this.page = this.pagesCount), opts);
eventBus._on("nextpage", () => pdfViewer.nextPage(), opts);
eventBus._on("previouspage", () => pdfViewer.previousPage(), opts);
eventBus._on("redo", evt => pdfViewer.redo(), opts);
eventBus._on("undo", evt => pdfViewer.undo(), opts);
eventBus._on("zoomin", this.zoomIn.bind(this), opts);
eventBus._on("zoomout", this.zoomOut.bind(this), opts);
eventBus._on("zoomreset", this.zoomReset.bind(this), opts);

View File

@ -0,0 +1 @@
<svg fill="#000000" width="16px" height="16px" viewBox="-0.02 -0.04 0.48 0.48" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin" class="jam jam-redo"><path d="m0.387 0.145 0.017 -0.025a0.02 0.02 0 0 1 0.028 -0.005c0.009 0.006 0.012 0.019 0.006 0.028L0.393 0.208a0.02 0.02 0 0 1 -0.028 0.005L0.299 0.168a0.02 0.02 0 0 1 -0.006 -0.028 0.02 0.02 0 0 1 0.028 -0.005l0.027 0.018C0.329 0.088 0.268 0.04 0.197 0.04c-0.087 0 -0.158 0.072 -0.158 0.16s0.071 0.16 0.158 0.16c0.011 0 0.02 0.009 0.02 0.02s-0.009 0.02 -0.02 0.02C0.088 0.4 0 0.31 0 0.2S0.088 0 0.197 0c0.09 0 0.166 0.061 0.19 0.145"/></svg>

After

Width:  |  Height:  |  Size: 609 B

View File

@ -0,0 +1 @@
<svg fill="#000000" width="16px" height="16px" viewBox="-0.01 -0.04 0.48 0.48" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin" class="jam jam-undo"><path d="m0.106 0.152 0.027 -0.018a0.02 0.02 0 0 1 0.027 0.005 0.02 0.02 0 0 1 -0.005 0.028l-0.066 0.045a0.02 0.02 0 0 1 -0.027 -0.005L0.018 0.14a0.02 0.02 0 0 1 0.005 -0.028 0.02 0.02 0 0 1 0.027 0.005l0.017 0.025C0.092 0.06 0.168 0 0.257 0c0.109 0 0.198 0.09 0.198 0.2s-0.088 0.2 -0.198 0.2a0.02 0.02 0 0 1 -0.02 -0.02c0 -0.011 0.009 -0.02 0.02 -0.02 0.087 0 0.158 -0.072 0.158 -0.16s-0.071 -0.16 -0.158 -0.16C0.186 0.04 0.126 0.087 0.106 0.152"/></svg>

After

Width:  |  Height:  |  Size: 621 B

View File

@ -2532,6 +2532,24 @@ class PDFViewer {
updater();
}
undo() {
if (!this.#annotationEditorUIManager) {
throw new Error(`The AnnotationEditor is not enabled.`);
}
if (this.pdfDocument) {
this.#annotationEditorUIManager.undo();
}
}
redo() {
if (!this.#annotationEditorUIManager) {
throw new Error(`The AnnotationEditor is not enabled.`);
}
if (this.pdfDocument) {
this.#annotationEditorUIManager.redo();
}
}
refresh(noUpdate = false, updateArgs = Object.create(null)) {
if (!this.pdfDocument) {
return;

View File

@ -67,6 +67,8 @@ class Toolbar {
{ element: options.zoomOut, eventName: "zoomout" },
{ element: options.print, eventName: "print" },
{ element: options.download, eventName: "download" },
{ element: options.undo, eventName: "undo" },
{ element: options.redo, eventName: "redo" },
{
element: options.editorFreeTextButton,
eventName: "switchannotationeditormode",

View File

@ -111,6 +111,8 @@
--toolbarButton-pageDown-icon: url(images/toolbarButton-pageDown.svg);
--toolbarButton-zoomOut-icon: url(images/toolbarButton-zoomOut.svg);
--toolbarButton-zoomIn-icon: url(images/toolbarButton-zoomIn.svg);
--toolbarButton-redo-icon: url(images/toolbarButton-redo.svg);
--toolbarButton-undo-icon: url(images/toolbarButton-undo.svg);
--toolbarButton-presentationMode-icon: url(images/toolbarButton-presentationMode.svg);
--toolbarButton-print-icon: url(images/toolbarButton-print.svg);
/*#if GENERIC*/
@ -540,6 +542,14 @@ body {
mask-image: var(--toolbarButton-zoomIn-icon);
}
#redoButton::before {
mask-image: var(--toolbarButton-redo-icon);
}
#undoButton::before {
mask-image: var(--toolbarButton-undo-icon);
}
#editorFreeTextButton::before {
mask-image: var(--toolbarButton-editorFreeText-icon);
}

View File

@ -332,6 +332,12 @@ See https://github.com/adobe-type-tools/cmap-resources
</div>
</div>
</div>
<button id="undoButton" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-undo-button">
<span data-l10n-id="pdfjs-undo-button-label"></span>
</button>
<button id="redoButton" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-redo-button">
<span data-l10n-id="pdfjs-redo-button-label"></span>
</button>
</div>
<div id="editorModeSeparator" class="verticalToolbarSeparator"></div>

View File

@ -45,6 +45,12 @@ function getViewerConfiguration() {
zoomIn: document.getElementById("zoomInButton"),
zoomOut: document.getElementById("zoomOutButton"),
print: document.getElementById("printButton"),
undo: document.getElementById("undoButton"),
redo: document.getElementById("redoButton"),
editorEraserButton: document.getElementById("editorEraserButton"),
editorEraserParamsToolbar: document.getElementById(
"editorEraserParamsToolbar"
),
editorFreeTextButton: document.getElementById("editorFreeTextButton"),
editorFreeTextParamsToolbar: document.getElementById(
"editorFreeTextParamsToolbar"
@ -241,6 +247,7 @@ function getViewerConfiguration() {
updateButton: document.getElementById("editSignatureUpdateButton"),
},
annotationEditorParams: {
editorEraserThickness: document.getElementById("editorEraserThickness"),
editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
editorFreeTextColor: document.getElementById("editorFreeTextColor"),
editorInkColor: document.getElementById("editorInkColor"),