@datagrok-libraries/dock-spawn-dg 0.0.1
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/.eslintrc.json +47 -0
- package/CHANGELOG.md +355 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/css/dock-manager-context-menu.css +19 -0
- package/css/dock-manager-style.css +190 -0
- package/css/dock-manager.css +411 -0
- package/images/close.svg +6 -0
- package/images/dock_bottom.png +0 -0
- package/images/dock_bottom_sel.png +0 -0
- package/images/dock_fill.png +0 -0
- package/images/dock_fill_sel.png +0 -0
- package/images/dock_left.png +0 -0
- package/images/dock_left_sel.png +0 -0
- package/images/dock_right.png +0 -0
- package/images/dock_right_sel.png +0 -0
- package/images/dock_top.png +0 -0
- package/images/dock_top_sel.png +0 -0
- package/index.ts +32 -0
- package/lib/BrowserDialogHelper.d.ts +8 -0
- package/lib/BrowserDialogHelper.d.ts.map +1 -0
- package/lib/BrowserDialogHelper.js +60 -0
- package/lib/ContainerType.d.ts +7 -0
- package/lib/ContainerType.d.ts.map +1 -0
- package/lib/ContainerType.js +7 -0
- package/lib/Dialog.d.ts +51 -0
- package/lib/Dialog.d.ts.map +1 -0
- package/lib/Dialog.js +209 -0
- package/lib/DockConfig.d.ts +9 -0
- package/lib/DockConfig.d.ts.map +1 -0
- package/lib/DockConfig.js +14 -0
- package/lib/DockGraphDeserializer.d.ts +19 -0
- package/lib/DockGraphDeserializer.d.ts.map +1 -0
- package/lib/DockGraphDeserializer.js +114 -0
- package/lib/DockGraphSerializer.d.ts +14 -0
- package/lib/DockGraphSerializer.d.ts.map +1 -0
- package/lib/DockGraphSerializer.js +40 -0
- package/lib/DockLayoutEngine.d.ts +36 -0
- package/lib/DockLayoutEngine.d.ts.map +1 -0
- package/lib/DockLayoutEngine.js +323 -0
- package/lib/DockManager.d.ts +155 -0
- package/lib/DockManager.d.ts.map +1 -0
- package/lib/DockManager.js +752 -0
- package/lib/DockManagerContext.d.ts +10 -0
- package/lib/DockManagerContext.d.ts.map +1 -0
- package/lib/DockManagerContext.js +12 -0
- package/lib/DockModel.d.ts +9 -0
- package/lib/DockModel.d.ts.map +1 -0
- package/lib/DockModel.js +8 -0
- package/lib/DockNode.d.ts +16 -0
- package/lib/DockNode.d.ts.map +1 -0
- package/lib/DockNode.js +64 -0
- package/lib/DockWheel.d.ts +41 -0
- package/lib/DockWheel.d.ts.map +1 -0
- package/lib/DockWheel.js +208 -0
- package/lib/DockWheelItem.d.ts +16 -0
- package/lib/DockWheelItem.d.ts.map +1 -0
- package/lib/DockWheelItem.js +34 -0
- package/lib/DocumentManagerContainer.d.ts +16 -0
- package/lib/DocumentManagerContainer.d.ts.map +1 -0
- package/lib/DocumentManagerContainer.js +28 -0
- package/lib/DocumentTabPage.d.ts +11 -0
- package/lib/DocumentTabPage.d.ts.map +1 -0
- package/lib/DocumentTabPage.js +26 -0
- package/lib/DraggableContainer.d.ts +51 -0
- package/lib/DraggableContainer.d.ts.map +1 -0
- package/lib/DraggableContainer.js +145 -0
- package/lib/EventHandler.d.ts +8 -0
- package/lib/EventHandler.d.ts.map +1 -0
- package/lib/EventHandler.js +14 -0
- package/lib/FillDockContainer.d.ts +34 -0
- package/lib/FillDockContainer.d.ts.map +1 -0
- package/lib/FillDockContainer.js +80 -0
- package/lib/HorizontalDockContainer.d.ts +7 -0
- package/lib/HorizontalDockContainer.d.ts.map +1 -0
- package/lib/HorizontalDockContainer.js +9 -0
- package/lib/PanelContainer.d.ts +114 -0
- package/lib/PanelContainer.d.ts.map +1 -0
- package/lib/PanelContainer.js +517 -0
- package/lib/Point.d.ts +6 -0
- package/lib/Point.d.ts.map +1 -0
- package/lib/Point.js +8 -0
- package/lib/ResizableContainer.d.ts +56 -0
- package/lib/ResizableContainer.d.ts.map +1 -0
- package/lib/ResizableContainer.js +254 -0
- package/lib/ResizeHandle.d.ts +16 -0
- package/lib/ResizeHandle.d.ts.map +1 -0
- package/lib/ResizeHandle.js +58 -0
- package/lib/SplitterBar.d.ts +33 -0
- package/lib/SplitterBar.d.ts.map +1 -0
- package/lib/SplitterBar.js +137 -0
- package/lib/SplitterDockContainer.d.ts +36 -0
- package/lib/SplitterDockContainer.d.ts.map +1 -0
- package/lib/SplitterDockContainer.js +75 -0
- package/lib/SplitterPanel.d.ts +27 -0
- package/lib/SplitterPanel.d.ts.map +1 -0
- package/lib/SplitterPanel.js +195 -0
- package/lib/TabHandle.d.ts +56 -0
- package/lib/TabHandle.d.ts.map +1 -0
- package/lib/TabHandle.js +292 -0
- package/lib/TabHost.d.ts +47 -0
- package/lib/TabHost.d.ts.map +1 -0
- package/lib/TabHost.js +238 -0
- package/lib/TabPage.d.ts +20 -0
- package/lib/TabPage.d.ts.map +1 -0
- package/lib/TabPage.js +81 -0
- package/lib/UndockInitiator.d.ts +32 -0
- package/lib/UndockInitiator.d.ts.map +1 -0
- package/lib/UndockInitiator.js +152 -0
- package/lib/Utils.d.ts +15 -0
- package/lib/Utils.d.ts.map +1 -0
- package/lib/Utils.js +69 -0
- package/lib/VerticalDockContainer.d.ts +7 -0
- package/lib/VerticalDockContainer.d.ts.map +1 -0
- package/lib/VerticalDockContainer.js +9 -0
- package/lib/enums/PanelType.d.ts +5 -0
- package/lib/enums/PanelType.d.ts.map +1 -0
- package/lib/enums/PanelType.js +5 -0
- package/lib/enums/TabHostDirection.d.ts +7 -0
- package/lib/enums/TabHostDirection.d.ts.map +1 -0
- package/lib/enums/TabHostDirection.js +7 -0
- package/lib/enums/WheelTypes.d.ts +12 -0
- package/lib/enums/WheelTypes.d.ts.map +1 -0
- package/lib/enums/WheelTypes.js +14 -0
- package/lib/i18n/Defaults.d.ts +12 -0
- package/lib/i18n/Defaults.d.ts.map +1 -0
- package/lib/i18n/Defaults.js +9 -0
- package/lib/i18n/Localizer.d.ts +7 -0
- package/lib/i18n/Localizer.d.ts.map +1 -0
- package/lib/i18n/Localizer.js +16 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +32 -0
- package/lib/interfaces/IDockContainer.d.ts +26 -0
- package/lib/interfaces/IDockContainer.d.ts.map +1 -0
- package/lib/interfaces/IDockContainer.js +1 -0
- package/lib/interfaces/IDockContainerWithSize.d.ts +6 -0
- package/lib/interfaces/IDockContainerWithSize.d.ts.map +1 -0
- package/lib/interfaces/IDockContainerWithSize.js +1 -0
- package/lib/interfaces/ILayoutEventListener.d.ts +27 -0
- package/lib/interfaces/ILayoutEventListener.d.ts.map +1 -0
- package/lib/interfaces/ILayoutEventListener.js +1 -0
- package/lib/interfaces/IMouseOrTouchEvent.d.ts +7 -0
- package/lib/interfaces/IMouseOrTouchEvent.d.ts.map +1 -0
- package/lib/interfaces/IMouseOrTouchEvent.js +1 -0
- package/lib/interfaces/INodeInfo.d.ts +8 -0
- package/lib/interfaces/INodeInfo.d.ts.map +1 -0
- package/lib/interfaces/INodeInfo.js +1 -0
- package/lib/interfaces/IPanelInfo.d.ts +10 -0
- package/lib/interfaces/IPanelInfo.d.ts.map +1 -0
- package/lib/interfaces/IPanelInfo.js +1 -0
- package/lib/interfaces/IRectangle.d.ts +7 -0
- package/lib/interfaces/IRectangle.d.ts.map +1 -0
- package/lib/interfaces/IRectangle.js +1 -0
- package/lib/interfaces/ISize.d.ts +5 -0
- package/lib/interfaces/ISize.d.ts.map +1 -0
- package/lib/interfaces/ISize.js +1 -0
- package/lib/interfaces/IState.d.ts +12 -0
- package/lib/interfaces/IState.d.ts.map +1 -0
- package/lib/interfaces/IState.js +1 -0
- package/lib/interfaces/IThickness.d.ts +7 -0
- package/lib/interfaces/IThickness.d.ts.map +1 -0
- package/lib/interfaces/IThickness.js +1 -0
- package/lib/webcomponent/DockSpawnTsWebcomponent.d.ts +35 -0
- package/lib/webcomponent/DockSpawnTsWebcomponent.d.ts.map +1 -0
- package/lib/webcomponent/DockSpawnTsWebcomponent.js +209 -0
- package/lib/webcomponent/styles.d.ts +5 -0
- package/lib/webcomponent/styles.d.ts.map +1 -0
- package/lib/webcomponent/styles.js +537 -0
- package/package.json +36 -0
- package/src/BrowserDialogHelper.ts +76 -0
- package/src/ContainerType.ts +6 -0
- package/src/Dialog.ts +253 -0
- package/src/DockConfig.ts +15 -0
- package/src/DockGraphDeserializer.ts +129 -0
- package/src/DockGraphSerializer.ts +53 -0
- package/src/DockLayoutEngine.ts +370 -0
- package/src/DockManager.ts +880 -0
- package/src/DockManagerContext.ts +16 -0
- package/src/DockModel.ts +12 -0
- package/src/DockNode.ts +81 -0
- package/src/DockWheel.ts +215 -0
- package/src/DockWheelItem.ts +41 -0
- package/src/DocumentManagerContainer.ts +39 -0
- package/src/DocumentTabPage.ts +35 -0
- package/src/DraggableContainer.ts +177 -0
- package/src/EventHandler.ts +17 -0
- package/src/FillDockContainer.ts +98 -0
- package/src/HorizontalDockContainer.ts +13 -0
- package/src/PanelContainer.ts +596 -0
- package/src/Point.ts +10 -0
- package/src/ResizableContainer.ts +293 -0
- package/src/ResizeHandle.ts +59 -0
- package/src/SplitterBar.ts +157 -0
- package/src/SplitterDockContainer.ts +95 -0
- package/src/SplitterPanel.ts +228 -0
- package/src/TabHandle.ts +347 -0
- package/src/TabHost.ts +267 -0
- package/src/TabPage.ts +98 -0
- package/src/UndockInitiator.ts +181 -0
- package/src/Utils.ts +85 -0
- package/src/VerticalDockContainer.ts +13 -0
- package/src/enums/PanelType.ts +4 -0
- package/src/enums/TabHostDirection.ts +6 -0
- package/src/enums/WheelTypes.ts +14 -0
- package/src/i18n/Defaults.ts +20 -0
- package/src/i18n/Localizer.ts +23 -0
- package/src/index.ts +32 -0
- package/src/interfaces/IDockContainer.ts +27 -0
- package/src/interfaces/IDockContainerWithSize.ts +6 -0
- package/src/interfaces/ILayoutEventListener.ts +28 -0
- package/src/interfaces/IMouseOrTouchEvent.ts +6 -0
- package/src/interfaces/INodeInfo.ts +8 -0
- package/src/interfaces/IPanelInfo.ts +10 -0
- package/src/interfaces/IRectangle.ts +6 -0
- package/src/interfaces/ISize.ts +4 -0
- package/src/interfaces/IState.ts +12 -0
- package/src/interfaces/IThickness.ts +6 -0
- package/src/webcomponent/DockSpawnTsWebcomponent.ts +248 -0
- package/src/webcomponent/styles.ts +544 -0
- package/tsconfig.json +74 -0
- package/tsconfig.tsbuildinfo +1 -0
package/lib/Dialog.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Point } from './Point.js';
|
|
2
|
+
import { PanelContainer } from './PanelContainer.js';
|
|
3
|
+
import { DraggableContainer } from './DraggableContainer.js';
|
|
4
|
+
import { ResizableContainer } from './ResizableContainer.js';
|
|
5
|
+
import { EventHandler } from './EventHandler.js';
|
|
6
|
+
import { Utils } from './Utils.js';
|
|
7
|
+
import { Localizer } from './i18n/Localizer.js';
|
|
8
|
+
export class Dialog {
|
|
9
|
+
elementDialog;
|
|
10
|
+
draggable;
|
|
11
|
+
panel;
|
|
12
|
+
dockManager;
|
|
13
|
+
eventListener;
|
|
14
|
+
position;
|
|
15
|
+
resizable;
|
|
16
|
+
disableResize;
|
|
17
|
+
mouseDownHandler;
|
|
18
|
+
onKeyPressBound;
|
|
19
|
+
noDocking;
|
|
20
|
+
isHidden;
|
|
21
|
+
keyPressHandler;
|
|
22
|
+
focusHandler;
|
|
23
|
+
grayoutParent;
|
|
24
|
+
contextmenuHandler;
|
|
25
|
+
_ctxMenu;
|
|
26
|
+
_windowsContextMenuCloseBound;
|
|
27
|
+
constructor(panel, dockManager, grayoutParent, disableResize) {
|
|
28
|
+
this.panel = panel;
|
|
29
|
+
this.dockManager = dockManager;
|
|
30
|
+
this.eventListener = dockManager;
|
|
31
|
+
this.grayoutParent = grayoutParent;
|
|
32
|
+
this.disableResize = disableResize;
|
|
33
|
+
this._initialize();
|
|
34
|
+
this.dockManager.context.model.dialogs.push(this);
|
|
35
|
+
this.position = dockManager.defaultDialogPosition;
|
|
36
|
+
this.dockManager.notifyOnCreateDialog(this);
|
|
37
|
+
panel.isDialog = true;
|
|
38
|
+
}
|
|
39
|
+
saveState(x, y) {
|
|
40
|
+
this.position = new Point(x, y);
|
|
41
|
+
this.dockManager.notifyOnChangeDialogPosition(this, x, y);
|
|
42
|
+
}
|
|
43
|
+
static fromElement(id, dockManager) {
|
|
44
|
+
return new Dialog(new PanelContainer(document.getElementById(id), dockManager), dockManager, null);
|
|
45
|
+
}
|
|
46
|
+
_initialize() {
|
|
47
|
+
this.panel.floatingDialog = this;
|
|
48
|
+
this.elementDialog = Object.assign(document.createElement('div'), { floatingDialog: this });
|
|
49
|
+
this.elementDialog.tabIndex = 0;
|
|
50
|
+
this.elementDialog.appendChild(this.panel.elementPanel);
|
|
51
|
+
this.draggable = new DraggableContainer(this, this.panel, this.elementDialog, this.panel.elementTitle);
|
|
52
|
+
this.resizable = new ResizableContainer(this, this.draggable, this.draggable.topLevelElement, this.disableResize);
|
|
53
|
+
this.dockManager.config.dialogRootElement.appendChild(this.elementDialog);
|
|
54
|
+
this.elementDialog.classList.add('dialog-floating');
|
|
55
|
+
this.focusHandler = new EventHandler(this.elementDialog, 'focus', this.onFocus.bind(this), true);
|
|
56
|
+
this.mouseDownHandler = new EventHandler(this.elementDialog, 'pointerdown', this.onMouseDown.bind(this), true);
|
|
57
|
+
this.keyPressHandler = new EventHandler(this.elementDialog, 'keypress', this.dockManager.onKeyPressBound, true);
|
|
58
|
+
this.contextmenuHandler = new EventHandler(this.panel.elementTitle, 'contextmenu', this.oncontextMenuClicked.bind(this));
|
|
59
|
+
this.resize(this.panel.elementPanel.clientWidth, this.panel.elementPanel.clientHeight);
|
|
60
|
+
this.isHidden = false;
|
|
61
|
+
if (this.grayoutParent != null)
|
|
62
|
+
this.grayoutParent.grayOut(true);
|
|
63
|
+
this.bringToFront();
|
|
64
|
+
}
|
|
65
|
+
setPosition(x, y) {
|
|
66
|
+
const rect = this.dockManager.config.dialogRootElement.getBoundingClientRect();
|
|
67
|
+
this.position = new Point(x - rect.left, y - rect.top);
|
|
68
|
+
this.elementDialog.style.left = (x - rect.left) + 'px';
|
|
69
|
+
this.elementDialog.style.top = (y - rect.top) + 'px';
|
|
70
|
+
this.panel.setDialogPosition(x, y);
|
|
71
|
+
this.dockManager.notifyOnChangeDialogPosition(this, x, y);
|
|
72
|
+
}
|
|
73
|
+
getPosition() {
|
|
74
|
+
return new Point(this.position ? this.position.x : 0, this.position ? this.position.y : 0);
|
|
75
|
+
}
|
|
76
|
+
onFocus() {
|
|
77
|
+
if (this.dockManager.activePanel != this.panel)
|
|
78
|
+
this.dockManager.activePanel = this.panel;
|
|
79
|
+
}
|
|
80
|
+
onMouseDown(e) {
|
|
81
|
+
if (e.button != 2)
|
|
82
|
+
this.bringToFront();
|
|
83
|
+
}
|
|
84
|
+
destroy() {
|
|
85
|
+
this.panel.lastDialogSize = { width: this.resizable.width, height: this.resizable.height };
|
|
86
|
+
if (this.focusHandler) {
|
|
87
|
+
this.focusHandler.cancel();
|
|
88
|
+
delete this.focusHandler;
|
|
89
|
+
}
|
|
90
|
+
if (this.mouseDownHandler) {
|
|
91
|
+
this.mouseDownHandler.cancel();
|
|
92
|
+
delete this.mouseDownHandler;
|
|
93
|
+
}
|
|
94
|
+
if (this.keyPressHandler) {
|
|
95
|
+
this.keyPressHandler.cancel();
|
|
96
|
+
delete this.keyPressHandler;
|
|
97
|
+
}
|
|
98
|
+
if (this.contextmenuHandler) {
|
|
99
|
+
this.contextmenuHandler.cancel();
|
|
100
|
+
delete this.contextmenuHandler;
|
|
101
|
+
}
|
|
102
|
+
Utils.removeNode(this.elementDialog);
|
|
103
|
+
this.draggable.removeDecorator();
|
|
104
|
+
Utils.removeNode(this.panel.elementPanel);
|
|
105
|
+
Utils.arrayRemove(this.dockManager.context.model.dialogs, this);
|
|
106
|
+
delete this.panel.floatingDialog;
|
|
107
|
+
if (this.grayoutParent)
|
|
108
|
+
this.grayoutParent.grayOut(false);
|
|
109
|
+
}
|
|
110
|
+
resize(width, height) {
|
|
111
|
+
this.resizable.resize(width, height);
|
|
112
|
+
}
|
|
113
|
+
setTitle(title) {
|
|
114
|
+
this.panel.setTitle(title);
|
|
115
|
+
}
|
|
116
|
+
setTitleIcon(iconName) {
|
|
117
|
+
this.panel.setTitleIcon(iconName);
|
|
118
|
+
}
|
|
119
|
+
bringToFront() {
|
|
120
|
+
this.panel.elementContentContainer.style.zIndex = this.dockManager.zIndexDialogCounter++;
|
|
121
|
+
this.elementDialog.style.zIndex = this.dockManager.zIndexDialogCounter++;
|
|
122
|
+
this.dockManager.activePanel = this.panel;
|
|
123
|
+
}
|
|
124
|
+
hide() {
|
|
125
|
+
this.elementDialog.style.zIndex = '0';
|
|
126
|
+
this.panel.elementContentContainer.style.zIndex = '';
|
|
127
|
+
this.elementDialog.style.display = 'none';
|
|
128
|
+
if (!this.isHidden) {
|
|
129
|
+
this.isHidden = true;
|
|
130
|
+
this.dockManager.notifyOnHideDialog(this);
|
|
131
|
+
}
|
|
132
|
+
if (this.grayoutParent)
|
|
133
|
+
this.grayoutParent.grayOut(false);
|
|
134
|
+
}
|
|
135
|
+
close() {
|
|
136
|
+
this.hide();
|
|
137
|
+
this.remove();
|
|
138
|
+
this.dockManager.notifyOnClosePanel(this.panel);
|
|
139
|
+
this.destroy();
|
|
140
|
+
}
|
|
141
|
+
remove() {
|
|
142
|
+
this.elementDialog.parentNode.removeChild(this.elementDialog);
|
|
143
|
+
}
|
|
144
|
+
show() {
|
|
145
|
+
this.panel.elementContentContainer.style.zIndex = this.dockManager.zIndexDialogCounter++;
|
|
146
|
+
this.elementDialog.style.zIndex = this.dockManager.zIndexDialogCounter++;
|
|
147
|
+
this.elementDialog.style.display = 'block';
|
|
148
|
+
if (this.isHidden) {
|
|
149
|
+
this.isHidden = false;
|
|
150
|
+
this.dockManager.notifyOnShowDialog(this);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
static createContextMenuContentCallback = (dialog, documentMangerNodes) => {
|
|
154
|
+
if (!dialog.panel._hideCloseButton)
|
|
155
|
+
return [];
|
|
156
|
+
const result = [];
|
|
157
|
+
const btnCloseDialog = document.createElement('div');
|
|
158
|
+
btnCloseDialog.innerText = Localizer.getString('CloseDialog');
|
|
159
|
+
result.push(btnCloseDialog);
|
|
160
|
+
btnCloseDialog.onclick = () => {
|
|
161
|
+
dialog.panel.close();
|
|
162
|
+
dialog.closeContextMenu();
|
|
163
|
+
};
|
|
164
|
+
if (dialog.dockManager.config.enableBrowserWindows) {
|
|
165
|
+
const btnNewBrowserWindow = document.createElement('div');
|
|
166
|
+
btnNewBrowserWindow.innerText = Localizer.getString('NewBrowserWindow');
|
|
167
|
+
result.push(btnNewBrowserWindow);
|
|
168
|
+
btnNewBrowserWindow.onclick = () => {
|
|
169
|
+
dialog.panel.undockToBrowserDialog();
|
|
170
|
+
dialog.closeContextMenu();
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
};
|
|
175
|
+
oncontextMenuClicked(e) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
if (!this._ctxMenu && Dialog.createContextMenuContentCallback) {
|
|
178
|
+
const menuItems = Dialog.createContextMenuContentCallback(this, this.dockManager.context.model.documentManagerNode.children);
|
|
179
|
+
if (menuItems.length == 0)
|
|
180
|
+
return;
|
|
181
|
+
this._ctxMenu = document.createElement('div');
|
|
182
|
+
this._ctxMenu.className = 'dockspab-tab-handle-context-menu';
|
|
183
|
+
this._ctxMenu.append(...menuItems);
|
|
184
|
+
this._ctxMenu.style.left = e.pageX + 'px';
|
|
185
|
+
this._ctxMenu.style.top = e.pageY + 'px';
|
|
186
|
+
document.body.appendChild(this._ctxMenu);
|
|
187
|
+
this._windowsContextMenuCloseBound = this.windowsContextMenuClose.bind(this);
|
|
188
|
+
window.addEventListener('pointerup', this._windowsContextMenuCloseBound);
|
|
189
|
+
}
|
|
190
|
+
else
|
|
191
|
+
this.closeContextMenu();
|
|
192
|
+
}
|
|
193
|
+
closeContextMenu() {
|
|
194
|
+
if (this._ctxMenu) {
|
|
195
|
+
document.body.removeChild(this._ctxMenu);
|
|
196
|
+
delete this._ctxMenu;
|
|
197
|
+
window.removeEventListener('pointerup', this._windowsContextMenuCloseBound);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
windowsContextMenuClose(e) {
|
|
201
|
+
const cp = e.composedPath();
|
|
202
|
+
for (const i in cp) {
|
|
203
|
+
const el = cp[i];
|
|
204
|
+
if (el == this._ctxMenu)
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
this.closeContextMenu();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class DockConfig {
|
|
2
|
+
constructor();
|
|
3
|
+
escClosesWindow?: boolean;
|
|
4
|
+
escClosesDialog?: boolean;
|
|
5
|
+
dialogRootElement: HTMLElement;
|
|
6
|
+
moveOnlyWithinDockConatiner?: boolean;
|
|
7
|
+
enableBrowserWindows?: boolean;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=DockConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DockConfig.d.ts","sourceRoot":"","sources":["../src/DockConfig.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;;IASnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,EAAE,WAAW,CAAC;IAC/B,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class DockConfig {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.escClosesWindow = true;
|
|
4
|
+
this.escClosesDialog = true;
|
|
5
|
+
this.dialogRootElement = document.body;
|
|
6
|
+
this.moveOnlyWithinDockConatiner = false;
|
|
7
|
+
this.enableBrowserWindows = true;
|
|
8
|
+
}
|
|
9
|
+
escClosesWindow;
|
|
10
|
+
escClosesDialog;
|
|
11
|
+
dialogRootElement;
|
|
12
|
+
moveOnlyWithinDockConatiner;
|
|
13
|
+
enableBrowserWindows;
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DockManager } from './DockManager.js';
|
|
2
|
+
import { DockModel } from './DockModel.js';
|
|
3
|
+
import { DockNode } from './DockNode.js';
|
|
4
|
+
import { Dialog } from './Dialog.js';
|
|
5
|
+
import { IPanelInfo } from './interfaces/IPanelInfo.js';
|
|
6
|
+
import { INodeInfo } from './interfaces/INodeInfo.js';
|
|
7
|
+
/**
|
|
8
|
+
* Deserializes the dock layout hierarchy from JSON and creates a dock hierarhcy graph
|
|
9
|
+
*/
|
|
10
|
+
export declare class DockGraphDeserializer {
|
|
11
|
+
dockManager: DockManager;
|
|
12
|
+
documentManagerNode: DockNode;
|
|
13
|
+
constructor(dockManager: DockManager);
|
|
14
|
+
deserialize(_json: string): Promise<DockModel>;
|
|
15
|
+
_buildGraph(nodeInfo: INodeInfo): Promise<DockNode>;
|
|
16
|
+
_createContainer(nodeInfo: INodeInfo, children: DockNode[]): Promise<any>;
|
|
17
|
+
_buildDialogs(dialogsInfo: IPanelInfo[]): Promise<Dialog[]>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=DockGraphDeserializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DockGraphDeserializer.d.ts","sourceRoot":"","sources":["../src/DockGraphDeserializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAMvC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,2BAA2B,CAAC;AAGpD;;GAEG;AACH,qBAAa,qBAAqB;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,mBAAmB,EAAE,QAAQ,CAAC;gBAElB,WAAW,EAAE,WAAW;IAI9B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAS9C,WAAW,CAAC,QAAQ,EAAE,SAAS;IA2B/B,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAwC1D,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE;CA2B9C"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { DockModel } from './DockModel.js';
|
|
2
|
+
import { DockNode } from './DockNode.js';
|
|
3
|
+
import { PanelContainer } from './PanelContainer.js';
|
|
4
|
+
import { HorizontalDockContainer } from './HorizontalDockContainer.js';
|
|
5
|
+
import { VerticalDockContainer } from './VerticalDockContainer.js';
|
|
6
|
+
import { DocumentManagerContainer } from './DocumentManagerContainer.js';
|
|
7
|
+
import { FillDockContainer } from './FillDockContainer.js';
|
|
8
|
+
import { Dialog } from './Dialog.js';
|
|
9
|
+
import { Utils } from './Utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Deserializes the dock layout hierarchy from JSON and creates a dock hierarhcy graph
|
|
12
|
+
*/
|
|
13
|
+
export class DockGraphDeserializer {
|
|
14
|
+
dockManager;
|
|
15
|
+
documentManagerNode;
|
|
16
|
+
constructor(dockManager) {
|
|
17
|
+
this.dockManager = dockManager;
|
|
18
|
+
}
|
|
19
|
+
async deserialize(_json) {
|
|
20
|
+
const info = JSON.parse(_json);
|
|
21
|
+
const model = new DockModel();
|
|
22
|
+
model.rootNode = await this._buildGraph(info.graphInfo);
|
|
23
|
+
model.dialogs = await this._buildDialogs(info.dialogsInfo);
|
|
24
|
+
model.documentManagerNode = this.documentManagerNode;
|
|
25
|
+
return model;
|
|
26
|
+
}
|
|
27
|
+
async _buildGraph(nodeInfo) {
|
|
28
|
+
const childrenInfo = nodeInfo.children;
|
|
29
|
+
const children = [];
|
|
30
|
+
for (const childInfo of childrenInfo) {
|
|
31
|
+
const childNode = await this._buildGraph(childInfo);
|
|
32
|
+
if (childNode !== null)
|
|
33
|
+
children.push(childNode);
|
|
34
|
+
}
|
|
35
|
+
;
|
|
36
|
+
// Build the container owned by this node
|
|
37
|
+
const container = await this._createContainer(nodeInfo, children);
|
|
38
|
+
if (container === null)
|
|
39
|
+
return null;
|
|
40
|
+
// Build the node for this container and attach it's children
|
|
41
|
+
const node = new DockNode(container);
|
|
42
|
+
if (container instanceof DocumentManagerContainer)
|
|
43
|
+
this.documentManagerNode = node;
|
|
44
|
+
node.children = children;
|
|
45
|
+
for (const childNode of node.children.reverse())
|
|
46
|
+
childNode.parent = node;
|
|
47
|
+
;
|
|
48
|
+
node.children.reverse();
|
|
49
|
+
// node.container.setActiveChild(node.container);
|
|
50
|
+
return node;
|
|
51
|
+
}
|
|
52
|
+
async _createContainer(nodeInfo, children) {
|
|
53
|
+
const containerType = nodeInfo.containerType;
|
|
54
|
+
const containerState = nodeInfo.state;
|
|
55
|
+
let container;
|
|
56
|
+
const childContainers = [];
|
|
57
|
+
for (const childNode of children)
|
|
58
|
+
childContainers.push(childNode.container);
|
|
59
|
+
if (containerType === 'panel') {
|
|
60
|
+
container = await PanelContainer.loadFromState(containerState, this.dockManager);
|
|
61
|
+
if (!container?.prepareForDocking)
|
|
62
|
+
return null;
|
|
63
|
+
container.prepareForDocking();
|
|
64
|
+
Utils.removeNode(container.elementPanel);
|
|
65
|
+
}
|
|
66
|
+
else if (containerType === 'horizontal')
|
|
67
|
+
container = new HorizontalDockContainer(this.dockManager, childContainers);
|
|
68
|
+
else if (containerType === 'vertical')
|
|
69
|
+
container = new VerticalDockContainer(this.dockManager, childContainers);
|
|
70
|
+
else if (containerType === 'fill') {
|
|
71
|
+
// Check if this is a document manager
|
|
72
|
+
// TODO: Layout engine compares the string 'fill', so cannot create another subclass type
|
|
73
|
+
// called document_manager and have to resort to this hack. use RTTI in layout engine
|
|
74
|
+
const typeDocumentManager = containerState.documentManager;
|
|
75
|
+
if (typeDocumentManager)
|
|
76
|
+
container = new DocumentManagerContainer(this.dockManager);
|
|
77
|
+
else
|
|
78
|
+
container = new FillDockContainer(this.dockManager);
|
|
79
|
+
}
|
|
80
|
+
else
|
|
81
|
+
throw new Error('Cannot create dock container of unknown type: ' + containerType);
|
|
82
|
+
// Restore the state of the container
|
|
83
|
+
container.loadState(containerState);
|
|
84
|
+
// container.performLayout(childContainers);
|
|
85
|
+
return container;
|
|
86
|
+
}
|
|
87
|
+
async _buildDialogs(dialogsInfo) {
|
|
88
|
+
const dialogs = [];
|
|
89
|
+
for (const dialogInfo of dialogsInfo) {
|
|
90
|
+
const containerType = dialogInfo.containerType;
|
|
91
|
+
const containerState = dialogInfo.state;
|
|
92
|
+
let container;
|
|
93
|
+
if (containerType === 'panel') {
|
|
94
|
+
container = await PanelContainer.loadFromState(containerState, this.dockManager);
|
|
95
|
+
if (container.prepareForDocking) {
|
|
96
|
+
Utils.removeNode(container.elementPanel);
|
|
97
|
+
container.isDialog = true;
|
|
98
|
+
const dialog = new Dialog(container, this.dockManager);
|
|
99
|
+
if (dialogInfo.position.x > document.body.clientWidth ||
|
|
100
|
+
dialogInfo.position.y > document.body.clientHeight - 70) {
|
|
101
|
+
dialogInfo.position.x = 20;
|
|
102
|
+
dialogInfo.position.y = 70;
|
|
103
|
+
}
|
|
104
|
+
dialog.setPosition(dialogInfo.position.x, dialogInfo.position.y);
|
|
105
|
+
dialog.isHidden = dialogInfo.isHidden;
|
|
106
|
+
if (dialog.isHidden)
|
|
107
|
+
dialog.hide();
|
|
108
|
+
dialogs.push(dialog);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return dialogs;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DockModel } from './DockModel.js';
|
|
2
|
+
import { DockNode } from './DockNode.js';
|
|
3
|
+
import { Dialog } from './Dialog.js';
|
|
4
|
+
import { IPanelInfo } from './interfaces/IPanelInfo.js';
|
|
5
|
+
import { INodeInfo } from './interfaces/INodeInfo.js';
|
|
6
|
+
/**
|
|
7
|
+
* The serializer saves / loads the state of the dock layout hierarchy
|
|
8
|
+
*/
|
|
9
|
+
export declare class DockGraphSerializer {
|
|
10
|
+
serialize(model: DockModel): string;
|
|
11
|
+
_buildGraphInfo(node: DockNode): INodeInfo;
|
|
12
|
+
_buildDialogsInfo(dialogs: Dialog[]): IPanelInfo[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=DockGraphSerializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DockGraphSerializer.d.ts","sourceRoot":"","sources":["../src/DockGraphSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,2BAA2B,CAAC;AAGpD;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,KAAK,EAAE,SAAS;IAM1B,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS;IAiB1C,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE;CAkBnD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The serializer saves / loads the state of the dock layout hierarchy
|
|
3
|
+
*/
|
|
4
|
+
export class DockGraphSerializer {
|
|
5
|
+
serialize(model) {
|
|
6
|
+
const graphInfo = this._buildGraphInfo(model.rootNode);
|
|
7
|
+
const dialogs = this._buildDialogsInfo(model.dialogs.sort((x, y) => x.elementDialog.style.zIndex - y.elementDialog.style.zIndex));
|
|
8
|
+
return JSON.stringify({ graphInfo: graphInfo, dialogsInfo: dialogs });
|
|
9
|
+
}
|
|
10
|
+
_buildGraphInfo(node) {
|
|
11
|
+
const nodeState = {};
|
|
12
|
+
node.container.saveState(nodeState);
|
|
13
|
+
const childrenInfo = [];
|
|
14
|
+
node.children.forEach((childNode) => {
|
|
15
|
+
childrenInfo.push(this._buildGraphInfo(childNode));
|
|
16
|
+
});
|
|
17
|
+
const nodeInfo = {
|
|
18
|
+
containerType: node.container.containerType,
|
|
19
|
+
state: nodeState,
|
|
20
|
+
children: childrenInfo,
|
|
21
|
+
};
|
|
22
|
+
return nodeInfo;
|
|
23
|
+
}
|
|
24
|
+
_buildDialogsInfo(dialogs) {
|
|
25
|
+
const dialogsInfo = [];
|
|
26
|
+
dialogs.forEach((dialog) => {
|
|
27
|
+
const panelState = {};
|
|
28
|
+
const panelContainer = dialog.panel;
|
|
29
|
+
panelContainer.saveState(panelState);
|
|
30
|
+
const panelInfo = {
|
|
31
|
+
containerType: panelContainer.containerType,
|
|
32
|
+
state: panelState,
|
|
33
|
+
position: dialog.getPosition(),
|
|
34
|
+
isHidden: dialog.isHidden,
|
|
35
|
+
};
|
|
36
|
+
dialogsInfo.push(panelInfo);
|
|
37
|
+
});
|
|
38
|
+
return dialogsInfo;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DockManager } from './DockManager.js';
|
|
2
|
+
import { DockNode } from './DockNode.js';
|
|
3
|
+
import { HorizontalDockContainer } from './HorizontalDockContainer.js';
|
|
4
|
+
import { VerticalDockContainer } from './VerticalDockContainer.js';
|
|
5
|
+
import { FillDockContainer } from './FillDockContainer.js';
|
|
6
|
+
import { IRectangle } from './interfaces/IRectangle.js';
|
|
7
|
+
import { IDockContainer } from './interfaces/IDockContainer.js';
|
|
8
|
+
import { TabHandle } from './TabHandle.js';
|
|
9
|
+
export declare class DockLayoutEngine {
|
|
10
|
+
dockManager: DockManager;
|
|
11
|
+
constructor(dockManager: DockManager);
|
|
12
|
+
/** docks the [newNode] to the left of [referenceNode] */
|
|
13
|
+
dockLeft(referenceNode: DockNode, newNode: DockNode): void;
|
|
14
|
+
/** docks the [newNode] to the right of [referenceNode] */
|
|
15
|
+
dockRight(referenceNode: DockNode, newNode: DockNode): void;
|
|
16
|
+
/** docks the [newNode] to the top of [referenceNode] */
|
|
17
|
+
dockUp(referenceNode: DockNode, newNode: DockNode): void;
|
|
18
|
+
/** docks the [newNode] to the bottom of [referenceNode] */
|
|
19
|
+
dockDown(referenceNode: DockNode, newNode: DockNode): void;
|
|
20
|
+
/** docks the [newNode] by creating a new tab inside [referenceNode] */
|
|
21
|
+
dockFill(referenceNode: DockNode, newNode: DockNode): void;
|
|
22
|
+
undock(node: DockNode): void;
|
|
23
|
+
close(node: DockNode): void;
|
|
24
|
+
reorderTabs(node: DockNode, handle: TabHandle, state: string, index: number): void;
|
|
25
|
+
_performDock(referenceNode: DockNode, newNode: DockNode, direction: string, insertBeforeReference: boolean): void;
|
|
26
|
+
_forceResizeCompositeContainer: (container: IDockContainer) => void;
|
|
27
|
+
_createDockContainer(containerType: string, newNode: DockNode, referenceNode: DockNode): FillDockContainer | HorizontalDockContainer | VerticalDockContainer;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the bounds of the new node if it were to dock with the specified configuration
|
|
30
|
+
* The state is not modified in this function. It is used for showing a preview of where
|
|
31
|
+
* the panel would be docked when hovered over a dock wheel button
|
|
32
|
+
*/
|
|
33
|
+
getDockBounds(referenceNode: DockNode, containerToDock: IDockContainer, direction: string, insertBeforeReference: boolean): IRectangle;
|
|
34
|
+
_getVaringDimension(container: IDockContainer, direction: string): number;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=DockLayoutEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DockLayoutEngine.d.ts","sourceRoot":"","sources":["../src/DockLayoutEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,cAAc,EAAC,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,qBAAa,gBAAgB;IAC3B,WAAW,EAAE,WAAW,CAAC;gBAEb,WAAW,EAAE,WAAW;IAIpC,yDAAyD;IACzD,QAAQ,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ;IAInD,0DAA0D;IAC1D,SAAS,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ;IAIpD,wDAAwD;IACxD,MAAM,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ;IAIjD,2DAA2D;IAC3D,QAAQ,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ;IAInD,uEAAuE;IACvE,QAAQ,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ;IAInD,MAAM,CAAC,IAAI,EAAE,QAAQ;IAoDrB,KAAK,CAAC,IAAI,EAAE,QAAQ;IA2DpB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAiB3E,YAAY,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,OAAO;IA8F1G,8BAA8B,cAAe,cAAc,UAIzD;IAEF,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ;IAWtF;;;;SAIK;IACL,aAAa,CAAC,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,qBAAqB,EAAE,OAAO,GAAG,UAAU;IA4EtI,mBAAmB,CAAC,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;CAO1E"}
|