@next-bricks/diagram 0.28.1 → 0.29.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.
Files changed (65) hide show
  1. package/dist/bricks.json +3 -3
  2. package/dist/chunks/1728.1dbc9d53.js +2 -0
  3. package/dist/chunks/1728.1dbc9d53.js.map +1 -0
  4. package/dist/chunks/1860.4fd60630.js +2 -0
  5. package/dist/chunks/1860.4fd60630.js.map +1 -0
  6. package/dist/chunks/{1972.8418a5c0.js → 1972.d6fea46c.js} +2 -2
  7. package/dist/chunks/{1972.8418a5c0.js.map → 1972.d6fea46c.js.map} +1 -1
  8. package/dist/chunks/2311.1877f3a0.js +2 -0
  9. package/dist/chunks/2311.1877f3a0.js.map +1 -0
  10. package/dist/chunks/5481.d6977dfc.js +3 -0
  11. package/dist/chunks/5481.d6977dfc.js.map +1 -0
  12. package/dist/chunks/7034.286dd8ae.js +3 -0
  13. package/dist/chunks/7034.286dd8ae.js.map +1 -0
  14. package/dist/chunks/{9591.d3a952ac.js → 9591.c5101110.js} +2 -2
  15. package/dist/chunks/{9591.d3a952ac.js.map → 9591.c5101110.js.map} +1 -1
  16. package/dist/chunks/{eo-diagram.40f64d0f.js → eo-diagram.5f32fd41.js} +2 -2
  17. package/dist/chunks/eo-diagram.5f32fd41.js.map +1 -0
  18. package/dist/chunks/eo-display-canvas.577f0b51.js +2 -0
  19. package/dist/chunks/eo-display-canvas.577f0b51.js.map +1 -0
  20. package/dist/chunks/eo-draw-canvas.cdb7565f.js +2 -0
  21. package/dist/chunks/eo-draw-canvas.cdb7565f.js.map +1 -0
  22. package/dist/chunks/main.08edb90f.js +2 -0
  23. package/dist/chunks/main.08edb90f.js.map +1 -0
  24. package/dist/examples.json +4 -4
  25. package/dist/index.6f17b5d2.js +2 -0
  26. package/dist/index.6f17b5d2.js.map +1 -0
  27. package/dist/manifest.json +108 -90
  28. package/dist/types.json +3228 -2624
  29. package/dist-types/display-canvas/index.d.ts +5 -1
  30. package/dist-types/draw-canvas/CellComponent.d.ts +3 -2
  31. package/dist-types/draw-canvas/constants.d.ts +1 -0
  32. package/dist-types/draw-canvas/index.d.ts +5 -1
  33. package/dist-types/draw-canvas/interfaces.d.ts +30 -2
  34. package/dist-types/draw-canvas/processors/asserts.d.ts +1 -0
  35. package/dist-types/draw-canvas/processors/handleMouseDown.d.ts +3 -2
  36. package/dist-types/draw-canvas/processors/updateCells.d.ts +3 -2
  37. package/dist-types/shared/canvas/useAutoCenter.d.ts +2 -1
  38. package/dist-types/shared/canvas/useLayout.d.ts +19 -0
  39. package/dist-types/shared/canvas/useReady.d.ts +7 -0
  40. package/docs/eo-display-canvas.md +276 -0
  41. package/docs/eo-draw-canvas.md +770 -0
  42. package/package.json +2 -2
  43. package/dist/chunks/1728.8cc54faa.js +0 -2
  44. package/dist/chunks/1728.8cc54faa.js.map +0 -1
  45. package/dist/chunks/4456.3fd8ee7c.js +0 -2
  46. package/dist/chunks/4456.3fd8ee7c.js.map +0 -1
  47. package/dist/chunks/5816.f6e1a89e.js +0 -3
  48. package/dist/chunks/5816.f6e1a89e.js.map +0 -1
  49. package/dist/chunks/730.3f786ebf.js +0 -3
  50. package/dist/chunks/730.3f786ebf.js.map +0 -1
  51. package/dist/chunks/8304.613a484c.js +0 -2
  52. package/dist/chunks/8304.613a484c.js.map +0 -1
  53. package/dist/chunks/9061.cbb65689.js +0 -2
  54. package/dist/chunks/9061.cbb65689.js.map +0 -1
  55. package/dist/chunks/eo-diagram.40f64d0f.js.map +0 -1
  56. package/dist/chunks/eo-display-canvas.ab282773.js +0 -2
  57. package/dist/chunks/eo-display-canvas.ab282773.js.map +0 -1
  58. package/dist/chunks/eo-draw-canvas.ef0d61bd.js +0 -2
  59. package/dist/chunks/eo-draw-canvas.ef0d61bd.js.map +0 -1
  60. package/dist/chunks/main.660ee53e.js +0 -2
  61. package/dist/chunks/main.660ee53e.js.map +0 -1
  62. package/dist/index.3e204276.js +0 -2
  63. package/dist/index.3e204276.js.map +0 -1
  64. /package/dist/chunks/{5816.f6e1a89e.js.LICENSE.txt → 5481.d6977dfc.js.LICENSE.txt} +0 -0
  65. /package/dist/chunks/{730.3f786ebf.js.LICENSE.txt → 7034.286dd8ae.js.LICENSE.txt} +0 -0
