fix(编辑能力): 修复全选及全局快捷键

This commit is contained in:
xiaoqidun committed 2026-10-29 16:09:14 +08:00
1 parent 838a769c5b
commit af80fcc9ba
2 files changed
+18 -5

No files matched your search

+8 -4
View File
@@ -684,9 +684,12 @@ function createPrintDialog(tab) {
}); });
} }
function openPrintPanel() { async function openPrintPanel() {
const tab = documentTab(); const tab = documentTab(), content = documentContentKey(state);
if (!tab.state.doc || !tab.state.ready || document.body.hasAttribute("data-busy") || formDialogOpen()) return; 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 ||= 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, 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, selection:tab.state.pageSelection.size ? selectedPageIndexes() : [], annotations:tab.state.renderAnnotations,
@@ -1978,10 +1981,11 @@ function handleKeyDown(event) {
return; return;
} }
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && key.toLowerCase() === "a" && state.doc 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(); event.preventDefault();
if (!document.body.hasAttribute("data-busy") && !formDialogOpen()) { if (!document.body.hasAttribute("data-busy") && !formDialogOpen()) {
selectDocumentText(); if (state.editing) canvasEditor.selectAll(state.pageIndex);
else selectDocumentText();
} }
return; return;
} }
+10 -1
View File
@@ -1122,6 +1122,14 @@ export class CanvasEditor {
return true; 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() { clear() {
this.closeText(); this.closeText();
this.closeCrop(); this.closeCrop();
@@ -1952,7 +1960,8 @@ export class CanvasEditor {
} }
}); });
input.addEventListener("keydown", (event) => { 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(); event.stopPropagation();
if (event.isComposing || editing.composing || editing.saving) { if (event.isComposing || editing.composing || editing.saving) {
return; return;