mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 17:27:08 +08:00
1 parent
fb51fd3b07
commit
5b4f2472f7
2 files changed
+16
-5
No files matched your search
+13
-2
@@ -1308,7 +1308,10 @@ for (const [button, tool] of [[el.drawLineButton, "line"], [el.drawRectangleButt
|
||||
}
|
||||
editorClick(el.eraseButton, () => toggleDrawingTool(el.eraseMode.value));
|
||||
el.eraseMode.addEventListener("change", () => {
|
||||
if (canvasEditor.tool.startsWith("erase-")) canvasEditor.setTool(el.eraseMode.value);
|
||||
if (canvasEditor.tool.startsWith("erase-")) {
|
||||
canvasEditor.setTool(el.eraseMode.value);
|
||||
canvasEditor.focus();
|
||||
}
|
||||
});
|
||||
for (const input of [el.shapeFill, el.shapeStroke]) {
|
||||
input.addEventListener("change", changeShapeStyle);
|
||||
@@ -1408,9 +1411,11 @@ for (const [button, ungroup] of [[el.groupObjectsButton, false], [el.ungroupObje
|
||||
});
|
||||
}
|
||||
el.arrowTool.addEventListener("change", async () => {
|
||||
const tab = documentTab(), content = documentContentKey(state);
|
||||
const current = () => isForegroundDocument(tab) && state.editing && content === documentContentKey(state);
|
||||
const tool = el.arrowTool.value;
|
||||
el.arrowTool.value = "";
|
||||
if (await canvasEditor.commitText() && await canvasEditor.commitCrop()) {
|
||||
if (await canvasEditor.commitText() && current() && await canvasEditor.commitCrop() && current()) {
|
||||
const item = canvasEditor.selected;
|
||||
if (lineShape(item?.shape)) {
|
||||
const box = item.geometry;
|
||||
@@ -1421,6 +1426,7 @@ el.arrowTool.addEventListener("change", async () => {
|
||||
state.selectObjects = true;
|
||||
canvasEditor.setTool(tool);
|
||||
updateControls();
|
||||
canvasEditor.focus();
|
||||
}
|
||||
});
|
||||
el.copyStyleButton.addEventListener("click", async () => {
|
||||
@@ -2017,6 +2023,11 @@ function handleKeyDown(event) {
|
||||
if (!state.doc) {
|
||||
return;
|
||||
}
|
||||
if (state.editing && !event.shiftKey && el.editorTools.contains(target) && editorShortcutTarget(target)
|
||||
&& (key === "Delete" || key === "F2")) {
|
||||
canvasEditor.keyDown(event, true);
|
||||
return;
|
||||
}
|
||||
if (key === "Escape" && !event.shiftKey && state.documentSelection && el.viewerPanel.contains(target)
|
||||
&& !target.closest("input, textarea, select, [contenteditable]")) {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1741,8 +1741,8 @@ export class CanvasEditor {
|
||||
return this.nudgeCommit;
|
||||
}
|
||||
|
||||
keyDown(event) {
|
||||
if (event.defaultPrevented || event.target?.closest("input, textarea, select, [contenteditable]")) return;
|
||||
keyDown(event, toolbar = false) {
|
||||
if (event.defaultPrevented || !toolbar && event.target?.closest("input, textarea, select, [contenteditable]")) return;
|
||||
if (this.crop && !this.options.busy()) {
|
||||
if (event.key === "Escape" || event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
@@ -1952,7 +1952,7 @@ export class CanvasEditor {
|
||||
}
|
||||
});
|
||||
input.addEventListener("keydown", (event) => {
|
||||
if ((event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === "s") return;
|
||||
if ((event.ctrlKey || event.metaKey) && !event.altKey && event.key.toLowerCase() === "s") return;
|
||||
event.stopPropagation();
|
||||
if (event.isComposing || editing.composing || editing.saving) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user