sequential-workflow-designer 0.27.3 → 0.28.0
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 +229 -216
- package/lib/cjs/index.cjs +46 -33
- package/lib/esm/index.js +47 -34
- package/lib/index.d.ts +11 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,10 +104,10 @@ Add the below code to your head section in HTML document.
|
|
|
104
104
|
```html
|
|
105
105
|
<head>
|
|
106
106
|
...
|
|
107
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.
|
|
108
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.
|
|
109
|
-
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.
|
|
110
|
-
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.
|
|
107
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.28.0/css/designer.css" rel="stylesheet">
|
|
108
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.28.0/css/designer-light.css" rel="stylesheet">
|
|
109
|
+
<link href="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.28.0/css/designer-dark.css" rel="stylesheet">
|
|
110
|
+
<script src="https://cdn.jsdelivr.net/npm/sequential-workflow-designer@0.28.0/dist/index.umd.js"></script>
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
Call the designer by:
|
package/dist/index.umd.js
CHANGED
|
@@ -769,9 +769,193 @@
|
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
|
|
772
|
+
const defaultResolvers = [sequentialResolver, branchedResolver];
|
|
773
|
+
function branchedResolver(step) {
|
|
774
|
+
const branches = step.branches;
|
|
775
|
+
if (branches) {
|
|
776
|
+
return { type: exports.StepChildrenType.branches, items: branches };
|
|
777
|
+
}
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
function sequentialResolver(step) {
|
|
781
|
+
const sequence = step.sequence;
|
|
782
|
+
if (sequence) {
|
|
783
|
+
return { type: exports.StepChildrenType.sequence, items: sequence };
|
|
784
|
+
}
|
|
785
|
+
return null;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
exports.StepChildrenType = void 0;
|
|
789
|
+
(function (StepChildrenType) {
|
|
790
|
+
StepChildrenType[StepChildrenType["sequence"] = 1] = "sequence";
|
|
791
|
+
StepChildrenType[StepChildrenType["branches"] = 2] = "branches";
|
|
792
|
+
})(exports.StepChildrenType || (exports.StepChildrenType = {}));
|
|
793
|
+
class DefinitionWalker {
|
|
794
|
+
constructor(resolvers) {
|
|
795
|
+
this.resolvers = resolvers ? resolvers.concat(defaultResolvers) : defaultResolvers;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Returns children of the step. If the step doesn't have children, returns null.
|
|
799
|
+
* @param step The step.
|
|
800
|
+
*/
|
|
801
|
+
getChildren(step) {
|
|
802
|
+
const count = this.resolvers.length;
|
|
803
|
+
for (let i = 0; i < count; i++) {
|
|
804
|
+
const result = this.resolvers[i](step);
|
|
805
|
+
if (result) {
|
|
806
|
+
return result;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return null;
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Returns the parents of the step or the sequence.
|
|
813
|
+
* @param definition The definition.
|
|
814
|
+
* @param needle The step, stepId or sequence to find.
|
|
815
|
+
* @returns The parents of the step or the sequence.
|
|
816
|
+
*/
|
|
817
|
+
getParents(definition, needle) {
|
|
818
|
+
const result = [];
|
|
819
|
+
let searchSequence = null;
|
|
820
|
+
let searchStepId = null;
|
|
821
|
+
if (Array.isArray(needle)) {
|
|
822
|
+
searchSequence = needle;
|
|
823
|
+
}
|
|
824
|
+
else if (typeof needle === 'string') {
|
|
825
|
+
searchStepId = needle;
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
searchStepId = needle.id;
|
|
829
|
+
}
|
|
830
|
+
if (this.find(definition.sequence, searchSequence, searchStepId, result)) {
|
|
831
|
+
result.reverse();
|
|
832
|
+
return result.map(item => {
|
|
833
|
+
return typeof item === 'string' ? item : item.step;
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
throw new Error(searchStepId ? `Cannot get parents of step: ${searchStepId}` : 'Cannot get parents of sequence');
|
|
837
|
+
}
|
|
838
|
+
findParentSequence(definition, stepId) {
|
|
839
|
+
const result = [];
|
|
840
|
+
if (this.find(definition.sequence, null, stepId, result)) {
|
|
841
|
+
return result[0];
|
|
842
|
+
}
|
|
843
|
+
return null;
|
|
844
|
+
}
|
|
845
|
+
getParentSequence(definition, stepId) {
|
|
846
|
+
const result = this.findParentSequence(definition, stepId);
|
|
847
|
+
if (!result) {
|
|
848
|
+
throw new Error(`Cannot find step by id: ${stepId}`);
|
|
849
|
+
}
|
|
850
|
+
return result;
|
|
851
|
+
}
|
|
852
|
+
findById(definition, stepId) {
|
|
853
|
+
const result = this.findParentSequence(definition, stepId);
|
|
854
|
+
return result ? result.step : null;
|
|
855
|
+
}
|
|
856
|
+
getById(definition, stepId) {
|
|
857
|
+
return this.getParentSequence(definition, stepId).step;
|
|
858
|
+
}
|
|
859
|
+
forEach(definition, callback) {
|
|
860
|
+
this.iterateSequence(definition.sequence, callback);
|
|
861
|
+
}
|
|
862
|
+
forEachSequence(sequence, callback) {
|
|
863
|
+
this.iterateSequence(sequence, callback);
|
|
864
|
+
}
|
|
865
|
+
forEachChildren(step, callback) {
|
|
866
|
+
this.iterateStep(step, callback);
|
|
867
|
+
}
|
|
868
|
+
find(sequence, needSequence, needStepId, result) {
|
|
869
|
+
if (needSequence && sequence === needSequence) {
|
|
870
|
+
return true;
|
|
871
|
+
}
|
|
872
|
+
const count = sequence.length;
|
|
873
|
+
for (let index = 0; index < count; index++) {
|
|
874
|
+
const step = sequence[index];
|
|
875
|
+
if (needStepId && step.id === needStepId) {
|
|
876
|
+
result.push({ step, index, parentSequence: sequence });
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
const children = this.getChildren(step);
|
|
880
|
+
if (children) {
|
|
881
|
+
switch (children.type) {
|
|
882
|
+
case exports.StepChildrenType.sequence:
|
|
883
|
+
{
|
|
884
|
+
const parentSequence = children.items;
|
|
885
|
+
if (this.find(parentSequence, needSequence, needStepId, result)) {
|
|
886
|
+
result.push({ step, index, parentSequence });
|
|
887
|
+
return true;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
break;
|
|
891
|
+
case exports.StepChildrenType.branches:
|
|
892
|
+
{
|
|
893
|
+
const branches = children.items;
|
|
894
|
+
const branchNames = Object.keys(branches);
|
|
895
|
+
for (const branchName of branchNames) {
|
|
896
|
+
const parentSequence = branches[branchName];
|
|
897
|
+
if (this.find(parentSequence, needSequence, needStepId, result)) {
|
|
898
|
+
result.push(branchName);
|
|
899
|
+
result.push({ step, index, parentSequence });
|
|
900
|
+
return true;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
break;
|
|
905
|
+
default:
|
|
906
|
+
throw new Error(`Not supported step children type: ${children.type}`);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
iterateSequence(sequence, callback) {
|
|
913
|
+
const count = sequence.length;
|
|
914
|
+
for (let index = 0; index < count; index++) {
|
|
915
|
+
const step = sequence[index];
|
|
916
|
+
if (callback(step, index, sequence) === false) {
|
|
917
|
+
return false;
|
|
918
|
+
}
|
|
919
|
+
if (!this.iterateStep(step, callback)) {
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
iterateStep(step, callback) {
|
|
926
|
+
const children = this.getChildren(step);
|
|
927
|
+
if (children) {
|
|
928
|
+
switch (children.type) {
|
|
929
|
+
case exports.StepChildrenType.sequence:
|
|
930
|
+
{
|
|
931
|
+
const sequence = children.items;
|
|
932
|
+
if (!this.iterateSequence(sequence, callback)) {
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
break;
|
|
937
|
+
case exports.StepChildrenType.branches:
|
|
938
|
+
{
|
|
939
|
+
const sequences = Object.values(children.items);
|
|
940
|
+
for (const sequence of sequences) {
|
|
941
|
+
if (!this.iterateSequence(sequence, callback)) {
|
|
942
|
+
return false;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
break;
|
|
947
|
+
default:
|
|
948
|
+
throw new Error(`Not supported step children type: ${children.type}`);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
|
|
772
955
|
class WorkspaceApi {
|
|
773
|
-
constructor(state, workspaceController) {
|
|
956
|
+
constructor(state, definitionWalker, workspaceController) {
|
|
774
957
|
this.state = state;
|
|
958
|
+
this.definitionWalker = definitionWalker;
|
|
775
959
|
this.workspaceController = workspaceController;
|
|
776
960
|
}
|
|
777
961
|
getViewport() {
|
|
@@ -798,11 +982,29 @@
|
|
|
798
982
|
updateCanvasSize() {
|
|
799
983
|
this.workspaceController.updateCanvasSize();
|
|
800
984
|
}
|
|
985
|
+
getRootSequence() {
|
|
986
|
+
const stepId = this.state.tryGetLastStepIdFromFolderPath();
|
|
987
|
+
if (stepId) {
|
|
988
|
+
const parentStep = this.definitionWalker.getParentSequence(this.state.definition, stepId);
|
|
989
|
+
const children = this.definitionWalker.getChildren(parentStep.step);
|
|
990
|
+
if (!children || children.type !== exports.StepChildrenType.sequence) {
|
|
991
|
+
throw new Error('Cannot find single sequence in folder step');
|
|
992
|
+
}
|
|
993
|
+
return {
|
|
994
|
+
sequence: children.items,
|
|
995
|
+
parentStep
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
return {
|
|
999
|
+
sequence: this.state.definition.sequence,
|
|
1000
|
+
parentStep: null
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
801
1003
|
}
|
|
802
1004
|
|
|
803
1005
|
class DesignerApi {
|
|
804
1006
|
static create(context) {
|
|
805
|
-
const workspace = new WorkspaceApi(context.state, context.workspaceController);
|
|
1007
|
+
const workspace = new WorkspaceApi(context.state, context.definitionWalker, context.workspaceController);
|
|
806
1008
|
const viewportController = context.services.viewportController.create(workspace);
|
|
807
1009
|
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
|
|
808
1010
|
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
@@ -2379,189 +2581,6 @@
|
|
|
2379
2581
|
}
|
|
2380
2582
|
}
|
|
2381
2583
|
|
|
2382
|
-
const defaultResolvers = [sequentialResolver, branchedResolver];
|
|
2383
|
-
function branchedResolver(step) {
|
|
2384
|
-
const branches = step.branches;
|
|
2385
|
-
if (branches) {
|
|
2386
|
-
return { type: exports.StepChildrenType.branches, items: branches };
|
|
2387
|
-
}
|
|
2388
|
-
return null;
|
|
2389
|
-
}
|
|
2390
|
-
function sequentialResolver(step) {
|
|
2391
|
-
const sequence = step.sequence;
|
|
2392
|
-
if (sequence) {
|
|
2393
|
-
return { type: exports.StepChildrenType.sequence, items: sequence };
|
|
2394
|
-
}
|
|
2395
|
-
return null;
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
exports.StepChildrenType = void 0;
|
|
2399
|
-
(function (StepChildrenType) {
|
|
2400
|
-
StepChildrenType[StepChildrenType["sequence"] = 1] = "sequence";
|
|
2401
|
-
StepChildrenType[StepChildrenType["branches"] = 2] = "branches";
|
|
2402
|
-
})(exports.StepChildrenType || (exports.StepChildrenType = {}));
|
|
2403
|
-
class DefinitionWalker {
|
|
2404
|
-
constructor(resolvers) {
|
|
2405
|
-
this.resolvers = resolvers ? resolvers.concat(defaultResolvers) : defaultResolvers;
|
|
2406
|
-
}
|
|
2407
|
-
/**
|
|
2408
|
-
* Returns children of the step. If the step doesn't have children, returns null.
|
|
2409
|
-
* @param step The step.
|
|
2410
|
-
*/
|
|
2411
|
-
getChildren(step) {
|
|
2412
|
-
const count = this.resolvers.length;
|
|
2413
|
-
for (let i = 0; i < count; i++) {
|
|
2414
|
-
const result = this.resolvers[i](step);
|
|
2415
|
-
if (result) {
|
|
2416
|
-
return result;
|
|
2417
|
-
}
|
|
2418
|
-
}
|
|
2419
|
-
return null;
|
|
2420
|
-
}
|
|
2421
|
-
/**
|
|
2422
|
-
* Returns the parents of the step or the sequence.
|
|
2423
|
-
* @param definition The definition.
|
|
2424
|
-
* @param needle The step, stepId or sequence to find.
|
|
2425
|
-
* @returns The parents of the step or the sequence.
|
|
2426
|
-
*/
|
|
2427
|
-
getParents(definition, needle) {
|
|
2428
|
-
const result = [];
|
|
2429
|
-
let searchSequence = null;
|
|
2430
|
-
let searchStepId = null;
|
|
2431
|
-
if (Array.isArray(needle)) {
|
|
2432
|
-
searchSequence = needle;
|
|
2433
|
-
}
|
|
2434
|
-
else if (typeof needle === 'string') {
|
|
2435
|
-
searchStepId = needle;
|
|
2436
|
-
}
|
|
2437
|
-
else {
|
|
2438
|
-
searchStepId = needle.id;
|
|
2439
|
-
}
|
|
2440
|
-
if (this.find(definition.sequence, searchSequence, searchStepId, result)) {
|
|
2441
|
-
result.reverse();
|
|
2442
|
-
return result.map(item => {
|
|
2443
|
-
return typeof item === 'string' ? item : item.step;
|
|
2444
|
-
});
|
|
2445
|
-
}
|
|
2446
|
-
throw new Error(searchStepId ? `Cannot get parents of step: ${searchStepId}` : 'Cannot get parents of sequence');
|
|
2447
|
-
}
|
|
2448
|
-
findParentSequence(definition, stepId) {
|
|
2449
|
-
const result = [];
|
|
2450
|
-
if (this.find(definition.sequence, null, stepId, result)) {
|
|
2451
|
-
return result[0];
|
|
2452
|
-
}
|
|
2453
|
-
return null;
|
|
2454
|
-
}
|
|
2455
|
-
getParentSequence(definition, stepId) {
|
|
2456
|
-
const result = this.findParentSequence(definition, stepId);
|
|
2457
|
-
if (!result) {
|
|
2458
|
-
throw new Error(`Cannot find step by id: ${stepId}`);
|
|
2459
|
-
}
|
|
2460
|
-
return result;
|
|
2461
|
-
}
|
|
2462
|
-
findById(definition, stepId) {
|
|
2463
|
-
const result = this.findParentSequence(definition, stepId);
|
|
2464
|
-
return result ? result.step : null;
|
|
2465
|
-
}
|
|
2466
|
-
getById(definition, stepId) {
|
|
2467
|
-
return this.getParentSequence(definition, stepId).step;
|
|
2468
|
-
}
|
|
2469
|
-
forEach(definition, callback) {
|
|
2470
|
-
this.iterateSequence(definition.sequence, callback);
|
|
2471
|
-
}
|
|
2472
|
-
forEachSequence(sequence, callback) {
|
|
2473
|
-
this.iterateSequence(sequence, callback);
|
|
2474
|
-
}
|
|
2475
|
-
forEachChildren(step, callback) {
|
|
2476
|
-
this.iterateStep(step, callback);
|
|
2477
|
-
}
|
|
2478
|
-
find(sequence, needSequence, needStepId, result) {
|
|
2479
|
-
if (needSequence && sequence === needSequence) {
|
|
2480
|
-
return true;
|
|
2481
|
-
}
|
|
2482
|
-
const count = sequence.length;
|
|
2483
|
-
for (let index = 0; index < count; index++) {
|
|
2484
|
-
const step = sequence[index];
|
|
2485
|
-
if (needStepId && step.id === needStepId) {
|
|
2486
|
-
result.push({ step, index, parentSequence: sequence });
|
|
2487
|
-
return true;
|
|
2488
|
-
}
|
|
2489
|
-
const children = this.getChildren(step);
|
|
2490
|
-
if (children) {
|
|
2491
|
-
switch (children.type) {
|
|
2492
|
-
case exports.StepChildrenType.sequence:
|
|
2493
|
-
{
|
|
2494
|
-
const parentSequence = children.items;
|
|
2495
|
-
if (this.find(parentSequence, needSequence, needStepId, result)) {
|
|
2496
|
-
result.push({ step, index, parentSequence });
|
|
2497
|
-
return true;
|
|
2498
|
-
}
|
|
2499
|
-
}
|
|
2500
|
-
break;
|
|
2501
|
-
case exports.StepChildrenType.branches:
|
|
2502
|
-
{
|
|
2503
|
-
const branches = children.items;
|
|
2504
|
-
const branchNames = Object.keys(branches);
|
|
2505
|
-
for (const branchName of branchNames) {
|
|
2506
|
-
const parentSequence = branches[branchName];
|
|
2507
|
-
if (this.find(parentSequence, needSequence, needStepId, result)) {
|
|
2508
|
-
result.push(branchName);
|
|
2509
|
-
result.push({ step, index, parentSequence });
|
|
2510
|
-
return true;
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
break;
|
|
2515
|
-
default:
|
|
2516
|
-
throw new Error(`Not supported step children type: ${children.type}`);
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
}
|
|
2520
|
-
return false;
|
|
2521
|
-
}
|
|
2522
|
-
iterateSequence(sequence, callback) {
|
|
2523
|
-
const count = sequence.length;
|
|
2524
|
-
for (let index = 0; index < count; index++) {
|
|
2525
|
-
const step = sequence[index];
|
|
2526
|
-
if (callback(step, index, sequence) === false) {
|
|
2527
|
-
return false;
|
|
2528
|
-
}
|
|
2529
|
-
if (!this.iterateStep(step, callback)) {
|
|
2530
|
-
return false;
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
return true;
|
|
2534
|
-
}
|
|
2535
|
-
iterateStep(step, callback) {
|
|
2536
|
-
const children = this.getChildren(step);
|
|
2537
|
-
if (children) {
|
|
2538
|
-
switch (children.type) {
|
|
2539
|
-
case exports.StepChildrenType.sequence:
|
|
2540
|
-
{
|
|
2541
|
-
const sequence = children.items;
|
|
2542
|
-
if (!this.iterateSequence(sequence, callback)) {
|
|
2543
|
-
return false;
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
break;
|
|
2547
|
-
case exports.StepChildrenType.branches:
|
|
2548
|
-
{
|
|
2549
|
-
const sequences = Object.values(children.items);
|
|
2550
|
-
for (const sequence of sequences) {
|
|
2551
|
-
if (!this.iterateSequence(sequence, callback)) {
|
|
2552
|
-
return false;
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
}
|
|
2556
|
-
break;
|
|
2557
|
-
default:
|
|
2558
|
-
throw new Error(`Not supported step children type: ${children.type}`);
|
|
2559
|
-
}
|
|
2560
|
-
}
|
|
2561
|
-
return true;
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
|
|
2565
2584
|
function readMousePosition(e) {
|
|
2566
2585
|
return new Vector(e.pageX, e.pageY);
|
|
2567
2586
|
}
|
|
@@ -3240,11 +3259,11 @@
|
|
|
3240
3259
|
this.context = context;
|
|
3241
3260
|
this.onResizeHandler = () => this.onResize();
|
|
3242
3261
|
}
|
|
3243
|
-
render(sequence,
|
|
3262
|
+
render(sequence, parentPlaceIndicator) {
|
|
3244
3263
|
if (this.rootComponent) {
|
|
3245
3264
|
this.foreground.removeChild(this.rootComponent.view.g);
|
|
3246
3265
|
}
|
|
3247
|
-
this.rootComponent = this.context.services.rootComponent.create(this.foreground, sequence,
|
|
3266
|
+
this.rootComponent = this.context.services.rootComponent.create(this.foreground, sequence, parentPlaceIndicator, this.context);
|
|
3248
3267
|
this.refreshSize();
|
|
3249
3268
|
}
|
|
3250
3269
|
setPositionAndScale(position, scale) {
|
|
@@ -3404,10 +3423,14 @@
|
|
|
3404
3423
|
}
|
|
3405
3424
|
|
|
3406
3425
|
class RerenderStepPressingBehaviorHandler {
|
|
3407
|
-
constructor(designerContext) {
|
|
3426
|
+
constructor(command, designerContext) {
|
|
3427
|
+
this.command = command;
|
|
3408
3428
|
this.designerContext = designerContext;
|
|
3409
3429
|
}
|
|
3410
3430
|
handle() {
|
|
3431
|
+
if (this.command.beforeCallback) {
|
|
3432
|
+
this.command.beforeCallback();
|
|
3433
|
+
}
|
|
3411
3434
|
this.designerContext.workspaceController.updateRootComponent();
|
|
3412
3435
|
}
|
|
3413
3436
|
}
|
|
@@ -3445,7 +3468,7 @@
|
|
|
3445
3468
|
case exports.ClickCommandType.selectStep:
|
|
3446
3469
|
return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
|
|
3447
3470
|
case exports.ClickCommandType.rerenderStep:
|
|
3448
|
-
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(this.context));
|
|
3471
|
+
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(commandOrNull, this.context));
|
|
3449
3472
|
case exports.ClickCommandType.openFolder:
|
|
3450
3473
|
return PressingBehavior.create(element, new OpenFolderPressingBehaviorHandler(commandOrNull, this.context));
|
|
3451
3474
|
case exports.ClickCommandType.triggerCustomAction:
|
|
@@ -3581,8 +3604,9 @@
|
|
|
3581
3604
|
}
|
|
3582
3605
|
|
|
3583
3606
|
class ContextMenuItemsBuilder {
|
|
3584
|
-
constructor(viewportApi, i18n, stateModifier, state, customMenuItemsProvider) {
|
|
3607
|
+
constructor(viewportApi, workspaceApi, i18n, stateModifier, state, customMenuItemsProvider) {
|
|
3585
3608
|
this.viewportApi = viewportApi;
|
|
3609
|
+
this.workspaceApi = workspaceApi;
|
|
3586
3610
|
this.i18n = i18n;
|
|
3587
3611
|
this.stateModifier = stateModifier;
|
|
3588
3612
|
this.state = state;
|
|
@@ -3641,8 +3665,9 @@
|
|
|
3641
3665
|
}
|
|
3642
3666
|
}
|
|
3643
3667
|
}
|
|
3644
|
-
else {
|
|
3645
|
-
|
|
3668
|
+
else if (!commandOrNull) {
|
|
3669
|
+
const rootSequence = this.workspaceApi.getRootSequence();
|
|
3670
|
+
this.tryAppendCustomItems(items, null, rootSequence.sequence);
|
|
3646
3671
|
}
|
|
3647
3672
|
items.push({
|
|
3648
3673
|
label: this.i18n('contextMenu.resetView', 'Reset view'),
|
|
@@ -3656,7 +3681,7 @@
|
|
|
3656
3681
|
}
|
|
3657
3682
|
tryAppendCustomItems(items, step, parentSequence) {
|
|
3658
3683
|
if (this.customMenuItemsProvider) {
|
|
3659
|
-
const customItems = this.customMenuItemsProvider.getItems(step, parentSequence);
|
|
3684
|
+
const customItems = this.customMenuItemsProvider.getItems(step, parentSequence, this.state.definition);
|
|
3660
3685
|
for (const customItem of customItems) {
|
|
3661
3686
|
items.push(customItem);
|
|
3662
3687
|
}
|
|
@@ -3747,11 +3772,11 @@
|
|
|
3747
3772
|
const clickBehaviorWrapper = designerContext.services.clickBehaviorWrapperExtension.create(designerContext.customActionController);
|
|
3748
3773
|
const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
|
|
3749
3774
|
const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
|
|
3750
|
-
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3775
|
+
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.workspace, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3751
3776
|
? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
|
|
3752
3777
|
: undefined);
|
|
3753
3778
|
const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
|
|
3754
|
-
const workspace = new Workspace(view, designerContext.
|
|
3779
|
+
const workspace = new Workspace(view, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, api.workspace, designerContext.services);
|
|
3755
3780
|
setTimeout(() => {
|
|
3756
3781
|
workspace.updateRootComponent();
|
|
3757
3782
|
api.viewport.resetViewport();
|
|
@@ -3767,9 +3792,8 @@
|
|
|
3767
3792
|
view.bindContextMenu(workspace.onContextMenu);
|
|
3768
3793
|
return workspace;
|
|
3769
3794
|
}
|
|
3770
|
-
constructor(view,
|
|
3795
|
+
constructor(view, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, workspaceApi, services) {
|
|
3771
3796
|
this.view = view;
|
|
3772
|
-
this.definitionWalker = definitionWalker;
|
|
3773
3797
|
this.state = state;
|
|
3774
3798
|
this.behaviorController = behaviorController;
|
|
3775
3799
|
this.wheelController = wheelController;
|
|
@@ -3778,6 +3802,7 @@
|
|
|
3778
3802
|
this.clickBehaviorResolver = clickBehaviorResolver;
|
|
3779
3803
|
this.clickBehaviorWrapper = clickBehaviorWrapper;
|
|
3780
3804
|
this.viewportApi = viewportApi;
|
|
3805
|
+
this.workspaceApi = workspaceApi;
|
|
3781
3806
|
this.services = services;
|
|
3782
3807
|
this.onRendered = new SimpleEvent();
|
|
3783
3808
|
this.isValid = false;
|
|
@@ -3812,26 +3837,14 @@
|
|
|
3812
3837
|
}
|
|
3813
3838
|
updateRootComponent() {
|
|
3814
3839
|
this.selectedStepComponent = null;
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
const children = this.definitionWalker.getChildren(parentSequence.step);
|
|
3821
|
-
if (!children || children.type !== exports.StepChildrenType.sequence) {
|
|
3822
|
-
throw new Error('Cannot find single sequence in folder step');
|
|
3840
|
+
const rootSequence = this.workspaceApi.getRootSequence();
|
|
3841
|
+
const parentPlaceIndicator = rootSequence.parentStep
|
|
3842
|
+
? {
|
|
3843
|
+
sequence: rootSequence.parentStep.parentSequence,
|
|
3844
|
+
index: rootSequence.parentStep.index
|
|
3823
3845
|
}
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
sequence: parentSequence.parentSequence,
|
|
3827
|
-
index: parentSequence.index
|
|
3828
|
-
};
|
|
3829
|
-
}
|
|
3830
|
-
else {
|
|
3831
|
-
sequence = this.state.definition.sequence;
|
|
3832
|
-
parentSequencePlaceIndicator = null;
|
|
3833
|
-
}
|
|
3834
|
-
this.view.render(sequence, parentSequencePlaceIndicator);
|
|
3846
|
+
: null;
|
|
3847
|
+
this.view.render(rootSequence.sequence, parentPlaceIndicator);
|
|
3835
3848
|
this.trySelectStepComponent(this.state.selectedStepId);
|
|
3836
3849
|
this.updateBadges();
|
|
3837
3850
|
this.onRendered.forward();
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -768,8 +768,9 @@ class ViewportApi {
|
|
|
768
768
|
}
|
|
769
769
|
|
|
770
770
|
class WorkspaceApi {
|
|
771
|
-
constructor(state, workspaceController) {
|
|
771
|
+
constructor(state, definitionWalker, workspaceController) {
|
|
772
772
|
this.state = state;
|
|
773
|
+
this.definitionWalker = definitionWalker;
|
|
773
774
|
this.workspaceController = workspaceController;
|
|
774
775
|
}
|
|
775
776
|
getViewport() {
|
|
@@ -796,11 +797,29 @@ class WorkspaceApi {
|
|
|
796
797
|
updateCanvasSize() {
|
|
797
798
|
this.workspaceController.updateCanvasSize();
|
|
798
799
|
}
|
|
800
|
+
getRootSequence() {
|
|
801
|
+
const stepId = this.state.tryGetLastStepIdFromFolderPath();
|
|
802
|
+
if (stepId) {
|
|
803
|
+
const parentStep = this.definitionWalker.getParentSequence(this.state.definition, stepId);
|
|
804
|
+
const children = this.definitionWalker.getChildren(parentStep.step);
|
|
805
|
+
if (!children || children.type !== sequentialWorkflowModel.StepChildrenType.sequence) {
|
|
806
|
+
throw new Error('Cannot find single sequence in folder step');
|
|
807
|
+
}
|
|
808
|
+
return {
|
|
809
|
+
sequence: children.items,
|
|
810
|
+
parentStep
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
return {
|
|
814
|
+
sequence: this.state.definition.sequence,
|
|
815
|
+
parentStep: null
|
|
816
|
+
};
|
|
817
|
+
}
|
|
799
818
|
}
|
|
800
819
|
|
|
801
820
|
class DesignerApi {
|
|
802
821
|
static create(context) {
|
|
803
|
-
const workspace = new WorkspaceApi(context.state, context.workspaceController);
|
|
822
|
+
const workspace = new WorkspaceApi(context.state, context.definitionWalker, context.workspaceController);
|
|
804
823
|
const viewportController = context.services.viewportController.create(workspace);
|
|
805
824
|
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
|
|
806
825
|
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
@@ -3055,11 +3074,11 @@ class WorkspaceView {
|
|
|
3055
3074
|
this.context = context;
|
|
3056
3075
|
this.onResizeHandler = () => this.onResize();
|
|
3057
3076
|
}
|
|
3058
|
-
render(sequence,
|
|
3077
|
+
render(sequence, parentPlaceIndicator) {
|
|
3059
3078
|
if (this.rootComponent) {
|
|
3060
3079
|
this.foreground.removeChild(this.rootComponent.view.g);
|
|
3061
3080
|
}
|
|
3062
|
-
this.rootComponent = this.context.services.rootComponent.create(this.foreground, sequence,
|
|
3081
|
+
this.rootComponent = this.context.services.rootComponent.create(this.foreground, sequence, parentPlaceIndicator, this.context);
|
|
3063
3082
|
this.refreshSize();
|
|
3064
3083
|
}
|
|
3065
3084
|
setPositionAndScale(position, scale) {
|
|
@@ -3219,10 +3238,14 @@ class PressingBehavior {
|
|
|
3219
3238
|
}
|
|
3220
3239
|
|
|
3221
3240
|
class RerenderStepPressingBehaviorHandler {
|
|
3222
|
-
constructor(designerContext) {
|
|
3241
|
+
constructor(command, designerContext) {
|
|
3242
|
+
this.command = command;
|
|
3223
3243
|
this.designerContext = designerContext;
|
|
3224
3244
|
}
|
|
3225
3245
|
handle() {
|
|
3246
|
+
if (this.command.beforeCallback) {
|
|
3247
|
+
this.command.beforeCallback();
|
|
3248
|
+
}
|
|
3226
3249
|
this.designerContext.workspaceController.updateRootComponent();
|
|
3227
3250
|
}
|
|
3228
3251
|
}
|
|
@@ -3260,7 +3283,7 @@ class ClickBehaviorResolver {
|
|
|
3260
3283
|
case exports.ClickCommandType.selectStep:
|
|
3261
3284
|
return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
|
|
3262
3285
|
case exports.ClickCommandType.rerenderStep:
|
|
3263
|
-
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(this.context));
|
|
3286
|
+
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(commandOrNull, this.context));
|
|
3264
3287
|
case exports.ClickCommandType.openFolder:
|
|
3265
3288
|
return PressingBehavior.create(element, new OpenFolderPressingBehaviorHandler(commandOrNull, this.context));
|
|
3266
3289
|
case exports.ClickCommandType.triggerCustomAction:
|
|
@@ -3396,8 +3419,9 @@ class ContextMenuController {
|
|
|
3396
3419
|
}
|
|
3397
3420
|
|
|
3398
3421
|
class ContextMenuItemsBuilder {
|
|
3399
|
-
constructor(viewportApi, i18n, stateModifier, state, customMenuItemsProvider) {
|
|
3422
|
+
constructor(viewportApi, workspaceApi, i18n, stateModifier, state, customMenuItemsProvider) {
|
|
3400
3423
|
this.viewportApi = viewportApi;
|
|
3424
|
+
this.workspaceApi = workspaceApi;
|
|
3401
3425
|
this.i18n = i18n;
|
|
3402
3426
|
this.stateModifier = stateModifier;
|
|
3403
3427
|
this.state = state;
|
|
@@ -3456,8 +3480,9 @@ class ContextMenuItemsBuilder {
|
|
|
3456
3480
|
}
|
|
3457
3481
|
}
|
|
3458
3482
|
}
|
|
3459
|
-
else {
|
|
3460
|
-
|
|
3483
|
+
else if (!commandOrNull) {
|
|
3484
|
+
const rootSequence = this.workspaceApi.getRootSequence();
|
|
3485
|
+
this.tryAppendCustomItems(items, null, rootSequence.sequence);
|
|
3461
3486
|
}
|
|
3462
3487
|
items.push({
|
|
3463
3488
|
label: this.i18n('contextMenu.resetView', 'Reset view'),
|
|
@@ -3471,7 +3496,7 @@ class ContextMenuItemsBuilder {
|
|
|
3471
3496
|
}
|
|
3472
3497
|
tryAppendCustomItems(items, step, parentSequence) {
|
|
3473
3498
|
if (this.customMenuItemsProvider) {
|
|
3474
|
-
const customItems = this.customMenuItemsProvider.getItems(step, parentSequence);
|
|
3499
|
+
const customItems = this.customMenuItemsProvider.getItems(step, parentSequence, this.state.definition);
|
|
3475
3500
|
for (const customItem of customItems) {
|
|
3476
3501
|
items.push(customItem);
|
|
3477
3502
|
}
|
|
@@ -3562,11 +3587,11 @@ class Workspace {
|
|
|
3562
3587
|
const clickBehaviorWrapper = designerContext.services.clickBehaviorWrapperExtension.create(designerContext.customActionController);
|
|
3563
3588
|
const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
|
|
3564
3589
|
const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
|
|
3565
|
-
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3590
|
+
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.workspace, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3566
3591
|
? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
|
|
3567
3592
|
: undefined);
|
|
3568
3593
|
const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
|
|
3569
|
-
const workspace = new Workspace(view, designerContext.
|
|
3594
|
+
const workspace = new Workspace(view, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, api.workspace, designerContext.services);
|
|
3570
3595
|
setTimeout(() => {
|
|
3571
3596
|
workspace.updateRootComponent();
|
|
3572
3597
|
api.viewport.resetViewport();
|
|
@@ -3582,9 +3607,8 @@ class Workspace {
|
|
|
3582
3607
|
view.bindContextMenu(workspace.onContextMenu);
|
|
3583
3608
|
return workspace;
|
|
3584
3609
|
}
|
|
3585
|
-
constructor(view,
|
|
3610
|
+
constructor(view, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, workspaceApi, services) {
|
|
3586
3611
|
this.view = view;
|
|
3587
|
-
this.definitionWalker = definitionWalker;
|
|
3588
3612
|
this.state = state;
|
|
3589
3613
|
this.behaviorController = behaviorController;
|
|
3590
3614
|
this.wheelController = wheelController;
|
|
@@ -3593,6 +3617,7 @@ class Workspace {
|
|
|
3593
3617
|
this.clickBehaviorResolver = clickBehaviorResolver;
|
|
3594
3618
|
this.clickBehaviorWrapper = clickBehaviorWrapper;
|
|
3595
3619
|
this.viewportApi = viewportApi;
|
|
3620
|
+
this.workspaceApi = workspaceApi;
|
|
3596
3621
|
this.services = services;
|
|
3597
3622
|
this.onRendered = new SimpleEvent();
|
|
3598
3623
|
this.isValid = false;
|
|
@@ -3627,26 +3652,14 @@ class Workspace {
|
|
|
3627
3652
|
}
|
|
3628
3653
|
updateRootComponent() {
|
|
3629
3654
|
this.selectedStepComponent = null;
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
const children = this.definitionWalker.getChildren(parentSequence.step);
|
|
3636
|
-
if (!children || children.type !== sequentialWorkflowModel.StepChildrenType.sequence) {
|
|
3637
|
-
throw new Error('Cannot find single sequence in folder step');
|
|
3655
|
+
const rootSequence = this.workspaceApi.getRootSequence();
|
|
3656
|
+
const parentPlaceIndicator = rootSequence.parentStep
|
|
3657
|
+
? {
|
|
3658
|
+
sequence: rootSequence.parentStep.parentSequence,
|
|
3659
|
+
index: rootSequence.parentStep.index
|
|
3638
3660
|
}
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
sequence: parentSequence.parentSequence,
|
|
3642
|
-
index: parentSequence.index
|
|
3643
|
-
};
|
|
3644
|
-
}
|
|
3645
|
-
else {
|
|
3646
|
-
sequence = this.state.definition.sequence;
|
|
3647
|
-
parentSequencePlaceIndicator = null;
|
|
3648
|
-
}
|
|
3649
|
-
this.view.render(sequence, parentSequencePlaceIndicator);
|
|
3661
|
+
: null;
|
|
3662
|
+
this.view.render(rootSequence.sequence, parentPlaceIndicator);
|
|
3650
3663
|
this.trySelectStepComponent(this.state.selectedStepId);
|
|
3651
3664
|
this.updateBadges();
|
|
3652
3665
|
this.onRendered.forward();
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StepChildrenType, DefinitionWalker } from 'sequential-workflow-model';
|
|
2
2
|
export * from 'sequential-workflow-model';
|
|
3
3
|
|
|
4
4
|
class Dom {
|
|
@@ -767,8 +767,9 @@ class ViewportApi {
|
|
|
767
767
|
}
|
|
768
768
|
|
|
769
769
|
class WorkspaceApi {
|
|
770
|
-
constructor(state, workspaceController) {
|
|
770
|
+
constructor(state, definitionWalker, workspaceController) {
|
|
771
771
|
this.state = state;
|
|
772
|
+
this.definitionWalker = definitionWalker;
|
|
772
773
|
this.workspaceController = workspaceController;
|
|
773
774
|
}
|
|
774
775
|
getViewport() {
|
|
@@ -795,11 +796,29 @@ class WorkspaceApi {
|
|
|
795
796
|
updateCanvasSize() {
|
|
796
797
|
this.workspaceController.updateCanvasSize();
|
|
797
798
|
}
|
|
799
|
+
getRootSequence() {
|
|
800
|
+
const stepId = this.state.tryGetLastStepIdFromFolderPath();
|
|
801
|
+
if (stepId) {
|
|
802
|
+
const parentStep = this.definitionWalker.getParentSequence(this.state.definition, stepId);
|
|
803
|
+
const children = this.definitionWalker.getChildren(parentStep.step);
|
|
804
|
+
if (!children || children.type !== StepChildrenType.sequence) {
|
|
805
|
+
throw new Error('Cannot find single sequence in folder step');
|
|
806
|
+
}
|
|
807
|
+
return {
|
|
808
|
+
sequence: children.items,
|
|
809
|
+
parentStep
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
return {
|
|
813
|
+
sequence: this.state.definition.sequence,
|
|
814
|
+
parentStep: null
|
|
815
|
+
};
|
|
816
|
+
}
|
|
798
817
|
}
|
|
799
818
|
|
|
800
819
|
class DesignerApi {
|
|
801
820
|
static create(context) {
|
|
802
|
-
const workspace = new WorkspaceApi(context.state, context.workspaceController);
|
|
821
|
+
const workspace = new WorkspaceApi(context.state, context.definitionWalker, context.workspaceController);
|
|
803
822
|
const viewportController = context.services.viewportController.create(workspace);
|
|
804
823
|
const toolboxDataProvider = new ToolboxDataProvider(context.componentContext.iconProvider, context.i18n, context.configuration.toolbox);
|
|
805
824
|
return new DesignerApi(context.configuration.shadowRoot, ControlBarApi.create(context.state, context.historyController, context.stateModifier), new ToolboxApi(context.state, context, context.behaviorController, toolboxDataProvider, context.configuration.uidGenerator), new EditorApi(context.state, context.definitionWalker, context.stateModifier), workspace, new ViewportApi(context.state, context.workspaceController, viewportController), new PathBarApi(context.state, context.definitionWalker), context.definitionWalker, context.i18n);
|
|
@@ -3054,11 +3073,11 @@ class WorkspaceView {
|
|
|
3054
3073
|
this.context = context;
|
|
3055
3074
|
this.onResizeHandler = () => this.onResize();
|
|
3056
3075
|
}
|
|
3057
|
-
render(sequence,
|
|
3076
|
+
render(sequence, parentPlaceIndicator) {
|
|
3058
3077
|
if (this.rootComponent) {
|
|
3059
3078
|
this.foreground.removeChild(this.rootComponent.view.g);
|
|
3060
3079
|
}
|
|
3061
|
-
this.rootComponent = this.context.services.rootComponent.create(this.foreground, sequence,
|
|
3080
|
+
this.rootComponent = this.context.services.rootComponent.create(this.foreground, sequence, parentPlaceIndicator, this.context);
|
|
3062
3081
|
this.refreshSize();
|
|
3063
3082
|
}
|
|
3064
3083
|
setPositionAndScale(position, scale) {
|
|
@@ -3218,10 +3237,14 @@ class PressingBehavior {
|
|
|
3218
3237
|
}
|
|
3219
3238
|
|
|
3220
3239
|
class RerenderStepPressingBehaviorHandler {
|
|
3221
|
-
constructor(designerContext) {
|
|
3240
|
+
constructor(command, designerContext) {
|
|
3241
|
+
this.command = command;
|
|
3222
3242
|
this.designerContext = designerContext;
|
|
3223
3243
|
}
|
|
3224
3244
|
handle() {
|
|
3245
|
+
if (this.command.beforeCallback) {
|
|
3246
|
+
this.command.beforeCallback();
|
|
3247
|
+
}
|
|
3225
3248
|
this.designerContext.workspaceController.updateRootComponent();
|
|
3226
3249
|
}
|
|
3227
3250
|
}
|
|
@@ -3259,7 +3282,7 @@ class ClickBehaviorResolver {
|
|
|
3259
3282
|
case ClickCommandType.selectStep:
|
|
3260
3283
|
return SelectStepBehavior.create(commandOrNull.component, forceMove, this.context);
|
|
3261
3284
|
case ClickCommandType.rerenderStep:
|
|
3262
|
-
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(this.context));
|
|
3285
|
+
return PressingBehavior.create(element, new RerenderStepPressingBehaviorHandler(commandOrNull, this.context));
|
|
3263
3286
|
case ClickCommandType.openFolder:
|
|
3264
3287
|
return PressingBehavior.create(element, new OpenFolderPressingBehaviorHandler(commandOrNull, this.context));
|
|
3265
3288
|
case ClickCommandType.triggerCustomAction:
|
|
@@ -3395,8 +3418,9 @@ class ContextMenuController {
|
|
|
3395
3418
|
}
|
|
3396
3419
|
|
|
3397
3420
|
class ContextMenuItemsBuilder {
|
|
3398
|
-
constructor(viewportApi, i18n, stateModifier, state, customMenuItemsProvider) {
|
|
3421
|
+
constructor(viewportApi, workspaceApi, i18n, stateModifier, state, customMenuItemsProvider) {
|
|
3399
3422
|
this.viewportApi = viewportApi;
|
|
3423
|
+
this.workspaceApi = workspaceApi;
|
|
3400
3424
|
this.i18n = i18n;
|
|
3401
3425
|
this.stateModifier = stateModifier;
|
|
3402
3426
|
this.state = state;
|
|
@@ -3455,8 +3479,9 @@ class ContextMenuItemsBuilder {
|
|
|
3455
3479
|
}
|
|
3456
3480
|
}
|
|
3457
3481
|
}
|
|
3458
|
-
else {
|
|
3459
|
-
|
|
3482
|
+
else if (!commandOrNull) {
|
|
3483
|
+
const rootSequence = this.workspaceApi.getRootSequence();
|
|
3484
|
+
this.tryAppendCustomItems(items, null, rootSequence.sequence);
|
|
3460
3485
|
}
|
|
3461
3486
|
items.push({
|
|
3462
3487
|
label: this.i18n('contextMenu.resetView', 'Reset view'),
|
|
@@ -3470,7 +3495,7 @@ class ContextMenuItemsBuilder {
|
|
|
3470
3495
|
}
|
|
3471
3496
|
tryAppendCustomItems(items, step, parentSequence) {
|
|
3472
3497
|
if (this.customMenuItemsProvider) {
|
|
3473
|
-
const customItems = this.customMenuItemsProvider.getItems(step, parentSequence);
|
|
3498
|
+
const customItems = this.customMenuItemsProvider.getItems(step, parentSequence, this.state.definition);
|
|
3474
3499
|
for (const customItem of customItems) {
|
|
3475
3500
|
items.push(customItem);
|
|
3476
3501
|
}
|
|
@@ -3561,11 +3586,11 @@ class Workspace {
|
|
|
3561
3586
|
const clickBehaviorWrapper = designerContext.services.clickBehaviorWrapperExtension.create(designerContext.customActionController);
|
|
3562
3587
|
const wheelController = designerContext.services.wheelController.create(api.viewport, api.workspace);
|
|
3563
3588
|
const pinchToZoomController = PinchToZoomController.create(api.workspace, api.viewport, api.shadowRoot);
|
|
3564
|
-
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3589
|
+
const contextMenuItemsBuilder = new ContextMenuItemsBuilder(api.viewport, api.workspace, api.i18n, designerContext.stateModifier, designerContext.state, ((_a = designerContext.services.contextMenu) === null || _a === void 0 ? void 0 : _a.createItemsProvider)
|
|
3565
3590
|
? designerContext.services.contextMenu.createItemsProvider(designerContext.customActionController)
|
|
3566
3591
|
: undefined);
|
|
3567
3592
|
const contextMenuController = new ContextMenuController(designerContext.theme, designerContext.configuration, contextMenuItemsBuilder);
|
|
3568
|
-
const workspace = new Workspace(view, designerContext.
|
|
3593
|
+
const workspace = new Workspace(view, designerContext.state, designerContext.behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, api.viewport, api.workspace, designerContext.services);
|
|
3569
3594
|
setTimeout(() => {
|
|
3570
3595
|
workspace.updateRootComponent();
|
|
3571
3596
|
api.viewport.resetViewport();
|
|
@@ -3581,9 +3606,8 @@ class Workspace {
|
|
|
3581
3606
|
view.bindContextMenu(workspace.onContextMenu);
|
|
3582
3607
|
return workspace;
|
|
3583
3608
|
}
|
|
3584
|
-
constructor(view,
|
|
3609
|
+
constructor(view, state, behaviorController, wheelController, pinchToZoomController, contextMenuController, clickBehaviorResolver, clickBehaviorWrapper, viewportApi, workspaceApi, services) {
|
|
3585
3610
|
this.view = view;
|
|
3586
|
-
this.definitionWalker = definitionWalker;
|
|
3587
3611
|
this.state = state;
|
|
3588
3612
|
this.behaviorController = behaviorController;
|
|
3589
3613
|
this.wheelController = wheelController;
|
|
@@ -3592,6 +3616,7 @@ class Workspace {
|
|
|
3592
3616
|
this.clickBehaviorResolver = clickBehaviorResolver;
|
|
3593
3617
|
this.clickBehaviorWrapper = clickBehaviorWrapper;
|
|
3594
3618
|
this.viewportApi = viewportApi;
|
|
3619
|
+
this.workspaceApi = workspaceApi;
|
|
3595
3620
|
this.services = services;
|
|
3596
3621
|
this.onRendered = new SimpleEvent();
|
|
3597
3622
|
this.isValid = false;
|
|
@@ -3626,26 +3651,14 @@ class Workspace {
|
|
|
3626
3651
|
}
|
|
3627
3652
|
updateRootComponent() {
|
|
3628
3653
|
this.selectedStepComponent = null;
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
const children = this.definitionWalker.getChildren(parentSequence.step);
|
|
3635
|
-
if (!children || children.type !== StepChildrenType.sequence) {
|
|
3636
|
-
throw new Error('Cannot find single sequence in folder step');
|
|
3654
|
+
const rootSequence = this.workspaceApi.getRootSequence();
|
|
3655
|
+
const parentPlaceIndicator = rootSequence.parentStep
|
|
3656
|
+
? {
|
|
3657
|
+
sequence: rootSequence.parentStep.parentSequence,
|
|
3658
|
+
index: rootSequence.parentStep.index
|
|
3637
3659
|
}
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
sequence: parentSequence.parentSequence,
|
|
3641
|
-
index: parentSequence.index
|
|
3642
|
-
};
|
|
3643
|
-
}
|
|
3644
|
-
else {
|
|
3645
|
-
sequence = this.state.definition.sequence;
|
|
3646
|
-
parentSequencePlaceIndicator = null;
|
|
3647
|
-
}
|
|
3648
|
-
this.view.render(sequence, parentSequencePlaceIndicator);
|
|
3660
|
+
: null;
|
|
3661
|
+
this.view.render(rootSequence.sequence, parentPlaceIndicator);
|
|
3649
3662
|
this.trySelectStepComponent(this.state.selectedStepId);
|
|
3650
3663
|
this.updateBadges();
|
|
3651
3664
|
this.onRendered.forward();
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Definition, Step, Sequence, ComponentType, DefinitionWalker, StepOrName } from 'sequential-workflow-model';
|
|
1
|
+
import { Definition, Step, Sequence, ComponentType, DefinitionWalker, StepWithParentSequence, StepOrName } from 'sequential-workflow-model';
|
|
2
2
|
export * from 'sequential-workflow-model';
|
|
3
3
|
|
|
4
4
|
declare class Icons {
|
|
@@ -211,6 +211,7 @@ interface SelectStepClickCommand extends BaseClickCommand {
|
|
|
211
211
|
interface RerenderStepClickCommand extends BaseClickCommand {
|
|
212
212
|
type: ClickCommandType.rerenderStep;
|
|
213
213
|
step: Step;
|
|
214
|
+
beforeCallback?: () => void;
|
|
214
215
|
}
|
|
215
216
|
interface OpenFolderClickCommand extends BaseClickCommand {
|
|
216
217
|
type: ClickCommandType.openFolder;
|
|
@@ -479,8 +480,9 @@ declare class ViewportApi {
|
|
|
479
480
|
|
|
480
481
|
declare class WorkspaceApi {
|
|
481
482
|
private readonly state;
|
|
483
|
+
private readonly definitionWalker;
|
|
482
484
|
private readonly workspaceController;
|
|
483
|
-
constructor(state: DesignerState, workspaceController: WorkspaceControllerWrapper);
|
|
485
|
+
constructor(state: DesignerState, definitionWalker: DefinitionWalker, workspaceController: WorkspaceControllerWrapper);
|
|
484
486
|
getViewport(): Viewport;
|
|
485
487
|
setViewport(viewport: Viewport): void;
|
|
486
488
|
getCanvasPosition(): Vector;
|
|
@@ -489,6 +491,11 @@ declare class WorkspaceApi {
|
|
|
489
491
|
updateRootComponent(): void;
|
|
490
492
|
updateBadges(): void;
|
|
491
493
|
updateCanvasSize(): void;
|
|
494
|
+
getRootSequence(): WorkspaceRootSequence;
|
|
495
|
+
}
|
|
496
|
+
interface WorkspaceRootSequence {
|
|
497
|
+
sequence: Sequence;
|
|
498
|
+
parentStep: StepWithParentSequence | null;
|
|
492
499
|
}
|
|
493
500
|
|
|
494
501
|
declare class DesignerApi {
|
|
@@ -891,7 +898,7 @@ interface ContextMenuExtension {
|
|
|
891
898
|
createItemsProvider?: (customActionController: CustomActionController) => ContextMenuItemsProvider;
|
|
892
899
|
}
|
|
893
900
|
interface ContextMenuItemsProvider {
|
|
894
|
-
getItems(step: Step | null,
|
|
901
|
+
getItems(step: Step | null, parentSequence: Sequence, definition: Definition): ContextMenuItem[];
|
|
895
902
|
}
|
|
896
903
|
interface ContextMenuItem {
|
|
897
904
|
readonly label: string;
|
|
@@ -1367,4 +1374,4 @@ declare class Designer<TDefinition extends Definition = Definition> {
|
|
|
1367
1374
|
private getHistoryController;
|
|
1368
1375
|
}
|
|
1369
1376
|
|
|
1370
|
-
export { Attributes, Badge, BadgeExtension, BadgeView, Badges, BadgesDecorator, BadgesResult, BaseClickCommand, Behavior, BehaviorEndToken, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickBehaviorWrapper, ClickBehaviorWrapperExtension, ClickCommand, ClickCommandType, ClickDetails, Component, ComponentContext, ComponentDom, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, ControlBarApi, CustomAction, CustomActionController, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultRegionComponentViewExtension, DefaultRegionView, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerConfiguration, DefaultViewportControllerDesignerExtension, DefaultViewportControllerExtension, DefaultViewportControllerExtensionConfiguration, DefinitionChangeType, DefinitionChangedEvent, Designer, DesignerApi, DesignerConfiguration, DesignerContext, DesignerExtension, DesignerState, Dom, DraggedComponent, DraggedComponentExtension, Editor, EditorApi, EditorsConfiguration, FoundPlaceholders, Grid, GridExtension, I18n, Icons, InputView, JoinView, KeyboardAction, KeyboardConfiguration, LabelView, LineGridConfiguration, LineGridDesignerExtension, NextScale, ObjectCloner, OpenFolderClickCommand, OutputView, PathBarApi, Placeholder, PlaceholderController, PlaceholderControllerExtension, PlaceholderDirection, PlaceholderExtension, PlaceholderView, PreferenceStorage, RectPlaceholder, RectPlaceholderConfiguration, RectPlaceholderView, RegionComponentViewContentFactory, RegionComponentViewExtension, RegionView, RegionViewFactory, RerenderStepClickCommand, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepBehaviorEndToken, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, ServicesResolver, SimpleEvent, SimpleEventListener, StartStopRootComponentDesignerExtension, StartStopRootComponentExtension, StartStopRootComponentExtensionConfiguration, StartStopRootComponentViewConfiguration, StateModifierDependency, StepBadgesDecoratorExtension, StepComponent, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepExtensionResolver, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtension, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TYPE, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxApi, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, Uid, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtension, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Vector, Viewport, ViewportApi, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceApi, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, race };
|
|
1377
|
+
export { Attributes, Badge, BadgeExtension, BadgeView, Badges, BadgesDecorator, BadgesResult, BaseClickCommand, Behavior, BehaviorEndToken, CenteredViewportCalculator, ClassicWheelControllerExtension, ClickBehaviorWrapper, ClickBehaviorWrapperExtension, ClickCommand, ClickCommandType, ClickDetails, Component, ComponentContext, ComponentDom, ComponentView, ContainerStepComponentViewConfiguration, ContainerStepExtensionConfiguration, ContextMenuExtension, ContextMenuItem, ContextMenuItemsProvider, ControlBarApi, CustomAction, CustomActionController, CustomActionHandler, CustomActionHandlerContext, Daemon, DaemonExtension, DefaultRegionComponentViewExtension, DefaultRegionView, DefaultSequenceComponent, DefaultSequenceComponentView, DefaultViewportController, DefaultViewportControllerConfiguration, DefaultViewportControllerDesignerExtension, DefaultViewportControllerExtension, DefaultViewportControllerExtensionConfiguration, DefinitionChangeType, DefinitionChangedEvent, Designer, DesignerApi, DesignerConfiguration, DesignerContext, DesignerExtension, DesignerState, Dom, DraggedComponent, DraggedComponentExtension, Editor, EditorApi, EditorsConfiguration, FoundPlaceholders, Grid, GridExtension, I18n, Icons, InputView, JoinView, KeyboardAction, KeyboardConfiguration, LabelView, LineGridConfiguration, LineGridDesignerExtension, NextScale, ObjectCloner, OpenFolderClickCommand, OutputView, PathBarApi, Placeholder, PlaceholderController, PlaceholderControllerExtension, PlaceholderDirection, PlaceholderExtension, PlaceholderView, PreferenceStorage, RectPlaceholder, RectPlaceholderConfiguration, RectPlaceholderView, RegionComponentViewContentFactory, RegionComponentViewExtension, RegionView, RegionViewFactory, RerenderStepClickCommand, RootComponentExtension, RootEditorContext, RootEditorProvider, RootValidator, SelectStepBehaviorEndToken, SelectStepClickCommand, SelectedStepIdProvider, SequenceComponent, SequenceComponentExtension, SequenceContext, SequencePlaceIndicator, Services, ServicesResolver, SimpleEvent, SimpleEventListener, StartStopRootComponentDesignerExtension, StartStopRootComponentExtension, StartStopRootComponentExtensionConfiguration, StartStopRootComponentViewConfiguration, StateModifierDependency, StepBadgesDecoratorExtension, StepComponent, StepComponentView, StepComponentViewContext, StepComponentViewFactory, StepComponentViewWrapperExtension, StepContext, StepDefinition, StepDescriptionProvider, StepEditorContext, StepEditorProvider, StepExtension, StepExtensionResolver, StepIconUrlProvider, StepLabelProvider, StepValidator, StepsConfiguration, StepsDesignerExtension, StepsDesignerExtensionConfiguration, SwitchStepComponentViewConfiguration, SwitchStepExtensionConfiguration, TYPE, TaskStepComponentViewConfiguration, TaskStepExtensionConfiguration, ToolboxApi, ToolboxConfiguration, ToolboxGroupConfiguration, TriggerCustomActionClickCommand, UiComponent, UiComponentExtension, Uid, UidGenerator, UndoStack, UndoStackItem, ValidationErrorBadgeExtension, ValidationErrorBadgeExtensionConfiguration, ValidationErrorBadgeViewConfiguration, ValidatorConfiguration, Vector, Viewport, ViewportApi, ViewportController, ViewportControllerExtension, WheelController, WheelControllerExtension, WorkspaceApi, WorkspaceRootSequence, createContainerStepComponentViewFactory, createSwitchStepComponentViewFactory, createTaskStepComponentViewFactory, getAbsolutePosition, 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.
|
|
4
|
+
"version": "0.28.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|