sequential-workflow-designer 0.16.8 → 0.16.10
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 +4 -4
- package/dist/index.umd.js +75 -24
- package/lib/cjs/index.cjs +75 -24
- package/lib/esm/index.js +76 -25
- package/lib/index.d.ts +28 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,10 +96,10 @@ Add the below code to your head section in HTML document.
|
|
|
96
96
|
```html
|
|
97
97
|
<head>
|
|
98
98
|
...
|
|
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
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.
|
|
102
|
-
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.
|
|
99
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.10/css/designer.css" rel="stylesheet">
|
|
100
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.10/css/designer-light.css" rel="stylesheet">
|
|
101
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.10/css/designer-dark.css" rel="stylesheet">
|
|
102
|
+
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.16.10/dist/index.umd.js"></script>
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
Call the designer by:
|
package/dist/index.umd.js
CHANGED
|
@@ -76,6 +76,10 @@
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
exports.KeyboardAction = void 0;
|
|
80
|
+
(function (KeyboardAction) {
|
|
81
|
+
KeyboardAction["delete"] = "delete";
|
|
82
|
+
})(exports.KeyboardAction || (exports.KeyboardAction = {}));
|
|
79
83
|
exports.DefinitionChangeType = void 0;
|
|
80
84
|
(function (DefinitionChangeType) {
|
|
81
85
|
DefinitionChangeType[DefinitionChangeType["stepNameChanged"] = 1] = "stepNameChanged";
|
|
@@ -267,27 +271,29 @@
|
|
|
267
271
|
|
|
268
272
|
class EditorRenderer {
|
|
269
273
|
static create(state, definitionWalker, handler) {
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
if (definitionChanged) {
|
|
274
|
-
listener.onDefinitionChanged(definitionChanged);
|
|
275
|
-
}
|
|
276
|
-
else if (selectedStepId !== undefined) {
|
|
277
|
-
listener.onSelectedStepIdChanged(selectedStepId);
|
|
278
|
-
}
|
|
279
|
-
});
|
|
274
|
+
const raceEvent = race(0, state.onDefinitionChanged, state.onSelectedStepIdChanged);
|
|
275
|
+
const listener = new EditorRenderer(state, definitionWalker, handler, raceEvent);
|
|
276
|
+
raceEvent.subscribe(listener.raceEventHandler);
|
|
280
277
|
listener.tryRender(state.selectedStepId);
|
|
281
278
|
return listener;
|
|
282
279
|
}
|
|
283
|
-
constructor(state, definitionWalker, handler) {
|
|
280
|
+
constructor(state, definitionWalker, handler, raceEvent) {
|
|
284
281
|
this.state = state;
|
|
285
282
|
this.definitionWalker = definitionWalker;
|
|
286
283
|
this.handler = handler;
|
|
284
|
+
this.raceEvent = raceEvent;
|
|
287
285
|
this.currentStepId = undefined;
|
|
286
|
+
this.raceEventHandler = ([definitionChanged, selectedStepId]) => {
|
|
287
|
+
if (definitionChanged) {
|
|
288
|
+
this.onDefinitionChanged(definitionChanged);
|
|
289
|
+
}
|
|
290
|
+
else if (selectedStepId !== undefined) {
|
|
291
|
+
this.onSelectedStepIdChanged(selectedStepId);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
288
294
|
}
|
|
289
295
|
destroy() {
|
|
290
|
-
|
|
296
|
+
this.raceEvent.unsubscribe(this.raceEventHandler);
|
|
291
297
|
}
|
|
292
298
|
render(stepId) {
|
|
293
299
|
const step = stepId ? this.definitionWalker.getById(this.state.definition, stepId) : null;
|
|
@@ -3451,23 +3457,27 @@
|
|
|
3451
3457
|
}
|
|
3452
3458
|
}
|
|
3453
3459
|
|
|
3454
|
-
const
|
|
3455
|
-
const ignoreTagNames = ['INPUT', 'TEXTAREA'];
|
|
3460
|
+
const ignoreTagNames = ['INPUT', 'TEXTAREA', 'SELECT'];
|
|
3456
3461
|
class KeyboardDaemon {
|
|
3457
|
-
static create(api) {
|
|
3458
|
-
const controller = new KeyboardDaemon(api.controlBar);
|
|
3462
|
+
static create(api, configuration) {
|
|
3463
|
+
const controller = new KeyboardDaemon(api.controlBar, configuration);
|
|
3459
3464
|
document.addEventListener('keyup', controller.onKeyUp, false);
|
|
3460
3465
|
return controller;
|
|
3461
3466
|
}
|
|
3462
|
-
constructor(controlBarApi) {
|
|
3467
|
+
constructor(controlBarApi, configuration) {
|
|
3463
3468
|
this.controlBarApi = controlBarApi;
|
|
3469
|
+
this.configuration = configuration;
|
|
3464
3470
|
this.onKeyUp = (e) => {
|
|
3465
|
-
|
|
3471
|
+
const action = detectAction(e);
|
|
3472
|
+
if (!action) {
|
|
3466
3473
|
return;
|
|
3467
3474
|
}
|
|
3468
3475
|
if (document.activeElement && ignoreTagNames.includes(document.activeElement.tagName)) {
|
|
3469
3476
|
return;
|
|
3470
3477
|
}
|
|
3478
|
+
if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, e)) {
|
|
3479
|
+
return;
|
|
3480
|
+
}
|
|
3471
3481
|
const isDeletable = this.controlBarApi.canDelete();
|
|
3472
3482
|
if (isDeletable) {
|
|
3473
3483
|
e.preventDefault();
|
|
@@ -3479,11 +3489,26 @@
|
|
|
3479
3489
|
destroy() {
|
|
3480
3490
|
document.removeEventListener('keyup', this.onKeyUp, false);
|
|
3481
3491
|
}
|
|
3492
|
+
}
|
|
3493
|
+
function detectAction(e) {
|
|
3494
|
+
if (e.key === 'Backspace' || e.key === 'Delete') {
|
|
3495
|
+
return exports.KeyboardAction.delete;
|
|
3496
|
+
}
|
|
3497
|
+
return null;
|
|
3482
3498
|
}
|
|
3483
3499
|
|
|
3484
3500
|
class KeyboardDaemonExtension {
|
|
3485
|
-
|
|
3486
|
-
|
|
3501
|
+
static create(configuration) {
|
|
3502
|
+
if (configuration === undefined || configuration === true) {
|
|
3503
|
+
configuration = {};
|
|
3504
|
+
}
|
|
3505
|
+
return new KeyboardDaemonExtension(configuration);
|
|
3506
|
+
}
|
|
3507
|
+
constructor(configuration) {
|
|
3508
|
+
this.configuration = configuration;
|
|
3509
|
+
}
|
|
3510
|
+
create(api) {
|
|
3511
|
+
return KeyboardDaemon.create(api, this.configuration);
|
|
3487
3512
|
}
|
|
3488
3513
|
}
|
|
3489
3514
|
|
|
@@ -4263,7 +4288,9 @@
|
|
|
4263
4288
|
if (!services.daemons) {
|
|
4264
4289
|
services.daemons = [];
|
|
4265
4290
|
}
|
|
4266
|
-
|
|
4291
|
+
if (configuration.keyboard === undefined || configuration.keyboard) {
|
|
4292
|
+
services.daemons.push(KeyboardDaemonExtension.create(configuration.keyboard));
|
|
4293
|
+
}
|
|
4267
4294
|
}
|
|
4268
4295
|
|
|
4269
4296
|
function throwDepreciatedError(propertyName, groupName) {
|
|
@@ -4316,10 +4343,17 @@
|
|
|
4316
4343
|
const view = DesignerView.create(placeholder, designerContext, designerApi);
|
|
4317
4344
|
const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
|
|
4318
4345
|
view.workspace.onReady.subscribe(() => designer.onReady.forward());
|
|
4319
|
-
designerContext.state.onDefinitionChanged.subscribe(() => {
|
|
4320
|
-
|
|
4346
|
+
race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
|
|
4347
|
+
if (definition !== undefined) {
|
|
4348
|
+
designer.onDefinitionChanged.forward(designerContext.state.definition);
|
|
4349
|
+
}
|
|
4350
|
+
if (selectedStepId !== undefined) {
|
|
4351
|
+
designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
|
|
4352
|
+
}
|
|
4353
|
+
});
|
|
4354
|
+
designerContext.state.onViewportChanged.subscribe(viewPort => {
|
|
4355
|
+
designer.onViewportChanged.forward(viewPort);
|
|
4321
4356
|
});
|
|
4322
|
-
designerContext.state.onSelectedStepIdChanged.subscribe(() => designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId));
|
|
4323
4357
|
designerContext.state.onIsToolboxCollapsedChanged.subscribe(isCollapsed => {
|
|
4324
4358
|
designer.onIsToolboxCollapsedChanged.forward(isCollapsed);
|
|
4325
4359
|
});
|
|
@@ -4342,6 +4376,10 @@
|
|
|
4342
4376
|
* @description Fires when the definition has changed.
|
|
4343
4377
|
*/
|
|
4344
4378
|
this.onDefinitionChanged = new SimpleEvent();
|
|
4379
|
+
/**
|
|
4380
|
+
* @description Fires when the viewport has changed.
|
|
4381
|
+
*/
|
|
4382
|
+
this.onViewportChanged = new SimpleEvent();
|
|
4345
4383
|
/**
|
|
4346
4384
|
* @description Fires when the selected step has changed.
|
|
4347
4385
|
*/
|
|
@@ -4391,6 +4429,19 @@
|
|
|
4391
4429
|
selectStepById(stepId) {
|
|
4392
4430
|
this.state.setSelectedStepId(stepId);
|
|
4393
4431
|
}
|
|
4432
|
+
/**
|
|
4433
|
+
* @returns the current viewport.
|
|
4434
|
+
*/
|
|
4435
|
+
getViewport() {
|
|
4436
|
+
return this.state.viewport;
|
|
4437
|
+
}
|
|
4438
|
+
/**
|
|
4439
|
+
* @description Sets the viewport.
|
|
4440
|
+
* @param viewport Viewport.
|
|
4441
|
+
*/
|
|
4442
|
+
setViewport(viewport) {
|
|
4443
|
+
this.state.setViewport(viewport);
|
|
4444
|
+
}
|
|
4394
4445
|
/**
|
|
4395
4446
|
* @description Unselects the selected step.
|
|
4396
4447
|
*/
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -74,6 +74,10 @@ class ControlBarApi {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
exports.KeyboardAction = void 0;
|
|
78
|
+
(function (KeyboardAction) {
|
|
79
|
+
KeyboardAction["delete"] = "delete";
|
|
80
|
+
})(exports.KeyboardAction || (exports.KeyboardAction = {}));
|
|
77
81
|
exports.DefinitionChangeType = void 0;
|
|
78
82
|
(function (DefinitionChangeType) {
|
|
79
83
|
DefinitionChangeType[DefinitionChangeType["stepNameChanged"] = 1] = "stepNameChanged";
|
|
@@ -265,27 +269,29 @@ function race(timeout, a, b, c) {
|
|
|
265
269
|
|
|
266
270
|
class EditorRenderer {
|
|
267
271
|
static create(state, definitionWalker, handler) {
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if (definitionChanged) {
|
|
272
|
-
listener.onDefinitionChanged(definitionChanged);
|
|
273
|
-
}
|
|
274
|
-
else if (selectedStepId !== undefined) {
|
|
275
|
-
listener.onSelectedStepIdChanged(selectedStepId);
|
|
276
|
-
}
|
|
277
|
-
});
|
|
272
|
+
const raceEvent = race(0, state.onDefinitionChanged, state.onSelectedStepIdChanged);
|
|
273
|
+
const listener = new EditorRenderer(state, definitionWalker, handler, raceEvent);
|
|
274
|
+
raceEvent.subscribe(listener.raceEventHandler);
|
|
278
275
|
listener.tryRender(state.selectedStepId);
|
|
279
276
|
return listener;
|
|
280
277
|
}
|
|
281
|
-
constructor(state, definitionWalker, handler) {
|
|
278
|
+
constructor(state, definitionWalker, handler, raceEvent) {
|
|
282
279
|
this.state = state;
|
|
283
280
|
this.definitionWalker = definitionWalker;
|
|
284
281
|
this.handler = handler;
|
|
282
|
+
this.raceEvent = raceEvent;
|
|
285
283
|
this.currentStepId = undefined;
|
|
284
|
+
this.raceEventHandler = ([definitionChanged, selectedStepId]) => {
|
|
285
|
+
if (definitionChanged) {
|
|
286
|
+
this.onDefinitionChanged(definitionChanged);
|
|
287
|
+
}
|
|
288
|
+
else if (selectedStepId !== undefined) {
|
|
289
|
+
this.onSelectedStepIdChanged(selectedStepId);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
286
292
|
}
|
|
287
293
|
destroy() {
|
|
288
|
-
|
|
294
|
+
this.raceEvent.unsubscribe(this.raceEventHandler);
|
|
289
295
|
}
|
|
290
296
|
render(stepId) {
|
|
291
297
|
const step = stepId ? this.definitionWalker.getById(this.state.definition, stepId) : null;
|
|
@@ -3266,23 +3272,27 @@ class ControlBarExtension {
|
|
|
3266
3272
|
}
|
|
3267
3273
|
}
|
|
3268
3274
|
|
|
3269
|
-
const
|
|
3270
|
-
const ignoreTagNames = ['INPUT', 'TEXTAREA'];
|
|
3275
|
+
const ignoreTagNames = ['INPUT', 'TEXTAREA', 'SELECT'];
|
|
3271
3276
|
class KeyboardDaemon {
|
|
3272
|
-
static create(api) {
|
|
3273
|
-
const controller = new KeyboardDaemon(api.controlBar);
|
|
3277
|
+
static create(api, configuration) {
|
|
3278
|
+
const controller = new KeyboardDaemon(api.controlBar, configuration);
|
|
3274
3279
|
document.addEventListener('keyup', controller.onKeyUp, false);
|
|
3275
3280
|
return controller;
|
|
3276
3281
|
}
|
|
3277
|
-
constructor(controlBarApi) {
|
|
3282
|
+
constructor(controlBarApi, configuration) {
|
|
3278
3283
|
this.controlBarApi = controlBarApi;
|
|
3284
|
+
this.configuration = configuration;
|
|
3279
3285
|
this.onKeyUp = (e) => {
|
|
3280
|
-
|
|
3286
|
+
const action = detectAction(e);
|
|
3287
|
+
if (!action) {
|
|
3281
3288
|
return;
|
|
3282
3289
|
}
|
|
3283
3290
|
if (document.activeElement && ignoreTagNames.includes(document.activeElement.tagName)) {
|
|
3284
3291
|
return;
|
|
3285
3292
|
}
|
|
3293
|
+
if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, e)) {
|
|
3294
|
+
return;
|
|
3295
|
+
}
|
|
3286
3296
|
const isDeletable = this.controlBarApi.canDelete();
|
|
3287
3297
|
if (isDeletable) {
|
|
3288
3298
|
e.preventDefault();
|
|
@@ -3294,11 +3304,26 @@ class KeyboardDaemon {
|
|
|
3294
3304
|
destroy() {
|
|
3295
3305
|
document.removeEventListener('keyup', this.onKeyUp, false);
|
|
3296
3306
|
}
|
|
3307
|
+
}
|
|
3308
|
+
function detectAction(e) {
|
|
3309
|
+
if (e.key === 'Backspace' || e.key === 'Delete') {
|
|
3310
|
+
return exports.KeyboardAction.delete;
|
|
3311
|
+
}
|
|
3312
|
+
return null;
|
|
3297
3313
|
}
|
|
3298
3314
|
|
|
3299
3315
|
class KeyboardDaemonExtension {
|
|
3300
|
-
|
|
3301
|
-
|
|
3316
|
+
static create(configuration) {
|
|
3317
|
+
if (configuration === undefined || configuration === true) {
|
|
3318
|
+
configuration = {};
|
|
3319
|
+
}
|
|
3320
|
+
return new KeyboardDaemonExtension(configuration);
|
|
3321
|
+
}
|
|
3322
|
+
constructor(configuration) {
|
|
3323
|
+
this.configuration = configuration;
|
|
3324
|
+
}
|
|
3325
|
+
create(api) {
|
|
3326
|
+
return KeyboardDaemon.create(api, this.configuration);
|
|
3302
3327
|
}
|
|
3303
3328
|
}
|
|
3304
3329
|
|
|
@@ -4078,7 +4103,9 @@ function setDefault(services, configuration) {
|
|
|
4078
4103
|
if (!services.daemons) {
|
|
4079
4104
|
services.daemons = [];
|
|
4080
4105
|
}
|
|
4081
|
-
|
|
4106
|
+
if (configuration.keyboard === undefined || configuration.keyboard) {
|
|
4107
|
+
services.daemons.push(KeyboardDaemonExtension.create(configuration.keyboard));
|
|
4108
|
+
}
|
|
4082
4109
|
}
|
|
4083
4110
|
|
|
4084
4111
|
function throwDepreciatedError(propertyName, groupName) {
|
|
@@ -4131,10 +4158,17 @@ class Designer {
|
|
|
4131
4158
|
const view = DesignerView.create(placeholder, designerContext, designerApi);
|
|
4132
4159
|
const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
|
|
4133
4160
|
view.workspace.onReady.subscribe(() => designer.onReady.forward());
|
|
4134
|
-
designerContext.state.onDefinitionChanged.subscribe(() => {
|
|
4135
|
-
|
|
4161
|
+
race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
|
|
4162
|
+
if (definition !== undefined) {
|
|
4163
|
+
designer.onDefinitionChanged.forward(designerContext.state.definition);
|
|
4164
|
+
}
|
|
4165
|
+
if (selectedStepId !== undefined) {
|
|
4166
|
+
designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
|
|
4167
|
+
}
|
|
4168
|
+
});
|
|
4169
|
+
designerContext.state.onViewportChanged.subscribe(viewPort => {
|
|
4170
|
+
designer.onViewportChanged.forward(viewPort);
|
|
4136
4171
|
});
|
|
4137
|
-
designerContext.state.onSelectedStepIdChanged.subscribe(() => designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId));
|
|
4138
4172
|
designerContext.state.onIsToolboxCollapsedChanged.subscribe(isCollapsed => {
|
|
4139
4173
|
designer.onIsToolboxCollapsedChanged.forward(isCollapsed);
|
|
4140
4174
|
});
|
|
@@ -4157,6 +4191,10 @@ class Designer {
|
|
|
4157
4191
|
* @description Fires when the definition has changed.
|
|
4158
4192
|
*/
|
|
4159
4193
|
this.onDefinitionChanged = new SimpleEvent();
|
|
4194
|
+
/**
|
|
4195
|
+
* @description Fires when the viewport has changed.
|
|
4196
|
+
*/
|
|
4197
|
+
this.onViewportChanged = new SimpleEvent();
|
|
4160
4198
|
/**
|
|
4161
4199
|
* @description Fires when the selected step has changed.
|
|
4162
4200
|
*/
|
|
@@ -4206,6 +4244,19 @@ class Designer {
|
|
|
4206
4244
|
selectStepById(stepId) {
|
|
4207
4245
|
this.state.setSelectedStepId(stepId);
|
|
4208
4246
|
}
|
|
4247
|
+
/**
|
|
4248
|
+
* @returns the current viewport.
|
|
4249
|
+
*/
|
|
4250
|
+
getViewport() {
|
|
4251
|
+
return this.state.viewport;
|
|
4252
|
+
}
|
|
4253
|
+
/**
|
|
4254
|
+
* @description Sets the viewport.
|
|
4255
|
+
* @param viewport Viewport.
|
|
4256
|
+
*/
|
|
4257
|
+
setViewport(viewport) {
|
|
4258
|
+
this.state.setViewport(viewport);
|
|
4259
|
+
}
|
|
4209
4260
|
/**
|
|
4210
4261
|
* @description Unselects the selected step.
|
|
4211
4262
|
*/
|
package/lib/esm/index.js
CHANGED
|
@@ -73,6 +73,10 @@ class ControlBarApi {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
var KeyboardAction;
|
|
77
|
+
(function (KeyboardAction) {
|
|
78
|
+
KeyboardAction["delete"] = "delete";
|
|
79
|
+
})(KeyboardAction || (KeyboardAction = {}));
|
|
76
80
|
var DefinitionChangeType;
|
|
77
81
|
(function (DefinitionChangeType) {
|
|
78
82
|
DefinitionChangeType[DefinitionChangeType["stepNameChanged"] = 1] = "stepNameChanged";
|
|
@@ -264,27 +268,29 @@ function race(timeout, a, b, c) {
|
|
|
264
268
|
|
|
265
269
|
class EditorRenderer {
|
|
266
270
|
static create(state, definitionWalker, handler) {
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (definitionChanged) {
|
|
271
|
-
listener.onDefinitionChanged(definitionChanged);
|
|
272
|
-
}
|
|
273
|
-
else if (selectedStepId !== undefined) {
|
|
274
|
-
listener.onSelectedStepIdChanged(selectedStepId);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
271
|
+
const raceEvent = race(0, state.onDefinitionChanged, state.onSelectedStepIdChanged);
|
|
272
|
+
const listener = new EditorRenderer(state, definitionWalker, handler, raceEvent);
|
|
273
|
+
raceEvent.subscribe(listener.raceEventHandler);
|
|
277
274
|
listener.tryRender(state.selectedStepId);
|
|
278
275
|
return listener;
|
|
279
276
|
}
|
|
280
|
-
constructor(state, definitionWalker, handler) {
|
|
277
|
+
constructor(state, definitionWalker, handler, raceEvent) {
|
|
281
278
|
this.state = state;
|
|
282
279
|
this.definitionWalker = definitionWalker;
|
|
283
280
|
this.handler = handler;
|
|
281
|
+
this.raceEvent = raceEvent;
|
|
284
282
|
this.currentStepId = undefined;
|
|
283
|
+
this.raceEventHandler = ([definitionChanged, selectedStepId]) => {
|
|
284
|
+
if (definitionChanged) {
|
|
285
|
+
this.onDefinitionChanged(definitionChanged);
|
|
286
|
+
}
|
|
287
|
+
else if (selectedStepId !== undefined) {
|
|
288
|
+
this.onSelectedStepIdChanged(selectedStepId);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
285
291
|
}
|
|
286
292
|
destroy() {
|
|
287
|
-
|
|
293
|
+
this.raceEvent.unsubscribe(this.raceEventHandler);
|
|
288
294
|
}
|
|
289
295
|
render(stepId) {
|
|
290
296
|
const step = stepId ? this.definitionWalker.getById(this.state.definition, stepId) : null;
|
|
@@ -3265,23 +3271,27 @@ class ControlBarExtension {
|
|
|
3265
3271
|
}
|
|
3266
3272
|
}
|
|
3267
3273
|
|
|
3268
|
-
const
|
|
3269
|
-
const ignoreTagNames = ['INPUT', 'TEXTAREA'];
|
|
3274
|
+
const ignoreTagNames = ['INPUT', 'TEXTAREA', 'SELECT'];
|
|
3270
3275
|
class KeyboardDaemon {
|
|
3271
|
-
static create(api) {
|
|
3272
|
-
const controller = new KeyboardDaemon(api.controlBar);
|
|
3276
|
+
static create(api, configuration) {
|
|
3277
|
+
const controller = new KeyboardDaemon(api.controlBar, configuration);
|
|
3273
3278
|
document.addEventListener('keyup', controller.onKeyUp, false);
|
|
3274
3279
|
return controller;
|
|
3275
3280
|
}
|
|
3276
|
-
constructor(controlBarApi) {
|
|
3281
|
+
constructor(controlBarApi, configuration) {
|
|
3277
3282
|
this.controlBarApi = controlBarApi;
|
|
3283
|
+
this.configuration = configuration;
|
|
3278
3284
|
this.onKeyUp = (e) => {
|
|
3279
|
-
|
|
3285
|
+
const action = detectAction(e);
|
|
3286
|
+
if (!action) {
|
|
3280
3287
|
return;
|
|
3281
3288
|
}
|
|
3282
3289
|
if (document.activeElement && ignoreTagNames.includes(document.activeElement.tagName)) {
|
|
3283
3290
|
return;
|
|
3284
3291
|
}
|
|
3292
|
+
if (this.configuration.canHandleKey && !this.configuration.canHandleKey(action, e)) {
|
|
3293
|
+
return;
|
|
3294
|
+
}
|
|
3285
3295
|
const isDeletable = this.controlBarApi.canDelete();
|
|
3286
3296
|
if (isDeletable) {
|
|
3287
3297
|
e.preventDefault();
|
|
@@ -3293,11 +3303,26 @@ class KeyboardDaemon {
|
|
|
3293
3303
|
destroy() {
|
|
3294
3304
|
document.removeEventListener('keyup', this.onKeyUp, false);
|
|
3295
3305
|
}
|
|
3306
|
+
}
|
|
3307
|
+
function detectAction(e) {
|
|
3308
|
+
if (e.key === 'Backspace' || e.key === 'Delete') {
|
|
3309
|
+
return KeyboardAction.delete;
|
|
3310
|
+
}
|
|
3311
|
+
return null;
|
|
3296
3312
|
}
|
|
3297
3313
|
|
|
3298
3314
|
class KeyboardDaemonExtension {
|
|
3299
|
-
|
|
3300
|
-
|
|
3315
|
+
static create(configuration) {
|
|
3316
|
+
if (configuration === undefined || configuration === true) {
|
|
3317
|
+
configuration = {};
|
|
3318
|
+
}
|
|
3319
|
+
return new KeyboardDaemonExtension(configuration);
|
|
3320
|
+
}
|
|
3321
|
+
constructor(configuration) {
|
|
3322
|
+
this.configuration = configuration;
|
|
3323
|
+
}
|
|
3324
|
+
create(api) {
|
|
3325
|
+
return KeyboardDaemon.create(api, this.configuration);
|
|
3301
3326
|
}
|
|
3302
3327
|
}
|
|
3303
3328
|
|
|
@@ -4077,7 +4102,9 @@ function setDefault(services, configuration) {
|
|
|
4077
4102
|
if (!services.daemons) {
|
|
4078
4103
|
services.daemons = [];
|
|
4079
4104
|
}
|
|
4080
|
-
|
|
4105
|
+
if (configuration.keyboard === undefined || configuration.keyboard) {
|
|
4106
|
+
services.daemons.push(KeyboardDaemonExtension.create(configuration.keyboard));
|
|
4107
|
+
}
|
|
4081
4108
|
}
|
|
4082
4109
|
|
|
4083
4110
|
function throwDepreciatedError(propertyName, groupName) {
|
|
@@ -4130,10 +4157,17 @@ class Designer {
|
|
|
4130
4157
|
const view = DesignerView.create(placeholder, designerContext, designerApi);
|
|
4131
4158
|
const designer = new Designer(view, designerContext.state, designerContext.definitionWalker, designerContext.historyController, designerApi);
|
|
4132
4159
|
view.workspace.onReady.subscribe(() => designer.onReady.forward());
|
|
4133
|
-
designerContext.state.onDefinitionChanged.subscribe(() => {
|
|
4134
|
-
|
|
4160
|
+
race(0, designerContext.state.onDefinitionChanged, designerContext.state.onSelectedStepIdChanged).subscribe(([definition, selectedStepId]) => {
|
|
4161
|
+
if (definition !== undefined) {
|
|
4162
|
+
designer.onDefinitionChanged.forward(designerContext.state.definition);
|
|
4163
|
+
}
|
|
4164
|
+
if (selectedStepId !== undefined) {
|
|
4165
|
+
designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId);
|
|
4166
|
+
}
|
|
4167
|
+
});
|
|
4168
|
+
designerContext.state.onViewportChanged.subscribe(viewPort => {
|
|
4169
|
+
designer.onViewportChanged.forward(viewPort);
|
|
4135
4170
|
});
|
|
4136
|
-
designerContext.state.onSelectedStepIdChanged.subscribe(() => designer.onSelectedStepIdChanged.forward(designerContext.state.selectedStepId));
|
|
4137
4171
|
designerContext.state.onIsToolboxCollapsedChanged.subscribe(isCollapsed => {
|
|
4138
4172
|
designer.onIsToolboxCollapsedChanged.forward(isCollapsed);
|
|
4139
4173
|
});
|
|
@@ -4156,6 +4190,10 @@ class Designer {
|
|
|
4156
4190
|
* @description Fires when the definition has changed.
|
|
4157
4191
|
*/
|
|
4158
4192
|
this.onDefinitionChanged = new SimpleEvent();
|
|
4193
|
+
/**
|
|
4194
|
+
* @description Fires when the viewport has changed.
|
|
4195
|
+
*/
|
|
4196
|
+
this.onViewportChanged = new SimpleEvent();
|
|
4159
4197
|
/**
|
|
4160
4198
|
* @description Fires when the selected step has changed.
|
|
4161
4199
|
*/
|
|
@@ -4205,6 +4243,19 @@ class Designer {
|
|
|
4205
4243
|
selectStepById(stepId) {
|
|
4206
4244
|
this.state.setSelectedStepId(stepId);
|
|
4207
4245
|
}
|
|
4246
|
+
/**
|
|
4247
|
+
* @returns the current viewport.
|
|
4248
|
+
*/
|
|
4249
|
+
getViewport() {
|
|
4250
|
+
return this.state.viewport;
|
|
4251
|
+
}
|
|
4252
|
+
/**
|
|
4253
|
+
* @description Sets the viewport.
|
|
4254
|
+
* @param viewport Viewport.
|
|
4255
|
+
*/
|
|
4256
|
+
setViewport(viewport) {
|
|
4257
|
+
this.state.setViewport(viewport);
|
|
4258
|
+
}
|
|
4208
4259
|
/**
|
|
4209
4260
|
* @description Unselects the selected step.
|
|
4210
4261
|
*/
|
|
@@ -4317,4 +4368,4 @@ class StepsDesignerExtension {
|
|
|
4317
4368
|
class StepsExtension extends StepsDesignerExtension {
|
|
4318
4369
|
}
|
|
4319
4370
|
|
|
4320
|
-
export { Badges, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommandType, ComponentContext, ControlBarApi, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerExtension, DefinitionChangeType, Designer, DesignerApi, DesignerContext, DesignerState, Dom, Editor, EditorApi, Icons, InputView, JoinView, LabelView, LineGridDesignerExtension, ObjectCloner, OutputView, PathBarApi, PlaceholderDirection, QuantifiedScaleViewportCalculator, RectPlaceholder, RectPlaceholderView, RegionView, ServicesResolver, SimpleEvent, StepComponent, StepExtensionResolver, StepsDesignerExtension, StepsExtension, ToolboxApi, Uid, ValidationErrorBadgeExtension, Vector, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, race };
|
|
4371
|
+
export { Badges, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommandType, ComponentContext, ControlBarApi, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerExtension, DefinitionChangeType, Designer, DesignerApi, DesignerContext, DesignerState, Dom, Editor, EditorApi, Icons, InputView, JoinView, KeyboardAction, LabelView, LineGridDesignerExtension, ObjectCloner, OutputView, PathBarApi, PlaceholderDirection, QuantifiedScaleViewportCalculator, RectPlaceholder, RectPlaceholderView, RegionView, ServicesResolver, SimpleEvent, StepComponent, StepExtensionResolver, StepsDesignerExtension, StepsExtension, ToolboxApi, Uid, ValidationErrorBadgeExtension, Vector, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, race };
|
package/lib/index.d.ts
CHANGED
|
@@ -361,12 +361,14 @@ declare class EditorRenderer {
|
|
|
361
361
|
private readonly state;
|
|
362
362
|
private readonly definitionWalker;
|
|
363
363
|
private readonly handler;
|
|
364
|
+
private readonly raceEvent;
|
|
364
365
|
static create(state: DesignerState, definitionWalker: DefinitionWalker, handler: EditorRendererHandler): EditorRenderer;
|
|
365
366
|
private currentStepId;
|
|
366
367
|
private constructor();
|
|
367
368
|
destroy(): void;
|
|
368
369
|
private render;
|
|
369
370
|
private tryRender;
|
|
371
|
+
private readonly raceEventHandler;
|
|
370
372
|
private onDefinitionChanged;
|
|
371
373
|
private onSelectedStepIdChanged;
|
|
372
374
|
}
|
|
@@ -798,8 +800,8 @@ interface ViewportController {
|
|
|
798
800
|
focusOnComponent(componentPosition: Vector, componentSize: Vector): void;
|
|
799
801
|
}
|
|
800
802
|
interface Viewport {
|
|
801
|
-
position: Vector;
|
|
802
|
-
scale: number;
|
|
803
|
+
readonly position: Vector;
|
|
804
|
+
readonly scale: number;
|
|
803
805
|
}
|
|
804
806
|
interface DaemonExtension {
|
|
805
807
|
create(api: DesignerApi): Daemon;
|
|
@@ -850,6 +852,10 @@ interface DesignerConfiguration<TDefinition extends Definition = Definition> {
|
|
|
850
852
|
* @description The configuration of validators.
|
|
851
853
|
*/
|
|
852
854
|
validator?: ValidatorConfiguration;
|
|
855
|
+
/**
|
|
856
|
+
* @description The configuration of the keyboard shortcuts. By default, the keyboard shortcuts are enabled (`true`). If `false`, the keyboard shortcuts are disabled.
|
|
857
|
+
*/
|
|
858
|
+
keyboard?: boolean | KeyboardConfiguration;
|
|
853
859
|
/**
|
|
854
860
|
* @description The handler that handles custom actions.
|
|
855
861
|
*/
|
|
@@ -932,6 +938,12 @@ interface ValidatorConfiguration {
|
|
|
932
938
|
}
|
|
933
939
|
type StepValidator = (step: Step, parentSequence: Sequence, definition: Definition) => boolean;
|
|
934
940
|
type RootValidator = (definition: Definition) => boolean;
|
|
941
|
+
interface KeyboardConfiguration {
|
|
942
|
+
canHandleKey?: (action: KeyboardAction, event: KeyboardEvent) => boolean;
|
|
943
|
+
}
|
|
944
|
+
declare enum KeyboardAction {
|
|
945
|
+
delete = "delete"
|
|
946
|
+
}
|
|
935
947
|
interface EditorsConfiguration<TDefinition extends Definition = Definition> {
|
|
936
948
|
isCollapsed?: boolean;
|
|
937
949
|
stepEditorProvider: StepEditorProvider<TDefinition>;
|
|
@@ -1040,6 +1052,10 @@ declare class Designer<TDefinition extends Definition = Definition> {
|
|
|
1040
1052
|
* @description Fires when the definition has changed.
|
|
1041
1053
|
*/
|
|
1042
1054
|
readonly onDefinitionChanged: SimpleEvent<TDefinition>;
|
|
1055
|
+
/**
|
|
1056
|
+
* @description Fires when the viewport has changed.
|
|
1057
|
+
*/
|
|
1058
|
+
readonly onViewportChanged: SimpleEvent<Viewport>;
|
|
1043
1059
|
/**
|
|
1044
1060
|
* @description Fires when the selected step has changed.
|
|
1045
1061
|
*/
|
|
@@ -1076,6 +1092,15 @@ declare class Designer<TDefinition extends Definition = Definition> {
|
|
|
1076
1092
|
* @description Selects a step by the id.
|
|
1077
1093
|
*/
|
|
1078
1094
|
selectStepById(stepId: string): void;
|
|
1095
|
+
/**
|
|
1096
|
+
* @returns the current viewport.
|
|
1097
|
+
*/
|
|
1098
|
+
getViewport(): Viewport;
|
|
1099
|
+
/**
|
|
1100
|
+
* @description Sets the viewport.
|
|
1101
|
+
* @param viewport Viewport.
|
|
1102
|
+
*/
|
|
1103
|
+
setViewport(viewport: Viewport): void;
|
|
1079
1104
|
/**
|
|
1080
1105
|
* @description Unselects the selected step.
|
|
1081
1106
|
*/
|
|
@@ -1169,4 +1194,4 @@ declare class StepsExtension extends StepsDesignerExtension {
|
|
|
1169
1194
|
interface StepsExtensionConfiguration extends StepsDesignerExtensionConfiguration {
|
|
1170
1195
|
}
|
|
1171
1196
|
|
|
1172
|
-
export { Attributes, Badge, BadgeExtension, BadgeView, Badges, BadgesResult, BaseClickCommand, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommand, ClickCommandType, ClickDetails, Component, ComponentContext, ComponentView, ContainerStep, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ControlBarApi, CustomAction, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerExtension, DefinitionChangeType, DefinitionChangedEvent, Designer, DesignerApi, DesignerConfiguration, DesignerContext, DesignerExtension, DesignerState, Dom, DraggedComponent, DraggedComponentExtension, Editor, EditorApi, EditorsConfiguration, GlobalEditorContext, GlobalEditorProvider, Grid, GridExtension, Icons, InputView, JoinView, LabelView, LineGridConfiguration, LineGridDesignerExtension, ObjectCloner, OpenFolderClickCommand, OutputView, PathBarApi, Placeholder, PlaceholderController, PlaceholderControllerExtension, PlaceholderDirection, PlaceholderExtension, PlaceholderView, QuantifiedScaleViewportCalculator, RectPlaceholder, RectPlaceholderConfiguration, RectPlaceholderView, RegionView, RerenderStepClickCommand, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, ServicesResolver, SimpleEvent, SimpleEventListener, StepComponent, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepExtensionResolver, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtension, StepsDesignerExtensionConfiguration, StepsExtension, StepsExtensionConfiguration, SwitchStep, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TaskStep, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxApi, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, Uid, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtension, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Vector, Viewport, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, race };
|
|
1197
|
+
export { Attributes, Badge, BadgeExtension, BadgeView, Badges, BadgesResult, BaseClickCommand, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickCommand, ClickCommandType, ClickDetails, Component, ComponentContext, ComponentView, ContainerStep, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ControlBarApi, CustomAction, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerExtension, DefinitionChangeType, DefinitionChangedEvent, Designer, DesignerApi, DesignerConfiguration, DesignerContext, DesignerExtension, DesignerState, Dom, DraggedComponent, DraggedComponentExtension, Editor, EditorApi, EditorsConfiguration, GlobalEditorContext, GlobalEditorProvider, Grid, GridExtension, Icons, InputView, JoinView, KeyboardAction, KeyboardConfiguration, LabelView, LineGridConfiguration, LineGridDesignerExtension, ObjectCloner, OpenFolderClickCommand, OutputView, PathBarApi, Placeholder, PlaceholderController, PlaceholderControllerExtension, PlaceholderDirection, PlaceholderExtension, PlaceholderView, QuantifiedScaleViewportCalculator, RectPlaceholder, RectPlaceholderConfiguration, RectPlaceholderView, RegionView, RerenderStepClickCommand, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepClickCommand, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, ServicesResolver, SimpleEvent, SimpleEventListener, StepComponent, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepExtensionResolver, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtension, StepsDesignerExtensionConfiguration, StepsExtension, StepsExtensionConfiguration, SwitchStep, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TaskStep, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxApi, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, Uid, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtension, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Vector, Viewport, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, race };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sequential-workflow-designer",
|
|
3
3
|
"description": "Customizable no-code component for building flow-based programming applications.",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.10",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|