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
feat: comprehensive editor improvements across panels, CSS, and workflows
esenginee31d5de9c922
diff --git a/editor/src/DockLayoutManager.ts b/editor/src/DockLayoutManager.tsindex a8177e3b7..f8367f7a8 100644--- a/editor/src/DockLayoutManager.ts+++ b/editor/src/DockLayoutManager.ts@@ -9,6 +9,7 @@ import {import type { EditorStore } from './store/EditorStore';import { getPanel, type PanelDescriptor } from './panels/PanelRegistry';import type { PanelManager } from './PanelManager';+import { showErrorToast } from './ui/Toast';const LAYOUT_STORAGE_KEY = 'esengine.editor.layout';@@ -48,6 +49,9 @@ export class DockLayoutManager {private panelManager_: PanelManager;private store_: EditorStore;private layoutChangeDisposable_: { dispose(): void } | null = null;+ private activePanelDisposable_: { dispose(): void } | null = null;+ private saveTimer_: ReturnType<typeof setTimeout> | null = null;+ private lastActivePanelId_: string | null = null;constructor(panelManager: PanelManager, store: EditorStore) {this.panelManager_ = panelManager;@@ -71,6 +75,18 @@ export class DockLayoutManager {disableFloatingGroups: true,});+ this.activePanelDisposable_ = this.api_.onDidActivePanelChange((panel) => {+ const newId = panel?.id ?? null;+ if (newId === this.lastActivePanelId_) return;+ if (this.lastActivePanelId_) {+ this.panelManager_.hidePanel(this.lastActivePanelId_);+ }+ if (newId) {+ this.panelManager_.showPanel(newId);+ }+ this.lastActivePanelId_ = newId;+ });+const saved = this.loadSavedLayout();if (saved) {try {@@ -79,6 +95,7 @@ export class DockLayoutManager {return;} catch {localStorage.removeItem(LAYOUT_STORAGE_KEY);+ showErrorToast('Layout Restore Failed', 'The saved layout could not be restored. Using default layout.');}}@@ -110,12 +127,25 @@ export class DockLayoutManager {position: { referencePanel: 'scene', direction: 'right' },initialWidth: 260,});++ this.api_.addPanel({+ id: 'output',+ component: 'output',+ title: 'Output',+ position: { referencePanel: 'scene', direction: 'below' },+ initialHeight: 200,+ inactive: true,+ });}private startSavingLayout(): void {if (!this.api_) return;this.layoutChangeDisposable_ = this.api_.onDidLayoutChange(() => {- this.saveLayout();+ if (this.saveTimer_) clearTimeout(this.saveTimer_);+ this.saveTimer_ = setTimeout(() => {+ this.saveTimer_ = null;+ this.saveLayout();+ }, 500);});}@@ -201,6 +231,12 @@ export class DockLayoutManager {}dispose(): void {+ if (this.saveTimer_) {+ clearTimeout(this.saveTimer_);+ this.saveTimer_ = null;+ }+ this.activePanelDisposable_?.dispose();+ this.activePanelDisposable_ = null;this.layoutChangeDisposable_?.dispose();this.layoutChangeDisposable_ = null;this.api_?.dispose();diff --git a/editor/src/Editor.ts b/editor/src/Editor.tsindex fd078d0f9..714e878e6 100644--- a/editor/src/Editor.ts+++ b/editor/src/Editor.ts@@ -104,6 +104,7 @@ export class Editor {private addressableWindow_: { element: HTMLElement; panel: AddressablePanel; keyHandler: (e: KeyboardEvent) => void } | null = null;private isPreviewRunning_ = false;private escapeHandler_: ((e: KeyboardEvent) => void) | null = null;+ private settingsDebounceTimer_: ReturnType<typeof setTimeout> | null = null;constructor(container: HTMLElement, options?: EditorOptions) {this.container_ = container;@@ -229,7 +230,17 @@ export class Editor {}togglePanel(id: string): void {- this.showPanel(id);+ if (id === 'content-browser') {+ this.contentDrawer_?.toggle();+ return;+ }+ const panel = this.dockLayout_?.api?.getPanel(id);+ if (panel) {+ this.dockLayout_!.removePanel(id);+ this.panelManager_.removePanelInstance(id);+ } else {+ this.showPanel(id);+ }}resetLayout(): void {@@ -318,37 +329,43 @@ export class Editor {}duplicateSelected(): void {- const entity = this.store_.selectedEntity;- if (entity === null) return;+ const selected = Array.from(this.store_.selectedEntities);+ if (selected.length === 0) return;- const entityData = this.store_.getEntityData(entity as number);- if (!entityData) return;+ for (const id of selected) {+ const entityData = this.store_.getEntityData(id);+ if (!entityData) continue;- const scene = this.store_.scene;- const siblings = scene.entities- .filter(e => e.parent === entityData.parent)- .map(e => e.name);- const siblingNames = new Set(siblings);- const newName = generateUniqueName(entityData.name, siblingNames);+ const scene = this.store_.scene;+ const siblings = scene.entities+ .filter(e => e.parent === entityData.parent)+ .map(e => e.name);+ const siblingNames = new Set(siblings);+ const newName = generateUniqueName(entityData.name, siblingNames);- const newEntity = this.store_.createEntity(- newName,- entityData.parent as Entity | null- );+ const newEntity = this.store_.createEntity(+ newName,+ entityData.parent as Entity | null+ );- for (const comp of entityData.components) {- this.store_.addComponent(newEntity, comp.type, JSON.parse(JSON.stringify(comp.data)));+ for (const comp of entityData.components) {+ this.store_.addComponent(newEntity, comp.type, JSON.parse(JSON.stringify(comp.data)));+ }}}copySelected(): void {- const entity = this.store_.selectedEntity;- if (entity === null) return;+ const selected = Array.from(this.store_.selectedEntities);+ if (selected.length === 0) return;- const tree = this.collectEntityTree_(entity as number);- if (tree.length === 0) return;+ const allTrees: EntityData[] = [];+ for (const id of selected) {+ const tree = this.collectEntityTree_(id);+ allTrees.push(...tree);+ }+ if (allTrees.length === 0) return;- this.clipboard_ = JSON.parse(JSON.stringify(tree));+ this.clipboard_ = JSON.parse(JSON.stringify(allTrees));for (const e of this.clipboard_!) {delete e.prefab;}@@ -359,37 +376,42 @@ export class Editor {const cloned: EntityData[] = JSON.parse(JSON.stringify(this.clipboard_));const parent = this.store_.selectedEntity;- const rootData = cloned[0];+ const clipboardIds = new Set(cloned.map(e => e.id));+ const oldIdToNewId = new Map<number, Entity>();const scene = this.store_.scene;const siblings = scene.entities.filter(e => e.parent === (parent as number | null)).map(e => e.name);const siblingNames = new Set(siblings);- const newName = generateUniqueName(rootData.name, siblingNames);- const oldIdToNewId = new Map<number, Entity>();+ let lastRoot: Entity | null = null;- const newRoot = this.store_.createEntity(newName, parent);- oldIdToNewId.set(rootData.id, newRoot);- for (const comp of rootData.components) {- this.store_.addComponent(newRoot, comp.type, { ...comp.data });- }+ for (const entityData of cloned) {+ const isRoot = entityData.parent === null || !clipboardIds.has(entityData.parent);+ const newParent = isRoot ? parent : (oldIdToNewId.get(entityData.parent!) ?? null);+ if (!isRoot && newParent === null) continue;- for (let i = 1; i < cloned.length; i++) {- const entityData = cloned[i];- const newParent = oldIdToNewId.get(entityData.parent!);- if (newParent === undefined) continue;+ const name = isRoot+ ? generateUniqueName(entityData.name, siblingNames)+ : entityData.name;- const newEntity = this.store_.createEntity(entityData.name, newParent);+ const newEntity = this.store_.createEntity(name, newParent);oldIdToNewId.set(entityData.id, newEntity);+ if (isRoot) {+ siblingNames.add(name);+ lastRoot = newEntity;+ }+for (const comp of entityData.components) {this.store_.addComponent(newEntity, comp.type, { ...comp.data });}}- this.store_.selectEntity(newRoot);+ if (lastRoot !== null) {+ this.store_.selectEntity(lastRoot);+ }}hasClipboard(): boolean {@@ -554,7 +576,8 @@ export class Editor {const projectPath = this.projectPath_;onSettingsChange((id, value) => {if (id.startsWith('project.') || id.startsWith('physics.') || id.startsWith('build.') || id.startsWith('runtime.')) {- this.saveProjectField(projectPath);+ if (this.settingsDebounceTimer_) clearTimeout(this.settingsDebounceTimer_);+ this.settingsDebounceTimer_ = setTimeout(() => this.saveProjectField(projectPath), 500);if (id === 'project.spineVersion') {this.spineVersionChangeHandler_?.(value as string);}@@ -806,6 +829,10 @@ export class Editor {// =========================================================================async startPreview(): Promise<void> {+ if (this.store_.isDirty && this.store_.filePath && hasFileHandle()) {+ await this.saveScene();+ showToast({ type: 'info', title: 'Scene saved before preview' });+ }await this.previewManager_.startPreview(this.store_.scene, this.scriptLoader_, this.spineVersion_,);diff --git a/editor/src/PanelManager.ts b/editor/src/PanelManager.tsindex 5ed2e1214..5859a21ea 100644--- a/editor/src/PanelManager.ts+++ b/editor/src/PanelManager.ts@@ -17,6 +17,7 @@ import {} from './panels/PanelRegistry';import type { EditorAssetServer } from './asset/EditorAssetServer';import { icons } from './utils/icons';+import { escapeHtml } from './utils/html';export class PanelManager {private panelInstances_ = new Map<string, PanelInstance>();@@ -86,7 +87,7 @@ export class PanelManager {overlay.querySelector('[data-action="retry"]')?.addEventListener('click', () => {overlay.remove();- this.createPanelWithErrorBoundary(desc, container, store);+ this.createPanelWithErrorBoundary(desc, container, store, this.bridge_, this.app_);});overlay.querySelector('[data-action="close"]')?.addEventListener('click', () => {@@ -189,8 +190,3 @@ export class PanelManager {}}-function escapeHtml(text: string): string {- const div = document.createElement('div');- div.textContent = text;- return div.innerHTML;-}diff --git a/editor/src/menus/builtinMenus.ts b/editor/src/menus/builtinMenus.tsindex b5da66398..01e8a452a 100644--- a/editor/src/menus/builtinMenus.ts+++ b/editor/src/menus/builtinMenus.ts@@ -2,6 +2,7 @@ import { registerMenu, registerMenuItem } from './MenuRegistry';import type { Editor } from '../Editor';import { getEditorContext } from '../context/EditorContext';import { showStatusBarMessage } from './builtinStatusbar';+import { showConfirmDialog } from '../ui/dialog';import type { Entity } from 'esengine';export function registerBuiltinMenus(editor: Editor): void {@@ -94,21 +95,41 @@ export function registerBuiltinMenus(editor: Editor): void {registerMenuItem({id: 'edit.duplicate', menu: 'edit', label: 'Duplicate',shortcut: 'Ctrl+D', order: 3,- enabled: () => editor.store.selectedEntity !== null,+ enabled: () => editor.store.selectedEntities.size > 0,action: () => editor.duplicateSelected(),});registerMenuItem({id: 'edit.copy', menu: 'edit', label: 'Copy',shortcut: 'Ctrl+C', order: 4,- enabled: () => editor.store.selectedEntity !== null,+ enabled: () => editor.store.selectedEntities.size > 0,action: () => editor.copySelected(),});+ registerMenuItem({+ id: 'edit.cut', menu: 'edit', label: 'Cut',+ shortcut: 'Ctrl+X', order: 4.5,+ enabled: () => editor.store.selectedEntities.size > 0,+ action: () => {+ editor.copySelected();+ if (editor.store.selectedEntities.size === 1) {+ const id = Array.from(editor.store.selectedEntities)[0];+ editor.store.deleteEntity(id as Entity);+ } else if (editor.store.selectedEntities.size > 1) {+ editor.store.deleteSelectedEntities();+ }+ },+ });registerMenuItem({id: 'edit.paste', menu: 'edit', label: 'Paste',shortcut: 'Ctrl+V', order: 5,enabled: () => editor.hasClipboard(),action: () => editor.pasteEntity(),});+ registerMenuItem({+ id: 'edit.create-entity', menu: 'edit', label: 'Create Entity',+ shortcut: 'Ctrl+Shift+N', order: 6,+ action: () => editor.store.createEntity('New Entity', editor.store.selectedEntity),+ hidden: true,+ });registerMenuItem({id: 'edit.preferences', menu: 'edit', label: 'Settings...',shortcut: 'Ctrl+,', order: 10, separator: true,@@ -145,7 +166,14 @@ export function registerBuiltinMenus(editor: Editor): void {registerMenuItem({id: 'view.reload-extensions', menu: 'view', label: 'Reload Extensions',order: 10, separator: true,- action: () => editor.reloadExtensions(),+ action: async () => {+ const confirmed = await showConfirmDialog({+ title: 'Reload Extensions',+ message: 'Reload all extensions? This will reset any extension state.',+ confirmText: 'Reload',+ });+ if (confirmed) editor.reloadExtensions();+ },});registerMenuItem({id: 'view.reload', menu: 'view', label: 'Reload',@@ -161,6 +189,25 @@ export function registerBuiltinMenus(editor: Editor): void {},});+ registerMenuItem({+ id: 'view.focus-hierarchy', menu: 'view', label: 'Focus Hierarchy',+ shortcut: 'Ctrl+1', order: 30,+ action: () => editor.showPanel('hierarchy'),+ hidden: true,+ });+ registerMenuItem({+ id: 'view.focus-scene', menu: 'view', label: 'Focus Scene',+ shortcut: 'Ctrl+2', order: 31,+ action: () => editor.showPanel('scene'),+ hidden: true,+ });+ registerMenuItem({+ id: 'view.focus-inspector', menu: 'view', label: 'Focus Inspector',+ shortcut: 'Ctrl+3', order: 32,+ action: () => editor.showPanel('inspector'),+ hidden: true,+ });+registerMenuItem({id: 'help.docs', menu: 'help', label: 'Documentation', order: 0,action: () => {diff --git a/editor/src/panels/AddressablePanel.ts b/editor/src/panels/AddressablePanel.tsindex a648a5953..66cb4b674 100644--- a/editor/src/panels/AddressablePanel.ts+++ b/editor/src/panels/AddressablePanel.ts@@ -15,6 +15,7 @@ import { showContextMenu, type ContextMenuItem } from '../ui/ContextMenu';import { getContextMenuItems, type ContextMenuContext } from '../ui/ContextMenuRegistry';import { showErrorToast, showSuccessToast } from '../ui/Toast';import { getEditorType } from 'esengine';+import { escapeHtml } from '../utils/html';const EDITOR_TYPE_TO_ASSET_TYPE: Record<string, AssetType> = {'texture': 'image',@@ -180,7 +181,7 @@ export class AddressablePanel implements PanelInstance {const count = db.getUuidsByGroup(group.name).size;const item = document.createElement('div');item.className = `es-addr-group-item${group.name === this.selectedGroup_ ? ' es-selected' : ''}`;- item.innerHTML = `<span class="es-addr-group-dot"></span> ${this.escapeHtml(group.name)}<span class="es-addr-group-count">${count}</span>`;+ item.innerHTML = `<span class="es-addr-group-dot"></span> ${escapeHtml(group.name)}<span class="es-addr-group-count">${count}</span>`;item.addEventListener('click', () => {this.selectedGroup_ = group.name;this.renderGroupList();@@ -236,7 +237,7 @@ export class AddressablePanel implements PanelInstance {<label class="es-addr-label-check"><input type="checkbox" ${checked ? 'checked' : ''} /><span class="es-addr-label-dot" style="background:${color}"></span>- <span>${this.escapeHtml(label)}</span>+ <span>${escapeHtml(label)}</span></label>`;const checkbox = item.querySelector('input')!;@@ -332,14 +333,14 @@ export class AddressablePanel implements PanelInstance {const name = entry.path.split('/').pop() || '';const labelsHtml = [...entry.labels].map(l => {const color = this.getLabelColor(l);- return `<span class="es-addr-tag" style="--tag-color: ${color}">${this.escapeHtml(l)}</span>`;+ return `<span class="es-addr-tag" style="--tag-color: ${color}">${escapeHtml(l)}</span>`;}).join('');const size = this.formatSize(entry.fileSize);const selected = this.selectedUuids_.has(entry.uuid);return `<div class="es-addr-table-row${selected ? ' es-selected' : ''}" data-uuid="${entry.uuid}" draggable="true">- <span class="es-addr-col-name" title="${this.escapeHtml(entry.path)}">${this.escapeHtml(name)}</span>- <span class="es-addr-col-address">${this.escapeHtml(entry.address || '')}</span>+ <span class="es-addr-col-name" title="${escapeHtml(entry.path)}">${escapeHtml(name)}</span>+ <span class="es-addr-col-address">${escapeHtml(entry.address || '')}</span><span class="es-addr-col-labels">${labelsHtml}</span><span class="es-addr-col-type">${entry.type}</span><span class="es-addr-col-size">${size}</span>@@ -472,15 +473,15 @@ export class AddressablePanel implements PanelInstance {.join('');const includeHtml = group.include.length > 0- ? group.include.map(p => `<div class="es-addr-include-item">${this.escapeHtml(p)}</div>`).join('')+ ? group.include.map(p => `<div class="es-addr-include-item">${escapeHtml(p)}</div>`).join(''): '<div class="es-muted">No patterns</div>';this.groupConfigEl_.innerHTML = `- <div class="es-addr-config-toggle" title="Hide group config">▾ Config: ${this.escapeHtml(group.name)}</div>+ <div class="es-addr-config-toggle" title="Hide group config">▾ Config: ${escapeHtml(group.name)}</div><div class="es-addr-group-config-body"><div class="es-addr-config-field"><span class="es-addr-config-label">Description</span>- <input type="text" class="es-input es-addr-config-desc" value="${this.escapeHtml(group.description)}" placeholder="Group description" />+ <input type="text" class="es-input es-addr-config-desc" value="${escapeHtml(group.description)}" placeholder="Group description" /></div><div class="es-addr-config-field"><span class="es-addr-config-label">Bundle Mode</span>@@ -551,8 +552,8 @@ export class AddressablePanel implements PanelInstance {if (!entry) return '';const name = entry.path.split('/').pop() || '';return `- <div class="es-addr-unreferenced-row" data-uuid="${uuid}" title="${this.escapeHtml(entry.path)}">- <span class="es-addr-col-name">${this.escapeHtml(name)}</span>+ <div class="es-addr-unreferenced-row" data-uuid="${uuid}" title="${escapeHtml(entry.path)}">+ <span class="es-addr-col-name">${escapeHtml(name)}</span><span class="es-addr-col-type">${entry.type}</span><span class="es-addr-col-size">${this.formatSize(entry.fileSize)}</span></div>@@ -910,11 +911,4 @@ export class AddressablePanel implements PanelInstance {return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;}- private escapeHtml(text: string): string {- return text- .replace(/&/g, '&')- .replace(/</g, '<')- .replace(/>/g, '>')- .replace(/"/g, '"');- }}diff --git a/editor/src/panels/ContentBrowserPanel.ts b/editor/src/panels/ContentBrowserPanel.tsindex d8ddc3e79..3cbe4a235 100644--- a/editor/src/panels/ContentBrowserPanel.ts+++ b/editor/src/panels/ContentBrowserPanel.ts@@ -18,6 +18,7 @@ import { showErrorToast } from '../ui/Toast';import { createEmptyScene } from '../types/SceneTypes';import { getSettingsValue } from '../settings';import { DEFAULT_DESIGN_WIDTH, DEFAULT_DESIGN_HEIGHT, getEditorType } from 'esengine';+import { fuzzyMatch } from '../utils/fuzzy';// =============================================================================// Types@@ -254,7 +255,7 @@ export class ContentBrowserPanel {<input type="text" class="es-input es-content-search" placeholder="Search assets..."><button class="es-btn es-btn-icon es-cb-view-toggle" title="Toggle view"></button></div>- <div class="es-content-browser-grid" tabindex="0"></div>+ <div class="es-content-browser-grid" tabindex="0" role="grid"></div></div></div><div class="es-content-browser-footer">0 items</div>@@ -1554,10 +1555,10 @@ void main() {const fs = getNativeFS();if (!fs || !basePath) return [];- const results: AssetItem[] = [];+ const scored: Array<{ item: AssetItem; score: number }> = [];const stack = [basePath];- while (stack.length > 0 && results.length < SEARCH_RESULTS_LIMIT * 2) {+ while (stack.length > 0 && scored.length < SEARCH_RESULTS_LIMIT * 2) {const dir = stack.pop()!;try {const entries = await fs.listDirectoryDetailed(dir);@@ -1568,23 +1569,23 @@ void main() {if (entry.isDirectory) {stack.push(entryPath);- if (entry.name.toLowerCase().includes(filter)) {+ const match = fuzzyMatch(filter, entry.name);+ if (match) {const relative = entryPath.substring(basePath.length).replace(/^\//, '');- results.push({- name: entry.name,- path: entryPath,- type: 'folder',- relativePath: relative,+ scored.push({+ item: { name: entry.name, path: entryPath, type: 'folder', relativePath: relative },+ score: match.score,+ });+ }+ } else {+ const match = fuzzyMatch(filter, entry.name);+ if (match) {+ const relative = entryPath.substring(basePath.length).replace(/^\//, '');+ scored.push({+ item: { name: entry.name, path: entryPath, type: getAssetType(entry), relativePath: relative },+ score: match.score,});}- } else if (entry.name.toLowerCase().includes(filter)) {- const relative = entryPath.substring(basePath.length).replace(/^\//, '');- results.push({- name: entry.name,- path: entryPath,- type: getAssetType(entry),- relativePath: relative,- });}}} catch {@@ -1592,11 +1593,13 @@ void main() {}}- return results.sort((a, b) => {- if (a.type === 'folder' && b.type !== 'folder') return -1;- if (a.type !== 'folder' && b.type === 'folder') return 1;- return a.name.localeCompare(b.name);- });+ return scored+ .sort((a, b) => {+ if (a.item.type === 'folder' && b.item.type !== 'folder') return -1;+ if (a.item.type !== 'folder' && b.item.type === 'folder') return 1;+ return b.score - a.score;+ })+ .map(s => s.item);}private async loadCurrentFolderItems(): Promise<AssetItem[]> {diff --git a/editor/src/panels/HierarchyPanel.ts b/editor/src/panels/HierarchyPanel.tsindex 533d47b3e..0683bdf65 100644--- a/editor/src/panels/HierarchyPanel.ts+++ b/editor/src/panels/HierarchyPanel.ts@@ -19,6 +19,7 @@ import { showInputDialog } from '../ui/dialog';import { joinPath, getParentDir } from '../utils/path';import { hasAnyOverrides } from '../prefab';import { fuzzyFilter, type FuzzyMatch } from '../utils/fuzzy';+import { escapeHtml } from '../utils/html';type DropPosition = 'before' | 'after' | 'inside';@@ -79,6 +80,8 @@ export class HierarchyPanel {</div><div class="es-hierarchy-toolbar"><input type="text" class="es-input es-hierarchy-search" placeholder="Search...">+ <button class="es-btn es-btn-icon" data-action="collapse-all" title="Collapse All">${icons.chevronRight(12)}</button>+ <button class="es-btn es-btn-icon" data-action="expand-all" title="Expand All">${icons.chevronDown(12)}</button><button class="es-btn es-btn-icon" data-action="add" title="Create Entity">${icons.plus()}</button><button class="es-btn es-btn-icon" data-action="duplicate" title="Duplicate">${icons.copy()}</button></div>@@ -88,7 +91,7 @@ export class HierarchyPanel {<span class="es-hierarchy-col-label">Item Label</span><span class="es-hierarchy-col-type">Type</span></div>- <div class="es-hierarchy-tree"></div>+ <div class="es-hierarchy-tree" role="tree"></div><div class="es-hierarchy-footer">0 entities</div>`;@@ -161,6 +164,22 @@ export class HierarchyPanel {}});+ const collapseAllBtn = this.container_.querySelector('[data-action="collapse-all"]');+ collapseAllBtn?.addEventListener('click', () => {+ this.expandedIds_.clear();+ this.render();+ });++ const expandAllBtn = this.container_.querySelector('[data-action="expand-all"]');+ expandAllBtn?.addEventListener('click', () => {+ for (const entity of this.store_.scene.entities) {+ if (entity.children.length > 0) {+ this.expandedIds_.add(entity.id);+ }+ }+ this.render();+ });+this.searchInput_?.addEventListener('input', () => {this.searchFilter_ = this.searchInput_?.value ?? '';this.performSearch();@@ -291,6 +310,15 @@ export class HierarchyPanel {return;}+ if ((e.key === 'a' || e.key === 'A') && (e.ctrlKey || e.metaKey)) {+ e.preventDefault();+ const roots = this.store_.scene.entities.filter(ent => ent.parent === null);+ if (roots.length > 0) {+ this.store_.selectEntities(roots.map(ent => ent.id));+ }+ return;+ }+if (e.key === 'Delete' || e.key === 'Backspace') {e.preventDefault();if (this.store_.selectedEntities.size > 1) {@@ -754,7 +782,7 @@ export class HierarchyPanel {const rawPath = this.store_.prefabEditingPath ?? '';const path = isUUID(rawPath) ? (getAssetDatabase().getPath(rawPath) ?? rawPath) : rawPath;const fileName = path.split('/').pop() ?? path;- nameEl.innerHTML = `${icons.package(12)} ${this.escapeHtml(fileName)}`;+ nameEl.innerHTML = `${icons.package(12)} ${escapeHtml(fileName)}`;}} else {this.prefabEditBar_.style.display = 'none';@@ -980,7 +1008,9 @@ export class HierarchyPanel {const nameHtml = this.renderEntityName(entity.name, match);- return `<div class="${itemClass}" data-entity-id="${entity.id}">+ const ariaExpanded = hasChildren ? ` aria-expanded="${isExpanded}"` : '';++ return `<div class="${itemClass}" data-entity-id="${entity.id}" role="treeitem"${ariaExpanded}><div class="es-hierarchy-row" draggable="true" style="padding-left: ${8 + depth * 16}px">${hasChildren ? `<span class="es-hierarchy-expand">${expandIcon}</span>` : '<span class="es-hierarchy-spacer"></span>'}<span class="es-hierarchy-visibility">${visibilityIcon}</span>@@ -993,15 +1023,15 @@ export class HierarchyPanel {private renderEntityName(name: string, match: FuzzyMatch | null | undefined): string {if (!match || match.matches.length === 0) {- return this.escapeHtml(name);+ return escapeHtml(name);}let html = '';for (let i = 0; i < name.length; i++) {if (match.matches.includes(i)) {- html += `<mark class="es-search-highlight">${this.escapeHtml(name[i])}</mark>`;+ html += `<mark class="es-search-highlight">${escapeHtml(name[i])}</mark>`;} else {- html += this.escapeHtml(name[i]);+ html += escapeHtml(name[i]);}}return html;@@ -1304,9 +1334,4 @@ export class HierarchyPanel {await this.store_.instantiatePrefab(uuid, parent);}- private escapeHtml(text: string): string {- const div = document.createElement('div');- div.textContent = text;- return div.innerHTML;- }}diff --git a/editor/src/panels/InspectorPanel.ts b/editor/src/panels/InspectorPanel.tsindex 8db94f334..91f8aa5f9 100644--- a/editor/src/panels/InspectorPanel.ts+++ b/editor/src/panels/InspectorPanel.ts@@ -244,9 +244,43 @@ export class InspectorPanel {`;this.contentContainer_.appendChild(header);+ const commonComponents = this.getCommonComponents(entities);+ if (commonComponents.length > 0) {+ const section = document.createElement('div');+ section.className = 'es-inspector-common-components';+ section.innerHTML = `+ <div class="es-section-header">+ <span class="es-section-title">Common Components</span>+ </div>+ <div class="es-common-component-list">+ ${commonComponents.map(name => `<div class="es-common-component-item">${icons.box(12)} ${name}</div>`).join('')}+ </div>+ `;+ this.contentContainer_.appendChild(section);+ }++ hideMaterialPreview(this.materialPreviewState_);this.updateFooter(`${entities.length} entities selected`);}+ private getCommonComponents(entities: Entity[]): string[] {+ if (entities.length === 0) return [];++ const first = this.store_.getEntityData(entities[0] as number);+ if (!first) return [];++ let common = new Set(first.components.map(c => c.type));++ for (let i = 1; i < entities.length; i++) {+ const data = this.store_.getEntityData(entities[i] as number);+ if (!data) return [];+ const types = new Set(data.components.map(c => c.type));+ common = new Set([...common].filter(t => types.has(t)));+ }++ return [...common];+ }+// =========================================================================// Asset Inspector// =========================================================================diff --git a/editor/src/panels/OutputPanel.ts b/editor/src/panels/OutputPanel.tsindex a81235e8b..90121b111 100644--- a/editor/src/panels/OutputPanel.ts+++ b/editor/src/panels/OutputPanel.ts@@ -67,7 +67,7 @@ export class OutputPanel implements PanelInstance {<button class="es-btn es-btn-icon" data-action="clear-output" title="Clear">${icons.trash(12)}</button></div></div>- <div class="es-output-content">+ <div class="es-output-content" role="log" aria-live="polite"><div class="es-output-empty">No output messages</div></div></div>diff --git a/editor/src/store/EditorStore.ts b/editor/src/store/EditorStore.tsindex d5d242aa6..1975feee5 100644--- a/editor/src/store/EditorStore.ts+++ b/editor/src/store/EditorStore.ts@@ -43,6 +43,7 @@ import { getGlobalPathResolver, getAssetDatabase, isUUID } from '../asset';import { WorldTransformCache } from '../transform/WorldTransformCache';import type { Transform } from '../math/Transform';import { isComponentRemovable } from '../schemas/ComponentSchemas';+import { showConfirmDialog } from '../ui/dialog';// =============================================================================// Types@@ -137,6 +138,10 @@ export class EditorStore {filePath: string | null;isDirty: boolean;} | null = null;+ private autoSaveTimer_: ReturnType<typeof setInterval> | null = null;++ private static readonly AUTOSAVE_KEY = 'esengine.autosave';+ private static readonly AUTOSAVE_INTERVAL = 60_000;constructor() {const scene = createEmptyScene();@@ -151,6 +156,7 @@ export class EditorStore {this.nextEntityId_ = this.computeNextEntityId(scene);this.rebuildEntityMap();this.worldTransforms_.setScene(scene);+ this.startAutoSave();}private computeNextEntityId(scene: SceneData): number {@@ -224,6 +230,7 @@ export class EditorStore {// =========================================================================newScene(name: string = 'Untitled', designResolution?: { width: number; height: number }): void {+ this.saveRecoveryBackup();this.state_.scene = createEmptyScene(name, designResolution);this.state_.selectedEntities.clear();this.state_.selectedAsset = null;@@ -238,6 +245,7 @@ export class EditorStore {}loadScene(scene: SceneData, filePath: string | null = null): void {+ this.saveRecoveryBackup();this.state_.scene = scene;this.state_.selectedEntities.clear();this.state_.selectedAsset = null;@@ -258,9 +266,38 @@ export class EditorStore {if (filePath) {this.state_.filePath = filePath;}+ this.clearAutoSave();this.notify('scene');}+ hasRecoveryData(): boolean {+ try {+ return localStorage.getItem(EditorStore.AUTOSAVE_KEY) !== null;+ } catch {+ return false;+ }+ }++ recoverScene(): SceneData | null {+ try {+ const raw = localStorage.getItem(EditorStore.AUTOSAVE_KEY);+ if (!raw) return null;+ const data = JSON.parse(raw) as { scene: SceneData; filePath: string | null };+ this.clearAutoSave();+ this.loadScene(data.scene, data.filePath);+ this.state_.isDirty = true;+ this.notify('scene');+ return data.scene;+ } catch {+ this.clearAutoSave();+ return null;+ }+ }++ dismissRecovery(): void {+ this.clearAutoSave();+ }+// =========================================================================// Selection// =========================================================================@@ -483,6 +520,12 @@ export class EditorStore {deleteSelectedEntities(): void {const toDelete = Array.from(this.state_.selectedEntities);++ const descendantMap = new Map<number, number[]>();+ for (const id of toDelete) {+ descendantMap.set(id, this.collectDescendantIds(id));+ }+const commands = toDelete.map(id => new DeleteEntityCommand(this.state_.scene, this.entityMap_, id as Entity));const compound = new CompoundCommand(commands, 'Delete entities');this.executeCommand(compound);@@ -490,7 +533,7 @@ export class EditorStore {this.state_.selectedEntities.clear();for (const id of toDelete) {- const descendants = this.collectDescendantIds(id);+ const descendants = descendantMap.get(id)!;for (const descId of descendants) {this.notifyEntityLifecycle({ entity: descId, type: 'deleted', parent: null });}@@ -902,12 +945,7 @@ export class EditorStore {let saveFailed = false;if (this.state_.isDirty) {- try {- await this.savePrefabEditing();- } catch (e) {- console.error('Failed to save prefab:', e);- saveFailed = true;- }+ saveFailed = !(await this.trySavePrefabWithRetry());}const saved = this.savedSceneState_;@@ -921,6 +959,24 @@ export class EditorStore {this.notify('scene');}+ private async trySavePrefabWithRetry(): Promise<boolean> {+ while (true) {+ try {+ await this.savePrefabEditing();+ return true;+ } catch (e) {+ const retry = await showConfirmDialog({+ title: 'Failed to save prefab',+ message: `${String(e)}\n\nRetry saving, or discard changes?`,+ confirmText: 'Retry',+ cancelText: 'Discard',+ danger: true,+ });+ if (!retry) return false;+ }+ }+ }+async savePrefabEditing(): Promise<boolean> {if (!this.prefabEditingPath_) return false;@@ -1125,6 +1181,39 @@ export class EditorStore {this.entityMap_.set(entity.id, entity);}}++ private startAutoSave(): void {+ this.autoSaveTimer_ = setInterval(() => {+ if (this.state_.isDirty) {+ this.saveAutoSave();+ }+ }, EditorStore.AUTOSAVE_INTERVAL);+ }++ private saveAutoSave(): void {+ try {+ const data = JSON.stringify({+ scene: this.state_.scene,+ filePath: this.state_.filePath,+ });+ localStorage.setItem(EditorStore.AUTOSAVE_KEY, data);+ } catch {+ // localStorage full or unavailable+ }+ }++ private clearAutoSave(): void {+ try {+ localStorage.removeItem(EditorStore.AUTOSAVE_KEY);+ } catch {+ // localStorage unavailable+ }+ }++ private saveRecoveryBackup(): void {+ if (!this.state_.isDirty) return;+ this.saveAutoSave();+ }}// =============================================================================diff --git a/editor/src/styles/editor.css b/editor/src/styles/editor.cssindex 5799cf813..93b536635 100644--- a/editor/src/styles/editor.css+++ b/editor/src/styles/editor.css@@ -13,17 +13,35 @@--es-bg-hover: #3e3e42;--es-border: #3c3c3c;--es-text-primary: #cccccc;- --es-text-secondary: #808080;+ --es-text-secondary: #8c8c8c;--es-accent: #0078d4;--es-accent-hover: #1084d8;--es-danger: #f44336;--es-success: #4caf50;+ --es-warning: #f0ad4e;+ --es-error: #d9534f;--es-input-bg: #2d2d2d;--es-text-disabled: #555555;- --es-text-muted: #666666;+ --es-text-muted: #737373;--es-scrollbar-track: #1e1e1e;--es-scrollbar-thumb: #424242;--es-scrollbar-thumb-hover: #555555;+ --es-accent-gold: #d19a66;+ --es-prefab: #4fc1ff;+ --es-drag: #61afef;+ --es-selection-bg: rgba(209, 154, 102, 0.2);+ --es-radius-sm: 3px;+ --es-radius-md: 4px;+ --es-radius-lg: 6px;+ --es-font-xs: 10px;+ --es-font-sm: 11px;+ --es-font-md: 12px;+ --es-font-base: 13px;+ --es-font-lg: 14px;+}++*, *::before, *::after {+ box-sizing: border-box;}/* =============================================================================@@ -56,7 +74,7 @@* SVG Icons* ============================================================================= */-svg {+.es-editor svg {display: inline-block;vertical-align: middle;}@@ -66,7 +84,7 @@ svg {}.es-btn-icon:hover svg {- stroke: var(--es-text-primary);+ stroke: #e0e0e0;}.es-btn-icon.es-active {@@ -85,7 +103,7 @@ svg {}.es-hierarchy-item.es-selected .es-hierarchy-icon svg {- stroke: #d19a66;+ stroke: var(--es-accent-gold);}.es-btn-remove svg {@@ -213,6 +231,7 @@ svg {.es-menu-item.es-disabled {color: var(--es-text-secondary);cursor: not-allowed;+ pointer-events: none;}.es-menu-item.es-disabled:hover {@@ -265,7 +284,7 @@ svg {}.es-editor-menubar .es-btn-preview.es-btn-danger {- background: var(--es-error, #d9534f);+ background: var(--es-error);}.es-editor-menubar .es-btn-preview.es-btn-danger:hover {@@ -287,7 +306,7 @@ svg {--dv-activegroup-hiddenpanel-tab-background-color: var(--es-bg-secondary);--dv-inactivegroup-visiblepanel-tab-background-color: var(--es-bg-tertiary);--dv-inactivegroup-hiddenpanel-tab-background-color: var(--es-bg-secondary);- --dv-activegroup-visiblepanel-tab-color: #d19a66;+ --dv-activegroup-visiblepanel-tab-color: var(--es-accent-gold);--dv-activegroup-hiddenpanel-tab-color: var(--es-text-secondary);--dv-inactivegroup-visiblepanel-tab-color: var(--es-text-primary);--dv-inactivegroup-hiddenpanel-tab-color: var(--es-text-secondary);@@ -412,6 +431,7 @@ svg {position: relative;height: 22px;box-sizing: border-box;+ transition: background 0.15s;}.es-hierarchy-row:hover {@@ -420,21 +440,21 @@ svg {.es-hierarchy-item.es-selected > .es-hierarchy-row {background: rgba(209, 154, 102, 0.3);- border-left-color: #d19a66;+ border-left-color: var(--es-accent-gold);}.es-hierarchy-item.es-selected > .es-hierarchy-row .es-hierarchy-name {- color: #d19a66;+ color: var(--es-accent-gold);}.es-hierarchy-item.es-drag-over > .es-hierarchy-row {background: rgba(97, 175, 239, 0.3);- border-left-color: #61afef;+ border-left-color: var(--es-drag);}.es-hierarchy-tree.es-drag-over {background: rgba(97, 175, 239, 0.1);- outline: 1px dashed #61afef;+ outline: 1px dashed var(--es-drag);outline-offset: -2px;}@@ -445,7 +465,7 @@ svg {left: 20px;right: 0;height: 2px;- background: #61afef;+ background: var(--es-drag);pointer-events: none;}@@ -456,13 +476,13 @@ svg {left: 20px;right: 0;height: 2px;- background: #61afef;+ background: var(--es-drag);pointer-events: none;}.es-hierarchy-item.es-drop-inside > .es-hierarchy-row {background: rgba(97, 175, 239, 0.3);- border-left-color: #61afef;+ border-left-color: var(--es-drag);}.es-hierarchy-item.es-dragging {@@ -539,7 +559,7 @@ svg {height: 18px;padding: 0 4px;margin: 0;- border: 1px solid #d19a66;+ border: 1px solid var(--es-accent-gold);border-radius: 2px;background: var(--es-bg-primary);color: var(--es-text-primary);@@ -561,7 +581,7 @@ svg {background: rgba(79, 193, 255, 0.1);border-bottom: 1px solid rgba(79, 193, 255, 0.25);font-size: 11px;- color: #4fc1ff;+ color: var(--es-prefab);}.es-prefab-back-btn {@@ -593,16 +613,16 @@ svg {}.es-prefab-edit-name svg {- stroke: #4fc1ff;+ stroke: var(--es-prefab);}.es-hierarchy-item.es-prefab-root > .es-hierarchy-row .es-hierarchy-name {- color: #4fc1ff;+ color: var(--es-prefab);font-weight: 600;}.es-hierarchy-item.es-prefab-root > .es-hierarchy-row .es-hierarchy-icon svg {- stroke: #4fc1ff;+ stroke: var(--es-prefab);}.es-hierarchy-item.es-prefab-child > .es-hierarchy-row .es-hierarchy-name {@@ -622,7 +642,7 @@ svg {}.es-hierarchy-item.es-search-selected > .es-hierarchy-row {- border-left: 2px solid #61afef;+ border-left: 2px solid var(--es-drag);}.es-hierarchy-footer {@@ -707,14 +727,17 @@ svg {}.es-entity-icon svg {- stroke: #d19a66;+ stroke: var(--es-accent-gold);}.es-entity-name {flex: 1;font-weight: 600;font-size: 12px;- color: #d19a66;+ color: var(--es-accent-gold);+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;}.es-entity-visibility {@@ -745,7 +768,7 @@ svg {padding: 2px 4px;font-size: 12px;font-weight: 600;- color: #d19a66;+ color: var(--es-accent-gold);background: transparent;border: 1px solid transparent;border-radius: 2px;@@ -771,11 +794,11 @@ svg {border: 1px solid rgba(79, 193, 255, 0.25);border-radius: 3px;font-size: 11px;- color: #4fc1ff;+ color: var(--es-prefab);}.es-prefab-info-bar svg {- stroke: #4fc1ff;+ stroke: var(--es-prefab);flex-shrink: 0;}@@ -795,14 +818,14 @@ svg {}.es-prefab-info-link:hover {- text-decoration-color: #4fc1ff;+ text-decoration-color: var(--es-prefab);}.es-prefab-info-bar .es-btn {font-size: 10px;padding: 1px 6px;border: 1px solid rgba(79, 193, 255, 0.3);- color: #4fc1ff;+ color: var(--es-prefab);background: transparent;cursor: pointer;border-radius: 3px;@@ -814,7 +837,7 @@ svg {.es-property-row.es-overridden .es-property-label {font-weight: 700;- color: #4fc1ff;+ color: var(--es-prefab);}.es-property-row.es-overridden .es-property-label::before {@@ -823,7 +846,7 @@ svg {width: 6px;height: 6px;border-radius: 50%;- background: #4fc1ff;+ background: var(--es-prefab);margin-right: 4px;vertical-align: middle;}@@ -893,13 +916,16 @@ svg {}.es-component-icon svg {- stroke: #d19a66;+ stroke: var(--es-accent-gold);}.es-component-title {flex: 1;font-weight: 500;font-size: 11px;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;}.es-collapsible-content {@@ -1371,6 +1397,8 @@ svg {.es-btn-icon {padding: 2px 6px;min-width: 20px;+ cursor: pointer;+ transition: background 0.15s;}.es-btn-remove {@@ -1468,7 +1496,7 @@ svg {}.es-number-drag-label:hover {- background: var(--es-hover-bg);+ background: var(--es-bg-hover);color: #999;}@@ -1477,7 +1505,7 @@ svg {height: 14px;margin: 0;cursor: pointer;- accent-color: #d19a66;+ accent-color: var(--es-accent-gold);}.es-input-select {@@ -1660,7 +1688,7 @@ svg {box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);min-width: 160px;padding: 4px 0;- z-index: 1000;+ z-index: 2000;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;font-size: 12px;}@@ -1673,6 +1701,7 @@ svg {color: var(--es-text-primary);cursor: pointer;position: relative;+ transition: background 0.15s;}.es-context-menu-item:hover {@@ -1879,6 +1908,7 @@ svg {padding: 4px 8px;cursor: pointer;user-select: none;+ transition: background 0.15s;}.es-folder-item:hover {@@ -1886,11 +1916,11 @@ svg {}.es-folder-item.es-selected {- background: rgba(209, 154, 102, 0.2);+ background: var(--es-selection-bg);}.es-folder-item.es-selected .es-folder-name {- color: #d19a66;+ color: var(--es-accent-gold);}.es-folder-expand {@@ -1931,6 +1961,7 @@ svg {border-radius: 4px;cursor: pointer;user-select: none;+ transition: background 0.15s;}.es-asset-item:hover {@@ -1938,7 +1969,7 @@ svg {}.es-asset-item.es-selected {- background: rgba(209, 154, 102, 0.2);+ background: var(--es-selection-bg);}.es-asset-item.es-dragging {@@ -2028,7 +2059,7 @@ svg {}.es-cb-list-row.es-selected {- background: rgba(209, 154, 102, 0.2);+ background: var(--es-selection-bg);}.es-cb-list-row[draggable="true"] {@@ -2190,7 +2221,7 @@ svg {}.es-status-unsaved {- color: var(--es-warning, #f0ad4e);+ color: var(--es-warning);}.es-unsaved-dot {@@ -2198,7 +2229,7 @@ svg {width: 6px;height: 6px;border-radius: 50%;- background: var(--es-warning, #f0ad4e);+ background: var(--es-warning);}.es-statusbar-message {@@ -2303,12 +2334,12 @@ svg {/* Active state for statusbar buttons */.es-btn-dropdown.es-active,.es-btn-tab.es-active {- color: #d19a66;+ color: var(--es-accent-gold);}.es-btn-dropdown.es-active svg,.es-btn-tab.es-active svg {- stroke: #d19a66;+ stroke: var(--es-accent-gold);}/* =============================================================================@@ -2399,8 +2430,8 @@ svg {}.es-launcher-btn-primary {- background: #d19a66;- border-color: #d19a66;+ background: var(--es-accent-gold);+ border-color: var(--es-accent-gold);color: #1e1e1e;font-weight: 500;}@@ -2544,7 +2575,7 @@ svg {display: flex;align-items: center;justify-content: center;- z-index: 1000;+ z-index: 3000;color: var(--es-text-primary);font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;font-size: 13px;@@ -2665,7 +2696,7 @@ svg {}.es-dialog-template.selected {- border-color: #d19a66;+ border-color: var(--es-accent-gold);background: rgba(209, 154, 102, 0.1);}@@ -2720,8 +2751,8 @@ svg {}.es-dialog-btn-primary {- background: #d19a66;- border-color: #d19a66;+ background: var(--es-accent-gold);+ border-color: var(--es-accent-gold);color: #1e1e1e;font-weight: 500;}@@ -2805,7 +2836,7 @@ svg {.es-settings-nav-item.es-active {color: var(--es-text-primary);background: var(--es-bg-tertiary);- border-left: 2px solid #d19a66;+ border-left: 2px solid var(--es-accent-gold);padding-left: 14px;}@@ -2960,7 +2991,7 @@ svg {display: flex;align-items: center;justify-content: center;- z-index: 10000;+ z-index: 5000;}.es-popup-container {@@ -3447,6 +3478,7 @@ svg {}.es-build-config-item {+ position: relative;padding: 6px 12px 6px 32px;display: flex;align-items: center;@@ -3727,7 +3759,7 @@ svg {.es-build-hint {margin-top: 4px;font-size: 11px;- color: var(--es-text-tertiary);+ color: var(--es-text-muted);}.es-build-empty {@@ -3840,7 +3872,7 @@ svg {.es-toast-container {position: fixed;- bottom: 20px;+ bottom: 44px;right: 20px;z-index: 10000;display: flex;@@ -3926,7 +3958,7 @@ svg {justify-content: center;background: none;border: none;- color: var(--es-text-tertiary);+ color: var(--es-text-muted);cursor: pointer;border-radius: 3px;transition: background 0.15s, color 0.15s;@@ -4811,8 +4843,8 @@ svg {.es-addr-group-item.es-selected {background: rgba(209, 154, 102, 0.25);- border-left-color: #d19a66;- color: #d19a66;+ border-left-color: var(--es-accent-gold);+ color: var(--es-accent-gold);}.es-addr-group-dot {@@ -4824,7 +4856,7 @@ svg {}.es-addr-group-item.es-selected .es-addr-group-dot {- background: #d19a66;+ background: var(--es-accent-gold);}.es-addr-group-count {@@ -4857,7 +4889,7 @@ svg {}.es-addr-label-check input[type="checkbox"] {- accent-color: #d19a66;+ accent-color: var(--es-accent-gold);}.es-addressable-toolbar {@@ -4931,11 +4963,11 @@ svg {}.es-addr-table-row.es-selected {- background: rgba(209, 154, 102, 0.2);+ background: var(--es-selection-bg);}.es-addr-table-row.es-selected .es-addr-col-name {- color: #d19a66;+ color: var(--es-accent-gold);}.es-addr-table-row:active {@@ -5052,7 +5084,7 @@ svg {.es-addr-group-item.es-drag-over {background: rgba(97, 175, 239, 0.25);- border-left-color: #61afef;+ border-left-color: var(--es-drag);}.es-addr-config-toggle {@@ -5233,7 +5265,7 @@ svg {.es-floating-window {position: fixed;- z-index: 1000;+ z-index: 5000;background: var(--es-bg-secondary);border: 1px solid var(--es-border);border-radius: 6px;@@ -5383,6 +5415,7 @@ svg {.es-content-drawer.es-drawer-open {height: var(--drawer-height, 300px);+ box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);}.es-content-drawer.es-drawer-resizing {@@ -5422,6 +5455,9 @@ svg {gap: 6px;font-size: 12px;color: var(--es-text-primary);+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;}.es-content-drawer-title svg {@@ -5459,6 +5495,10 @@ svg {stroke: var(--es-text-primary);}+.es-content-drawer-actions .es-btn-icon.es-active svg {+ stroke: var(--es-accent);+}+.es-content-drawer-body {flex: 1;overflow: hidden;@@ -5467,3 +5507,74 @@ svg {.es-content-drawer-body .es-content-browser-header {display: none;}++/* =============================================================================+ * Focus Visible+ * ============================================================================= */++.es-btn:focus-visible,+.es-btn-icon:focus-visible,+.es-gizmo-btn:focus-visible,+.es-menu-trigger:focus-visible,+.es-menu-item:focus-visible,+.es-context-menu-item:focus-visible,+.es-input:focus-visible,+.es-input-checkbox:focus-visible,+.es-statusbar-btn:focus-visible {+ outline: 2px solid var(--es-accent);+ outline-offset: 2px;+}++/* =============================================================================+ * Active / Pressed States+ * ============================================================================= */++.es-btn:active:not(:disabled) {+ background: var(--es-bg-primary);+}++.es-btn-icon:active {+ background: var(--es-bg-primary);+}++.es-gizmo-btn:active {+ background: var(--es-bg-primary);+}++/* =============================================================================+ * Splitter+ * ============================================================================= */++.es-splitter {+ background: var(--es-border);+ flex-shrink: 0;+ transition: background 0.15s;+}++.es-splitter:hover {+ background: var(--es-accent);+}++.es-splitter-horizontal {+ width: 100%;+ height: 4px;+ cursor: ns-resize;+}++.es-splitter-vertical {+ width: 4px;+ height: 100%;+ cursor: ew-resize;+}++/* =============================================================================+ * Reduced Motion+ * ============================================================================= */++@media (prefers-reduced-motion: reduce) {+ *, *::before, *::after {+ animation-duration: 0.01ms !important;+ animation-iteration-count: 1 !important;+ transition-duration: 0.01ms !important;+ }+}diff --git a/editor/src/ui/ContentDrawer.ts b/editor/src/ui/ContentDrawer.tsindex b914468da..d176c3000 100644--- a/editor/src/ui/ContentDrawer.ts+++ b/editor/src/ui/ContentDrawer.ts@@ -6,6 +6,7 @@ import { icons } from '../utils/icons';type DrawerState = 'hidden' | 'open';const DRAWER_HEIGHT_KEY = 'esengine.content-drawer.height';+const DRAWER_PINNED_KEY = 'esengine.content-drawer.pinned';const DEFAULT_HEIGHT = 300;const MIN_HEIGHT = 150;const MAX_HEIGHT = 600;@@ -18,6 +19,8 @@ export class ContentDrawer {private drawerHeight_: number;private outsideClickHandler_: ((e: MouseEvent) => void) | null = null;private resizing_ = false;+ private pinned_: boolean;+ private pinBtn_: HTMLElement | null = null;constructor(private editorContainer_: HTMLElement,@@ -26,6 +29,7 @@ export class ContentDrawer {private panelOptions_: ContentBrowserOptions,) {this.drawerHeight_ = parseInt(localStorage.getItem(DRAWER_HEIGHT_KEY) ?? '', 10) || DEFAULT_HEIGHT;+ this.pinned_ = localStorage.getItem(DRAWER_PINNED_KEY) === 'true';}get state(): DrawerState {@@ -57,7 +61,9 @@ export class ContentDrawer {this.updateStatusbarButton_(true);});- this.attachOutsideClick_();+ if (!this.pinned_) {+ this.attachOutsideClick_();+ }this.drawerEl_!.addEventListener('transitionend', () => {window.dispatchEvent(new Event('resize'));@@ -123,6 +129,7 @@ export class ContentDrawer {<span class="es-content-drawer-title">${icons.folder(14)} Content Browser</span><div class="es-content-drawer-actions"><button class="es-btn-icon" title="Dock in Layout">${icons.template(14)}</button>+ <button class="es-btn-icon es-drawer-pin-btn${this.pinned_ ? ' es-active' : ''}" title="${this.pinned_ ? 'Unpin' : 'Pin'}">${this.pinned_ ? icons.lock(14) : icons.lockOpen(14)}</button><button class="es-btn-icon" title="Close">${icons.x(14)}</button></div></div>@@ -138,8 +145,12 @@ export class ContentDrawer {this.panelBody_ = this.drawerEl_.querySelector('.es-content-drawer-body') as HTMLElement;- const [dockBtn, closeBtn] = this.drawerEl_.querySelectorAll('.es-content-drawer-actions .es-btn-icon');+ const dockBtn = this.drawerEl_.querySelector('[title="Dock in Layout"]');+ this.pinBtn_ = this.drawerEl_.querySelector('.es-drawer-pin-btn') as HTMLElement;+ const closeBtn = this.drawerEl_.querySelector('[title="Close"]');+dockBtn?.addEventListener('click', () => this.dockInLayout());+ this.pinBtn_?.addEventListener('click', () => this.togglePin_());closeBtn?.addEventListener('click', () => this.closeDrawer());this.setupResize_();@@ -178,6 +189,23 @@ export class ContentDrawer {});}+ private togglePin_(): void {+ this.pinned_ = !this.pinned_;+ localStorage.setItem(DRAWER_PINNED_KEY, String(this.pinned_));++ if (this.pinBtn_) {+ this.pinBtn_.innerHTML = this.pinned_ ? icons.lock(14) : icons.lockOpen(14);+ this.pinBtn_.title = this.pinned_ ? 'Unpin' : 'Pin';+ this.pinBtn_.classList.toggle('es-active', this.pinned_);+ }++ if (this.pinned_) {+ this.detachOutsideClick_();+ } else if (this.state_ === 'open') {+ this.attachOutsideClick_();+ }+ }+private attachOutsideClick_(): void {this.detachOutsideClick_();diff --git a/editor/src/utils/html.ts b/editor/src/utils/html.tsnew file mode 100644index 000000000..f5f157c61--- /dev/null+++ b/editor/src/utils/html.ts@@ -0,0 +1,5 @@+export function escapeHtml(text: string): string {+ const div = document.createElement('div');+ div.textContent = text;+ return div.innerHTML;+}