sequential-workflow-designer 0.16.2 → 0.16.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/README.md +5 -5
- package/dist/index.umd.js +181 -158
- package/lib/cjs/index.cjs +181 -158
- package/lib/esm/index.js +181 -158
- package/lib/index.d.ts +38 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,12 +27,12 @@ Features:
|
|
|
27
27
|
* [🔴 Particles](https://nocode-js.github.io/sequential-workflow-designer/examples/particles.html)
|
|
28
28
|
* [⛅ Light Dark](https://nocode-js.github.io/sequential-workflow-designer/examples/light-dark.html)
|
|
29
29
|
* [🤖 Code Generator](https://nocode-js.github.io/sequential-workflow-designer/examples/code-generator.html)
|
|
30
|
-
* [📐 Simple Flow](https://nocode-js.github.io/sequential-workflow-designer/examples/simple-flow.html)
|
|
31
30
|
* [🌻 Rendering Test](https://nocode-js.github.io/sequential-workflow-designer/examples/rendering-test.html)
|
|
32
31
|
* [🚄 Stress Test](https://nocode-js.github.io/sequential-workflow-designer/examples/stress-test.html)
|
|
33
32
|
* [🚪 Editing Restrictions](https://nocode-js.github.io/sequential-workflow-designer/examples/editing-restrictions.html)
|
|
34
33
|
* [📜 Scrollable Page](https://nocode-js.github.io/sequential-workflow-designer/examples/scrollable-page.html)
|
|
35
34
|
* [🌵 Multi-Conditional Switch](https://nocode-js.github.io/sequential-workflow-designer/examples/multi-conditional-switch.html)
|
|
35
|
+
* [🌀 Auto-Select](https://nocode-js.github.io/sequential-workflow-designer/examples/auto-select.html)
|
|
36
36
|
* [React Demo](https://nocode-js.github.io/sequential-workflow-designer/react-app/)
|
|
37
37
|
* [Angular Demo](https://nocode-js.github.io/sequential-workflow-designer/angular-app/)
|
|
38
38
|
|
|
@@ -95,10 +95,10 @@ Add the below code to your head section in HTML document.
|
|
|
95
95
|
```html
|
|
96
96
|
<head>
|
|
97
97
|
...
|
|
98
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.
|
|
99
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.
|
|
100
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.
|
|
101
|
-
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.
|
|
98
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.4/css/designer.css" rel="stylesheet">
|
|
99
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.4/css/designer-light.css" rel="stylesheet">
|
|
100
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.4/css/designer-dark.css" rel="stylesheet">
|
|
101
|
+
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.4/dist/index.umd.js"></script>
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
Call the designer by:
|
package/dist/index.umd.js
CHANGED
|
@@ -76,57 +76,6 @@
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
class SimpleEvent {
|
|
80
|
-
constructor() {
|
|
81
|
-
this.listeners = [];
|
|
82
|
-
}
|
|
83
|
-
subscribe(listener) {
|
|
84
|
-
this.listeners.push(listener);
|
|
85
|
-
}
|
|
86
|
-
unsubscribe(listener) {
|
|
87
|
-
const index = this.listeners.indexOf(listener);
|
|
88
|
-
if (index >= 0) {
|
|
89
|
-
this.listeners.splice(index, 1);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
throw new Error('Unknown listener');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
forward(value) {
|
|
96
|
-
if (this.listeners.length > 0) {
|
|
97
|
-
this.listeners.forEach(listener => listener(value));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
count() {
|
|
101
|
-
return this.listeners.length;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
class Vector {
|
|
106
|
-
constructor(x, y) {
|
|
107
|
-
this.x = x;
|
|
108
|
-
this.y = y;
|
|
109
|
-
}
|
|
110
|
-
add(v) {
|
|
111
|
-
return new Vector(this.x + v.x, this.y + v.y);
|
|
112
|
-
}
|
|
113
|
-
subtract(v) {
|
|
114
|
-
return new Vector(this.x - v.x, this.y - v.y);
|
|
115
|
-
}
|
|
116
|
-
multiplyByScalar(s) {
|
|
117
|
-
return new Vector(this.x * s, this.y * s);
|
|
118
|
-
}
|
|
119
|
-
divideByScalar(s) {
|
|
120
|
-
return new Vector(this.x / s, this.y / s);
|
|
121
|
-
}
|
|
122
|
-
round() {
|
|
123
|
-
return new Vector(Math.round(this.x), Math.round(this.y));
|
|
124
|
-
}
|
|
125
|
-
distance() {
|
|
126
|
-
return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
79
|
exports.DefinitionChangeType = void 0;
|
|
131
80
|
(function (DefinitionChangeType) {
|
|
132
81
|
DefinitionChangeType[DefinitionChangeType["stepNameChanged"] = 1] = "stepNameChanged";
|
|
@@ -137,88 +86,7 @@
|
|
|
137
86
|
DefinitionChangeType[DefinitionChangeType["stepInserted"] = 6] = "stepInserted";
|
|
138
87
|
DefinitionChangeType[DefinitionChangeType["globalPropertyChanged"] = 7] = "globalPropertyChanged";
|
|
139
88
|
DefinitionChangeType[DefinitionChangeType["rootReplaced"] = 8] = "rootReplaced";
|
|
140
|
-
})(exports.DefinitionChangeType || (exports.DefinitionChangeType = {}));
|
|
141
|
-
class DesignerState {
|
|
142
|
-
constructor(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed) {
|
|
143
|
-
this.definition = definition;
|
|
144
|
-
this.isReadonly = isReadonly;
|
|
145
|
-
this.isToolboxCollapsed = isToolboxCollapsed;
|
|
146
|
-
this.isEditorCollapsed = isEditorCollapsed;
|
|
147
|
-
this.onViewportChanged = new SimpleEvent();
|
|
148
|
-
this.onSelectedStepIdChanged = new SimpleEvent();
|
|
149
|
-
this.onFolderPathChanged = new SimpleEvent();
|
|
150
|
-
this.onIsReadonlyChanged = new SimpleEvent();
|
|
151
|
-
this.onIsDraggingChanged = new SimpleEvent();
|
|
152
|
-
this.onIsDragDisabledChanged = new SimpleEvent();
|
|
153
|
-
this.onDefinitionChanged = new SimpleEvent();
|
|
154
|
-
this.onIsToolboxCollapsedChanged = new SimpleEvent();
|
|
155
|
-
this.onIsEditorCollapsedChanged = new SimpleEvent();
|
|
156
|
-
this.viewport = {
|
|
157
|
-
position: new Vector(0, 0),
|
|
158
|
-
scale: 1
|
|
159
|
-
};
|
|
160
|
-
this.selectedStepId = null;
|
|
161
|
-
this.folderPath = [];
|
|
162
|
-
this.isDragging = false;
|
|
163
|
-
this.isDragDisabled = false;
|
|
164
|
-
}
|
|
165
|
-
setSelectedStepId(stepId) {
|
|
166
|
-
if (this.selectedStepId !== stepId) {
|
|
167
|
-
this.selectedStepId = stepId;
|
|
168
|
-
this.onSelectedStepIdChanged.forward(stepId);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
pushStepIdToFolderPath(stepId) {
|
|
172
|
-
this.folderPath.push(stepId);
|
|
173
|
-
this.onFolderPathChanged.forward(this.folderPath);
|
|
174
|
-
}
|
|
175
|
-
setFolderPath(path) {
|
|
176
|
-
this.folderPath = path;
|
|
177
|
-
this.onFolderPathChanged.forward(path);
|
|
178
|
-
}
|
|
179
|
-
tryGetLastStepIdFromFolderPath() {
|
|
180
|
-
return this.folderPath.length > 0 ? this.folderPath[this.folderPath.length - 1] : null;
|
|
181
|
-
}
|
|
182
|
-
setDefinition(definition) {
|
|
183
|
-
this.definition = definition;
|
|
184
|
-
this.notifyDefinitionChanged(exports.DefinitionChangeType.rootReplaced, null);
|
|
185
|
-
}
|
|
186
|
-
notifyDefinitionChanged(changeType, stepId) {
|
|
187
|
-
this.onDefinitionChanged.forward({ changeType, stepId });
|
|
188
|
-
}
|
|
189
|
-
setViewport(viewport) {
|
|
190
|
-
this.viewport = viewport;
|
|
191
|
-
this.onViewportChanged.forward(viewport);
|
|
192
|
-
}
|
|
193
|
-
setIsReadonly(isReadonly) {
|
|
194
|
-
if (this.isReadonly !== isReadonly) {
|
|
195
|
-
this.isReadonly = isReadonly;
|
|
196
|
-
this.onIsReadonlyChanged.forward(isReadonly);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
setIsDragging(isDragging) {
|
|
200
|
-
if (this.isDragging !== isDragging) {
|
|
201
|
-
this.isDragging = isDragging;
|
|
202
|
-
this.onIsDraggingChanged.forward(isDragging);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
toggleIsDragDisabled() {
|
|
206
|
-
this.isDragDisabled = !this.isDragDisabled;
|
|
207
|
-
this.onIsDragDisabledChanged.forward(this.isDragDisabled);
|
|
208
|
-
}
|
|
209
|
-
setIsToolboxCollapsed(isCollapsed) {
|
|
210
|
-
if (this.isToolboxCollapsed !== isCollapsed) {
|
|
211
|
-
this.isToolboxCollapsed = isCollapsed;
|
|
212
|
-
this.onIsToolboxCollapsedChanged.forward(isCollapsed);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
setIsEditorCollapsed(isCollapsed) {
|
|
216
|
-
if (this.isEditorCollapsed !== isCollapsed) {
|
|
217
|
-
this.isEditorCollapsed = isCollapsed;
|
|
218
|
-
this.onIsEditorCollapsedChanged.forward(isCollapsed);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
89
|
+
})(exports.DefinitionChangeType || (exports.DefinitionChangeType = {}));
|
|
222
90
|
|
|
223
91
|
class Dom {
|
|
224
92
|
static svg(name, attributes) {
|
|
@@ -308,6 +176,31 @@
|
|
|
308
176
|
}
|
|
309
177
|
}
|
|
310
178
|
|
|
179
|
+
class Vector {
|
|
180
|
+
constructor(x, y) {
|
|
181
|
+
this.x = x;
|
|
182
|
+
this.y = y;
|
|
183
|
+
}
|
|
184
|
+
add(v) {
|
|
185
|
+
return new Vector(this.x + v.x, this.y + v.y);
|
|
186
|
+
}
|
|
187
|
+
subtract(v) {
|
|
188
|
+
return new Vector(this.x - v.x, this.y - v.y);
|
|
189
|
+
}
|
|
190
|
+
multiplyByScalar(s) {
|
|
191
|
+
return new Vector(this.x * s, this.y * s);
|
|
192
|
+
}
|
|
193
|
+
divideByScalar(s) {
|
|
194
|
+
return new Vector(this.x / s, this.y / s);
|
|
195
|
+
}
|
|
196
|
+
round() {
|
|
197
|
+
return new Vector(Math.round(this.x), Math.round(this.y));
|
|
198
|
+
}
|
|
199
|
+
distance() {
|
|
200
|
+
return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
311
204
|
class Uid {
|
|
312
205
|
static next() {
|
|
313
206
|
const bytes = new Uint8Array(16);
|
|
@@ -316,6 +209,32 @@
|
|
|
316
209
|
}
|
|
317
210
|
}
|
|
318
211
|
|
|
212
|
+
class SimpleEvent {
|
|
213
|
+
constructor() {
|
|
214
|
+
this.listeners = [];
|
|
215
|
+
}
|
|
216
|
+
subscribe(listener) {
|
|
217
|
+
this.listeners.push(listener);
|
|
218
|
+
}
|
|
219
|
+
unsubscribe(listener) {
|
|
220
|
+
const index = this.listeners.indexOf(listener);
|
|
221
|
+
if (index >= 0) {
|
|
222
|
+
this.listeners.splice(index, 1);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
throw new Error('Unknown listener');
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
forward(value) {
|
|
229
|
+
if (this.listeners.length > 0) {
|
|
230
|
+
this.listeners.forEach(listener => listener(value));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
count() {
|
|
234
|
+
return this.listeners.length;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
319
238
|
function race(timeout, a, b, c) {
|
|
320
239
|
const value = [undefined, undefined, undefined];
|
|
321
240
|
const result = new SimpleEvent();
|
|
@@ -2357,7 +2276,9 @@
|
|
|
2357
2276
|
}
|
|
2358
2277
|
SequenceModifier.insertStep(step, targetSequence, targetIndex);
|
|
2359
2278
|
this.state.notifyDefinitionChanged(exports.DefinitionChangeType.stepInserted, step.id);
|
|
2360
|
-
this.
|
|
2279
|
+
if (!this.configuration.steps.isAutoSelectDisabled) {
|
|
2280
|
+
this.state.setSelectedStepId(step.id);
|
|
2281
|
+
}
|
|
2361
2282
|
return true;
|
|
2362
2283
|
}
|
|
2363
2284
|
isDraggable(step, parentSequence) {
|
|
@@ -2376,7 +2297,9 @@
|
|
|
2376
2297
|
}
|
|
2377
2298
|
apply();
|
|
2378
2299
|
this.state.notifyDefinitionChanged(exports.DefinitionChangeType.stepMoved, step.id);
|
|
2379
|
-
this.
|
|
2300
|
+
if (!this.configuration.steps.isAutoSelectDisabled) {
|
|
2301
|
+
this.state.setSelectedStepId(step.id);
|
|
2302
|
+
}
|
|
2380
2303
|
return true;
|
|
2381
2304
|
}
|
|
2382
2305
|
isDuplicable(step, parentSequence) {
|
|
@@ -2417,13 +2340,101 @@
|
|
|
2417
2340
|
}
|
|
2418
2341
|
}
|
|
2419
2342
|
|
|
2343
|
+
class DesignerState {
|
|
2344
|
+
constructor(definition, isReadonly, isToolboxCollapsed, isEditorCollapsed) {
|
|
2345
|
+
this.definition = definition;
|
|
2346
|
+
this.isReadonly = isReadonly;
|
|
2347
|
+
this.isToolboxCollapsed = isToolboxCollapsed;
|
|
2348
|
+
this.isEditorCollapsed = isEditorCollapsed;
|
|
2349
|
+
this.onViewportChanged = new SimpleEvent();
|
|
2350
|
+
this.onSelectedStepIdChanged = new SimpleEvent();
|
|
2351
|
+
this.onFolderPathChanged = new SimpleEvent();
|
|
2352
|
+
this.onIsReadonlyChanged = new SimpleEvent();
|
|
2353
|
+
this.onIsDraggingChanged = new SimpleEvent();
|
|
2354
|
+
this.onIsDragDisabledChanged = new SimpleEvent();
|
|
2355
|
+
this.onDefinitionChanged = new SimpleEvent();
|
|
2356
|
+
this.onIsToolboxCollapsedChanged = new SimpleEvent();
|
|
2357
|
+
this.onIsEditorCollapsedChanged = new SimpleEvent();
|
|
2358
|
+
this.viewport = {
|
|
2359
|
+
position: new Vector(0, 0),
|
|
2360
|
+
scale: 1
|
|
2361
|
+
};
|
|
2362
|
+
this.selectedStepId = null;
|
|
2363
|
+
this.folderPath = [];
|
|
2364
|
+
this.isDragging = false;
|
|
2365
|
+
this.isDragDisabled = false;
|
|
2366
|
+
}
|
|
2367
|
+
setSelectedStepId(stepId) {
|
|
2368
|
+
if (this.selectedStepId !== stepId) {
|
|
2369
|
+
this.selectedStepId = stepId;
|
|
2370
|
+
this.onSelectedStepIdChanged.forward(stepId);
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
pushStepIdToFolderPath(stepId) {
|
|
2374
|
+
this.folderPath.push(stepId);
|
|
2375
|
+
this.onFolderPathChanged.forward(this.folderPath);
|
|
2376
|
+
}
|
|
2377
|
+
setFolderPath(path) {
|
|
2378
|
+
this.folderPath = path;
|
|
2379
|
+
this.onFolderPathChanged.forward(path);
|
|
2380
|
+
}
|
|
2381
|
+
tryGetLastStepIdFromFolderPath() {
|
|
2382
|
+
return this.folderPath.length > 0 ? this.folderPath[this.folderPath.length - 1] : null;
|
|
2383
|
+
}
|
|
2384
|
+
setDefinition(definition) {
|
|
2385
|
+
this.definition = definition;
|
|
2386
|
+
this.notifyDefinitionChanged(exports.DefinitionChangeType.rootReplaced, null);
|
|
2387
|
+
}
|
|
2388
|
+
notifyDefinitionChanged(changeType, stepId) {
|
|
2389
|
+
this.onDefinitionChanged.forward({ changeType, stepId });
|
|
2390
|
+
}
|
|
2391
|
+
setViewport(viewport) {
|
|
2392
|
+
this.viewport = viewport;
|
|
2393
|
+
this.onViewportChanged.forward(viewport);
|
|
2394
|
+
}
|
|
2395
|
+
setIsReadonly(isReadonly) {
|
|
2396
|
+
if (this.isReadonly !== isReadonly) {
|
|
2397
|
+
this.isReadonly = isReadonly;
|
|
2398
|
+
this.onIsReadonlyChanged.forward(isReadonly);
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
setIsDragging(isDragging) {
|
|
2402
|
+
if (this.isDragging !== isDragging) {
|
|
2403
|
+
this.isDragging = isDragging;
|
|
2404
|
+
this.onIsDraggingChanged.forward(isDragging);
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
toggleIsDragDisabled() {
|
|
2408
|
+
this.isDragDisabled = !this.isDragDisabled;
|
|
2409
|
+
this.onIsDragDisabledChanged.forward(this.isDragDisabled);
|
|
2410
|
+
}
|
|
2411
|
+
setIsToolboxCollapsed(isCollapsed) {
|
|
2412
|
+
if (this.isToolboxCollapsed !== isCollapsed) {
|
|
2413
|
+
this.isToolboxCollapsed = isCollapsed;
|
|
2414
|
+
this.onIsToolboxCollapsedChanged.forward(isCollapsed);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
setIsEditorCollapsed(isCollapsed) {
|
|
2418
|
+
if (this.isEditorCollapsed !== isCollapsed) {
|
|
2419
|
+
this.isEditorCollapsed = isCollapsed;
|
|
2420
|
+
this.onIsEditorCollapsedChanged.forward(isCollapsed);
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2420
2425
|
class HistoryController {
|
|
2421
|
-
static create(state, definitionModifier, configuration) {
|
|
2426
|
+
static create(initialStack, state, definitionModifier, configuration) {
|
|
2422
2427
|
if (!configuration.undoStackSize || configuration.undoStackSize < 1) {
|
|
2423
2428
|
throw new Error('Invalid undo stack size');
|
|
2424
2429
|
}
|
|
2425
|
-
const
|
|
2426
|
-
|
|
2430
|
+
const stack = initialStack || {
|
|
2431
|
+
index: 0,
|
|
2432
|
+
items: []
|
|
2433
|
+
};
|
|
2434
|
+
const controller = new HistoryController(stack, state, definitionModifier, configuration.undoStackSize);
|
|
2435
|
+
if (!initialStack) {
|
|
2436
|
+
controller.remember(exports.DefinitionChangeType.rootReplaced, null);
|
|
2437
|
+
}
|
|
2427
2438
|
state.onDefinitionChanged.subscribe(event => {
|
|
2428
2439
|
if (event.changeType !== exports.DefinitionChangeType.rootReplaced) {
|
|
2429
2440
|
controller.remember(event.changeType, event.stepId);
|
|
@@ -2431,49 +2442,51 @@
|
|
|
2431
2442
|
});
|
|
2432
2443
|
return controller;
|
|
2433
2444
|
}
|
|
2434
|
-
constructor(state, definitionModifier, stackSize) {
|
|
2445
|
+
constructor(stack, state, definitionModifier, stackSize) {
|
|
2446
|
+
this.stack = stack;
|
|
2435
2447
|
this.state = state;
|
|
2436
2448
|
this.definitionModifier = definitionModifier;
|
|
2437
2449
|
this.stackSize = stackSize;
|
|
2438
|
-
this.stack = [];
|
|
2439
|
-
this.currentIndex = 0;
|
|
2440
2450
|
}
|
|
2441
2451
|
canUndo() {
|
|
2442
|
-
return this.
|
|
2452
|
+
return this.stack.index > 1;
|
|
2443
2453
|
}
|
|
2444
2454
|
undo() {
|
|
2445
|
-
this.
|
|
2455
|
+
this.stack.index--;
|
|
2446
2456
|
this.commit();
|
|
2447
2457
|
}
|
|
2448
2458
|
canRedo() {
|
|
2449
|
-
return this.
|
|
2459
|
+
return this.stack.index < this.stack.items.length;
|
|
2450
2460
|
}
|
|
2451
2461
|
redo() {
|
|
2452
|
-
this.
|
|
2462
|
+
this.stack.index++;
|
|
2453
2463
|
this.commit();
|
|
2454
2464
|
}
|
|
2465
|
+
dump() {
|
|
2466
|
+
return Object.assign({}, this.stack);
|
|
2467
|
+
}
|
|
2455
2468
|
remember(changeType, stepId) {
|
|
2456
2469
|
const definition = ObjectCloner.deepClone(this.state.definition);
|
|
2457
|
-
if (this.stack.length > 0 && this.
|
|
2458
|
-
const lastItem = this.stack[this.stack.length - 1];
|
|
2470
|
+
if (this.stack.items.length > 0 && this.stack.index === this.stack.items.length) {
|
|
2471
|
+
const lastItem = this.stack.items[this.stack.items.length - 1];
|
|
2459
2472
|
if (areItemsEqual(lastItem, changeType, stepId)) {
|
|
2460
2473
|
lastItem.definition = definition;
|
|
2461
2474
|
return;
|
|
2462
2475
|
}
|
|
2463
2476
|
}
|
|
2464
|
-
this.stack.splice(this.
|
|
2465
|
-
this.stack.push({
|
|
2477
|
+
this.stack.items.splice(this.stack.index);
|
|
2478
|
+
this.stack.items.push({
|
|
2466
2479
|
definition,
|
|
2467
2480
|
changeType,
|
|
2468
2481
|
stepId
|
|
2469
2482
|
});
|
|
2470
|
-
if (this.stack.length > this.stackSize) {
|
|
2471
|
-
this.stack.splice(0, this.stack.length - this.stackSize - 1);
|
|
2483
|
+
if (this.stack.items.length > this.stackSize) {
|
|
2484
|
+
this.stack.items.splice(0, this.stack.items.length - this.stackSize - 1);
|
|
2472
2485
|
}
|
|
2473
|
-
this.
|
|
2486
|
+
this.stack.index = this.stack.items.length;
|
|
2474
2487
|
}
|
|
2475
2488
|
commit() {
|
|
2476
|
-
const definition = ObjectCloner.deepClone(this.stack[this.
|
|
2489
|
+
const definition = ObjectCloner.deepClone(this.stack.items[this.stack.index - 1].definition);
|
|
2477
2490
|
this.definitionModifier.replaceDefinition(definition);
|
|
2478
2491
|
}
|
|
2479
2492
|
}
|
|
@@ -2546,7 +2559,7 @@
|
|
|
2546
2559
|
const definitionModifier = new DefinitionModifier(definitionWalker, state, configuration);
|
|
2547
2560
|
let historyController = undefined;
|
|
2548
2561
|
if (configuration.undoStackSize) {
|
|
2549
|
-
historyController = HistoryController.create(state, definitionModifier, configuration);
|
|
2562
|
+
historyController = HistoryController.create(configuration.undoStack, state, definitionModifier, configuration);
|
|
2550
2563
|
}
|
|
2551
2564
|
const componentContext = ComponentContext.create(configuration.steps, configuration.validator, state, stepExtensionResolver, services);
|
|
2552
2565
|
return new DesignerContext(theme, state, configuration, services, componentContext, definitionWalker, definitionModifier, layoutController, workspaceController, behaviorController, historyController);
|
|
@@ -4297,24 +4310,25 @@
|
|
|
4297
4310
|
const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
|
|
4298
4311
|
const designerApi = DesignerApi.create(designerContext);
|
|
4299
4312
|
const view = DesignerView.create(placeholder, designerContext, designerApi);
|
|
4300
|
-
const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerApi);
|
|
4313
|
+
const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
|
|
4301
4314
|
view.workspace.onReady.subscribe(() => designer.onReady.forward());
|
|
4302
4315
|
designerContext.state.onDefinitionChanged.subscribe(() => {
|
|
4303
4316
|
setTimeout(() => designer.onDefinitionChanged.forward(designerContext.state.definition));
|
|
4304
4317
|
});
|
|
4305
4318
|
designerContext.state.onSelectedStepIdChanged.subscribe(() => designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId));
|
|
4306
|
-
|
|
4319
|
+
designerContext.state.onIsToolboxCollapsedChanged.subscribe(isCollapsed => {
|
|
4307
4320
|
designer.onIsToolboxCollapsedChanged.forward(isCollapsed);
|
|
4308
4321
|
});
|
|
4309
|
-
|
|
4322
|
+
designerContext.state.onIsEditorCollapsedChanged.subscribe(isCollapsed => {
|
|
4310
4323
|
designer.onIsEditorCollapsedChanged.forward(isCollapsed);
|
|
4311
4324
|
});
|
|
4312
4325
|
return designer;
|
|
4313
4326
|
}
|
|
4314
|
-
constructor(view, state, walker, api) {
|
|
4327
|
+
constructor(view, state, walker, historyController, api) {
|
|
4315
4328
|
this.view = view;
|
|
4316
4329
|
this.state = state;
|
|
4317
4330
|
this.walker = walker;
|
|
4331
|
+
this.historyController = historyController;
|
|
4318
4332
|
this.api = api;
|
|
4319
4333
|
/**
|
|
4320
4334
|
* @description Fires when the designer is initialized and ready to use.
|
|
@@ -4427,6 +4441,15 @@
|
|
|
4427
4441
|
setIsEditorCollapsed(isCollapsed) {
|
|
4428
4442
|
this.state.setIsEditorCollapsed(isCollapsed);
|
|
4429
4443
|
}
|
|
4444
|
+
/**
|
|
4445
|
+
* @description Dump the undo stack.
|
|
4446
|
+
*/
|
|
4447
|
+
dumpUndoStack() {
|
|
4448
|
+
if (!this.historyController) {
|
|
4449
|
+
throw new Error('Undo feature is not activated');
|
|
4450
|
+
}
|
|
4451
|
+
return this.historyController.dump();
|
|
4452
|
+
}
|
|
4430
4453
|
/**
|
|
4431
4454
|
* @param needle A step, a sequence or a step id.
|
|
4432
4455
|
* @returns parent steps and branch names.
|