sequential-workflow-designer 0.16.3 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.umd.js +189 -162
- package/lib/cjs/index.cjs +189 -162
- package/lib/esm/index.js +189 -162
- 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.5/css/designer.css" rel="stylesheet">
|
|
99
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.5/css/designer-light.css" rel="stylesheet">
|
|
100
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.5/css/designer-dark.css" rel="stylesheet">
|
|
101
|
+
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.5/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();
|
|
@@ -1093,7 +1012,7 @@
|
|
|
1093
1012
|
Dom.translate(circle, halfOfSize, halfOfSize);
|
|
1094
1013
|
g.appendChild(circle);
|
|
1095
1014
|
const icon = Icons.appendPath(g, 'sqd-validation-error-icon-path', Icons.alert, cfg.iconSize);
|
|
1096
|
-
const offsetX = (cfg.size - cfg.iconSize)
|
|
1015
|
+
const offsetX = (cfg.size - cfg.iconSize) / 2;
|
|
1097
1016
|
const offsetY = offsetX * 1.5;
|
|
1098
1017
|
Dom.translate(icon, offsetX, offsetY);
|
|
1099
1018
|
parent.appendChild(g);
|
|
@@ -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);
|
|
@@ -2574,6 +2587,9 @@
|
|
|
2574
2587
|
}
|
|
2575
2588
|
|
|
2576
2589
|
let lastGridPatternId = 0;
|
|
2590
|
+
const listenerOptions$1 = {
|
|
2591
|
+
passive: false
|
|
2592
|
+
};
|
|
2577
2593
|
class WorkspaceView {
|
|
2578
2594
|
static create(parent, componentContext) {
|
|
2579
2595
|
const patternId = 'sqd-grid-pattern-' + lastGridPatternId++;
|
|
@@ -2654,7 +2670,7 @@
|
|
|
2654
2670
|
const position = readTouchPosition(e);
|
|
2655
2671
|
handler(position, element, 0);
|
|
2656
2672
|
}
|
|
2657
|
-
},
|
|
2673
|
+
}, listenerOptions$1);
|
|
2658
2674
|
}
|
|
2659
2675
|
bindContextMenu(handler) {
|
|
2660
2676
|
this.canvas.addEventListener('contextmenu', e => {
|
|
@@ -2663,7 +2679,7 @@
|
|
|
2663
2679
|
}, false);
|
|
2664
2680
|
}
|
|
2665
2681
|
bindWheel(handler) {
|
|
2666
|
-
this.canvas.addEventListener('wheel', handler,
|
|
2682
|
+
this.canvas.addEventListener('wheel', handler, listenerOptions$1);
|
|
2667
2683
|
}
|
|
2668
2684
|
destroy() {
|
|
2669
2685
|
window.removeEventListener('resize', this.onResizeHandler, false);
|
|
@@ -3562,7 +3578,7 @@
|
|
|
3562
3578
|
parent.appendChild(root);
|
|
3563
3579
|
const view = new ScrollBoxView(root, viewport);
|
|
3564
3580
|
window.addEventListener('resize', view.onResize, false);
|
|
3565
|
-
root.addEventListener('wheel', e => view.onWheel(e),
|
|
3581
|
+
root.addEventListener('wheel', e => view.onWheel(e), listenerOptions);
|
|
3566
3582
|
root.addEventListener('touchstart', e => view.onTouchStart(e), listenerOptions);
|
|
3567
3583
|
root.addEventListener('mousedown', e => view.onMouseDown(e), false);
|
|
3568
3584
|
return view;
|
|
@@ -3626,6 +3642,7 @@
|
|
|
3626
3642
|
};
|
|
3627
3643
|
}
|
|
3628
3644
|
onWheel(e) {
|
|
3645
|
+
e.preventDefault();
|
|
3629
3646
|
e.stopPropagation();
|
|
3630
3647
|
if (this.content) {
|
|
3631
3648
|
const delta = e.deltaY > 0 ? -25 : 25;
|
|
@@ -4297,24 +4314,25 @@
|
|
|
4297
4314
|
const designerContext = DesignerContext.create(placeholder, startDefinition, config, services);
|
|
4298
4315
|
const designerApi = DesignerApi.create(designerContext);
|
|
4299
4316
|
const view = DesignerView.create(placeholder, designerContext, designerApi);
|
|
4300
|
-
const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerApi);
|
|
4317
|
+
const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
|
|
4301
4318
|
view.workspace.onReady.subscribe(() => designer.onReady.forward());
|
|
4302
4319
|
designerContext.state.onDefinitionChanged.subscribe(() => {
|
|
4303
4320
|
setTimeout(() => designer.onDefinitionChanged.forward(designerContext.state.definition));
|
|
4304
4321
|
});
|
|
4305
4322
|
designerContext.state.onSelectedStepIdChanged.subscribe(() => designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId));
|
|
4306
|
-
|
|
4323
|
+
designerContext.state.onIsToolboxCollapsedChanged.subscribe(isCollapsed => {
|
|
4307
4324
|
designer.onIsToolboxCollapsedChanged.forward(isCollapsed);
|
|
4308
4325
|
});
|
|
4309
|
-
|
|
4326
|
+
designerContext.state.onIsEditorCollapsedChanged.subscribe(isCollapsed => {
|
|
4310
4327
|
designer.onIsEditorCollapsedChanged.forward(isCollapsed);
|
|
4311
4328
|
});
|
|
4312
4329
|
return designer;
|
|
4313
4330
|
}
|
|
4314
|
-
constructor(view, state, walker, api) {
|
|
4331
|
+
constructor(view, state, walker, historyController, api) {
|
|
4315
4332
|
this.view = view;
|
|
4316
4333
|
this.state = state;
|
|
4317
4334
|
this.walker = walker;
|
|
4335
|
+
this.historyController = historyController;
|
|
4318
4336
|
this.api = api;
|
|
4319
4337
|
/**
|
|
4320
4338
|
* @description Fires when the designer is initialized and ready to use.
|
|
@@ -4427,6 +4445,15 @@
|
|
|
4427
4445
|
setIsEditorCollapsed(isCollapsed) {
|
|
4428
4446
|
this.state.setIsEditorCollapsed(isCollapsed);
|
|
4429
4447
|
}
|
|
4448
|
+
/**
|
|
4449
|
+
* @description Dump the undo stack.
|
|
4450
|
+
*/
|
|
4451
|
+
dumpUndoStack() {
|
|
4452
|
+
if (!this.historyController) {
|
|
4453
|
+
throw new Error('Undo feature is not activated');
|
|
4454
|
+
}
|
|
4455
|
+
return this.historyController.dump();
|
|
4456
|
+
}
|
|
4430
4457
|
/**
|
|
4431
4458
|
* @param needle A step, a sequence or a step id.
|
|
4432
4459
|
* @returns parent steps and branch names.
|