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 UI improvements across all panels
esengine1458e39509b2
diff --git a/editor/src/Editor.ts b/editor/src/Editor.tsindex 3fd3d37a7..7533cb58c 100644--- a/editor/src/Editor.ts+++ b/editor/src/Editor.ts@@ -54,7 +54,7 @@ import {lockBuiltinInspectorExtensions,clearExtensionInspectorExtensions,} from './panels/inspector/InspectorRegistry';-import { showConfirmDialog, showInputDialog } from './ui/dialog';+import { showConfirmDialog, showInputDialog, showDialog } from './ui/dialog';import { getEditorStore } from './store';import { generateUniqueName } from './utils/naming';import {@@ -100,6 +100,8 @@ export class Editor {private assetLibraryReady_: Promise<void> = Promise.resolve();private clipboard_: EntityData[] | null = null;private addressableWindow_: { element: HTMLElement; panel: AddressablePanel; keyHandler: (e: KeyboardEvent) => void } | null = null;+ private isPreviewRunning_ = false;+ private escapeHandler_: ((e: KeyboardEvent) => void) | null = null;constructor(container: HTMLElement, options?: EditorOptions) {this.container_ = container;@@ -108,6 +110,7 @@ export class Editor {this.panelManager_ = new PanelManager();this.menuManager_ = new MenuManager();+ this.menuManager_.setStore(this.store_);this.previewManager_ = new PreviewManager(this.projectPath_);installGlobalErrorHandler();@@ -235,7 +238,12 @@ export class Editor {// Scene Operations// =========================================================================- newScene(): void {+ async newScene(): Promise<void> {+ if (this.store_.isDirty) {+ const result = await this.showUnsavedChangesPrompt();+ if (result === 'cancel') return;+ if (result === 'save') await this.saveScene();+ }const w = getSettingsValue<number>('project.designWidth');const h = getSettingsValue<number>('project.designHeight');this.store_.newScene('Untitled', { width: w, height: h });@@ -275,6 +283,11 @@ export class Editor {}async loadScene(): Promise<void> {+ if (this.store_.isDirty) {+ const result = await this.showUnsavedChangesPrompt();+ if (result === 'cancel') return;+ if (result === 'save') await this.saveScene();+ }await this.assetLibraryReady_;const scene = await loadSceneFromFile();if (scene) {@@ -788,10 +801,34 @@ export class Editor {await this.previewManager_.startPreview(this.store_.scene, this.scriptLoader_, this.spineVersion_,);+ this.isPreviewRunning_ = true;+ this.updatePreviewButton();}async stopPreview(): Promise<void> {await this.previewManager_.stopPreview();+ this.isPreviewRunning_ = false;+ this.updatePreviewButton();+ }++ async togglePreview(): Promise<void> {+ if (this.isPreviewRunning_) {+ await this.stopPreview();+ } else {+ await this.startPreview();+ }+ }++ private updatePreviewButton(): void {+ const btn = this.container_.querySelector('[data-action="preview"]') as HTMLElement;+ if (!btn) return;+ if (this.isPreviewRunning_) {+ btn.innerHTML = `${icons.stop(14)} Stop`;+ btn.classList.add('es-btn-danger');+ } else {+ btn.innerHTML = `${icons.play(14)} Preview`;+ btn.classList.remove('es-btn-danger');+ }}async navigateToAsset(assetPath: string): Promise<void> {@@ -924,6 +961,7 @@ export class Editor {`;this.panelManager_.instantiatePanels(this.container_, this.store_);+ this.panelManager_.setupTabEvents(this.container_);this.panelManager_.updateBottomPanelVisibility(this.container_);this.setupSplitters();@@ -938,7 +976,8 @@ export class Editor {e.preventDefault();});- this.menuManager_.setupToolbarEvents(this.container_, () => this.startPreview());+ this.menuManager_.setupToolbarEvents(this.container_, () => this.togglePreview());+ this.setupEscapeHandler();this.store_.subscribe(() => this.menuManager_.updateToolbarState(this.container_));this.store_.subscribe(() => {this.menuManager_.updateStatusbar();@@ -986,6 +1025,25 @@ export class Editor {});this.splitters_.push(rightSplitter);}++ const body = this.container_.querySelector('.es-editor-body') as HTMLElement;+ const bottomPanel = this.container_.querySelector('.es-editor-bottom') as HTMLElement;+ if (body && main && bottomPanel) {+ const bottomSize = this.loadPanelSize('panelSizeBottom', 250);+ bottomPanel.style.height = `${bottomSize}px`;+ (main as HTMLElement).style.flex = '1';+ const bottomSplitter = new Splitter({+ direction: 'vertical',+ container: body,+ leftPanel: main as HTMLElement,+ rightPanel: bottomPanel,+ minSize: 120,+ onResize: (_, size) => {+ this.savePanelSize('panelSizeBottom', size);+ },+ });+ this.splitters_.push(bottomSplitter);+ }}private loadPanelSize(key: string, defaultValue: number): number {@@ -1010,6 +1068,61 @@ export class Editor {}}+ private async showUnsavedChangesPrompt(): Promise<'save' | 'discard' | 'cancel'> {+ return new Promise((resolve) => {+ let resolved = false;+ showDialog({+ title: 'Unsaved Changes',+ content: 'You have unsaved changes. Save before continuing?',+ buttons: [+ { label: 'Cancel', role: 'cancel' },+ {+ label: "Don't Save", role: 'custom',+ onClick: () => { resolved = true; resolve('discard'); },+ },+ {+ label: 'Save', role: 'confirm', primary: true,+ onClick: () => { resolved = true; resolve('save'); },+ },+ ],+ closeOnEscape: true,+ }).then((result) => {+ if (!resolved) {+ resolve(result.action === 'confirm' ? 'save' : 'cancel');+ }+ });+ });+ }++ private setupEscapeHandler(): void {+ this.escapeHandler_ = (e: KeyboardEvent) => {+ if (e.key !== 'Escape') return;+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return;++ if (document.querySelector('.es-dialog-overlay')) return;+ if (document.querySelector('.es-context-menu')) return;++ const openMenu = this.container_.querySelector('.es-menu.es-open');+ if (openMenu) {+ openMenu.classList.remove('es-open');+ return;+ }++ if (this.addressableWindow_) {+ this.addressableWindow_.panel.dispose();+ this.addressableWindow_.element.remove();+ document.removeEventListener('keydown', this.addressableWindow_.keyHandler);+ this.addressableWindow_ = null;+ return;+ }++ if (this.store_.selectedEntities.size > 0) {+ this.store_.selectEntity(null);+ }+ };+ document.addEventListener('keydown', this.escapeHandler_);+ }+dispose(): void {if (this.addressableWindow_) {this.addressableWindow_.panel.dispose();@@ -1017,6 +1130,10 @@ export class Editor {document.removeEventListener('keydown', this.addressableWindow_.keyHandler);this.addressableWindow_ = null;}+ if (this.escapeHandler_) {+ document.removeEventListener('keydown', this.escapeHandler_);+ this.escapeHandler_ = null;+ }this.menuManager_.dispose();this.scriptLoader_?.dispose();this.extensionLoader_?.dispose();diff --git a/editor/src/MenuManager.ts b/editor/src/MenuManager.tsindex 6cfcbf07f..36fe47f36 100644--- a/editor/src/MenuManager.ts+++ b/editor/src/MenuManager.ts@@ -2,16 +2,22 @@ import { getAllMenus, getMenuItems, getAllStatusbarItems } from './menus';import { ShortcutManager } from './menus/ShortcutManager';import { getPanelsByPosition } from './panels/PanelRegistry';import { icons } from './utils/icons';+import type { EditorStore } from './store/EditorStore';export class MenuManager {private statusbarInstances_: Array<{ dispose(): void; update?(): void }> = [];private shortcutManager_: ShortcutManager;private documentClickHandler_: ((e: MouseEvent) => void) | null = null;+ private store_: EditorStore | null = null;constructor() {this.shortcutManager_ = new ShortcutManager();}+ setStore(store: EditorStore): void {+ this.store_ = store;+ }+get statusbarInstances(): Array<{ dispose(): void; update?(): void }> {return this.statusbarInstances_;}@@ -55,7 +61,7 @@ export class MenuManager {buildMenuBarHTML(): string {const menus = getAllMenus();return menus.map(menu => {- const items = getMenuItems(menu.id);+ const items = getMenuItems(menu.id).filter(i => !i.hidden);const itemsHTML = items.map(item => {const parts: string[] = [];if (item.separator) {@@ -193,6 +199,19 @@ export class MenuManager {const el = container.querySelector(`[data-action="${item.id}"]`);el?.classList.toggle('es-disabled', !item.enabled());}++ if (this.store_ && (item.id === 'edit.undo' || item.id === 'edit.redo')) {+ const el = container.querySelector(`[data-action="${item.id}"] .es-menu-item-text`);+ if (el) {+ if (item.id === 'edit.undo') {+ const desc = this.store_.undoDescription;+ el.textContent = desc ? `Undo ${desc}` : 'Undo';+ } else {+ const desc = this.store_.redoDescription;+ el.textContent = desc ? `Redo ${desc}` : 'Redo';+ }+ }+ }}}}diff --git a/editor/src/PanelManager.ts b/editor/src/PanelManager.tsindex 3509ce2df..b5b4c556e 100644--- a/editor/src/PanelManager.ts+++ b/editor/src/PanelManager.ts@@ -23,6 +23,7 @@ import { icons } from './utils/icons';export class PanelManager {private panelInstances_ = new Map<string, PanelInstance>();private activeBottomPanelId_: string | null = 'content-browser';+ private activeTabIds_ = new Map<string, string>();get activeBottomPanelId(): string | null {return this.activeBottomPanelId_;@@ -305,14 +306,73 @@ export class PanelManager {buildTabBarHTML(): string {const positions: PanelPosition[] = ['left', 'center', 'right'];- return positions.flatMap(pos => getPanelsByPosition(pos))- .filter(p => p.defaultVisible)- .map(p => `- <div class="es-tab es-tab-active" data-panel="${p.id}">+ const allPanels = positions.flatMap(pos => getPanelsByPosition(pos))+ .filter(p => p.defaultVisible);++ for (const p of allPanels) {+ const pos = p.position ?? 'center';+ if (!this.activeTabIds_.has(pos)) {+ this.activeTabIds_.set(pos, p.id);+ }+ }++ return allPanels.map(p => {+ const pos = p.position ?? 'center';+ const isActive = this.activeTabIds_.get(pos) === p.id;+ return `+ <div class="es-tab${isActive ? ' es-tab-active' : ''}" data-panel="${p.id}" data-position="${pos}"><span class="es-tab-label">${p.title}</span><button class="es-tab-close">${icons.x(10)}</button></div>- `).join('');+ `;+ }).join('');+ }++ setupTabEvents(container: HTMLElement): void {+ const tabBar = container.querySelector('.es-editor-tabs');+ if (!tabBar) return;++ tabBar.addEventListener('click', (e) => {+ const target = e.target as HTMLElement;+ const closeBtn = target.closest('.es-tab-close');+ const tab = target.closest('.es-tab') as HTMLElement;+ if (!tab) return;++ const panelId = tab.dataset.panel;+ if (!panelId) return;++ if (closeBtn) {+ const panelEl = container.querySelector(`[data-panel-id="${panelId}"]`) as HTMLElement;+ if (panelEl) {+ panelEl.style.display = 'none';+ }+ tab.style.display = 'none';+ this.hidePanel(panelId);+ return;+ }++ const pos = tab.dataset.position;+ if (pos) {+ this.activeTabIds_.set(pos, panelId);+ }++ tabBar.querySelectorAll('.es-tab').forEach(t => {+ const el = t as HTMLElement;+ if (el.dataset.position === pos) {+ el.classList.toggle('es-tab-active', el.dataset.panel === panelId);+ }+ });++ const panels = getPanelsByPosition(pos as PanelPosition);+ for (const p of panels) {+ const panelEl = container.querySelector(`[data-panel-id="${p.id}"]`) as HTMLElement;+ if (panelEl) {+ panelEl.style.display = p.id === panelId ? '' : 'none';+ }+ }++ this.showPanel(panelId);+ });}dispose(): void {diff --git a/editor/src/commands/EntityCommands.ts b/editor/src/commands/EntityCommands.tsindex 16ac042fa..8856b6fe5 100644--- a/editor/src/commands/EntityCommands.ts+++ b/editor/src/commands/EntityCommands.ts@@ -374,3 +374,40 @@ export class RemoveComponentCommand extends BaseCommand {});}}++// =============================================================================+// ReorderComponentCommand+// =============================================================================++export class ReorderComponentCommand extends BaseCommand {+ readonly type = 'reorder_component';+ readonly description: string;++ constructor(+ private scene_: SceneData,+ private entityMap_: Map<number, EntityData>,+ private entityId_: number,+ private fromIndex_: number,+ private toIndex_: number+ ) {+ super();+ this.description = `Reorder component`;+ }++ execute(): void {+ this.swap(this.fromIndex_, this.toIndex_);+ }++ undo(): void {+ this.swap(this.toIndex_, this.fromIndex_);+ }++ private swap(from: number, to: number): void {+ const entity = this.entityMap_.get(this.entityId_);+ if (!entity) return;+ const components = entity.components;+ if (from < 0 || from >= components.length || to < 0 || to >= components.length) return;+ const [removed] = components.splice(from, 1);+ components.splice(to, 0, removed);+ }+}diff --git a/editor/src/commands/index.ts b/editor/src/commands/index.tsindex f1816ef68..c014f75e1 100644--- a/editor/src/commands/index.ts+++ b/editor/src/commands/index.ts@@ -12,6 +12,7 @@ export {MoveEntityCommand,AddComponentCommand,RemoveComponentCommand,+ ReorderComponentCommand,} from './EntityCommands';export {InstantiatePrefabCommand,diff --git a/editor/src/gizmos/GizmoManager.ts b/editor/src/gizmos/GizmoManager.tsindex 39df5b630..a14e435b9 100644--- a/editor/src/gizmos/GizmoManager.ts+++ b/editor/src/gizmos/GizmoManager.ts@@ -61,11 +61,11 @@ export class GizmoManager {return true;}- onMouseMove(worldX: number, worldY: number): void {+ onMouseMove(worldX: number, worldY: number, event?: MouseEvent): void {if (!this.context_) return;if (this.dragState_) {- this.dragState_.descriptor.onDrag?.(worldX, worldY, this.dragState_.data, this.context_);+ this.dragState_.descriptor.onDrag?.(worldX, worldY, this.dragState_.data, this.context_, event);return;}diff --git a/editor/src/gizmos/GizmoRegistry.ts b/editor/src/gizmos/GizmoRegistry.tsindex fa33ff66c..509f0d148 100644--- a/editor/src/gizmos/GizmoRegistry.ts+++ b/editor/src/gizmos/GizmoRegistry.ts@@ -22,7 +22,7 @@ export interface GizmoDescriptor {hitTest(worldX: number, worldY: number, ctx: GizmoContext): { hit: boolean; data?: unknown };draw(ctx: GizmoContext): void;onDragStart?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext): void;- onDrag?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext): void;+ onDrag?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext, event?: MouseEvent): void;onDragEnd?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext): void;onHover?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext): void;getCursor?(hitData: unknown): string;diff --git a/editor/src/gizmos/builtinGizmos.ts b/editor/src/gizmos/builtinGizmos.tsindex 387363542..137b170de 100644--- a/editor/src/gizmos/builtinGizmos.ts+++ b/editor/src/gizmos/builtinGizmos.ts@@ -1,6 +1,7 @@import { registerGizmo, type GizmoContext, type GizmoDescriptor } from './GizmoRegistry';import { icons } from '../utils/icons';import { quatToEuler, eulerToQuat } from '../math/Transform';+import { getSettingsValue } from '../settings/SettingsRegistry';const GIZMO_COLORS = {x: '#e74c3c',@@ -178,7 +179,7 @@ export function createMoveGizmo(): GizmoDescriptor {}},- onDrag(worldX, worldY, _hitData, gctx) {+ onDrag(worldX, worldY, _hitData, gctx, event) {const entity = gctx.store.selectedEntity;if (entity === null || !dragState) return;@@ -191,6 +192,13 @@ export function createMoveGizmo(): GizmoDescriptor {if (dragAxis === 'x' || dragAxis === 'xy') newX += dx;if (dragAxis === 'y' || dragAxis === 'xy') newY += dy;+ const snapActive = event && (event.ctrlKey || event.metaKey);+ if (snapActive) {+ const gridSize = getSettingsValue<number>('scene.gridSize') ?? 50;+ newX = Math.round(newX / gridSize) * gridSize;+ newY = Math.round(newY / gridSize) * gridSize;+ }+gctx.store.updatePropertyDirect(entity, 'LocalTransform', 'position', {x: newX, y: newY, z: dragState.startValue.z,});@@ -326,7 +334,7 @@ export function createRotateGizmo(): GizmoDescriptor {}},- onDrag(worldX, worldY, _hitData, gctx) {+ onDrag(worldX, worldY, _hitData, gctx, event) {const entity = gctx.store.selectedEntity;if (entity === null || !dragState) return;@@ -338,7 +346,11 @@ export function createRotateGizmo(): GizmoDescriptor {dragState.startWorldX - pos.x,);const currentAngle = Math.atan2(worldY - pos.y, worldX - pos.x);- const deltaAngle = (currentAngle - startAngle) * (180 / Math.PI);+ let deltaAngle = (currentAngle - startAngle) * (180 / Math.PI);++ if (event?.shiftKey) {+ deltaAngle = Math.round(deltaAngle / 15) * 15;+ }const newRotZ = dragState.startEuler.z + deltaAngle;const quat = eulerToQuat({ x: 0, y: 0, z: newRotZ });@@ -552,33 +564,6 @@ export function createRectGizmo(): GizmoDescriptor {let activeHandle: RectHandle = 'none';let dragState: RectGizmoDragState | null = null;- function getHandles(gctx: GizmoContext): { x: number; y: number; key: RectHandle }[] | null {- const entityData = gctx.store.getSelectedEntityData();- if (!entityData) return null;-- const pos = getSelectedEntityPosition(gctx);- if (!pos) return null;-- const worldTransform = gctx.getWorldTransform(entityData.id);- const bounds = gctx.getEntityBounds(entityData);-- const w = bounds.width * Math.abs(worldTransform.scale.x);- const h = bounds.height * Math.abs(worldTransform.scale.y);- const halfW = w / 2;- const halfH = h / 2;-- return [- { x: -halfW, y: halfH, key: 'tl' },- { x: halfW, y: halfH, key: 'tr' },- { x: -halfW, y: -halfH, key: 'bl' },- { x: halfW, y: -halfH, key: 'br' },- { x: 0, y: halfH, key: 't' },- { x: 0, y: -halfH, key: 'b' },- { x: -halfW, y: 0, key: 'l' },- { x: halfW, y: 0, key: 'r' },- ];- }-return {id: 'rect',name: 'Rect',diff --git a/editor/src/menus/MenuRegistry.ts b/editor/src/menus/MenuRegistry.tsindex 6c6fc2b5f..56aed8dab 100644--- a/editor/src/menus/MenuRegistry.ts+++ b/editor/src/menus/MenuRegistry.ts@@ -14,6 +14,7 @@ export interface MenuItemDescriptor {order?: number;enabled?: () => boolean;action: () => void;+ hidden?: boolean;}export interface StatusbarItemDescriptor {diff --git a/editor/src/menus/ShortcutManager.ts b/editor/src/menus/ShortcutManager.tsindex 1bfeb8602..a3853c006 100644--- a/editor/src/menus/ShortcutManager.ts+++ b/editor/src/menus/ShortcutManager.ts@@ -33,15 +33,16 @@ export class ShortcutManager {}handleKeyDown(e: KeyboardEvent): boolean {- if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {- return false;- }-const ctrl = e.ctrlKey || e.metaKey;const shift = e.shiftKey;const alt = e.altKey;const key = e.key.toLowerCase();+ const inTextInput = e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement;+ if (inTextInput && !ctrl && !alt) {+ return false;+ }+for (const binding of this.bindings_) {if (binding.ctrl === ctrl &&binding.shift === shift &&diff --git a/editor/src/menus/builtinMenus.ts b/editor/src/menus/builtinMenus.tsindex 3b5272972..0157378a5 100644--- a/editor/src/menus/builtinMenus.ts+++ b/editor/src/menus/builtinMenus.ts@@ -1,6 +1,7 @@import { registerMenu, registerMenuItem } from './MenuRegistry';import type { Editor } from '../Editor';import { getEditorContext } from '../context/EditorContext';+import { showStatusBarMessage } from './builtinStatusbar';import type { Entity } from 'esengine';export function registerBuiltinMenus(editor: Editor): void {@@ -32,7 +33,13 @@ export function registerBuiltinMenus(editor: Editor): void {registerMenuItem({id: 'file.preview', menu: 'file', label: 'Preview',shortcut: 'F5', order: 4, separator: true,- action: () => editor.startPreview(),+ action: () => editor.togglePreview(),+ });+ registerMenuItem({+ id: 'file.stop-preview', menu: 'file', label: 'Stop Preview',+ shortcut: 'Shift+F5', order: 5,+ action: () => editor.stopPreview(),+ hidden: true,});registerMenuItem({id: 'file.build-settings', menu: 'file', label: 'Build Settings...',@@ -44,13 +51,32 @@ export function registerBuiltinMenus(editor: Editor): void {id: 'edit.undo', menu: 'edit', label: 'Undo',shortcut: 'Ctrl+Z', order: 0,enabled: () => editor.store.canUndo,- action: () => editor.store.undo(),+ action: () => {+ const desc = editor.store.undoDescription;+ editor.store.undo();+ if (desc) showStatusBarMessage(`Undo: ${desc}`);+ },});registerMenuItem({id: 'edit.redo', menu: 'edit', label: 'Redo',shortcut: 'Ctrl+Y', order: 1,enabled: () => editor.store.canRedo,- action: () => editor.store.redo(),+ action: () => {+ const desc = editor.store.redoDescription;+ editor.store.redo();+ if (desc) showStatusBarMessage(`Redo: ${desc}`);+ },+ });+ registerMenuItem({+ id: 'edit.redo-alt', menu: 'edit', label: 'Redo (Alt)',+ shortcut: 'Ctrl+Shift+Z', order: 1,+ enabled: () => editor.store.canRedo,+ action: () => {+ const desc = editor.store.redoDescription;+ editor.store.redo();+ if (desc) showStatusBarMessage(`Redo: ${desc}`);+ },+ hidden: true,});registerMenuItem({id: 'edit.delete', menu: 'edit', label: 'Delete',diff --git a/editor/src/menus/builtinStatusbar.ts b/editor/src/menus/builtinStatusbar.tsindex 9a5663fbb..7d9aac920 100644--- a/editor/src/menus/builtinStatusbar.ts+++ b/editor/src/menus/builtinStatusbar.ts@@ -3,6 +3,19 @@ import { getPanelsByPosition } from '../panels/PanelRegistry';import { icons } from '../utils/icons';import type { Editor } from '../Editor';+let statusMessageTimer_: ReturnType<typeof setTimeout> | null = null;+let statusMessageEl_: HTMLElement | null = null;++export function showStatusBarMessage(text: string, durationMs = 2000): void {+ if (!statusMessageEl_) return;+ statusMessageEl_.textContent = text;+ statusMessageEl_.style.display = '';+ if (statusMessageTimer_) clearTimeout(statusMessageTimer_);+ statusMessageTimer_ = setTimeout(() => {+ if (statusMessageEl_) statusMessageEl_.style.display = 'none';+ }, durationMs);+}+export function registerBuiltinStatusbarItems(editor: Editor): void {const bottomPanels = getPanelsByPosition('bottom');@@ -65,20 +78,61 @@ export function registerBuiltinStatusbarItems(editor: Editor): void {},});+ registerStatusbarItem({+ id: 'status-message',+ position: 'right',+ order: -10,+ render: (container) => {+ const el = document.createElement('span');+ el.className = 'es-statusbar-message';+ el.style.display = 'none';+ container.appendChild(el);+ statusMessageEl_ = el;+ return { dispose() { el.remove(); statusMessageEl_ = null; } };+ },+ });+registerStatusbarItem({id: 'undo',position: 'right',order: 0,render: (container) => {- const btn = document.createElement('button');- btn.className = 'es-statusbar-btn';- btn.dataset.action = 'undo';- btn.title = 'Undo';- btn.innerHTML = '<span>Undo</span>';- btn.addEventListener('click', () => editor.store.undo());- container.appendChild(btn);-- return { dispose() { btn.remove(); } };+ const wrapper = document.createElement('div');+ wrapper.className = 'es-statusbar-icons';++ const undoBtn = document.createElement('button');+ undoBtn.title = 'Undo';+ undoBtn.innerHTML = '<span>Undo</span>';+ undoBtn.addEventListener('click', () => {+ const desc = editor.store.undoDescription;+ editor.store.undo();+ if (desc) showStatusBarMessage(`Undo: ${desc}`);+ });++ const redoBtn = document.createElement('button');+ redoBtn.title = 'Redo';+ redoBtn.innerHTML = '<span>Redo</span>';+ redoBtn.addEventListener('click', () => {+ const desc = editor.store.redoDescription;+ editor.store.redo();+ if (desc) showStatusBarMessage(`Redo: ${desc}`);+ });++ wrapper.appendChild(undoBtn);+ wrapper.appendChild(redoBtn);+ container.appendChild(wrapper);++ return {+ dispose() { wrapper.remove(); },+ update() {+ const undoDesc = editor.store.undoDescription;+ const redoDesc = editor.store.redoDescription;+ undoBtn.title = undoDesc ? `Undo: ${undoDesc}` : 'Undo';+ redoBtn.title = redoDesc ? `Redo: ${redoDesc}` : 'Redo';+ undoBtn.disabled = !editor.store.canUndo;+ redoBtn.disabled = !editor.store.canRedo;+ },+ };},});@@ -89,11 +143,19 @@ export function registerBuiltinStatusbarItems(editor: Editor): void {render: (container) => {const wrapper = document.createElement('div');wrapper.className = 'es-statusbar-icons';- wrapper.innerHTML = `- <button title="Notifications">${icons.list(12)}</button>- <button title="Extensions">${icons.grid(12)}</button>- <button title="Settings">${icons.settings(12)}</button>- `;++ const notifBtn = document.createElement('button');+ notifBtn.title = 'Notifications';+ notifBtn.innerHTML = icons.list(12);+ notifBtn.addEventListener('click', () => editor.toggleBottomPanel('output'));++ const settingsBtn = document.createElement('button');+ settingsBtn.title = 'Settings';+ settingsBtn.innerHTML = icons.settings(12);+ settingsBtn.addEventListener('click', () => editor.showSettings());++ wrapper.appendChild(notifBtn);+ wrapper.appendChild(settingsBtn);container.appendChild(wrapper);return { dispose() { wrapper.remove(); } };@@ -110,20 +172,23 @@ export function registerBuiltinStatusbarItems(editor: Editor): void {${icons.check(12)}<span>All Saved</span></span>- <div class="es-statusbar-divider"></div>- <span class="es-status-indicator">- <span>Version Control</span>+ <span class="es-status-indicator es-status-unsaved" style="display: none;">+ <span class="es-unsaved-dot"></span>+ <span>Unsaved Changes</span></span>`;return {dispose() { container.innerHTML = ''; },update() {- const saved = container.querySelector('.es-status-saved');+ const saved = container.querySelector('.es-status-saved') as HTMLElement;+ const unsaved = container.querySelector('.es-status-unsaved') as HTMLElement;if (editor.store.isDirty) {- saved?.classList.add('es-hidden');+ if (saved) saved.style.display = 'none';+ if (unsaved) unsaved.style.display = '';} else {- saved?.classList.remove('es-hidden');+ if (saved) saved.style.display = '';+ if (unsaved) unsaved.style.display = 'none';}},};diff --git a/editor/src/panels/AddComponentPopup.ts b/editor/src/panels/AddComponentPopup.tsindex 07b140cde..f1601baa0 100644--- a/editor/src/panels/AddComponentPopup.ts+++ b/editor/src/panels/AddComponentPopup.ts@@ -33,6 +33,7 @@ export class AddComponentPopup {private options_: AddComponentPopupOptions;private searchInput_: HTMLInputElement | null = null;private listContainer_: HTMLElement | null = null;+ private highlightIndex_: number = -1;private categoryStates_: Map<ComponentCategory, CategoryState> = new Map([['builtin', { expanded: true }],['ui', { expanded: true }],@@ -70,9 +71,21 @@ export class AddComponentPopup {this.renderList();}+ private highlightName(name: string, filter: string): string {+ if (!filter) return name;+ const idx = name.toLowerCase().indexOf(filter.toLowerCase());+ if (idx < 0) return name;+ const before = name.substring(0, idx);+ const match = name.substring(idx, idx + filter.length);+ const after = name.substring(idx + filter.length);+ return `${before}<mark>${match}</mark>${after}`;+ }+private renderList(filter: string = ''): void {if (!this.listContainer_) return;+ this.highlightIndex_ = -1;+const components = getComponentsByCategory();const filterLower = filter.toLowerCase();const existing = new Set(this.options_.existingComponents);@@ -107,10 +120,11 @@ export class AddComponentPopup {`;for (const schema of filtered) {+ const displayName = this.highlightName(schema.name, filter);categoryHtml += `<div class="es-component-item" data-component="${schema.name}"><span class="es-component-icon">${iconFn()}</span>- <span class="es-component-name">${schema.name}</span>+ <span class="es-component-name">${displayName}</span></div>`;}@@ -171,9 +185,54 @@ export class AddComponentPopup {setTimeout(() => this.searchInput_?.focus(), 0);}+ private getVisibleItems(): HTMLElement[] {+ if (!this.listContainer_) return [];+ return Array.from(+ this.listContainer_.querySelectorAll('.es-category-items:not(.es-hidden) > .es-component-item')+ );+ }++ private updateHighlight(): void {+ const items = this.getVisibleItems();+ for (const el of items) {+ el.classList.remove('es-highlighted');+ }+ if (this.highlightIndex_ >= 0 && this.highlightIndex_ < items.length) {+ items[this.highlightIndex_].classList.add('es-highlighted');+ items[this.highlightIndex_].scrollIntoView({ block: 'nearest' });+ }+ }+private handleKeyDown = (e: KeyboardEvent): void => {if (e.key === 'Escape') {this.options_.onClose();+ return;+ }++ const items = this.getVisibleItems();+ if (items.length === 0) return;++ if (e.key === 'ArrowDown') {+ e.preventDefault();+ this.highlightIndex_ = this.highlightIndex_ < items.length - 1+ ? this.highlightIndex_ + 1+ : 0;+ this.updateHighlight();+ } else if (e.key === 'ArrowUp') {+ e.preventDefault();+ this.highlightIndex_ = this.highlightIndex_ > 0+ ? this.highlightIndex_ - 1+ : items.length - 1;+ this.updateHighlight();+ } else if (e.key === 'Enter') {+ e.preventDefault();+ if (this.highlightIndex_ >= 0 && this.highlightIndex_ < items.length) {+ const name = items[this.highlightIndex_].dataset.component;+ if (name) {+ this.options_.onSelect(name);+ this.options_.onClose();+ }+ }}};diff --git a/editor/src/panels/ContentBrowserPanel.ts b/editor/src/panels/ContentBrowserPanel.tsindex 3c8257164..d8ddc3e79 100644--- a/editor/src/panels/ContentBrowserPanel.ts+++ b/editor/src/panels/ContentBrowserPanel.ts@@ -40,13 +40,22 @@ interface AssetItem {name: string;path: string;type: 'folder' | 'scene' | 'script' | 'image' | 'audio' | 'json' | 'material' | 'shader' | 'spine' | 'font' | 'prefab' | 'file';+ relativePath?: string;}+type ViewMode = 'grid' | 'list';+export interface ContentBrowserOptions {projectPath?: string;onOpenScene?: (scenePath: string) => void;}+const THUMBNAIL_CACHE_MAX = 200;+const THUMBNAIL_SIZE = 48;+const IMAGE_EXTENSIONS = new Set(['.png', '.jpg', '.jpeg', '.webp', '.gif', '.bmp']);+const SEARCH_RESULTS_LIMIT = 100;+const VIEW_MODE_KEY = 'esengine.editor.contentBrowserView';+// =============================================================================// Helpers// =============================================================================@@ -116,6 +125,79 @@ function getAssetIcon(type: AssetItem['type'], size: number = 32): string {}}+function isImageFile(name: string): boolean {+ return IMAGE_EXTENSIONS.has(getFileExtension(name));+}++// =============================================================================+// ThumbnailCache+// =============================================================================++class ThumbnailCache {+ private cache_ = new Map<string, string>();+ private loading_ = new Set<string>();++ get(path: string): string | undefined {+ return this.cache_.get(path);+ }++ isLoading(path: string): boolean {+ return this.loading_.has(path);+ }++ async load(path: string, onLoaded: () => void): Promise<void> {+ if (this.cache_.has(path) || this.loading_.has(path)) return;++ this.loading_.add(path);++ try {+ const fs = getNativeFS();+ if (!fs) return;++ const data = await fs.readBinaryFile(path);+ if (!data) return;++ const blob = new Blob([data.buffer as ArrayBuffer]);+ const url = URL.createObjectURL(blob);++ const img = new Image();+ await new Promise<void>((resolve, reject) => {+ img.onload = () => resolve();+ img.onerror = () => reject();+ img.src = url;+ });++ const canvas = document.createElement('canvas');+ canvas.width = THUMBNAIL_SIZE;+ canvas.height = THUMBNAIL_SIZE;+ const ctx = canvas.getContext('2d')!;++ const scale = Math.min(THUMBNAIL_SIZE / img.width, THUMBNAIL_SIZE / img.height);+ const w = img.width * scale;+ const h = img.height * scale;+ const x = (THUMBNAIL_SIZE - w) / 2;+ const y = (THUMBNAIL_SIZE - h) / 2;++ ctx.drawImage(img, x, y, w, h);++ const dataUrl = canvas.toDataURL('image/png');+ URL.revokeObjectURL(url);++ if (this.cache_.size >= THUMBNAIL_CACHE_MAX) {+ const firstKey = this.cache_.keys().next().value;+ if (firstKey) this.cache_.delete(firstKey);+ }++ this.cache_.set(path, dataUrl);+ onLoaded();+ } catch {+ // ignore load failures+ } finally {+ this.loading_.delete(path);+ }+ }+}+// =============================================================================// ContentBrowserPanel// =============================================================================@@ -137,14 +219,19 @@ export class ContentBrowserPanel {private refreshing_ = false;private refreshPending_ = false;private currentItems_: AssetItem[] = [];+ private filteredItems_: AssetItem[] = [];private onOpenScene_: ((scenePath: string) => void) | null = null;- private selectedAssetPath_: string | null = null;+ private selectedPaths_ = new Set<string>();+ private lastSelectedPath_: string | null = null;+ private thumbnailCache_ = new ThumbnailCache();+ private viewMode_: ViewMode;constructor(container: HTMLElement, store: EditorStore, options?: ContentBrowserOptions) {this.container_ = container;this.store_ = store;this.projectPath_ = options?.projectPath ?? null;this.onOpenScene_ = options?.onOpenScene ?? null;+ this.viewMode_ = (localStorage.getItem(VIEW_MODE_KEY) as ViewMode) || 'grid';if (this.projectPath_) {this.currentPath_ = getParentDir(this.projectPath_);@@ -162,10 +249,12 @@ export class ContentBrowserPanel {<div class="es-content-browser-tree"></div><div class="es-content-browser-main"><div class="es-content-browser-toolbar">+ <button class="es-btn es-btn-icon es-cb-up-btn" title="Parent folder">${icons.arrowUp(14)}</button><div class="es-content-breadcrumb"></div><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"></div>+ <div class="es-content-browser-grid" tabindex="0"></div></div></div><div class="es-content-browser-footer">0 items</div>@@ -177,6 +266,7 @@ export class ContentBrowserPanel {this.searchInput_ = this.container_.querySelector('.es-content-search');this.breadcrumbContainer_ = this.container_.querySelector('.es-content-breadcrumb');+ this.updateViewToggleButton();this.setupEvents();this.initialize();}@@ -225,7 +315,9 @@ export class ContentBrowserPanel {this.currentPath_ = targetFolderPath;const fullAssetPath = joinPath(projectDir, normalized);- this.selectedAssetPath_ = fullAssetPath;+ this.selectedPaths_.clear();+ this.selectedPaths_.add(fullAssetPath);+ this.lastSelectedPath_ = fullAssetPath;this.renderTree();await this.renderGrid();@@ -364,6 +456,13 @@ export class ContentBrowserPanel {};}+ private updateViewToggleButton(): void {+ const btn = this.container_.querySelector('.es-cb-view-toggle');+ if (!btn) return;+ btn.innerHTML = this.viewMode_ === 'grid' ? icons.layoutList(14) : icons.layoutGrid(14);+ btn.setAttribute('title', this.viewMode_ === 'grid' ? 'Switch to list view' : 'Switch to grid view');+ }+private setupEvents(): void {this.searchInput_?.addEventListener('input', () => {this.searchFilter_ = this.searchInput_?.value.toLowerCase() ?? '';@@ -381,6 +480,19 @@ export class ContentBrowserPanel {}});+ const upBtn = this.container_.querySelector('.es-cb-up-btn');+ upBtn?.addEventListener('click', () => {+ this.navigateToParent();+ });++ const viewToggle = this.container_.querySelector('.es-cb-view-toggle');+ viewToggle?.addEventListener('click', () => {+ this.viewMode_ = this.viewMode_ === 'grid' ? 'list' : 'grid';+ localStorage.setItem(VIEW_MODE_KEY, this.viewMode_);+ this.updateViewToggleButton();+ this.renderGrid();+ });+this.treeContainer_?.addEventListener('click', async (e) => {const target = e.target as HTMLElement;const item = target.closest('.es-folder-item') as HTMLElement;@@ -398,18 +510,40 @@ export class ContentBrowserPanel {this.gridContainer_?.addEventListener('click', (e) => {const target = e.target as HTMLElement;- const item = target.closest('.es-asset-item') as HTMLElement;- if (!item) return;+ const item = (target.closest('.es-asset-item') || target.closest('.es-cb-list-row')) as HTMLElement;++ if (!item) {+ this.selectedPaths_.clear();+ this.lastSelectedPath_ = null;+ this.updateAssetSelection();+ return;+ }const path = item.dataset.path;- if (path) {- this.selectAsset(path);+ if (!path) return;++ if (e.shiftKey && this.lastSelectedPath_) {+ this.rangeSelect(this.lastSelectedPath_, path);+ } else if (e.ctrlKey || e.metaKey) {+ if (this.selectedPaths_.has(path)) {+ this.selectedPaths_.delete(path);+ } else {+ this.selectedPaths_.add(path);+ }+ this.lastSelectedPath_ = path;+ } else {+ this.selectedPaths_.clear();+ this.selectedPaths_.add(path);+ this.lastSelectedPath_ = path;}++ this.updateAssetSelection();+ this.notifyStoreSelection();});this.gridContainer_?.addEventListener('dblclick', async (e) => {const target = e.target as HTMLElement;- const item = target.closest('.es-asset-item') as HTMLElement;+ const item = (target.closest('.es-asset-item') || target.closest('.es-cb-list-row')) as HTMLElement;if (!item) return;const path = item.dataset.path;@@ -431,13 +565,24 @@ export class ContentBrowserPanel {this.gridContainer_?.addEventListener('contextmenu', (e) => {e.preventDefault();const target = e.target as HTMLElement;- const item = target.closest('.es-asset-item') as HTMLElement;+ const item = (target.closest('.es-asset-item') || target.closest('.es-cb-list-row')) as HTMLElement;if (item) {const path = item.dataset.path;const type = item.dataset.type;if (path) {- this.showAssetContextMenu(e, path, type as AssetItem['type']);+ if (!this.selectedPaths_.has(path)) {+ this.selectedPaths_.clear();+ this.selectedPaths_.add(path);+ this.lastSelectedPath_ = path;+ this.updateAssetSelection();+ }++ if (this.selectedPaths_.size > 1) {+ this.showMultiSelectContextMenu(e);+ } else {+ this.showAssetContextMenu(e, path, type as AssetItem['type']);+ }}} else {this.showFolderContextMenu(e, this.currentPath_);@@ -456,21 +601,26 @@ export class ContentBrowserPanel {this.gridContainer_?.addEventListener('dragstart', (e) => {const target = e.target as HTMLElement;- const item = target.closest('.es-asset-item') as HTMLElement;+ const item = (target.closest('.es-asset-item') || target.closest('.es-cb-list-row')) as HTMLElement;if (!item) return;const path = item.dataset.path;const type = item.dataset.type;if (!path || !type) return;- const assetData = this.currentItems_.find(i => i.path === path);- if (!assetData) return;+ if (!this.selectedPaths_.has(path)) {+ this.selectedPaths_.clear();+ this.selectedPaths_.add(path);+ this.lastSelectedPath_ = path;+ this.updateAssetSelection();+ }++ const dragItems = this.filteredItems_.filter(i => this.selectedPaths_.has(i.path));+ const payload = dragItems.map(i => ({ type: i.type, path: i.path, name: i.name }));- e.dataTransfer?.setData('application/esengine-asset', JSON.stringify({- type: type,- path: path,- name: assetData.name,- }));+ e.dataTransfer?.setData('application/esengine-asset', JSON.stringify(+ payload.length === 1 ? payload[0] : payload+ ));e.dataTransfer!.effectAllowed = 'copy';item.classList.add('es-dragging');@@ -478,7 +628,7 @@ export class ContentBrowserPanel {this.gridContainer_?.addEventListener('dragend', (e) => {const target = e.target as HTMLElement;- const item = target.closest('.es-asset-item') as HTMLElement;+ const item = (target.closest('.es-asset-item') || target.closest('.es-cb-list-row')) as HTMLElement;item?.classList.remove('es-dragging');});@@ -515,6 +665,187 @@ export class ContentBrowserPanel {this.saveDroppedEntityAsPrefab(entityId);});++ this.gridContainer_?.addEventListener('keydown', (e) => {+ this.handleKeyboardNavigation(e);+ });+ }++ private navigateToParent(): void {+ if (!this.rootFolder_) return;+ if (this.currentPath_ === this.rootFolder_.path) return;++ const parentPath = getParentDir(this.currentPath_);+ if (parentPath) {+ this.selectFolder(parentPath);+ }+ }++ private rangeSelect(fromPath: string, toPath: string): void {+ const fromIndex = this.filteredItems_.findIndex(i => i.path === fromPath);+ const toIndex = this.filteredItems_.findIndex(i => i.path === toPath);+ if (fromIndex < 0 || toIndex < 0) return;++ const start = Math.min(fromIndex, toIndex);+ const end = Math.max(fromIndex, toIndex);++ this.selectedPaths_.clear();+ for (let i = start; i <= end; i++) {+ this.selectedPaths_.add(this.filteredItems_[i].path);+ }+ }++ private notifyStoreSelection(): void {+ if (this.selectedPaths_.size === 1) {+ const path = this.selectedPaths_.values().next().value!;+ const item = this.filteredItems_.find(i => i.path === path);+ if (item) {+ this.store_.selectAsset({+ path: item.path,+ type: item.type as AssetType,+ name: item.name,+ });+ }+ }+ }++ private handleKeyboardNavigation(e: KeyboardEvent): void {+ if (!this.gridContainer_ || this.filteredItems_.length === 0) return;++ const isGrid = this.viewMode_ === 'grid';++ switch (e.key) {+ case 'ArrowRight':+ case 'ArrowLeft':+ case 'ArrowDown':+ case 'ArrowUp': {+ e.preventDefault();+ const currentIndex = this.lastSelectedPath_+ ? this.filteredItems_.findIndex(i => i.path === this.lastSelectedPath_)+ : -1;++ let cols = 1;+ if (isGrid) {+ const containerWidth = this.gridContainer_.clientWidth - 24;+ cols = Math.max(1, Math.floor(containerWidth / 80));+ }++ let nextIndex = currentIndex;+ if (e.key === 'ArrowRight') nextIndex = currentIndex + 1;+ else if (e.key === 'ArrowLeft') nextIndex = currentIndex - 1;+ else if (e.key === 'ArrowDown') nextIndex = currentIndex + cols;+ else if (e.key === 'ArrowUp') nextIndex = currentIndex - cols;++ if (nextIndex >= 0 && nextIndex < this.filteredItems_.length) {+ this.selectedPaths_.clear();+ this.selectedPaths_.add(this.filteredItems_[nextIndex].path);+ this.lastSelectedPath_ = this.filteredItems_[nextIndex].path;+ this.updateAssetSelection();+ this.notifyStoreSelection();++ const el = this.gridContainer_.children[nextIndex] as HTMLElement;+ el?.scrollIntoView({ block: 'nearest' });+ }+ break;+ }+ case 'Enter': {+ e.preventDefault();+ if (this.selectedPaths_.size !== 1) return;+ const path = this.selectedPaths_.values().next().value!;+ const item = this.filteredItems_.find(i => i.path === path);+ if (!item) return;++ if (item.type === 'folder') {+ this.selectFolder(item.path);+ this.expandFolder(item.path);+ } else {+ this.onAssetDoubleClick(item.path, item.type);+ }+ break;+ }+ case 'Delete':+ case 'Backspace': {+ e.preventDefault();+ if (this.selectedPaths_.size === 0) return;+ this.deleteSelectedAssets();+ break;+ }+ case 'F2': {+ e.preventDefault();+ if (this.selectedPaths_.size !== 1) return;+ const path = this.selectedPaths_.values().next().value!;+ const item = this.filteredItems_.find(i => i.path === path);+ if (item) {+ this.renameAsset(item.path, item.type);+ }+ break;+ }+ case 'a': {+ if (e.ctrlKey || e.metaKey) {+ e.preventDefault();+ this.selectedPaths_.clear();+ for (const item of this.filteredItems_) {+ this.selectedPaths_.add(item.path);+ }+ this.updateAssetSelection();+ }+ break;+ }+ }+ }++ private async deleteSelectedAssets(): Promise<void> {+ const paths = Array.from(this.selectedPaths_);+ const names = paths.map(p => p.split('/').pop() ?? p);+ const message = paths.length === 1+ ? `Are you sure you want to delete "${names[0]}"?`+ : `Are you sure you want to delete ${paths.length} items?`;++ const confirmed = await showConfirmDialog({+ title: 'Delete Assets',+ message,+ confirmText: 'Delete',+ danger: true,+ });++ if (!confirmed) return;++ const platform = getPlatformAdapter();+ for (const path of paths) {+ try {+ await platform.remove(path);+ const metaPath = `${path}.meta`;+ try { await platform.remove(metaPath); } catch { /* no .meta file */ }++ if (this.rootFolder_) {+ const projectDir = this.rootFolder_.path;+ const prefix = projectDir.endsWith('/') ? projectDir : projectDir + '/';+ if (path.startsWith(prefix)) {+ getAssetLibrary().unregister(path.substring(prefix.length));+ }+ }+ } catch (err) {+ console.error('Failed to delete asset:', err);+ showErrorToast('Failed to delete asset', String(err));+ }+ }++ this.selectedPaths_.clear();+ this.lastSelectedPath_ = null;+ this.refresh();+ }++ private showMultiSelectContextMenu(e: MouseEvent): void {+ const count = this.selectedPaths_.size;+ const items: ContextMenuItem[] = [+ {+ label: `Delete ${count} items`,+ icon: icons.trash(14),+ onClick: () => this.deleteSelectedAssets(),+ },+ ];++ showContextMenu({ x: e.clientX, y: e.clientY, items });}private showAssetContextMenu(e: MouseEvent, path: string, type: AssetItem['type']): void {@@ -925,26 +1256,21 @@ void main() {}private selectAsset(path: string): void {- this.selectedAssetPath_ = path;+ this.selectedPaths_.clear();+ this.selectedPaths_.add(path);+ this.lastSelectedPath_ = path;this.updateAssetSelection();-- const item = this.currentItems_.find(i => i.path === path);- if (item) {- this.store_.selectAsset({- path: item.path,- type: item.type as AssetType,- name: item.name,- });- }+ this.notifyStoreSelection();}private updateAssetSelection(): void {if (!this.gridContainer_) return;- const items = this.gridContainer_.querySelectorAll('.es-asset-item');+ const selector = this.viewMode_ === 'list' ? '.es-cb-list-row' : '.es-asset-item';+ const items = this.gridContainer_.querySelectorAll(selector);items.forEach((item) => {const el = item as HTMLElement;- if (el.dataset.path === this.selectedAssetPath_) {+ if (this.selectedPaths_.has(el.dataset.path ?? '')) {el.classList.add('es-selected');} else {el.classList.remove('es-selected');@@ -1006,6 +1332,8 @@ void main() {private selectFolder(path: string): void {this.currentPath_ = path;+ this.selectedPaths_.clear();+ this.lastSelectedPath_ = null;this.renderTree();this.renderBreadcrumb();this.renderGrid();@@ -1089,35 +1417,186 @@ void main() {private async renderGrid(): Promise<void> {if (!this.gridContainer_) return;- const items = await this.loadCurrentFolderItems();+ let items: AssetItem[];+ if (this.searchFilter_) {+ items = await this.searchRecursive(this.currentPath_, this.searchFilter_);+ } else {+ items = await this.loadCurrentFolderItems();+ }this.currentItems_ = items;let filteredItems = items;if (this.searchFilter_) {- filteredItems = items.filter((item) =>- item.name.toLowerCase().includes(this.searchFilter_)- );+ filteredItems = items.slice(0, SEARCH_RESULTS_LIMIT);+ }+ this.filteredItems_ = filteredItems;++ if (filteredItems.length === 0) {+ this.gridContainer_.innerHTML = this.renderEmptyState();+ this.gridContainer_.classList.remove('es-cb-list-view');+ if (this.footerContainer_) {+ this.footerContainer_.textContent = '0 items';+ }+ return;}const isDraggable = (type: AssetItem['type']) => type !== 'folder';- this.gridContainer_.innerHTML = filteredItems- .map(- (item) => `- <div class="es-asset-item${item.path === this.selectedAssetPath_ ? ' es-selected' : ''}"- data-path="${item.path}"- data-type="${item.type}"- ${isDraggable(item.type) ? 'draggable="true"' : ''}>- <div class="es-asset-icon">${getAssetIcon(item.type)}</div>- <div class="es-asset-name">${item.name}</div>- </div>- `- )- .join('');+ if (this.viewMode_ === 'list') {+ this.gridContainer_.classList.add('es-cb-list-view');+ this.gridContainer_.innerHTML = filteredItems+ .map((item) => {+ const iconHtml = this.getItemIconHtml(item, 24);+ const subtext = item.relativePath+ ? `<span class="es-cb-list-subpath">${item.relativePath}</span>`+ : '';+ return `+ <div class="es-cb-list-row${this.selectedPaths_.has(item.path) ? ' es-selected' : ''}"+ data-path="${item.path}"+ data-type="${item.type}"+ ${isDraggable(item.type) ? 'draggable="true"' : ''}>+ <span class="es-cb-list-icon">${iconHtml}</span>+ <span class="es-cb-list-name">${item.name}${subtext}</span>+ <span class="es-cb-list-type">${item.type}</span>+ </div>`;+ })+ .join('');+ } else {+ this.gridContainer_.classList.remove('es-cb-list-view');+ this.gridContainer_.innerHTML = filteredItems+ .map((item) => {+ const iconHtml = this.getItemIconHtml(item, 32);+ const subtext = item.relativePath+ ? `<div class="es-asset-subpath">${item.relativePath}</div>`+ : '';+ return `+ <div class="es-asset-item${this.selectedPaths_.has(item.path) ? ' es-selected' : ''}"+ data-path="${item.path}"+ data-type="${item.type}"+ ${isDraggable(item.type) ? 'draggable="true"' : ''}>+ <div class="es-asset-icon">${iconHtml}</div>+ <div class="es-asset-name">${item.name}</div>+ ${subtext}+ </div>`;+ })+ .join('');+ }++ for (const item of filteredItems) {+ if (item.type === 'image' && isImageFile(item.name)) {+ this.loadThumbnailFor(item.path);+ }+ }if (this.footerContainer_) {- this.footerContainer_.textContent = `${filteredItems.length} items`;+ const suffix = this.searchFilter_ && items.length > SEARCH_RESULTS_LIMIT+ ? ` (showing ${SEARCH_RESULTS_LIMIT} of ${items.length})`+ : '';+ this.footerContainer_.textContent = `${filteredItems.length} items${suffix}`;+ }+ }++ private getItemIconHtml(item: AssetItem, size: number): string {+ if (item.type === 'image' && isImageFile(item.name)) {+ const cached = this.thumbnailCache_.get(item.path);+ if (cached) {+ return `<img src="${cached}" width="${size}" height="${size}" class="es-cb-thumbnail" alt="">`;+ }+ if (this.thumbnailCache_.isLoading(item.path)) {+ return `<span class="es-cb-thumb-loading">${getAssetIcon(item.type, size)}</span>`;+ }}+ return getAssetIcon(item.type, size);+ }++ private loadThumbnailFor(path: string): void {+ this.thumbnailCache_.load(path, () => {+ this.updateThumbnailInDom(path);+ });+ }++ private updateThumbnailInDom(path: string): void {+ if (!this.gridContainer_) return;+ const dataUrl = this.thumbnailCache_.get(path);+ if (!dataUrl) return;++ const selector = this.viewMode_ === 'list' ? '.es-cb-list-row' : '.es-asset-item';+ const items = this.gridContainer_.querySelectorAll(selector);+ for (const el of items) {+ const htmlEl = el as HTMLElement;+ if (htmlEl.dataset.path !== path) continue;++ const iconContainer = this.viewMode_ === 'list'+ ? htmlEl.querySelector('.es-cb-list-icon')+ : htmlEl.querySelector('.es-asset-icon');+ if (iconContainer) {+ const size = this.viewMode_ === 'list' ? 24 : 32;+ iconContainer.innerHTML = `<img src="${dataUrl}" width="${size}" height="${size}" class="es-cb-thumbnail" alt="">`;+ }+ break;+ }+ }++ private renderEmptyState(): string {+ if (this.searchFilter_) {+ return `<div class="es-cb-empty-state">+ <div class="es-cb-empty-icon">${icons.search(32)}</div>+ <div class="es-cb-empty-text">No matching assets found</div>+ </div>`;+ }+ return `<div class="es-cb-empty-state">+ <div class="es-cb-empty-icon">${icons.folder(32)}</div>+ <div class="es-cb-empty-text">This folder is empty</div>+ </div>`;+ }++ private async searchRecursive(basePath: string, filter: string): Promise<AssetItem[]> {+ const fs = getNativeFS();+ if (!fs || !basePath) return [];++ const results: AssetItem[] = [];+ const stack = [basePath];++ while (stack.length > 0 && results.length < SEARCH_RESULTS_LIMIT * 2) {+ const dir = stack.pop()!;+ try {+ const entries = await fs.listDirectoryDetailed(dir);+ for (const entry of entries) {+ if (entry.name.startsWith('.') || entry.name.endsWith('.meta')) continue;++ const entryPath = joinPath(dir, entry.name);++ if (entry.isDirectory) {+ stack.push(entryPath);+ if (entry.name.toLowerCase().includes(filter)) {+ const relative = entryPath.substring(basePath.length).replace(/^\//, '');+ results.push({+ name: entry.name,+ path: entryPath,+ type: 'folder',+ relativePath: relative,+ });+ }+ } 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 {+ // skip inaccessible directories+ }+ }++ 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);+ });}private async loadCurrentFolderItems(): Promise<AssetItem[]> {diff --git a/editor/src/panels/HierarchyPanel.ts b/editor/src/panels/HierarchyPanel.tsindex 23e6c1ae8..533d47b3e 100644--- a/editor/src/panels/HierarchyPanel.ts+++ b/editor/src/panels/HierarchyPanel.ts@@ -5,7 +5,7 @@import type { Entity } from 'esengine';import type { EntityData } from '../types/SceneTypes';-import type { EditorStore } from '../store/EditorStore';+import type { EditorStore, DirtyFlag } from '../store/EditorStore';import { icons } from '../utils/icons';import { getGlobalPathResolver } from '../asset';import { getInitialComponentData } from '../schemas/ComponentSchemas';@@ -24,6 +24,8 @@ type DropPosition = 'before' | 'after' | 'inside';const ROW_HEIGHT = 22;const OVERSCAN = 5;+const SLOW_DOUBLE_CLICK_MIN = 300;+const SLOW_DOUBLE_CLICK_MAX = 800;interface FlattenedRow {entity: EntityData;@@ -59,7 +61,9 @@ export class HierarchyPanel {private dropPosition_: DropPosition | null = null;private draggingEntityId_: number | null = null;private boundOnScroll_: (() => void) | null = null;-+ private renamingEntityId_: number | null = null;+ private lastClickEntityId_: number | null = null;+ private lastClickTime_: number = 0;constructor(container: HTMLElement, store: EditorStore) {this.container_ = container;this.store_ = store;@@ -68,10 +72,6 @@ export class HierarchyPanel {this.container_.innerHTML = `<div class="es-panel-header"><span class="es-panel-title">${icons.list(14)} Hierarchy</span>- <div class="es-panel-actions">- <button class="es-btn es-btn-icon" title="Minimize">${icons.chevronDown(12)}</button>- <button class="es-btn es-btn-icon" title="Close">${icons.x(12)}</button>- </div></div><div class="es-prefab-edit-bar" style="display: none;"><button class="es-prefab-back-btn">${icons.chevronRight(12)} Back to Scene</button>@@ -80,8 +80,7 @@ export class HierarchyPanel {<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="add" title="Create Entity">${icons.plus()}</button>- <button class="es-btn es-btn-icon" title="Duplicate">${icons.copy()}</button>- <button class="es-btn es-btn-icon" title="Settings">${icons.settings()}</button>+ <button class="es-btn es-btn-icon" data-action="duplicate" title="Duplicate">${icons.copy()}</button></div><div class="es-hierarchy-columns"><span class="es-hierarchy-col-visibility">${icons.eye(12)}</span>@@ -94,6 +93,7 @@ export class HierarchyPanel {`;this.treeContainer_ = this.container_.querySelector('.es-hierarchy-tree')!;+ this.treeContainer_.tabIndex = 0;this.scrollContent_ = document.createElement('div');this.scrollContent_.className = 'es-hierarchy-scroll-content';this.visibleWindow_ = document.createElement('div');@@ -112,7 +112,7 @@ export class HierarchyPanel {});this.setupEvents();- this.unsubscribe_ = store.subscribe(() => this.render());+ this.unsubscribe_ = store.subscribe((_state, dirtyFlags) => this.onStoreNotify(dirtyFlags));this.render();}@@ -131,6 +131,21 @@ export class HierarchyPanel {}}+ private onStoreNotify(dirtyFlags?: ReadonlySet<DirtyFlag>): void {+ if (dirtyFlags && !dirtyFlags.has('scene') && !dirtyFlags.has('hierarchy') && !dirtyFlags.has('selection')) {+ return;+ }++ const needsRebuild = !dirtyFlags || dirtyFlags.has('scene') || dirtyFlags.has('hierarchy');++ if (needsRebuild) {+ this.render();+ } else {+ this.renderVisibleRows();+ this.updateFooter();+ }+ }+private setupEvents(): void {const addBtn = this.container_.querySelector('[data-action="add"]');addBtn?.addEventListener('click', () => {@@ -138,6 +153,14 @@ export class HierarchyPanel {this.store_.addComponent(entity, 'LocalTransform', getInitialComponentData('LocalTransform'));});+ const dupBtn = this.container_.querySelector('[data-action="duplicate"]');+ dupBtn?.addEventListener('click', () => {+ const selected = this.store_.selectedEntity;+ if (selected !== null) {+ this.duplicateEntity(selected);+ }+ });+this.searchInput_?.addEventListener('input', () => {this.searchFilter_ = this.searchInput_?.value ?? '';this.performSearch();@@ -162,6 +185,8 @@ export class HierarchyPanel {this.treeContainer_.addEventListener('click', (e) => {const target = e.target as HTMLElement;+ if (target.closest('.es-hierarchy-rename-input')) return;+const visibilityBtn = target.closest('.es-hierarchy-visibility') as HTMLElement;if (visibilityBtn) {e.stopPropagation();@@ -197,25 +222,42 @@ export class HierarchyPanel {const entityId = parseInt(item.dataset.entityId ?? '', 10);if (isNaN(entityId)) return;+ const now = Date.now();+ const timeSinceLastClick = now - this.lastClickTime_;+ const sameEntity = this.lastClickEntityId_ === entityId;+ const wasSelected = this.store_.selectedEntities.has(entityId);+if (e.shiftKey && this.lastSelectedEntity_ !== null) {- this.store_.selectRange(this.lastSelectedEntity_ as number, entityId);+ this.selectRangeFromFlatRows(this.lastSelectedEntity_ as number, entityId);this.lastSelectedEntity_ = entityId as Entity;} else if (e.ctrlKey || e.metaKey) {this.store_.selectEntity(entityId as Entity, 'toggle');this.lastSelectedEntity_ = entityId as Entity;} else {- this.store_.selectEntity(entityId as Entity, 'replace');- this.lastSelectedEntity_ = entityId as Entity;+ if (sameEntity && wasSelected && !e.shiftKey && !e.ctrlKey && !e.metaKey+ && timeSinceLastClick >= SLOW_DOUBLE_CLICK_MIN+ && timeSinceLastClick <= SLOW_DOUBLE_CLICK_MAX) {+ this.startInlineRename(entityId);+ } else {+ this.store_.selectEntity(entityId as Entity, 'replace');+ this.lastSelectedEntity_ = entityId as Entity;+ }}++ this.lastClickEntityId_ = entityId;+ this.lastClickTime_ = now;});this.treeContainer_.addEventListener('dblclick', (e) => {const target = e.target as HTMLElement;+ if (target.closest('.es-hierarchy-rename-input')) return;const item = target.closest('.es-hierarchy-item') as HTMLElement;if (!item) return;const entityId = parseInt(item.dataset.entityId ?? '', 10);if (!isNaN(entityId)) {+ this.lastClickEntityId_ = null;+ this.lastClickTime_ = 0;this.store_.focusEntity(entityId);}});@@ -235,9 +277,186 @@ export class HierarchyPanel {}});+ this.treeContainer_.addEventListener('keydown', (e) => {+ if (this.renamingEntityId_ !== null) {+ return;+ }++ if (e.key === 'F2') {+ e.preventDefault();+ const selected = this.store_.selectedEntity;+ if (selected !== null) {+ this.startInlineRename(selected as number);+ }+ return;+ }++ if (e.key === 'Delete' || e.key === 'Backspace') {+ e.preventDefault();+ if (this.store_.selectedEntities.size > 1) {+ this.store_.deleteSelectedEntities();+ } else {+ const selected = this.store_.selectedEntity;+ if (selected !== null) {+ this.store_.deleteEntity(selected);+ }+ }+ return;+ }++ const selected = this.store_.selectedEntity;+ const selectedIndex = selected !== null+ ? this.flatRows_.findIndex(r => r.entity.id === (selected as number))+ : -1;++ switch (e.key) {+ case 'ArrowDown': {+ e.preventDefault();+ const nextIndex = selectedIndex + 1;+ if (nextIndex < this.flatRows_.length) {+ const nextEntity = this.flatRows_[nextIndex].entity;+ this.store_.selectEntity(nextEntity.id as Entity, 'replace');+ this.lastSelectedEntity_ = nextEntity.id as Entity;+ this.scrollToEntity(nextEntity.id);+ }+ break;+ }+ case 'ArrowUp': {+ e.preventDefault();+ const prevIndex = selectedIndex - 1;+ if (prevIndex >= 0) {+ const prevEntity = this.flatRows_[prevIndex].entity;+ this.store_.selectEntity(prevEntity.id as Entity, 'replace');+ this.lastSelectedEntity_ = prevEntity.id as Entity;+ this.scrollToEntity(prevEntity.id);+ }+ break;+ }+ case 'ArrowRight': {+ e.preventDefault();+ if (selectedIndex === -1) break;+ const row = this.flatRows_[selectedIndex];+ if (row.hasChildren && !row.isExpanded) {+ this.expandedIds_.add(row.entity.id);+ this.render();+ } else if (row.hasChildren && row.isExpanded) {+ const nextIndex = selectedIndex + 1;+ if (nextIndex < this.flatRows_.length) {+ const child = this.flatRows_[nextIndex].entity;+ this.store_.selectEntity(child.id as Entity, 'replace');+ this.lastSelectedEntity_ = child.id as Entity;+ this.scrollToEntity(child.id);+ }+ }+ break;+ }+ case 'ArrowLeft': {+ e.preventDefault();+ if (selectedIndex === -1) break;+ const row = this.flatRows_[selectedIndex];+ if (row.hasChildren && row.isExpanded) {+ this.expandedIds_.delete(row.entity.id);+ this.render();+ } else if (row.entity.parent !== null) {+ const parentIdx = this.flatRows_.findIndex(r => r.entity.id === row.entity.parent);+ if (parentIdx !== -1) {+ const parentEntity = this.flatRows_[parentIdx].entity;+ this.store_.selectEntity(parentEntity.id as Entity, 'replace');+ this.lastSelectedEntity_ = parentEntity.id as Entity;+ this.scrollToEntity(parentEntity.id);+ }+ }+ break;+ }+ case 'Home': {+ e.preventDefault();+ if (this.flatRows_.length > 0) {+ const first = this.flatRows_[0].entity;+ this.store_.selectEntity(first.id as Entity, 'replace');+ this.lastSelectedEntity_ = first.id as Entity;+ this.scrollToEntity(first.id);+ }+ break;+ }+ case 'End': {+ e.preventDefault();+ if (this.flatRows_.length > 0) {+ const last = this.flatRows_[this.flatRows_.length - 1].entity;+ this.store_.selectEntity(last.id as Entity, 'replace');+ this.lastSelectedEntity_ = last.id as Entity;+ this.scrollToEntity(last.id);+ }+ break;+ }+ }+ });+this.setupDragAndDrop();}+ private selectRangeFromFlatRows(fromEntity: number, toEntity: number): void {+ const fromIndex = this.flatRows_.findIndex(r => r.entity.id === fromEntity);+ const toIndex = this.flatRows_.findIndex(r => r.entity.id === toEntity);++ if (fromIndex === -1 || toIndex === -1) return;++ const start = Math.min(fromIndex, toIndex);+ const end = Math.max(fromIndex, toIndex);+ const ids = this.flatRows_.slice(start, end + 1).map(r => r.entity.id);+ this.store_.selectEntities(ids);+ }++ private startInlineRename(entityId: number): void {+ const entityData = this.store_.getEntityData(entityId);+ if (!entityData) return;++ this.renamingEntityId_ = entityId;++ const item = this.visibleWindow_.querySelector(`[data-entity-id="${entityId}"]`);+ if (!item) return;++ const nameSpan = item.querySelector('.es-hierarchy-name') as HTMLElement;+ if (!nameSpan) return;++ const input = document.createElement('input');+ input.type = 'text';+ input.className = 'es-hierarchy-rename-input';+ input.value = entityData.name;+ input.select();++ const commitRename = () => {+ const newName = input.value.trim();+ if (newName && newName !== entityData.name) {+ this.store_.renameEntity(entityId as Entity, newName);+ }+ this.renamingEntityId_ = null;+ this.renderVisibleRows();+ };++ const cancelRename = () => {+ this.renamingEntityId_ = null;+ this.renderVisibleRows();+ };++ input.addEventListener('keydown', (e) => {+ if (e.key === 'Enter') {+ e.preventDefault();+ commitRename();+ } else if (e.key === 'Escape') {+ e.preventDefault();+ cancelRename();+ }+ e.stopPropagation();+ });++ input.addEventListener('blur', commitRename, { once: true });++ nameSpan.textContent = '';+ nameSpan.appendChild(input);+ input.focus();+ input.select();+ }+private setupDragAndDrop(): void {this.treeContainer_.addEventListener('dragstart', (e) => {const target = e.target as HTMLElement;@@ -430,7 +649,7 @@ export class HierarchyPanel {if (!atlasPath) {console.error(`[HierarchyPanel] No atlas file found for: ${skeletonPath}`);- alert(`无法找到 atlas 文件。\n请确保骨骼文件所在目录下有 .atlas 文件。`);+ alert(`No atlas file found.\nPlease ensure there is an .atlas file in the same directory as the skeleton file.`);return;}@@ -554,21 +773,25 @@ export class HierarchyPanel {this.lastVisibleEnd_ = -1;this.renderVisibleRows();- if (this.footerContainer_) {- if (this.searchFilter_) {- const count = this.searchResults_.length;- this.footerContainer_.textContent = `${count} ${count === 1 ? 'match' : 'matches'}`;- } else {- const count = scene.entities.length;- this.footerContainer_.textContent = `${count} ${count === 1 ? 'entity' : 'entities'}`;- }- }+ this.updateFooter();if (selectionChanged) {this.scrollToEntity(selectedEntity as number);}}+ private updateFooter(): void {+ if (!this.footerContainer_) return;++ if (this.searchFilter_) {+ const count = this.searchResults_.length;+ this.footerContainer_.textContent = `${count} ${count === 1 ? 'match' : 'matches'}`;+ } else {+ const count = this.store_.scene.entities.length;+ this.footerContainer_.textContent = `${count} ${count === 1 ? 'entity' : 'entities'}`;+ }+ }+private expandAncestors(entityId: Entity): void {const entity = this.store_.getEntityData(entityId as number);if (!entity || entity.parent === null) return;@@ -714,6 +937,13 @@ export class HierarchyPanel {this.lastVisibleStart_ = start;this.lastVisibleEnd_ = end;++ if (this.renamingEntityId_ !== null) {+ const item = this.visibleWindow_.querySelector(`[data-entity-id="${this.renamingEntityId_}"]`);+ if (item) {+ this.startInlineRename(this.renamingEntityId_);+ }+ }}private renderSingleRow(row: FlattenedRow, selectedEntity: Entity | null): string {@@ -808,6 +1038,7 @@ export class HierarchyPanel {const entityData = entity !== null ? this.store_.getEntityData(entity as number) : null;const has = (type: string) => entityData?.components.some(c => c.type === type) ?? false;const editor = getEditorInstance();+ const multiSelected = this.store_.selectedEntities.size > 1;const createChildren: ContextMenuItem[] = [{ label: 'Empty Entity', icon: icons.plus(14), onClick: () => {@@ -838,10 +1069,34 @@ export class HierarchyPanel {if (entity !== null) {items.push(- { label: 'Duplicate', icon: icons.copy(14), onClick: () => this.duplicateEntity(entity) },+ { label: 'Rename', icon: icons.pencil(14), onClick: () => this.startInlineRename(entity as number) },+ { label: 'Duplicate', icon: icons.copy(14), onClick: () => {+ if (multiSelected) {+ for (const id of this.store_.selectedEntities) {+ this.duplicateEntity(id as Entity);+ }+ } else {+ this.duplicateEntity(entity);+ }+ } },{ label: 'Copy', icon: icons.copy(14), onClick: () => { this.store_.selectEntity(entity); editor?.copySelected(); } },+ { label: 'Cut', icon: icons.copy(14), onClick: () => {+ this.store_.selectEntity(entity);+ editor?.copySelected();+ if (multiSelected) {+ this.store_.deleteSelectedEntities();+ } else {+ this.store_.deleteEntity(entity);+ }+ } },{ label: 'Paste', icon: icons.template(14), disabled: !editor?.hasClipboard(), onClick: () => { this.store_.selectEntity(entity); editor?.pasteEntity(); } },- { label: 'Delete', icon: icons.trash(14), onClick: () => this.store_.deleteEntity(entity) },+ { label: 'Delete', icon: icons.trash(14), onClick: () => {+ if (multiSelected) {+ this.store_.deleteSelectedEntities();+ } else {+ this.store_.deleteEntity(entity);+ }+ } },{ label: '', separator: true },);}@@ -984,6 +1239,23 @@ export class HierarchyPanel {for (const comp of entityData.components) {this.store_.addComponent(newEntity, comp.type, JSON.parse(JSON.stringify(comp.data)));}++ this.duplicateChildren(entityData, newEntity);+ }++ private duplicateChildren(sourceEntity: EntityData, newParent: Entity): void {+ for (const childId of sourceEntity.children) {+ const childData = this.store_.getEntityData(childId);+ if (!childData) continue;++ const childEntity = this.store_.createEntity(childData.name, newParent);++ for (const comp of childData.components) {+ this.store_.addComponent(childEntity, comp.type, JSON.parse(JSON.stringify(comp.data)));+ }++ this.duplicateChildren(childData, childEntity);+ }}private async saveEntityAsPrefab(entity: Entity): Promise<void> {diff --git a/editor/src/panels/InspectorPanel.ts b/editor/src/panels/InspectorPanel.tsindex 0c2c67a88..a2a3ed785 100644--- a/editor/src/panels/InspectorPanel.ts+++ b/editor/src/panels/InspectorPanel.ts@@ -198,14 +198,17 @@ export class InspectorPanel {renderEntityHeader(this.contentContainer_, entityData.name, entity, this.store_);- for (const component of entityData.components) {- renderComponent(this.contentContainer_, entity, component, this.store_, this.editors_);+ for (let i = 0; i < entityData.components.length; i++) {+ renderComponent(+ this.contentContainer_, entity, entityData.components[i],+ this.store_, this.editors_, i, entityData.components.length+ );}renderAddComponentButton(this.contentContainer_, entity, entityData.components, this.store_);this.extensionSections_ = renderEntityExtensionSections(this.contentContainer_, entity, this.store_);renderMaterialPreview(this.materialPreviewState_, entity, entityData.components, this.store_);- this.updateFooter(`${entityData.components.length + 1} components`);+ this.updateFooter(`${entityData.components.length} components`);}private updateVisibilityIcon(): void {diff --git a/editor/src/panels/SceneViewPanel.ts b/editor/src/panels/SceneViewPanel.tsindex 8e0f668cf..117e00993 100644--- a/editor/src/panels/SceneViewPanel.ts+++ b/editor/src/panels/SceneViewPanel.ts@@ -8,9 +8,7 @@ import { Renderer } from 'esengine';import type { SpineModuleController } from 'esengine/spine';import type { EditorStore } from '../store/EditorStore';import type { EditorBridge } from '../bridge/EditorBridge';-import type { SliceBorder } from '../types/TextureMetadata';import { getPlatformAdapter } from '../platform/PlatformAdapter';-import { hasSlicing, parseTextureMetadata } from '../types/TextureMetadata';import { getDefaultComponentData, getInitialComponentData } from '../schemas/ComponentSchemas';import { getGlobalPathResolver } from '../asset';import { isUUID, getAssetLibrary } from '../asset/AssetDatabase';@@ -22,6 +20,7 @@ import { GizmoManager, getAllGizmos } from '../gizmos';import type { GizmoContext } from '../gizmos';import { ColliderOverlay } from '../gizmos/ColliderOverlay';import { getSettingsValue, setSettingsValue, onSettingsChange } from '../settings/SettingsRegistry';+import { getEditorInstance } from '../context/EditorContext';const CAMERA_COLORS = ['#ffaa00',@@ -86,13 +85,21 @@ export class SceneViewPanel {private static readonly MAX_CACHE_SIZE = 100;private textureCache_: Map<string, HTMLImageElement | null> = new Map();- private metadataCache_: Map<string, SliceBorder | null> = new Map();private loadingTextures_: Set<string> = new Set();private settingsDropdown_: HTMLElement | null = null;private settingsDropdownClickHandler_: ((e: MouseEvent) => void) | null = null;private unsubscribeSettings_: (() => void) | null = null;+ private spaceDown_ = false;+ private keyupHandler_: ((e: KeyboardEvent) => void) | null = null;++ private marqueeActive_ = false;+ private marqueeStartX_ = 0;+ private marqueeStartY_ = 0;+ private marqueeEndX_ = 0;+ private marqueeEndY_ = 0;+private getEntityBoundsWithSpine(entityData: import('../types/SceneTypes').EntityData): { width: number; height: number; offsetX?: number; offsetY?: number } {const hasSpine = entityData.components.some(c => c.type === 'SpineAnimation');if (hasSpine && this.sceneRenderer_) {@@ -142,6 +149,7 @@ export class SceneViewPanel {<div class="es-toolbar-divider"></div><button class="es-btn es-btn-icon" data-action="reset-view" title="Reset View">${icons.refresh(14)}</button><span class="es-zoom-display">100%</span>+ <span class="es-snap-indicator" style="display: none;">SNAP</span><div class="es-toolbar-divider"></div><div class="es-gizmo-settings-wrapper"><button class="es-btn es-btn-icon" data-action="gizmo-settings" title="Gizmo Settings">${icons.settings(14)}</button>@@ -160,6 +168,10 @@ export class SceneViewPanel {<label class="es-settings-label">Grid Opacity</label><input type="range" data-setting="scene.gridOpacity" min="0" max="1" step="0.1" value="${getSettingsValue<number>('scene.gridOpacity')}" class="es-slider-input"></div>+ <div class="es-settings-row">+ <label class="es-settings-label">Grid Size</label>+ <input type="number" data-setting="scene.gridSize" min="1" max="500" step="1" value="${getSettingsValue<number>('scene.gridSize') ?? 50}" class="es-number-input">+ </div><div class="es-settings-divider"></div><div class="es-settings-row"><label class="es-settings-checkbox">@@ -248,6 +260,10 @@ export class SceneViewPanel {document.removeEventListener('keydown', this.keydownHandler_);this.keydownHandler_ = null;}+ if (this.keyupHandler_) {+ document.removeEventListener('keyup', this.keyupHandler_);+ this.keyupHandler_ = null;+ }if (this.settingsDropdownClickHandler_) {document.removeEventListener('click', this.settingsDropdownClickHandler_);this.settingsDropdownClickHandler_ = null;@@ -499,6 +515,16 @@ export class SceneViewPanel {if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {return;}++ if (e.key === ' ' && !this.spaceDown_) {+ this.spaceDown_ = true;+ if (!this.isDragging_) {+ this.canvas_.style.cursor = 'grab';+ }+ e.preventDefault();+ return;+ }+const gizmos = getAllGizmos();for (const g of gizmos) {if (g.shortcut && e.key.toLowerCase() === g.shortcut) {@@ -506,9 +532,66 @@ export class SceneViewPanel {return;}}++ if (e.key === 'f' || e.key === 'F') {+ const entity = this.store_.selectedEntity;+ if (entity !== null) {+ this.focusOnEntity(entity as number);+ }+ return;+ }++ if (e.key === 'Delete' || e.key === 'Backspace') {+ if (this.store_.selectedEntities.size > 0) {+ this.store_.deleteSelectedEntities();+ }+ return;+ }++ if ((e.key === 'd' || e.key === 'D') && (e.ctrlKey || e.metaKey)) {+ e.preventDefault();+ getEditorInstance()?.duplicateSelected();+ return;+ }++ if (e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === 'ArrowLeft' || e.key === 'ArrowRight') {+ this.nudgeSelection(e);+ return;+ }++ if (e.key === '+' || e.key === '=') {+ this.zoom_ = Math.min(10, this.zoom_ * 1.1);+ this.updateZoomDisplay();+ this.requestRender();+ return;+ }++ if (e.key === '-') {+ this.zoom_ = Math.max(0.1, this.zoom_ * 0.9);+ this.updateZoomDisplay();+ this.requestRender();+ return;+ }++ if (e.key === 'Control' || e.key === 'Meta') {+ this.updateSnapIndicator(true);+ }};document.addEventListener('keydown', this.keydownHandler_);+ this.keyupHandler_ = (e: KeyboardEvent) => {+ if (e.key === ' ') {+ this.spaceDown_ = false;+ if (!this.isDragging_) {+ this.canvas_.style.cursor = 'default';+ }+ }+ if (e.key === 'Control' || e.key === 'Meta') {+ this.updateSnapIndicator(false);+ }+ };+ document.addEventListener('keyup', this.keyupHandler_);+this.boundOnMouseDown_ = this.onMouseDown.bind(this);this.boundOnMouseMove_ = this.onMouseMove.bind(this);this.boundOnMouseUp_ = this.onMouseUp.bind(this);@@ -594,7 +677,7 @@ export class SceneViewPanel {input.addEventListener('change', () => {if (input.type === 'checkbox') {setSettingsValue(settingId, input.checked);- } else if (input.type === 'range') {+ } else if (input.type === 'range' || input.type === 'number') {setSettingsValue(settingId, parseFloat(input.value));} else if (input.type === 'color') {setSettingsValue(settingId, input.value);@@ -637,7 +720,7 @@ export class SceneViewPanel {}private onMouseDown(e: MouseEvent): void {- if (e.button === 1 || (e.button === 0 && e.altKey)) {+ if (e.button === 1 || (e.button === 0 && e.altKey) || (e.button === 0 && this.spaceDown_)) {this.isDragging_ = true;this.lastMouseX_ = e.clientX;this.lastMouseY_ = e.clientY;@@ -671,6 +754,19 @@ export class SceneViewPanel {}}+ if (this.gizmoManager_.getActiveId() === 'select') {+ const hits = this.findEntitiesAtPosition(worldX, worldY);+ if (hits.length === 0) {+ this.marqueeActive_ = true;+ this.marqueeStartX_ = worldX;+ this.marqueeStartY_ = worldY;+ this.marqueeEndX_ = worldX;+ this.marqueeEndY_ = worldY;+ this.startDocumentDrag();+ return;+ }+ }+this.lastMouseX_ = e.clientX;this.lastMouseY_ = e.clientY;}@@ -718,9 +814,16 @@ export class SceneViewPanel {return;}+ if (this.marqueeActive_) {+ this.marqueeEndX_ = worldX;+ this.marqueeEndY_ = worldY;+ this.requestRender();+ return;+ }+if (this.gizmoManager_.isDragging()) {this.updateGizmoContext();- this.gizmoManager_.onMouseMove(worldX, worldY);+ this.gizmoManager_.onMouseMove(worldX, worldY, e);return;}@@ -737,7 +840,7 @@ export class SceneViewPanel {if (this.gizmoManager_.getActiveId() !== 'select' && hasSelection) {this.updateGizmoContext();- this.gizmoManager_.onMouseMove(worldX, worldY);+ this.gizmoManager_.onMouseMove(worldX, worldY, e);this.canvas_.style.cursor = this.gizmoManager_.getCursor();}@@ -760,10 +863,20 @@ export class SceneViewPanel {if (this.isDragging_) {this.isDragging_ = false;- this.canvas_.style.cursor = 'default';+ this.canvas_.style.cursor = this.spaceDown_ ? 'grab' : 'default';this.skipNextClick_ = true;}+ if (this.marqueeActive_) {+ this.marqueeActive_ = false;+ const { worldX, worldY } = this.screenToWorld(_e.clientX, _e.clientY);+ this.marqueeEndX_ = worldX;+ this.marqueeEndY_ = worldY;+ this.finishMarqueeSelection(_e.ctrlKey || _e.metaKey);+ this.skipNextClick_ = true;+ this.requestRender();+ }+if (this.gizmoManager_.isDragging()) {const { worldX, worldY } = this.screenToWorld(_e.clientX, _e.clientY);this.updateGizmoContext();@@ -781,7 +894,7 @@ export class SceneViewPanel {}private onMouseLeave(_e: MouseEvent): void {- if (this.isDragging_ || this.gizmoManager_.isDragging() || this.colliderOverlay_.isDragging()) {+ if (this.isDragging_ || this.gizmoManager_.isDragging() || this.colliderOverlay_.isDragging() || this.marqueeActive_) {return;}this.gizmoManager_.resetHover();@@ -847,8 +960,9 @@ export class SceneViewPanel {const newZoom = Math.max(0.1, Math.min(10, this.zoom_ * zoomFactor));const rect = this.canvas_.getBoundingClientRect();- const mouseX = e.clientX - rect.left;- const mouseY = e.clientY - rect.top;+ const dpr = window.devicePixelRatio;+ const mouseX = (e.clientX - rect.left) * dpr;+ const mouseY = (e.clientY - rect.top) * dpr;const worldX = (mouseX - this.canvas_.width / 2) / this.zoom_ - this.panX_;const worldY = (mouseY - this.canvas_.height / 2) / this.zoom_ - this.panY_;@@ -902,6 +1016,88 @@ export class SceneViewPanel {return result;}+ private findEntitiesInRect(x1: number, y1: number, x2: number, y2: number): Entity[] {+ const minX = Math.min(x1, x2);+ const maxX = Math.max(x1, x2);+ const minY = Math.min(y1, y2);+ const maxY = Math.max(y1, y2);++ const scene = this.store_.scene;+ const result: Entity[] = [];++ for (const entity of scene.entities) {+ if (!this.store_.isEntityVisible(entity.id)) continue;+ const transform = entity.components.find(c => c.type === 'LocalTransform');+ if (!transform) continue;++ const worldTransform = this.store_.getWorldTransform(entity.id);+ const pos = worldTransform.position;+ const scale = worldTransform.scale;+ const bounds = this.getEntityBoundsWithSpine(entity);+ const w = bounds.width * Math.abs(scale.x);+ const h = bounds.height * Math.abs(scale.y);+ const offsetX = (bounds.offsetX ?? 0) * scale.x;+ const offsetY = (bounds.offsetY ?? 0) * scale.y;++ const centerX = pos.x + offsetX;+ const centerY = pos.y + offsetY;+ const halfW = w / 2;+ const halfH = h / 2;++ if (centerX + halfW >= minX && centerX - halfW <= maxX &&+ centerY + halfH >= minY && centerY - halfH <= maxY) {+ result.push(entity.id as Entity);+ }+ }++ return result;+ }++ private finishMarqueeSelection(addToExisting: boolean): void {+ const hits = this.findEntitiesInRect(+ this.marqueeStartX_, this.marqueeStartY_,+ this.marqueeEndX_, this.marqueeEndY_,+ );++ if (addToExisting) {+ const existing = Array.from(this.store_.selectedEntities);+ const merged = new Set([...existing, ...hits.map(h => h as number)]);+ this.store_.selectEntities(Array.from(merged));+ } else {+ this.store_.selectEntities(hits.map(h => h as number));+ }+ }++ private nudgeSelection(e: KeyboardEvent): void {+ const entity = this.store_.selectedEntity;+ if (entity === null) return;++ const entityData = this.store_.getEntityData(entity as number);+ if (!entityData) return;++ const transform = entityData.components.find(c => c.type === 'LocalTransform');+ if (!transform) return;++ const pos = transform.data.position as { x: number; y: number; z: number };+ if (!pos) return;++ const snapOn = e.ctrlKey || e.metaKey;+ const step = snapOn ? (getSettingsValue<number>('scene.gridSize') ?? 50) : 1;++ let dx = 0;+ let dy = 0;+ if (e.key === 'ArrowLeft') dx = -step;+ if (e.key === 'ArrowRight') dx = step;+ if (e.key === 'ArrowUp') dy = step;+ if (e.key === 'ArrowDown') dy = -step;++ const oldPos = { ...pos };+ const newPos = { x: pos.x + dx, y: pos.y + dy, z: pos.z };++ this.store_.updateProperty(entity as number, 'LocalTransform', 'position', oldPos, newPos);+ e.preventDefault();+ }+private updateZoomDisplay(): void {const display = this.container_.querySelector('.es-zoom-display');if (display) {@@ -909,6 +1105,13 @@ export class SceneViewPanel {}}+ private updateSnapIndicator(active: boolean): void {+ const indicator = this.container_.querySelector('.es-snap-indicator') as HTMLElement | null;+ if (indicator) {+ indicator.style.display = active ? 'inline' : 'none';+ }+ }+private requestRender(): void {this.isDirty_ = true;if (this.animationId_ !== null) return;@@ -1022,6 +1225,10 @@ export class SceneViewPanel {}}+ if (this.marqueeActive_) {+ this.drawMarquee(ctx);+ }+ctx.restore();this.drawStats(ctx, w, h);@@ -1081,6 +1288,21 @@ export class SceneViewPanel {}}+ private drawMarquee(ctx: CanvasRenderingContext2D): void {+ const x = Math.min(this.marqueeStartX_, this.marqueeEndX_);+ const y = Math.min(-this.marqueeStartY_, -this.marqueeEndY_);+ const w = Math.abs(this.marqueeEndX_ - this.marqueeStartX_);+ const h = Math.abs(this.marqueeEndY_ - this.marqueeStartY_);++ ctx.fillStyle = 'rgba(0, 170, 255, 0.1)';+ ctx.fillRect(x, y, w, h);++ ctx.strokeStyle = '#00aaff';+ ctx.lineWidth = 1 / this.zoom_;+ ctx.setLineDash([]);+ ctx.strokeRect(x, y, w, h);+ }+private drawCameraFrustums(ctx: CanvasRenderingContext2D): void {const selectedEntity = this.store_.selectedEntity;@@ -1418,6 +1640,10 @@ export class SceneViewPanel {}}+ if (this.marqueeActive_) {+ this.drawMarquee(ctx);+ }+ctx.restore();}@@ -1425,19 +1651,63 @@ export class SceneViewPanel {if (!getSettingsValue<boolean>('scene.showGrid')) return;const gridSize = getSettingsValue<number>('scene.gridSize') ?? 50;+ const baseOpacity = getSettingsValue<number>('scene.gridOpacity');+ const gridColor = getSettingsValue<string>('scene.gridColor');const halfW = w / 2 / this.zoom_;const halfH = h / 2 / this.zoom_;+ const screenGridSize = gridSize * this.zoom_;++ if (screenGridSize > 100) {+ const subDiv = screenGridSize > 250 ? 10 : 5;+ const subSize = gridSize / subDiv;+ this.drawGridLines(ctx, subSize, halfW, halfH, gridColor, baseOpacity * 0.3);+ }++ this.drawGridLines(ctx, gridSize, halfW, halfH, gridColor, baseOpacity);++ if (screenGridSize < 15) {+ const majorSize = gridSize * (screenGridSize < 5 ? 10 : 5);+ this.drawGridLines(ctx, majorSize, halfW, halfH, gridColor, baseOpacity);+ }++ ctx.globalAlpha = baseOpacity;+ ctx.strokeStyle = this.lightenColor(gridColor, 30);+ ctx.lineWidth = 2 / this.zoom_;const startX = Math.floor((-halfW - this.panX_) / gridSize) * gridSize;const endX = Math.ceil((halfW - this.panX_) / gridSize) * gridSize;const startY = Math.floor((-halfH - this.panY_) / gridSize) * gridSize;const endY = Math.ceil((halfH - this.panY_) / gridSize) * gridSize;+ ctx.beginPath();+ ctx.moveTo(startX, 0);+ ctx.lineTo(endX, 0);+ ctx.stroke();+ ctx.beginPath();+ ctx.moveTo(0, startY);+ ctx.lineTo(0, endY);+ ctx.stroke();- ctx.globalAlpha = getSettingsValue<number>('scene.gridOpacity');- ctx.strokeStyle = getSettingsValue<string>('scene.gridColor');+ ctx.globalAlpha = 1;+ }++ private drawGridLines(+ ctx: CanvasRenderingContext2D,+ step: number,+ halfW: number,+ halfH: number,+ color: string,+ opacity: number,+ ): void {+ const startX = Math.floor((-halfW - this.panX_) / step) * step;+ const endX = Math.ceil((halfW - this.panX_) / step) * step;+ const startY = Math.floor((-halfH - this.panY_) / step) * step;+ const endY = Math.ceil((halfH - this.panY_) / step) * step;++ ctx.globalAlpha = opacity;+ ctx.strokeStyle = color;ctx.lineWidth = 1 / this.zoom_;- for (let x = startX; x <= endX; x += gridSize) {+ for (let x = startX; x <= endX; x += step) {if (x === 0) continue;ctx.beginPath();ctx.moveTo(x, startY);@@ -1445,26 +1715,13 @@ export class SceneViewPanel {ctx.stroke();}- for (let y = startY; y <= endY; y += gridSize) {+ for (let y = startY; y <= endY; y += step) {if (y === 0) continue;ctx.beginPath();ctx.moveTo(startX, y);ctx.lineTo(endX, y);ctx.stroke();}-- ctx.strokeStyle = this.lightenColor(getSettingsValue<string>('scene.gridColor'), 30);- ctx.lineWidth = 2 / this.zoom_;- ctx.beginPath();- ctx.moveTo(startX, 0);- ctx.lineTo(endX, 0);- ctx.stroke();- ctx.beginPath();- ctx.moveTo(0, startY);- ctx.lineTo(0, endY);- ctx.stroke();-- ctx.globalAlpha = 1;}private lightenColor(hex: string, percent: number): string {diff --git a/editor/src/panels/inspector/EntityInspector.ts b/editor/src/panels/inspector/EntityInspector.tsindex 2a8f61a7c..aa8b0dc80 100644--- a/editor/src/panels/inspector/EntityInspector.ts+++ b/editor/src/panels/inspector/EntityInspector.ts@@ -24,6 +24,7 @@ import {getComponentIcon,getProjectDir,} from './InspectorHelpers';+import { showContextMenu, type ContextMenuItem } from '../../ui/ContextMenu';import { isPropertyOverridden, hasAnyOverrides } from '../../prefab';import {getComponentInspector,@@ -154,7 +155,9 @@ export function renderComponent(entity: Entity,component: ComponentData,store: EditorStore,- editors: EditorInfo[]+ editors: EditorInfo[],+ componentIndex: number = 0,+ componentCount: number = 1): void {const schema = getComponentSchema(component.type);if (!schema) {@@ -192,6 +195,87 @@ export function renderComponent(section.classList.toggle('es-expanded');});+ header.addEventListener('contextmenu', (e) => {+ e.preventDefault();+ const defaults = getDefaultComponentData(component.type);+ const menuItems: ContextMenuItem[] = [+ {+ label: 'Reset to Default',+ icon: icons.rotateCcw(14),+ onClick: () => {+ const changes = Object.keys(defaults).map(key => ({+ property: key,+ oldValue: component.data[key] ?? defaults[key],+ newValue: defaults[key],+ }));+ if (changes.length > 0) {+ store.updateProperties(entity, component.type, changes);+ }+ },+ },+ {+ label: 'Copy Component',+ icon: icons.copy(14),+ onClick: () => {+ const payload = JSON.stringify({ type: component.type, data: component.data });+ navigator.clipboard.writeText(payload);+ },+ },+ {+ label: 'Paste Component Values',+ icon: icons.clipboard(14),+ onClick: async () => {+ try {+ const text = await navigator.clipboard.readText();+ const parsed = JSON.parse(text);+ if (parsed.type === component.type && parsed.data) {+ const changes = Object.keys(parsed.data).map(key => ({+ property: key,+ oldValue: component.data[key] ?? defaults[key],+ newValue: parsed.data[key],+ }));+ if (changes.length > 0) {+ store.updateProperties(entity, component.type, changes);+ }+ }+ } catch { /* ignore invalid clipboard data */ }+ },+ },+ { label: '', separator: true },+ {+ label: 'Move Up',+ icon: icons.arrowUp(14),+ disabled: componentIndex <= 0,+ onClick: () => {+ store.reorderComponent(entity, componentIndex, componentIndex - 1);+ },+ },+ {+ label: 'Move Down',+ icon: icons.arrowDown(14),+ disabled: componentIndex >= componentCount - 1,+ onClick: () => {+ store.reorderComponent(entity, componentIndex, componentIndex + 1);+ },+ },+ ];++ if (removable) {+ menuItems.push(+ { label: '', separator: true },+ {+ label: 'Remove',+ icon: icons.trash(14),+ onClick: () => {+ store.removeComponent(entity, component.type);+ },+ }+ );+ }++ showContextMenu({ items: menuItems, x: e.clientX, y: e.clientY });+ });+if (schema?.category === 'script') {header.addEventListener('dblclick', () => {const sourceMap = window.__esengine_componentSourceMap;@@ -288,11 +372,12 @@ export function renderComponent(value: currentValue,meta: propMeta,onChange: (newValue) => {+ const oldValue = component.data[propMeta.name] ?? currentValue;store.updateProperty(entity,component.type,propMeta.name,- currentValue,+ oldValue,newValue);},@@ -311,6 +396,26 @@ export function renderComponent(row.appendChild(label);row.appendChild(editorContainer);+ const defaults = getDefaultComponentData(component.type);+ const defaultValue = defaults[propMeta.name];+ const isModified = currentValue !== undefined &&+ JSON.stringify(currentValue) !== JSON.stringify(defaultValue);++ if (isModified) {+ const resetBtn = document.createElement('button');+ resetBtn.className = 'es-property-reset';+ resetBtn.title = `Reset to default`;+ resetBtn.innerHTML = icons.rotateCcw(10);+ resetBtn.addEventListener('click', () => {+ store.updateProperty(+ entity, component.type, propMeta.name,+ component.data[propMeta.name] ?? currentValue,+ defaultValue+ );+ });+ row.appendChild(resetBtn);+ }+if (component.type === 'Sprite' && propMeta.name === 'size') {const resetBtn = createSpriteSizeResetButton(entity, component, store);row.appendChild(resetBtn);diff --git a/editor/src/panels/inspector/InspectorHelpers.ts b/editor/src/panels/inspector/InspectorHelpers.tsindex 97f47e176..3b2a59cf0 100644--- a/editor/src/panels/inspector/InspectorHelpers.ts+++ b/editor/src/panels/inspector/InspectorHelpers.ts@@ -128,12 +128,28 @@ export function getComponentIcon(type: string): string {case 'WorldTransform':return icons.move(14);case 'Sprite':+ case 'NinePatch':return icons.image(14);case 'Camera':return icons.camera(14);case 'Text':case 'TextInput':return icons.type(14);+ case 'RigidBody':+ case 'BoxCollider':+ case 'CircleCollider':+ case 'CapsuleCollider':+ return icons.zap(14);+ case 'SpineAnimation':+ return icons.film(14);+ case 'Button':+ case 'Canvas':+ case 'UIRect':+ return icons.scan(14);+ case 'LayoutGroup':+ return icons.layoutGrid(14);+ case 'UIMask':+ return icons.shield(14);default:return icons.settings(14);}diff --git a/editor/src/panels/inspector/SharedEditors.ts b/editor/src/panels/inspector/SharedEditors.tsindex 144bedcd9..bd299cd97 100644--- a/editor/src/panels/inspector/SharedEditors.ts+++ b/editor/src/panels/inspector/SharedEditors.ts@@ -7,52 +7,7 @@ import type { ShaderProperty } from '../../shader/ShaderPropertyParser';import { ShaderPropertyType, getDefaultPropertyValue } from '../../shader/ShaderPropertyParser';import { getPlatformAdapter } from '../../platform/PlatformAdapter';import { getProjectDir, openAssetInBrowser } from './InspectorHelpers';--// =============================================================================-// Drag Label-// =============================================================================--export function setupDragLabel(- label: HTMLElement,- input: HTMLInputElement,- onChange: (value: number) => void,- step: number = 0.1,- min?: number,- max?: number-): void {- let startX = 0;- let startValue = 0;- let isDragging = false;-- const onMouseMove = (e: MouseEvent) => {- if (!isDragging) return;- const delta = (e.clientX - startX) * step;- let newValue = startValue + delta;- if (min !== undefined && newValue < min) newValue = min;- if (max !== undefined && newValue > max) newValue = max;- newValue = parseFloat(newValue.toFixed(4));- input.value = String(newValue);- onChange(newValue);- };-- const onMouseUp = () => {- isDragging = false;- document.removeEventListener('mousemove', onMouseMove);- document.removeEventListener('mouseup', onMouseUp);- document.body.style.cursor = '';- };-- label.style.cursor = 'ew-resize';- label.addEventListener('mousedown', (e) => {- e.preventDefault();- isDragging = true;- startX = e.clientX;- startValue = parseFloat(input.value) || 0;- document.body.style.cursor = 'ew-resize';- document.addEventListener('mousemove', onMouseMove);- document.addEventListener('mouseup', onMouseUp);- });-}+import { setupDragLabel } from '../../property/editorUtils';// =============================================================================// Numeric Editorsdiff --git a/editor/src/property/editorUtils.ts b/editor/src/property/editorUtils.tsindex e0910794a..2e9141160 100644--- a/editor/src/property/editorUtils.ts+++ b/editor/src/property/editorUtils.ts@@ -1,8 +1,10 @@export function setupDragLabel(label: HTMLElement,input: HTMLInputElement,- onChange: (delta: number) => void,- step: number = 0.1+ onChange: (value: number) => void,+ step: number = 0.1,+ min?: number,+ max?: number): void {let startX = 0;let startValue = 0;@@ -11,8 +13,11 @@ export function setupDragLabel(const onMouseMove = (e: MouseEvent) => {if (!isDragging) return;const delta = (e.clientX - startX) * step;- const newValue = startValue + delta;- input.value = newValue.toFixed(2);+ let newValue = startValue + delta;+ if (min !== undefined && newValue < min) newValue = min;+ if (max !== undefined && newValue > max) newValue = max;+ newValue = parseFloat(newValue.toFixed(4));+ input.value = String(newValue);onChange(newValue);};diff --git a/editor/src/property/validation.ts b/editor/src/property/validation.tsindex 05269c27f..4c9569816 100644--- a/editor/src/property/validation.ts+++ b/editor/src/property/validation.ts@@ -122,13 +122,13 @@ export function validateColor(value: unknown, meta: PropertyMeta): ValidationResif (!value || typeof value !== 'object') {return {valid: false,- value: { r: 255, g: 255, b: 255, a: 255 },+ value: { r: 1, g: 1, b: 1, a: 1 },error: 'Value must be a Color object'};}const color = value as { r: number; g: number; b: number; a: number };- const componentMeta = { ...meta, min: 0, max: 255 };+ const componentMeta = { ...meta, min: 0, max: 1 };const rResult = validateNumber(color.r, componentMeta);const gResult = validateNumber(color.g, componentMeta);@@ -144,7 +144,7 @@ export function validateColor(value: unknown, meta: PropertyMeta): ValidationResb: bResult.value as number,a: aResult.value as number},- error: 'Color components must be 0-255'+ error: 'Color components must be 0-1'};}diff --git a/editor/src/settings/SettingsDialog.ts b/editor/src/settings/SettingsDialog.tsindex ea597f653..bafa434a3 100644--- a/editor/src/settings/SettingsDialog.ts+++ b/editor/src/settings/SettingsDialog.ts@@ -8,6 +8,8 @@ import {type SettingsItemDescriptor,} from './SettingsRegistry';+let lastActiveSectionId_: string | null = null;+export function showSettingsDialog(): void {const sections = getAllSections();if (sections.length === 0) return;@@ -24,8 +26,11 @@ export function showSettingsDialog(): void {body.appendChild(nav);body.appendChild(content);- let activeSectionId = sections[0].id;+ let activeSectionId = lastActiveSectionId_ && sections.find(s => s.id === lastActiveSectionId_)+ ? lastActiveSectionId_+ : sections[0].id;const inputElements = new Map<string, HTMLInputElement | HTMLSelectElement>();+ const itemRows = new Map<string, HTMLElement>();function buildNav(): void {nav.innerHTML = '';@@ -38,6 +43,7 @@ export function showSettingsDialog(): void {btn.textContent = section.title;btn.addEventListener('click', () => {activeSectionId = section.id;+ lastActiveSectionId_ = section.id;buildNav();buildContent();});@@ -45,8 +51,25 @@ export function showSettingsDialog(): void {}}+ function isItemVisible(item: SettingsItemDescriptor): boolean {+ if (!item.visibleWhen) return true;+ const depValue = getSettingsValue(item.visibleWhen.settingId);+ return depValue === item.visibleWhen.value;+ }++ function updateVisibility(): void {+ for (const [id, row] of itemRows) {+ const items = getSectionItems(activeSectionId);+ const item = items.find(i => i.id === id);+ if (item) {+ row.style.display = isItemVisible(item) ? '' : 'none';+ }+ }+ }+function buildContent(): void {content.innerHTML = '';+ itemRows.clear();const items = getSectionItems(activeSectionId);const section = sections.find(s => s.id === activeSectionId);@@ -60,11 +83,37 @@ export function showSettingsDialog(): void {for (const item of items) {const row = document.createElement('div');row.className = 'es-settings-item';+ if (!isItemVisible(item)) {+ row.style.display = 'none';+ }+ itemRows.set(item.id, row);content.appendChild(row);renderItem(row, item);}}+ function addDescription(container: HTMLElement, item: SettingsItemDescriptor): void {+ if (!item.description) return;+ const desc = document.createElement('div');+ desc.className = 'es-settings-description';+ desc.textContent = item.description;+ container.appendChild(desc);+ }++ function addResetButton(container: HTMLElement, item: SettingsItemDescriptor): void {+ const value = getSettingsValue(item.id);+ if (value === item.defaultValue) return;+ const btn = document.createElement('button');+ btn.className = 'es-settings-reset-btn';+ btn.title = `Reset to default (${String(item.defaultValue)})`;+ btn.textContent = '\u21BA';+ btn.addEventListener('click', () => {+ setSettingsValue(item.id, item.defaultValue);+ buildContent();+ });+ container.appendChild(btn);+ }+function renderItem(container: HTMLElement, item: SettingsItemDescriptor): void {const value = getSettingsValue(item.id);@@ -77,20 +126,28 @@ export function showSettingsDialog(): void {input.checked = value as boolean;input.addEventListener('change', () => {setSettingsValue(item.id, input.checked);+ updateVisibility();});const span = document.createElement('span');span.textContent = item.label;label.appendChild(input);label.appendChild(span);+ addResetButton(label, item);container.appendChild(label);+ addDescription(container, item);inputElements.set(item.id, input);break;}case 'number': {+ const header = document.createElement('div');+ header.className = 'es-settings-item-header';const label = document.createElement('label');label.className = 'es-settings-label';label.textContent = item.label;- container.appendChild(label);+ header.appendChild(label);+ addResetButton(header, item);+ container.appendChild(header);+ addDescription(container, item);const input = document.createElement('input');input.type = 'number';input.className = 'es-settings-input';@@ -99,8 +156,9 @@ export function showSettingsDialog(): void {if (item.max !== undefined) input.max = String(item.max);if (item.step !== undefined) input.step = String(item.step);input.addEventListener('input', () => {- const val = parseFloat(input.value);+ let val = parseFloat(input.value);if (!isNaN(val)) {+ val = Math.max(item.min ?? -Infinity, Math.min(item.max ?? Infinity, val));setSettingsValue(item.id, val);}});@@ -109,10 +167,15 @@ export function showSettingsDialog(): void {break;}case 'string': {+ const header = document.createElement('div');+ header.className = 'es-settings-item-header';const label = document.createElement('label');label.className = 'es-settings-label';label.textContent = item.label;- container.appendChild(label);+ header.appendChild(label);+ addResetButton(header, item);+ container.appendChild(header);+ addDescription(container, item);const input = document.createElement('input');input.type = 'text';input.className = 'es-settings-input';@@ -131,6 +194,7 @@ export function showSettingsDialog(): void {label.className = 'es-settings-label';label.textContent = item.label;row.appendChild(label);+ addResetButton(row, item);const input = document.createElement('input');input.type = 'color';input.className = 'es-color-input';@@ -140,14 +204,20 @@ export function showSettingsDialog(): void {});row.appendChild(input);container.appendChild(row);+ addDescription(container, item);inputElements.set(item.id, input);break;}case 'select': {+ const header = document.createElement('div');+ header.className = 'es-settings-item-header';const label = document.createElement('label');label.className = 'es-settings-label';label.textContent = item.label;- container.appendChild(label);+ header.appendChild(label);+ addResetButton(header, item);+ container.appendChild(header);+ addDescription(container, item);const select = document.createElement('select');select.className = 'es-settings-select';for (const opt of item.options ?? []) {@@ -159,6 +229,7 @@ export function showSettingsDialog(): void {}select.addEventListener('change', () => {setSettingsValue(item.id, select.value);+ updateVisibility();});container.appendChild(select);inputElements.set(item.id, select);@@ -171,11 +242,13 @@ export function showSettingsDialog(): void {label.className = 'es-settings-label';label.textContent = item.label;row.appendChild(label);+ addResetButton(row, item);const valueDisplay = document.createElement('span');valueDisplay.className = 'es-settings-range-value';valueDisplay.textContent = String(value ?? 0);row.appendChild(valueDisplay);container.appendChild(row);+ addDescription(container, item);const input = document.createElement('input');input.type = 'range';input.className = 'es-slider-input';@@ -208,6 +281,7 @@ export function showSettingsDialog(): void {} else {el.value = String(value);}+ updateVisibility();});const dialog = new Dialog({diff --git a/editor/src/settings/SettingsRegistry.ts b/editor/src/settings/SettingsRegistry.tsindex ad4d4ecfd..cb0552614 100644--- a/editor/src/settings/SettingsRegistry.ts+++ b/editor/src/settings/SettingsRegistry.ts@@ -11,6 +11,7 @@ export interface SettingsItemDescriptor {id: string;section: string;label: string;+ description?: string;type: SettingsItemType;defaultValue: unknown;order?: number;@@ -19,6 +20,7 @@ export interface SettingsItemDescriptor {max?: number;step?: number;onChange?: (value: unknown) => void;+ visibleWhen?: { settingId: string; value: unknown };}type SettingsChangeListener = (id: string, value: unknown) => void;@@ -132,6 +134,10 @@ export function getSectionItems(sectionId: string): SettingsItemDescriptor[] {.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));}+export function getItemDescriptor(id: string): SettingsItemDescriptor | undefined {+ return items_.get(id);+}+export function lockBuiltinSettings(): void {builtinSectionIds_ = new Set(sections_.keys());builtinItemIds_ = new Set(items_.keys());diff --git a/editor/src/settings/builtinSettings.ts b/editor/src/settings/builtinSettings.tsindex cb38046c3..9d773a80c 100644--- a/editor/src/settings/builtinSettings.ts+++ b/editor/src/settings/builtinSettings.ts@@ -113,6 +113,7 @@ export function registerBuiltinSettings(): void {id: 'physics.fixedTimestep',section: 'physics',label: 'Fixed Timestep',+ description: 'Maximum simulation time step in seconds',type: 'number',defaultValue: 1 / 60,step: 0.001,@@ -124,6 +125,7 @@ export function registerBuiltinSettings(): void {id: 'physics.subStepCount',section: 'physics',label: 'Sub-Step Count',+ description: 'Maximum physics sub-steps per frame',type: 'number',defaultValue: 4,step: 1,@@ -287,6 +289,7 @@ export function registerBuiltinSettings(): void {id: 'runtime.sceneTransitionDuration',section: 'runtime',label: 'Scene Transition Duration',+ description: 'Fade duration when switching scenes, in seconds',type: 'number',defaultValue: 0.3,min: 0,@@ -299,6 +302,7 @@ export function registerBuiltinSettings(): void {id: 'runtime.sceneTransitionColor',section: 'runtime',label: 'Scene Transition Color',+ description: 'Background color during scene transitions',type: 'color',defaultValue: '#000000',order: 1,@@ -308,6 +312,7 @@ export function registerBuiltinSettings(): void {id: 'runtime.defaultFontFamily',section: 'runtime',label: 'Default Font Family',+ description: 'Fallback font used for text rendering',type: 'string',defaultValue: 'Arial',order: 2,@@ -317,6 +322,7 @@ export function registerBuiltinSettings(): void {id: 'runtime.canvasScaleMode',section: 'runtime',label: 'Canvas Scale Mode',+ description: 'How the canvas adapts to different screen sizes',type: 'select',defaultValue: 'FixedHeight',order: 3,@@ -333,18 +339,21 @@ export function registerBuiltinSettings(): void {id: 'runtime.canvasMatchWidthOrHeight',section: 'runtime',label: 'Canvas Match W/H',+ description: 'Blend between matching width (0) and height (1)',type: 'range',defaultValue: 0.5,min: 0,max: 1,step: 0.1,order: 4,+ visibleWhen: { settingId: 'runtime.canvasScaleMode', value: 'Match' },});registerSettingsItem({id: 'runtime.maxDeltaTime',section: 'runtime',label: 'Max Delta Time',+ description: 'Maximum allowed frame delta time in seconds',type: 'number',defaultValue: 0.25,min: 0.01,@@ -357,6 +366,7 @@ export function registerBuiltinSettings(): void {id: 'runtime.maxFixedSteps',section: 'runtime',label: 'Max Fixed Steps',+ description: 'Maximum fixed update iterations per frame',type: 'number',defaultValue: 8,min: 1,diff --git a/editor/src/settings/index.ts b/editor/src/settings/index.tsindex 4f7c9f158..59b3ec20f 100644--- a/editor/src/settings/index.ts+++ b/editor/src/settings/index.ts@@ -9,6 +9,7 @@ export {onSettingsChange,getAllSections,getSectionItems,+ getItemDescriptor,lockBuiltinSettings,clearExtensionSettings,} from './SettingsRegistry';diff --git a/editor/src/store/EditorStore.ts b/editor/src/store/EditorStore.tsindex af365fa27..d5d242aa6 100644--- a/editor/src/store/EditorStore.ts+++ b/editor/src/store/EditorStore.ts@@ -16,6 +16,7 @@ import {MoveEntityCommand,AddComponentCommand,RemoveComponentCommand,+ ReorderComponentCommand,RenameEntityCommand,ToggleVisibilityCommand,InstantiatePrefabCommand,@@ -202,6 +203,14 @@ export class EditorStore {return this.history_.canRedo();}+ get undoDescription(): string | null {+ return this.history_.undoDescription;+ }++ get redoDescription(): string | null {+ return this.history_.redoDescription;+ }+get isDirty(): boolean {return this.state_.isDirty;}@@ -553,6 +562,14 @@ export class EditorStore {this.notifyComponentChange({ entity: entity as number, componentType: type, action: 'removed' });}+ reorderComponent(entity: Entity, fromIndex: number, toIndex: number): void {+ const cmd = new ReorderComponentCommand(+ this.state_.scene, this.entityMap_, entity as number, fromIndex, toIndex+ );+ this.executeCommand(cmd);+ this.notify('selection');+ }+updateProperty(entity: Entity,componentType: string,diff --git a/editor/src/styles/editor.css b/editor/src/styles/editor.cssindex 7c4f972a5..a63251d88 100644--- a/editor/src/styles/editor.css+++ b/editor/src/styles/editor.css@@ -18,6 +18,9 @@--es-accent-hover: #1084d8;--es-danger: #f44336;--es-success: #4caf50;+ --es-input-bg: #2d2d2d;+ --es-text-disabled: #555555;+ --es-text-muted: #666666;--es-scrollbar-track: #1e1e1e;--es-scrollbar-thumb: #424242;--es-scrollbar-thumb-hover: #555555;@@ -261,6 +264,14 @@ svg {stroke: white;}+.es-editor-menubar .es-btn-preview.es-btn-danger {+ background: var(--es-error, #d9534f);+}++.es-editor-menubar .es-btn-preview.es-btn-danger:hover {+ background: #c9302c;+}+.es-editor-body {display: flex;flex-direction: column;@@ -571,38 +582,19 @@ svg {color: var(--es-text-secondary);}-.es-hierarchy-children {- display: none;- position: relative;-}--.es-hierarchy-item.es-expanded > .es-hierarchy-children {- display: block;-}--.es-hierarchy-children > .es-hierarchy-item::before {- content: '';- position: absolute;- top: 0;- left: calc(2px + var(--depth) * 16px);- bottom: 0;- border-left: 1px dotted var(--es-border);- pointer-events: none;-}--.es-hierarchy-children > .es-hierarchy-item:last-child::before {- bottom: auto;- height: 11px;-}--.es-hierarchy-children > .es-hierarchy-item::after {- content: '';- position: absolute;- top: 11px;- left: calc(2px + var(--depth) * 16px);- width: 8px;- border-top: 1px dotted var(--es-border);- pointer-events: none;+.es-hierarchy-rename-input {+ width: 100%;+ height: 18px;+ padding: 0 4px;+ margin: 0;+ border: 1px solid #d19a66;+ border-radius: 2px;+ background: var(--es-bg-primary);+ color: var(--es-text-primary);+ font-size: 12px;+ font-family: inherit;+ outline: none;+ box-sizing: border-box;}.es-hierarchy-item.es-entity-hidden > .es-hierarchy-row {@@ -990,15 +982,42 @@ svg {}.es-property-label {- width: 80px;- flex-shrink: 0;+ width: 35%;+ max-width: 80px;+ flex-shrink: 1;padding-right: 8px;color: var(--es-text-secondary);font-size: 11px;- word-break: break-word;+ text-overflow: ellipsis;+ overflow: hidden;+ white-space: nowrap;line-height: 1.3;}+.es-property-reset {+ flex-shrink: 0;+ margin-left: 2px;+ padding: 0;+ width: 16px;+ height: 16px;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ background: transparent;+ border: none;+ opacity: 0;+ cursor: pointer;+ color: var(--es-text-secondary);+}++.es-property-row:hover .es-property-reset {+ opacity: 0.5;+}++.es-property-reset:hover {+ opacity: 1 !important;+}+.es-property-editor {flex: 1;display: flex;@@ -2086,6 +2105,132 @@ svg {width: 100%;}+.es-asset-subpath {+ font-size: 9px;+ color: var(--es-text-muted);+ text-align: center;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ width: 100%;+}++/* Thumbnail */+.es-cb-thumbnail {+ object-fit: contain;+ border-radius: 2px;+}++.es-cb-thumb-loading {+ opacity: 0.5;+}++/* Up Button */+.es-cb-up-btn {+ flex-shrink: 0;+}++/* View Toggle */+.es-cb-view-toggle {+ flex-shrink: 0;+}++/* List View */+.es-cb-list-view {+ flex-direction: column;+ flex-wrap: nowrap;+ gap: 0;+ padding: 4px 0;+}++.es-cb-list-row {+ display: flex;+ align-items: center;+ height: 24px;+ padding: 0 8px;+ cursor: pointer;+ user-select: none;+ gap: 8px;+}++.es-cb-list-row:hover {+ background: var(--es-bg-hover);+}++.es-cb-list-row.es-selected {+ background: rgba(209, 154, 102, 0.2);+}++.es-cb-list-row[draggable="true"] {+ cursor: grab;+}++.es-cb-list-icon {+ display: flex;+ align-items: center;+ justify-content: center;+ width: 24px;+ height: 24px;+ flex-shrink: 0;+}++.es-cb-list-icon svg {+ stroke: #e8c36a;+}++.es-cb-list-name {+ flex: 1;+ font-size: 12px;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ min-width: 0;+}++.es-cb-list-subpath {+ color: var(--es-text-muted);+ font-size: 10px;+ margin-left: 6px;+}++.es-cb-list-type {+ font-size: 10px;+ color: var(--es-text-muted);+ flex-shrink: 0;+ width: 60px;+ text-align: right;+}++/* Empty State */+.es-cb-empty-state {+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ width: 100%;+ height: 100%;+ gap: 8px;+ pointer-events: none;+}++.es-cb-empty-icon {+ opacity: 0.3;+}++.es-cb-empty-icon svg {+ stroke: var(--es-text-muted);+}++.es-cb-empty-text {+ font-size: 12px;+ color: var(--es-text-muted);+}++/* Grid focus */+.es-content-browser-grid:focus {+ outline: none;+}+/* =============================================================================* Status Bar* ============================================================================= */@@ -2174,6 +2319,25 @@ svg {stroke: var(--es-text-secondary);}+.es-status-unsaved {+ color: var(--es-warning, #f0ad4e);+}++.es-unsaved-dot {+ display: inline-block;+ width: 6px;+ height: 6px;+ border-radius: 50%;+ background: var(--es-warning, #f0ad4e);+}++.es-statusbar-message {+ padding: 0 8px;+ font-size: 11px;+ color: var(--es-text-secondary);+ white-space: nowrap;+}+.es-statusbar-icons {display: flex;align-items: center;@@ -2872,6 +3036,44 @@ svg {text-align: right;}+.es-settings-description {+ font-size: 11px;+ color: var(--es-text-secondary);+ margin: 2px 0 6px;+ opacity: 0.7;+}++.es-settings-item-header {+ display: flex;+ align-items: center;+ gap: 6px;+}++.es-settings-item-header .es-settings-label {+ margin-bottom: 0;+}++.es-settings-reset-btn {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 18px;+ height: 18px;+ padding: 0;+ background: transparent;+ border: 1px solid var(--es-border);+ border-radius: 3px;+ color: var(--es-text-secondary);+ font-size: 12px;+ cursor: pointer;+ flex-shrink: 0;+}++.es-settings-reset-btn:hover {+ background: var(--es-bg-hover);+ color: var(--es-text-primary);+}+/* =============================================================================* Add Component Popup* ============================================================================= */@@ -3031,7 +3233,8 @@ svg {margin: 2px 8px;}-.es-component-item:hover {+.es-component-item:hover,+.es-component-item.es-highlighted {background: var(--es-bg-hover);}@@ -3039,10 +3242,18 @@ svg {stroke: var(--es-text-secondary);}-.es-component-item:hover .es-component-icon svg {+.es-component-item:hover .es-component-icon svg,+.es-component-item.es-highlighted .es-component-icon svg {stroke: var(--es-accent);}+.es-component-item mark {+ background: var(--es-accent);+ color: var(--es-bg-primary);+ border-radius: 2px;+ padding: 0 1px;+}+.es-component-name {font-size: 13px;color: var(--es-text-primary);diff --git a/editor/src/ui/Toast.ts b/editor/src/ui/Toast.tsindex 238dca9a0..070a19477 100644--- a/editor/src/ui/Toast.ts+++ b/editor/src/ui/Toast.ts@@ -66,13 +66,17 @@ class ToastManager {toast.innerHTML = `<div class="es-toast-icon">${iconHtml}</div><div class="es-toast-content">- <div class="es-toast-title">${options.title}</div>- ${options.message ? `<div class="es-toast-message">${options.message}</div>` : ''}+ <div class="es-toast-title"></div>+ ${options.message ? `<div class="es-toast-message"></div>` : ''}${progressHtml}${actionsHtml}</div><button class="es-toast-close">${icons.x(12)}</button>`;+ toast.querySelector('.es-toast-title')!.textContent = options.title;+ if (options.message) {+ toast.querySelector('.es-toast-message')!.textContent = options.message;+ }// Event listenerstoast.querySelector('.es-toast-close')?.addEventListener('click', () => {diff --git a/editor/src/utils/icons.ts b/editor/src/utils/icons.tsindex e8eec9399..dfeae9eb3 100644--- a/editor/src/utils/icons.ts+++ b/editor/src/utils/icons.ts@@ -52,6 +52,16 @@ import {EyeOff,Pencil,Package2,+ ArrowUp,+ ArrowDown,+ LayoutGrid,+ LayoutList,+ Zap,+ Film,+ Scan,+ Shield,+ RotateCcw,+ Clipboard,} from 'lucide';// =============================================================================@@ -160,6 +170,16 @@ export const icons = {bone: (size?: number) => renderIcon(Bone as IconNode, size),pencil: (size?: number) => renderIcon(Pencil as IconNode, size),package: (size?: number) => renderIcon(Package2 as IconNode, size),+ arrowUp: (size?: number) => renderIcon(ArrowUp as IconNode, size),+ arrowDown: (size?: number) => renderIcon(ArrowDown as IconNode, size),+ layoutGrid: (size?: number) => renderIcon(LayoutGrid as IconNode, size),+ layoutList: (size?: number) => renderIcon(LayoutList as IconNode, size),+ zap: (size?: number) => renderIcon(Zap as IconNode, size),+ film: (size?: number) => renderIcon(Film as IconNode, size),+ scan: (size?: number) => renderIcon(Scan as IconNode, size),+ shield: (size?: number) => renderIcon(Shield as IconNode, size),+ rotateCcw: (size?: number) => renderIcon(RotateCcw as IconNode, size),+ clipboard: (size?: number) => renderIcon(Clipboard as IconNode, size),};export type IconName = keyof typeof icons;