flexlayout-react 0.7.1 → 0.7.4
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/ChangeLog.txt +12 -0
- package/README.md +33 -34
- package/declarations/view/Icons.d.ts +1 -0
- package/declarations/view/Layout.d.ts +1 -0
- package/dist/flexlayout.js +96 -184
- package/dist/flexlayout_min.js +1 -1
- package/lib/Attribute.js +12 -17
- package/lib/Attribute.js.map +1 -1
- package/lib/AttributeDefinitions.js +44 -53
- package/lib/AttributeDefinitions.js.map +1 -1
- package/lib/DockLocation.js +41 -46
- package/lib/DockLocation.js.map +1 -1
- package/lib/DragDrop.js +55 -60
- package/lib/DragDrop.js.map +1 -1
- package/lib/DropInfo.js +3 -8
- package/lib/DropInfo.js.map +1 -1
- package/lib/I18nLabel.js +2 -5
- package/lib/I18nLabel.js.map +1 -1
- package/lib/Orientation.js +11 -16
- package/lib/Orientation.js.map +1 -1
- package/lib/PopupMenu.js +24 -28
- package/lib/PopupMenu.js.map +1 -1
- package/lib/Rect.js +35 -41
- package/lib/Rect.js.map +1 -1
- package/lib/Types.js +2 -5
- package/lib/Types.js.map +1 -1
- package/lib/index.js +22 -38
- package/lib/index.js.map +1 -1
- package/lib/model/Action.js +3 -8
- package/lib/model/Action.js.map +1 -1
- package/lib/model/Actions.js +68 -75
- package/lib/model/Actions.js.map +1 -1
- package/lib/model/BorderNode.js +189 -206
- package/lib/model/BorderNode.js.map +1 -1
- package/lib/model/BorderSet.js +44 -55
- package/lib/model/BorderSet.js.map +1 -1
- package/lib/model/ICloseType.js +2 -5
- package/lib/model/ICloseType.js.map +1 -1
- package/lib/model/IDraggable.js +1 -2
- package/lib/model/IDropTarget.js +1 -2
- package/lib/model/IJsonModel.js +1 -2
- package/lib/model/Model.js +217 -232
- package/lib/model/Model.js.map +1 -1
- package/lib/model/Node.js +87 -94
- package/lib/model/Node.js.map +1 -1
- package/lib/model/RowNode.js +204 -250
- package/lib/model/RowNode.js.map +1 -1
- package/lib/model/SplitterNode.js +35 -57
- package/lib/model/SplitterNode.js.map +1 -1
- package/lib/model/TabNode.js +100 -124
- package/lib/model/TabNode.js.map +1 -1
- package/lib/model/TabSetNode.js +181 -197
- package/lib/model/TabSetNode.js.map +1 -1
- package/lib/model/Utils.js +20 -26
- package/lib/model/Utils.js.map +1 -1
- package/lib/view/BorderButton.js +45 -49
- package/lib/view/BorderButton.js.map +1 -1
- package/lib/view/BorderTabSet.js +57 -61
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/ErrorBoundary.js +15 -37
- package/lib/view/ErrorBoundary.js.map +1 -1
- package/lib/view/FloatingWindow.js +43 -56
- package/lib/view/FloatingWindow.js.map +1 -1
- package/lib/view/FloatingWindowTab.js +12 -16
- package/lib/view/FloatingWindowTab.js.map +1 -1
- package/lib/view/Icons.js +17 -25
- package/lib/view/Icons.js.map +1 -1
- package/lib/view/Layout.js +396 -508
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/Splitter.js +53 -57
- package/lib/view/Splitter.js.map +1 -1
- package/lib/view/Tab.js +31 -35
- package/lib/view/Tab.js.map +1 -1
- package/lib/view/TabButton.js +46 -50
- package/lib/view/TabButton.js.map +1 -1
- package/lib/view/TabButtonStamp.js +11 -15
- package/lib/view/TabButtonStamp.js.map +1 -1
- package/lib/view/TabFloating.js +30 -34
- package/lib/view/TabFloating.js.map +1 -1
- package/lib/view/TabOverflowHook.js +46 -50
- package/lib/view/TabOverflowHook.js.map +1 -1
- package/lib/view/TabSet.js +93 -106
- package/lib/view/TabSet.js.map +1 -1
- package/lib/view/Utils.js +11 -17
- package/lib/view/Utils.js.map +1 -1
- package/package.json +5 -3
- package/src/model/BorderNode.ts +6 -1
- package/src/model/TabSetNode.ts +6 -1
- package/src/view/FloatingWindow.tsx +5 -1
- package/src/view/Icons.tsx +7 -7
- package/src/view/Layout.tsx +23 -104
- package/style/dark.css +1 -0
- package/style/dark.css.map +1 -1
- package/style/dark.scss +1 -0
- package/style/gray.css +1 -0
- package/style/gray.css.map +1 -1
- package/style/gray.scss +1 -0
- package/style/light.css +1 -0
- package/style/light.css.map +1 -1
- package/style/light.scss +1 -0
- package/style/underline.css +1 -0
- package/style/underline.css.map +1 -1
- package/style/underline.scss +1 -0
package/lib/model/Model.js
CHANGED
|
@@ -1,242 +1,230 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var Attribute_1 = require("../Attribute");
|
|
15
|
-
var AttributeDefinitions_1 = require("../AttributeDefinitions");
|
|
16
|
-
var DockLocation_1 = require("../DockLocation");
|
|
17
|
-
var Orientation_1 = require("../Orientation");
|
|
18
|
-
var Rect_1 = require("../Rect");
|
|
19
|
-
var Actions_1 = require("./Actions");
|
|
20
|
-
var BorderNode_1 = require("./BorderNode");
|
|
21
|
-
var BorderSet_1 = require("./BorderSet");
|
|
22
|
-
var RowNode_1 = require("./RowNode");
|
|
23
|
-
var TabNode_1 = require("./TabNode");
|
|
24
|
-
var TabSetNode_1 = require("./TabSetNode");
|
|
25
|
-
var Utils_1 = require("./Utils");
|
|
1
|
+
import { v4 as getUUID } from "uuid";
|
|
2
|
+
import { Attribute } from "../Attribute";
|
|
3
|
+
import { AttributeDefinitions } from "../AttributeDefinitions";
|
|
4
|
+
import { DockLocation } from "../DockLocation";
|
|
5
|
+
import { Orientation } from "../Orientation";
|
|
6
|
+
import { Rect } from "../Rect";
|
|
7
|
+
import { Actions } from "./Actions";
|
|
8
|
+
import { BorderNode } from "./BorderNode";
|
|
9
|
+
import { BorderSet } from "./BorderSet";
|
|
10
|
+
import { RowNode } from "./RowNode";
|
|
11
|
+
import { TabNode } from "./TabNode";
|
|
12
|
+
import { TabSetNode } from "./TabSetNode";
|
|
13
|
+
import { adjustSelectedIndexAfterDock, adjustSelectedIndexAfterFloat } from "./Utils";
|
|
26
14
|
/**
|
|
27
15
|
* Class containing the Tree of Nodes used by the FlexLayout component
|
|
28
16
|
*/
|
|
29
|
-
|
|
17
|
+
export class Model {
|
|
30
18
|
/**
|
|
31
19
|
* 'private' constructor. Use the static method Model.fromJson(json) to create a model
|
|
32
20
|
* @internal
|
|
33
21
|
*/
|
|
34
|
-
|
|
22
|
+
constructor() {
|
|
35
23
|
/** @internal */
|
|
36
|
-
this._borderRects = { inner:
|
|
24
|
+
this._borderRects = { inner: Rect.empty(), outer: Rect.empty() };
|
|
37
25
|
this._attributes = {};
|
|
38
26
|
this._idMap = {};
|
|
39
|
-
this._borders = new
|
|
27
|
+
this._borders = new BorderSet(this);
|
|
40
28
|
this._pointerFine = true;
|
|
41
|
-
this._showHiddenBorder =
|
|
29
|
+
this._showHiddenBorder = DockLocation.CENTER;
|
|
42
30
|
}
|
|
43
31
|
/**
|
|
44
32
|
* Loads the model from the given json object
|
|
45
33
|
* @param json the json model to load
|
|
46
34
|
* @returns {Model} a new Model object
|
|
47
35
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
static fromJson(json) {
|
|
37
|
+
const model = new Model();
|
|
50
38
|
Model._attributeDefinitions.fromJson(json.global, model._attributes);
|
|
51
39
|
if (json.borders) {
|
|
52
|
-
model._borders =
|
|
40
|
+
model._borders = BorderSet._fromJson(json.borders, model);
|
|
53
41
|
}
|
|
54
|
-
model._root =
|
|
42
|
+
model._root = RowNode._fromJson(json.layout, model);
|
|
55
43
|
model._tidy(); // initial tidy of node tree
|
|
56
44
|
return model;
|
|
57
|
-
}
|
|
45
|
+
}
|
|
58
46
|
/** @internal */
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
attributeDefinitions.add("legacyOverflowMenu", false).setType(
|
|
47
|
+
static _createAttributeDefinitions() {
|
|
48
|
+
const attributeDefinitions = new AttributeDefinitions();
|
|
49
|
+
attributeDefinitions.add("legacyOverflowMenu", false).setType(Attribute.BOOLEAN);
|
|
62
50
|
// splitter
|
|
63
|
-
attributeDefinitions.add("splitterSize", -1).setType(
|
|
64
|
-
attributeDefinitions.add("splitterExtra", 0).setType(
|
|
65
|
-
attributeDefinitions.add("enableEdgeDock", true).setType(
|
|
66
|
-
attributeDefinitions.add("rootOrientationVertical", false).setType(
|
|
51
|
+
attributeDefinitions.add("splitterSize", -1).setType(Attribute.NUMBER);
|
|
52
|
+
attributeDefinitions.add("splitterExtra", 0).setType(Attribute.NUMBER);
|
|
53
|
+
attributeDefinitions.add("enableEdgeDock", true).setType(Attribute.BOOLEAN);
|
|
54
|
+
attributeDefinitions.add("rootOrientationVertical", false).setType(Attribute.BOOLEAN);
|
|
67
55
|
attributeDefinitions.add("marginInsets", { top: 0, right: 0, bottom: 0, left: 0 })
|
|
68
56
|
.setType("IInsets");
|
|
69
|
-
attributeDefinitions.add("enableUseVisibility", false).setType(
|
|
57
|
+
attributeDefinitions.add("enableUseVisibility", false).setType(Attribute.BOOLEAN);
|
|
70
58
|
// tab
|
|
71
|
-
attributeDefinitions.add("tabEnableClose", true).setType(
|
|
59
|
+
attributeDefinitions.add("tabEnableClose", true).setType(Attribute.BOOLEAN);
|
|
72
60
|
attributeDefinitions.add("tabCloseType", 1).setType("ICloseType");
|
|
73
|
-
attributeDefinitions.add("tabEnableFloat", false).setType(
|
|
74
|
-
attributeDefinitions.add("tabEnableDrag", true).setType(
|
|
75
|
-
attributeDefinitions.add("tabEnableRename", true).setType(
|
|
76
|
-
attributeDefinitions.add("tabClassName", undefined).setType(
|
|
77
|
-
attributeDefinitions.add("tabIcon", undefined).setType(
|
|
78
|
-
attributeDefinitions.add("tabEnableRenderOnDemand", true).setType(
|
|
79
|
-
attributeDefinitions.add("tabDragSpeed", 0.3).setType(
|
|
80
|
-
attributeDefinitions.add("tabBorderWidth", -1).setType(
|
|
81
|
-
attributeDefinitions.add("tabBorderHeight", -1).setType(
|
|
61
|
+
attributeDefinitions.add("tabEnableFloat", false).setType(Attribute.BOOLEAN);
|
|
62
|
+
attributeDefinitions.add("tabEnableDrag", true).setType(Attribute.BOOLEAN);
|
|
63
|
+
attributeDefinitions.add("tabEnableRename", true).setType(Attribute.BOOLEAN);
|
|
64
|
+
attributeDefinitions.add("tabClassName", undefined).setType(Attribute.STRING);
|
|
65
|
+
attributeDefinitions.add("tabIcon", undefined).setType(Attribute.STRING);
|
|
66
|
+
attributeDefinitions.add("tabEnableRenderOnDemand", true).setType(Attribute.BOOLEAN);
|
|
67
|
+
attributeDefinitions.add("tabDragSpeed", 0.3).setType(Attribute.NUMBER);
|
|
68
|
+
attributeDefinitions.add("tabBorderWidth", -1).setType(Attribute.NUMBER);
|
|
69
|
+
attributeDefinitions.add("tabBorderHeight", -1).setType(Attribute.NUMBER);
|
|
82
70
|
// tabset
|
|
83
|
-
attributeDefinitions.add("tabSetEnableDeleteWhenEmpty", true).setType(
|
|
84
|
-
attributeDefinitions.add("tabSetEnableDrop", true).setType(
|
|
85
|
-
attributeDefinitions.add("tabSetEnableDrag", true).setType(
|
|
86
|
-
attributeDefinitions.add("tabSetEnableDivide", true).setType(
|
|
87
|
-
attributeDefinitions.add("tabSetEnableMaximize", true).setType(
|
|
88
|
-
attributeDefinitions.add("tabSetEnableClose", false).setType(
|
|
89
|
-
attributeDefinitions.add("tabSetAutoSelectTab", true).setType(
|
|
90
|
-
attributeDefinitions.add("tabSetClassNameTabStrip", undefined).setType(
|
|
91
|
-
attributeDefinitions.add("tabSetClassNameHeader", undefined).setType(
|
|
92
|
-
attributeDefinitions.add("tabSetEnableTabStrip", true).setType(
|
|
93
|
-
attributeDefinitions.add("tabSetHeaderHeight", 0).setType(
|
|
94
|
-
attributeDefinitions.add("tabSetTabStripHeight", 0).setType(
|
|
71
|
+
attributeDefinitions.add("tabSetEnableDeleteWhenEmpty", true).setType(Attribute.BOOLEAN);
|
|
72
|
+
attributeDefinitions.add("tabSetEnableDrop", true).setType(Attribute.BOOLEAN);
|
|
73
|
+
attributeDefinitions.add("tabSetEnableDrag", true).setType(Attribute.BOOLEAN);
|
|
74
|
+
attributeDefinitions.add("tabSetEnableDivide", true).setType(Attribute.BOOLEAN);
|
|
75
|
+
attributeDefinitions.add("tabSetEnableMaximize", true).setType(Attribute.BOOLEAN);
|
|
76
|
+
attributeDefinitions.add("tabSetEnableClose", false).setType(Attribute.BOOLEAN);
|
|
77
|
+
attributeDefinitions.add("tabSetAutoSelectTab", true).setType(Attribute.BOOLEAN);
|
|
78
|
+
attributeDefinitions.add("tabSetClassNameTabStrip", undefined).setType(Attribute.STRING);
|
|
79
|
+
attributeDefinitions.add("tabSetClassNameHeader", undefined).setType(Attribute.STRING);
|
|
80
|
+
attributeDefinitions.add("tabSetEnableTabStrip", true).setType(Attribute.BOOLEAN);
|
|
81
|
+
attributeDefinitions.add("tabSetHeaderHeight", 0).setType(Attribute.NUMBER);
|
|
82
|
+
attributeDefinitions.add("tabSetTabStripHeight", 0).setType(Attribute.NUMBER);
|
|
95
83
|
attributeDefinitions.add("tabSetMarginInsets", { top: 0, right: 0, bottom: 0, left: 0 })
|
|
96
84
|
.setType("IInsets");
|
|
97
85
|
attributeDefinitions.add("tabSetBorderInsets", { top: 0, right: 0, bottom: 0, left: 0 })
|
|
98
86
|
.setType("IInsets");
|
|
99
87
|
attributeDefinitions.add("tabSetTabLocation", "top").setType("ITabLocation");
|
|
100
|
-
attributeDefinitions.add("tabSetMinWidth", 0).setType(
|
|
101
|
-
attributeDefinitions.add("tabSetMinHeight", 0).setType(
|
|
88
|
+
attributeDefinitions.add("tabSetMinWidth", 0).setType(Attribute.NUMBER);
|
|
89
|
+
attributeDefinitions.add("tabSetMinHeight", 0).setType(Attribute.NUMBER);
|
|
102
90
|
// border
|
|
103
|
-
attributeDefinitions.add("borderSize", 200).setType(
|
|
104
|
-
attributeDefinitions.add("borderMinSize", 0).setType(
|
|
105
|
-
attributeDefinitions.add("borderBarSize", 0).setType(
|
|
106
|
-
attributeDefinitions.add("borderEnableDrop", true).setType(
|
|
107
|
-
attributeDefinitions.add("borderAutoSelectTabWhenOpen", true).setType(
|
|
108
|
-
attributeDefinitions.add("borderAutoSelectTabWhenClosed", false).setType(
|
|
109
|
-
attributeDefinitions.add("borderClassName", undefined).setType(
|
|
110
|
-
attributeDefinitions.add("borderEnableAutoHide", false).setType(
|
|
91
|
+
attributeDefinitions.add("borderSize", 200).setType(Attribute.NUMBER);
|
|
92
|
+
attributeDefinitions.add("borderMinSize", 0).setType(Attribute.NUMBER);
|
|
93
|
+
attributeDefinitions.add("borderBarSize", 0).setType(Attribute.NUMBER);
|
|
94
|
+
attributeDefinitions.add("borderEnableDrop", true).setType(Attribute.BOOLEAN);
|
|
95
|
+
attributeDefinitions.add("borderAutoSelectTabWhenOpen", true).setType(Attribute.BOOLEAN);
|
|
96
|
+
attributeDefinitions.add("borderAutoSelectTabWhenClosed", false).setType(Attribute.BOOLEAN);
|
|
97
|
+
attributeDefinitions.add("borderClassName", undefined).setType(Attribute.STRING);
|
|
98
|
+
attributeDefinitions.add("borderEnableAutoHide", false).setType(Attribute.BOOLEAN);
|
|
111
99
|
return attributeDefinitions;
|
|
112
|
-
}
|
|
100
|
+
}
|
|
113
101
|
/** @internal */
|
|
114
|
-
|
|
102
|
+
_setChangeListener(listener) {
|
|
115
103
|
this._changeListener = listener;
|
|
116
|
-
}
|
|
104
|
+
}
|
|
117
105
|
/**
|
|
118
106
|
* Get the currently active tabset node
|
|
119
107
|
*/
|
|
120
|
-
|
|
108
|
+
getActiveTabset() {
|
|
121
109
|
if (this._activeTabSet && this.getNodeById(this._activeTabSet.getId())) {
|
|
122
110
|
return this._activeTabSet;
|
|
123
111
|
}
|
|
124
112
|
else {
|
|
125
113
|
return undefined;
|
|
126
114
|
}
|
|
127
|
-
}
|
|
115
|
+
}
|
|
128
116
|
/** @internal */
|
|
129
|
-
|
|
117
|
+
_getShowHiddenBorder() {
|
|
130
118
|
return this._showHiddenBorder;
|
|
131
|
-
}
|
|
119
|
+
}
|
|
132
120
|
/** @internal */
|
|
133
|
-
|
|
121
|
+
_setShowHiddenBorder(location) {
|
|
134
122
|
this._showHiddenBorder = location;
|
|
135
|
-
}
|
|
123
|
+
}
|
|
136
124
|
/** @internal */
|
|
137
|
-
|
|
125
|
+
_setActiveTabset(tabsetNode) {
|
|
138
126
|
this._activeTabSet = tabsetNode;
|
|
139
|
-
}
|
|
127
|
+
}
|
|
140
128
|
/**
|
|
141
129
|
* Get the currently maximized tabset node
|
|
142
130
|
*/
|
|
143
|
-
|
|
131
|
+
getMaximizedTabset() {
|
|
144
132
|
return this._maximizedTabSet;
|
|
145
|
-
}
|
|
133
|
+
}
|
|
146
134
|
/** @internal */
|
|
147
|
-
|
|
135
|
+
_setMaximizedTabset(tabsetNode) {
|
|
148
136
|
this._maximizedTabSet = tabsetNode;
|
|
149
|
-
}
|
|
137
|
+
}
|
|
150
138
|
/**
|
|
151
139
|
* Gets the root RowNode of the model
|
|
152
140
|
* @returns {RowNode}
|
|
153
141
|
*/
|
|
154
|
-
|
|
142
|
+
getRoot() {
|
|
155
143
|
return this._root;
|
|
156
|
-
}
|
|
157
|
-
|
|
144
|
+
}
|
|
145
|
+
isRootOrientationVertical() {
|
|
158
146
|
return this._attributes.rootOrientationVertical;
|
|
159
|
-
}
|
|
160
|
-
|
|
147
|
+
}
|
|
148
|
+
isUseVisibility() {
|
|
161
149
|
return this._attributes.enableUseVisibility;
|
|
162
|
-
}
|
|
150
|
+
}
|
|
163
151
|
/**
|
|
164
152
|
* Gets the
|
|
165
153
|
* @returns {BorderSet|*}
|
|
166
154
|
*/
|
|
167
|
-
|
|
155
|
+
getBorderSet() {
|
|
168
156
|
return this._borders;
|
|
169
|
-
}
|
|
157
|
+
}
|
|
170
158
|
/** @internal */
|
|
171
|
-
|
|
159
|
+
_getOuterInnerRects() {
|
|
172
160
|
return this._borderRects;
|
|
173
|
-
}
|
|
161
|
+
}
|
|
174
162
|
/** @internal */
|
|
175
|
-
|
|
163
|
+
_getPointerFine() {
|
|
176
164
|
return this._pointerFine;
|
|
177
|
-
}
|
|
165
|
+
}
|
|
178
166
|
/** @internal */
|
|
179
|
-
|
|
167
|
+
_setPointerFine(pointerFine) {
|
|
180
168
|
this._pointerFine = pointerFine;
|
|
181
|
-
}
|
|
169
|
+
}
|
|
182
170
|
/**
|
|
183
171
|
* Visits all the nodes in the model and calls the given function for each
|
|
184
172
|
* @param fn a function that takes visited node and a integer level as parameters
|
|
185
173
|
*/
|
|
186
|
-
|
|
174
|
+
visitNodes(fn) {
|
|
187
175
|
this._borders._forEachNode(fn);
|
|
188
176
|
this._root._forEachNode(fn, 0);
|
|
189
|
-
}
|
|
177
|
+
}
|
|
190
178
|
/**
|
|
191
179
|
* Gets a node by its id
|
|
192
180
|
* @param id the id to find
|
|
193
181
|
*/
|
|
194
|
-
|
|
182
|
+
getNodeById(id) {
|
|
195
183
|
return this._idMap[id];
|
|
196
|
-
}
|
|
184
|
+
}
|
|
197
185
|
/**
|
|
198
186
|
* Update the node tree by performing the given action,
|
|
199
187
|
* Actions should be generated via static methods on the Actions class
|
|
200
188
|
* @param action the action to perform
|
|
201
189
|
* @returns added Node for Actions.addNode; undefined otherwise
|
|
202
190
|
*/
|
|
203
|
-
|
|
204
|
-
|
|
191
|
+
doAction(action) {
|
|
192
|
+
let returnVal = undefined;
|
|
205
193
|
// console.log(action);
|
|
206
194
|
switch (action.type) {
|
|
207
|
-
case
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (toNode instanceof
|
|
211
|
-
toNode.drop(newNode,
|
|
195
|
+
case Actions.ADD_NODE: {
|
|
196
|
+
const newNode = new TabNode(this, action.data.json, true);
|
|
197
|
+
const toNode = this._idMap[action.data.toNode];
|
|
198
|
+
if (toNode instanceof TabSetNode || toNode instanceof BorderNode || toNode instanceof RowNode) {
|
|
199
|
+
toNode.drop(newNode, DockLocation.getByName(action.data.location), action.data.index, action.data.select);
|
|
212
200
|
returnVal = newNode;
|
|
213
201
|
}
|
|
214
202
|
break;
|
|
215
203
|
}
|
|
216
|
-
case
|
|
217
|
-
|
|
218
|
-
if (fromNode instanceof
|
|
219
|
-
|
|
220
|
-
if (toNode instanceof
|
|
221
|
-
toNode.drop(fromNode,
|
|
204
|
+
case Actions.MOVE_NODE: {
|
|
205
|
+
const fromNode = this._idMap[action.data.fromNode];
|
|
206
|
+
if (fromNode instanceof TabNode || fromNode instanceof TabSetNode) {
|
|
207
|
+
const toNode = this._idMap[action.data.toNode];
|
|
208
|
+
if (toNode instanceof TabSetNode || toNode instanceof BorderNode || toNode instanceof RowNode) {
|
|
209
|
+
toNode.drop(fromNode, DockLocation.getByName(action.data.location), action.data.index, action.data.select);
|
|
222
210
|
}
|
|
223
211
|
}
|
|
224
212
|
break;
|
|
225
213
|
}
|
|
226
|
-
case
|
|
227
|
-
|
|
228
|
-
if (node instanceof
|
|
214
|
+
case Actions.DELETE_TAB: {
|
|
215
|
+
const node = this._idMap[action.data.node];
|
|
216
|
+
if (node instanceof TabNode) {
|
|
229
217
|
node._delete();
|
|
230
218
|
}
|
|
231
219
|
break;
|
|
232
220
|
}
|
|
233
|
-
case
|
|
234
|
-
|
|
235
|
-
if (node instanceof
|
|
221
|
+
case Actions.DELETE_TABSET: {
|
|
222
|
+
const node = this._idMap[action.data.node];
|
|
223
|
+
if (node instanceof TabSetNode) {
|
|
236
224
|
// first delete all child tabs that are closeable
|
|
237
|
-
|
|
238
|
-
for (
|
|
239
|
-
|
|
225
|
+
const children = [...node.getChildren()];
|
|
226
|
+
for (let i = 0; i < children.length; i++) {
|
|
227
|
+
const child = children[i];
|
|
240
228
|
if (child.isEnableClose()) {
|
|
241
229
|
child._delete();
|
|
242
230
|
}
|
|
@@ -248,77 +236,77 @@ var Model = /** @class */ (function () {
|
|
|
248
236
|
}
|
|
249
237
|
break;
|
|
250
238
|
}
|
|
251
|
-
case
|
|
252
|
-
|
|
253
|
-
if (node instanceof
|
|
239
|
+
case Actions.FLOAT_TAB: {
|
|
240
|
+
const node = this._idMap[action.data.node];
|
|
241
|
+
if (node instanceof TabNode) {
|
|
254
242
|
node._setFloating(true);
|
|
255
|
-
|
|
243
|
+
adjustSelectedIndexAfterFloat(node);
|
|
256
244
|
}
|
|
257
245
|
break;
|
|
258
246
|
}
|
|
259
|
-
case
|
|
260
|
-
|
|
261
|
-
if (node instanceof
|
|
247
|
+
case Actions.UNFLOAT_TAB: {
|
|
248
|
+
const node = this._idMap[action.data.node];
|
|
249
|
+
if (node instanceof TabNode) {
|
|
262
250
|
node._setFloating(false);
|
|
263
|
-
|
|
251
|
+
adjustSelectedIndexAfterDock(node);
|
|
264
252
|
}
|
|
265
253
|
break;
|
|
266
254
|
}
|
|
267
|
-
case
|
|
268
|
-
|
|
269
|
-
if (node instanceof
|
|
255
|
+
case Actions.RENAME_TAB: {
|
|
256
|
+
const node = this._idMap[action.data.node];
|
|
257
|
+
if (node instanceof TabNode) {
|
|
270
258
|
node._setName(action.data.text);
|
|
271
259
|
}
|
|
272
260
|
break;
|
|
273
261
|
}
|
|
274
|
-
case
|
|
275
|
-
|
|
276
|
-
if (tabNode instanceof
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (
|
|
280
|
-
if (
|
|
281
|
-
|
|
262
|
+
case Actions.SELECT_TAB: {
|
|
263
|
+
const tabNode = this._idMap[action.data.tabNode];
|
|
264
|
+
if (tabNode instanceof TabNode) {
|
|
265
|
+
const parent = tabNode.getParent();
|
|
266
|
+
const pos = parent.getChildren().indexOf(tabNode);
|
|
267
|
+
if (parent instanceof BorderNode) {
|
|
268
|
+
if (parent.getSelected() === pos) {
|
|
269
|
+
parent._setSelected(-1);
|
|
282
270
|
}
|
|
283
271
|
else {
|
|
284
|
-
|
|
272
|
+
parent._setSelected(pos);
|
|
285
273
|
}
|
|
286
274
|
}
|
|
287
|
-
else if (
|
|
288
|
-
if (
|
|
289
|
-
|
|
275
|
+
else if (parent instanceof TabSetNode) {
|
|
276
|
+
if (parent.getSelected() !== pos) {
|
|
277
|
+
parent._setSelected(pos);
|
|
290
278
|
}
|
|
291
|
-
this._activeTabSet =
|
|
279
|
+
this._activeTabSet = parent;
|
|
292
280
|
}
|
|
293
281
|
}
|
|
294
282
|
break;
|
|
295
283
|
}
|
|
296
|
-
case
|
|
297
|
-
|
|
298
|
-
if (tabsetNode instanceof
|
|
284
|
+
case Actions.SET_ACTIVE_TABSET: {
|
|
285
|
+
const tabsetNode = this._idMap[action.data.tabsetNode];
|
|
286
|
+
if (tabsetNode instanceof TabSetNode) {
|
|
299
287
|
this._activeTabSet = tabsetNode;
|
|
300
288
|
}
|
|
301
289
|
break;
|
|
302
290
|
}
|
|
303
|
-
case
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if ((node1 instanceof
|
|
291
|
+
case Actions.ADJUST_SPLIT: {
|
|
292
|
+
const node1 = this._idMap[action.data.node1];
|
|
293
|
+
const node2 = this._idMap[action.data.node2];
|
|
294
|
+
if ((node1 instanceof TabSetNode || node1 instanceof RowNode) && (node2 instanceof TabSetNode || node2 instanceof RowNode)) {
|
|
307
295
|
this._adjustSplitSide(node1, action.data.weight1, action.data.pixelWidth1);
|
|
308
296
|
this._adjustSplitSide(node2, action.data.weight2, action.data.pixelWidth2);
|
|
309
297
|
}
|
|
310
298
|
break;
|
|
311
299
|
}
|
|
312
|
-
case
|
|
313
|
-
|
|
314
|
-
if (node instanceof
|
|
300
|
+
case Actions.ADJUST_BORDER_SPLIT: {
|
|
301
|
+
const node = this._idMap[action.data.node];
|
|
302
|
+
if (node instanceof BorderNode) {
|
|
315
303
|
node._setSize(action.data.pos);
|
|
316
304
|
}
|
|
317
305
|
break;
|
|
318
306
|
}
|
|
319
|
-
case
|
|
320
|
-
|
|
321
|
-
if (node instanceof
|
|
307
|
+
case Actions.MAXIMIZE_TOGGLE: {
|
|
308
|
+
const node = this._idMap[action.data.node];
|
|
309
|
+
if (node instanceof TabSetNode) {
|
|
322
310
|
if (node === this._maximizedTabSet) {
|
|
323
311
|
this._maximizedTabSet = undefined;
|
|
324
312
|
}
|
|
@@ -329,12 +317,12 @@ var Model = /** @class */ (function () {
|
|
|
329
317
|
}
|
|
330
318
|
break;
|
|
331
319
|
}
|
|
332
|
-
case
|
|
320
|
+
case Actions.UPDATE_MODEL_ATTRIBUTES: {
|
|
333
321
|
this._updateAttrs(action.data.json);
|
|
334
322
|
break;
|
|
335
323
|
}
|
|
336
|
-
case
|
|
337
|
-
|
|
324
|
+
case Actions.UPDATE_NODE_ATTRIBUTES: {
|
|
325
|
+
const node = this._idMap[action.data.node];
|
|
338
326
|
node._updateAttrs(action.data.json);
|
|
339
327
|
break;
|
|
340
328
|
}
|
|
@@ -346,67 +334,66 @@ var Model = /** @class */ (function () {
|
|
|
346
334
|
this._changeListener();
|
|
347
335
|
}
|
|
348
336
|
return returnVal;
|
|
349
|
-
}
|
|
337
|
+
}
|
|
350
338
|
/** @internal */
|
|
351
|
-
|
|
352
|
-
var _this = this;
|
|
339
|
+
_updateIdMap() {
|
|
353
340
|
// regenerate idMap to stop it building up
|
|
354
341
|
this._idMap = {};
|
|
355
|
-
this.visitNodes(
|
|
342
|
+
this.visitNodes((node) => (this._idMap[node.getId()] = node));
|
|
356
343
|
// console.log(JSON.stringify(Object.keys(this._idMap)));
|
|
357
|
-
}
|
|
344
|
+
}
|
|
358
345
|
/** @internal */
|
|
359
|
-
|
|
346
|
+
_adjustSplitSide(node, weight, pixels) {
|
|
360
347
|
node._setWeight(weight);
|
|
361
|
-
if (node.getWidth() != null && node.getOrientation() ===
|
|
348
|
+
if (node.getWidth() != null && node.getOrientation() === Orientation.VERT) {
|
|
362
349
|
node._updateAttrs({ width: pixels });
|
|
363
350
|
}
|
|
364
|
-
else if (node.getHeight() != null && node.getOrientation() ===
|
|
351
|
+
else if (node.getHeight() != null && node.getOrientation() === Orientation.HORZ) {
|
|
365
352
|
node._updateAttrs({ height: pixels });
|
|
366
353
|
}
|
|
367
|
-
}
|
|
354
|
+
}
|
|
368
355
|
/**
|
|
369
356
|
* Converts the model to a json object
|
|
370
357
|
* @returns {IJsonModel} json object that represents this model
|
|
371
358
|
*/
|
|
372
|
-
|
|
373
|
-
|
|
359
|
+
toJson() {
|
|
360
|
+
const global = {};
|
|
374
361
|
Model._attributeDefinitions.toJson(global, this._attributes);
|
|
375
362
|
// save state of nodes
|
|
376
|
-
this.visitNodes(
|
|
363
|
+
this.visitNodes((node) => {
|
|
377
364
|
node._fireEvent("save", undefined);
|
|
378
365
|
});
|
|
379
|
-
return { global
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
366
|
+
return { global, borders: this._borders._toJson(), layout: this._root.toJson() };
|
|
367
|
+
}
|
|
368
|
+
getSplitterSize() {
|
|
369
|
+
let splitterSize = this._attributes.splitterSize;
|
|
383
370
|
if (splitterSize === -1) {
|
|
384
371
|
// use defaults
|
|
385
372
|
splitterSize = this._pointerFine ? 8 : 12; // larger for mobile
|
|
386
373
|
}
|
|
387
374
|
return splitterSize;
|
|
388
|
-
}
|
|
389
|
-
|
|
375
|
+
}
|
|
376
|
+
isLegacyOverflowMenu() {
|
|
390
377
|
return this._attributes.legacyOverflowMenu;
|
|
391
|
-
}
|
|
392
|
-
|
|
378
|
+
}
|
|
379
|
+
getSplitterExtra() {
|
|
393
380
|
return this._attributes.splitterExtra;
|
|
394
|
-
}
|
|
395
|
-
|
|
381
|
+
}
|
|
382
|
+
isEnableEdgeDock() {
|
|
396
383
|
return this._attributes.enableEdgeDock;
|
|
397
|
-
}
|
|
384
|
+
}
|
|
398
385
|
/** @internal */
|
|
399
|
-
|
|
400
|
-
|
|
386
|
+
_addNode(node) {
|
|
387
|
+
const id = node.getId();
|
|
401
388
|
if (this._idMap[id] !== undefined) {
|
|
402
|
-
throw new Error(
|
|
389
|
+
throw new Error(`Error: each node must have a unique id, duplicate id:${node.getId()}`);
|
|
403
390
|
}
|
|
404
391
|
if (node.getType() !== "splitter") {
|
|
405
392
|
this._idMap[id] = node;
|
|
406
393
|
}
|
|
407
|
-
}
|
|
394
|
+
}
|
|
408
395
|
/** @internal */
|
|
409
|
-
|
|
396
|
+
_layout(rect, metrics) {
|
|
410
397
|
var _a;
|
|
411
398
|
// let start = Date.now();
|
|
412
399
|
this._borderRects = this._borders._layoutBorder({ outer: rect, inner: rect }, metrics);
|
|
@@ -415,70 +402,68 @@ var Model = /** @class */ (function () {
|
|
|
415
402
|
this._root._layout(rect, metrics);
|
|
416
403
|
// console.log("layout time: " + (Date.now() - start));
|
|
417
404
|
return rect;
|
|
418
|
-
}
|
|
405
|
+
}
|
|
419
406
|
/** @internal */
|
|
420
|
-
|
|
421
|
-
|
|
407
|
+
_findDropTargetNode(dragNode, x, y) {
|
|
408
|
+
let node = this._root._findDropTargetNode(dragNode, x, y);
|
|
422
409
|
if (node === undefined) {
|
|
423
410
|
node = this._borders._findDropTargetNode(dragNode, x, y);
|
|
424
411
|
}
|
|
425
412
|
return node;
|
|
426
|
-
}
|
|
413
|
+
}
|
|
427
414
|
/** @internal */
|
|
428
|
-
|
|
415
|
+
_tidy() {
|
|
429
416
|
// console.log("before _tidy", this.toString());
|
|
430
417
|
this._root._tidy();
|
|
431
418
|
// console.log("after _tidy", this.toString());
|
|
432
|
-
}
|
|
419
|
+
}
|
|
433
420
|
/** @internal */
|
|
434
|
-
|
|
421
|
+
_updateAttrs(json) {
|
|
435
422
|
Model._attributeDefinitions.update(json, this._attributes);
|
|
436
|
-
}
|
|
423
|
+
}
|
|
437
424
|
/** @internal */
|
|
438
|
-
|
|
439
|
-
return '#' + (
|
|
440
|
-
}
|
|
425
|
+
_nextUniqueId() {
|
|
426
|
+
return '#' + getUUID();
|
|
427
|
+
}
|
|
441
428
|
/** @internal */
|
|
442
|
-
|
|
429
|
+
_getAttribute(name) {
|
|
443
430
|
return this._attributes[name];
|
|
444
|
-
}
|
|
431
|
+
}
|
|
445
432
|
/**
|
|
446
433
|
* Sets a function to allow/deny dropping a node
|
|
447
434
|
* @param onAllowDrop function that takes the drag node and DropInfo and returns true if the drop is allowed
|
|
448
435
|
*/
|
|
449
|
-
|
|
436
|
+
setOnAllowDrop(onAllowDrop) {
|
|
450
437
|
this._onAllowDrop = onAllowDrop;
|
|
451
|
-
}
|
|
438
|
+
}
|
|
452
439
|
/** @internal */
|
|
453
|
-
|
|
440
|
+
_getOnAllowDrop() {
|
|
454
441
|
return this._onAllowDrop;
|
|
455
|
-
}
|
|
442
|
+
}
|
|
456
443
|
/**
|
|
457
444
|
* set callback called when a new TabSet is created.
|
|
458
445
|
* The tabNode can be undefined if it's the auto created first tabset in the root row (when the last
|
|
459
446
|
* tab is deleted, the root tabset can be recreated)
|
|
460
447
|
* @param onCreateTabSet
|
|
461
448
|
*/
|
|
462
|
-
|
|
449
|
+
setOnCreateTabSet(onCreateTabSet) {
|
|
463
450
|
this._onCreateTabSet = onCreateTabSet;
|
|
464
|
-
}
|
|
451
|
+
}
|
|
465
452
|
/** @internal */
|
|
466
|
-
|
|
453
|
+
_getOnCreateTabSet() {
|
|
467
454
|
return this._onCreateTabSet;
|
|
468
|
-
}
|
|
469
|
-
|
|
455
|
+
}
|
|
456
|
+
static toTypescriptInterfaces() {
|
|
470
457
|
console.log(Model._attributeDefinitions.toTypescriptInterface("Global", undefined));
|
|
471
|
-
console.log(
|
|
472
|
-
console.log(
|
|
473
|
-
console.log(
|
|
474
|
-
console.log(
|
|
475
|
-
}
|
|
476
|
-
|
|
458
|
+
console.log(RowNode.getAttributeDefinitions().toTypescriptInterface("Row", Model._attributeDefinitions));
|
|
459
|
+
console.log(TabSetNode.getAttributeDefinitions().toTypescriptInterface("TabSet", Model._attributeDefinitions));
|
|
460
|
+
console.log(TabNode.getAttributeDefinitions().toTypescriptInterface("Tab", Model._attributeDefinitions));
|
|
461
|
+
console.log(BorderNode.getAttributeDefinitions().toTypescriptInterface("Border", Model._attributeDefinitions));
|
|
462
|
+
}
|
|
463
|
+
toString() {
|
|
477
464
|
return JSON.stringify(this.toJson());
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}());
|
|
483
|
-
exports.Model = Model;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/** @internal */
|
|
468
|
+
Model._attributeDefinitions = Model._createAttributeDefinitions();
|
|
484
469
|
//# sourceMappingURL=Model.js.map
|