@@ -395,3 +395,773 @@
395
395
  - source: <% EVENT.detail.source.id %>
396
396
  target: <% EVENT.detail.target.id %>
397
397
  ```
398
+
399
+ ### Force layout
400
+
401
+ ```yaml preview minHeight="600px"
402
+ - brick: div
403
+ properties:
404
+ style:
405
+ display: flex
406
+ height: 600px
407
+ gap: 1em
408
+ context:
409
+ - name: initialCells
410
+ value: |
411
+ <%
412
+ [
413
+ {
414
+ type: "decorator",
415
+ id: "area-1",
416
+ decorator: "area",
417
+ view: {
418
+ x: 10,
419
+ y: 20,
420
+ width: 400,
421
+ height: 300,
422
+ },
423
+ },
424
+ {
425
+ type: "edge",
426
+ source: "X",
427
+ target: "Y",
428
+ },
429
+ {
430
+ type: "edge",
431
+ source: "X",
432
+ target: "Z",
433
+ data: {
434
+ virtual: true,
435
+ }
436
+ },
437
+ ].concat(
438
+ ["X", "Y", "Z", "W"].map((id) => ({
439
+ type: "node",
440
+ id,
441
+ data: {
442
+ name: `Node ${id}`,
443
+ },
444
+ view: {
445
+ width: 60,
446
+ height: 60,
447
+ }
448
+ }))
449
+ ).concat([
450
+ {
451
+ type: "decorator",
452
+ id: "text-1",
453
+ decorator: "text",
454
+ view: {
455
+ x: 100,
456
+ y: 120,
457
+ width: 100,
458
+ height: 20,
459
+ text: "Hello!"
460
+ },
461
+ },
462
+ ])
463
+ %>
464
+ - name: dragging
465
+ - name: activeTarget
466
+ - name: targetCell
467
+ - name: scale
468
+ value: 1
469
+ children:
470
+ - brick: div
471
+ properties:
472
+ style:
473
+ width: 180px
474
+ display: flex
475
+ flexDirection: column
476
+ gap: 1em
477
+ children:
478
+ - brick: eo-button
479
+ properties:
480
+ textContent: Add random nodes
481
+ events:
482
+ click:
483
+ target: eo-draw-canvas
484
+ method: addNodes
485
+ args:
486
+ - |
487
+ <%
488
+ ((...seeds) => seeds.map((seed) => ({
489
+ id: seed,
490
+ data: {
491
+ name: String(seed),
492
+ },
493
+ })))(
494
+ Math.round(Math.random() * 1e6),
495
+ Math.round(Math.random() * 1e6),
496
+ Math.round(Math.random() * 1e6),
497
+ )
498
+ %>
499
+ callback:
500
+ success:
501
+ action: console.log
502
+ args:
503
+ - Added nodes
504
+ - <% EVENT.detail %>
505
+ - brick: eo-button
506
+ properties:
507
+ textContent: "Add edge: Y => Z"
508
+ events:
509
+ click:
510
+ target: eo-draw-canvas
511
+ method: addEdge
512
+ args:
513
+ - source: Y
514
+ target: Z
515
+ data:
516
+ virtual: true
517
+ - brick: :forEach
518
+ dataSource:
519
+ - X
520
+ - Y
521
+ children:
522
+ - brick: eo-button
523
+ properties:
524
+ textContent: <% `Add nodes below ${ITEM}` %>
525
+ events:
526
+ click:
527
+ target: eo-draw-canvas
528
+ method: updateCells
529
+ args:
530
+ - |
531
+ <%
532
+ CTX.initialCells.concat([
533
+ {
534
+ type: "edge",
535
+ source: ITEM,
536
+ target: "U",
537
+ },
538
+ {
539
+ type: "edge",
540
+ source: ITEM,
541
+ target: "V",
542
+ },
543
+ {
544
+ type: "node",
545
+ id: "U",
546
+ data: {
547
+ name: "U"
548
+ }
549
+ },
550
+ {
551
+ type: "node",
552
+ id: "V",
553
+ data: {
554
+ name: "V"
555
+ }
556
+ },
557
+ ])
558
+ %>
559
+ - reason: add-related-nodes
560
+ parent: <% ITEM %>
561
+ callback:
562
+ success:
563
+ action: console.log
564
+ - brick: hr
565
+ properties:
566
+ style:
567
+ width: 100%
568
+ - brick: h3
569
+ properties:
570
+ textContent: Drag nodes below
571
+ - brick: :forEach
572
+ dataSource: |
573
+ <%
574
+ ["A", "B", "C"].map((id) => ({
575
+ type: "node",
576
+ id,
577
+ data: {
578
+ name: `Node ${id}`,
579
+ },
580
+ }))
581
+ %>
582
+ children:
583
+ - brick: diagram.experimental-node
584
+ properties:
585
+ textContent: <% ITEM.data.name %>
586
+ usage: library
587
+ events:
588
+ drag.move:
589
+ action: context.replace
590
+ args:
591
+ - dragging
592
+ - |
593
+ <% {position: EVENT.detail, ...ITEM} %>
594
+ drag.end:
595
+ - action: context.replace
596
+ args:
597
+ - dragging
598
+ - null
599
+ - target: eo-draw-canvas
600
+ method: dropNode
601
+ args:
602
+ - position: <% EVENT.detail %>
603
+ id: <% ITEM.id %>
604
+ data: <% ITEM.data %>
605
+ callback:
606
+ success:
607
+ if: <% EVENT.detail %>
608
+ then:
609
+ action: message.success
610
+ args:
611
+ - <% JSON.stringify(EVENT.detail) %>
612
+ else:
613
+ action: message.warn
614
+ args:
615
+ - Unexpected drop position
616
+ - brick: hr
617
+ properties:
618
+ style:
619
+ width: 100%
620
+ - brick: h3
621
+ properties:
622
+ textContent: Drag decorators below
623
+ - brick: :forEach
624
+ dataSource:
625
+ - area
626
+ - text
627
+ children:
628
+ - brick: diagram.experimental-node
629
+ properties:
630
+ textContent: <% _.upperFirst(ITEM) %>
631
+ usage: library
632
+ events:
633
+ drag.move:
634
+ action: context.replace
635
+ args:
636
+ - dragging
637
+ - |
638
+ <% {position: EVENT.detail, type: "decorator", decorator: ITEM} %>
639
+ drag.end:
640
+ - action: context.replace
641
+ args:
642
+ - dragging
643
+ - null
644
+ - target: eo-draw-canvas
645
+ method: dropDecorator
646
+ args:
647
+ - position: <% EVENT.detail %>
648
+ decorator: <% ITEM %>
649
+ text: '<% ITEM === "text" ? "Text" : undefined %>'
650
+ callback:
651
+ success:
652
+ if: <% EVENT.detail %>
653
+ then:
654
+ # action: message.success
655
+ # args:
656
+ # - <% JSON.stringify(EVENT.detail) %>
657
+ else:
658
+ action: message.warn
659
+ args:
660
+ - Unexpected drop position
661
+ - brick: div
662
+ properties:
663
+ style:
664
+ flex: 1
665
+ minWidth: 0
666
+ children:
667
+ - brick: eo-draw-canvas
668
+ properties:
669
+ style:
670
+ width: 100%
671
+ height: 100%
672
+ activeTarget: <%= CTX.activeTarget %>
673
+ fadeUnrelatedCells: true
674
+ layout: force
675
+ # Initial nodes only
676
+ defaultNodeSize: [60, 60]
677
+ defaultNodeBricks:
678
+ - useBrick:
679
+ brick: diagram.experimental-node
680
+ properties:
681
+ textContent: <% `Node ${DATA.node.id}` %>
682
+ status: |
683
+ <%=
684
+ CTX.activeTarget?.type === "node" && CTX.activeTarget.id === DATA.node.id
685
+ ? "highlighted"
686
+ // : CTX.unrelated.some(n =>
687
+ // n.type === "node" && n.id === DATA.node.id
688
+ // )
689
+ // ? "faded"
690
+ : "default"
691
+ %>
692
+ defaultEdgeLines:
693
+ - if: <% DATA.edge.data?.virtual %>
694
+ dashed: true
695
+ cells: <% CTX.initialCells %>
696
+ events:
697
+ activeTarget.change:
698
+ action: context.replace
699
+ args:
700
+ - activeTarget
701
+ - <% EVENT.detail %>
702
+ cell.move:
703
+ action: message.info
704
+ args:
705
+ - <% `You just moved ${EVENT.detail.type} ${EVENT.detail.id} to (${Math.round(EVENT.detail.x)}, ${Math.round(EVENT.detail.y)})` %>
706
+ cell.resize:
707
+ action: message.info
708
+ args:
709
+ - <% `You just resized ${EVENT.detail.type} ${EVENT.detail.id} to (${Math.round(EVENT.detail.width)}, ${Math.round(EVENT.detail.height)})` %>
710
+ cell.delete:
711
+ action: message.warn
712
+ args:
713
+ - |
714
+ <% `You wanna delete ${EVENT.detail.type} ${EVENT.detail.type === "edge" ? `(${EVENT.detail.source} => ${EVENT.detail.target})` : EVENT.detail.id}?` %>
715
+ cell.contextmenu:
716
+ - target: eo-context-menu
717
+ method: open
718
+ args:
719
+ - position:
720
+ - <% EVENT.detail.clientX %>
721
+ - <% EVENT.detail.clientY %>
722
+ - action: context.replace
723
+ args:
724
+ - targetCell
725
+ - <% EVENT.detail.cell %>
726
+ decorator.text.change:
727
+ action: message.info
728
+ args:
729
+ - <% JSON.stringify(EVENT.detail) %>
730
+ scale.change:
731
+ action: context.replace
732
+ args:
733
+ - scale
734
+ - <% EVENT.detail %>
735
+ - brick: diagram.experimental-node
736
+ properties:
737
+ usage: dragging
738
+ textContent: |
739
+ <%= CTX.dragging?.type === "decorator" ? (CTX.dragging.decorator === "text" ? "Text" : null) : CTX.dragging?.data.name %>
740
+ decorator: |
741
+ <%= CTX.dragging?.type === "decorator" ? CTX.dragging.decorator : null %>
742
+ style: |
743
+ <%=
744
+ {
745
+ left: `${CTX.dragging?.position[0]}px`,
746
+ top: `${CTX.dragging?.position[1]}px`,
747
+ transform: `scale(${CTX.scale})`,
748
+ transformOrigin: "0 0",
749
+ padding: CTX.dragging?.decorator === "text" ? "0.5em" : "0"
750
+ }
751
+ %>
752
+ hidden: <%= !CTX.dragging %>
753
+ - brick: eo-context-menu
754
+ properties:
755
+ actions: |
756
+ <%=
757
+ CTX.targetCell?.type === "node" ? [
758
+ {
759
+ text: "添加边",
760
+ event: "add-edge",
761
+ }
762
+ ] : [
763
+ {
764
+ text: `Test ${CTX.targetCell?.type}`,
765
+ event: `test-${CTX.targetCell?.type}`,
766
+ }
767
+ ]
768
+ %>
769
+ events:
770
+ add-edge:
771
+ target: eo-draw-canvas
772
+ method: manuallyConnectNodes
773
+ args:
774
+ - <% CTX.targetCell.id %>
775
+ callback:
776
+ success:
777
+ target: eo-draw-canvas
778
+ method: addEdge
779
+ args:
780
+ - source: <% EVENT.detail.source.id %>
781
+ target: <% EVENT.detail.target.id %>
782
+ ```
783
+
784
+ ### Dagre layout
785
+
786
+ ```yaml preview minHeight="600px"
787
+ - brick: div
788
+ properties:
789
+ style:
790
+ display: flex
791
+ height: 600px
792
+ gap: 1em
793
+ context:
794
+ - name: initialCells
795
+ value: |
796
+ <%
797
+ [
798
+ {
799
+ type: "decorator",
800
+ id: "area-1",
801
+ decorator: "area",
802
+ view: {
803
+ x: 10,
804
+ y: 20,
805
+ width: 400,
806
+ height: 300,
807
+ },
808
+ },
809
+ {
810
+ type: "edge",
811
+ source: "X",
812
+ target: "Y",
813
+ },
814
+ {
815
+ type: "edge",
816
+ source: "X",
817
+ target: "Z",
818
+ data: {
819
+ virtual: true,
820
+ }
821
+ },
822
+ ].concat(
823
+ ["X", "Y", "Z", "W"].map((id) => ({
824
+ type: "node",
825
+ id,
826
+ data: {
827
+ name: `Node ${id}`,
828
+ },
829
+ view: {
830
+ width: 60,
831
+ height: 60,
832
+ }
833
+ }))
834
+ ).concat([
835
+ {
836
+ type: "decorator",
837
+ id: "text-1",
838
+ decorator: "text",
839
+ view: {
840
+ x: 100,
841
+ y: 120,
842
+ width: 100,
843
+ height: 20,
844
+ text: "Hello!"
845
+ },
846
+ },
847
+ ])
848
+ %>
849
+ - name: dragging
850
+ - name: activeTarget
851
+ - name: targetCell
852
+ - name: scale
853
+ value: 1
854
+ children:
855
+ - brick: div
856
+ properties:
857
+ style:
858
+ width: 180px
859
+ display: flex
860
+ flexDirection: column
861
+ gap: 1em
862
+ children:
863
+ - brick: eo-button
864
+ properties:
865
+ textContent: Add random nodes
866
+ events:
867
+ click:
868
+ target: eo-draw-canvas
869
+ method: addNodes
870
+ args:
871
+ - |
872
+ <%
873
+ ((...seeds) => seeds.map((seed) => ({
874
+ id: seed,
875
+ data: {
876
+ name: String(seed),
877
+ },
878
+ })))(
879
+ Math.round(Math.random() * 1e6),
880
+ Math.round(Math.random() * 1e6),
881
+ Math.round(Math.random() * 1e6),
882
+ )
883
+ %>
884
+ callback:
885
+ success:
886
+ action: console.log
887
+ args:
888
+ - Added nodes
889
+ - <% EVENT.detail %>
890
+ - brick: eo-button
891
+ properties:
892
+ textContent: "Add edge: Y => Z"
893
+ events:
894
+ click:
895
+ target: eo-draw-canvas
896
+ method: addEdge
897
+ args:
898
+ - source: Y
899
+ target: Z
900
+ data:
901
+ virtual: true
902
+ - brick: :forEach
903
+ dataSource:
904
+ - X
905
+ - Y
906
+ children:
907
+ - brick: eo-button
908
+ properties:
909
+ textContent: <% `Add nodes below ${ITEM}` %>
910
+ events:
911
+ click:
912
+ target: eo-draw-canvas
913
+ method: updateCells
914
+ args:
915
+ - |
916
+ <%
917
+ CTX.initialCells.concat([
918
+ {
919
+ type: "edge",
920
+ source: ITEM,
921
+ target: "U",
922
+ },
923
+ {
924
+ type: "edge",
925
+ source: ITEM,
926
+ target: "V",
927
+ },
928
+ {
929
+ type: "node",
930
+ id: "U",
931
+ data: {
932
+ name: "U"
933
+ }
934
+ },
935
+ {
936
+ type: "node",
937
+ id: "V",
938
+ data: {
939
+ name: "V"
940
+ }
941
+ },
942
+ ])
943
+ %>
944
+ - reason: add-related-nodes
945
+ parent: <% ITEM %>
946
+ callback:
947
+ success:
948
+ action: console.log
949
+ - brick: hr
950
+ properties:
951
+ style:
952
+ width: 100%
953
+ - brick: h3
954
+ properties:
955
+ textContent: Drag nodes below
956
+ - brick: :forEach
957
+ dataSource: |
958
+ <%
959
+ ["A", "B", "C"].map((id) => ({
960
+ type: "node",
961
+ id,
962
+ data: {
963
+ name: `Node ${id}`,
964
+ },
965
+ }))
966
+ %>
967
+ children:
968
+ - brick: diagram.experimental-node
969
+ properties:
970
+ textContent: <% ITEM.data.name %>
971
+ usage: library
972
+ events:
973
+ drag.move:
974
+ action: context.replace
975
+ args:
976
+ - dragging
977
+ - |
978
+ <% {position: EVENT.detail, ...ITEM} %>
979
+ drag.end:
980
+ - action: context.replace
981
+ args:
982
+ - dragging
983
+ - null
984
+ - target: eo-draw-canvas
985
+ method: dropNode
986
+ args:
987
+ - position: <% EVENT.detail %>
988
+ id: <% ITEM.id %>
989
+ data: <% ITEM.data %>
990
+ callback:
991
+ success:
992
+ if: <% EVENT.detail %>
993
+ then:
994
+ action: message.success
995
+ args:
996
+ - <% JSON.stringify(EVENT.detail) %>
997
+ else:
998
+ action: message.warn
999
+ args:
1000
+ - Unexpected drop position
1001
+ - brick: hr
1002
+ properties:
1003
+ style:
1004
+ width: 100%
1005
+ - brick: h3
1006
+ properties:
1007
+ textContent: Drag decorators below
1008
+ - brick: :forEach
1009
+ dataSource:
1010
+ - area
1011
+ - text
1012
+ children:
1013
+ - brick: diagram.experimental-node
1014
+ properties:
1015
+ textContent: <% _.upperFirst(ITEM) %>
1016
+ usage: library
1017
+ events:
1018
+ drag.move:
1019
+ action: context.replace
1020
+ args:
1021
+ - dragging
1022
+ - |
1023
+ <% {position: EVENT.detail, type: "decorator", decorator: ITEM} %>
1024
+ drag.end:
1025
+ - action: context.replace
1026
+ args:
1027
+ - dragging
1028
+ - null
1029
+ - target: eo-draw-canvas
1030
+ method: dropDecorator
1031
+ args:
1032
+ - position: <% EVENT.detail %>
1033
+ decorator: <% ITEM %>
1034
+ text: '<% ITEM === "text" ? "Text" : undefined %>'
1035
+ callback:
1036
+ success:
1037
+ if: <% EVENT.detail %>
1038
+ then:
1039
+ # action: message.success
1040
+ # args:
1041
+ # - <% JSON.stringify(EVENT.detail) %>
1042
+ else:
1043
+ action: message.warn
1044
+ args:
1045
+ - Unexpected drop position
1046
+ - brick: div
1047
+ properties:
1048
+ style:
1049
+ flex: 1
1050
+ minWidth: 0
1051
+ children:
1052
+ - brick: eo-draw-canvas
1053
+ properties:
1054
+ style:
1055
+ width: 100%
1056
+ height: 100%
1057
+ activeTarget: <%= CTX.activeTarget %>
1058
+ fadeUnrelatedCells: true
1059
+ layout: dagre
1060
+ # Initial nodes only
1061
+ defaultNodeSize: [60, 60]
1062
+ defaultNodeBricks:
1063
+ - useBrick:
1064
+ brick: diagram.experimental-node
1065
+ properties:
1066
+ textContent: <% `Node ${DATA.node.id}` %>
1067
+ status: |
1068
+ <%=
1069
+ CTX.activeTarget?.type === "node" && CTX.activeTarget.id === DATA.node.id
1070
+ ? "highlighted"
1071
+ // : CTX.unrelated.some(n =>
1072
+ // n.type === "node" && n.id === DATA.node.id
1073
+ // )
1074
+ // ? "faded"
1075
+ : "default"
1076
+ %>
1077
+ defaultEdgeLines:
1078
+ - if: <% DATA.edge.data?.virtual %>
1079
+ dashed: true
1080
+ cells: <% CTX.initialCells %>
1081
+ events:
1082
+ activeTarget.change:
1083
+ action: context.replace
1084
+ args:
1085
+ - activeTarget
1086
+ - <% EVENT.detail %>
1087
+ cell.move:
1088
+ action: message.info
1089
+ args:
1090
+ - <% `You just moved ${EVENT.detail.type} ${EVENT.detail.id} to (${Math.round(EVENT.detail.x)}, ${Math.round(EVENT.detail.y)})` %>
1091
+ cell.resize:
1092
+ action: message.info
1093
+ args:
1094
+ - <% `You just resized ${EVENT.detail.type} ${EVENT.detail.id} to (${Math.round(EVENT.detail.width)}, ${Math.round(EVENT.detail.height)})` %>
1095
+ cell.delete:
1096
+ action: message.warn
1097
+ args:
1098
+ - |
1099
+ <% `You wanna delete ${EVENT.detail.type} ${EVENT.detail.type === "edge" ? `(${EVENT.detail.source} => ${EVENT.detail.target})` : EVENT.detail.id}?` %>
1100
+ cell.contextmenu:
1101
+ - target: eo-context-menu
1102
+ method: open
1103
+ args:
1104
+ - position:
1105
+ - <% EVENT.detail.clientX %>
1106
+ - <% EVENT.detail.clientY %>
1107
+ - action: context.replace
1108
+ args:
1109
+ - targetCell
1110
+ - <% EVENT.detail.cell %>
1111
+ decorator.text.change:
1112
+ action: message.info
1113
+ args:
1114
+ - <% JSON.stringify(EVENT.detail) %>
1115
+ scale.change:
1116
+ action: context.replace
1117
+ args:
1118
+ - scale
1119
+ - <% EVENT.detail %>
1120
+ - brick: diagram.experimental-node
1121
+ properties:
1122
+ usage: dragging
1123
+ textContent: |
1124
+ <%= CTX.dragging?.type === "decorator" ? (CTX.dragging.decorator === "text" ? "Text" : null) : CTX.dragging?.data.name %>
1125
+ decorator: |
1126
+ <%= CTX.dragging?.type === "decorator" ? CTX.dragging.decorator : null %>
1127
+ style: |
1128
+ <%=
1129
+ {
1130
+ left: `${CTX.dragging?.position[0]}px`,
1131
+ top: `${CTX.dragging?.position[1]}px`,
1132
+ transform: `scale(${CTX.scale})`,
1133
+ transformOrigin: "0 0",
1134
+ padding: CTX.dragging?.decorator === "text" ? "0.5em" : "0"
1135
+ }
1136
+ %>
1137
+ hidden: <%= !CTX.dragging %>
1138
+ - brick: eo-context-menu
1139
+ properties:
1140
+ actions: |
1141
+ <%=
1142
+ CTX.targetCell?.type === "node" ? [
1143
+ {
1144
+ text: "添加边",
1145
+ event: "add-edge",
1146
+ }
1147
+ ] : [
1148
+ {
1149
+ text: `Test ${CTX.targetCell?.type}`,
1150
+ event: `test-${CTX.targetCell?.type}`,
1151
+ }
1152
+ ]
1153
+ %>
1154
+ events:
1155
+ add-edge:
1156
+ target: eo-draw-canvas
1157
+ method: manuallyConnectNodes
1158
+ args:
1159
+ - <% CTX.targetCell.id %>
1160
+ callback:
1161
+ success:
1162
+ target: eo-draw-canvas
1163
+ method: addEdge
1164
+ args:
1165
+ - source: <% EVENT.detail.source.id %>
1166
+ target: <% EVENT.detail.target.id %>
1167
+ ```