dockview 0.0.28 → 1.0.2
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/LICENSE +21 -21
- package/README.md +60 -0
- package/dist/cjs/actionbar/actionsContainer.d.ts +7 -7
- package/dist/cjs/actionbar/actionsContainer.js +26 -26
- package/dist/cjs/api/component.api.d.ts +135 -131
- package/dist/cjs/api/component.api.js +486 -444
- package/dist/cjs/api/component.api.js.map +1 -1
- package/dist/cjs/api/gridviewPanelApi.d.ts +36 -36
- package/dist/cjs/api/gridviewPanelApi.js +46 -46
- package/dist/cjs/api/groupPanelApi.d.ts +44 -44
- package/dist/cjs/api/groupPanelApi.js +94 -94
- package/dist/cjs/api/groupPanelApi.js.map +1 -1
- package/dist/cjs/api/panelApi.d.ts +107 -107
- package/dist/cjs/api/panelApi.js +140 -140
- package/dist/cjs/api/paneviewPanelApi.d.ts +26 -26
- package/dist/cjs/api/paneviewPanelApi.js +56 -56
- package/dist/cjs/api/splitviewPanelApi.d.ts +33 -33
- package/dist/cjs/api/splitviewPanelApi.js +51 -51
- package/dist/cjs/array.d.ts +13 -13
- package/dist/cjs/array.js +77 -77
- package/dist/cjs/dnd/abstractDragHandler.d.ts +11 -11
- package/dist/cjs/dnd/abstractDragHandler.js +115 -115
- package/dist/cjs/dnd/dataTransfer.d.ts +56 -56
- package/dist/cjs/dnd/dataTransfer.js +144 -144
- package/dist/cjs/dnd/dataTransfer.js.map +1 -1
- package/dist/cjs/dnd/dnd.d.ts +40 -40
- package/dist/cjs/dnd/dnd.js +142 -142
- package/dist/cjs/dnd/droptarget.d.ts +33 -37
- package/dist/cjs/dnd/droptarget.js +177 -177
- package/dist/cjs/dnd/droptarget.js.map +1 -1
- package/dist/cjs/dockview/components/tab/defaultTab.d.ts +44 -44
- package/dist/cjs/dockview/components/tab/defaultTab.js +186 -186
- package/dist/cjs/dockview/components/watermark/watermark.d.ts +20 -20
- package/dist/cjs/dockview/components/watermark/watermark.js +99 -99
- package/dist/cjs/dockview/defaultGroupPanelView.d.ts +34 -34
- package/dist/cjs/dockview/defaultGroupPanelView.js +85 -83
- package/dist/cjs/dockview/defaultGroupPanelView.js.map +1 -1
- package/dist/cjs/dockview/deserializer.d.ts +14 -14
- package/dist/cjs/dockview/deserializer.js +47 -47
- package/dist/cjs/dockview/dockviewComponent.d.ts +121 -121
- package/dist/cjs/dockview/dockviewComponent.js +692 -692
- package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
- package/dist/cjs/dockview/dockviewGroupPanel.d.ts +35 -35
- package/dist/cjs/dockview/dockviewGroupPanel.js +195 -195
- package/dist/cjs/dockview/options.d.ts +79 -79
- package/dist/cjs/dockview/options.js +2 -2
- package/dist/cjs/dom.d.ts +14 -14
- package/dist/cjs/dom.js +182 -182
- package/dist/cjs/events.d.ts +30 -23
- package/dist/cjs/events.js +108 -87
- package/dist/cjs/events.js.map +1 -1
- package/dist/cjs/functions.d.ts +1 -1
- package/dist/cjs/functions.js +41 -41
- package/dist/cjs/gridview/baseComponentGridview.d.ts +98 -98
- package/dist/cjs/gridview/baseComponentGridview.js +285 -292
- package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
- package/dist/cjs/gridview/basePanelView.d.ts +46 -46
- package/dist/cjs/gridview/basePanelView.js +115 -115
- package/dist/cjs/gridview/branchNode.d.ts +46 -46
- package/dist/cjs/gridview/branchNode.js +342 -342
- package/dist/cjs/gridview/gridview.d.ts +123 -123
- package/dist/cjs/gridview/gridview.js +476 -477
- package/dist/cjs/gridview/gridview.js.map +1 -1
- package/dist/cjs/gridview/gridviewComponent.d.ts +88 -88
- package/dist/cjs/gridview/gridviewComponent.js +303 -303
- package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
- package/dist/cjs/gridview/gridviewPanel.d.ts +62 -62
- package/dist/cjs/gridview/gridviewPanel.js +205 -205
- package/dist/cjs/gridview/leafNode.d.ts +31 -31
- package/dist/cjs/gridview/leafNode.js +164 -164
- package/dist/cjs/gridview/options.d.ts +18 -18
- 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/groupview/dnd.d.ts +5 -5
- package/dist/cjs/groupview/dnd.js +9 -9
- package/dist/cjs/groupview/groupPanel.d.ts +41 -41
- package/dist/cjs/groupview/groupPanel.js +2 -2
- package/dist/cjs/groupview/groupview.d.ts +154 -154
- package/dist/cjs/groupview/groupview.js +633 -633
- package/dist/cjs/groupview/groupview.js.map +1 -1
- package/dist/cjs/groupview/groupviewPanel.d.ts +18 -18
- package/dist/cjs/groupview/groupviewPanel.js +83 -83
- package/dist/cjs/groupview/panel/content.d.ts +30 -30
- package/dist/cjs/groupview/panel/content.js +99 -99
- package/dist/cjs/groupview/panel/hostedPanel.d.ts +22 -22
- package/dist/cjs/groupview/panel/hostedPanel.js +56 -56
- package/dist/cjs/groupview/panel/hostedPanel.js.map +1 -1
- package/dist/cjs/groupview/tab.d.ts +44 -44
- package/dist/cjs/groupview/tab.js +182 -182
- package/dist/cjs/groupview/titlebar/tabsContainer.d.ts +66 -66
- package/dist/cjs/groupview/titlebar/tabsContainer.js +260 -260
- package/dist/cjs/groupview/titlebar/tabsContainer.js.map +1 -1
- package/dist/cjs/groupview/types.d.ts +59 -59
- package/dist/cjs/groupview/types.js +2 -2
- package/dist/cjs/hostedContainer.d.ts +23 -23
- package/dist/cjs/hostedContainer.js +73 -73
- package/dist/cjs/hostedContainer.js.map +1 -1
- package/dist/cjs/index.d.ts +28 -26
- package/dist/cjs/index.js +37 -35
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/json.d.ts +1 -1
- package/dist/cjs/json.js +13 -13
- package/dist/cjs/lifecycle.d.ts +22 -22
- package/dist/cjs/lifecycle.js +87 -87
- package/dist/cjs/math.d.ts +4 -4
- package/dist/cjs/math.js +15 -15
- package/dist/cjs/math.js.map +1 -1
- package/dist/cjs/panel/componentFactory.d.ts +8 -8
- package/dist/cjs/panel/componentFactory.js +30 -30
- package/dist/cjs/panel/componentFactory.js.map +1 -1
- package/dist/cjs/panel/types.d.ts +34 -34
- package/dist/cjs/panel/types.js +2 -2
- package/dist/cjs/paneview/defaultPaneviewHeader.d.ts +18 -18
- package/dist/cjs/paneview/defaultPaneviewHeader.js +64 -64
- package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +17 -17
- package/dist/cjs/paneview/draggablePaneviewPanel.js +111 -111
- package/dist/cjs/paneview/options.d.ts +25 -25
- package/dist/cjs/paneview/options.js +2 -2
- package/dist/cjs/paneview/paneview.d.ts +38 -38
- package/dist/cjs/paneview/paneview.js +195 -198
- package/dist/cjs/paneview/paneview.js.map +1 -1
- package/dist/cjs/paneview/paneviewComponent.d.ts +115 -113
- package/dist/cjs/paneview/paneviewComponent.js +338 -338
- package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
- package/dist/cjs/paneview/paneviewPanel.d.ts +85 -85
- package/dist/cjs/paneview/paneviewPanel.js +262 -262
- package/dist/cjs/paneview/paneviewPanel.js.map +1 -1
- package/dist/cjs/react/deserializer.d.ts +8 -8
- package/dist/cjs/react/deserializer.js +39 -39
- package/dist/cjs/react/dockview/components.d.ts +11 -11
- package/dist/cjs/react/dockview/components.js +76 -76
- package/dist/cjs/react/dockview/dockview.d.ts +34 -34
- package/dist/cjs/react/dockview/dockview.js +151 -135
- package/dist/cjs/react/dockview/dockview.js.map +1 -1
- package/dist/cjs/react/dockview/reactContentPart.d.ts +47 -47
- package/dist/cjs/react/dockview/reactContentPart.js +88 -88
- package/dist/cjs/react/dockview/reactHeaderPart.d.ts +24 -24
- package/dist/cjs/react/dockview/reactHeaderPart.js +50 -50
- package/dist/cjs/react/dockview/reactWatermarkPart.d.ts +30 -30
- package/dist/cjs/react/dockview/reactWatermarkPart.js +66 -66
- package/dist/cjs/react/dockview/v2/reactContentRenderer.d.ts +30 -30
- package/dist/cjs/react/dockview/v2/reactContentRenderer.js +90 -90
- package/dist/cjs/react/dockview/v2/reactGroupPanelView.d.ts +7 -7
- package/dist/cjs/react/dockview/v2/reactGroupPanelView.js +34 -34
- package/dist/cjs/react/dockview/v2/webviewContentRenderer.d.ts +18 -18
- package/dist/cjs/react/dockview/v2/webviewContentRenderer.js +45 -45
- package/dist/cjs/react/gridview/gridview.d.ts +24 -24
- package/dist/cjs/react/gridview/gridview.js +104 -96
- package/dist/cjs/react/gridview/gridview.js.map +1 -1
- package/dist/cjs/react/gridview/view.d.ts +10 -10
- package/dist/cjs/react/gridview/view.js +40 -40
- package/dist/cjs/react/index.d.ts +9 -9
- package/dist/cjs/react/index.js +21 -21
- package/dist/cjs/react/paneview/paneview.d.ts +28 -28
- package/dist/cjs/react/paneview/paneview.js +142 -138
- package/dist/cjs/react/paneview/paneview.js.map +1 -1
- package/dist/cjs/react/paneview/view.d.ts +20 -20
- package/dist/cjs/react/paneview/view.js +44 -44
- package/dist/cjs/react/react.d.ts +35 -35
- package/dist/cjs/react/react.js +181 -181
- package/dist/cjs/react/react.js.map +1 -1
- package/dist/cjs/react/splitview/splitview.d.ts +24 -24
- package/dist/cjs/react/splitview/splitview.js +101 -93
- package/dist/cjs/react/splitview/splitview.js.map +1 -1
- package/dist/cjs/react/splitview/view.d.ts +10 -10
- package/dist/cjs/react/splitview/view.js +40 -40
- package/dist/cjs/react/types.d.ts +7 -7
- package/dist/cjs/react/types.js +2 -2
- package/dist/cjs/splitview/core/options.d.ts +26 -26
- package/dist/cjs/splitview/core/options.js +2 -2
- package/dist/cjs/splitview/core/splitview.d.ts +124 -124
- package/dist/cjs/splitview/core/splitview.js +908 -908
- package/dist/cjs/splitview/core/splitview.js.map +1 -1
- package/dist/cjs/splitview/core/viewItem.d.ts +25 -25
- package/dist/cjs/splitview/core/viewItem.js +124 -124
- package/dist/cjs/splitview/splitviewComponent.d.ts +100 -100
- package/dist/cjs/splitview/splitviewComponent.js +327 -327
- package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
- package/dist/cjs/splitview/splitviewPanel.d.ts +47 -47
- package/dist/cjs/splitview/splitviewPanel.js +178 -178
- package/dist/cjs/types.d.ts +7 -7
- package/dist/cjs/types.js +2 -2
- package/dist/dockview.amd.js +6759 -6712
- package/dist/dockview.amd.min.js +3 -3
- package/dist/dockview.amd.min.noStyle.js +3 -3
- package/dist/dockview.amd.noStyle.js +6752 -6705
- package/dist/dockview.cjs.js +6755 -6708
- package/dist/dockview.esm.js +6750 -6707
- package/dist/dockview.esm.min.js +3 -3
- package/dist/dockview.js +6759 -6712
- package/dist/dockview.min.js +3 -3
- package/dist/dockview.min.noStyle.js +3 -3
- package/dist/dockview.noStyle.js +6752 -6705
- package/dist/esm/actionbar/actionsContainer.d.ts +7 -7
- package/dist/esm/actionbar/actionsContainer.js +17 -17
- package/dist/esm/api/component.api.d.ts +135 -131
- package/dist/esm/api/component.api.js +305 -287
- package/dist/esm/api/gridviewPanelApi.d.ts +36 -36
- package/dist/esm/api/gridviewPanelApi.js +24 -24
- package/dist/esm/api/groupPanelApi.d.ts +44 -44
- package/dist/esm/api/groupPanelApi.js +52 -52
- package/dist/esm/api/panelApi.d.ts +107 -107
- package/dist/esm/api/panelApi.js +98 -98
- package/dist/esm/api/paneviewPanelApi.d.ts +26 -26
- package/dist/esm/api/paneviewPanelApi.js +26 -26
- package/dist/esm/api/splitviewPanelApi.d.ts +33 -33
- package/dist/esm/api/splitviewPanelApi.js +29 -29
- package/dist/esm/array.d.ts +13 -13
- package/dist/esm/array.js +67 -67
- package/dist/esm/dnd/abstractDragHandler.d.ts +11 -11
- package/dist/esm/dnd/abstractDragHandler.js +37 -37
- package/dist/esm/dnd/dataTransfer.d.ts +56 -56
- package/dist/esm/dnd/dataTransfer.js +109 -109
- package/dist/esm/dnd/dnd.d.ts +40 -40
- package/dist/esm/dnd/dnd.js +109 -109
- package/dist/esm/dnd/droptarget.d.ts +33 -37
- package/dist/esm/dnd/droptarget.js +143 -143
- package/dist/esm/dockview/components/tab/defaultTab.d.ts +44 -44
- package/dist/esm/dockview/components/tab/defaultTab.js +130 -130
- package/dist/esm/dockview/components/watermark/watermark.d.ts +20 -20
- package/dist/esm/dockview/components/watermark/watermark.js +68 -68
- package/dist/esm/dockview/defaultGroupPanelView.d.ts +34 -34
- package/dist/esm/dockview/defaultGroupPanelView.js +57 -55
- package/dist/esm/dockview/deserializer.d.ts +14 -14
- package/dist/esm/dockview/deserializer.js +20 -20
- package/dist/esm/dockview/dockviewComponent.d.ts +121 -121
- package/dist/esm/dockview/dockviewComponent.js +533 -533
- package/dist/esm/dockview/dockviewGroupPanel.d.ts +35 -35
- package/dist/esm/dockview/dockviewGroupPanel.js +145 -145
- package/dist/esm/dockview/options.d.ts +79 -79
- package/dist/esm/dockview/options.js +1 -1
- package/dist/esm/dom.d.ts +14 -14
- package/dist/esm/dom.js +113 -113
- package/dist/esm/events.d.ts +30 -23
- package/dist/esm/events.js +89 -71
- package/dist/esm/functions.d.ts +1 -1
- package/dist/esm/functions.js +8 -8
- package/dist/esm/gridview/baseComponentGridview.d.ts +98 -98
- package/dist/esm/gridview/baseComponentGridview.js +217 -224
- package/dist/esm/gridview/basePanelView.d.ts +46 -46
- package/dist/esm/gridview/basePanelView.js +70 -70
- package/dist/esm/gridview/branchNode.d.ts +46 -46
- package/dist/esm/gridview/branchNode.js +218 -218
- package/dist/esm/gridview/gridview.d.ts +123 -123
- package/dist/esm/gridview/gridview.js +395 -396
- package/dist/esm/gridview/gridviewComponent.d.ts +88 -88
- package/dist/esm/gridview/gridviewComponent.js +238 -238
- package/dist/esm/gridview/gridviewPanel.d.ts +62 -62
- package/dist/esm/gridview/gridviewPanel.js +141 -141
- package/dist/esm/gridview/leafNode.d.ts +31 -31
- package/dist/esm/gridview/leafNode.js +97 -97
- package/dist/esm/gridview/options.d.ts +18 -18
- 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/groupview/dnd.d.ts +5 -5
- package/dist/esm/groupview/dnd.js +6 -6
- package/dist/esm/groupview/groupPanel.d.ts +41 -41
- package/dist/esm/groupview/groupPanel.js +1 -1
- package/dist/esm/groupview/groupview.d.ts +154 -154
- package/dist/esm/groupview/groupview.js +448 -448
- package/dist/esm/groupview/groupviewPanel.d.ts +18 -18
- package/dist/esm/groupview/groupviewPanel.js +41 -41
- package/dist/esm/groupview/panel/content.d.ts +30 -30
- package/dist/esm/groupview/panel/content.js +72 -72
- package/dist/esm/groupview/panel/hostedPanel.d.ts +22 -22
- package/dist/esm/groupview/panel/hostedPanel.js +43 -43
- package/dist/esm/groupview/tab.d.ts +44 -44
- package/dist/esm/groupview/tab.js +101 -101
- package/dist/esm/groupview/titlebar/tabsContainer.d.ts +66 -66
- package/dist/esm/groupview/titlebar/tabsContainer.js +185 -185
- package/dist/esm/groupview/types.d.ts +59 -59
- package/dist/esm/groupview/types.js +1 -1
- package/dist/esm/hostedContainer.d.ts +23 -23
- package/dist/esm/hostedContainer.js +63 -63
- package/dist/esm/index.d.ts +28 -26
- package/dist/esm/index.js +23 -21
- package/dist/esm/json.d.ts +1 -1
- package/dist/esm/json.js +9 -9
- package/dist/esm/lifecycle.d.ts +22 -22
- package/dist/esm/lifecycle.js +38 -38
- package/dist/esm/math.d.ts +4 -4
- package/dist/esm/math.js +10 -10
- package/dist/esm/panel/componentFactory.d.ts +8 -8
- package/dist/esm/panel/componentFactory.js +24 -24
- package/dist/esm/panel/types.d.ts +34 -34
- package/dist/esm/panel/types.js +1 -1
- package/dist/esm/paneview/defaultPaneviewHeader.d.ts +18 -18
- package/dist/esm/paneview/defaultPaneviewHeader.js +37 -37
- package/dist/esm/paneview/draggablePaneviewPanel.d.ts +17 -17
- package/dist/esm/paneview/draggablePaneviewPanel.js +72 -72
- package/dist/esm/paneview/options.d.ts +25 -25
- package/dist/esm/paneview/options.js +1 -1
- package/dist/esm/paneview/paneview.d.ts +38 -38
- package/dist/esm/paneview/paneview.js +141 -144
- package/dist/esm/paneview/paneviewComponent.d.ts +115 -113
- package/dist/esm/paneview/paneviewComponent.js +247 -247
- package/dist/esm/paneview/paneviewPanel.d.ts +85 -85
- package/dist/esm/paneview/paneviewPanel.js +183 -183
- package/dist/esm/react/deserializer.d.ts +8 -8
- package/dist/esm/react/deserializer.js +34 -34
- package/dist/esm/react/dockview/components.d.ts +11 -11
- package/dist/esm/react/dockview/components.js +54 -54
- package/dist/esm/react/dockview/dockview.d.ts +34 -34
- package/dist/esm/react/dockview/dockview.js +113 -97
- package/dist/esm/react/dockview/reactContentPart.d.ts +47 -47
- package/dist/esm/react/dockview/reactContentPart.js +75 -75
- package/dist/esm/react/dockview/reactHeaderPart.d.ts +24 -24
- package/dist/esm/react/dockview/reactHeaderPart.js +41 -41
- package/dist/esm/react/dockview/reactWatermarkPart.d.ts +30 -30
- package/dist/esm/react/dockview/reactWatermarkPart.js +56 -56
- package/dist/esm/react/dockview/v2/reactContentRenderer.d.ts +30 -30
- package/dist/esm/react/dockview/v2/reactContentRenderer.js +72 -72
- package/dist/esm/react/dockview/v2/reactGroupPanelView.d.ts +7 -7
- package/dist/esm/react/dockview/v2/reactGroupPanelView.js +12 -12
- package/dist/esm/react/dockview/v2/webviewContentRenderer.d.ts +18 -18
- package/dist/esm/react/dockview/v2/webviewContentRenderer.js +36 -36
- package/dist/esm/react/gridview/gridview.d.ts +24 -24
- package/dist/esm/react/gridview/gridview.js +66 -58
- package/dist/esm/react/gridview/view.d.ts +10 -10
- package/dist/esm/react/gridview/view.js +18 -18
- package/dist/esm/react/index.d.ts +9 -9
- package/dist/esm/react/index.js +9 -9
- package/dist/esm/react/paneview/paneview.d.ts +28 -28
- package/dist/esm/react/paneview/paneview.js +91 -87
- package/dist/esm/react/paneview/view.d.ts +20 -20
- package/dist/esm/react/paneview/view.js +35 -35
- package/dist/esm/react/react.d.ts +35 -35
- package/dist/esm/react/react.js +116 -116
- package/dist/esm/react/splitview/splitview.d.ts +24 -24
- package/dist/esm/react/splitview/splitview.js +63 -55
- package/dist/esm/react/splitview/view.d.ts +10 -10
- package/dist/esm/react/splitview/view.js +18 -18
- package/dist/esm/react/types.d.ts +7 -7
- package/dist/esm/react/types.js +1 -1
- package/dist/esm/splitview/core/options.d.ts +26 -26
- package/dist/esm/splitview/core/options.js +1 -1
- package/dist/esm/splitview/core/splitview.d.ts +124 -124
- package/dist/esm/splitview/core/splitview.js +689 -689
- package/dist/esm/splitview/core/viewItem.d.ts +25 -25
- package/dist/esm/splitview/core/viewItem.js +79 -79
- package/dist/esm/splitview/splitviewComponent.d.ts +100 -100
- package/dist/esm/splitview/splitviewComponent.js +241 -241
- package/dist/esm/splitview/splitviewPanel.d.ts +47 -47
- package/dist/esm/splitview/splitviewPanel.js +107 -107
- package/dist/esm/types.d.ts +7 -7
- package/dist/esm/types.js +1 -1
- package/dist/styles/dockview.css +45 -45
- package/package.json +75 -75
- package/dist/cjs/footnote.d.ts +0 -1
- package/dist/cjs/footnote.js +0 -20
- package/dist/cjs/footnote.js.map +0 -1
- package/dist/esm/footnote.d.ts +0 -1
- package/dist/esm/footnote.js +0 -19
|
@@ -1,533 +1,533 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { getRelativeLocation, getGridLocation, } from '../gridview/gridview';
|
|
11
|
-
import { Position } from '../dnd/droptarget';
|
|
12
|
-
import { tail, sequenceEquals } from '../array';
|
|
13
|
-
import { DockviewGroupPanel } from './dockviewGroupPanel';
|
|
14
|
-
import { CompositeDisposable } from '../lifecycle';
|
|
15
|
-
import { Emitter } from '../events';
|
|
16
|
-
import { Watermark } from './components/watermark/watermark';
|
|
17
|
-
import { debounce } from '../functions';
|
|
18
|
-
import { sequentialNumberGenerator } from '../math';
|
|
19
|
-
import { DefaultDeserializer } from './deserializer';
|
|
20
|
-
import { createComponent } from '../panel/componentFactory';
|
|
21
|
-
import { BaseGrid, GroupChangeKind, toTarget, } from '../gridview/baseComponentGridview';
|
|
22
|
-
import { DockviewApi } from '../api/component.api';
|
|
23
|
-
import { MouseEventKind } from '../groupview/tab';
|
|
24
|
-
import { Orientation } from '../splitview/core/splitview';
|
|
25
|
-
import { DefaultTab } from './components/tab/defaultTab';
|
|
26
|
-
import { GroupChangeKind2, } from '../groupview/groupview';
|
|
27
|
-
import { GroupviewPanel } from '../groupview/groupviewPanel';
|
|
28
|
-
import { DefaultGroupPanelView } from './defaultGroupPanelView';
|
|
29
|
-
const nextGroupId = sequentialNumberGenerator();
|
|
30
|
-
export class DockviewComponent extends BaseGrid {
|
|
31
|
-
constructor(element, options) {
|
|
32
|
-
super(element, {
|
|
33
|
-
proportionalLayout: true,
|
|
34
|
-
orientation: options.orientation || Orientation.HORIZONTAL,
|
|
35
|
-
styles: options.styles,
|
|
36
|
-
});
|
|
37
|
-
this._panels = new Map();
|
|
38
|
-
this.dirtyPanels = new Set();
|
|
39
|
-
this.debouncedDeque = debounce(this.syncConfigs.bind(this), 5000);
|
|
40
|
-
// events
|
|
41
|
-
this._onTabInteractionEvent = new Emitter();
|
|
42
|
-
this.onTabInteractionEvent = this._onTabInteractionEvent.event;
|
|
43
|
-
this._onTabContextMenu = new Emitter();
|
|
44
|
-
this.onTabContextMenu = this._onTabContextMenu.event;
|
|
45
|
-
this.panelState = {};
|
|
46
|
-
this._options = options;
|
|
47
|
-
if (!this.options.components) {
|
|
48
|
-
this.options.components = {};
|
|
49
|
-
}
|
|
50
|
-
if (!this.options.frameworkComponents) {
|
|
51
|
-
this.options.frameworkComponents = {};
|
|
52
|
-
}
|
|
53
|
-
if (!this.options.frameworkTabComponents) {
|
|
54
|
-
this.options.frameworkTabComponents = {};
|
|
55
|
-
}
|
|
56
|
-
if (!this.options.tabComponents) {
|
|
57
|
-
this.options.tabComponents = {};
|
|
58
|
-
}
|
|
59
|
-
if (!this.options.watermarkComponent &&
|
|
60
|
-
!this.options.watermarkFrameworkComponent) {
|
|
61
|
-
this.options.watermarkComponent = Watermark;
|
|
62
|
-
}
|
|
63
|
-
this._api = new DockviewApi(this);
|
|
64
|
-
}
|
|
65
|
-
get totalPanels() {
|
|
66
|
-
return this._panels.size;
|
|
67
|
-
}
|
|
68
|
-
get panels() {
|
|
69
|
-
return Array.from(this._panels.values()).map((_) => _.value);
|
|
70
|
-
}
|
|
71
|
-
get deserializer() {
|
|
72
|
-
return this._deserializer;
|
|
73
|
-
}
|
|
74
|
-
set deserializer(value) {
|
|
75
|
-
this._deserializer = value;
|
|
76
|
-
}
|
|
77
|
-
get options() {
|
|
78
|
-
return this._options;
|
|
79
|
-
}
|
|
80
|
-
get activePanel() {
|
|
81
|
-
const activeGroup = this.activeGroup;
|
|
82
|
-
if (!activeGroup) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
return activeGroup.model.activePanel;
|
|
86
|
-
}
|
|
87
|
-
set tabHeight(height) {
|
|
88
|
-
this.options.tabHeight = height;
|
|
89
|
-
this._groups.forEach((value) => {
|
|
90
|
-
value.value.model.tabHeight = height;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
get tabHeight() {
|
|
94
|
-
return this.options.tabHeight;
|
|
95
|
-
}
|
|
96
|
-
updateOptions(options) {
|
|
97
|
-
const hasOrientationChanged = typeof options.orientation === 'string' &&
|
|
98
|
-
this.options.orientation !== options.orientation;
|
|
99
|
-
// TODO support style update
|
|
100
|
-
// const hasStylesChanged =
|
|
101
|
-
// typeof options.styles === 'object' &&
|
|
102
|
-
// this.options.styles !== options.styles;
|
|
103
|
-
this._options = Object.assign(Object.assign({}, this.options), options);
|
|
104
|
-
if (hasOrientationChanged) {
|
|
105
|
-
this.gridview.orientation = options.orientation;
|
|
106
|
-
}
|
|
107
|
-
this.layout(this.gridview.width, this.gridview.height, true);
|
|
108
|
-
}
|
|
109
|
-
focus() {
|
|
110
|
-
var _a;
|
|
111
|
-
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
112
|
-
}
|
|
113
|
-
getGroupPanel(id) {
|
|
114
|
-
var _a;
|
|
115
|
-
return (_a = this._panels.get(id)) === null || _a === void 0 ? void 0 : _a.value;
|
|
116
|
-
}
|
|
117
|
-
setActivePanel(panel) {
|
|
118
|
-
if (!panel.group) {
|
|
119
|
-
throw new Error(`Panel ${panel.id} has no associated group`);
|
|
120
|
-
}
|
|
121
|
-
this.doSetGroupActive(panel.group);
|
|
122
|
-
panel.group.model.openPanel(panel);
|
|
123
|
-
}
|
|
124
|
-
moveToNext(options = {}) {
|
|
125
|
-
var _a;
|
|
126
|
-
if (!options.group) {
|
|
127
|
-
if (!this.activeGroup) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
options.group = this.activeGroup;
|
|
131
|
-
}
|
|
132
|
-
if (options.includePanel && options.group) {
|
|
133
|
-
if (options.group.model.activePanel !==
|
|
134
|
-
options.group.model.panels[options.group.model.panels.length - 1]) {
|
|
135
|
-
options.group.model.moveToNext({ suppressRoll: true });
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const location = getGridLocation(options.group.element);
|
|
140
|
-
const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
141
|
-
this.doSetGroupActive(next);
|
|
142
|
-
}
|
|
143
|
-
moveToPrevious(options = {}) {
|
|
144
|
-
var _a;
|
|
145
|
-
if (!options.group) {
|
|
146
|
-
if (!this.activeGroup) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
options.group = this.activeGroup;
|
|
150
|
-
}
|
|
151
|
-
if (options.includePanel && options.group) {
|
|
152
|
-
if (options.group.model.activePanel !==
|
|
153
|
-
options.group.model.panels[0]) {
|
|
154
|
-
options.group.model.moveToPrevious({ suppressRoll: true });
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
const location = getGridLocation(options.group.element);
|
|
159
|
-
const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
160
|
-
if (next) {
|
|
161
|
-
this.doSetGroupActive(next);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
registerPanel(panel) {
|
|
165
|
-
if (this._panels.has(panel.id)) {
|
|
166
|
-
throw new Error(`panel ${panel.id} already exists`);
|
|
167
|
-
}
|
|
168
|
-
const disposable = new CompositeDisposable(panel.onDidStateChange(() => this.addDirtyPanel(panel)));
|
|
169
|
-
this._panels.set(panel.id, { value: panel, disposable });
|
|
170
|
-
}
|
|
171
|
-
unregisterPanel(panel) {
|
|
172
|
-
if (!this._panels.has(panel.id)) {
|
|
173
|
-
throw new Error(`panel ${panel.id} doesn't exist`);
|
|
174
|
-
}
|
|
175
|
-
const item = this._panels.get(panel.id);
|
|
176
|
-
if (item) {
|
|
177
|
-
item.disposable.dispose();
|
|
178
|
-
item.value.dispose();
|
|
179
|
-
}
|
|
180
|
-
this._panels.delete(panel.id);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Serialize the current state of the layout
|
|
184
|
-
*
|
|
185
|
-
* @returns A JSON respresentation of the layout
|
|
186
|
-
*/
|
|
187
|
-
toJSON() {
|
|
188
|
-
var _a;
|
|
189
|
-
this.syncConfigs();
|
|
190
|
-
const data = this.gridview.serialize();
|
|
191
|
-
const panels = Array.from(this._panels.values()).reduce((collection, panel) => {
|
|
192
|
-
if (!this.panelState[panel.value.id]) {
|
|
193
|
-
collection[panel.value.id] = panel.value.toJSON();
|
|
194
|
-
}
|
|
195
|
-
return collection;
|
|
196
|
-
}, {});
|
|
197
|
-
return {
|
|
198
|
-
grid: data,
|
|
199
|
-
panels,
|
|
200
|
-
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
201
|
-
options: { tabHeight: this.tabHeight },
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
fromJSON(data) {
|
|
205
|
-
this.gridview.clear();
|
|
206
|
-
this._panels.forEach((panel) => {
|
|
207
|
-
panel.disposable.dispose();
|
|
208
|
-
panel.value.dispose();
|
|
209
|
-
});
|
|
210
|
-
this._panels.clear();
|
|
211
|
-
this._groups.clear();
|
|
212
|
-
if (!this.deserializer) {
|
|
213
|
-
throw new Error('invalid deserializer');
|
|
214
|
-
}
|
|
215
|
-
const { grid, panels, options, activeGroup } = data;
|
|
216
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.tabHeight) === 'number') {
|
|
217
|
-
this.tabHeight = options.tabHeight;
|
|
218
|
-
}
|
|
219
|
-
if (!this.deserializer) {
|
|
220
|
-
throw new Error('no deserializer provided');
|
|
221
|
-
}
|
|
222
|
-
this.gridview.deserialize(grid, new DefaultDeserializer(this, {
|
|
223
|
-
createPanel: (id) => {
|
|
224
|
-
const panelData = panels[id];
|
|
225
|
-
const panel = this.deserializer.fromJSON(panelData);
|
|
226
|
-
this.registerPanel(panel);
|
|
227
|
-
return panel;
|
|
228
|
-
},
|
|
229
|
-
}));
|
|
230
|
-
if (typeof activeGroup === 'string') {
|
|
231
|
-
const panel = this.getPanel(activeGroup);
|
|
232
|
-
if (panel) {
|
|
233
|
-
this.doSetGroupActive(panel);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
this.gridview.layout(this.width, this.height);
|
|
237
|
-
this._onGridEvent.fire({ kind: GroupChangeKind.LAYOUT_FROM_JSON });
|
|
238
|
-
}
|
|
239
|
-
closeAllGroups() {
|
|
240
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
-
for (const entry of this._groups.entries()) {
|
|
242
|
-
const [_, group] = entry;
|
|
243
|
-
const didCloseAll = yield group.value.model.closeAllPanels();
|
|
244
|
-
if (!didCloseAll) {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return true;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
fireMouseEvent(event) {
|
|
252
|
-
switch (event.kind) {
|
|
253
|
-
case MouseEventKind.CONTEXT_MENU:
|
|
254
|
-
if (event.tab && event.panel) {
|
|
255
|
-
this._onTabContextMenu.fire({
|
|
256
|
-
event: event.event,
|
|
257
|
-
api: this._api,
|
|
258
|
-
panel: event.panel,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
addPanel(options) {
|
|
265
|
-
var _a, _b;
|
|
266
|
-
const panel = this._addPanel(options);
|
|
267
|
-
let referenceGroup;
|
|
268
|
-
if ((_a = options.position) === null || _a === void 0 ? void 0 : _a.referencePanel) {
|
|
269
|
-
const referencePanel = this.getGroupPanel(options.position.referencePanel);
|
|
270
|
-
if (!referencePanel) {
|
|
271
|
-
throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
|
|
272
|
-
}
|
|
273
|
-
referenceGroup = this.findGroup(referencePanel);
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
referenceGroup = this.activeGroup;
|
|
277
|
-
}
|
|
278
|
-
if (referenceGroup) {
|
|
279
|
-
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
280
|
-
if (target === Position.Center) {
|
|
281
|
-
referenceGroup.model.openPanel(panel);
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
const location = getGridLocation(referenceGroup.element);
|
|
285
|
-
const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
|
|
286
|
-
this.addPanelToNewGroup(panel, relativeLocation);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
this.addPanelToNewGroup(panel);
|
|
291
|
-
}
|
|
292
|
-
return panel;
|
|
293
|
-
}
|
|
294
|
-
removePanel(panel) {
|
|
295
|
-
this.unregisterPanel(panel);
|
|
296
|
-
const group = panel.group;
|
|
297
|
-
if (!group) {
|
|
298
|
-
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
299
|
-
}
|
|
300
|
-
group.model.removePanel(panel);
|
|
301
|
-
if (group.model.size === 0) {
|
|
302
|
-
this.removeGroup(group);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
createWatermarkComponent() {
|
|
306
|
-
var _a;
|
|
307
|
-
return createComponent('watermark-id', 'watermark-name', this.options.watermarkComponent
|
|
308
|
-
? { 'watermark-name': this.options.watermarkComponent }
|
|
309
|
-
: {}, this.options.watermarkFrameworkComponent
|
|
310
|
-
? { 'watermark-name': this.options.watermarkFrameworkComponent }
|
|
311
|
-
: {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
|
|
312
|
-
}
|
|
313
|
-
addEmptyGroup(options) {
|
|
314
|
-
var _a;
|
|
315
|
-
const group = this.createGroup();
|
|
316
|
-
if (options) {
|
|
317
|
-
const referencePanel = (_a = this._panels.get(options.referencePanel)) === null || _a === void 0 ? void 0 : _a.value;
|
|
318
|
-
if (!referencePanel) {
|
|
319
|
-
throw new Error(`reference panel ${options.referencePanel} does not exist`);
|
|
320
|
-
}
|
|
321
|
-
const referenceGroup = this.findGroup(referencePanel);
|
|
322
|
-
if (!referenceGroup) {
|
|
323
|
-
throw new Error(`reference group for reference panel ${options.referencePanel} does not exist`);
|
|
324
|
-
}
|
|
325
|
-
const target = toTarget(options.direction || 'within');
|
|
326
|
-
const location = getGridLocation(referenceGroup.element);
|
|
327
|
-
const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
|
|
328
|
-
this.doAddGroup(group, relativeLocation);
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
this.doAddGroup(group);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
removeGroup(group) {
|
|
335
|
-
const panels = [...group.model.panels]; // reassign since group panels will mutate
|
|
336
|
-
panels.forEach((panel) => {
|
|
337
|
-
this.removePanel(panel);
|
|
338
|
-
});
|
|
339
|
-
if (this._groups.size === 1) {
|
|
340
|
-
this._activeGroup = group;
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
super.removeGroup(group);
|
|
344
|
-
}
|
|
345
|
-
moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
|
|
346
|
-
var _a, _b, _c;
|
|
347
|
-
const sourceGroup = groupId
|
|
348
|
-
? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
|
|
349
|
-
: undefined;
|
|
350
|
-
if (!target || target === Position.Center) {
|
|
351
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
|
|
352
|
-
((_b = this._panels.get(itemId)) === null || _b === void 0 ? void 0 : _b.value);
|
|
353
|
-
if (!groupItem) {
|
|
354
|
-
throw new Error(`No panel with id ${itemId}`);
|
|
355
|
-
}
|
|
356
|
-
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
357
|
-
this.doRemoveGroup(sourceGroup);
|
|
358
|
-
}
|
|
359
|
-
referenceGroup.model.openPanel(groupItem, { index });
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
363
|
-
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
364
|
-
if (sourceGroup && sourceGroup.model.size < 2) {
|
|
365
|
-
const [targetParentLocation, to] = tail(targetLocation);
|
|
366
|
-
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
367
|
-
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
368
|
-
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
369
|
-
// special case when 'swapping' two views within same grid location
|
|
370
|
-
// if a group has one tab - we are essentially moving the 'group'
|
|
371
|
-
// which is equivalent to swapping two views in this case
|
|
372
|
-
this.gridview.moveView(sourceParentLocation, from, to);
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
// source group will become empty so delete the group
|
|
376
|
-
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
377
|
-
skipActive: true,
|
|
378
|
-
skipDispose: true,
|
|
379
|
-
});
|
|
380
|
-
// after deleting the group we need to re-evaulate the ref location
|
|
381
|
-
const updatedReferenceLocation = getGridLocation(referenceGroup.element);
|
|
382
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, target);
|
|
383
|
-
this.doAddGroup(targetGroup, location);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
|
|
388
|
-
((_c = this._panels.get(itemId)) === null || _c === void 0 ? void 0 : _c.value);
|
|
389
|
-
if (!groupItem) {
|
|
390
|
-
throw new Error(`No panel with id ${itemId}`);
|
|
391
|
-
}
|
|
392
|
-
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
393
|
-
this.addPanelToNewGroup(groupItem, dropLocation);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
doSetGroupActive(group, skipFocus) {
|
|
398
|
-
var _a, _b;
|
|
399
|
-
const isGroupAlreadyFocused = this._activeGroup === group;
|
|
400
|
-
super.doSetGroupActive(group, skipFocus);
|
|
401
|
-
if (!isGroupAlreadyFocused && ((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.model.activePanel)) {
|
|
402
|
-
this._onGridEvent.fire({
|
|
403
|
-
kind: GroupChangeKind.PANEL_ACTIVE,
|
|
404
|
-
panel: (_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.model.activePanel,
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
createGroup(options) {
|
|
409
|
-
if (!options) {
|
|
410
|
-
options = { tabHeight: this.tabHeight };
|
|
411
|
-
}
|
|
412
|
-
if (typeof options.tabHeight !== 'number') {
|
|
413
|
-
options.tabHeight = this.tabHeight;
|
|
414
|
-
}
|
|
415
|
-
let id = options === null || options === void 0 ? void 0 : options.id;
|
|
416
|
-
if (id && this._groups.has(options.id)) {
|
|
417
|
-
console.warn(`Duplicate group id ${options === null || options === void 0 ? void 0 : options.id}. reassigning group id to avoid errors`);
|
|
418
|
-
id = undefined;
|
|
419
|
-
}
|
|
420
|
-
if (!id) {
|
|
421
|
-
id = nextGroupId.next();
|
|
422
|
-
while (this._groups.has(id)) {
|
|
423
|
-
id = nextGroupId.next();
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
const view = new GroupviewPanel(this, id, options);
|
|
427
|
-
if (!this._groups.has(view.id)) {
|
|
428
|
-
const disposable = new CompositeDisposable(view.model.onMove((event) => {
|
|
429
|
-
const { groupId, itemId, target, index } = event;
|
|
430
|
-
this.moveGroupOrPanel(view, groupId, itemId, target, index);
|
|
431
|
-
}), view.model.onDidGroupChange((event) => {
|
|
432
|
-
switch (event.kind) {
|
|
433
|
-
case GroupChangeKind2.ADD_PANEL:
|
|
434
|
-
this._onGridEvent.fire({
|
|
435
|
-
kind: GroupChangeKind.ADD_PANEL,
|
|
436
|
-
panel: event.panel,
|
|
437
|
-
});
|
|
438
|
-
break;
|
|
439
|
-
case GroupChangeKind2.GROUP_ACTIVE:
|
|
440
|
-
this._onGridEvent.fire({
|
|
441
|
-
kind: GroupChangeKind.GROUP_ACTIVE,
|
|
442
|
-
panel: event.panel,
|
|
443
|
-
});
|
|
444
|
-
break;
|
|
445
|
-
case GroupChangeKind2.REMOVE_PANEL:
|
|
446
|
-
this._onGridEvent.fire({
|
|
447
|
-
kind: GroupChangeKind.REMOVE_PANEL,
|
|
448
|
-
panel: event.panel,
|
|
449
|
-
});
|
|
450
|
-
break;
|
|
451
|
-
case GroupChangeKind2.PANEL_ACTIVE:
|
|
452
|
-
this._onGridEvent.fire({
|
|
453
|
-
kind: GroupChangeKind.PANEL_ACTIVE,
|
|
454
|
-
panel: event.panel,
|
|
455
|
-
});
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
}));
|
|
459
|
-
this._groups.set(view.id, { value: view, disposable });
|
|
460
|
-
}
|
|
461
|
-
// TODO: must be called after the above listeners have been setup,
|
|
462
|
-
// not an ideal pattern
|
|
463
|
-
view.initialize();
|
|
464
|
-
if (typeof this.options.tabHeight === 'number') {
|
|
465
|
-
view.model.tabHeight = this.options.tabHeight;
|
|
466
|
-
}
|
|
467
|
-
return view;
|
|
468
|
-
}
|
|
469
|
-
dispose() {
|
|
470
|
-
super.dispose();
|
|
471
|
-
this._onGridEvent.dispose();
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Ensure the local copy of the layout state is up-to-date
|
|
475
|
-
*/
|
|
476
|
-
syncConfigs() {
|
|
477
|
-
const dirtyPanels = Array.from(this.dirtyPanels);
|
|
478
|
-
if (dirtyPanels.length === 0) {
|
|
479
|
-
//
|
|
480
|
-
}
|
|
481
|
-
this.dirtyPanels.clear();
|
|
482
|
-
const partialPanelState = dirtyPanels
|
|
483
|
-
.map((panel) => this._panels.get(panel.id))
|
|
484
|
-
.filter((_) => !!_)
|
|
485
|
-
.reduce((collection, panel) => {
|
|
486
|
-
collection[panel.value.id] = panel.value.toJSON();
|
|
487
|
-
return collection;
|
|
488
|
-
}, {});
|
|
489
|
-
this.panelState = Object.assign(Object.assign({}, this.panelState), partialPanelState);
|
|
490
|
-
dirtyPanels
|
|
491
|
-
.filter((p) => this._panels.has(p.id))
|
|
492
|
-
.forEach((panel) => {
|
|
493
|
-
panel.setDirty(false);
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
_addPanel(options) {
|
|
497
|
-
const view = new DefaultGroupPanelView({
|
|
498
|
-
content: this.createContentComponent(options.id, options.component),
|
|
499
|
-
tab: this.createTabComponent(options.id, options.tabComponent),
|
|
500
|
-
});
|
|
501
|
-
const panel = new DockviewGroupPanel(options.id, this._api);
|
|
502
|
-
panel.init({
|
|
503
|
-
view,
|
|
504
|
-
title: options.title || options.id,
|
|
505
|
-
suppressClosable: options === null || options === void 0 ? void 0 : options.suppressClosable,
|
|
506
|
-
params: (options === null || options === void 0 ? void 0 : options.params) || {},
|
|
507
|
-
});
|
|
508
|
-
this.registerPanel(panel);
|
|
509
|
-
return panel;
|
|
510
|
-
}
|
|
511
|
-
createContentComponent(id, componentName) {
|
|
512
|
-
var _a;
|
|
513
|
-
return createComponent(id, componentName, this.options.components || {}, this.options.frameworkComponents, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.content);
|
|
514
|
-
}
|
|
515
|
-
createTabComponent(id, componentName) {
|
|
516
|
-
var _a;
|
|
517
|
-
return createComponent(id, componentName, this.options.tabComponents || {}, this.options.frameworkTabComponents, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.tab, () => new DefaultTab());
|
|
518
|
-
}
|
|
519
|
-
addPanelToNewGroup(panel, location = [0]) {
|
|
520
|
-
const group = this.createGroup();
|
|
521
|
-
this.doAddGroup(group, location);
|
|
522
|
-
group.model.openPanel(panel);
|
|
523
|
-
}
|
|
524
|
-
findGroup(panel) {
|
|
525
|
-
var _a;
|
|
526
|
-
return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
|
|
527
|
-
}
|
|
528
|
-
addDirtyPanel(panel) {
|
|
529
|
-
this.dirtyPanels.add(panel);
|
|
530
|
-
panel.setDirty(true);
|
|
531
|
-
this.debouncedDeque();
|
|
532
|
-
}
|
|
533
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { getRelativeLocation, getGridLocation, } from '../gridview/gridview';
|
|
11
|
+
import { Position } from '../dnd/droptarget';
|
|
12
|
+
import { tail, sequenceEquals } from '../array';
|
|
13
|
+
import { DockviewGroupPanel } from './dockviewGroupPanel';
|
|
14
|
+
import { CompositeDisposable } from '../lifecycle';
|
|
15
|
+
import { Emitter } from '../events';
|
|
16
|
+
import { Watermark } from './components/watermark/watermark';
|
|
17
|
+
import { debounce } from '../functions';
|
|
18
|
+
import { sequentialNumberGenerator } from '../math';
|
|
19
|
+
import { DefaultDeserializer } from './deserializer';
|
|
20
|
+
import { createComponent } from '../panel/componentFactory';
|
|
21
|
+
import { BaseGrid, GroupChangeKind, toTarget, } from '../gridview/baseComponentGridview';
|
|
22
|
+
import { DockviewApi } from '../api/component.api';
|
|
23
|
+
import { MouseEventKind } from '../groupview/tab';
|
|
24
|
+
import { Orientation } from '../splitview/core/splitview';
|
|
25
|
+
import { DefaultTab } from './components/tab/defaultTab';
|
|
26
|
+
import { GroupChangeKind2, } from '../groupview/groupview';
|
|
27
|
+
import { GroupviewPanel } from '../groupview/groupviewPanel';
|
|
28
|
+
import { DefaultGroupPanelView } from './defaultGroupPanelView';
|
|
29
|
+
const nextGroupId = sequentialNumberGenerator();
|
|
30
|
+
export class DockviewComponent extends BaseGrid {
|
|
31
|
+
constructor(element, options) {
|
|
32
|
+
super(element, {
|
|
33
|
+
proportionalLayout: true,
|
|
34
|
+
orientation: options.orientation || Orientation.HORIZONTAL,
|
|
35
|
+
styles: options.styles,
|
|
36
|
+
});
|
|
37
|
+
this._panels = new Map();
|
|
38
|
+
this.dirtyPanels = new Set();
|
|
39
|
+
this.debouncedDeque = debounce(this.syncConfigs.bind(this), 5000);
|
|
40
|
+
// events
|
|
41
|
+
this._onTabInteractionEvent = new Emitter();
|
|
42
|
+
this.onTabInteractionEvent = this._onTabInteractionEvent.event;
|
|
43
|
+
this._onTabContextMenu = new Emitter();
|
|
44
|
+
this.onTabContextMenu = this._onTabContextMenu.event;
|
|
45
|
+
this.panelState = {};
|
|
46
|
+
this._options = options;
|
|
47
|
+
if (!this.options.components) {
|
|
48
|
+
this.options.components = {};
|
|
49
|
+
}
|
|
50
|
+
if (!this.options.frameworkComponents) {
|
|
51
|
+
this.options.frameworkComponents = {};
|
|
52
|
+
}
|
|
53
|
+
if (!this.options.frameworkTabComponents) {
|
|
54
|
+
this.options.frameworkTabComponents = {};
|
|
55
|
+
}
|
|
56
|
+
if (!this.options.tabComponents) {
|
|
57
|
+
this.options.tabComponents = {};
|
|
58
|
+
}
|
|
59
|
+
if (!this.options.watermarkComponent &&
|
|
60
|
+
!this.options.watermarkFrameworkComponent) {
|
|
61
|
+
this.options.watermarkComponent = Watermark;
|
|
62
|
+
}
|
|
63
|
+
this._api = new DockviewApi(this);
|
|
64
|
+
}
|
|
65
|
+
get totalPanels() {
|
|
66
|
+
return this._panels.size;
|
|
67
|
+
}
|
|
68
|
+
get panels() {
|
|
69
|
+
return Array.from(this._panels.values()).map((_) => _.value);
|
|
70
|
+
}
|
|
71
|
+
get deserializer() {
|
|
72
|
+
return this._deserializer;
|
|
73
|
+
}
|
|
74
|
+
set deserializer(value) {
|
|
75
|
+
this._deserializer = value;
|
|
76
|
+
}
|
|
77
|
+
get options() {
|
|
78
|
+
return this._options;
|
|
79
|
+
}
|
|
80
|
+
get activePanel() {
|
|
81
|
+
const activeGroup = this.activeGroup;
|
|
82
|
+
if (!activeGroup) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
return activeGroup.model.activePanel;
|
|
86
|
+
}
|
|
87
|
+
set tabHeight(height) {
|
|
88
|
+
this.options.tabHeight = height;
|
|
89
|
+
this._groups.forEach((value) => {
|
|
90
|
+
value.value.model.tabHeight = height;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
get tabHeight() {
|
|
94
|
+
return this.options.tabHeight;
|
|
95
|
+
}
|
|
96
|
+
updateOptions(options) {
|
|
97
|
+
const hasOrientationChanged = typeof options.orientation === 'string' &&
|
|
98
|
+
this.options.orientation !== options.orientation;
|
|
99
|
+
// TODO support style update
|
|
100
|
+
// const hasStylesChanged =
|
|
101
|
+
// typeof options.styles === 'object' &&
|
|
102
|
+
// this.options.styles !== options.styles;
|
|
103
|
+
this._options = Object.assign(Object.assign({}, this.options), options);
|
|
104
|
+
if (hasOrientationChanged) {
|
|
105
|
+
this.gridview.orientation = options.orientation;
|
|
106
|
+
}
|
|
107
|
+
this.layout(this.gridview.width, this.gridview.height, true);
|
|
108
|
+
}
|
|
109
|
+
focus() {
|
|
110
|
+
var _a;
|
|
111
|
+
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
112
|
+
}
|
|
113
|
+
getGroupPanel(id) {
|
|
114
|
+
var _a;
|
|
115
|
+
return (_a = this._panels.get(id)) === null || _a === void 0 ? void 0 : _a.value;
|
|
116
|
+
}
|
|
117
|
+
setActivePanel(panel) {
|
|
118
|
+
if (!panel.group) {
|
|
119
|
+
throw new Error(`Panel ${panel.id} has no associated group`);
|
|
120
|
+
}
|
|
121
|
+
this.doSetGroupActive(panel.group);
|
|
122
|
+
panel.group.model.openPanel(panel);
|
|
123
|
+
}
|
|
124
|
+
moveToNext(options = {}) {
|
|
125
|
+
var _a;
|
|
126
|
+
if (!options.group) {
|
|
127
|
+
if (!this.activeGroup) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
options.group = this.activeGroup;
|
|
131
|
+
}
|
|
132
|
+
if (options.includePanel && options.group) {
|
|
133
|
+
if (options.group.model.activePanel !==
|
|
134
|
+
options.group.model.panels[options.group.model.panels.length - 1]) {
|
|
135
|
+
options.group.model.moveToNext({ suppressRoll: true });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const location = getGridLocation(options.group.element);
|
|
140
|
+
const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
141
|
+
this.doSetGroupActive(next);
|
|
142
|
+
}
|
|
143
|
+
moveToPrevious(options = {}) {
|
|
144
|
+
var _a;
|
|
145
|
+
if (!options.group) {
|
|
146
|
+
if (!this.activeGroup) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
options.group = this.activeGroup;
|
|
150
|
+
}
|
|
151
|
+
if (options.includePanel && options.group) {
|
|
152
|
+
if (options.group.model.activePanel !==
|
|
153
|
+
options.group.model.panels[0]) {
|
|
154
|
+
options.group.model.moveToPrevious({ suppressRoll: true });
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const location = getGridLocation(options.group.element);
|
|
159
|
+
const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
160
|
+
if (next) {
|
|
161
|
+
this.doSetGroupActive(next);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
registerPanel(panel) {
|
|
165
|
+
if (this._panels.has(panel.id)) {
|
|
166
|
+
throw new Error(`panel ${panel.id} already exists`);
|
|
167
|
+
}
|
|
168
|
+
const disposable = new CompositeDisposable(panel.onDidStateChange(() => this.addDirtyPanel(panel)));
|
|
169
|
+
this._panels.set(panel.id, { value: panel, disposable });
|
|
170
|
+
}
|
|
171
|
+
unregisterPanel(panel) {
|
|
172
|
+
if (!this._panels.has(panel.id)) {
|
|
173
|
+
throw new Error(`panel ${panel.id} doesn't exist`);
|
|
174
|
+
}
|
|
175
|
+
const item = this._panels.get(panel.id);
|
|
176
|
+
if (item) {
|
|
177
|
+
item.disposable.dispose();
|
|
178
|
+
item.value.dispose();
|
|
179
|
+
}
|
|
180
|
+
this._panels.delete(panel.id);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Serialize the current state of the layout
|
|
184
|
+
*
|
|
185
|
+
* @returns A JSON respresentation of the layout
|
|
186
|
+
*/
|
|
187
|
+
toJSON() {
|
|
188
|
+
var _a;
|
|
189
|
+
this.syncConfigs();
|
|
190
|
+
const data = this.gridview.serialize();
|
|
191
|
+
const panels = Array.from(this._panels.values()).reduce((collection, panel) => {
|
|
192
|
+
if (!this.panelState[panel.value.id]) {
|
|
193
|
+
collection[panel.value.id] = panel.value.toJSON();
|
|
194
|
+
}
|
|
195
|
+
return collection;
|
|
196
|
+
}, {});
|
|
197
|
+
return {
|
|
198
|
+
grid: data,
|
|
199
|
+
panels,
|
|
200
|
+
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
201
|
+
options: { tabHeight: this.tabHeight },
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
fromJSON(data) {
|
|
205
|
+
this.gridview.clear();
|
|
206
|
+
this._panels.forEach((panel) => {
|
|
207
|
+
panel.disposable.dispose();
|
|
208
|
+
panel.value.dispose();
|
|
209
|
+
});
|
|
210
|
+
this._panels.clear();
|
|
211
|
+
this._groups.clear();
|
|
212
|
+
if (!this.deserializer) {
|
|
213
|
+
throw new Error('invalid deserializer');
|
|
214
|
+
}
|
|
215
|
+
const { grid, panels, options, activeGroup } = data;
|
|
216
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.tabHeight) === 'number') {
|
|
217
|
+
this.tabHeight = options.tabHeight;
|
|
218
|
+
}
|
|
219
|
+
if (!this.deserializer) {
|
|
220
|
+
throw new Error('no deserializer provided');
|
|
221
|
+
}
|
|
222
|
+
this.gridview.deserialize(grid, new DefaultDeserializer(this, {
|
|
223
|
+
createPanel: (id) => {
|
|
224
|
+
const panelData = panels[id];
|
|
225
|
+
const panel = this.deserializer.fromJSON(panelData);
|
|
226
|
+
this.registerPanel(panel);
|
|
227
|
+
return panel;
|
|
228
|
+
},
|
|
229
|
+
}));
|
|
230
|
+
if (typeof activeGroup === 'string') {
|
|
231
|
+
const panel = this.getPanel(activeGroup);
|
|
232
|
+
if (panel) {
|
|
233
|
+
this.doSetGroupActive(panel);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
this.gridview.layout(this.width, this.height);
|
|
237
|
+
this._onGridEvent.fire({ kind: GroupChangeKind.LAYOUT_FROM_JSON });
|
|
238
|
+
}
|
|
239
|
+
closeAllGroups() {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
for (const entry of this._groups.entries()) {
|
|
242
|
+
const [_, group] = entry;
|
|
243
|
+
const didCloseAll = yield group.value.model.closeAllPanels();
|
|
244
|
+
if (!didCloseAll) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return true;
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
fireMouseEvent(event) {
|
|
252
|
+
switch (event.kind) {
|
|
253
|
+
case MouseEventKind.CONTEXT_MENU:
|
|
254
|
+
if (event.tab && event.panel) {
|
|
255
|
+
this._onTabContextMenu.fire({
|
|
256
|
+
event: event.event,
|
|
257
|
+
api: this._api,
|
|
258
|
+
panel: event.panel,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
addPanel(options) {
|
|
265
|
+
var _a, _b;
|
|
266
|
+
const panel = this._addPanel(options);
|
|
267
|
+
let referenceGroup;
|
|
268
|
+
if ((_a = options.position) === null || _a === void 0 ? void 0 : _a.referencePanel) {
|
|
269
|
+
const referencePanel = this.getGroupPanel(options.position.referencePanel);
|
|
270
|
+
if (!referencePanel) {
|
|
271
|
+
throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
|
|
272
|
+
}
|
|
273
|
+
referenceGroup = this.findGroup(referencePanel);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
referenceGroup = this.activeGroup;
|
|
277
|
+
}
|
|
278
|
+
if (referenceGroup) {
|
|
279
|
+
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
280
|
+
if (target === Position.Center) {
|
|
281
|
+
referenceGroup.model.openPanel(panel);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
const location = getGridLocation(referenceGroup.element);
|
|
285
|
+
const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
|
|
286
|
+
this.addPanelToNewGroup(panel, relativeLocation);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
this.addPanelToNewGroup(panel);
|
|
291
|
+
}
|
|
292
|
+
return panel;
|
|
293
|
+
}
|
|
294
|
+
removePanel(panel) {
|
|
295
|
+
this.unregisterPanel(panel);
|
|
296
|
+
const group = panel.group;
|
|
297
|
+
if (!group) {
|
|
298
|
+
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
299
|
+
}
|
|
300
|
+
group.model.removePanel(panel);
|
|
301
|
+
if (group.model.size === 0) {
|
|
302
|
+
this.removeGroup(group);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
createWatermarkComponent() {
|
|
306
|
+
var _a;
|
|
307
|
+
return createComponent('watermark-id', 'watermark-name', this.options.watermarkComponent
|
|
308
|
+
? { 'watermark-name': this.options.watermarkComponent }
|
|
309
|
+
: {}, this.options.watermarkFrameworkComponent
|
|
310
|
+
? { 'watermark-name': this.options.watermarkFrameworkComponent }
|
|
311
|
+
: {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
|
|
312
|
+
}
|
|
313
|
+
addEmptyGroup(options) {
|
|
314
|
+
var _a;
|
|
315
|
+
const group = this.createGroup();
|
|
316
|
+
if (options) {
|
|
317
|
+
const referencePanel = (_a = this._panels.get(options.referencePanel)) === null || _a === void 0 ? void 0 : _a.value;
|
|
318
|
+
if (!referencePanel) {
|
|
319
|
+
throw new Error(`reference panel ${options.referencePanel} does not exist`);
|
|
320
|
+
}
|
|
321
|
+
const referenceGroup = this.findGroup(referencePanel);
|
|
322
|
+
if (!referenceGroup) {
|
|
323
|
+
throw new Error(`reference group for reference panel ${options.referencePanel} does not exist`);
|
|
324
|
+
}
|
|
325
|
+
const target = toTarget(options.direction || 'within');
|
|
326
|
+
const location = getGridLocation(referenceGroup.element);
|
|
327
|
+
const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
|
|
328
|
+
this.doAddGroup(group, relativeLocation);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
this.doAddGroup(group);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
removeGroup(group) {
|
|
335
|
+
const panels = [...group.model.panels]; // reassign since group panels will mutate
|
|
336
|
+
panels.forEach((panel) => {
|
|
337
|
+
this.removePanel(panel);
|
|
338
|
+
});
|
|
339
|
+
if (this._groups.size === 1) {
|
|
340
|
+
this._activeGroup = group;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
super.removeGroup(group);
|
|
344
|
+
}
|
|
345
|
+
moveGroupOrPanel(referenceGroup, groupId, itemId, target, index) {
|
|
346
|
+
var _a, _b, _c;
|
|
347
|
+
const sourceGroup = groupId
|
|
348
|
+
? (_a = this._groups.get(groupId)) === null || _a === void 0 ? void 0 : _a.value
|
|
349
|
+
: undefined;
|
|
350
|
+
if (!target || target === Position.Center) {
|
|
351
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
|
|
352
|
+
((_b = this._panels.get(itemId)) === null || _b === void 0 ? void 0 : _b.value);
|
|
353
|
+
if (!groupItem) {
|
|
354
|
+
throw new Error(`No panel with id ${itemId}`);
|
|
355
|
+
}
|
|
356
|
+
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
357
|
+
this.doRemoveGroup(sourceGroup);
|
|
358
|
+
}
|
|
359
|
+
referenceGroup.model.openPanel(groupItem, { index });
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
363
|
+
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
364
|
+
if (sourceGroup && sourceGroup.model.size < 2) {
|
|
365
|
+
const [targetParentLocation, to] = tail(targetLocation);
|
|
366
|
+
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
367
|
+
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
368
|
+
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
369
|
+
// special case when 'swapping' two views within same grid location
|
|
370
|
+
// if a group has one tab - we are essentially moving the 'group'
|
|
371
|
+
// which is equivalent to swapping two views in this case
|
|
372
|
+
this.gridview.moveView(sourceParentLocation, from, to);
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
// source group will become empty so delete the group
|
|
376
|
+
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
377
|
+
skipActive: true,
|
|
378
|
+
skipDispose: true,
|
|
379
|
+
});
|
|
380
|
+
// after deleting the group we need to re-evaulate the ref location
|
|
381
|
+
const updatedReferenceLocation = getGridLocation(referenceGroup.element);
|
|
382
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, target);
|
|
383
|
+
this.doAddGroup(targetGroup, location);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(itemId)) ||
|
|
388
|
+
((_c = this._panels.get(itemId)) === null || _c === void 0 ? void 0 : _c.value);
|
|
389
|
+
if (!groupItem) {
|
|
390
|
+
throw new Error(`No panel with id ${itemId}`);
|
|
391
|
+
}
|
|
392
|
+
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
393
|
+
this.addPanelToNewGroup(groupItem, dropLocation);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
doSetGroupActive(group, skipFocus) {
|
|
398
|
+
var _a, _b;
|
|
399
|
+
const isGroupAlreadyFocused = this._activeGroup === group;
|
|
400
|
+
super.doSetGroupActive(group, skipFocus);
|
|
401
|
+
if (!isGroupAlreadyFocused && ((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.model.activePanel)) {
|
|
402
|
+
this._onGridEvent.fire({
|
|
403
|
+
kind: GroupChangeKind.PANEL_ACTIVE,
|
|
404
|
+
panel: (_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.model.activePanel,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
createGroup(options) {
|
|
409
|
+
if (!options) {
|
|
410
|
+
options = { tabHeight: this.tabHeight };
|
|
411
|
+
}
|
|
412
|
+
if (typeof options.tabHeight !== 'number') {
|
|
413
|
+
options.tabHeight = this.tabHeight;
|
|
414
|
+
}
|
|
415
|
+
let id = options === null || options === void 0 ? void 0 : options.id;
|
|
416
|
+
if (id && this._groups.has(options.id)) {
|
|
417
|
+
console.warn(`Duplicate group id ${options === null || options === void 0 ? void 0 : options.id}. reassigning group id to avoid errors`);
|
|
418
|
+
id = undefined;
|
|
419
|
+
}
|
|
420
|
+
if (!id) {
|
|
421
|
+
id = nextGroupId.next();
|
|
422
|
+
while (this._groups.has(id)) {
|
|
423
|
+
id = nextGroupId.next();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
const view = new GroupviewPanel(this, id, options);
|
|
427
|
+
if (!this._groups.has(view.id)) {
|
|
428
|
+
const disposable = new CompositeDisposable(view.model.onMove((event) => {
|
|
429
|
+
const { groupId, itemId, target, index } = event;
|
|
430
|
+
this.moveGroupOrPanel(view, groupId, itemId, target, index);
|
|
431
|
+
}), view.model.onDidGroupChange((event) => {
|
|
432
|
+
switch (event.kind) {
|
|
433
|
+
case GroupChangeKind2.ADD_PANEL:
|
|
434
|
+
this._onGridEvent.fire({
|
|
435
|
+
kind: GroupChangeKind.ADD_PANEL,
|
|
436
|
+
panel: event.panel,
|
|
437
|
+
});
|
|
438
|
+
break;
|
|
439
|
+
case GroupChangeKind2.GROUP_ACTIVE:
|
|
440
|
+
this._onGridEvent.fire({
|
|
441
|
+
kind: GroupChangeKind.GROUP_ACTIVE,
|
|
442
|
+
panel: event.panel,
|
|
443
|
+
});
|
|
444
|
+
break;
|
|
445
|
+
case GroupChangeKind2.REMOVE_PANEL:
|
|
446
|
+
this._onGridEvent.fire({
|
|
447
|
+
kind: GroupChangeKind.REMOVE_PANEL,
|
|
448
|
+
panel: event.panel,
|
|
449
|
+
});
|
|
450
|
+
break;
|
|
451
|
+
case GroupChangeKind2.PANEL_ACTIVE:
|
|
452
|
+
this._onGridEvent.fire({
|
|
453
|
+
kind: GroupChangeKind.PANEL_ACTIVE,
|
|
454
|
+
panel: event.panel,
|
|
455
|
+
});
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
}));
|
|
459
|
+
this._groups.set(view.id, { value: view, disposable });
|
|
460
|
+
}
|
|
461
|
+
// TODO: must be called after the above listeners have been setup,
|
|
462
|
+
// not an ideal pattern
|
|
463
|
+
view.initialize();
|
|
464
|
+
if (typeof this.options.tabHeight === 'number') {
|
|
465
|
+
view.model.tabHeight = this.options.tabHeight;
|
|
466
|
+
}
|
|
467
|
+
return view;
|
|
468
|
+
}
|
|
469
|
+
dispose() {
|
|
470
|
+
super.dispose();
|
|
471
|
+
this._onGridEvent.dispose();
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Ensure the local copy of the layout state is up-to-date
|
|
475
|
+
*/
|
|
476
|
+
syncConfigs() {
|
|
477
|
+
const dirtyPanels = Array.from(this.dirtyPanels);
|
|
478
|
+
if (dirtyPanels.length === 0) {
|
|
479
|
+
//
|
|
480
|
+
}
|
|
481
|
+
this.dirtyPanels.clear();
|
|
482
|
+
const partialPanelState = dirtyPanels
|
|
483
|
+
.map((panel) => this._panels.get(panel.id))
|
|
484
|
+
.filter((_) => !!_)
|
|
485
|
+
.reduce((collection, panel) => {
|
|
486
|
+
collection[panel.value.id] = panel.value.toJSON();
|
|
487
|
+
return collection;
|
|
488
|
+
}, {});
|
|
489
|
+
this.panelState = Object.assign(Object.assign({}, this.panelState), partialPanelState);
|
|
490
|
+
dirtyPanels
|
|
491
|
+
.filter((p) => this._panels.has(p.id))
|
|
492
|
+
.forEach((panel) => {
|
|
493
|
+
panel.setDirty(false);
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
_addPanel(options) {
|
|
497
|
+
const view = new DefaultGroupPanelView({
|
|
498
|
+
content: this.createContentComponent(options.id, options.component),
|
|
499
|
+
tab: this.createTabComponent(options.id, options.tabComponent),
|
|
500
|
+
});
|
|
501
|
+
const panel = new DockviewGroupPanel(options.id, this._api);
|
|
502
|
+
panel.init({
|
|
503
|
+
view,
|
|
504
|
+
title: options.title || options.id,
|
|
505
|
+
suppressClosable: options === null || options === void 0 ? void 0 : options.suppressClosable,
|
|
506
|
+
params: (options === null || options === void 0 ? void 0 : options.params) || {},
|
|
507
|
+
});
|
|
508
|
+
this.registerPanel(panel);
|
|
509
|
+
return panel;
|
|
510
|
+
}
|
|
511
|
+
createContentComponent(id, componentName) {
|
|
512
|
+
var _a;
|
|
513
|
+
return createComponent(id, componentName, this.options.components || {}, this.options.frameworkComponents, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.content);
|
|
514
|
+
}
|
|
515
|
+
createTabComponent(id, componentName) {
|
|
516
|
+
var _a;
|
|
517
|
+
return createComponent(id, componentName, this.options.tabComponents || {}, this.options.frameworkTabComponents, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.tab, () => new DefaultTab());
|
|
518
|
+
}
|
|
519
|
+
addPanelToNewGroup(panel, location = [0]) {
|
|
520
|
+
const group = this.createGroup();
|
|
521
|
+
this.doAddGroup(group, location);
|
|
522
|
+
group.model.openPanel(panel);
|
|
523
|
+
}
|
|
524
|
+
findGroup(panel) {
|
|
525
|
+
var _a;
|
|
526
|
+
return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
|
|
527
|
+
}
|
|
528
|
+
addDirtyPanel(panel) {
|
|
529
|
+
this.dirtyPanels.add(panel);
|
|
530
|
+
panel.setDirty(true);
|
|
531
|
+
this.debouncedDeque();
|
|
532
|
+
}
|
|
533
|
+
}
|