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;