@widgetstools/dock-manager-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6298 -0
- package/dist/index.d.cts +1478 -0
- package/dist/index.d.ts +1478 -0
- package/dist/index.js +6214 -0
- package/dist/styles/dock-manager.css +632 -0
- package/package.json +60 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1478 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for the dock manager layout system.
|
|
3
|
+
*
|
|
4
|
+
* These types define the shape of the layout tree, panel configuration,
|
|
5
|
+
* floating/popout/unpinned panel state, and dock events.
|
|
6
|
+
*
|
|
7
|
+
* @module dock
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Direction of a split divider.
|
|
11
|
+
* - `'horizontal'` splits children left-to-right.
|
|
12
|
+
* - `'vertical'` splits children top-to-bottom.
|
|
13
|
+
*/
|
|
14
|
+
type SplitDirection = 'horizontal' | 'vertical';
|
|
15
|
+
/**
|
|
16
|
+
* Position for docking a panel relative to a target tab group.
|
|
17
|
+
* - `'center'` adds the panel as a new tab in the group.
|
|
18
|
+
* - `'left' | 'right' | 'top' | 'bottom'` creates a new split beside the target.
|
|
19
|
+
*/
|
|
20
|
+
type DockPosition = 'left' | 'right' | 'top' | 'bottom' | 'center';
|
|
21
|
+
/**
|
|
22
|
+
* Edge of the dock container where an unpinned panel strip can appear.
|
|
23
|
+
* Bottom, left, and right are supported; top is not.
|
|
24
|
+
*/
|
|
25
|
+
type DockEdge = 'left' | 'right' | 'top' | 'bottom';
|
|
26
|
+
/**
|
|
27
|
+
* Position of the tab header bar within a tab group.
|
|
28
|
+
*/
|
|
29
|
+
type HeaderPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for a single panel in the dock manager.
|
|
32
|
+
*
|
|
33
|
+
* Panels are the atomic content units displayed inside tab groups,
|
|
34
|
+
* floating windows, or unpinned strips.
|
|
35
|
+
*/
|
|
36
|
+
interface PanelConfig {
|
|
37
|
+
/** Unique identifier for this panel. */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Display title shown in the tab header. */
|
|
40
|
+
title: string;
|
|
41
|
+
/** Optional icon key or URL rendered beside the title. */
|
|
42
|
+
icon?: string;
|
|
43
|
+
/** If true, prevents ALL user interactions with this pane (drag, close, resize, etc.) */
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
/** Whether the user can close this panel. Defaults to `true`. */
|
|
46
|
+
closable?: boolean;
|
|
47
|
+
/** Whether the user can float this panel into a separate window. Defaults to `true`. */
|
|
48
|
+
floatable?: boolean;
|
|
49
|
+
/** Whether other panels can be docked to this one. Defaults to `true`. */
|
|
50
|
+
allowDocking?: boolean;
|
|
51
|
+
/** Whether to show the maximize button in the tab group header. Defaults to `true`. */
|
|
52
|
+
allowMaximize?: boolean;
|
|
53
|
+
/** Whether to show the pin/unpin button. Defaults to `true`. */
|
|
54
|
+
allowPinning?: boolean;
|
|
55
|
+
/** If `true`, the panel is restricted to the document host area only. Defaults to `false`. */
|
|
56
|
+
documentOnly?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether this panel is currently maximized.
|
|
59
|
+
* @deprecated Use `DockManagerState.maximizedPanelId` instead.
|
|
60
|
+
*/
|
|
61
|
+
isMaximized?: boolean;
|
|
62
|
+
/** Minimum size in pixels (applies to both width and height). */
|
|
63
|
+
minimumSize?: number;
|
|
64
|
+
/** Minimum width in pixels. */
|
|
65
|
+
minimumWidth?: number;
|
|
66
|
+
/** Maximum width in pixels. */
|
|
67
|
+
maximumWidth?: number;
|
|
68
|
+
/** Minimum height in pixels. */
|
|
69
|
+
minimumHeight?: number;
|
|
70
|
+
/** Maximum height in pixels. */
|
|
71
|
+
maximumHeight?: number;
|
|
72
|
+
/** Component key used to resolve the panel's content renderer. */
|
|
73
|
+
content?: string;
|
|
74
|
+
/** Component key used to resolve a custom tab renderer. */
|
|
75
|
+
tabComponent?: string;
|
|
76
|
+
/** Whether this floating panel can be resized. Defaults to true. */
|
|
77
|
+
floatingResizable?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Widget type identifier. Used by the consuming app's widget registry
|
|
80
|
+
* to resolve which component to render in this panel.
|
|
81
|
+
* @example `"chart"`, `"table"`, `"editor"`, `"route"`
|
|
82
|
+
*/
|
|
83
|
+
widgetType?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Widget-specific props/configuration. Passed to the component via PanelApi.
|
|
86
|
+
* Must be JSON-serializable (no functions, no DOM refs).
|
|
87
|
+
* @example `{ symbol: "AAPL", timeframe: "1D" }`
|
|
88
|
+
*/
|
|
89
|
+
widgetProps?: Record<string, unknown>;
|
|
90
|
+
/**
|
|
91
|
+
* Badge text displayed after the panel title (e.g. notification count, unsaved dot).
|
|
92
|
+
* Set via PanelApi.setBadge(). Persists across serialization.
|
|
93
|
+
*/
|
|
94
|
+
badge?: string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Whether this panel is hidden (invisible but not removed from layout).
|
|
97
|
+
* Hidden panels don't render content but retain their position in the tree.
|
|
98
|
+
*/
|
|
99
|
+
hidden?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A leaf node in the layout tree representing a tab group.
|
|
103
|
+
*
|
|
104
|
+
* A tab group displays one or more panels as tabs. Exactly one panel
|
|
105
|
+
* is visible (the `activePanel`) at any time.
|
|
106
|
+
*/
|
|
107
|
+
interface TabGroupNode {
|
|
108
|
+
/** Discriminator for the layout node union. Always `'tabgroup'`. */
|
|
109
|
+
type: 'tabgroup';
|
|
110
|
+
/** Unique identifier for this tab group (e.g. `'tg_abc123'`). */
|
|
111
|
+
id: string;
|
|
112
|
+
/** Ordered list of panel IDs contained in this group. */
|
|
113
|
+
panels: string[];
|
|
114
|
+
/** The panel ID of the currently visible tab. */
|
|
115
|
+
activePanel: string;
|
|
116
|
+
/** Where to render the tab header bar. Defaults to `'top'` if omitted. */
|
|
117
|
+
headerPosition?: HeaderPosition;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A branch node in the layout tree representing a split container.
|
|
121
|
+
*
|
|
122
|
+
* A split node divides its space among two or more child nodes
|
|
123
|
+
* (tab groups or nested splits) separated by draggable dividers.
|
|
124
|
+
*/
|
|
125
|
+
interface SplitNode {
|
|
126
|
+
/** Discriminator for the layout node union. Always `'split'`. */
|
|
127
|
+
type: 'split';
|
|
128
|
+
/** Unique identifier for this split (e.g. `'split_abc123'`). */
|
|
129
|
+
id: string;
|
|
130
|
+
/** Whether children are arranged horizontally or vertically. */
|
|
131
|
+
direction: SplitDirection;
|
|
132
|
+
/** Child layout nodes. Must have at least two entries. */
|
|
133
|
+
children: LayoutNode[];
|
|
134
|
+
/** Size of each child as a percentage. Must sum to 100. */
|
|
135
|
+
sizes: number[];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A node in the layout tree. Either a leaf {@link TabGroupNode} or
|
|
139
|
+
* a branch {@link SplitNode}.
|
|
140
|
+
*/
|
|
141
|
+
type LayoutNode = TabGroupNode | SplitNode;
|
|
142
|
+
/**
|
|
143
|
+
* Describes a panel that has been detached from the layout tree
|
|
144
|
+
* and is rendered as a draggable, resizable floating window.
|
|
145
|
+
*/
|
|
146
|
+
interface FloatingPanel {
|
|
147
|
+
/** The ID of the panel being floated. */
|
|
148
|
+
panelId: string;
|
|
149
|
+
/** Horizontal offset in pixels from the dock container's left edge. */
|
|
150
|
+
x: number;
|
|
151
|
+
/** Vertical offset in pixels from the dock container's top edge. */
|
|
152
|
+
y: number;
|
|
153
|
+
/** Width of the floating window in pixels. */
|
|
154
|
+
width: number;
|
|
155
|
+
/** Height of the floating window in pixels. */
|
|
156
|
+
height: number;
|
|
157
|
+
/** CSS z-index controlling stacking order among floating panels. */
|
|
158
|
+
zIndex: number;
|
|
159
|
+
/** The tab group ID this panel was in before being floated. Used to dock back to original location. */
|
|
160
|
+
sourceTabGroupId?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Describes a panel rendered in a separate browser window (popout).
|
|
164
|
+
*/
|
|
165
|
+
interface PopoutPanel {
|
|
166
|
+
/** The ID of the panel shown in the popout window. */
|
|
167
|
+
panelId: string;
|
|
168
|
+
/** The `window.name` of the popout browser window. */
|
|
169
|
+
windowName: string;
|
|
170
|
+
/** Horizontal screen position of the popout window in pixels. */
|
|
171
|
+
x: number;
|
|
172
|
+
/** Vertical screen position of the popout window in pixels. */
|
|
173
|
+
y: number;
|
|
174
|
+
/** Width of the popout window in pixels. */
|
|
175
|
+
width: number;
|
|
176
|
+
/** Height of the popout window in pixels. */
|
|
177
|
+
height: number;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Describes a panel that has been unpinned from the layout and is
|
|
181
|
+
* rendered as an auto-hide strip along a container edge.
|
|
182
|
+
*/
|
|
183
|
+
interface UnpinnedPanel {
|
|
184
|
+
/** The ID of the unpinned panel. */
|
|
185
|
+
panelId: string;
|
|
186
|
+
/** The edge of the dock container where the strip is rendered. */
|
|
187
|
+
edge: DockEdge;
|
|
188
|
+
/** Width (for left/right edges) or height (for bottom) in pixels when expanded. */
|
|
189
|
+
size: number;
|
|
190
|
+
/** The tab group ID the panel was removed from (used to restore on pin-back). */
|
|
191
|
+
sourceTabGroupId?: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Complete state of the dock manager.
|
|
195
|
+
*
|
|
196
|
+
* This is the single source of truth for layout, panel configuration,
|
|
197
|
+
* floating windows, popouts, and unpinned strips. It is fully serializable
|
|
198
|
+
* and can be persisted/restored via `LOAD_STATE`.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* const state: DockManagerState = createDefaultState();
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
interface DockManagerState {
|
|
206
|
+
/** The root of the layout tree describing docked panels. */
|
|
207
|
+
layout: LayoutNode;
|
|
208
|
+
/** Map of panel ID to its configuration. */
|
|
209
|
+
panels: Record<string, PanelConfig>;
|
|
210
|
+
/** Panels currently rendered as floating windows. */
|
|
211
|
+
floatingPanels: FloatingPanel[];
|
|
212
|
+
/** Panels currently rendered in separate browser windows. */
|
|
213
|
+
popoutPanels: PopoutPanel[];
|
|
214
|
+
/** Panels removed from the layout and shown as auto-hide strips. */
|
|
215
|
+
unpinnedPanels: UnpinnedPanel[];
|
|
216
|
+
/** Counter used to assign z-index values to floating panels. */
|
|
217
|
+
nextZIndex: number;
|
|
218
|
+
/** The panel ID that is currently focused (shown with an active indicator). */
|
|
219
|
+
activePaneId: string;
|
|
220
|
+
/** The panel ID currently displayed in maximized (full-container) mode, if any. */
|
|
221
|
+
maximizedPanelId?: string;
|
|
222
|
+
}
|
|
223
|
+
/** Discriminated event type identifiers emitted by the dock manager. */
|
|
224
|
+
type DockEventType = 'paneClose' | 'paneDragStart' | 'paneDragOver' | 'paneDragEnd' | 'activePaneChanged' | 'splitterResizeStart' | 'splitterResizeEnd' | 'layoutChanged' | 'paneMaximized' | 'paneRestored' | 'willDrop' | 'willFocus' | 'willClose' | 'willMaximize';
|
|
225
|
+
/** Base dock manager event. */
|
|
226
|
+
interface DockEvent {
|
|
227
|
+
/** The event type identifier. */
|
|
228
|
+
type: DockEventType;
|
|
229
|
+
/** The panel associated with this event, if any. */
|
|
230
|
+
panelId?: string;
|
|
231
|
+
/** Whether the event was cancelled by a listener. */
|
|
232
|
+
cancelled?: boolean;
|
|
233
|
+
}
|
|
234
|
+
/** An event that can be prevented from executing its default behavior */
|
|
235
|
+
interface PreventableDockEvent extends DockEvent {
|
|
236
|
+
defaultPrevented: boolean;
|
|
237
|
+
preventDefault(): void;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Create a {@link PreventableDockEvent} that listeners can cancel
|
|
241
|
+
* by calling `event.preventDefault()`.
|
|
242
|
+
*
|
|
243
|
+
* @param type - The event type identifier.
|
|
244
|
+
* @param panelId - Optional panel ID associated with the event.
|
|
245
|
+
* @returns A new preventable event instance.
|
|
246
|
+
*/
|
|
247
|
+
declare function createPreventableEvent(type: DockEventType, panelId?: string): PreventableDockEvent;
|
|
248
|
+
/** Aggregated size constraints for a layout node, derived from its children. */
|
|
249
|
+
interface LayoutConstraints {
|
|
250
|
+
/** Minimum width in pixels. */
|
|
251
|
+
minimumWidth?: number;
|
|
252
|
+
/** Maximum width in pixels. */
|
|
253
|
+
maximumWidth?: number;
|
|
254
|
+
/** Minimum height in pixels. */
|
|
255
|
+
minimumHeight?: number;
|
|
256
|
+
/** Maximum height in pixels. */
|
|
257
|
+
maximumHeight?: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Resource strings for localization of dock manager UI elements.
|
|
262
|
+
*
|
|
263
|
+
* Consumers can provide partial overrides via `DockviewComponentOptions.resourceStrings`.
|
|
264
|
+
*/
|
|
265
|
+
interface DockResourceStrings {
|
|
266
|
+
close: string;
|
|
267
|
+
closeOthers: string;
|
|
268
|
+
closeAll: string;
|
|
269
|
+
float: string;
|
|
270
|
+
pin: string;
|
|
271
|
+
unpin: string;
|
|
272
|
+
maximize: string;
|
|
273
|
+
restore: string;
|
|
274
|
+
dock: string;
|
|
275
|
+
}
|
|
276
|
+
declare const defaultResourceStrings: DockResourceStrings;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Dock Manager Reducer
|
|
280
|
+
*
|
|
281
|
+
* Pure reducer function for immutable state management.
|
|
282
|
+
* Uses LayoutTree module for all tree operations.
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
type DockAction = {
|
|
286
|
+
type: 'ADD_PANEL';
|
|
287
|
+
payload: {
|
|
288
|
+
panelId: string;
|
|
289
|
+
title: string;
|
|
290
|
+
icon?: string;
|
|
291
|
+
closable?: boolean;
|
|
292
|
+
floatable?: boolean;
|
|
293
|
+
tabComponent?: string;
|
|
294
|
+
widgetType?: string;
|
|
295
|
+
widgetProps?: Record<string, unknown>;
|
|
296
|
+
};
|
|
297
|
+
} | {
|
|
298
|
+
type: 'MOVE_PANEL';
|
|
299
|
+
payload: {
|
|
300
|
+
panelId: string;
|
|
301
|
+
targetTabGroupId: string;
|
|
302
|
+
position: DockPosition;
|
|
303
|
+
};
|
|
304
|
+
} | {
|
|
305
|
+
type: 'CLOSE_PANEL';
|
|
306
|
+
payload: {
|
|
307
|
+
panelId: string;
|
|
308
|
+
};
|
|
309
|
+
} | {
|
|
310
|
+
type: 'FLOAT_PANEL';
|
|
311
|
+
payload: {
|
|
312
|
+
panelId: string;
|
|
313
|
+
x: number;
|
|
314
|
+
y: number;
|
|
315
|
+
width: number;
|
|
316
|
+
height: number;
|
|
317
|
+
};
|
|
318
|
+
} | {
|
|
319
|
+
type: 'DOCK_FLOATING';
|
|
320
|
+
payload: {
|
|
321
|
+
panelId: string;
|
|
322
|
+
targetTabGroupId: string;
|
|
323
|
+
position: DockPosition;
|
|
324
|
+
};
|
|
325
|
+
} | {
|
|
326
|
+
type: 'UPDATE_FLOATING';
|
|
327
|
+
payload: {
|
|
328
|
+
panelId: string;
|
|
329
|
+
x?: number;
|
|
330
|
+
y?: number;
|
|
331
|
+
width?: number;
|
|
332
|
+
height?: number;
|
|
333
|
+
};
|
|
334
|
+
} | {
|
|
335
|
+
type: 'SET_ACTIVE_PANEL';
|
|
336
|
+
payload: {
|
|
337
|
+
tabGroupId: string;
|
|
338
|
+
panelId: string;
|
|
339
|
+
};
|
|
340
|
+
} | {
|
|
341
|
+
type: 'RESIZE_SPLIT';
|
|
342
|
+
payload: {
|
|
343
|
+
splitId: string;
|
|
344
|
+
sizes: number[];
|
|
345
|
+
};
|
|
346
|
+
} | {
|
|
347
|
+
type: 'BRING_TO_FRONT';
|
|
348
|
+
payload: {
|
|
349
|
+
panelId: string;
|
|
350
|
+
};
|
|
351
|
+
} | {
|
|
352
|
+
type: 'UNPIN_PANEL';
|
|
353
|
+
payload: {
|
|
354
|
+
panelId: string;
|
|
355
|
+
};
|
|
356
|
+
} | {
|
|
357
|
+
type: 'PIN_PANEL';
|
|
358
|
+
payload: {
|
|
359
|
+
panelId: string;
|
|
360
|
+
};
|
|
361
|
+
} | {
|
|
362
|
+
type: 'LOAD_STATE';
|
|
363
|
+
payload: DockManagerState;
|
|
364
|
+
} | {
|
|
365
|
+
type: 'MAXIMIZE_PANEL';
|
|
366
|
+
payload: {
|
|
367
|
+
panelId: string;
|
|
368
|
+
};
|
|
369
|
+
} | {
|
|
370
|
+
type: 'RESTORE_PANEL';
|
|
371
|
+
payload: {
|
|
372
|
+
panelId: string;
|
|
373
|
+
};
|
|
374
|
+
} | {
|
|
375
|
+
type: 'SET_ACTIVE_PANE';
|
|
376
|
+
payload: {
|
|
377
|
+
panelId: string;
|
|
378
|
+
};
|
|
379
|
+
} | {
|
|
380
|
+
type: 'UPDATE_PANEL_CONFIG';
|
|
381
|
+
payload: {
|
|
382
|
+
panelId: string;
|
|
383
|
+
updates: Partial<PanelConfig>;
|
|
384
|
+
};
|
|
385
|
+
} | {
|
|
386
|
+
type: 'POPOUT_PANEL';
|
|
387
|
+
payload: {
|
|
388
|
+
panelId: string;
|
|
389
|
+
windowName: string;
|
|
390
|
+
x: number;
|
|
391
|
+
y: number;
|
|
392
|
+
width: number;
|
|
393
|
+
height: number;
|
|
394
|
+
};
|
|
395
|
+
} | {
|
|
396
|
+
type: 'DOCK_POPOUT';
|
|
397
|
+
payload: {
|
|
398
|
+
panelId: string;
|
|
399
|
+
targetTabGroupId: string;
|
|
400
|
+
position: DockPosition;
|
|
401
|
+
};
|
|
402
|
+
} | {
|
|
403
|
+
type: 'UPDATE_POPOUT';
|
|
404
|
+
payload: {
|
|
405
|
+
panelId: string;
|
|
406
|
+
x?: number;
|
|
407
|
+
y?: number;
|
|
408
|
+
width?: number;
|
|
409
|
+
height?: number;
|
|
410
|
+
};
|
|
411
|
+
} | {
|
|
412
|
+
type: 'SET_HEADER_POSITION';
|
|
413
|
+
payload: {
|
|
414
|
+
tabGroupId: string;
|
|
415
|
+
headerPosition: HeaderPosition | undefined;
|
|
416
|
+
};
|
|
417
|
+
} | {
|
|
418
|
+
type: 'NAVIGATE';
|
|
419
|
+
payload: {
|
|
420
|
+
direction: 'next' | 'previous';
|
|
421
|
+
};
|
|
422
|
+
} | {
|
|
423
|
+
type: 'ACTIVATE_OVERFLOW_TAB';
|
|
424
|
+
payload: {
|
|
425
|
+
tabGroupId: string;
|
|
426
|
+
panelId: string;
|
|
427
|
+
};
|
|
428
|
+
} | {
|
|
429
|
+
type: 'DOCK_TO_EDGE';
|
|
430
|
+
payload: {
|
|
431
|
+
panelId: string;
|
|
432
|
+
edge: DockPosition;
|
|
433
|
+
};
|
|
434
|
+
} | {
|
|
435
|
+
type: 'REORDER_TABS';
|
|
436
|
+
payload: {
|
|
437
|
+
tabGroupId: string;
|
|
438
|
+
panelId: string;
|
|
439
|
+
newIndex: number;
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
declare function dockReducer(state: DockManagerState, action: DockAction): DockManagerState;
|
|
443
|
+
declare function validateState(state: DockManagerState): DockManagerState;
|
|
444
|
+
declare function createDefaultState(): DockManagerState;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Options for adding a new panel via {@link DockviewApi.addPanel}.
|
|
448
|
+
*/
|
|
449
|
+
interface AddPanelOptions {
|
|
450
|
+
/** Unique identifier for the new panel. Use `id` or `panelId`. */
|
|
451
|
+
id?: string;
|
|
452
|
+
/** Unique identifier for the new panel. Alias for `id`. */
|
|
453
|
+
panelId?: string;
|
|
454
|
+
/** Display title shown in the tab header. */
|
|
455
|
+
title: string;
|
|
456
|
+
/** Optional icon key or URL rendered beside the title. */
|
|
457
|
+
icon?: string;
|
|
458
|
+
/** Whether the panel can be closed by the user. Defaults to `true`. */
|
|
459
|
+
closable?: boolean;
|
|
460
|
+
/** Whether the panel can be floated by the user. Defaults to `true`. */
|
|
461
|
+
floatable?: boolean;
|
|
462
|
+
/** Component key for a custom tab renderer. */
|
|
463
|
+
tabComponent?: string;
|
|
464
|
+
/** Widget type identifier for the widget registry. */
|
|
465
|
+
widgetType?: string;
|
|
466
|
+
/** Widget-specific props/configuration (must be JSON-serializable). */
|
|
467
|
+
widgetProps?: Record<string, unknown>;
|
|
468
|
+
/** Target tab group to add to. If omitted, adds to the first tab group. */
|
|
469
|
+
targetGroupId?: string;
|
|
470
|
+
/** Position relative to the target group. Defaults to `'center'` (add as tab). */
|
|
471
|
+
position?: DockPosition;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Options for floating a panel via {@link DockviewApi.floatPanel}.
|
|
475
|
+
*/
|
|
476
|
+
interface FloatPanelOptions {
|
|
477
|
+
/** The ID of the panel to float. */
|
|
478
|
+
panelId: string;
|
|
479
|
+
/** Horizontal offset in pixels from the container's left edge. Defaults to `100`. */
|
|
480
|
+
x?: number;
|
|
481
|
+
/** Vertical offset in pixels from the container's top edge. Defaults to `100`. */
|
|
482
|
+
y?: number;
|
|
483
|
+
/** Width of the floating window in pixels. Defaults to `400`. */
|
|
484
|
+
width?: number;
|
|
485
|
+
/** Height of the floating window in pixels. Defaults to `300`. */
|
|
486
|
+
height?: number;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Options for moving a panel via {@link DockviewApi.movePanel}.
|
|
490
|
+
*/
|
|
491
|
+
interface MovePanelOptions {
|
|
492
|
+
/** The ID of the panel to move. */
|
|
493
|
+
panelId: string;
|
|
494
|
+
/** The target tab group to move the panel into. */
|
|
495
|
+
targetGroupId: string;
|
|
496
|
+
/** Where to place the panel relative to the target group. */
|
|
497
|
+
position: DockPosition;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Typed, high-level API for programmatic control of the dock manager.
|
|
501
|
+
*
|
|
502
|
+
* Wraps the low-level reducer dispatch with validated, documented methods.
|
|
503
|
+
* Use this instead of dispatching raw {@link DockAction} objects directly.
|
|
504
|
+
*
|
|
505
|
+
* The API is stateless itself -- it reads from and writes to the state
|
|
506
|
+
* via the `getState` and `dispatch` callbacks provided at construction time.
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* ```ts
|
|
510
|
+
* const api = new DockviewApi(getState, dispatch);
|
|
511
|
+
* api.addPanel({ id: 'editor', title: 'Editor' });
|
|
512
|
+
* api.movePanel({ panelId: 'editor', targetGroupId: 'tg_right', position: 'center' });
|
|
513
|
+
* api.floatPanel({ panelId: 'editor', x: 100, y: 100, width: 400, height: 300 });
|
|
514
|
+
* api.closePanel('editor');
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
declare class DockviewApi {
|
|
518
|
+
private readonly getState;
|
|
519
|
+
private readonly dispatch;
|
|
520
|
+
private readonly _onUndo?;
|
|
521
|
+
private readonly _onRedo?;
|
|
522
|
+
/**
|
|
523
|
+
* @param getState - Returns the current {@link DockManagerState} snapshot.
|
|
524
|
+
* @param dispatch - Sends a {@link DockAction} to mutate state.
|
|
525
|
+
* @param _onUndo - Optional undo callback wired by DockviewComponent.
|
|
526
|
+
* @param _onRedo - Optional redo callback wired by DockviewComponent.
|
|
527
|
+
*/
|
|
528
|
+
constructor(getState: () => DockManagerState, dispatch: (action: DockAction) => void, _onUndo?: (() => void) | undefined, _onRedo?: (() => void) | undefined);
|
|
529
|
+
/** Get the current dock manager state (read-only snapshot) */
|
|
530
|
+
get state(): Readonly<DockManagerState>;
|
|
531
|
+
/** Get the currently active pane's panel ID */
|
|
532
|
+
get activePanelId(): string;
|
|
533
|
+
/** Get the currently maximized panel ID, or undefined */
|
|
534
|
+
get maximizedPanelId(): string | undefined;
|
|
535
|
+
/**
|
|
536
|
+
* Get a panel's configuration by ID.
|
|
537
|
+
*
|
|
538
|
+
* @param panelId - The panel to look up.
|
|
539
|
+
* @returns The panel config, or `undefined` if no panel with that ID exists.
|
|
540
|
+
*/
|
|
541
|
+
getPanel(panelId: string): PanelConfig | undefined;
|
|
542
|
+
/**
|
|
543
|
+
* Get all panel IDs in the docked layout tree (excludes floating and unpinned panels).
|
|
544
|
+
*
|
|
545
|
+
* @returns Panel IDs in depth-first order.
|
|
546
|
+
*/
|
|
547
|
+
getLayoutPanelIds(): string[];
|
|
548
|
+
/** Get all panel IDs across the entire dock manager */
|
|
549
|
+
getAllPanelIds(): string[];
|
|
550
|
+
/** Get the total number of panels */
|
|
551
|
+
get panelCount(): number;
|
|
552
|
+
/**
|
|
553
|
+
* Check if a panel exists in the dock manager.
|
|
554
|
+
*
|
|
555
|
+
* @param panelId - The panel ID to check.
|
|
556
|
+
* @returns `true` if the panel is registered (regardless of placement).
|
|
557
|
+
*/
|
|
558
|
+
hasPanel(panelId: string): boolean;
|
|
559
|
+
/**
|
|
560
|
+
* Check if a panel is placed somewhere visible (in the layout tree, floating, or unpinned).
|
|
561
|
+
*
|
|
562
|
+
* @param panelId - The panel ID to check.
|
|
563
|
+
* @returns `true` if the panel occupies a slot in the UI.
|
|
564
|
+
*/
|
|
565
|
+
isPanelPlaced(panelId: string): boolean;
|
|
566
|
+
/**
|
|
567
|
+
* Get the tab group ID that contains a given panel.
|
|
568
|
+
*
|
|
569
|
+
* @param panelId - The panel to search for.
|
|
570
|
+
* @returns The containing tab group ID, or `null` if the panel is not in any group.
|
|
571
|
+
*/
|
|
572
|
+
getGroupForPanel(panelId: string): string | null;
|
|
573
|
+
/**
|
|
574
|
+
* Get a tab group by its ID.
|
|
575
|
+
*
|
|
576
|
+
* @param groupId - The tab group ID.
|
|
577
|
+
* @returns The tab group node, or `null` if not found.
|
|
578
|
+
*/
|
|
579
|
+
getGroup(groupId: string): TabGroupNode | null;
|
|
580
|
+
/** Get all tab groups */
|
|
581
|
+
getAllGroups(): TabGroupNode[];
|
|
582
|
+
/** Get all floating panels */
|
|
583
|
+
getFloatingPanels(): readonly FloatingPanel[];
|
|
584
|
+
/**
|
|
585
|
+
* Check if a panel is currently rendered as a floating window.
|
|
586
|
+
*
|
|
587
|
+
* @param panelId - The panel ID to check.
|
|
588
|
+
* @returns `true` if the panel is floating.
|
|
589
|
+
*/
|
|
590
|
+
isFloating(panelId: string): boolean;
|
|
591
|
+
/** Check if a panel is the active pane */
|
|
592
|
+
isActive(panelId: string): boolean;
|
|
593
|
+
/** Check if a panel is maximized */
|
|
594
|
+
isMaximized(panelId: string): boolean;
|
|
595
|
+
/** Get the layout tree */
|
|
596
|
+
get layout(): LayoutNode;
|
|
597
|
+
/**
|
|
598
|
+
* Add a new panel to the dock manager.
|
|
599
|
+
*
|
|
600
|
+
* By default the panel is inserted as a new tab in the first tab group.
|
|
601
|
+
* Use `targetGroupId` and `position` to control placement.
|
|
602
|
+
*
|
|
603
|
+
* @param options - Panel creation and placement options.
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```ts
|
|
607
|
+
* api.addPanel({ id: 'terminal', title: 'Terminal', closable: true });
|
|
608
|
+
* api.addPanel({ id: 'output', title: 'Output', targetGroupId: 'tg_2', position: 'bottom' });
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
addPanel(options: AddPanelOptions): void;
|
|
612
|
+
/**
|
|
613
|
+
* Remove a panel from the dock manager entirely.
|
|
614
|
+
*
|
|
615
|
+
* The panel is removed from the layout tree, floating list, and unpinned list,
|
|
616
|
+
* and its {@link PanelConfig} is deleted.
|
|
617
|
+
*
|
|
618
|
+
* @param panelId - The ID of the panel to close.
|
|
619
|
+
*/
|
|
620
|
+
closePanel(panelId: string): void;
|
|
621
|
+
/**
|
|
622
|
+
* Move a panel to a different location in the layout.
|
|
623
|
+
*
|
|
624
|
+
* @param options - Target group and position for the move.
|
|
625
|
+
*/
|
|
626
|
+
movePanel(options: MovePanelOptions): void;
|
|
627
|
+
/**
|
|
628
|
+
* Set the active (visible) panel within a tab group, switching the displayed tab.
|
|
629
|
+
*
|
|
630
|
+
* @param groupId - The tab group containing the panel.
|
|
631
|
+
* @param panelId - The panel to make active.
|
|
632
|
+
*/
|
|
633
|
+
setActivePanel(groupId: string, panelId: string): void;
|
|
634
|
+
/**
|
|
635
|
+
* Set the globally active pane (highlighted with the focus indicator).
|
|
636
|
+
*
|
|
637
|
+
* @param panelId - The panel to focus.
|
|
638
|
+
*/
|
|
639
|
+
setActivePane(panelId: string): void;
|
|
640
|
+
/**
|
|
641
|
+
* Update a panel's configuration (title, icon, closable, etc.).
|
|
642
|
+
*
|
|
643
|
+
* Only the provided fields are merged; unspecified fields remain unchanged.
|
|
644
|
+
*
|
|
645
|
+
* @param panelId - The panel to update.
|
|
646
|
+
* @param updates - Partial config to merge.
|
|
647
|
+
*/
|
|
648
|
+
updatePanel(panelId: string, updates: Partial<PanelConfig>): void;
|
|
649
|
+
/**
|
|
650
|
+
* Float a panel by removing it from the layout tree and rendering it
|
|
651
|
+
* as a draggable, resizable floating window.
|
|
652
|
+
*
|
|
653
|
+
* @param options - Position and size for the floating window.
|
|
654
|
+
*/
|
|
655
|
+
floatPanel(options: FloatPanelOptions): void;
|
|
656
|
+
/**
|
|
657
|
+
* Dock a floating panel back into the layout tree.
|
|
658
|
+
*
|
|
659
|
+
* @param panelId - The floating panel to dock.
|
|
660
|
+
* @param targetGroupId - The tab group to dock into. Defaults to `'default'` (first group).
|
|
661
|
+
* @param position - Where to place it relative to the target. Defaults to `'center'`.
|
|
662
|
+
*/
|
|
663
|
+
dockFloatingPanel(panelId: string, targetGroupId?: string, position?: DockPosition): void;
|
|
664
|
+
/**
|
|
665
|
+
* Update a floating panel's position and/or size.
|
|
666
|
+
*
|
|
667
|
+
* @param panelId - The floating panel to update.
|
|
668
|
+
* @param updates - Partial position/size values to merge.
|
|
669
|
+
*/
|
|
670
|
+
updateFloatingPanel(panelId: string, updates: {
|
|
671
|
+
x?: number;
|
|
672
|
+
y?: number;
|
|
673
|
+
width?: number;
|
|
674
|
+
height?: number;
|
|
675
|
+
}): void;
|
|
676
|
+
/**
|
|
677
|
+
* Bring a floating panel to the front by assigning it the highest z-index.
|
|
678
|
+
*
|
|
679
|
+
* @param panelId - The floating panel to bring forward.
|
|
680
|
+
*/
|
|
681
|
+
bringToFront(panelId: string): void;
|
|
682
|
+
/**
|
|
683
|
+
* Maximize a panel so it occupies the full container space.
|
|
684
|
+
*
|
|
685
|
+
* @param panelId - The panel to maximize.
|
|
686
|
+
*/
|
|
687
|
+
maximizePanel(panelId: string): void;
|
|
688
|
+
/** Restore the maximized panel to its original position */
|
|
689
|
+
restorePanel(): void;
|
|
690
|
+
/**
|
|
691
|
+
* Toggle maximize state for a panel. Maximizes if not already maximized,
|
|
692
|
+
* restores if it is.
|
|
693
|
+
*
|
|
694
|
+
* @param panelId - The panel to toggle.
|
|
695
|
+
*/
|
|
696
|
+
toggleMaximize(panelId: string): void;
|
|
697
|
+
/** Navigate to the next panel (Ctrl+Tab behavior) */
|
|
698
|
+
navigateNext(): void;
|
|
699
|
+
/** Navigate to the previous panel (Ctrl+Shift+Tab behavior) */
|
|
700
|
+
navigatePrevious(): void;
|
|
701
|
+
/**
|
|
702
|
+
* Resize the children of a split node.
|
|
703
|
+
*
|
|
704
|
+
* @param splitId - The split node to resize.
|
|
705
|
+
* @param sizes - New size percentages for each child. Must sum to 100.
|
|
706
|
+
*/
|
|
707
|
+
resizeSplit(splitId: string, sizes: number[]): void;
|
|
708
|
+
/**
|
|
709
|
+
* Set the header (tab bar) position for a tab group.
|
|
710
|
+
*
|
|
711
|
+
* @param groupId - The tab group to update.
|
|
712
|
+
* @param position - The new header position, or `undefined` to reset to default.
|
|
713
|
+
*/
|
|
714
|
+
setHeaderPosition(groupId: string, position: HeaderPosition | undefined): void;
|
|
715
|
+
/**
|
|
716
|
+
* Unpin a panel, removing it from the layout tree and displaying it
|
|
717
|
+
* as an auto-hide strip along the nearest edge.
|
|
718
|
+
*
|
|
719
|
+
* @param panelId - The panel to unpin.
|
|
720
|
+
*/
|
|
721
|
+
unpinPanel(panelId: string): void;
|
|
722
|
+
/**
|
|
723
|
+
* Pin an unpinned panel back into the layout tree as a tab in the first group.
|
|
724
|
+
*
|
|
725
|
+
* @param panelId - The unpinned panel to restore.
|
|
726
|
+
*/
|
|
727
|
+
pinPanel(panelId: string): void;
|
|
728
|
+
/**
|
|
729
|
+
* Replace the entire dock manager state (e.g., to restore a serialized layout).
|
|
730
|
+
*
|
|
731
|
+
* The state is validated and repaired before being applied.
|
|
732
|
+
*
|
|
733
|
+
* @param state - The complete state to load.
|
|
734
|
+
*/
|
|
735
|
+
loadState(state: DockManagerState): void;
|
|
736
|
+
/** Close all panels */
|
|
737
|
+
closeAllPanels(): void;
|
|
738
|
+
/** Undo the last state change. */
|
|
739
|
+
undo(): void;
|
|
740
|
+
/** Redo a previously undone state change. */
|
|
741
|
+
redo(): void;
|
|
742
|
+
private presets;
|
|
743
|
+
/** Reset layout to a given default state. */
|
|
744
|
+
resetLayout(defaultState: DockManagerState): void;
|
|
745
|
+
/** Save the current state as a named preset. Returns the preset object. */
|
|
746
|
+
savePreset(name: string): {
|
|
747
|
+
name: string;
|
|
748
|
+
state: DockManagerState;
|
|
749
|
+
};
|
|
750
|
+
/** Load a previously saved preset. */
|
|
751
|
+
loadPreset(preset: {
|
|
752
|
+
name: string;
|
|
753
|
+
state: DockManagerState;
|
|
754
|
+
}): void;
|
|
755
|
+
/** Get all saved presets. */
|
|
756
|
+
getPresets(): {
|
|
757
|
+
name: string;
|
|
758
|
+
state: DockManagerState;
|
|
759
|
+
}[];
|
|
760
|
+
/** Dock all floating panels back into the layout. */
|
|
761
|
+
dockAllFloating(): void;
|
|
762
|
+
/** Export the current state as a base64 URL-safe string. */
|
|
763
|
+
exportAsUrl(): string;
|
|
764
|
+
/** Import state from a base64 URL-safe string. */
|
|
765
|
+
importFromUrl(urlString: string): void;
|
|
766
|
+
private _debugMode;
|
|
767
|
+
private _debugOverlayHandler;
|
|
768
|
+
/** Enable/disable debug overlay showing group IDs, panel IDs, split ratios. */
|
|
769
|
+
setDebugMode(enabled: boolean): void;
|
|
770
|
+
/** @internal Set the debug overlay handler (called by DockviewComponent). */
|
|
771
|
+
_setDebugOverlayHandler(handler: (enabled: boolean) => void): void;
|
|
772
|
+
/** Whether debug mode is currently enabled. */
|
|
773
|
+
get debugMode(): boolean;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* PanelApi — Per-panel API for widget-to-header communication.
|
|
778
|
+
*
|
|
779
|
+
* Each panel receives a PanelApi instance via the `createContent` callback.
|
|
780
|
+
* Widgets use this API to manipulate their own pane header at runtime
|
|
781
|
+
* (change title, add icons, show badges, request attention).
|
|
782
|
+
*
|
|
783
|
+
* All changes are reflected in the state (PanelConfig) so they persist
|
|
784
|
+
* across serialization/deserialization.
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
type DisposeCallback = () => void;
|
|
788
|
+
type VisibilityCallback = (visible: boolean) => void;
|
|
789
|
+
declare class PanelApi {
|
|
790
|
+
/** Panel identity (read-only) */
|
|
791
|
+
readonly panelId: string;
|
|
792
|
+
private _disposed;
|
|
793
|
+
private _visible;
|
|
794
|
+
private _disposeCallbacks;
|
|
795
|
+
private _visibilityCallbacks;
|
|
796
|
+
private _onUpdateConfig;
|
|
797
|
+
private _onRequestAttention;
|
|
798
|
+
private _getConfig;
|
|
799
|
+
constructor(panelId: string);
|
|
800
|
+
/** Get the widget type string */
|
|
801
|
+
get widgetType(): string;
|
|
802
|
+
/** Get the widget props */
|
|
803
|
+
get widgetProps(): Record<string, unknown>;
|
|
804
|
+
/** Get the current panel title */
|
|
805
|
+
getTitle(): string;
|
|
806
|
+
/** Set the panel title (updates tab header text) */
|
|
807
|
+
setTitle(title: string): void;
|
|
808
|
+
/** Set the panel icon (prefix before title text) */
|
|
809
|
+
setIcon(icon: string | null): void;
|
|
810
|
+
/**
|
|
811
|
+
* Set a badge on the panel tab (notification count, unsaved dot, etc.)
|
|
812
|
+
* @param badge - Badge text (e.g. "3", "!", "●"), or null to clear
|
|
813
|
+
*/
|
|
814
|
+
setBadge(badge: string | null): void;
|
|
815
|
+
/**
|
|
816
|
+
* Request attention for this panel (triggers a CSS pulse animation on the tab).
|
|
817
|
+
* Call with `false` to clear the attention state.
|
|
818
|
+
*/
|
|
819
|
+
setAttention(attention: boolean): void;
|
|
820
|
+
/** Set the hidden state (hide without removing from layout) */
|
|
821
|
+
setHidden(hidden: boolean): void;
|
|
822
|
+
/** Check if the panel is currently hidden */
|
|
823
|
+
get isHidden(): boolean;
|
|
824
|
+
/**
|
|
825
|
+
* Update widget props (partial merge). Triggers state update + re-serialization.
|
|
826
|
+
* @param props - Partial props to merge into existing widgetProps
|
|
827
|
+
*/
|
|
828
|
+
updateProps(props: Partial<Record<string, unknown>>): void;
|
|
829
|
+
/** Register a callback to be called when the panel is closed/disposed */
|
|
830
|
+
onDidDispose(callback: DisposeCallback): void;
|
|
831
|
+
/** Register a callback for visibility changes (hidden/shown) */
|
|
832
|
+
onDidChangeVisibility(callback: VisibilityCallback): void;
|
|
833
|
+
/** Check if the panel content is currently visible */
|
|
834
|
+
get isVisible(): boolean;
|
|
835
|
+
/** @internal Set the config accessor */
|
|
836
|
+
_setConfigAccessor(getConfig: () => PanelConfig | undefined): void;
|
|
837
|
+
/** @internal Set the update handler */
|
|
838
|
+
_setUpdateHandler(handler: (panelId: string, updates: Partial<PanelConfig>) => void): void;
|
|
839
|
+
/** @internal Set the attention handler */
|
|
840
|
+
_setAttentionHandler(handler: (panelId: string, attention: boolean) => void): void;
|
|
841
|
+
/** @internal Notify visibility change */
|
|
842
|
+
_setVisible(visible: boolean): void;
|
|
843
|
+
/** @internal Dispose this API (called when panel is closed) */
|
|
844
|
+
_dispose(): void;
|
|
845
|
+
private _updateConfig;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Dock Manager Theme System
|
|
850
|
+
*
|
|
851
|
+
* Themes are plain objects that define all visual properties.
|
|
852
|
+
* The DockviewComponent applies themes by setting CSS custom properties
|
|
853
|
+
* on its container element, so themes are scoped and don't leak globally.
|
|
854
|
+
*
|
|
855
|
+
* Users can:
|
|
856
|
+
* 1. Use a built-in theme: `theme: themes.vsCodeLight`
|
|
857
|
+
* 2. Create a custom theme: `theme: { name: 'custom', mode: 'light', colors: { ... } }`
|
|
858
|
+
* 3. Extend a built-in theme: `theme: { ...themes.vsCodeLight, colors: { ...themes.vsCodeLight.colors, primary: '#ff0000' } }`
|
|
859
|
+
*/
|
|
860
|
+
interface DockThemeColors {
|
|
861
|
+
/** Main background behind all panels */
|
|
862
|
+
bg: string;
|
|
863
|
+
/** Panel content surface */
|
|
864
|
+
surface: string;
|
|
865
|
+
/** Alternate surface (e.g., sidebar) */
|
|
866
|
+
surfaceAlt: string;
|
|
867
|
+
/** Panel header / tab bar background */
|
|
868
|
+
panelHeader: string;
|
|
869
|
+
/** Tab bar background */
|
|
870
|
+
tabBar: string;
|
|
871
|
+
/** Active/selected tab background */
|
|
872
|
+
tabActive: string;
|
|
873
|
+
/** Unselected tab text color */
|
|
874
|
+
tabText: string;
|
|
875
|
+
/** Selected + active tab text color (blue) */
|
|
876
|
+
tabTextActive: string;
|
|
877
|
+
/** Primary content text */
|
|
878
|
+
text: string;
|
|
879
|
+
/** Secondary text (labels, descriptions) */
|
|
880
|
+
textSecondary: string;
|
|
881
|
+
/** Muted text (placeholders, hints) */
|
|
882
|
+
textMuted: string;
|
|
883
|
+
/** Border color for panels, tabs, splitters */
|
|
884
|
+
border: string;
|
|
885
|
+
/** Splitter bar color */
|
|
886
|
+
splitter: string;
|
|
887
|
+
/** Splitter bar hover color */
|
|
888
|
+
splitterHover: string;
|
|
889
|
+
/** Hover state background */
|
|
890
|
+
hover: string;
|
|
891
|
+
/** Primary accent color (active indicators, selected tabs) */
|
|
892
|
+
primary: string;
|
|
893
|
+
/** Floating window shadow color */
|
|
894
|
+
floatShadow: string;
|
|
895
|
+
}
|
|
896
|
+
interface DockTheme {
|
|
897
|
+
/** Human-readable theme name */
|
|
898
|
+
name: string;
|
|
899
|
+
/** Whether this is a light or dark theme */
|
|
900
|
+
mode: 'light' | 'dark';
|
|
901
|
+
/** Theme colors */
|
|
902
|
+
colors: DockThemeColors;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Apply a theme to a container element by setting CSS custom properties.
|
|
906
|
+
* This scopes the theme to that element's subtree.
|
|
907
|
+
*/
|
|
908
|
+
declare function applyTheme(container: HTMLElement, theme: DockTheme): void;
|
|
909
|
+
/** VS Code-inspired light theme — clean whites and grays */
|
|
910
|
+
declare const vsCodeLight: DockTheme;
|
|
911
|
+
/** GitHub-inspired light theme — warm grays with subtle blue accent */
|
|
912
|
+
declare const githubLight: DockTheme;
|
|
913
|
+
/** Soft warm light theme — cream tones with amber accent */
|
|
914
|
+
declare const warmLight: DockTheme;
|
|
915
|
+
/** Solarized Light — low-contrast cream with teal accents, designed for all-day use */
|
|
916
|
+
declare const solarizedLight: DockTheme;
|
|
917
|
+
/** Sepia — book-like warmth with brown tones, very gentle on eyes */
|
|
918
|
+
declare const sepiaLight: DockTheme;
|
|
919
|
+
/** Mint — soft green tones, refreshing and calming */
|
|
920
|
+
declare const mintLight: DockTheme;
|
|
921
|
+
/** Lavender — soft purple-gray, elegant and easy on eyes */
|
|
922
|
+
declare const lavenderLight: DockTheme;
|
|
923
|
+
/** VS Code-inspired dark theme — deep blues and grays */
|
|
924
|
+
declare const vsCodeDark: DockTheme;
|
|
925
|
+
/** Dracula-inspired dark theme — purple accents on dark gray */
|
|
926
|
+
declare const draculaDark: DockTheme;
|
|
927
|
+
/** Nord-inspired dark theme — arctic blue-gray palette */
|
|
928
|
+
declare const nordDark: DockTheme;
|
|
929
|
+
/** Solarized Dark — low-contrast dark with teal accents, designed for all-day use */
|
|
930
|
+
declare const solarizedDark: DockTheme;
|
|
931
|
+
/** Midnight Blue — deep navy with soft blue accents, very easy on eyes at night */
|
|
932
|
+
declare const midnightDark: DockTheme;
|
|
933
|
+
/** Forest — deep green-gray with emerald accents, nature-inspired calm */
|
|
934
|
+
declare const forestDark: DockTheme;
|
|
935
|
+
/** Slate — neutral gray with warm undertones, minimalist and gentle */
|
|
936
|
+
declare const slateDark: DockTheme;
|
|
937
|
+
/** All built-in themes */
|
|
938
|
+
declare const themes: {
|
|
939
|
+
readonly vsCodeLight: DockTheme;
|
|
940
|
+
readonly githubLight: DockTheme;
|
|
941
|
+
readonly warmLight: DockTheme;
|
|
942
|
+
readonly solarizedLight: DockTheme;
|
|
943
|
+
readonly sepiaLight: DockTheme;
|
|
944
|
+
readonly mintLight: DockTheme;
|
|
945
|
+
readonly lavenderLight: DockTheme;
|
|
946
|
+
readonly vsCodeDark: DockTheme;
|
|
947
|
+
readonly draculaDark: DockTheme;
|
|
948
|
+
readonly nordDark: DockTheme;
|
|
949
|
+
readonly solarizedDark: DockTheme;
|
|
950
|
+
readonly midnightDark: DockTheme;
|
|
951
|
+
readonly forestDark: DockTheme;
|
|
952
|
+
readonly slateDark: DockTheme;
|
|
953
|
+
};
|
|
954
|
+
/** Get a theme by name */
|
|
955
|
+
declare function getThemeByName(name: string): DockTheme | undefined;
|
|
956
|
+
/** Get all themes for a given mode */
|
|
957
|
+
declare function getThemesByMode(mode: 'light' | 'dark'): DockTheme[];
|
|
958
|
+
|
|
959
|
+
/** A resource that can release its DOM and event listener references. */
|
|
960
|
+
interface IDisposable {
|
|
961
|
+
/** Release all resources held by this object. */
|
|
962
|
+
dispose(): void;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Configuration options for {@link DockviewComponent}.
|
|
966
|
+
*/
|
|
967
|
+
interface DockviewComponentOptions {
|
|
968
|
+
/** The initial layout and panel state to render. */
|
|
969
|
+
initialState: DockManagerState;
|
|
970
|
+
/**
|
|
971
|
+
* Factory called to render a panel's content into a container element.
|
|
972
|
+
*
|
|
973
|
+
* @param panelId - The panel to render.
|
|
974
|
+
* @param container - The DOM element to mount content into.
|
|
975
|
+
* @param api - PanelApi instance for this panel (widget-to-header communication).
|
|
976
|
+
* @returns A disposable that cleans up the rendered content.
|
|
977
|
+
*/
|
|
978
|
+
createContent: (panelId: string, container: HTMLElement, api: PanelApi) => IDisposable;
|
|
979
|
+
/**
|
|
980
|
+
* Optional factory to render a custom tab for a panel.
|
|
981
|
+
*
|
|
982
|
+
* @param panelId - The panel the tab belongs to.
|
|
983
|
+
* @param container - The DOM element to mount the tab into.
|
|
984
|
+
* @param isActive - Whether the tab is currently active.
|
|
985
|
+
* @returns A disposable that cleans up the rendered tab.
|
|
986
|
+
*/
|
|
987
|
+
createTab?: (panelId: string, container: HTMLElement, isActive: boolean) => IDisposable;
|
|
988
|
+
/**
|
|
989
|
+
* Optional factory to render custom header action buttons in a tab group.
|
|
990
|
+
*
|
|
991
|
+
* @param slot - Which slot to render into (`'left'`, `'right'`, or `'prefix'`).
|
|
992
|
+
* @param tabGroupId - The tab group the actions belong to.
|
|
993
|
+
* @param container - The DOM element to mount actions into.
|
|
994
|
+
* @returns A disposable that cleans up the rendered actions.
|
|
995
|
+
*/
|
|
996
|
+
createHeaderActions?: (slot: 'left' | 'right' | 'prefix', tabGroupId: string, container: HTMLElement) => IDisposable;
|
|
997
|
+
/** Called after every state change with the new state. */
|
|
998
|
+
onStateChange?: (state: DockManagerState) => void;
|
|
999
|
+
/** Called before a panel is closed. Call `event.preventDefault()` to cancel. */
|
|
1000
|
+
onWillClose?: (event: PreventableDockEvent, panelId: string) => void;
|
|
1001
|
+
/** Called before a drag-and-drop completes. Call `event.preventDefault()` to cancel. */
|
|
1002
|
+
onWillDrop?: (event: PreventableDockEvent, sourceId: string, targetId: string, position: DockPosition) => void;
|
|
1003
|
+
/**
|
|
1004
|
+
* Color theme. Can be:
|
|
1005
|
+
* - `'light'` / `'dark'` — uses the default VS Code-style theme
|
|
1006
|
+
* - A `DockTheme` object — applies custom colors via CSS custom properties
|
|
1007
|
+
*
|
|
1008
|
+
* Defaults to `'light'`.
|
|
1009
|
+
*/
|
|
1010
|
+
theme?: 'light' | 'dark' | DockTheme;
|
|
1011
|
+
/** Whether to show edge dock indicators. Defaults to true. */
|
|
1012
|
+
allowRootDock?: boolean;
|
|
1013
|
+
/** Whether to allow dropping on splitters. Defaults to true. */
|
|
1014
|
+
allowSplitterDock?: boolean;
|
|
1015
|
+
/** Custom strings for UI elements (tooltips, context menu, etc.) */
|
|
1016
|
+
resourceStrings?: Partial<DockResourceStrings>;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Framework-agnostic dock layout manager.
|
|
1020
|
+
*
|
|
1021
|
+
* `DockviewComponent` owns the entire DOM tree for the dock layout.
|
|
1022
|
+
* It accepts a host element and a set of renderer callbacks, then
|
|
1023
|
+
* manages tab groups, split panes, floating windows, unpinned strips,
|
|
1024
|
+
* drag-and-drop, and keyboard navigation internally.
|
|
1025
|
+
*
|
|
1026
|
+
* Framework wrappers (React, Vue, Angular) typically instantiate this
|
|
1027
|
+
* class and supply framework-specific content renderers.
|
|
1028
|
+
*
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```ts
|
|
1031
|
+
* const dock = new DockviewComponent(document.getElementById('root')!, {
|
|
1032
|
+
* initialState: createDefaultState(),
|
|
1033
|
+
* createContent: (panelId, container) => {
|
|
1034
|
+
* container.textContent = panelId;
|
|
1035
|
+
* return { dispose: () => { container.textContent = ''; } };
|
|
1036
|
+
* },
|
|
1037
|
+
* });
|
|
1038
|
+
* dock.dispatch({ type: 'ADD_PANEL', payload: { panelId: 'p1', title: 'Panel 1' } });
|
|
1039
|
+
* // Later:
|
|
1040
|
+
* dock.dispose();
|
|
1041
|
+
* ```
|
|
1042
|
+
*/
|
|
1043
|
+
declare class DockviewComponent {
|
|
1044
|
+
private container;
|
|
1045
|
+
private options;
|
|
1046
|
+
private state;
|
|
1047
|
+
private dragManager;
|
|
1048
|
+
private focusManager;
|
|
1049
|
+
private keyboardManager;
|
|
1050
|
+
private historyManager;
|
|
1051
|
+
private tabGroupViews;
|
|
1052
|
+
private splitViews;
|
|
1053
|
+
private floatingViews;
|
|
1054
|
+
private unpinnedStripViews;
|
|
1055
|
+
private panelApis;
|
|
1056
|
+
/** Global content cache: content containers persist across layout changes (float/dock/move) */
|
|
1057
|
+
private contentCache;
|
|
1058
|
+
private _api;
|
|
1059
|
+
private maximizeOverlay;
|
|
1060
|
+
private maximizeOverlayPanelId;
|
|
1061
|
+
private panelFinder;
|
|
1062
|
+
private debugOverlayEl;
|
|
1063
|
+
private rootEl;
|
|
1064
|
+
private layoutRowEl;
|
|
1065
|
+
private topStripContainer;
|
|
1066
|
+
private leftStripContainer;
|
|
1067
|
+
private centerEl;
|
|
1068
|
+
private rightStripContainer;
|
|
1069
|
+
private bottomStripContainer;
|
|
1070
|
+
private layoutContentEl;
|
|
1071
|
+
/**
|
|
1072
|
+
* Create a new dock layout manager.
|
|
1073
|
+
*
|
|
1074
|
+
* @param element - The host DOM element. The dock layout will fill this element.
|
|
1075
|
+
* @param options - Configuration including initial state and renderer callbacks.
|
|
1076
|
+
*/
|
|
1077
|
+
constructor(element: HTMLElement, options: DockviewComponentOptions);
|
|
1078
|
+
/**
|
|
1079
|
+
* Dispatch a {@link DockAction} to update state and re-render.
|
|
1080
|
+
*
|
|
1081
|
+
* If the reducer throws, the error is logged and the previous valid state
|
|
1082
|
+
* is preserved. If the state did not change (same reference), rendering is skipped.
|
|
1083
|
+
*
|
|
1084
|
+
* @param action - The action to dispatch.
|
|
1085
|
+
*/
|
|
1086
|
+
/** Actions that are purely visual / navigational — don't push undo state for these */
|
|
1087
|
+
private static readonly NON_UNDOABLE_ACTIONS;
|
|
1088
|
+
dispatch(action: DockAction): void;
|
|
1089
|
+
/** Undo the last state change. */
|
|
1090
|
+
undo(): void;
|
|
1091
|
+
/** Redo a previously undone state change. */
|
|
1092
|
+
redo(): void;
|
|
1093
|
+
/**
|
|
1094
|
+
* Get the current dock manager state.
|
|
1095
|
+
*
|
|
1096
|
+
* @returns The current {@link DockManagerState}.
|
|
1097
|
+
*/
|
|
1098
|
+
getState(): DockManagerState;
|
|
1099
|
+
/** Get a high-level API for programmatic control (lazy-initialized). */
|
|
1100
|
+
get api(): DockviewApi;
|
|
1101
|
+
/** Resolve a theme option to a 'light' | 'dark' mode string */
|
|
1102
|
+
private resolveThemeMode;
|
|
1103
|
+
/** Apply theme option — handles string ('light'/'dark') or DockTheme object */
|
|
1104
|
+
private applyThemeOption;
|
|
1105
|
+
/**
|
|
1106
|
+
* Update component options at runtime (e.g., switch theme or change callbacks).
|
|
1107
|
+
*
|
|
1108
|
+
* @param options - Partial options to merge into the current configuration.
|
|
1109
|
+
*/
|
|
1110
|
+
updateOptions(options: Partial<DockviewComponentOptions>): void;
|
|
1111
|
+
/**
|
|
1112
|
+
* Get or create a {@link PanelApi} for a given panel.
|
|
1113
|
+
*
|
|
1114
|
+
* The returned API is wired to dispatch `UPDATE_PANEL_CONFIG` actions
|
|
1115
|
+
* back into this component. Panel APIs are cached and reused across renders.
|
|
1116
|
+
*
|
|
1117
|
+
* @param panelId - The panel to get an API for.
|
|
1118
|
+
* @returns The PanelApi instance for the given panel.
|
|
1119
|
+
*/
|
|
1120
|
+
getPanelApi(panelId: string): PanelApi;
|
|
1121
|
+
/**
|
|
1122
|
+
* Dispose PanelApis for panels that no longer exist in state.
|
|
1123
|
+
*/
|
|
1124
|
+
private cleanupPanelApis;
|
|
1125
|
+
/** Enable or disable the debug overlay showing layout IDs and split ratios. */
|
|
1126
|
+
private setDebugOverlay;
|
|
1127
|
+
/** Update the debug overlay with current layout info. */
|
|
1128
|
+
private updateDebugOverlay;
|
|
1129
|
+
/**
|
|
1130
|
+
* Clean up all resources: dispose sub-managers, views, panel APIs, and
|
|
1131
|
+
* remove the root DOM element from the container.
|
|
1132
|
+
*
|
|
1133
|
+
* After calling `dispose()`, this instance must not be used again.
|
|
1134
|
+
*/
|
|
1135
|
+
dispose(): void;
|
|
1136
|
+
private onActionClick;
|
|
1137
|
+
/**
|
|
1138
|
+
* Get or create a content container for a panel. The container is cached
|
|
1139
|
+
* so that when a panel moves between locations (tab group → floating → tab group),
|
|
1140
|
+
* the content is preserved by reparenting the DOM element instead of destroying
|
|
1141
|
+
* and recreating it.
|
|
1142
|
+
*/
|
|
1143
|
+
private getOrCreateContent;
|
|
1144
|
+
/**
|
|
1145
|
+
* Permanently destroy a panel's cached content (called when panel is closed).
|
|
1146
|
+
*/
|
|
1147
|
+
private destroyContent;
|
|
1148
|
+
private render;
|
|
1149
|
+
private renderLayout;
|
|
1150
|
+
private renderLayoutNode;
|
|
1151
|
+
private renderTabGroup;
|
|
1152
|
+
private renderSplit;
|
|
1153
|
+
private renderFloatingPanels;
|
|
1154
|
+
private renderUnpinnedStrips;
|
|
1155
|
+
private renderMaximizeOverlay;
|
|
1156
|
+
private cleanupStaleViews;
|
|
1157
|
+
private collectNodeIds;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* LayoutTree — Clean, immutable layout tree operations.
|
|
1162
|
+
*
|
|
1163
|
+
* Replaces the scattered helpers in layoutHelpers.ts with a cohesive module
|
|
1164
|
+
* that handles all tree mutations correctly:
|
|
1165
|
+
*
|
|
1166
|
+
* 1. removePanel — always returns a valid tree (never null), auto-collapses
|
|
1167
|
+
* 2. insertAtEdge — inserts at the correct root-level edge (left/right/top/bottom)
|
|
1168
|
+
* 3. insertInGroup — adds panel to existing tab group (center drop)
|
|
1169
|
+
* 4. movePanel — combines remove + insert atomically
|
|
1170
|
+
* 5. normalizeSizes — ensures sizes always sum to 100
|
|
1171
|
+
* 6. collapseTree — removes empty groups and single-child splits
|
|
1172
|
+
*
|
|
1173
|
+
* All functions are pure (no side effects) and return new objects (immutable).
|
|
1174
|
+
*/
|
|
1175
|
+
|
|
1176
|
+
declare function genId(prefix: string): string;
|
|
1177
|
+
declare function resetIdCounter(): void;
|
|
1178
|
+
/**
|
|
1179
|
+
* Remove a panel from the layout tree.
|
|
1180
|
+
* Returns null if the tree becomes completely empty (no panels remain).
|
|
1181
|
+
*
|
|
1182
|
+
* Automatically:
|
|
1183
|
+
* - Removes the panel from its tab group
|
|
1184
|
+
* - Collapses empty tab groups
|
|
1185
|
+
* - Promotes single-child splits (removes unnecessary nesting)
|
|
1186
|
+
* - Normalizes sizes after child removal
|
|
1187
|
+
*/
|
|
1188
|
+
declare function removePanel(root: LayoutNode, panelId: string): LayoutNode | null;
|
|
1189
|
+
/**
|
|
1190
|
+
* Insert a panel into a specific tab group (center/tab drop).
|
|
1191
|
+
* If the group doesn't exist, the tree is returned unchanged.
|
|
1192
|
+
*/
|
|
1193
|
+
declare function insertInGroup(root: LayoutNode, targetGroupId: string, panelId: string): LayoutNode;
|
|
1194
|
+
/**
|
|
1195
|
+
* Insert a panel next to a specific tab group by splitting it.
|
|
1196
|
+
* Creates a new split with the existing group and a new tab group
|
|
1197
|
+
* at the given position (left/right/top/bottom).
|
|
1198
|
+
*/
|
|
1199
|
+
declare function insertBySplit(root: LayoutNode, targetGroupId: string, panelId: string, position: DockPosition): LayoutNode;
|
|
1200
|
+
/**
|
|
1201
|
+
* Insert a panel at a root-level edge of the layout.
|
|
1202
|
+
* This adds a new tab group flush against the left/right/top/bottom
|
|
1203
|
+
* edge of the entire layout, not nested inside any existing split.
|
|
1204
|
+
*
|
|
1205
|
+
* If the root split direction matches the edge axis, the new group is
|
|
1206
|
+
* appended/prepended as a direct child. Otherwise, the layout is
|
|
1207
|
+
* wrapped in a new split.
|
|
1208
|
+
*/
|
|
1209
|
+
declare function insertAtEdge(root: LayoutNode, panelId: string, edge: DockEdge, sizePercent?: number): LayoutNode;
|
|
1210
|
+
/**
|
|
1211
|
+
* Move a panel from its current location to a new target.
|
|
1212
|
+
* Combines remove + insert atomically. Handles all drop positions:
|
|
1213
|
+
* - center: add as tab in target group
|
|
1214
|
+
* - left/right/top/bottom: split target group
|
|
1215
|
+
*
|
|
1216
|
+
* Returns unchanged tree if:
|
|
1217
|
+
* - Dropping on same group as center (no-op)
|
|
1218
|
+
* - Panel doesn't exist in tree
|
|
1219
|
+
*/
|
|
1220
|
+
declare function movePanel(root: LayoutNode, panelId: string, targetGroupId: string, position: DockPosition): LayoutNode;
|
|
1221
|
+
/** Find which tab group contains a panel */
|
|
1222
|
+
declare function findTabGroupForPanel(node: LayoutNode, panelId: string): string | null;
|
|
1223
|
+
/** Find the first tab group (DFS) */
|
|
1224
|
+
declare function findFirstTabGroup(node: LayoutNode): string | null;
|
|
1225
|
+
/** Find a tab group by ID */
|
|
1226
|
+
declare function findTabGroupById(node: LayoutNode, id: string): TabGroupNode | null;
|
|
1227
|
+
/** Find all tab groups in DFS order */
|
|
1228
|
+
declare function findAllTabGroups(node: LayoutNode): TabGroupNode[];
|
|
1229
|
+
/** Collect all panel IDs in the layout tree */
|
|
1230
|
+
declare function collectLayoutPanelIds(node: LayoutNode): Set<string>;
|
|
1231
|
+
/** Collect all panels in DFS order (for keyboard navigation) */
|
|
1232
|
+
declare function collectAllPanelsOrdered(node: LayoutNode): string[];
|
|
1233
|
+
/** Count total panels */
|
|
1234
|
+
declare function countPanels(node: LayoutNode): number;
|
|
1235
|
+
/**
|
|
1236
|
+
* Detect which edge a panel is closest to in the layout.
|
|
1237
|
+
* Used by UNPIN_PANEL to determine which edge strip to place the panel on.
|
|
1238
|
+
*/
|
|
1239
|
+
declare function detectPanelEdge(node: LayoutNode, panelId: string): DockEdge;
|
|
1240
|
+
/**
|
|
1241
|
+
* Find the tab group at a specific edge of the layout.
|
|
1242
|
+
* Only matches tab groups at the outermost level on the correct axis.
|
|
1243
|
+
*/
|
|
1244
|
+
declare function findTabGroupByEdge(node: LayoutNode, edge: DockEdge): string | null;
|
|
1245
|
+
/** Check if a panel exists anywhere in the state */
|
|
1246
|
+
declare function isPanelPlaced(state: {
|
|
1247
|
+
layout: LayoutNode;
|
|
1248
|
+
floatingPanels: {
|
|
1249
|
+
panelId: string;
|
|
1250
|
+
}[];
|
|
1251
|
+
unpinnedPanels: {
|
|
1252
|
+
panelId: string;
|
|
1253
|
+
}[];
|
|
1254
|
+
popoutPanels?: {
|
|
1255
|
+
panelId: string;
|
|
1256
|
+
}[];
|
|
1257
|
+
}, panelId: string): boolean;
|
|
1258
|
+
|
|
1259
|
+
interface SerializedDockLayout {
|
|
1260
|
+
version: 1 | 2;
|
|
1261
|
+
timestamp: number;
|
|
1262
|
+
state: DockManagerState;
|
|
1263
|
+
/** Layout format version for forward compatibility. Added in v2. */
|
|
1264
|
+
layoutVersion?: number;
|
|
1265
|
+
}
|
|
1266
|
+
/** Serialize dock manager state to JSON string */
|
|
1267
|
+
declare function serialize(state: DockManagerState): string;
|
|
1268
|
+
/** Export the state as a base64 URL-safe string. */
|
|
1269
|
+
declare function exportAsUrl(state: DockManagerState): string;
|
|
1270
|
+
/** Import state from a base64 URL-safe string. */
|
|
1271
|
+
declare function importFromUrl(urlString: string): DockManagerState;
|
|
1272
|
+
/** Deserialize dock manager state from JSON string */
|
|
1273
|
+
declare function deserialize(json: string): {
|
|
1274
|
+
state: DockManagerState;
|
|
1275
|
+
warnings: string[];
|
|
1276
|
+
};
|
|
1277
|
+
declare function saveToLocalStorage(state: DockManagerState): void;
|
|
1278
|
+
declare function loadFromLocalStorage(): {
|
|
1279
|
+
state: DockManagerState;
|
|
1280
|
+
warnings: string[];
|
|
1281
|
+
} | null;
|
|
1282
|
+
declare function clearLocalStorage(): void;
|
|
1283
|
+
declare function exportToFile(state: DockManagerState, filename?: string): void;
|
|
1284
|
+
declare function importFromFile(): Promise<{
|
|
1285
|
+
state: DockManagerState;
|
|
1286
|
+
warnings: string[];
|
|
1287
|
+
}>;
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Minimal typed event emitter for dock manager events.
|
|
1291
|
+
*/
|
|
1292
|
+
type Listener<T> = (value: T) => void;
|
|
1293
|
+
declare class EventEmitter<T = void> {
|
|
1294
|
+
private listeners;
|
|
1295
|
+
on(listener: Listener<T>): () => void;
|
|
1296
|
+
emit(value: T): void;
|
|
1297
|
+
dispose(): void;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* KeyboardManager handles comprehensive keyboard shortcuts for the dock manager.
|
|
1302
|
+
*
|
|
1303
|
+
* All shortcuts are bound to the container element's `keydown` event.
|
|
1304
|
+
* Shortcuts are suppressed when the event target is an input, textarea, or
|
|
1305
|
+
* contenteditable element so that normal text editing is not interrupted.
|
|
1306
|
+
*/
|
|
1307
|
+
|
|
1308
|
+
interface KeyboardManagerOptions {
|
|
1309
|
+
/** The container element to attach the keydown listener to. */
|
|
1310
|
+
containerElement: HTMLElement;
|
|
1311
|
+
/** Dispatch a DockAction to the reducer. */
|
|
1312
|
+
dispatch: (action: DockAction) => void;
|
|
1313
|
+
/** Returns the current dock manager state. */
|
|
1314
|
+
getState: () => DockManagerState;
|
|
1315
|
+
/** Called when undo is requested (Ctrl+Z). */
|
|
1316
|
+
onUndo?: () => void;
|
|
1317
|
+
/** Called when redo is requested (Ctrl+Shift+Z). */
|
|
1318
|
+
onRedo?: () => void;
|
|
1319
|
+
/** Called when panel finder is requested (Ctrl+P). */
|
|
1320
|
+
onPanelFinder?: () => void;
|
|
1321
|
+
}
|
|
1322
|
+
declare class KeyboardManager {
|
|
1323
|
+
private options;
|
|
1324
|
+
private container;
|
|
1325
|
+
constructor(options: KeyboardManagerOptions);
|
|
1326
|
+
/** Remove the keydown listener. */
|
|
1327
|
+
dispose(): void;
|
|
1328
|
+
private onKeyDown;
|
|
1329
|
+
/** Set a handler for Ctrl+Tab pane navigation events. */
|
|
1330
|
+
setPaneNavigatorHandler(handler: ((direction: 'next' | 'previous') => void) | null): void;
|
|
1331
|
+
private paneNavigatorHandler;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* ContextMenuManager handles right-click context menus on tab elements.
|
|
1336
|
+
*
|
|
1337
|
+
* It uses event delegation on the container element to listen for
|
|
1338
|
+
* `contextmenu` events on `[data-tab-id]` elements, and shows a
|
|
1339
|
+
* floating context menu with relevant panel actions.
|
|
1340
|
+
*/
|
|
1341
|
+
|
|
1342
|
+
interface ContextMenuManagerOptions {
|
|
1343
|
+
/** The container element to attach the contextmenu listener to. */
|
|
1344
|
+
containerElement: HTMLElement;
|
|
1345
|
+
/** Dispatch a DockAction to the reducer. */
|
|
1346
|
+
dispatch: (action: DockAction) => void;
|
|
1347
|
+
/** Returns the current dock manager state. */
|
|
1348
|
+
getState: () => DockManagerState;
|
|
1349
|
+
/** Current theme mode for styling. */
|
|
1350
|
+
theme?: 'light' | 'dark';
|
|
1351
|
+
/** Custom resource strings for localization. */
|
|
1352
|
+
resourceStrings?: Partial<DockResourceStrings>;
|
|
1353
|
+
}
|
|
1354
|
+
declare class ContextMenuManager {
|
|
1355
|
+
private options;
|
|
1356
|
+
private container;
|
|
1357
|
+
private menuEl;
|
|
1358
|
+
private outsideClickHandler;
|
|
1359
|
+
private escapeHandler;
|
|
1360
|
+
private resourceStrings;
|
|
1361
|
+
constructor(options: ContextMenuManagerOptions);
|
|
1362
|
+
/** Remove the contextmenu listener and close any open menu. */
|
|
1363
|
+
dispose(): void;
|
|
1364
|
+
private onContextMenu;
|
|
1365
|
+
private buildMenuEntries;
|
|
1366
|
+
private showMenu;
|
|
1367
|
+
closeMenu(): void;
|
|
1368
|
+
private findTabGroup;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* PaneNavigator — Ctrl+Tab overlay for switching between panels.
|
|
1373
|
+
*
|
|
1374
|
+
* Shows a visual overlay with two columns: "Active Files" (documentOnly panels)
|
|
1375
|
+
* and "Tool Windows" (non-documentOnly panels). The user can cycle through
|
|
1376
|
+
* items while holding Ctrl, and releasing Ctrl activates the selected panel.
|
|
1377
|
+
*/
|
|
1378
|
+
|
|
1379
|
+
interface PaneNavigatorOptions {
|
|
1380
|
+
/** The container element to append the overlay to. */
|
|
1381
|
+
containerElement: HTMLElement;
|
|
1382
|
+
/** Returns the current dock manager state. */
|
|
1383
|
+
getState: () => DockManagerState;
|
|
1384
|
+
/** Called when a panel is selected for activation. */
|
|
1385
|
+
onActivate: (panelId: string) => void;
|
|
1386
|
+
}
|
|
1387
|
+
declare class PaneNavigator {
|
|
1388
|
+
private options;
|
|
1389
|
+
private overlayEl;
|
|
1390
|
+
private items;
|
|
1391
|
+
private selectedIndex;
|
|
1392
|
+
private isVisible;
|
|
1393
|
+
private boundKeyDown;
|
|
1394
|
+
private boundKeyUp;
|
|
1395
|
+
constructor(options: PaneNavigatorOptions);
|
|
1396
|
+
/** Show the navigator and highlight the next/previous panel. */
|
|
1397
|
+
show(direction: 'next' | 'previous'): void;
|
|
1398
|
+
/** Hide the navigator and activate the selected panel. */
|
|
1399
|
+
hide(): void;
|
|
1400
|
+
/** Whether the navigator is currently visible. */
|
|
1401
|
+
get visible(): boolean;
|
|
1402
|
+
/** Clean up all listeners and DOM elements. */
|
|
1403
|
+
dispose(): void;
|
|
1404
|
+
private buildItems;
|
|
1405
|
+
private moveSelection;
|
|
1406
|
+
private onKeyDown;
|
|
1407
|
+
private onKeyUp;
|
|
1408
|
+
private createOverlay;
|
|
1409
|
+
private updateHighlight;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* StateHistoryManager — Maintains an undo/redo stack for dock manager state.
|
|
1414
|
+
*
|
|
1415
|
+
* Keeps the last N states (default 20) and provides undo/redo operations.
|
|
1416
|
+
* Used by DockviewComponent to enable Ctrl+Z / Ctrl+Shift+Z support.
|
|
1417
|
+
*/
|
|
1418
|
+
|
|
1419
|
+
declare class StateHistoryManager {
|
|
1420
|
+
private undoStack;
|
|
1421
|
+
private redoStack;
|
|
1422
|
+
private maxHistory;
|
|
1423
|
+
constructor(maxHistory?: number);
|
|
1424
|
+
/**
|
|
1425
|
+
* Push a state onto the undo stack. Clears the redo stack.
|
|
1426
|
+
* Call this BEFORE applying a mutation so the previous state can be restored.
|
|
1427
|
+
*/
|
|
1428
|
+
push(state: DockManagerState): void;
|
|
1429
|
+
/** Whether there are states to undo to. */
|
|
1430
|
+
get canUndo(): boolean;
|
|
1431
|
+
/** Whether there are states to redo to. */
|
|
1432
|
+
get canRedo(): boolean;
|
|
1433
|
+
/**
|
|
1434
|
+
* Undo: pop from undo stack, push current state to redo stack.
|
|
1435
|
+
* @param currentState - The current state before undoing (will be pushed to redo stack).
|
|
1436
|
+
* @returns The previous state to restore, or null if nothing to undo.
|
|
1437
|
+
*/
|
|
1438
|
+
undo(currentState: DockManagerState): DockManagerState | null;
|
|
1439
|
+
/**
|
|
1440
|
+
* Redo: pop from redo stack, push current state to undo stack.
|
|
1441
|
+
* @param currentState - The current state before redoing (will be pushed to undo stack).
|
|
1442
|
+
* @returns The next state to restore, or null if nothing to redo.
|
|
1443
|
+
*/
|
|
1444
|
+
redo(currentState: DockManagerState): DockManagerState | null;
|
|
1445
|
+
/** Clear all history. */
|
|
1446
|
+
clear(): void;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* PanelFinder — Modal overlay with search input for finding and activating panels.
|
|
1451
|
+
*
|
|
1452
|
+
* Triggered by Ctrl+P. Lists all panels (docked, floating, unpinned) filtered
|
|
1453
|
+
* by title. Clicking an item activates that panel.
|
|
1454
|
+
*/
|
|
1455
|
+
|
|
1456
|
+
interface PanelFinderOptions {
|
|
1457
|
+
/** The container element to append the overlay to. */
|
|
1458
|
+
containerElement: HTMLElement;
|
|
1459
|
+
/** Returns the current dock manager state. */
|
|
1460
|
+
getState: () => DockManagerState;
|
|
1461
|
+
/** Called when a panel is selected. */
|
|
1462
|
+
onActivatePanel: (panelId: string) => void;
|
|
1463
|
+
}
|
|
1464
|
+
declare class PanelFinder {
|
|
1465
|
+
private options;
|
|
1466
|
+
private overlayEl;
|
|
1467
|
+
private isOpen;
|
|
1468
|
+
constructor(options: PanelFinderOptions);
|
|
1469
|
+
/** Toggle the panel finder modal. */
|
|
1470
|
+
toggle(): void;
|
|
1471
|
+
/** Open the panel finder modal. */
|
|
1472
|
+
open(): void;
|
|
1473
|
+
/** Close the panel finder modal. */
|
|
1474
|
+
close(): void;
|
|
1475
|
+
dispose(): void;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
export { AddPanelOptions, ContextMenuManager, ContextMenuManagerOptions, DockAction, DockEdge, DockManagerState, DockPosition, DockResourceStrings, DockTheme, DockThemeColors, DockviewApi, DockviewComponent, DockviewComponentOptions, EventEmitter, FloatPanelOptions, FloatingPanel, HeaderPosition, IDisposable, KeyboardManager, KeyboardManagerOptions, LayoutConstraints, LayoutNode, MovePanelOptions, PaneNavigator, PaneNavigatorOptions, PanelApi, PanelConfig, PanelFinder, PanelFinderOptions, PopoutPanel, PreventableDockEvent, SerializedDockLayout, SplitDirection, SplitNode, StateHistoryManager, TabGroupNode, UnpinnedPanel, applyTheme, clearLocalStorage, collectAllPanelsOrdered, collectLayoutPanelIds, countPanels, createDefaultState, createPreventableEvent, defaultResourceStrings, deserialize, detectPanelEdge, dockReducer, draculaDark, exportAsUrl, exportToFile, findAllTabGroups, findFirstTabGroup, findTabGroupByEdge, findTabGroupById, findTabGroupForPanel, forestDark, genId, getThemeByName, getThemesByMode, githubLight, importFromFile, importFromUrl, insertAtEdge, insertBySplit, insertInGroup, isPanelPlaced, lavenderLight, loadFromLocalStorage, midnightDark, mintLight, movePanel, nordDark, removePanel, resetIdCounter, saveToLocalStorage, sepiaLight, serialize, slateDark, solarizedDark, solarizedLight, themes, validateState, vsCodeDark, vsCodeLight, warmLight };
|