Skip to content

EditorPanels beta ​

Class of @v12-engine/editor

ts
export declare class EditorPanels

The editor's panels (editor.panels), there as long as the editor is, with its dock or not: their definitions, the editor's own (EDITOR_PANELS), the game's (EditorOptions.panels) and those added in code, in that order. The dock draws what is here, whenever it is there: a panel added, or opened, before the dock is, is drawn (and opened) when it is. What is about the dock itself (its layouts, its sides, pinning) is editor.dock

Members ​

constructor ​

ts
constructor(own: readonly (EditorPanelInfo & {
        search?: EditorPanelDef['search'];
    })[], changed: () => void, 
    bus?: EditorBus);

Constructs a new instance of the EditorPanels class

actionsOf ​

ts
actionsOf(id: string): {
        open: string;
        toggle: string;
    };

The names of the actions that open a panel and that open or close it (open-<id>, toggle-<id>), in editor.keys: for a menu's line, a button, a key

add ​

ts
add(def: EditorPanelDef): () => void;

Adds a panel, or one in the place of the panel of its id (the editor's own too). Gives back what takes it away

api ​

ts
api<K extends string>(id: K): PanelApi<K> | undefined;

What a panel offers the others (panel.provide), while it is open and has: typed by EditorPanelApis

close ​

ts
close(id: string): void;

Closes a panel; or, before the dock is there, does not open it after all

get ​

ts
get(id: string): EditorPanelDef | undefined;

A panel's definition, by its id

handle ​

ts
handle<K extends string>(id: K): EditorPanel<PanelApi<K>> | undefined;

The handle of a panel that is open (EditorPanel). None while it is closed, or while there is no dock

has ​

ts
has(id: string): boolean;

Whether there is a panel of that id

isOwn ​

ts
isOwn(id: string): boolean;

Whether the panel of an id is the editor's own, as it comes (nothing put in its place)

list ​

ts
list(): EditorPanelDef[];

Every panel there is, open or not, in the order they were made known

onAdded ​

ts
onAdded(listener: (def: EditorPanelDef) => void): () => void;

Told of each panel added (or in the place of another). Gives back what stops it

onRemoved ​

ts
onRemoved(listener: (id: string) => void): () => void;

Told of each panel taken away, by its id. Gives back what stops it

open ​

ts
open(id: string, options?: {
        over?: boolean;
    }): void;

Opens a panel: now, or as soon as the dock is there

panelOf ​

ts
panelOf(action: string): EditorPanelDef | undefined;

The panel an action opens or opens and closes (actionsOf), by the action's name

remove ​

ts
remove(id: string): void;

Takes a panel away for good, one of the editor's own too: closed, and its icon gone

reveal ​

ts
reveal(id: string, entry: string): Promise<void>;

Shows one of a panel's entries (EditorPanelDef.search, by the entry's id): the panel opened and brought to the front, then told the id (panel.onReveal). What picking the entry in the search does

when ​

ts
when<K extends string>(id: K, options?: {
        open?: boolean;
    }): Promise<EditorPanel<PanelApi<K>>>;

The handle of a panel once it is open, and what it offers with it: now, or as soon as it opens. With open, it is opened (rejected when there is no such panel); without, it waits for whoever opens it