dockview-core 1.8.4 → 1.8.5
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/README.md +51 -51
- package/dist/cjs/api/component.api.d.ts +455 -152
- package/dist/cjs/api/component.api.d.ts.map +1 -1
- package/dist/cjs/api/component.api.js +895 -592
- package/dist/cjs/api/component.api.js.map +1 -1
- package/dist/cjs/api/dockviewGroupPanelApi.d.ts +29 -29
- package/dist/cjs/api/dockviewGroupPanelApi.js +53 -53
- package/dist/cjs/api/dockviewPanelApi.d.ts +47 -47
- package/dist/cjs/api/dockviewPanelApi.js +88 -88
- package/dist/cjs/api/gridviewPanelApi.d.ts +37 -37
- package/dist/cjs/api/gridviewPanelApi.js +47 -47
- package/dist/cjs/api/panelApi.d.ts +88 -88
- package/dist/cjs/api/panelApi.js +135 -135
- package/dist/cjs/api/paneviewPanelApi.d.ts +26 -26
- package/dist/cjs/api/paneviewPanelApi.js +57 -57
- package/dist/cjs/api/splitviewPanelApi.d.ts +32 -32
- package/dist/cjs/api/splitviewPanelApi.js +47 -47
- package/dist/cjs/array.d.ts +13 -13
- package/dist/cjs/array.js +67 -67
- package/dist/cjs/dnd/abstractDragHandler.d.ts +12 -12
- package/dist/cjs/dnd/abstractDragHandler.js +141 -141
- package/dist/cjs/dnd/dataTransfer.d.ts +30 -31
- package/dist/cjs/dnd/dataTransfer.d.ts.map +1 -1
- package/dist/cjs/dnd/dataTransfer.js +99 -100
- package/dist/cjs/dnd/dataTransfer.js.map +1 -1
- package/dist/cjs/dnd/dnd.d.ts +27 -27
- package/dist/cjs/dnd/dnd.js +59 -59
- package/dist/cjs/dnd/droptarget.d.ts +53 -53
- package/dist/cjs/dnd/droptarget.js +304 -304
- package/dist/cjs/dnd/droptarget.js.map +1 -1
- package/dist/cjs/dnd/ghost.d.ts +1 -1
- package/dist/cjs/dnd/ghost.js +15 -15
- package/dist/cjs/dnd/groupDragHandler.d.ts +12 -12
- package/dist/cjs/dnd/groupDragHandler.js +77 -77
- package/dist/cjs/dnd/overlay.d.ts +43 -43
- package/dist/cjs/dnd/overlay.d.ts.map +1 -1
- package/dist/cjs/dnd/overlay.js +412 -412
- package/dist/cjs/dnd/overlay.js.map +1 -1
- package/dist/cjs/dockview/components/panel/content.d.ts +30 -30
- package/dist/cjs/dockview/components/panel/content.js +100 -100
- package/dist/cjs/dockview/components/tab/defaultTab.d.ts +21 -21
- package/dist/cjs/dockview/components/tab/defaultTab.js +105 -105
- package/dist/cjs/dockview/components/tab/tab.d.ts +34 -34
- package/dist/cjs/dockview/components/tab/tab.js +120 -120
- package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +81 -81
- package/dist/cjs/dockview/components/titlebar/tabsContainer.js +325 -325
- package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +17 -17
- package/dist/cjs/dockview/components/titlebar/voidContainer.js +77 -77
- package/dist/cjs/dockview/components/watermark/watermark.d.ts +18 -18
- package/dist/cjs/dockview/components/watermark/watermark.js +87 -87
- package/dist/cjs/dockview/deserializer.d.ts +12 -12
- package/dist/cjs/dockview/deserializer.js +33 -33
- package/dist/cjs/dockview/deserializer.js.map +1 -1
- package/dist/cjs/dockview/dockviewComponent.d.ts +159 -159
- package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
- package/dist/cjs/dockview/dockviewComponent.js +1170 -1156
- package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
- package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts +23 -23
- package/dist/cjs/dockview/dockviewFloatingGroupPanel.js +34 -34
- package/dist/cjs/dockview/dockviewGroupPanel.d.ts +30 -30
- package/dist/cjs/dockview/dockviewGroupPanel.js +97 -97
- package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +185 -185
- package/dist/cjs/dockview/dockviewGroupPanelModel.js +632 -631
- package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
- package/dist/cjs/dockview/dockviewPanel.d.ts +41 -41
- package/dist/cjs/dockview/dockviewPanel.js +172 -171
- package/dist/cjs/dockview/dockviewPanel.js.map +1 -1
- package/dist/cjs/dockview/dockviewPanelModel.d.ts +35 -35
- package/dist/cjs/dockview/dockviewPanelModel.js +98 -98
- package/dist/cjs/dockview/dockviewPanelModel.js.map +1 -1
- package/dist/cjs/dockview/options.d.ts +133 -136
- package/dist/cjs/dockview/options.d.ts.map +1 -1
- package/dist/cjs/dockview/options.js +31 -31
- package/dist/cjs/dockview/types.d.ts +63 -63
- package/dist/cjs/dockview/types.js +10 -10
- package/dist/cjs/dockview/types.js.map +1 -1
- package/dist/cjs/dom.d.ts +16 -16
- package/dist/cjs/dom.js +197 -197
- package/dist/cjs/events.d.ts +47 -47
- package/dist/cjs/events.js +216 -216
- package/dist/cjs/events.js.map +1 -1
- package/dist/cjs/gridview/baseComponentGridview.d.ts +88 -87
- package/dist/cjs/gridview/baseComponentGridview.d.ts.map +1 -1
- package/dist/cjs/gridview/baseComponentGridview.js +270 -270
- package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
- package/dist/cjs/gridview/basePanelView.d.ts +40 -40
- package/dist/cjs/gridview/basePanelView.js +156 -156
- package/dist/cjs/gridview/branchNode.d.ts +49 -49
- package/dist/cjs/gridview/branchNode.js +343 -343
- package/dist/cjs/gridview/gridview.d.ts +133 -133
- package/dist/cjs/gridview/gridview.js +547 -547
- package/dist/cjs/gridview/gridviewComponent.d.ts +80 -80
- package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
- package/dist/cjs/gridview/gridviewComponent.js +362 -360
- package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
- package/dist/cjs/gridview/gridviewPanel.d.ts +65 -65
- package/dist/cjs/gridview/gridviewPanel.js +214 -214
- package/dist/cjs/gridview/leafNode.d.ts +34 -34
- package/dist/cjs/gridview/leafNode.js +170 -170
- package/dist/cjs/gridview/leafNode.js.map +1 -1
- package/dist/cjs/gridview/options.d.ts +17 -18
- package/dist/cjs/gridview/options.d.ts.map +1 -1
- package/dist/cjs/gridview/options.js +2 -2
- package/dist/cjs/gridview/types.d.ts +3 -3
- package/dist/cjs/gridview/types.js +2 -2
- package/dist/cjs/index.d.ts +42 -42
- package/dist/cjs/index.js +61 -61
- package/dist/cjs/lifecycle.d.ts +23 -23
- package/dist/cjs/lifecycle.js +65 -65
- package/dist/cjs/lifecycle.js.map +1 -1
- package/dist/cjs/math.d.ts +5 -5
- package/dist/cjs/math.js +34 -34
- package/dist/cjs/panel/componentFactory.d.ts +11 -10
- package/dist/cjs/panel/componentFactory.d.ts.map +1 -1
- package/dist/cjs/panel/componentFactory.js +30 -30
- package/dist/cjs/panel/componentFactory.js.map +1 -1
- package/dist/cjs/panel/types.d.ts +33 -33
- package/dist/cjs/panel/types.js +2 -2
- package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +21 -21
- package/dist/cjs/paneview/defaultPaneviewHeader.js +90 -90
- package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +21 -21
- package/dist/cjs/paneview/draggablePaneviewPanel.js +131 -131
- package/dist/cjs/paneview/options.d.ts +25 -28
- package/dist/cjs/paneview/options.d.ts.map +1 -1
- package/dist/cjs/paneview/options.js +2 -2
- package/dist/cjs/paneview/paneview.d.ts +40 -40
- package/dist/cjs/paneview/paneview.d.ts.map +1 -1
- package/dist/cjs/paneview/paneview.js +200 -201
- package/dist/cjs/paneview/paneview.js.map +1 -1
- package/dist/cjs/paneview/paneviewComponent.d.ts +128 -128
- package/dist/cjs/paneview/paneviewComponent.js +400 -397
- package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
- package/dist/cjs/paneview/paneviewPanel.d.ts +92 -92
- package/dist/cjs/paneview/paneviewPanel.d.ts.map +1 -1
- package/dist/cjs/paneview/paneviewPanel.js +275 -275
- package/dist/cjs/resizable.d.ts +10 -7
- package/dist/cjs/resizable.d.ts.map +1 -1
- package/dist/cjs/resizable.js +79 -64
- package/dist/cjs/resizable.js.map +1 -1
- package/dist/cjs/splitview/options.d.ts +26 -27
- package/dist/cjs/splitview/options.d.ts.map +1 -1
- package/dist/cjs/splitview/options.js +2 -2
- package/dist/cjs/splitview/splitview.d.ts +128 -128
- package/dist/cjs/splitview/splitview.js +936 -936
- package/dist/cjs/splitview/splitview.js.map +1 -1
- package/dist/cjs/splitview/splitviewComponent.d.ts +101 -101
- package/dist/cjs/splitview/splitviewComponent.js +395 -392
- package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
- package/dist/cjs/splitview/splitviewPanel.d.ts +45 -45
- package/dist/cjs/splitview/splitviewPanel.d.ts.map +1 -1
- package/dist/cjs/splitview/splitviewPanel.js +179 -179
- package/dist/cjs/splitview/splitviewPanel.js.map +1 -1
- package/dist/cjs/splitview/viewItem.d.ts +25 -25
- package/dist/cjs/splitview/viewItem.js +119 -119
- package/dist/cjs/svg.d.ts +3 -3
- package/dist/cjs/svg.js +43 -43
- package/dist/cjs/types.d.ts +2 -2
- package/dist/cjs/types.js +2 -2
- package/dist/dockview-core.amd.js +7650 -7316
- package/dist/dockview-core.amd.js.map +1 -1
- package/dist/dockview-core.amd.min.js +2 -2
- package/dist/dockview-core.amd.min.js.map +1 -1
- package/dist/dockview-core.amd.min.noStyle.js +2 -2
- package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
- package/dist/dockview-core.amd.noStyle.js +7601 -7267
- package/dist/dockview-core.amd.noStyle.js.map +1 -1
- package/dist/dockview-core.cjs.js +7650 -7316
- package/dist/dockview-core.cjs.js.map +1 -1
- package/dist/dockview-core.esm.js +7650 -7316
- package/dist/dockview-core.esm.js.map +1 -1
- package/dist/dockview-core.esm.min.js +2 -2
- package/dist/dockview-core.esm.min.js.map +1 -1
- package/dist/dockview-core.js +7650 -7316
- package/dist/dockview-core.js.map +1 -1
- package/dist/dockview-core.min.js +2 -2
- package/dist/dockview-core.min.js.map +1 -1
- package/dist/dockview-core.min.noStyle.js +2 -2
- package/dist/dockview-core.min.noStyle.js.map +1 -1
- package/dist/dockview-core.noStyle.js +7601 -7267
- package/dist/dockview-core.noStyle.js.map +1 -1
- package/dist/esm/api/component.api.d.ts +455 -152
- package/dist/esm/api/component.api.d.ts.map +1 -1
- package/dist/esm/api/component.api.js +638 -335
- package/dist/esm/api/component.api.js.map +1 -1
- package/dist/esm/api/dockviewGroupPanelApi.d.ts +29 -29
- package/dist/esm/api/dockviewGroupPanelApi.js +27 -27
- package/dist/esm/api/dockviewPanelApi.d.ts +47 -47
- package/dist/esm/api/dockviewPanelApi.js +53 -53
- package/dist/esm/api/gridviewPanelApi.d.ts +37 -37
- package/dist/esm/api/gridviewPanelApi.js +25 -25
- package/dist/esm/api/panelApi.d.ts +88 -88
- package/dist/esm/api/panelApi.js +93 -93
- package/dist/esm/api/paneviewPanelApi.d.ts +26 -26
- package/dist/esm/api/paneviewPanelApi.js +27 -27
- package/dist/esm/api/splitviewPanelApi.d.ts +32 -32
- package/dist/esm/api/splitviewPanelApi.js +25 -25
- package/dist/esm/array.d.ts +13 -13
- package/dist/esm/array.js +57 -57
- package/dist/esm/dnd/abstractDragHandler.d.ts +12 -12
- package/dist/esm/dnd/abstractDragHandler.js +63 -63
- package/dist/esm/dnd/dataTransfer.d.ts +30 -31
- package/dist/esm/dnd/dataTransfer.d.ts.map +1 -1
- package/dist/esm/dnd/dataTransfer.js +66 -69
- package/dist/esm/dnd/dataTransfer.js.map +1 -1
- package/dist/esm/dnd/dnd.d.ts +27 -27
- package/dist/esm/dnd/dnd.js +36 -36
- package/dist/esm/dnd/droptarget.d.ts +53 -53
- package/dist/esm/dnd/droptarget.js +274 -274
- package/dist/esm/dnd/droptarget.js.map +1 -1
- package/dist/esm/dnd/ghost.d.ts +1 -1
- package/dist/esm/dnd/ghost.js +11 -11
- package/dist/esm/dnd/groupDragHandler.d.ts +12 -12
- package/dist/esm/dnd/groupDragHandler.js +54 -54
- package/dist/esm/dnd/overlay.d.ts +43 -43
- package/dist/esm/dnd/overlay.d.ts.map +1 -1
- package/dist/esm/dnd/overlay.js +304 -304
- package/dist/esm/dnd/overlay.js.map +1 -1
- package/dist/esm/dockview/components/panel/content.d.ts +30 -30
- package/dist/esm/dockview/components/panel/content.js +73 -73
- package/dist/esm/dockview/components/tab/defaultTab.d.ts +21 -21
- package/dist/esm/dockview/components/tab/defaultTab.js +67 -67
- package/dist/esm/dockview/components/tab/tab.d.ts +34 -34
- package/dist/esm/dockview/components/tab/tab.js +90 -90
- package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +81 -81
- package/dist/esm/dockview/components/titlebar/tabsContainer.js +239 -239
- package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +17 -17
- package/dist/esm/dockview/components/titlebar/voidContainer.js +51 -51
- package/dist/esm/dockview/components/watermark/watermark.d.ts +18 -18
- package/dist/esm/dockview/components/watermark/watermark.js +61 -61
- package/dist/esm/dockview/deserializer.d.ts +12 -12
- package/dist/esm/dockview/deserializer.js +28 -28
- package/dist/esm/dockview/deserializer.js.map +1 -1
- package/dist/esm/dockview/dockviewComponent.d.ts +159 -159
- package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
- package/dist/esm/dockview/dockviewComponent.js +932 -918
- package/dist/esm/dockview/dockviewComponent.js.map +1 -1
- package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +23 -23
- package/dist/esm/dockview/dockviewFloatingGroupPanel.js +12 -12
- package/dist/esm/dockview/dockviewGroupPanel.d.ts +30 -30
- package/dist/esm/dockview/dockviewGroupPanel.js +51 -51
- package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +185 -185
- package/dist/esm/dockview/dockviewGroupPanelModel.js +499 -498
- package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
- package/dist/esm/dockview/dockviewPanel.d.ts +41 -41
- package/dist/esm/dockview/dockviewPanel.js +105 -104
- package/dist/esm/dockview/dockviewPanel.js.map +1 -1
- package/dist/esm/dockview/dockviewPanelModel.d.ts +35 -35
- package/dist/esm/dockview/dockviewPanelModel.js +74 -74
- package/dist/esm/dockview/dockviewPanelModel.js.map +1 -1
- package/dist/esm/dockview/options.d.ts +133 -136
- package/dist/esm/dockview/options.d.ts.map +1 -1
- package/dist/esm/dockview/options.js +24 -24
- package/dist/esm/dockview/types.d.ts +63 -63
- package/dist/esm/dockview/types.js +7 -7
- package/dist/esm/dom.d.ts +16 -16
- package/dist/esm/dom.js +126 -126
- package/dist/esm/events.d.ts +47 -47
- package/dist/esm/events.js +156 -156
- package/dist/esm/events.js.map +1 -1
- package/dist/esm/gridview/baseComponentGridview.d.ts +88 -87
- package/dist/esm/gridview/baseComponentGridview.d.ts.map +1 -1
- package/dist/esm/gridview/baseComponentGridview.js +184 -184
- package/dist/esm/gridview/baseComponentGridview.js.map +1 -1
- package/dist/esm/gridview/basePanelView.d.ts +40 -40
- package/dist/esm/gridview/basePanelView.js +85 -85
- package/dist/esm/gridview/branchNode.d.ts +49 -49
- package/dist/esm/gridview/branchNode.js +219 -219
- package/dist/esm/gridview/gridview.d.ts +133 -133
- package/dist/esm/gridview/gridview.js +461 -461
- package/dist/esm/gridview/gridviewComponent.d.ts +80 -80
- package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
- package/dist/esm/gridview/gridviewComponent.js +264 -262
- package/dist/esm/gridview/gridviewComponent.js.map +1 -1
- package/dist/esm/gridview/gridviewPanel.d.ts +65 -65
- package/dist/esm/gridview/gridviewPanel.js +151 -151
- package/dist/esm/gridview/leafNode.d.ts +34 -34
- package/dist/esm/gridview/leafNode.js +103 -103
- package/dist/esm/gridview/options.d.ts +17 -18
- package/dist/esm/gridview/options.d.ts.map +1 -1
- package/dist/esm/gridview/options.js +1 -1
- package/dist/esm/gridview/types.d.ts +3 -3
- package/dist/esm/gridview/types.js +1 -1
- package/dist/esm/index.d.ts +42 -42
- package/dist/esm/index.js +34 -34
- package/dist/esm/lifecycle.d.ts +23 -23
- package/dist/esm/lifecycle.js +41 -41
- package/dist/esm/math.d.ts +5 -5
- package/dist/esm/math.js +28 -28
- package/dist/esm/panel/componentFactory.d.ts +11 -10
- package/dist/esm/panel/componentFactory.d.ts.map +1 -1
- package/dist/esm/panel/componentFactory.js +24 -24
- package/dist/esm/panel/componentFactory.js.map +1 -1
- package/dist/esm/panel/types.d.ts +33 -33
- package/dist/esm/panel/types.js +1 -1
- package/dist/esm/paneview/defaultPaneviewHeader.d.ts +21 -21
- package/dist/esm/paneview/defaultPaneviewHeader.js +63 -63
- package/dist/esm/paneview/draggablePaneviewPanel.d.ts +21 -21
- package/dist/esm/paneview/draggablePaneviewPanel.js +92 -92
- package/dist/esm/paneview/options.d.ts +25 -28
- package/dist/esm/paneview/options.d.ts.map +1 -1
- package/dist/esm/paneview/options.js +1 -1
- package/dist/esm/paneview/paneview.d.ts +40 -40
- package/dist/esm/paneview/paneview.d.ts.map +1 -1
- package/dist/esm/paneview/paneview.js +145 -145
- package/dist/esm/paneview/paneviewComponent.d.ts +128 -128
- package/dist/esm/paneview/paneviewComponent.js +276 -273
- package/dist/esm/paneview/paneviewComponent.js.map +1 -1
- package/dist/esm/paneview/paneviewPanel.d.ts +92 -92
- package/dist/esm/paneview/paneviewPanel.d.ts.map +1 -1
- package/dist/esm/paneview/paneviewPanel.js +192 -192
- package/dist/esm/resizable.d.ts +10 -7
- package/dist/esm/resizable.d.ts.map +1 -1
- package/dist/esm/resizable.js +48 -38
- package/dist/esm/resizable.js.map +1 -1
- package/dist/esm/splitview/options.d.ts +26 -27
- package/dist/esm/splitview/options.d.ts.map +1 -1
- package/dist/esm/splitview/options.js +1 -1
- package/dist/esm/splitview/splitview.d.ts +128 -128
- package/dist/esm/splitview/splitview.js +704 -704
- package/dist/esm/splitview/splitviewComponent.d.ts +101 -101
- package/dist/esm/splitview/splitviewComponent.js +261 -258
- package/dist/esm/splitview/splitviewComponent.js.map +1 -1
- package/dist/esm/splitview/splitviewPanel.d.ts +45 -45
- package/dist/esm/splitview/splitviewPanel.d.ts.map +1 -1
- package/dist/esm/splitview/splitviewPanel.js +108 -108
- package/dist/esm/splitview/splitviewPanel.js.map +1 -1
- package/dist/esm/splitview/viewItem.d.ts +25 -25
- package/dist/esm/splitview/viewItem.js +74 -74
- package/dist/esm/svg.d.ts +3 -3
- package/dist/esm/svg.js +31 -31
- package/dist/esm/types.d.ts +2 -2
- package/dist/esm/types.js +1 -1
- package/package.json +30 -42
- package/LICENSE +0 -21
|
@@ -1,919 +1,933 @@
|
|
|
1
|
-
import { getRelativeLocation, getGridLocation, } from '../gridview/gridview';
|
|
2
|
-
import { directionToPosition, Droptarget } from '../dnd/droptarget';
|
|
3
|
-
import { tail, sequenceEquals, remove } from '../array';
|
|
4
|
-
import { DockviewPanel } from './dockviewPanel';
|
|
5
|
-
import { CompositeDisposable } from '../lifecycle';
|
|
6
|
-
import { Event, Emitter } from '../events';
|
|
7
|
-
import { Watermark } from './components/watermark/watermark';
|
|
8
|
-
import { DockviewDropTargets, } from './types';
|
|
9
|
-
import { sequentialNumberGenerator } from '../math';
|
|
10
|
-
import { DefaultDockviewDeserialzier } from './deserializer';
|
|
11
|
-
import { createComponent } from '../panel/componentFactory';
|
|
12
|
-
import { isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, } from './options';
|
|
13
|
-
import { BaseGrid, toTarget, } from '../gridview/baseComponentGridview';
|
|
14
|
-
import { DockviewApi } from '../api/component.api';
|
|
15
|
-
import { Orientation, Sizing } from '../splitview/splitview';
|
|
16
|
-
import { DockviewGroupPanel } from './dockviewGroupPanel';
|
|
17
|
-
import { DockviewPanelModel } from './dockviewPanelModel';
|
|
18
|
-
import { getPanelData } from '../dnd/dataTransfer';
|
|
19
|
-
import { Overlay } from '../dnd/overlay';
|
|
20
|
-
import { toggleClass, watchElementResize } from '../dom';
|
|
21
|
-
import { DockviewFloatingGroupPanel, } from './dockviewFloatingGroupPanel';
|
|
22
|
-
const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
|
|
23
|
-
function typeValidate3(data, path) {
|
|
24
|
-
if (typeof data.id !== 'string') {
|
|
25
|
-
throw new Error(`${path}.id must be a string`);
|
|
26
|
-
}
|
|
27
|
-
if (typeof data.activeView !== 'string' ||
|
|
28
|
-
typeof data.activeView !== 'undefined') {
|
|
29
|
-
throw new Error(`${path}.activeView must be a string of undefined`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function typeValidate2(data, path) {
|
|
33
|
-
if (typeof data.size !== 'number' && typeof data.size !== 'undefined') {
|
|
34
|
-
throw new Error(`${path}.size must be a number or undefined`);
|
|
35
|
-
}
|
|
36
|
-
if (typeof data.visible !== 'boolean' &&
|
|
37
|
-
typeof data.visible !== 'undefined') {
|
|
38
|
-
throw new Error(`${path}.visible must be a boolean or undefined`);
|
|
39
|
-
}
|
|
40
|
-
if (data.type === 'leaf') {
|
|
41
|
-
if (typeof data.data !== 'object' ||
|
|
42
|
-
data.data === null ||
|
|
43
|
-
Array.isArray(data.data)) {
|
|
44
|
-
throw new Error('object must be a non-null object');
|
|
45
|
-
}
|
|
46
|
-
typeValidate3(data.data, `${path}.data`);
|
|
47
|
-
}
|
|
48
|
-
else if (data.type === 'branch') {
|
|
49
|
-
if (!Array.isArray(data.data)) {
|
|
50
|
-
throw new Error(`${path}.data must be an array`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
throw new Error(`${path}.type must be onew of {'branch', 'leaf'}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function typeValidate(data) {
|
|
58
|
-
if (typeof data !== 'object' || data === null) {
|
|
59
|
-
throw new Error('object must be a non-null object');
|
|
60
|
-
}
|
|
61
|
-
const { grid, panels, activeGroup, floatingGroups } = data;
|
|
62
|
-
if (typeof grid !== 'object' || grid === null) {
|
|
63
|
-
throw new Error("'.grid' must be a non-null object");
|
|
64
|
-
}
|
|
65
|
-
if (typeof grid.height !== 'number') {
|
|
66
|
-
throw new Error("'.grid.height' must be a number");
|
|
67
|
-
}
|
|
68
|
-
if (typeof grid.width !== 'number') {
|
|
69
|
-
throw new Error("'.grid.width' must be a number");
|
|
70
|
-
}
|
|
71
|
-
if (typeof grid.root !== 'object' || grid.root === null) {
|
|
72
|
-
throw new Error("'.grid.root' must be a non-null object");
|
|
73
|
-
}
|
|
74
|
-
if (grid.root.type !== 'branch') {
|
|
75
|
-
throw new Error(".grid.root.type must be of type 'branch'");
|
|
76
|
-
}
|
|
77
|
-
if (grid.orientation !== Orientation.HORIZONTAL &&
|
|
78
|
-
grid.orientation !== Orientation.VERTICAL) {
|
|
79
|
-
throw new Error(`'.grid.width' must be one of {${Orientation.HORIZONTAL}, ${Orientation.VERTICAL}}`);
|
|
80
|
-
}
|
|
81
|
-
typeValidate2(grid.root, '.grid.root');
|
|
82
|
-
}
|
|
83
|
-
export class DockviewComponent extends BaseGrid {
|
|
84
|
-
get orientation() {
|
|
85
|
-
return this.gridview.orientation;
|
|
86
|
-
}
|
|
87
|
-
get totalPanels() {
|
|
88
|
-
return this.panels.length;
|
|
89
|
-
}
|
|
90
|
-
get panels() {
|
|
91
|
-
return this.groups.flatMap((group) => group.panels);
|
|
92
|
-
}
|
|
93
|
-
get options() {
|
|
94
|
-
return this._options;
|
|
95
|
-
}
|
|
96
|
-
get activePanel() {
|
|
97
|
-
const activeGroup = this.activeGroup;
|
|
98
|
-
if (!activeGroup) {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
return activeGroup.activePanel;
|
|
102
|
-
}
|
|
103
|
-
constructor(options) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
this.
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
117
|
-
this.
|
|
118
|
-
this.
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
125
|
-
this.
|
|
126
|
-
this.
|
|
127
|
-
this.
|
|
128
|
-
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.
|
|
133
|
-
}))
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this.
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
group
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
? undefined
|
|
235
|
-
: (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
case '
|
|
301
|
-
case '
|
|
302
|
-
return this.createGroupAtLocation([
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
group.overlay.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
this.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
id
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
this.
|
|
552
|
-
}
|
|
553
|
-
if (
|
|
554
|
-
this.
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
if (options.position) {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
referenceGroup =
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
panel = this.createPanel(options,
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
if (group
|
|
663
|
-
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
this.
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
if (
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
this.
|
|
890
|
-
}))
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1
|
+
import { getRelativeLocation, getGridLocation, } from '../gridview/gridview';
|
|
2
|
+
import { directionToPosition, Droptarget } from '../dnd/droptarget';
|
|
3
|
+
import { tail, sequenceEquals, remove } from '../array';
|
|
4
|
+
import { DockviewPanel } from './dockviewPanel';
|
|
5
|
+
import { CompositeDisposable } from '../lifecycle';
|
|
6
|
+
import { Event, Emitter } from '../events';
|
|
7
|
+
import { Watermark } from './components/watermark/watermark';
|
|
8
|
+
import { DockviewDropTargets, } from './types';
|
|
9
|
+
import { sequentialNumberGenerator } from '../math';
|
|
10
|
+
import { DefaultDockviewDeserialzier } from './deserializer';
|
|
11
|
+
import { createComponent } from '../panel/componentFactory';
|
|
12
|
+
import { isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, } from './options';
|
|
13
|
+
import { BaseGrid, toTarget, } from '../gridview/baseComponentGridview';
|
|
14
|
+
import { DockviewApi } from '../api/component.api';
|
|
15
|
+
import { Orientation, Sizing } from '../splitview/splitview';
|
|
16
|
+
import { DockviewGroupPanel } from './dockviewGroupPanel';
|
|
17
|
+
import { DockviewPanelModel } from './dockviewPanelModel';
|
|
18
|
+
import { getPanelData } from '../dnd/dataTransfer';
|
|
19
|
+
import { Overlay } from '../dnd/overlay';
|
|
20
|
+
import { toggleClass, watchElementResize } from '../dom';
|
|
21
|
+
import { DockviewFloatingGroupPanel, } from './dockviewFloatingGroupPanel';
|
|
22
|
+
const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
|
|
23
|
+
function typeValidate3(data, path) {
|
|
24
|
+
if (typeof data.id !== 'string') {
|
|
25
|
+
throw new Error(`${path}.id must be a string`);
|
|
26
|
+
}
|
|
27
|
+
if (typeof data.activeView !== 'string' ||
|
|
28
|
+
typeof data.activeView !== 'undefined') {
|
|
29
|
+
throw new Error(`${path}.activeView must be a string of undefined`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function typeValidate2(data, path) {
|
|
33
|
+
if (typeof data.size !== 'number' && typeof data.size !== 'undefined') {
|
|
34
|
+
throw new Error(`${path}.size must be a number or undefined`);
|
|
35
|
+
}
|
|
36
|
+
if (typeof data.visible !== 'boolean' &&
|
|
37
|
+
typeof data.visible !== 'undefined') {
|
|
38
|
+
throw new Error(`${path}.visible must be a boolean or undefined`);
|
|
39
|
+
}
|
|
40
|
+
if (data.type === 'leaf') {
|
|
41
|
+
if (typeof data.data !== 'object' ||
|
|
42
|
+
data.data === null ||
|
|
43
|
+
Array.isArray(data.data)) {
|
|
44
|
+
throw new Error('object must be a non-null object');
|
|
45
|
+
}
|
|
46
|
+
typeValidate3(data.data, `${path}.data`);
|
|
47
|
+
}
|
|
48
|
+
else if (data.type === 'branch') {
|
|
49
|
+
if (!Array.isArray(data.data)) {
|
|
50
|
+
throw new Error(`${path}.data must be an array`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw new Error(`${path}.type must be onew of {'branch', 'leaf'}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function typeValidate(data) {
|
|
58
|
+
if (typeof data !== 'object' || data === null) {
|
|
59
|
+
throw new Error('object must be a non-null object');
|
|
60
|
+
}
|
|
61
|
+
const { grid, panels, activeGroup, floatingGroups } = data;
|
|
62
|
+
if (typeof grid !== 'object' || grid === null) {
|
|
63
|
+
throw new Error("'.grid' must be a non-null object");
|
|
64
|
+
}
|
|
65
|
+
if (typeof grid.height !== 'number') {
|
|
66
|
+
throw new Error("'.grid.height' must be a number");
|
|
67
|
+
}
|
|
68
|
+
if (typeof grid.width !== 'number') {
|
|
69
|
+
throw new Error("'.grid.width' must be a number");
|
|
70
|
+
}
|
|
71
|
+
if (typeof grid.root !== 'object' || grid.root === null) {
|
|
72
|
+
throw new Error("'.grid.root' must be a non-null object");
|
|
73
|
+
}
|
|
74
|
+
if (grid.root.type !== 'branch') {
|
|
75
|
+
throw new Error(".grid.root.type must be of type 'branch'");
|
|
76
|
+
}
|
|
77
|
+
if (grid.orientation !== Orientation.HORIZONTAL &&
|
|
78
|
+
grid.orientation !== Orientation.VERTICAL) {
|
|
79
|
+
throw new Error(`'.grid.width' must be one of {${Orientation.HORIZONTAL}, ${Orientation.VERTICAL}}`);
|
|
80
|
+
}
|
|
81
|
+
typeValidate2(grid.root, '.grid.root');
|
|
82
|
+
}
|
|
83
|
+
export class DockviewComponent extends BaseGrid {
|
|
84
|
+
get orientation() {
|
|
85
|
+
return this.gridview.orientation;
|
|
86
|
+
}
|
|
87
|
+
get totalPanels() {
|
|
88
|
+
return this.panels.length;
|
|
89
|
+
}
|
|
90
|
+
get panels() {
|
|
91
|
+
return this.groups.flatMap((group) => group.panels);
|
|
92
|
+
}
|
|
93
|
+
get options() {
|
|
94
|
+
return this._options;
|
|
95
|
+
}
|
|
96
|
+
get activePanel() {
|
|
97
|
+
const activeGroup = this.activeGroup;
|
|
98
|
+
if (!activeGroup) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
return activeGroup.activePanel;
|
|
102
|
+
}
|
|
103
|
+
constructor(options) {
|
|
104
|
+
var _a;
|
|
105
|
+
super({
|
|
106
|
+
proportionalLayout: true,
|
|
107
|
+
orientation: (_a = options.orientation) !== null && _a !== void 0 ? _a : Orientation.HORIZONTAL,
|
|
108
|
+
styles: options.styles,
|
|
109
|
+
parentElement: options.parentElement,
|
|
110
|
+
disableAutoResizing: options.disableAutoResizing,
|
|
111
|
+
});
|
|
112
|
+
this.nextGroupId = sequentialNumberGenerator();
|
|
113
|
+
this._deserializer = new DefaultDockviewDeserialzier(this);
|
|
114
|
+
this.watermark = null;
|
|
115
|
+
this._onWillDragPanel = new Emitter();
|
|
116
|
+
this.onWillDragPanel = this._onWillDragPanel.event;
|
|
117
|
+
this._onWillDragGroup = new Emitter();
|
|
118
|
+
this.onWillDragGroup = this._onWillDragGroup.event;
|
|
119
|
+
this._onDidDrop = new Emitter();
|
|
120
|
+
this.onDidDrop = this._onDidDrop.event;
|
|
121
|
+
this._onDidRemovePanel = new Emitter();
|
|
122
|
+
this.onDidRemovePanel = this._onDidRemovePanel.event;
|
|
123
|
+
this._onDidAddPanel = new Emitter();
|
|
124
|
+
this.onDidAddPanel = this._onDidAddPanel.event;
|
|
125
|
+
this._onDidLayoutFromJSON = new Emitter();
|
|
126
|
+
this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
|
|
127
|
+
this._onDidActivePanelChange = new Emitter();
|
|
128
|
+
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
129
|
+
this.floatingGroups = [];
|
|
130
|
+
toggleClass(this.gridview.element, 'dv-dockview', true);
|
|
131
|
+
this.addDisposables(this._onWillDragPanel, this._onWillDragGroup, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, Event.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
|
|
132
|
+
this.updateWatermark();
|
|
133
|
+
}), Event.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
|
|
134
|
+
this._bufferOnDidLayoutChange.fire();
|
|
135
|
+
}));
|
|
136
|
+
this._options = options;
|
|
137
|
+
if (!this.options.components) {
|
|
138
|
+
this.options.components = {};
|
|
139
|
+
}
|
|
140
|
+
if (!this.options.frameworkComponents) {
|
|
141
|
+
this.options.frameworkComponents = {};
|
|
142
|
+
}
|
|
143
|
+
if (!this.options.frameworkTabComponents) {
|
|
144
|
+
this.options.frameworkTabComponents = {};
|
|
145
|
+
}
|
|
146
|
+
if (!this.options.tabComponents) {
|
|
147
|
+
this.options.tabComponents = {};
|
|
148
|
+
}
|
|
149
|
+
if (!this.options.watermarkComponent &&
|
|
150
|
+
!this.options.watermarkFrameworkComponent) {
|
|
151
|
+
this.options.watermarkComponent = Watermark;
|
|
152
|
+
}
|
|
153
|
+
const dropTarget = new Droptarget(this.element, {
|
|
154
|
+
canDisplayOverlay: (event, position) => {
|
|
155
|
+
const data = getPanelData();
|
|
156
|
+
if (data) {
|
|
157
|
+
if (data.viewId !== this.id) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
if (position === 'center') {
|
|
161
|
+
// center drop target is only allowed if there are no panels in the grid
|
|
162
|
+
// floating panels are allowed
|
|
163
|
+
return this.gridview.length === 0;
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if (this.options.showDndOverlay) {
|
|
168
|
+
if (position === 'center' && this.gridview.length !== 0) {
|
|
169
|
+
/**
|
|
170
|
+
* for external events only show the four-corner drag overlays, disable
|
|
171
|
+
* the center position so that external drag events can fall through to the group
|
|
172
|
+
* and panel drop target handlers
|
|
173
|
+
*/
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return this.options.showDndOverlay({
|
|
177
|
+
nativeEvent: event,
|
|
178
|
+
position: position,
|
|
179
|
+
target: DockviewDropTargets.Edge,
|
|
180
|
+
getData: getPanelData,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
},
|
|
185
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
186
|
+
overlayModel: {
|
|
187
|
+
activationSize: { type: 'pixels', value: 10 },
|
|
188
|
+
size: { type: 'pixels', value: 20 },
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
this.addDisposables(dropTarget.onDrop((event) => {
|
|
192
|
+
var _a;
|
|
193
|
+
const data = getPanelData();
|
|
194
|
+
if (data) {
|
|
195
|
+
this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined, 'center');
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
|
|
199
|
+
}
|
|
200
|
+
}), dropTarget);
|
|
201
|
+
this._api = new DockviewApi(this);
|
|
202
|
+
this.updateWatermark();
|
|
203
|
+
}
|
|
204
|
+
addFloatingGroup(item, coord, options) {
|
|
205
|
+
var _a, _b, _c, _d, _e, _f;
|
|
206
|
+
let group;
|
|
207
|
+
if (item instanceof DockviewPanel) {
|
|
208
|
+
group = this.createGroup();
|
|
209
|
+
this.removePanel(item, {
|
|
210
|
+
removeEmptyGroup: true,
|
|
211
|
+
skipDispose: true,
|
|
212
|
+
});
|
|
213
|
+
group.model.openPanel(item);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
group = item;
|
|
217
|
+
const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
|
|
218
|
+
options.skipRemoveGroup;
|
|
219
|
+
if (!skip) {
|
|
220
|
+
this.doRemoveGroup(item, { skipDispose: true });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
group.model.isFloating = true;
|
|
224
|
+
const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
|
|
225
|
+
const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
|
|
226
|
+
const overlay = new Overlay({
|
|
227
|
+
container: this.gridview.element,
|
|
228
|
+
content: group.element,
|
|
229
|
+
height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
|
|
230
|
+
width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
|
|
231
|
+
left: overlayLeft,
|
|
232
|
+
top: overlayTop,
|
|
233
|
+
minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
|
|
234
|
+
? undefined
|
|
235
|
+
: (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
|
|
236
|
+
minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
|
|
237
|
+
? undefined
|
|
238
|
+
: (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
|
|
239
|
+
});
|
|
240
|
+
const el = group.element.querySelector('.void-container');
|
|
241
|
+
if (!el) {
|
|
242
|
+
throw new Error('failed to find drag handle');
|
|
243
|
+
}
|
|
244
|
+
overlay.setupDrag(el, {
|
|
245
|
+
inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
|
|
246
|
+
? options.inDragMode
|
|
247
|
+
: false,
|
|
248
|
+
});
|
|
249
|
+
const floatingGroupPanel = new DockviewFloatingGroupPanel(group, overlay);
|
|
250
|
+
const disposable = watchElementResize(group.element, (entry) => {
|
|
251
|
+
const { width, height } = entry.contentRect;
|
|
252
|
+
group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
|
|
253
|
+
});
|
|
254
|
+
floatingGroupPanel.addDisposables(overlay.onDidChange(() => {
|
|
255
|
+
// this is either a resize or a move
|
|
256
|
+
// to inform the panels .layout(...) the group with it's current size
|
|
257
|
+
// don't care about resize since the above watcher handles that
|
|
258
|
+
group.layout(group.height, group.width);
|
|
259
|
+
}), overlay.onDidChangeEnd(() => {
|
|
260
|
+
this._bufferOnDidLayoutChange.fire();
|
|
261
|
+
}), group.onDidChange((event) => {
|
|
262
|
+
overlay.setBounds({
|
|
263
|
+
height: event === null || event === void 0 ? void 0 : event.height,
|
|
264
|
+
width: event === null || event === void 0 ? void 0 : event.width,
|
|
265
|
+
});
|
|
266
|
+
}), {
|
|
267
|
+
dispose: () => {
|
|
268
|
+
disposable.dispose();
|
|
269
|
+
group.model.isFloating = false;
|
|
270
|
+
remove(this.floatingGroups, floatingGroupPanel);
|
|
271
|
+
this.updateWatermark();
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
this.floatingGroups.push(floatingGroupPanel);
|
|
275
|
+
this.updateWatermark();
|
|
276
|
+
}
|
|
277
|
+
orthogonalize(position) {
|
|
278
|
+
switch (position) {
|
|
279
|
+
case 'top':
|
|
280
|
+
case 'bottom':
|
|
281
|
+
if (this.gridview.orientation === Orientation.HORIZONTAL) {
|
|
282
|
+
// we need to add to a vertical splitview but the current root is a horizontal splitview.
|
|
283
|
+
// insert a vertical splitview at the root level and add the existing view as a child
|
|
284
|
+
this.gridview.insertOrthogonalSplitviewAtRoot();
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
case 'left':
|
|
288
|
+
case 'right':
|
|
289
|
+
if (this.gridview.orientation === Orientation.VERTICAL) {
|
|
290
|
+
// we need to add to a horizontal splitview but the current root is a vertical splitview.
|
|
291
|
+
// insert a horiziontal splitview at the root level and add the existing view as a child
|
|
292
|
+
this.gridview.insertOrthogonalSplitviewAtRoot();
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
default:
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
switch (position) {
|
|
299
|
+
case 'top':
|
|
300
|
+
case 'left':
|
|
301
|
+
case 'center':
|
|
302
|
+
return this.createGroupAtLocation([0]); // insert into first position
|
|
303
|
+
case 'bottom':
|
|
304
|
+
case 'right':
|
|
305
|
+
return this.createGroupAtLocation([this.gridview.length]); // insert into last position
|
|
306
|
+
default:
|
|
307
|
+
throw new Error(`unsupported position ${position}`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
updateOptions(options) {
|
|
311
|
+
var _a, _b;
|
|
312
|
+
const hasOrientationChanged = typeof options.orientation === 'string' &&
|
|
313
|
+
this.gridview.orientation !== options.orientation;
|
|
314
|
+
const hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
|
|
315
|
+
options.floatingGroupBounds !== this.options.floatingGroupBounds;
|
|
316
|
+
this._options = Object.assign(Object.assign({}, this.options), options);
|
|
317
|
+
if (hasOrientationChanged) {
|
|
318
|
+
this.gridview.orientation = options.orientation;
|
|
319
|
+
}
|
|
320
|
+
if (hasFloatingGroupOptionsChanged) {
|
|
321
|
+
for (const group of this.floatingGroups) {
|
|
322
|
+
switch (this.options.floatingGroupBounds) {
|
|
323
|
+
case 'boundedWithinViewport':
|
|
324
|
+
group.overlay.minimumInViewportHeight = undefined;
|
|
325
|
+
group.overlay.minimumInViewportWidth = undefined;
|
|
326
|
+
break;
|
|
327
|
+
case undefined:
|
|
328
|
+
group.overlay.minimumInViewportHeight =
|
|
329
|
+
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
|
|
330
|
+
group.overlay.minimumInViewportWidth =
|
|
331
|
+
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
group.overlay.minimumInViewportHeight =
|
|
335
|
+
(_a = this.options.floatingGroupBounds) === null || _a === void 0 ? void 0 : _a.minimumHeightWithinViewport;
|
|
336
|
+
group.overlay.minimumInViewportWidth =
|
|
337
|
+
(_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumWidthWithinViewport;
|
|
338
|
+
}
|
|
339
|
+
group.overlay.setBounds({});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
this.layout(this.gridview.width, this.gridview.height, true);
|
|
343
|
+
}
|
|
344
|
+
layout(width, height, forceResize) {
|
|
345
|
+
super.layout(width, height, forceResize);
|
|
346
|
+
if (this.floatingGroups) {
|
|
347
|
+
for (const floating of this.floatingGroups) {
|
|
348
|
+
// ensure floting groups stay within visible boundaries
|
|
349
|
+
floating.overlay.setBounds();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
focus() {
|
|
354
|
+
var _a;
|
|
355
|
+
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
356
|
+
}
|
|
357
|
+
getGroupPanel(id) {
|
|
358
|
+
return this.panels.find((panel) => panel.id === id);
|
|
359
|
+
}
|
|
360
|
+
setActivePanel(panel) {
|
|
361
|
+
this.doSetGroupActive(panel.group);
|
|
362
|
+
panel.group.model.openPanel(panel);
|
|
363
|
+
}
|
|
364
|
+
moveToNext(options = {}) {
|
|
365
|
+
var _a;
|
|
366
|
+
if (!options.group) {
|
|
367
|
+
if (!this.activeGroup) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
options.group = this.activeGroup;
|
|
371
|
+
}
|
|
372
|
+
if (options.includePanel && options.group) {
|
|
373
|
+
if (options.group.activePanel !==
|
|
374
|
+
options.group.panels[options.group.panels.length - 1]) {
|
|
375
|
+
options.group.model.moveToNext({ suppressRoll: true });
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const location = getGridLocation(options.group.element);
|
|
380
|
+
const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
381
|
+
this.doSetGroupAndPanelActive(next);
|
|
382
|
+
}
|
|
383
|
+
moveToPrevious(options = {}) {
|
|
384
|
+
var _a;
|
|
385
|
+
if (!options.group) {
|
|
386
|
+
if (!this.activeGroup) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
options.group = this.activeGroup;
|
|
390
|
+
}
|
|
391
|
+
if (options.includePanel && options.group) {
|
|
392
|
+
if (options.group.activePanel !== options.group.panels[0]) {
|
|
393
|
+
options.group.model.moveToPrevious({ suppressRoll: true });
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const location = getGridLocation(options.group.element);
|
|
398
|
+
const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
399
|
+
if (next) {
|
|
400
|
+
this.doSetGroupAndPanelActive(next);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Serialize the current state of the layout
|
|
405
|
+
*
|
|
406
|
+
* @returns A JSON respresentation of the layout
|
|
407
|
+
*/
|
|
408
|
+
toJSON() {
|
|
409
|
+
var _a;
|
|
410
|
+
const data = this.gridview.serialize();
|
|
411
|
+
const panels = this.panels.reduce((collection, panel) => {
|
|
412
|
+
collection[panel.id] = panel.toJSON();
|
|
413
|
+
return collection;
|
|
414
|
+
}, {});
|
|
415
|
+
const floats = this.floatingGroups.map((floatingGroup) => {
|
|
416
|
+
return {
|
|
417
|
+
data: floatingGroup.group.toJSON(),
|
|
418
|
+
position: floatingGroup.overlay.toJSON(),
|
|
419
|
+
};
|
|
420
|
+
});
|
|
421
|
+
const result = {
|
|
422
|
+
grid: data,
|
|
423
|
+
panels,
|
|
424
|
+
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
425
|
+
};
|
|
426
|
+
if (floats.length > 0) {
|
|
427
|
+
result.floatingGroups = floats;
|
|
428
|
+
}
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
fromJSON(data) {
|
|
432
|
+
var _a;
|
|
433
|
+
this.clear();
|
|
434
|
+
if (typeof data !== 'object' || data === null) {
|
|
435
|
+
throw new Error('serialized layout must be a non-null object');
|
|
436
|
+
}
|
|
437
|
+
const { grid, panels, activeGroup } = data;
|
|
438
|
+
if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
|
|
439
|
+
throw new Error('root must be of type branch');
|
|
440
|
+
}
|
|
441
|
+
try {
|
|
442
|
+
// take note of the existing dimensions
|
|
443
|
+
const width = this.width;
|
|
444
|
+
const height = this.height;
|
|
445
|
+
const createGroupFromSerializedState = (data) => {
|
|
446
|
+
const { id, locked, hideHeader, views, activeView } = data;
|
|
447
|
+
if (typeof id !== 'string') {
|
|
448
|
+
throw new Error('group id must be of type string');
|
|
449
|
+
}
|
|
450
|
+
const group = this.createGroup({
|
|
451
|
+
id,
|
|
452
|
+
locked: !!locked,
|
|
453
|
+
hideHeader: !!hideHeader,
|
|
454
|
+
});
|
|
455
|
+
const createdPanels = [];
|
|
456
|
+
for (const child of views) {
|
|
457
|
+
/**
|
|
458
|
+
* Run the deserializer step seperately since this may fail to due corrupted external state.
|
|
459
|
+
* In running this section first we avoid firing lots of 'add' events in the event of a failure
|
|
460
|
+
* due to a corruption of input data.
|
|
461
|
+
*/
|
|
462
|
+
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
463
|
+
createdPanels.push(panel);
|
|
464
|
+
}
|
|
465
|
+
this._onDidAddGroup.fire(group);
|
|
466
|
+
for (let i = 0; i < views.length; i++) {
|
|
467
|
+
const panel = createdPanels[i];
|
|
468
|
+
const isActive = typeof activeView === 'string' &&
|
|
469
|
+
activeView === panel.id;
|
|
470
|
+
group.model.openPanel(panel, {
|
|
471
|
+
skipSetPanelActive: !isActive,
|
|
472
|
+
skipSetGroupActive: true,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
if (!group.activePanel && group.panels.length > 0) {
|
|
476
|
+
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
477
|
+
skipSetGroupActive: true,
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
return group;
|
|
481
|
+
};
|
|
482
|
+
this.gridview.deserialize(grid, {
|
|
483
|
+
fromJSON: (node) => {
|
|
484
|
+
return createGroupFromSerializedState(node.data);
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
this.layout(width, height, true);
|
|
488
|
+
const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
|
|
489
|
+
for (const serializedFloatingGroup of serializedFloatingGroups) {
|
|
490
|
+
const { data, position } = serializedFloatingGroup;
|
|
491
|
+
const group = createGroupFromSerializedState(data);
|
|
492
|
+
this.addFloatingGroup(group, {
|
|
493
|
+
x: position.left,
|
|
494
|
+
y: position.top,
|
|
495
|
+
height: position.height,
|
|
496
|
+
width: position.width,
|
|
497
|
+
}, { skipRemoveGroup: true, inDragMode: false });
|
|
498
|
+
}
|
|
499
|
+
for (const floatingGroup of this.floatingGroups) {
|
|
500
|
+
floatingGroup.overlay.setBounds();
|
|
501
|
+
}
|
|
502
|
+
if (typeof activeGroup === 'string') {
|
|
503
|
+
const panel = this.getPanel(activeGroup);
|
|
504
|
+
if (panel) {
|
|
505
|
+
this.doSetGroupAndPanelActive(panel);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
catch (err) {
|
|
510
|
+
/**
|
|
511
|
+
* Takes all the successfully created groups and remove all of their panels.
|
|
512
|
+
*/
|
|
513
|
+
for (const group of this.groups) {
|
|
514
|
+
for (const panel of group.panels) {
|
|
515
|
+
this.removePanel(panel, {
|
|
516
|
+
removeEmptyGroup: false,
|
|
517
|
+
skipDispose: false,
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* To remove a group we cannot call this.removeGroup(...) since this makes assumptions about
|
|
523
|
+
* the underlying HTMLElement existing in the Gridview.
|
|
524
|
+
*/
|
|
525
|
+
for (const group of this.groups) {
|
|
526
|
+
group.dispose();
|
|
527
|
+
this._groups.delete(group.id);
|
|
528
|
+
this._onDidRemoveGroup.fire(group);
|
|
529
|
+
}
|
|
530
|
+
// iterate over a reassigned array since original array will be modified
|
|
531
|
+
for (const floatingGroup of [...this.floatingGroups]) {
|
|
532
|
+
floatingGroup.dispose();
|
|
533
|
+
}
|
|
534
|
+
// fires clean-up events and clears the underlying HTML gridview.
|
|
535
|
+
this.clear();
|
|
536
|
+
/**
|
|
537
|
+
* even though we have cleaned-up we still want to inform the caller of their error
|
|
538
|
+
* and we'll do this through re-throwing the original error since afterall you would
|
|
539
|
+
* expect trying to load a corrupted layout to result in an error and not silently fail...
|
|
540
|
+
*/
|
|
541
|
+
throw err;
|
|
542
|
+
}
|
|
543
|
+
this._onDidLayoutFromJSON.fire();
|
|
544
|
+
}
|
|
545
|
+
clear() {
|
|
546
|
+
const groups = Array.from(this._groups.values()).map((_) => _.value);
|
|
547
|
+
const hasActiveGroup = !!this.activeGroup;
|
|
548
|
+
const hasActivePanel = !!this.activePanel;
|
|
549
|
+
for (const group of groups) {
|
|
550
|
+
// remove the group will automatically remove the panels
|
|
551
|
+
this.removeGroup(group, { skipActive: true });
|
|
552
|
+
}
|
|
553
|
+
if (hasActiveGroup) {
|
|
554
|
+
this.doSetGroupAndPanelActive(undefined);
|
|
555
|
+
}
|
|
556
|
+
if (hasActivePanel) {
|
|
557
|
+
this._onDidActivePanelChange.fire(undefined);
|
|
558
|
+
}
|
|
559
|
+
this.gridview.clear();
|
|
560
|
+
}
|
|
561
|
+
closeAllGroups() {
|
|
562
|
+
for (const entry of this._groups.entries()) {
|
|
563
|
+
const [_, group] = entry;
|
|
564
|
+
group.value.model.closeAllPanels();
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
addPanel(options) {
|
|
568
|
+
var _a, _b;
|
|
569
|
+
if (this.panels.find((_) => _.id === options.id)) {
|
|
570
|
+
throw new Error(`panel with id ${options.id} already exists`);
|
|
571
|
+
}
|
|
572
|
+
let referenceGroup;
|
|
573
|
+
if (options.position && options.floating) {
|
|
574
|
+
throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
|
|
575
|
+
}
|
|
576
|
+
if (options.position) {
|
|
577
|
+
if (isPanelOptionsWithPanel(options.position)) {
|
|
578
|
+
const referencePanel = typeof options.position.referencePanel === 'string'
|
|
579
|
+
? this.getGroupPanel(options.position.referencePanel)
|
|
580
|
+
: options.position.referencePanel;
|
|
581
|
+
if (!referencePanel) {
|
|
582
|
+
throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
|
|
583
|
+
}
|
|
584
|
+
referenceGroup = this.findGroup(referencePanel);
|
|
585
|
+
}
|
|
586
|
+
else if (isPanelOptionsWithGroup(options.position)) {
|
|
587
|
+
referenceGroup =
|
|
588
|
+
typeof options.position.referenceGroup === 'string'
|
|
589
|
+
? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
|
|
590
|
+
: options.position.referenceGroup;
|
|
591
|
+
if (!referenceGroup) {
|
|
592
|
+
throw new Error(`referencePanel ${options.position.referenceGroup} does not exist`);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
const group = this.orthogonalize(directionToPosition(options.position.direction));
|
|
597
|
+
const panel = this.createPanel(options, group);
|
|
598
|
+
group.model.openPanel(panel);
|
|
599
|
+
return panel;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
referenceGroup = this.activeGroup;
|
|
604
|
+
}
|
|
605
|
+
let panel;
|
|
606
|
+
if (referenceGroup) {
|
|
607
|
+
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
608
|
+
if (options.floating) {
|
|
609
|
+
const group = this.createGroup();
|
|
610
|
+
const o = typeof options.floating === 'object' &&
|
|
611
|
+
options.floating !== null
|
|
612
|
+
? options.floating
|
|
613
|
+
: {};
|
|
614
|
+
this.addFloatingGroup(group, o, {
|
|
615
|
+
inDragMode: false,
|
|
616
|
+
skipRemoveGroup: true,
|
|
617
|
+
});
|
|
618
|
+
this._onDidAddGroup.fire(group);
|
|
619
|
+
panel = this.createPanel(options, group);
|
|
620
|
+
group.model.openPanel(panel);
|
|
621
|
+
this.doSetGroupAndPanelActive(group);
|
|
622
|
+
}
|
|
623
|
+
else if (referenceGroup.api.isFloating || target === 'center') {
|
|
624
|
+
panel = this.createPanel(options, referenceGroup);
|
|
625
|
+
referenceGroup.model.openPanel(panel);
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
const location = getGridLocation(referenceGroup.element);
|
|
629
|
+
const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
|
|
630
|
+
const group = this.createGroupAtLocation(relativeLocation);
|
|
631
|
+
panel = this.createPanel(options, group);
|
|
632
|
+
group.model.openPanel(panel);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
else if (options.floating) {
|
|
636
|
+
const group = this.createGroup();
|
|
637
|
+
const o = typeof options.floating === 'object' &&
|
|
638
|
+
options.floating !== null
|
|
639
|
+
? options.floating
|
|
640
|
+
: {};
|
|
641
|
+
this.addFloatingGroup(group, o, {
|
|
642
|
+
inDragMode: false,
|
|
643
|
+
skipRemoveGroup: true,
|
|
644
|
+
});
|
|
645
|
+
this._onDidAddGroup.fire(group);
|
|
646
|
+
panel = this.createPanel(options, group);
|
|
647
|
+
group.model.openPanel(panel);
|
|
648
|
+
this.doSetGroupAndPanelActive(group);
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
const group = this.createGroupAtLocation();
|
|
652
|
+
panel = this.createPanel(options, group);
|
|
653
|
+
group.model.openPanel(panel);
|
|
654
|
+
}
|
|
655
|
+
return panel;
|
|
656
|
+
}
|
|
657
|
+
removePanel(panel, options = {
|
|
658
|
+
removeEmptyGroup: true,
|
|
659
|
+
skipDispose: false,
|
|
660
|
+
}) {
|
|
661
|
+
const group = panel.group;
|
|
662
|
+
if (!group) {
|
|
663
|
+
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
664
|
+
}
|
|
665
|
+
group.model.removePanel(panel);
|
|
666
|
+
if (!options.skipDispose) {
|
|
667
|
+
panel.dispose();
|
|
668
|
+
}
|
|
669
|
+
if (group.size === 0 && options.removeEmptyGroup) {
|
|
670
|
+
this.removeGroup(group);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
createWatermarkComponent() {
|
|
674
|
+
var _a;
|
|
675
|
+
return createComponent('watermark-id', 'watermark-name', this.options.watermarkComponent
|
|
676
|
+
? { 'watermark-name': this.options.watermarkComponent }
|
|
677
|
+
: {}, this.options.watermarkFrameworkComponent
|
|
678
|
+
? { 'watermark-name': this.options.watermarkFrameworkComponent }
|
|
679
|
+
: {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
|
|
680
|
+
}
|
|
681
|
+
updateWatermark() {
|
|
682
|
+
var _a, _b;
|
|
683
|
+
if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
|
|
684
|
+
if (!this.watermark) {
|
|
685
|
+
this.watermark = this.createWatermarkComponent();
|
|
686
|
+
this.watermark.init({
|
|
687
|
+
containerApi: new DockviewApi(this),
|
|
688
|
+
});
|
|
689
|
+
const watermarkContainer = document.createElement('div');
|
|
690
|
+
watermarkContainer.className = 'dv-watermark-container';
|
|
691
|
+
watermarkContainer.appendChild(this.watermark.element);
|
|
692
|
+
this.gridview.element.appendChild(watermarkContainer);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
else if (this.watermark) {
|
|
696
|
+
this.watermark.element.parentElement.remove();
|
|
697
|
+
(_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
698
|
+
this.watermark = null;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
addGroup(options) {
|
|
702
|
+
var _a;
|
|
703
|
+
const group = this.createGroup();
|
|
704
|
+
if (options) {
|
|
705
|
+
let referenceGroup;
|
|
706
|
+
if (isGroupOptionsWithPanel(options)) {
|
|
707
|
+
const referencePanel = typeof options.referencePanel === 'string'
|
|
708
|
+
? this.panels.find((panel) => panel.id === options.referencePanel)
|
|
709
|
+
: options.referencePanel;
|
|
710
|
+
if (!referencePanel) {
|
|
711
|
+
throw new Error(`reference panel ${options.referencePanel} does not exist`);
|
|
712
|
+
}
|
|
713
|
+
referenceGroup = this.findGroup(referencePanel);
|
|
714
|
+
if (!referenceGroup) {
|
|
715
|
+
throw new Error(`reference group for reference panel ${options.referencePanel} does not exist`);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
else if (isGroupOptionsWithGroup(options)) {
|
|
719
|
+
referenceGroup =
|
|
720
|
+
typeof options.referenceGroup === 'string'
|
|
721
|
+
? (_a = this._groups.get(options.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
|
|
722
|
+
: options.referenceGroup;
|
|
723
|
+
if (!referenceGroup) {
|
|
724
|
+
throw new Error(`reference group ${options.referenceGroup} does not exist`);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
const group = this.orthogonalize(directionToPosition(options.direction));
|
|
729
|
+
return group;
|
|
730
|
+
}
|
|
731
|
+
const target = toTarget(options.direction || 'within');
|
|
732
|
+
const location = getGridLocation(referenceGroup.element);
|
|
733
|
+
const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
|
|
734
|
+
this.doAddGroup(group, relativeLocation);
|
|
735
|
+
return group;
|
|
736
|
+
}
|
|
737
|
+
else {
|
|
738
|
+
this.doAddGroup(group);
|
|
739
|
+
return group;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
removeGroup(group, options) {
|
|
743
|
+
var _a;
|
|
744
|
+
const panels = [...group.panels]; // reassign since group panels will mutate
|
|
745
|
+
for (const panel of panels) {
|
|
746
|
+
this.removePanel(panel, {
|
|
747
|
+
removeEmptyGroup: false,
|
|
748
|
+
skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
const activePanel = this.activePanel;
|
|
752
|
+
this.doRemoveGroup(group, options);
|
|
753
|
+
if (this.activePanel !== activePanel) {
|
|
754
|
+
this._onDidActivePanelChange.fire(this.activePanel);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
doRemoveGroup(group, options) {
|
|
758
|
+
const floatingGroup = this.floatingGroups.find((_) => _.group === group);
|
|
759
|
+
if (floatingGroup) {
|
|
760
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
|
|
761
|
+
floatingGroup.group.dispose();
|
|
762
|
+
this._groups.delete(group.id);
|
|
763
|
+
this._onDidRemoveGroup.fire(group);
|
|
764
|
+
}
|
|
765
|
+
floatingGroup.dispose();
|
|
766
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
|
|
767
|
+
const groups = Array.from(this._groups.values());
|
|
768
|
+
this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
|
|
769
|
+
}
|
|
770
|
+
return floatingGroup.group;
|
|
771
|
+
}
|
|
772
|
+
return super.doRemoveGroup(group, options);
|
|
773
|
+
}
|
|
774
|
+
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
775
|
+
var _a, _b, _c;
|
|
776
|
+
const sourceGroup = sourceGroupId
|
|
777
|
+
? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
|
|
778
|
+
: undefined;
|
|
779
|
+
if (sourceItemId === undefined) {
|
|
780
|
+
if (sourceGroup) {
|
|
781
|
+
this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
|
|
782
|
+
}
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
if (!destinationTarget || destinationTarget === 'center') {
|
|
786
|
+
const groupItem = (_b = sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) !== null && _b !== void 0 ? _b : this.panels.find((panel) => panel.id === sourceItemId);
|
|
787
|
+
if (!groupItem) {
|
|
788
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
789
|
+
}
|
|
790
|
+
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
791
|
+
this.doRemoveGroup(sourceGroup);
|
|
792
|
+
}
|
|
793
|
+
destinationGroup.model.openPanel(groupItem, {
|
|
794
|
+
index: destinationIndex,
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
const referenceLocation = getGridLocation(destinationGroup.element);
|
|
799
|
+
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
800
|
+
if (sourceGroup && sourceGroup.size < 2) {
|
|
801
|
+
const [targetParentLocation, to] = tail(targetLocation);
|
|
802
|
+
const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
803
|
+
if (!isFloating) {
|
|
804
|
+
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
805
|
+
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
806
|
+
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
807
|
+
// special case when 'swapping' two views within same grid location
|
|
808
|
+
// if a group has one tab - we are essentially moving the 'group'
|
|
809
|
+
// which is equivalent to swapping two views in this case
|
|
810
|
+
this.gridview.moveView(sourceParentLocation, from, to);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
// source group will become empty so delete the group
|
|
814
|
+
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
815
|
+
skipActive: true,
|
|
816
|
+
skipDispose: true,
|
|
817
|
+
});
|
|
818
|
+
// after deleting the group we need to re-evaulate the ref location
|
|
819
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
820
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
821
|
+
this.doAddGroup(targetGroup, location);
|
|
822
|
+
}
|
|
823
|
+
else {
|
|
824
|
+
const groupItem = (_c = sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) !== null && _c !== void 0 ? _c : this.panels.find((panel) => panel.id === sourceItemId);
|
|
825
|
+
if (!groupItem) {
|
|
826
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
827
|
+
}
|
|
828
|
+
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
829
|
+
const group = this.createGroupAtLocation(dropLocation);
|
|
830
|
+
group.model.openPanel(groupItem);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
moveGroup(sourceGroup, referenceGroup, target) {
|
|
835
|
+
if (sourceGroup) {
|
|
836
|
+
if (!target || target === 'center') {
|
|
837
|
+
const activePanel = sourceGroup.activePanel;
|
|
838
|
+
const panels = [...sourceGroup.panels].map((p) => sourceGroup.model.removePanel(p.id));
|
|
839
|
+
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
840
|
+
this.doRemoveGroup(sourceGroup);
|
|
841
|
+
}
|
|
842
|
+
for (const panel of panels) {
|
|
843
|
+
referenceGroup.model.openPanel(panel, {
|
|
844
|
+
skipSetPanelActive: panel !== activePanel,
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
850
|
+
if (floatingGroup) {
|
|
851
|
+
floatingGroup.dispose();
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
this.gridview.removeView(getGridLocation(sourceGroup.element));
|
|
855
|
+
}
|
|
856
|
+
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
857
|
+
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
858
|
+
this.gridview.addView(sourceGroup, Sizing.Distribute, dropLocation);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
doSetGroupAndPanelActive(group, skipFocus) {
|
|
863
|
+
var _a, _b;
|
|
864
|
+
const activePanel = this.activePanel;
|
|
865
|
+
super.doSetGroupActive(group, skipFocus);
|
|
866
|
+
if (((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel) !== activePanel) {
|
|
867
|
+
this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.activePanel);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
createGroup(options) {
|
|
871
|
+
if (!options) {
|
|
872
|
+
options = {};
|
|
873
|
+
}
|
|
874
|
+
let id = options === null || options === void 0 ? void 0 : options.id;
|
|
875
|
+
if (id && this._groups.has(options.id)) {
|
|
876
|
+
console.warn(`Duplicate group id ${options === null || options === void 0 ? void 0 : options.id}. reassigning group id to avoid errors`);
|
|
877
|
+
id = undefined;
|
|
878
|
+
}
|
|
879
|
+
if (!id) {
|
|
880
|
+
id = this.nextGroupId.next();
|
|
881
|
+
while (this._groups.has(id)) {
|
|
882
|
+
id = this.nextGroupId.next();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
const view = new DockviewGroupPanel(this, id, options);
|
|
886
|
+
view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
|
|
887
|
+
if (!this._groups.has(view.id)) {
|
|
888
|
+
const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
|
|
889
|
+
this._onWillDragPanel.fire(event);
|
|
890
|
+
}), view.model.onGroupDragStart((event) => {
|
|
891
|
+
this._onWillDragGroup.fire(event);
|
|
892
|
+
}), view.model.onMove((event) => {
|
|
893
|
+
const { groupId, itemId, target, index } = event;
|
|
894
|
+
this.moveGroupOrPanel(view, groupId, itemId, target, index);
|
|
895
|
+
}), view.model.onDidDrop((event) => {
|
|
896
|
+
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: view }));
|
|
897
|
+
}), view.model.onDidAddPanel((event) => {
|
|
898
|
+
this._onDidAddPanel.fire(event.panel);
|
|
899
|
+
}), view.model.onDidRemovePanel((event) => {
|
|
900
|
+
this._onDidRemovePanel.fire(event.panel);
|
|
901
|
+
}), view.model.onDidActivePanelChange((event) => {
|
|
902
|
+
this._onDidActivePanelChange.fire(event.panel);
|
|
903
|
+
}));
|
|
904
|
+
this._groups.set(view.id, { value: view, disposable });
|
|
905
|
+
}
|
|
906
|
+
// TODO: must be called after the above listeners have been setup,
|
|
907
|
+
// not an ideal pattern
|
|
908
|
+
view.initialize();
|
|
909
|
+
return view;
|
|
910
|
+
}
|
|
911
|
+
createPanel(options, group) {
|
|
912
|
+
var _a, _b, _c;
|
|
913
|
+
const contentComponent = options.component;
|
|
914
|
+
const tabComponent = (_a = options.tabComponent) !== null && _a !== void 0 ? _a : this.options.defaultTabComponent;
|
|
915
|
+
const view = new DockviewPanelModel(this, options.id, contentComponent, tabComponent);
|
|
916
|
+
const panel = new DockviewPanel(options.id, this, this._api, group, view);
|
|
917
|
+
panel.init({
|
|
918
|
+
title: (_b = options.title) !== null && _b !== void 0 ? _b : options.id,
|
|
919
|
+
params: (_c = options === null || options === void 0 ? void 0 : options.params) !== null && _c !== void 0 ? _c : {},
|
|
920
|
+
});
|
|
921
|
+
return panel;
|
|
922
|
+
}
|
|
923
|
+
createGroupAtLocation(location = [0]) {
|
|
924
|
+
const group = this.createGroup();
|
|
925
|
+
this.doAddGroup(group, location);
|
|
926
|
+
return group;
|
|
927
|
+
}
|
|
928
|
+
findGroup(panel) {
|
|
929
|
+
var _a;
|
|
930
|
+
return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
919
933
|
//# sourceMappingURL=dockviewComponent.js.map
|