mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-30 01:27:26 +08:00
1 parent
80e548f93e
commit
fb51fd3b07
1 file changed
+12
-7
+12
-7
@@ -1808,6 +1808,7 @@ el.annotationButton.addEventListener("click", toggleAnnotations);
|
|||||||
document.addEventListener("copy", copySelection);
|
document.addEventListener("copy", copySelection);
|
||||||
document.addEventListener("cut", copySelection);
|
document.addEventListener("cut", copySelection);
|
||||||
el.viewerPanel.addEventListener("paste", pasteEditorContent);
|
el.viewerPanel.addEventListener("paste", pasteEditorContent);
|
||||||
|
el.editorTools.addEventListener("paste", pasteEditorContent);
|
||||||
document.addEventListener("selectionchange", syncSelection);
|
document.addEventListener("selectionchange", syncSelection);
|
||||||
el.exportFormat.addEventListener("change", () => updateDPIControl());
|
el.exportFormat.addEventListener("change", () => updateDPIControl());
|
||||||
el.outputCompression.addEventListener("change", () => {
|
el.outputCompression.addEventListener("change", () => {
|
||||||
@@ -1934,6 +1935,11 @@ el.documentNewTab.addEventListener("click", openEmptyDocumentTab);
|
|||||||
updateSidebarState();
|
updateSidebarState();
|
||||||
boot();
|
boot();
|
||||||
|
|
||||||
|
function editorShortcutTarget(target) {
|
||||||
|
const field = target.closest?.("input, textarea, select, [contenteditable]");
|
||||||
|
return !field || el.editorTools.contains(field) && field.matches('select, input[type="checkbox"], input[type="radio"], input[type="color"], input[type="range"]');
|
||||||
|
}
|
||||||
|
|
||||||
function handleKeyDown(event) {
|
function handleKeyDown(event) {
|
||||||
if (sealPreview) {
|
if (sealPreview) {
|
||||||
if (event.key === "Escape") { event.preventDefault(); finishSealPosition(); }
|
if (event.key === "Escape") { event.preventDefault(); finishSealPosition(); }
|
||||||
@@ -1995,9 +2001,7 @@ function handleKeyDown(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.ctrlKey || event.metaKey) {
|
if (event.ctrlKey || event.metaKey) {
|
||||||
const field = target.closest("input, textarea, select, [contenteditable]");
|
if (state.editing && editorShortcutTarget(target)
|
||||||
const editorControl = field && el.editorTools.contains(field) && field.matches('select, input[type="checkbox"], input[type="radio"], input[type="color"], input[type="range"]');
|
|
||||||
if (state.editing && (!field || editorControl)
|
|
||||||
&& (key.toLowerCase() === "z" || (!event.shiftKey && key.toLowerCase() === "y"))) {
|
&& (key.toLowerCase() === "z" || (!event.shiftKey && key.toLowerCase() === "y"))) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
(key.toLowerCase() === "y" || event.shiftKey ? el.redoButton : el.undoButton).click();
|
(key.toLowerCase() === "y" || event.shiftKey ? el.redoButton : el.undoButton).click();
|
||||||
@@ -10854,8 +10858,9 @@ async function selectDocumentText() {
|
|||||||
|
|
||||||
function copyEditorSelection(event) {
|
function copyEditorSelection(event) {
|
||||||
const tab = documentTab(), state = tab.state;
|
const tab = documentTab(), state = tab.state;
|
||||||
if (!state.editing || !canvasEditor.enabled || !canvasEditor.selected || !el.viewerPanel.contains(event.target)
|
if (!state.editing || !canvasEditor.enabled || !canvasEditor.selected || !editorShortcutTarget(event.target)
|
||||||
|| canvasEditor.input || canvasEditor.crop || canvasEditor.drag || document.body.hasAttribute("data-busy")) return false;
|
|| !el.viewerPanel.contains(event.target) && !el.editorTools.contains(event.target)
|
||||||
|
|| canvasEditor.input || canvasEditor.crop || canvasEditor.drag || document.body.hasAttribute("data-busy") || formDialogOpen()) return false;
|
||||||
const items = canvasEditor.items().slice().sort((a, b) => a.order - b.order);
|
const items = canvasEditor.items().slice().sort((a, b) => a.order - b.order);
|
||||||
const cut = event.type === "cut";
|
const cut = event.type === "cut";
|
||||||
if (!canEditObject(canvasEditor.selected, "copy") || cut && !canEditObject(canvasEditor.selected, "delete")) {
|
if (!canEditObject(canvasEditor.selected, "copy") || cut && !canEditObject(canvasEditor.selected, "delete")) {
|
||||||
@@ -10931,7 +10936,7 @@ function visiblePageBounds(index) {
|
|||||||
|
|
||||||
async function pasteEditorContent(event) {
|
async function pasteEditorContent(event) {
|
||||||
const tab = documentTab(), state = tab.state;
|
const tab = documentTab(), state = tab.state;
|
||||||
if (!state.editing || event.target.closest?.("input, textarea, select, [contenteditable]") || formDialogOpen()) return;
|
if (!state.editing || !editorShortcutTarget(event.target) || formDialogOpen()) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const token = event.clipboardData.getData(OBJECT_CLIPBOARD_TYPE);
|
const token = event.clipboardData.getData(OBJECT_CLIPBOARD_TYPE);
|
||||||
const files = Array.from(event.clipboardData.files);
|
const files = Array.from(event.clipboardData.files);
|
||||||
@@ -11000,7 +11005,7 @@ async function pasteEditorContent(event) {
|
|||||||
|
|
||||||
function copySelection(event) {
|
function copySelection(event) {
|
||||||
if (sealPreview) return;
|
if (sealPreview) return;
|
||||||
if (event.target.closest?.("input, textarea, [contenteditable]")) {
|
if (!editorShortcutTarget(event.target)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const selection = document.getSelection();
|
const selection = document.getSelection();
|
||||||
|
|||||||
Reference in new issue
Block a user