diff --git a/src/core/stores/GuiStore.ts b/src/core/stores/GuiStore.ts index 7ecb245c..1924d1f9 100644 --- a/src/core/stores/GuiStore.ts +++ b/src/core/stores/GuiStore.ts @@ -25,7 +25,7 @@ class GuiStore implements Disposable { private readonly hash_disposer = this.tool.observe(({ value: tool }) => { window.location.hash = `#/${gui_tool_to_string(tool)}`; }); - private readonly global_keydown_handlers = new Map void>(); + private readonly global_keydown_handlers = new Map void>(); constructor() { const tool = window.location.hash.slice(2); @@ -43,7 +43,7 @@ class GuiStore implements Disposable { window.removeEventListener("keydown", this.dispatch_global_keydown); } - on_global_keydown(tool: GuiTool, binding: string, handler: () => void): Disposable { + on_global_keydown(tool: GuiTool, binding: string, handler: (e: KeyboardEvent) => void): Disposable { const key = this.handler_key(tool, binding); this.global_keydown_handlers.set(key, handler); @@ -67,7 +67,7 @@ class GuiStore implements Disposable { if (handler) { e.preventDefault(); - handler(); + handler(e); } }; diff --git a/src/quest_editor/gui/AsmEditorView.ts b/src/quest_editor/gui/AsmEditorView.ts index ed936ba4..d8301319 100644 --- a/src/quest_editor/gui/AsmEditorView.ts +++ b/src/quest_editor/gui/AsmEditorView.ts @@ -1,6 +1,6 @@ import { ResizableWidget } from "../../core/gui/ResizableWidget"; import { el } from "../../core/gui/dom"; -import { editor } from "monaco-editor"; +import { editor, KeyCode, KeyMod } from "monaco-editor"; import { asm_editor_store } from "../stores/AsmEditorStore"; import IStandaloneCodeEditor = editor.IStandaloneCodeEditor; @@ -45,6 +45,9 @@ export class AsmEditorView extends ResizableWidget { }), ); + this.editor.addCommand(KeyMod.CtrlCmd | KeyCode.KEY_Z, () => {}); + this.editor.addCommand(KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z, () => {}); + this.disposables( asm_editor_store.did_undo.observe(({ value: source }) => { this.editor.trigger(source, "undo", undefined); diff --git a/src/quest_editor/gui/QuestEditorToolBar.ts b/src/quest_editor/gui/QuestEditorToolBar.ts index 70156177..dbfddf99 100644 --- a/src/quest_editor/gui/QuestEditorToolBar.ts +++ b/src/quest_editor/gui/QuestEditorToolBar.ts @@ -120,17 +120,11 @@ export class QuestEditorToolBar extends ToolBar { ), gui_store.on_global_keydown(GuiTool.QuestEditor, "Ctrl-Z", () => { - // Let Monaco handle its own key bindings. - if (undo_manager.current.val !== asm_editor_store.undo) { - undo_manager.undo(); - } + undo_manager.undo(); }), gui_store.on_global_keydown(GuiTool.QuestEditor, "Ctrl-Shift-Z", () => { - // Let Monaco handle its own key bindings. - if (undo_manager.current.val !== asm_editor_store.undo) { - undo_manager.redo(); - } + undo_manager.redo(); }), );