From af80fcc9ba8e85b443264daa0642f75d0d99cf06 Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Thu, 29 Oct 2026 16:09:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=BC=96=E8=BE=91=E8=83=BD=E5=8A=9B):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=A8=E9=80=89=E5=8F=8A=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/webui/ofdgo.js | 12 ++++++++---- assets/webui/ofdgo_edit.js | 11 ++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/assets/webui/ofdgo.js b/assets/webui/ofdgo.js index 06bdd41..e31a8bc 100644 --- a/assets/webui/ofdgo.js +++ b/assets/webui/ofdgo.js @@ -684,9 +684,12 @@ function createPrintDialog(tab) { }); } -function openPrintPanel() { - const tab = documentTab(); +async function openPrintPanel() { + const tab = documentTab(), content = documentContentKey(state); if (!tab.state.doc || !tab.state.ready || document.body.hasAttribute("data-busy") || formDialogOpen()) return; + const current = () => isForegroundDocument(tab) && content === documentContentKey(state); + if (!await canvasEditor.commitNudge() || !current() || !await canvasEditor.commitText() || !current() + || !await canvasEditor.commitCrop() || !current() || document.body.hasAttribute("data-busy") || formDialogOpen()) return; tab.print ||= createPrintDialog(tab); tab.print.open({tab, document:documentEntryKey(tab.state.doc.documents?.[tab.state.doc.documentIndex || 0]), call:(name, ...args) => callTabWASM(tab, name, ...args), page:tab.state.pageIndex, selection:tab.state.pageSelection.size ? selectedPageIndexes() : [], annotations:tab.state.renderAnnotations, @@ -1978,10 +1981,11 @@ function handleKeyDown(event) { return; } if ((event.ctrlKey || event.metaKey) && !event.shiftKey && key.toLowerCase() === "a" && state.doc - && el.viewerPanel.contains(target) && !target.closest("input, textarea, select, [contenteditable]")) { + && (el.viewerPanel.contains(target) || state.editing && el.editorTools.contains(target)) && editorShortcutTarget(target)) { event.preventDefault(); if (!document.body.hasAttribute("data-busy") && !formDialogOpen()) { - selectDocumentText(); + if (state.editing) canvasEditor.selectAll(state.pageIndex); + else selectDocumentText(); } return; } diff --git a/assets/webui/ofdgo_edit.js b/assets/webui/ofdgo_edit.js index 3d58138..017504c 100644 --- a/assets/webui/ofdgo_edit.js +++ b/assets/webui/ofdgo_edit.js @@ -1122,6 +1122,14 @@ export class CanvasEditor { return true; } + selectAll(index) { + if (!this.enabled || this.input || this.crop || this.drag || this.nudge || this.nudgeCommit || this.options.busy()) return; + this.setTool(""); + document.getSelection()?.removeAllRanges(); + this.setSelection(this.pageItems(index)); + this.focus(); + } + clear() { this.closeText(); this.closeCrop(); @@ -1952,7 +1960,8 @@ export class CanvasEditor { } }); input.addEventListener("keydown", (event) => { - if ((event.ctrlKey || event.metaKey) && !event.altKey && ["s", "w", "tab"].includes(event.key.toLowerCase())) return; + if ((event.ctrlKey || event.metaKey) && !event.altKey && (["s", "w", "tab"].includes(event.key.toLowerCase()) + || !event.shiftKey && ["f", "o", "p"].includes(event.key.toLowerCase()))) return; event.stopPropagation(); if (event.isComposing || editing.composing || editing.saving) { return;