A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(editor): Cmd+S works mid-edit and saves the material you're inspecting
esengine35a16fa4f2af
diff --git a/desktop/src/App.tsx b/desktop/src/App.tsxindex 102f78ac4..bee6a7909 100644--- a/desktop/src/App.tsx+++ b/desktop/src/App.tsx@@ -48,6 +48,10 @@ import { forEachEditorWindow } from '@/layout/editorWindows';import { Toasts } from '@/store/Toasts';import { t } from '@/i18n';+// Commands that fire even while a text field is focused — Save must work mid-edit;+// everything else (typing, native Cmd+Z/backspace) stays with the field.+const FIELD_SAFE_COMMANDS = new Set(['project.save', 'project.saveAs']);+// The editor shell: fixed menu + toolbar on top, dockable workspace in the// middle, status strip at the bottom.export function App() {@@ -67,6 +71,15 @@ export function App() {// it — correct across popouts, unlike the main window's document.activeElement.const el = e.target as HTMLElement | null;if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.isContentEditable)) {+ // A field owns typing + native text undo/backspace — but Save must still+ // work while editing a value. Fire only the field-safe chords, committing+ // the field first (blur → onBlur writes) so Save reads the new value.+ const cmd = commands.forEvent(e);+ if (cmd && FIELD_SAFE_COMMANDS.has(cmd.id)) {+ e.preventDefault();+ el.blur();+ cmd.run();+ }return;}// Tile-editing context claims its keys first (single dispatch → no double-firediff --git a/desktop/src/commands/editorCommands.ts b/desktop/src/commands/editorCommands.tsindex d7ac5e975..e9db428b8 100644--- a/desktop/src/commands/editorCommands.ts+++ b/desktop/src/commands/editorCommands.ts@@ -20,6 +20,7 @@ import { applyFxPreview } from '@/engine/fxPreview';import { dockApi } from '@/layout/dockApi';import { panelDirtySource } from '@/layout/panelDirty';import { DirtyRegistry } from '@/document/DirtyRegistry';+import { MaterialDocument } from '@/material/MaterialDocument';import { isTilePaintMode, exitTilePaint } from '@/tools/tileMode';import { EDITOR_MODES } from '@/mode/editorModes';import { activeMode } from '@/mode/activeMode';@@ -71,16 +72,26 @@ commands.register({isEnabled: () => {const p = ProjectStore.getSnapshot();if (!p) return false;- const active = panelDirtySource(dockApi.activePanelId() ?? '');+ const activeId = dockApi.activePanelId() ?? '';+ const active = panelDirtySource(activeId);if (active.docId) return active.isDirty();+ // A material edits in the Details panel (no docId of its own).+ if (activeId === 'details' && MaterialDocument.isOpen) return MaterialDocument.dirty;return EditorHistory.isDirty() || !p.currentScene;},run: () => {- const active = panelDirtySource(dockApi.activePanelId() ?? '');+ const activeId = dockApi.activePanelId() ?? '';+ const active = panelDirtySource(activeId);if (active.docId) {void DirtyRegistry.saveDoc(active.docId);return;}+ // Shared-Inspector editors have no dock docId: a material being edited in the+ // Details panel saves ITSELF on Cmd+S, not the scene.+ if (activeId === 'details' && MaterialDocument.isOpen) {+ void DirtyRegistry.saveDoc('material');+ return;+ }void ProjectStore.save().catch(() => ProjectStore.saveAsViaDialog());},});