@flowgram.ai/renderer 0.1.0-alpha.3 → 0.1.0-alpha.31

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/dist/index.js CHANGED
@@ -36,8 +36,8 @@ var __decorateClass = (decorators, target, key, kind) => {
36
36
  };
37
37
 
38
38
  // src/index.ts
39
- var src_exports = {};
40
- __export(src_exports, {
39
+ var index_exports = {};
40
+ __export(index_exports, {
41
41
  FlowContextMenuLayer: () => FlowContextMenuLayer,
42
42
  FlowDebugLayer: () => FlowDebugLayer,
43
43
  FlowDragEntity: () => FlowDragEntity,
@@ -62,14 +62,15 @@ __export(src_exports, {
62
62
  MARK_ARROW_ID: () => MARK_ARROW_ID,
63
63
  ScrollBarEvents: () => ScrollBarEvents,
64
64
  SelectorBoxConfigEntity: () => SelectorBoxConfigEntity,
65
+ createLines: () => createLines,
65
66
  useBaseColor: () => useBaseColor
66
67
  });
67
- module.exports = __toCommonJS(src_exports);
68
+ module.exports = __toCommonJS(index_exports);
68
69
 
69
70
  // src/entities/flow-drag-entity.tsx
71
+ var import_utils = require("@flowgram.ai/utils");
70
72
  var import_document3 = require("@flowgram.ai/document");
71
73
  var import_core2 = require("@flowgram.ai/core");
72
- var import_utils = require("@flowgram.ai/utils");
73
74
 
74
75
  // src/components/utils.tsx
75
76
  var import_document2 = require("@flowgram.ai/document");
@@ -94,7 +95,7 @@ var DEFAULT_LINE_ATTRS = {
94
95
  strokeLinecap: "round",
95
96
  strokeLinejoin: "round"
96
97
  };
97
- var DEFAULT_RADIUS = 16;
98
+ var DEFAULT_RADIUS = import_document2.DEFAULT_SPACING[import_document2.DefaultSpacingKey.ROUNDED_LINE_RADIUS];
98
99
  var DEFAULT_LABEL_ACTIVATE_HEIGHT = 32;
99
100
  function getHorizontalVertices(line, xRadius = 16, yRadius = 20) {
100
101
  const { from, to, type } = line || {};
@@ -388,7 +389,6 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
388
389
  } else {
389
390
  this.containerX -= SCROLL_DELTA;
390
391
  }
391
- this.setDomStyle();
392
392
  }
393
393
  }, SCROLL_INTERVAL);
394
394
  this._scrollXInterval = { interval, origin };
@@ -417,7 +417,6 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
417
417
  } else {
418
418
  this.containerY -= SCROLL_DELTA;
419
419
  }
420
- this.setDomStyle();
421
420
  }
422
421
  }, SCROLL_INTERVAL);
423
422
  this._scrollYInterval = { interval, origin };
@@ -432,34 +431,30 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
432
431
  this._stopScrollX();
433
432
  this._stopScrollY();
434
433
  }
435
- setDomStyle() {
436
- this.containerDom.style.left = `${this.containerX}px`;
437
- this.containerDom.style.top = `${this.containerY}px`;
438
- }
439
- scrollDirection(e, containerDom, x, y) {
434
+ scrollDirection(e, x, y) {
440
435
  const playgroundConfig = this.playgroundConfigEntity.config;
441
436
  const currentScrollX = playgroundConfig.scrollX;
442
437
  const currentScrollY = playgroundConfig.scrollY;
443
- this.containerDom = containerDom;
444
438
  this.containerX = x;
445
439
  this.containerY = y;
446
- const mouseToBottom = playgroundConfig.height + playgroundConfig.clientY - e.clientY;
440
+ const clientRect = this.playgroundConfigEntity.playgroundDomNode.getBoundingClientRect();
441
+ const mouseToBottom = playgroundConfig.height + clientRect.y - e.clientY;
447
442
  if (mouseToBottom < SCROLL_BOUNDING) {
448
443
  this._startScrollY(currentScrollY, true);
449
444
  return 1 /* BOTTOM */;
450
445
  }
451
- const mouseToTop = e.clientY - playgroundConfig.clientY;
446
+ const mouseToTop = e.clientY - clientRect.y;
452
447
  if (mouseToTop < SCROLL_BOUNDING) {
453
448
  this._startScrollY(currentScrollY, false);
454
449
  return 0 /* TOP */;
455
450
  }
456
451
  this._stopScrollY();
457
- const mouseToRight = playgroundConfig.width + playgroundConfig.clientX - e.clientX;
452
+ const mouseToRight = playgroundConfig.width + clientRect.x - e.clientX;
458
453
  if (mouseToRight < SCROLL_BOUNDING) {
459
454
  this._startScrollX(currentScrollX, true);
460
455
  return 3 /* RIGHT */;
461
456
  }
462
- const mouseToLeft = e.clientX - playgroundConfig.clientX;
457
+ const mouseToLeft = e.clientX - clientRect.x;
463
458
  if (mouseToLeft < SCROLL_BOUNDING + EDITOR_LEFT_BAR_WIDTH) {
464
459
  this._startScrollX(currentScrollX, false);
465
460
  return 2 /* LEFT */;
@@ -479,7 +474,7 @@ var import_core3 = require("@flowgram.ai/core");
479
474
  var import_utils3 = require("@flowgram.ai/utils");
480
475
 
481
476
  // src/utils/find-selected-nodes.ts
482
- var import_lodash = require("lodash");
477
+ var import_lodash_es = require("lodash-es");
483
478
  function getNodePath(node) {
484
479
  const path = [node];
485
480
  node = node.parent;
@@ -502,13 +497,13 @@ function findSelectedNodes(nodes) {
502
497
  let index = 0;
503
498
  let selectedItems = [];
504
499
  while (index < minLength) {
505
- selectedItems = (0, import_lodash.uniq)(nodePathList.map((p) => p[index]));
500
+ selectedItems = (0, import_lodash_es.uniq)(nodePathList.map((p) => p[index]));
506
501
  if (selectedItems.length > 1) {
507
502
  break;
508
503
  }
509
504
  index += 1;
510
505
  }
511
- return (0, import_lodash.uniq)(selectedItems.map((item) => findRealEntity(item)));
506
+ return (0, import_lodash_es.uniq)(selectedItems.map((item) => findRealEntity(item)));
512
507
  }
513
508
 
514
509
  // src/entities/flow-select-config-entity.tsx
@@ -665,10 +660,16 @@ var import_inversify = require("inversify");
665
660
  var import_utils5 = require("@flowgram.ai/utils");
666
661
 
667
662
  // src/utils/element.ts
668
- var import_lodash2 = require("lodash");
663
+ var import_lodash_es2 = require("lodash-es");
669
664
  var isHidden = (dom) => {
665
+ if (!dom || (0, import_lodash_es2.isNil)(dom?.offsetParent)) {
666
+ return true;
667
+ }
670
668
  const style = window.getComputedStyle(dom);
671
- return (0, import_lodash2.isNil)(dom?.offsetParent) || style?.display === "none";
669
+ if (style?.display === "none") {
670
+ return true;
671
+ }
672
+ return false;
672
673
  };
673
674
  var isRectInit = (rect) => {
674
675
  if (!rect) {
@@ -737,7 +738,9 @@ var FlowNodesTransformLayer = class extends import_core5.Layer {
737
738
  const append = () => {
738
739
  if (resizeDispose) return;
739
740
  this.renderElement.appendChild(node);
740
- resizeDispose = this.resizeObserver.observe(node, transform);
741
+ if (!entity.getNodeMeta().autoResizeDisable) {
742
+ resizeDispose = this.resizeObserver.observe(node, transform);
743
+ }
741
744
  };
742
745
  const dispose = () => {
743
746
  if (!resizeDispose) return;
@@ -752,7 +755,9 @@ var FlowNodesTransformLayer = class extends import_core5.Layer {
752
755
  dispose,
753
756
  updateBounds: () => {
754
757
  const { bounds } = transform;
755
- if (node.style.left !== `${bounds.x}px` || node.style.top !== `${bounds.y}px`) {
758
+ const rawX = parseFloat(node.style.left);
759
+ const rawY = parseFloat(node.style.top);
760
+ if (!this.isCoordEqual(rawX, bounds.x) || !this.isCoordEqual(rawY, bounds.y)) {
756
761
  node.style.left = `${bounds.x}px`;
757
762
  node.style.top = `${bounds.y}px`;
758
763
  }
@@ -775,6 +780,10 @@ var FlowNodesTransformLayer = class extends import_core5.Layer {
775
780
  this.renderCache.dispose();
776
781
  super.dispose();
777
782
  }
783
+ isCoordEqual(a, b) {
784
+ const browserCoordEpsilon = 0.05;
785
+ return Math.abs(a - b) < browserCoordEpsilon;
786
+ }
778
787
  onReady() {
779
788
  this.node.style.zIndex = "10";
780
789
  }
@@ -856,6 +865,10 @@ var FlowRendererKey = /* @__PURE__ */ ((FlowRendererKey2) => {
856
865
  FlowRendererKey2["SELECTOR_BOX_POPOVER"] = "selector-box-popover";
857
866
  FlowRendererKey2["CONTEXT_MENU_POPOVER"] = "context-menu-popover";
858
867
  FlowRendererKey2["SUB_CANVAS"] = "sub-canvas";
868
+ FlowRendererKey2["SLOT_ADDER"] = "slot-adder";
869
+ FlowRendererKey2["SLOT_LABEL"] = "slot-label";
870
+ FlowRendererKey2["SLOT_COLLAPSE"] = "slot-collapse";
871
+ FlowRendererKey2["ARROW_RENDERER"] = "arrow-renderer";
859
872
  FlowRendererKey2["MARKER_ARROW"] = "marker-arrow";
860
873
  FlowRendererKey2["MARKER_ACTIVATE_ARROW"] = "marker-active-arrow";
861
874
  return FlowRendererKey2;
@@ -903,7 +916,7 @@ var FlowRendererRegistry = class {
903
916
  });
904
917
  }
905
918
  getText(textKey) {
906
- return import_i18n.I18n.t(textKey, { disableReturnKey: true }) || this.textMap.get(textKey);
919
+ return import_i18n.I18n.t(textKey, { defaultValue: "" }) || this.textMap.get(textKey);
907
920
  }
908
921
  /**
909
922
  * TODO: support memo
@@ -957,7 +970,7 @@ var FlowNodesContentLayer = class extends import_core7.Layer {
957
970
  const PortalRenderer = this.getPortalRenderer(data);
958
971
  function Portal() {
959
972
  import_react.default.useEffect(() => {
960
- if (node.clientWidth && node.clientHeight) {
973
+ if (!entity.getNodeMeta().autoResizeDisable && node.clientWidth && node.clientHeight) {
961
974
  const transform = entity.getData(import_document6.FlowNodeTransformData);
962
975
  if (transform)
963
976
  transform.size = {
@@ -965,7 +978,7 @@ var FlowNodesContentLayer = class extends import_core7.Layer {
965
978
  height: node.clientHeight
966
979
  };
967
980
  }
968
- }, []);
981
+ }, [entity, node]);
969
982
  return import_react_dom.default.createPortal(
970
983
  /* @__PURE__ */ import_react.default.createElement(import_core7.PlaygroundEntityContext.Provider, { value: entity }, /* @__PURE__ */ import_react.default.createElement(
971
984
  PortalRenderer,
@@ -1052,38 +1065,52 @@ FlowNodesContentLayer = __decorateClass([
1052
1065
 
1053
1066
  // src/layers/flow-lines-layer.tsx
1054
1067
  var import_react8 = __toESM(require("react"));
1055
- var import_lodash4 = require("lodash");
1068
+ var import_lodash_es4 = require("lodash-es");
1056
1069
  var import_inversify5 = require("inversify");
1057
1070
  var import_utils12 = require("@flowgram.ai/utils");
1058
1071
  var import_document9 = require("@flowgram.ai/document");
1059
- var import_core8 = require("@flowgram.ai/core");
1072
+ var import_core9 = require("@flowgram.ai/core");
1060
1073
 
1061
- // src/components/MarkerArrow.tsx
1074
+ // src/components/LinesRenderer.tsx
1075
+ var import_react7 = __toESM(require("react"));
1076
+ var import_utils11 = require("@flowgram.ai/utils");
1077
+ var import_document7 = require("@flowgram.ai/document");
1078
+ var import_document8 = require("@flowgram.ai/document");
1079
+
1080
+ // src/components/StraightLine.tsx
1062
1081
  var import_react2 = __toESM(require("react"));
1063
- var MARK_ARROW_ID = "line-marker-arrow";
1064
- var MARK_ARROW_URL = `url(#${MARK_ARROW_ID})`;
1065
- function MarkerArrow() {
1066
- const { baseColor } = useBaseColor();
1067
- return /* @__PURE__ */ import_react2.default.createElement("marker", { id: MARK_ARROW_ID, markerWidth: "11", markerHeight: "14", refX: "10", refY: "7", orient: "auto" }, /* @__PURE__ */ import_react2.default.createElement(
1082
+ function StraightLine(props) {
1083
+ const { from, to, activated, style } = props;
1084
+ const { baseColor, baseActivatedColor } = useBaseColor();
1085
+ return /* @__PURE__ */ import_react2.default.createElement(
1068
1086
  "path",
1069
1087
  {
1070
- d: "M9.6 5.2C10.8 6.1 10.8 7.9 9.6 8.8L3.6 13.3C2.11672 14.4125 0 13.3541 0 11.5L0 2.5C0 0.645898 2.11672 -0.412461 3.6 0.7L9.6 5.2Z",
1071
- fill: baseColor
1088
+ "data-line-id": props.lineId,
1089
+ d: `M ${from.x} ${from.y} L ${to.x} ${to.y}`,
1090
+ ...DEFAULT_LINE_ATTRS,
1091
+ stroke: activated ? baseActivatedColor : baseColor,
1092
+ style
1072
1093
  }
1073
- ));
1094
+ );
1074
1095
  }
1075
- var MarkerArrow_default = MarkerArrow;
1096
+ var StraightLine_default = StraightLine;
1076
1097
 
1077
- // src/components/MarkerActivatedArrow.tsx
1098
+ // src/components/RoundedTurningLine.tsx
1099
+ var import_react5 = __toESM(require("react"));
1100
+ var import_lodash_es3 = require("lodash-es");
1101
+ var import_utils9 = require("@flowgram.ai/utils");
1102
+ var import_core8 = require("@flowgram.ai/core");
1103
+
1104
+ // src/components/MarkerArrow.tsx
1078
1105
  var import_react3 = __toESM(require("react"));
1079
- var MARK_ACTIVATED_ARROW_ID = "line-marker-arrow-activated";
1080
- var MARK_ACTIVATED_ARROW_URL = `url(#${MARK_ACTIVATED_ARROW_ID})`;
1081
- function MarkerActivatedArrow() {
1082
- const { baseActivatedColor } = useBaseColor();
1106
+ var MARK_ARROW_ID = "$marker_arrow$";
1107
+ function MarkerArrow(props) {
1108
+ const { baseColor } = useBaseColor();
1083
1109
  return /* @__PURE__ */ import_react3.default.createElement(
1084
1110
  "marker",
1085
1111
  {
1086
- id: MARK_ACTIVATED_ARROW_ID,
1112
+ "data-line-id": props.id,
1113
+ id: props.id || MARK_ARROW_ID,
1087
1114
  markerWidth: "11",
1088
1115
  markerHeight: "14",
1089
1116
  refX: "10",
@@ -1094,40 +1121,54 @@ function MarkerActivatedArrow() {
1094
1121
  "path",
1095
1122
  {
1096
1123
  d: "M9.6 5.2C10.8 6.1 10.8 7.9 9.6 8.8L3.6 13.3C2.11672 14.4125 0 13.3541 0 11.5L0 2.5C0 0.645898 2.11672 -0.412461 3.6 0.7L9.6 5.2Z",
1097
- fill: baseActivatedColor
1124
+ fill: baseColor
1098
1125
  }
1099
1126
  )
1100
1127
  );
1101
1128
  }
1102
- var MarkerActivatedArrow_default = MarkerActivatedArrow;
1103
-
1104
- // src/components/LinesRenderer.tsx
1105
- var import_react7 = __toESM(require("react"));
1106
- var import_utils11 = require("@flowgram.ai/utils");
1107
- var import_document7 = require("@flowgram.ai/document");
1108
- var import_document8 = require("@flowgram.ai/document");
1129
+ var MarkerArrow_default = MarkerArrow;
1109
1130
 
1110
- // src/components/StraightLine.tsx
1131
+ // src/components/MarkerActivatedArrow.tsx
1111
1132
  var import_react4 = __toESM(require("react"));
1112
- function StraightLine(props) {
1113
- const { from, to, activated, style } = props;
1114
- const { baseColor, baseActivatedColor } = useBaseColor();
1133
+ var MARK_ACTIVATED_ARROW_ID = "$marker_arrow_activated$";
1134
+ function MarkerActivatedArrow(props) {
1135
+ const { baseActivatedColor } = useBaseColor();
1115
1136
  return /* @__PURE__ */ import_react4.default.createElement(
1116
- "path",
1137
+ "marker",
1117
1138
  {
1118
- d: `M ${from.x} ${from.y} L ${to.x} ${to.y}`,
1119
- ...DEFAULT_LINE_ATTRS,
1120
- stroke: activated ? baseActivatedColor : baseColor,
1121
- style
1122
- }
1139
+ "data-line-id": props.id,
1140
+ id: props.id || MARK_ACTIVATED_ARROW_ID,
1141
+ markerWidth: "11",
1142
+ markerHeight: "14",
1143
+ refX: "10",
1144
+ refY: "7",
1145
+ orient: "auto"
1146
+ },
1147
+ /* @__PURE__ */ import_react4.default.createElement(
1148
+ "path",
1149
+ {
1150
+ d: "M9.6 5.2C10.8 6.1 10.8 7.9 9.6 8.8L3.6 13.3C2.11672 14.4125 0 13.3541 0 11.5L0 2.5C0 0.645898 2.11672 -0.412461 3.6 0.7L9.6 5.2Z",
1151
+ fill: baseActivatedColor
1152
+ }
1153
+ )
1123
1154
  );
1124
1155
  }
1125
- var StraightLine_default = StraightLine;
1156
+ var MarkerActivatedArrow_default = MarkerActivatedArrow;
1126
1157
 
1127
1158
  // src/components/RoundedTurningLine.tsx
1128
- var import_react5 = __toESM(require("react"));
1129
- var import_lodash3 = require("lodash");
1130
- var import_utils9 = require("@flowgram.ai/utils");
1159
+ function MarkerDefs(props) {
1160
+ const renderRegistry = (0, import_core8.useService)(FlowRendererRegistry);
1161
+ const ArrowRenderer = renderRegistry?.tryToGetRendererComponent(
1162
+ props.activated ? "marker-active-arrow" /* MARKER_ACTIVATE_ARROW */ : "marker-arrow" /* MARKER_ARROW */
1163
+ );
1164
+ if (ArrowRenderer) {
1165
+ return /* @__PURE__ */ import_react5.default.createElement(ArrowRenderer.renderer, { ...props });
1166
+ }
1167
+ if (props.activated) {
1168
+ return /* @__PURE__ */ import_react5.default.createElement("defs", null, /* @__PURE__ */ import_react5.default.createElement(MarkerActivatedArrow_default, { id: props.id }));
1169
+ }
1170
+ return /* @__PURE__ */ import_react5.default.createElement("defs", null, /* @__PURE__ */ import_react5.default.createElement(MarkerArrow_default, { id: props.id }));
1171
+ }
1131
1172
  function RoundedTurningLine(props) {
1132
1173
  const { vertices, radius = DEFAULT_RADIUS, hide, xRadius, yRadius, ...line } = props;
1133
1174
  const { from, to, arrow, activated, style } = line || {};
@@ -1147,26 +1188,30 @@ function RoundedTurningLine(props) {
1147
1188
  }
1148
1189
  const inPoint = new import_utils9.Point().copyFrom(point);
1149
1190
  const outPoint = new import_utils9.Point().copyFrom(point);
1150
- const radiusX = (0, import_lodash3.isNil)(point.radiusX) ? radius : point.radiusX;
1151
- const radiusY = (0, import_lodash3.isNil)(point.radiusY) ? radius : point.radiusY;
1191
+ const radiusX = (0, import_lodash_es3.isNil)(point.radiusX) ? radius : point.radiusX;
1192
+ const radiusY = (0, import_lodash_es3.isNil)(point.radiusY) ? radius : point.radiusY;
1152
1193
  let rx = radiusX;
1153
1194
  let ry = radiusY;
1154
1195
  if (isRightAngleX) {
1155
1196
  ry = Math.min(prevDelta.y, radiusY);
1156
- const moveY = (0, import_lodash3.isNil)(point.moveY) ? ry : point.moveY;
1197
+ const moveY = (0, import_lodash_es3.isNil)(point.moveY) ? ry : point.moveY;
1157
1198
  inPoint.y += from.y < point.y ? -moveY : +moveY;
1158
1199
  rx = Math.min(nextDelta.x, radiusX);
1159
- const moveX = (0, import_lodash3.isNil)(point.moveX) ? rx : point.moveX;
1200
+ const moveX = (0, import_lodash_es3.isNil)(point.moveX) ? rx : point.moveX;
1160
1201
  outPoint.x += to.x < point.x ? -moveX : +moveX;
1161
1202
  }
1162
1203
  if (isRightAngleY) {
1163
1204
  rx = Math.min(prevDelta.x, radiusX);
1164
- const moveX = (0, import_lodash3.isNil)(point.moveX) ? rx : point.moveX;
1205
+ const moveX = (0, import_lodash_es3.isNil)(point.moveX) ? rx : point.moveX;
1165
1206
  inPoint.x += from.x < point.x ? -moveX : +moveX;
1166
1207
  ry = Math.min(nextDelta.y, radiusY);
1167
- const moveY = (0, import_lodash3.isNil)(point.moveY) ? ry : point.moveY;
1208
+ const moveY = (0, import_lodash_es3.isNil)(point.moveY) ? ry : point.moveY;
1168
1209
  outPoint.y += to.y < point.y ? -moveY : +moveY;
1169
1210
  }
1211
+ if (point.radiusOverflow === "truncate") {
1212
+ rx = radiusX;
1213
+ ry = radiusY;
1214
+ }
1170
1215
  const crossProduct = (point.x - inPoint.x) * (outPoint.y - inPoint.y) - (point.y - inPoint.y) * (outPoint.x - inPoint.x);
1171
1216
  const isClockWise = crossProduct > 0;
1172
1217
  return `L ${inPoint.x} ${inPoint.y} A ${rx} ${ry} 0 0 ${isClockWise ? 1 : 0} ${outPoint.x} ${outPoint.y}`;
@@ -1177,18 +1222,20 @@ function RoundedTurningLine(props) {
1177
1222
  return null;
1178
1223
  }
1179
1224
  const pathStr = `M ${from.x} ${from.y} ${middleStr} L ${to.x} ${to.y}`;
1180
- return /* @__PURE__ */ import_react5.default.createElement(
1225
+ const markerId = activated ? `${MARK_ACTIVATED_ARROW_ID}${props.lineId}` : `${MARK_ARROW_ID}${props.lineId}`;
1226
+ return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, arrow ? /* @__PURE__ */ import_react5.default.createElement(MarkerDefs, { id: markerId, activated }) : null, /* @__PURE__ */ import_react5.default.createElement(
1181
1227
  "path",
1182
1228
  {
1229
+ "data-line-id": props.lineId,
1183
1230
  d: pathStr,
1184
1231
  ...DEFAULT_LINE_ATTRS,
1185
1232
  stroke: activated ? baseActivatedColor : baseColor,
1186
1233
  ...arrow ? {
1187
- markerEnd: activated ? MARK_ACTIVATED_ARROW_URL : MARK_ARROW_URL
1234
+ markerEnd: `url(#${markerId})`
1188
1235
  } : {},
1189
1236
  style
1190
1237
  }
1191
- );
1238
+ ));
1192
1239
  }
1193
1240
  var RoundedTurningLine_default = RoundedTurningLine;
1194
1241
 
@@ -1204,7 +1251,7 @@ function CustomLine(props) {
1204
1251
  return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null);
1205
1252
  }
1206
1253
  const Component = renderer.renderer;
1207
- return /* @__PURE__ */ import_react6.default.createElement(Component, { ...line });
1254
+ return /* @__PURE__ */ import_react6.default.createElement(Component, { lineId: props.lineId, ...line });
1208
1255
  }
1209
1256
  var CustomLine_default = CustomLine;
1210
1257
 
@@ -1212,17 +1259,26 @@ var CustomLine_default = CustomLine;
1212
1259
  function createLines(props) {
1213
1260
  const { data, rendererRegistry, linesSave, dragService } = props;
1214
1261
  const { lines, entity } = data || {};
1262
+ const radius = (0, import_document8.getDefaultSpacing)(entity, import_document7.DefaultSpacingKey.ROUNDED_LINE_RADIUS);
1215
1263
  const xRadius = (0, import_document8.getDefaultSpacing)(entity, import_document7.DefaultSpacingKey.ROUNDED_LINE_X_RADIUS);
1216
1264
  const yRadius = (0, import_document8.getDefaultSpacing)(entity, import_document7.DefaultSpacingKey.ROUNDED_LINE_Y_RADIUS);
1217
1265
  const renderLine = (line, index) => {
1218
1266
  const { renderData } = data;
1219
1267
  const { isVertical } = data.entity;
1220
1268
  const { lineActivated } = renderData || {};
1221
- const draggingLineHide = line.type === import_document7.FlowTransitionLineEnum.DRAGGING_LINE && !dragService.isDroppableBranch(data.entity, line.side);
1222
- const draggingLineActivated = line.type === import_document7.FlowTransitionLineEnum.DRAGGING_LINE && data.entity?.id === dragService.dropNodeId && line.side === dragService.labelSide;
1269
+ const draggingLineHide = (line.type === import_document7.FlowTransitionLineEnum.DRAGGING_LINE || line.isDraggingLine) && !dragService.isDroppableBranch(data.entity, line.side);
1270
+ const draggingLineActivated = (line.type === import_document7.FlowTransitionLineEnum.DRAGGING_LINE || line.isDraggingLine) && data.entity?.id === dragService.dropNodeId && line.side === dragService.labelSide;
1223
1271
  switch (line.type) {
1224
1272
  case import_document7.FlowTransitionLineEnum.STRAIGHT_LINE:
1225
- return /* @__PURE__ */ import_react7.default.createElement(StraightLine_default, { key: `${data.entity.id}${index}`, activated: lineActivated, ...line });
1273
+ return /* @__PURE__ */ import_react7.default.createElement(
1274
+ StraightLine_default,
1275
+ {
1276
+ key: `${data.entity.id}_${index}`,
1277
+ lineId: data.entity.id,
1278
+ activated: lineActivated,
1279
+ ...line
1280
+ }
1281
+ );
1226
1282
  case import_document7.FlowTransitionLineEnum.DIVERGE_LINE:
1227
1283
  case import_document7.FlowTransitionLineEnum.DRAGGING_LINE:
1228
1284
  case import_document7.FlowTransitionLineEnum.MERGE_LINE:
@@ -1230,9 +1286,11 @@ function createLines(props) {
1230
1286
  return /* @__PURE__ */ import_react7.default.createElement(
1231
1287
  RoundedTurningLine_default,
1232
1288
  {
1233
- key: `${data.entity.id}${index}`,
1289
+ key: `${data.entity.id}_${index}`,
1290
+ lineId: data.entity.id,
1234
1291
  isHorizontal: !isVertical,
1235
1292
  activated: lineActivated || draggingLineActivated,
1293
+ radius,
1236
1294
  ...line,
1237
1295
  xRadius,
1238
1296
  yRadius,
@@ -1243,7 +1301,8 @@ function createLines(props) {
1243
1301
  return /* @__PURE__ */ import_react7.default.createElement(
1244
1302
  CustomLine_default,
1245
1303
  {
1246
- key: `${data.entity.id}${index}`,
1304
+ key: `${data.entity.id}_${index}`,
1305
+ lineId: data.entity.id,
1247
1306
  ...line,
1248
1307
  rendererRegistry
1249
1308
  }
@@ -1263,14 +1322,14 @@ function createLines(props) {
1263
1322
  }
1264
1323
 
1265
1324
  // src/layers/flow-lines-layer.tsx
1266
- var FlowLinesLayer = class extends import_core8.Layer {
1325
+ var FlowLinesLayer = class extends import_core9.Layer {
1267
1326
  constructor() {
1268
1327
  super(...arguments);
1269
1328
  this.node = import_utils12.domUtils.createDivWithClass("gedit-flow-lines-layer");
1270
1329
  /**
1271
1330
  * 可视区域变化
1272
1331
  */
1273
- this.onViewportChange = (0, import_lodash4.throttle)(() => {
1332
+ this.onViewportChange = (0, import_lodash_es4.throttle)(() => {
1274
1333
  this.render();
1275
1334
  }, 100);
1276
1335
  }
@@ -1302,19 +1361,11 @@ var FlowLinesLayer = class extends import_core8.Layer {
1302
1361
  dragService: this.dragService
1303
1362
  });
1304
1363
  });
1305
- const { activateLines = [], normalLines = [] } = (0, import_lodash4.groupBy)(
1364
+ const { activateLines = [], normalLines = [] } = (0, import_lodash_es4.groupBy)(
1306
1365
  allLines,
1307
1366
  (line) => line.props.activated ? "activateLines" : "normalLines"
1308
1367
  );
1309
1368
  const resultLines = [...normalLines, ...activateLines];
1310
- const arrowRenderer = this.rendererRegistry.tryToGetRendererComponent(
1311
- "marker-arrow" /* MARKER_ARROW */
1312
- );
1313
- const activateArrowRenderer = this.rendererRegistry.tryToGetRendererComponent(
1314
- "marker-active-arrow" /* MARKER_ACTIVATE_ARROW */
1315
- );
1316
- const arrow = arrowRenderer ? import_react8.default.createElement(arrowRenderer.renderer) : null;
1317
- const activateArrow = activateArrowRenderer ? import_react8.default.createElement(activateArrowRenderer.renderer) : null;
1318
1369
  return /* @__PURE__ */ import_react8.default.createElement(
1319
1370
  "svg",
1320
1371
  {
@@ -1325,7 +1376,6 @@ var FlowLinesLayer = class extends import_core8.Layer {
1325
1376
  viewBox: this.viewBox,
1326
1377
  xmlns: "http://www.w3.org/2000/svg"
1327
1378
  },
1328
- /* @__PURE__ */ import_react8.default.createElement("defs", null, arrowRenderer ? arrow : /* @__PURE__ */ import_react8.default.createElement(MarkerArrow_default, null), activateArrow ? activateArrow : /* @__PURE__ */ import_react8.default.createElement(MarkerActivatedArrow_default, null)),
1329
1379
  resultLines
1330
1380
  );
1331
1381
  }
@@ -1340,13 +1390,13 @@ __decorateClass([
1340
1390
  (0, import_inversify5.inject)(FlowRendererRegistry)
1341
1391
  ], FlowLinesLayer.prototype, "rendererRegistry", 2);
1342
1392
  __decorateClass([
1343
- (0, import_core8.observeEntity)(import_document9.FlowDocumentTransformerEntity)
1393
+ (0, import_core9.observeEntity)(import_document9.FlowDocumentTransformerEntity)
1344
1394
  ], FlowLinesLayer.prototype, "documentTransformer", 2);
1345
1395
  __decorateClass([
1346
- (0, import_core8.observeEntity)(import_document9.FlowRendererStateEntity)
1396
+ (0, import_core9.observeEntity)(import_document9.FlowRendererStateEntity)
1347
1397
  ], FlowLinesLayer.prototype, "flowRenderState", 2);
1348
1398
  __decorateClass([
1349
- (0, import_core8.observeEntityDatas)(import_document9.FlowNodeEntity, import_document9.FlowNodeTransitionData)
1399
+ (0, import_core9.observeEntityDatas)(import_document9.FlowNodeEntity, import_document9.FlowNodeTransitionData)
1350
1400
  ], FlowLinesLayer.prototype, "_transitions", 2);
1351
1401
  FlowLinesLayer = __decorateClass([
1352
1402
  (0, import_inversify5.injectable)()
@@ -1354,11 +1404,11 @@ FlowLinesLayer = __decorateClass([
1354
1404
 
1355
1405
  // src/layers/flow-labels-layer.tsx
1356
1406
  var import_react14 = __toESM(require("react"));
1357
- var import_lodash5 = require("lodash");
1407
+ var import_lodash_es5 = require("lodash-es");
1358
1408
  var import_inversify6 = require("inversify");
1359
1409
  var import_utils16 = require("@flowgram.ai/utils");
1360
1410
  var import_document15 = require("@flowgram.ai/document");
1361
- var import_core11 = require("@flowgram.ai/core");
1411
+ var import_core12 = require("@flowgram.ai/core");
1362
1412
 
1363
1413
  // src/components/LabelsRenderer.tsx
1364
1414
  var import_react13 = __toESM(require("react"));
@@ -1427,7 +1477,7 @@ function Collapse(props) {
1427
1477
  // src/components/Adder.tsx
1428
1478
  var import_react10 = __toESM(require("react"));
1429
1479
  var import_document11 = require("@flowgram.ai/document");
1430
- var import_core9 = require("@flowgram.ai/core");
1480
+ var import_core10 = require("@flowgram.ai/core");
1431
1481
  var getFlowRenderKey = (node, { dragService }) => {
1432
1482
  if (dragService && dragService.dragging && dragService.isDroppableNode(node)) {
1433
1483
  if (dragService.dropNodeId === node.id) {
@@ -1449,7 +1499,7 @@ function Adder(props) {
1449
1499
  const handleMouseEnter = (0, import_react10.useCallback)(() => setHoverActivated(true), []);
1450
1500
  const handleMouseLeave = (0, import_react10.useCallback)(() => setHoverActivated(false), []);
1451
1501
  const node = data.entity;
1452
- const dragService = (0, import_core9.useService)(import_document11.FlowDragService);
1502
+ const dragService = (0, import_core10.useService)(import_document11.FlowDragService);
1453
1503
  const flowRenderKey = getFlowRenderKey(node, { dragService });
1454
1504
  const adder = rendererRegistry.getRendererComponent(flowRenderKey);
1455
1505
  const from = node;
@@ -1557,7 +1607,7 @@ function CollapseAdder(props) {
1557
1607
  // src/components/BranchDraggableRenderer.tsx
1558
1608
  var import_react12 = __toESM(require("react"));
1559
1609
  var import_document13 = require("@flowgram.ai/document");
1560
- var import_core10 = require("@flowgram.ai/core");
1610
+ var import_core11 = require("@flowgram.ai/core");
1561
1611
  var getFlowRenderKey2 = (node, { dragService, side }) => {
1562
1612
  if (dragService.isDragBranch && side && dragService.labelSide === side && dragService.isDroppableBranch(node, side)) {
1563
1613
  if (dragService.dropNodeId === node.id) {
@@ -1570,7 +1620,7 @@ var getFlowRenderKey2 = (node, { dragService, side }) => {
1570
1620
  function BranchDraggableRenderer(props) {
1571
1621
  const { data, rendererRegistry, side, ...restProps } = props;
1572
1622
  const node = data.entity;
1573
- const dragService = (0, import_core10.useService)(import_document13.FlowDragService);
1623
+ const dragService = (0, import_core11.useService)(import_document13.FlowDragService);
1574
1624
  const flowRenderKey = getFlowRenderKey2(node, { side, dragService });
1575
1625
  if (!flowRenderKey) {
1576
1626
  return null;
@@ -1616,22 +1666,54 @@ function createLabels(labelProps) {
1616
1666
  const { labels, renderData } = data || {};
1617
1667
  const { activated } = renderData || {};
1618
1668
  const renderLabel = (label, index) => {
1619
- const { offset, renderKey, props, rotate, type } = label || {};
1669
+ const { offset, renderKey, props, rotate, origin, type } = label || {};
1620
1670
  const offsetX = offset.x;
1621
1671
  const offsetY = offset.y;
1622
1672
  let child = null;
1623
1673
  switch (type) {
1624
1674
  case import_document14.FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL:
1625
- child = /* @__PURE__ */ import_react13.default.createElement(BranchDraggableRenderer, { rendererRegistry, data, ...props });
1675
+ child = /* @__PURE__ */ import_react13.default.createElement(
1676
+ BranchDraggableRenderer,
1677
+ {
1678
+ labelId: label.labelId || labelProps.data.entity.id,
1679
+ rendererRegistry,
1680
+ data,
1681
+ ...props
1682
+ }
1683
+ );
1626
1684
  break;
1627
1685
  case import_document14.FlowTransitionLabelEnum.ADDER_LABEL:
1628
- child = /* @__PURE__ */ import_react13.default.createElement(Adder, { rendererRegistry, data, ...props });
1686
+ child = /* @__PURE__ */ import_react13.default.createElement(
1687
+ Adder,
1688
+ {
1689
+ labelId: label.labelId || labelProps.data.entity.id,
1690
+ rendererRegistry,
1691
+ data,
1692
+ ...props
1693
+ }
1694
+ );
1629
1695
  break;
1630
1696
  case import_document14.FlowTransitionLabelEnum.COLLAPSE_LABEL:
1631
- child = /* @__PURE__ */ import_react13.default.createElement(Collapse, { rendererRegistry, data, ...props });
1697
+ child = /* @__PURE__ */ import_react13.default.createElement(
1698
+ Collapse,
1699
+ {
1700
+ labelId: label.labelId || labelProps.data.entity.id,
1701
+ rendererRegistry,
1702
+ data,
1703
+ ...props
1704
+ }
1705
+ );
1632
1706
  break;
1633
1707
  case import_document14.FlowTransitionLabelEnum.COLLAPSE_ADDER_LABEL:
1634
- child = /* @__PURE__ */ import_react13.default.createElement(CollapseAdder, { rendererRegistry, data, ...props });
1708
+ child = /* @__PURE__ */ import_react13.default.createElement(
1709
+ CollapseAdder,
1710
+ {
1711
+ labelId: label.labelId || labelProps.data.entity.id,
1712
+ rendererRegistry,
1713
+ data,
1714
+ ...props
1715
+ }
1716
+ );
1635
1717
  break;
1636
1718
  case import_document14.FlowTransitionLabelEnum.TEXT_LABEL:
1637
1719
  if (!renderKey) {
@@ -1641,6 +1723,7 @@ function createLabels(labelProps) {
1641
1723
  child = /* @__PURE__ */ import_react13.default.createElement(
1642
1724
  "div",
1643
1725
  {
1726
+ "data-label-id": label.labelId || labelProps.data.entity.id,
1644
1727
  style: {
1645
1728
  ...TEXT_LABEL_STYLE,
1646
1729
  ...props?.style,
@@ -1661,6 +1744,7 @@ function createLabels(labelProps) {
1661
1744
  renderer.renderer,
1662
1745
  {
1663
1746
  node: data.entity,
1747
+ labelId: label.labelId || labelProps.data.entity.id,
1664
1748
  ...props
1665
1749
  }
1666
1750
  );
@@ -1672,15 +1756,18 @@ function createLabels(labelProps) {
1672
1756
  default:
1673
1757
  break;
1674
1758
  }
1759
+ const originX = typeof origin?.[0] === "number" ? origin?.[0] : 0.5;
1760
+ const originY = typeof origin?.[1] === "number" ? origin?.[1] : 0.5;
1675
1761
  return /* @__PURE__ */ import_react13.default.createElement(
1676
1762
  "div",
1677
1763
  {
1678
1764
  key: `${data.entity.id}${index}`,
1765
+ "data-label-id": label.labelId || labelProps.data.entity.id,
1679
1766
  style: {
1680
1767
  position: "absolute",
1681
1768
  left: offsetX,
1682
1769
  top: offsetY,
1683
- transform: "translate(-50%, -50%)"
1770
+ transform: `translate(-${originX * 100}%, -${originY * 100}%)`
1684
1771
  }
1685
1772
  },
1686
1773
  child
@@ -1694,14 +1781,14 @@ function createLabels(labelProps) {
1694
1781
  }
1695
1782
 
1696
1783
  // src/layers/flow-labels-layer.tsx
1697
- var FlowLabelsLayer = class extends import_core11.Layer {
1784
+ var FlowLabelsLayer = class extends import_core12.Layer {
1698
1785
  constructor() {
1699
1786
  super(...arguments);
1700
1787
  this.node = import_utils16.domUtils.createDivWithClass("gedit-flow-labels-layer");
1701
1788
  /**
1702
1789
  * 可视区域变化
1703
1790
  */
1704
- this.onViewportChange = (0, import_lodash5.throttle)(() => {
1791
+ this.onViewportChange = (0, import_lodash_es5.throttle)(() => {
1705
1792
  this.render();
1706
1793
  }, 100);
1707
1794
  }
@@ -1749,13 +1836,13 @@ __decorateClass([
1749
1836
  (0, import_inversify6.inject)(FlowRendererRegistry)
1750
1837
  ], FlowLabelsLayer.prototype, "rendererRegistry", 2);
1751
1838
  __decorateClass([
1752
- (0, import_core11.observeEntity)(import_document15.FlowDocumentTransformerEntity)
1839
+ (0, import_core12.observeEntity)(import_document15.FlowDocumentTransformerEntity)
1753
1840
  ], FlowLabelsLayer.prototype, "documentTransformer", 2);
1754
1841
  __decorateClass([
1755
- (0, import_core11.observeEntity)(import_document15.FlowRendererStateEntity)
1842
+ (0, import_core12.observeEntity)(import_document15.FlowRendererStateEntity)
1756
1843
  ], FlowLabelsLayer.prototype, "flowRenderState", 2);
1757
1844
  __decorateClass([
1758
- (0, import_core11.observeEntityDatas)(import_document15.FlowNodeEntity, import_document15.FlowNodeTransitionData)
1845
+ (0, import_core12.observeEntityDatas)(import_document15.FlowNodeEntity, import_document15.FlowNodeTransitionData)
1759
1846
  ], FlowLabelsLayer.prototype, "_transitions", 2);
1760
1847
  FlowLabelsLayer = __decorateClass([
1761
1848
  (0, import_inversify6.injectable)()
@@ -1765,7 +1852,7 @@ FlowLabelsLayer = __decorateClass([
1765
1852
  var import_inversify7 = require("inversify");
1766
1853
  var import_utils18 = require("@flowgram.ai/utils");
1767
1854
  var import_document16 = require("@flowgram.ai/document");
1768
- var import_core12 = require("@flowgram.ai/core");
1855
+ var import_core13 = require("@flowgram.ai/core");
1769
1856
 
1770
1857
  // src/utils/scroll-limit.ts
1771
1858
  var import_utils17 = require("@flowgram.ai/utils");
@@ -1811,7 +1898,7 @@ function randomColor(percent) {
1811
1898
  const random = () => Math.floor(Math.random() * max);
1812
1899
  return `rgb(${rgb === 0 ? random() : 0}, ${rgb === 1 ? random() : 0}, ${rgb === 2 ? random() : 0})`;
1813
1900
  }
1814
- var FlowDebugLayer = class extends import_core12.Layer {
1901
+ var FlowDebugLayer = class extends import_core13.Layer {
1815
1902
  constructor() {
1816
1903
  super(...arguments);
1817
1904
  this.node = document.createElement("div");
@@ -1974,10 +2061,10 @@ __decorateClass([
1974
2061
  (0, import_inversify7.inject)(import_document16.FlowDocument)
1975
2062
  ], FlowDebugLayer.prototype, "document", 2);
1976
2063
  __decorateClass([
1977
- (0, import_core12.observeEntity)(import_document16.FlowDocumentTransformerEntity)
2064
+ (0, import_core13.observeEntity)(import_document16.FlowDocumentTransformerEntity)
1978
2065
  ], FlowDebugLayer.prototype, "documentTransformer", 2);
1979
2066
  __decorateClass([
1980
- (0, import_core12.observeEntityDatas)(import_document16.FlowNodeEntity, import_document16.FlowNodeTransformData)
2067
+ (0, import_core13.observeEntityDatas)(import_document16.FlowNodeEntity, import_document16.FlowNodeTransformData)
1981
2068
  ], FlowDebugLayer.prototype, "_transforms", 2);
1982
2069
  FlowDebugLayer = __decorateClass([
1983
2070
  (0, import_inversify7.injectable)()
@@ -1986,12 +2073,12 @@ FlowDebugLayer = __decorateClass([
1986
2073
  // src/layers/flow-scroll-bar-layer.tsx
1987
2074
  var import_inversify8 = require("inversify");
1988
2075
  var import_document17 = require("@flowgram.ai/document");
1989
- var import_core13 = require("@flowgram.ai/core");
2076
+ var import_core14 = require("@flowgram.ai/core");
1990
2077
  var import_utils20 = require("@flowgram.ai/utils");
1991
2078
  var BORDER_WIDTH = 2;
1992
2079
  var BLOCK_OFFSET = 11;
1993
2080
  var SCROLL_BAR_WIDTH = "7px";
1994
- var FlowScrollBarLayer = class extends import_core13.Layer {
2081
+ var FlowScrollBarLayer = class extends import_core14.Layer {
1995
2082
  constructor() {
1996
2083
  super(...arguments);
1997
2084
  // @observeEntity(FlowDocumentTransformerEntity) readonly documentTransformer: FlowDocumentTransformerEntity
@@ -2011,7 +2098,7 @@ var FlowScrollBarLayer = class extends import_core13.Layer {
2011
2098
  this.initialScrollX = 0;
2012
2099
  // 初始 y 轴滚动距离
2013
2100
  this.initialScrollY = 0;
2014
- this.bottomGrabDragger = new import_core13.PlaygroundDrag({
2101
+ this.bottomGrabDragger = new import_core14.PlaygroundDrag({
2015
2102
  onDragStart: (e) => {
2016
2103
  this.config.updateCursor("grabbing");
2017
2104
  this.sum = 0;
@@ -2031,7 +2118,7 @@ var FlowScrollBarLayer = class extends import_core13.Layer {
2031
2118
  this.config.updateCursor("default");
2032
2119
  }
2033
2120
  });
2034
- this.rightGrabDragger = new import_core13.PlaygroundDrag({
2121
+ this.rightGrabDragger = new import_core14.PlaygroundDrag({
2035
2122
  onDragStart: (e) => {
2036
2123
  this.config.updateCursor("grabbing");
2037
2124
  this.sum = 0;
@@ -2226,32 +2313,34 @@ __decorateClass([
2226
2313
  (0, import_inversify8.optional)()
2227
2314
  ], FlowScrollBarLayer.prototype, "flowDocument", 2);
2228
2315
  __decorateClass([
2229
- (0, import_core13.observeEntity)(import_core13.PlaygroundConfigEntity)
2316
+ (0, import_core14.observeEntity)(import_core14.PlaygroundConfigEntity)
2230
2317
  ], FlowScrollBarLayer.prototype, "playgroundConfigEntity", 2);
2231
2318
  FlowScrollBarLayer = __decorateClass([
2232
2319
  (0, import_inversify8.injectable)()
2233
2320
  ], FlowScrollBarLayer);
2234
2321
 
2235
2322
  // src/layers/flow-drag-layer.tsx
2323
+ var import_react_dom2 = __toESM(require("react-dom"));
2236
2324
  var import_react15 = __toESM(require("react"));
2237
2325
  var import_inversify9 = require("inversify");
2238
2326
  var import_utils22 = require("@flowgram.ai/utils");
2239
2327
  var import_document18 = require("@flowgram.ai/document");
2240
- var import_core14 = require("@flowgram.ai/core");
2241
2328
  var import_core15 = require("@flowgram.ai/core");
2329
+ var import_core16 = require("@flowgram.ai/core");
2242
2330
  var DRAG_OFFSET = 10;
2243
2331
  var DEFAULT_DRAG_OFFSET_X = 8;
2244
2332
  var DEFAULT_DRAG_OFFSET_Y = 8;
2245
- var FlowDragLayer = class extends import_core14.Layer {
2333
+ var FlowDragLayer = class extends import_core15.Layer {
2246
2334
  constructor() {
2247
2335
  super(...arguments);
2336
+ this.disableDragScroll = false;
2248
2337
  this.dragOffset = {
2249
2338
  x: DEFAULT_DRAG_OFFSET_X,
2250
2339
  y: DEFAULT_DRAG_OFFSET_Y
2251
2340
  };
2252
2341
  this.containerRef = import_react15.default.createRef();
2253
2342
  this.draggingNodeMask = document.createElement("div");
2254
- this._dragger = new import_core15.PlaygroundDrag({
2343
+ this._dragger = new import_core16.PlaygroundDrag({
2255
2344
  onDrag: (e) => {
2256
2345
  this.handleMouseMove(e);
2257
2346
  },
@@ -2282,29 +2371,31 @@ var FlowDragLayer = class extends import_core14.Layer {
2282
2371
  }
2283
2372
  isGrab() {
2284
2373
  const currentState = this.editorStateConfig.getCurrentState();
2285
- return currentState === import_core14.EditorState.STATE_GRAB;
2374
+ return currentState === import_core15.EditorState.STATE_GRAB;
2286
2375
  }
2287
2376
  setDraggingStatus(status) {
2288
- if (this.service.nodeDragIdsWithChildren.length) {
2289
- this.service.nodeDragIdsWithChildren.forEach((_id) => {
2377
+ if (this.flowDragService.nodeDragIdsWithChildren.length) {
2378
+ this.flowDragService.nodeDragIdsWithChildren.forEach((_id) => {
2290
2379
  const node = this.entityManager.getEntityById(_id);
2291
2380
  const data = node?.getData(import_document18.FlowNodeRenderData);
2292
2381
  data.dragging = status;
2293
2382
  });
2294
2383
  }
2384
+ this.flowRenderStateEntity.setDragging(status);
2295
2385
  }
2296
2386
  dragEnable(e) {
2297
2387
  return Math.abs(e.clientX - this.initialPosition.x) > DRAG_OFFSET || Math.abs(e.clientY - this.initialPosition.y) > DRAG_OFFSET;
2298
2388
  }
2299
2389
  handleMouseMove(event) {
2300
- if (this.dragStartEntity && this.dragEnable(event)) {
2390
+ if ((this.dragJSON || this.dragStartEntity) && this.dragEnable(event)) {
2301
2391
  this.setDraggingStatus(true);
2302
2392
  const scale = this.playgroundConfigEntity.finalScale;
2303
2393
  if (this.containerRef.current) {
2304
2394
  const dragNode = this.containerRef.current.children?.[0];
2305
- const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - this.playgroundConfigEntity.config.clientX - (dragNode.clientWidth - this.dragOffset.x) * scale;
2306
- const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - this.playgroundConfigEntity.config.clientY - (dragNode.clientHeight - this.dragOffset.y) * scale;
2307
- const isBranch = this.service.isDragBranch;
2395
+ const clientBounds = this.playgroundConfigEntity.getClientBounds();
2396
+ const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x - (dragNode.clientWidth - this.dragOffset.x) * scale;
2397
+ const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y - (dragNode.clientHeight - this.dragOffset.y) * scale;
2398
+ const isBranch = this.flowDragService.isDragBranch;
2308
2399
  const draggingRect = new import_utils22.Rectangle(
2309
2400
  dragBlockX,
2310
2401
  dragBlockY,
@@ -2324,7 +2415,7 @@ var FlowDragLayer = class extends import_core14.Layer {
2324
2415
  side = labelOffsetType;
2325
2416
  return hasCollision;
2326
2417
  });
2327
- if (collisionTransition && (isBranch ? this.service.isDroppableBranch(collisionTransition.entity, side) : this.service.isDroppableNode(collisionTransition.entity)) && (!this.options.canDrop || this.options.canDrop({
2418
+ if (collisionTransition && (isBranch ? this.flowDragService.isDroppableBranch(collisionTransition.entity, side) : this.flowDragService.isDroppableNode(collisionTransition.entity)) && (!this.options.canDrop || this.options.canDrop({
2328
2419
  dragNodes: this.dragEntities,
2329
2420
  dropNode: collisionTransition.entity,
2330
2421
  isBranch
@@ -2336,37 +2427,45 @@ var FlowDragLayer = class extends import_core14.Layer {
2336
2427
  this.flowRenderStateEntity.setDragLabelSide(side);
2337
2428
  this.containerRef.current.style.visibility = "visible";
2338
2429
  this.pipelineNode.parentElement.appendChild(this.draggingNodeMask);
2339
- this.containerRef.current.style.left = `${dragBlockX}px`;
2340
- this.containerRef.current.style.top = `${dragBlockY}px`;
2430
+ this.containerRef.current.style.left = `${dragBlockX + this.pipelineNode.offsetLeft + clientBounds.x + window.scrollX}px`;
2431
+ this.containerRef.current.style.top = `${dragBlockY + this.pipelineNode.offsetTop + clientBounds.y + window.scrollY}px`;
2341
2432
  this.containerRef.current.style.transformOrigin = "top left";
2342
2433
  this.containerRef.current.style.transform = `scale(${scale})`;
2343
- this.flowDragConfigEntity.scrollDirection(
2344
- event,
2345
- this.containerRef.current,
2346
- dragBlockX,
2347
- dragBlockY
2348
- );
2434
+ if (!this.disableDragScroll) {
2435
+ this.flowDragConfigEntity.scrollDirection(event, dragBlockX, dragBlockY);
2436
+ }
2349
2437
  }
2350
2438
  }
2351
2439
  }
2352
- handleMouseUp() {
2440
+ async handleMouseUp() {
2353
2441
  this.setDraggingStatus(false);
2354
- if (this.dragStartEntity) {
2355
- const activatedNodeId = this.service.dropNodeId;
2442
+ if (this.dragStartEntity || this.dragJSON) {
2443
+ const activatedNodeId = this.flowDragService.dropNodeId;
2356
2444
  if (activatedNodeId) {
2357
- if (this.service.isDragBranch) {
2358
- this.service.dropBranch();
2445
+ if (this.flowDragService.isDragBranch) {
2446
+ if (this.dragJSON) {
2447
+ await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
2448
+ } else {
2449
+ this.flowDragService.dropBranch();
2450
+ }
2359
2451
  } else {
2360
- this.service.dropNode();
2452
+ if (this.dragJSON) {
2453
+ await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
2454
+ } else {
2455
+ this.flowDragService.dropNode();
2456
+ }
2361
2457
  this.selectConfigEntity.clearSelectedNodes();
2362
2458
  }
2363
2459
  }
2364
2460
  this.flowRenderStateEntity.setNodeDroppingId("");
2365
2461
  this.flowRenderStateEntity.setDragLabelSide();
2462
+ this.flowRenderStateEntity.setIsBranch(false);
2366
2463
  this.dragStartEntity = void 0;
2367
2464
  this.dragEntities = [];
2368
2465
  this.flowDragConfigEntity.stopAllScroll();
2369
2466
  }
2467
+ this.disableDragScroll = false;
2468
+ this.dragJSON = void 0;
2370
2469
  if (this.containerRef.current) {
2371
2470
  this.containerRef.current.style.visibility = "hidden";
2372
2471
  if (this.pipelineNode.parentElement.contains(this.draggingNodeMask)) {
@@ -2380,17 +2479,25 @@ var FlowDragLayer = class extends import_core14.Layer {
2380
2479
  */
2381
2480
  async startDrag(e, {
2382
2481
  dragStartEntity: startEntityFromProps,
2383
- dragEntities
2482
+ dragEntities,
2483
+ dragJSON,
2484
+ isBranch,
2485
+ onCreateNode
2384
2486
  }, options) {
2385
2487
  if (this.isGrab() || this.config.disabled || this.config.readonly) {
2386
2488
  return;
2387
2489
  }
2490
+ this.disableDragScroll = Boolean(options?.disableDragScroll);
2491
+ this.dragJSON = dragJSON;
2492
+ this.onCreateNode = onCreateNode;
2493
+ this.flowRenderStateEntity.setIsBranch(Boolean(isBranch));
2388
2494
  this.dragOffset.x = options?.dragOffsetX || DEFAULT_DRAG_OFFSET_X;
2389
2495
  this.dragOffset.y = options?.dragOffsetY || DEFAULT_DRAG_OFFSET_Y;
2390
- const isIcon = startEntityFromProps.flowNodeType === import_document18.FlowNodeBaseType.BLOCK_ICON;
2391
- const isOrderIcon = startEntityFromProps.flowNodeType === import_document18.FlowNodeBaseType.BLOCK_ORDER_ICON;
2496
+ const type = startEntityFromProps?.flowNodeType || dragJSON?.type;
2497
+ const isIcon = type === import_document18.FlowNodeBaseType.BLOCK_ICON;
2498
+ const isOrderIcon = type === import_document18.FlowNodeBaseType.BLOCK_ORDER_ICON;
2392
2499
  const dragStartEntity = isIcon || isOrderIcon ? startEntityFromProps.parent : startEntityFromProps;
2393
- if (!dragStartEntity.getData(import_document18.FlowNodeRenderData).draggable) {
2500
+ if (dragStartEntity && !dragStartEntity.getData(import_document18.FlowNodeRenderData).draggable) {
2394
2501
  return;
2395
2502
  }
2396
2503
  this.initialPosition = {
@@ -2398,7 +2505,7 @@ var FlowDragLayer = class extends import_core14.Layer {
2398
2505
  y: e.clientY
2399
2506
  };
2400
2507
  this.dragStartEntity = dragStartEntity;
2401
- this.dragEntities = dragEntities || [this.dragStartEntity];
2508
+ this.dragEntities = dragEntities || (this.dragStartEntity ? [this.dragStartEntity] : []);
2402
2509
  return this._dragger.start(e.clientX, e.clientY);
2403
2510
  }
2404
2511
  onReady() {
@@ -2410,19 +2517,33 @@ var FlowDragLayer = class extends import_core14.Layer {
2410
2517
  this.draggingNodeMask.style.cursor = "pointer";
2411
2518
  this.dragNodeComp = this.rendererRegistry.getRendererComponent("drag-node" /* DRAG_NODE */);
2412
2519
  if (this.options.onDrop) {
2413
- this.toDispose.push(this.service.onDrop(this.options.onDrop));
2520
+ this.toDispose.push(this.flowDragService.onDrop(this.options.onDrop));
2414
2521
  }
2415
2522
  }
2523
+ dispose() {
2524
+ this._dragger.dispose();
2525
+ super.dispose();
2526
+ }
2416
2527
  render() {
2417
2528
  const DragComp = this.dragNodeComp.renderer;
2418
- return /* @__PURE__ */ import_react15.default.createElement(
2419
- "div",
2420
- {
2421
- ref: this.containerRef,
2422
- style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
2423
- onMouseEnter: (e) => e.stopPropagation()
2424
- },
2425
- /* @__PURE__ */ import_react15.default.createElement(DragComp, { dragStart: this.dragStartEntity, dragNodes: this.dragEntities })
2529
+ return import_react_dom2.default.createPortal(
2530
+ /* @__PURE__ */ import_react15.default.createElement(
2531
+ "div",
2532
+ {
2533
+ ref: this.containerRef,
2534
+ style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
2535
+ onMouseEnter: (e) => e.stopPropagation()
2536
+ },
2537
+ /* @__PURE__ */ import_react15.default.createElement(
2538
+ DragComp,
2539
+ {
2540
+ dragJSON: this.dragJSON,
2541
+ dragStart: this.dragStartEntity,
2542
+ dragNodes: this.dragEntities
2543
+ }
2544
+ )
2545
+ ),
2546
+ document.body
2426
2547
  );
2427
2548
  }
2428
2549
  };
@@ -2431,24 +2552,24 @@ __decorateClass([
2431
2552
  ], FlowDragLayer.prototype, "document", 2);
2432
2553
  __decorateClass([
2433
2554
  (0, import_inversify9.inject)(import_document18.FlowDragService)
2434
- ], FlowDragLayer.prototype, "service", 2);
2555
+ ], FlowDragLayer.prototype, "flowDragService", 2);
2435
2556
  __decorateClass([
2436
- (0, import_core14.observeEntityDatas)(import_document18.FlowNodeEntity, import_document18.FlowNodeTransformData)
2557
+ (0, import_core15.observeEntityDatas)(import_document18.FlowNodeEntity, import_document18.FlowNodeTransformData)
2437
2558
  ], FlowDragLayer.prototype, "transforms", 2);
2438
2559
  __decorateClass([
2439
- (0, import_core14.observeEntity)(import_core14.EditorStateConfigEntity)
2560
+ (0, import_core15.observeEntity)(import_core15.EditorStateConfigEntity)
2440
2561
  ], FlowDragLayer.prototype, "editorStateConfig", 2);
2441
2562
  __decorateClass([
2442
- (0, import_core14.observeEntity)(import_core14.PlaygroundConfigEntity)
2563
+ (0, import_core15.observeEntity)(import_core15.PlaygroundConfigEntity)
2443
2564
  ], FlowDragLayer.prototype, "playgroundConfigEntity", 2);
2444
2565
  __decorateClass([
2445
- (0, import_core14.observeEntity)(FlowDragEntity)
2566
+ (0, import_core15.observeEntity)(FlowDragEntity)
2446
2567
  ], FlowDragLayer.prototype, "flowDragConfigEntity", 2);
2447
2568
  __decorateClass([
2448
- (0, import_core14.observeEntity)(import_document18.FlowRendererStateEntity)
2569
+ (0, import_core15.observeEntity)(import_document18.FlowRendererStateEntity)
2449
2570
  ], FlowDragLayer.prototype, "flowRenderStateEntity", 2);
2450
2571
  __decorateClass([
2451
- (0, import_core14.observeEntity)(FlowSelectConfigEntity)
2572
+ (0, import_core15.observeEntity)(FlowSelectConfigEntity)
2452
2573
  ], FlowDragLayer.prototype, "selectConfigEntity", 2);
2453
2574
  __decorateClass([
2454
2575
  (0, import_inversify9.inject)(FlowRendererRegistry)
@@ -2461,8 +2582,8 @@ FlowDragLayer = __decorateClass([
2461
2582
  var import_inversify10 = require("inversify");
2462
2583
  var import_utils23 = require("@flowgram.ai/utils");
2463
2584
  var import_document19 = require("@flowgram.ai/document");
2464
- var import_core16 = require("@flowgram.ai/core");
2465
- var FlowSelectorBoxLayer = class extends import_core16.Layer {
2585
+ var import_core17 = require("@flowgram.ai/core");
2586
+ var FlowSelectorBoxLayer = class extends import_core17.Layer {
2466
2587
  constructor() {
2467
2588
  super(...arguments);
2468
2589
  this.node = import_utils23.domUtils.createDivWithClass("gedit-selector-box-layer");
@@ -2477,7 +2598,7 @@ var FlowSelectorBoxLayer = class extends import_core16.Layer {
2477
2598
  /**
2478
2599
  * 拖动选择框
2479
2600
  */
2480
- this.selectboxDragger = new import_core16.PlaygroundDrag({
2601
+ this.selectboxDragger = new import_core17.PlaygroundDrag({
2481
2602
  onDragStart: (e) => {
2482
2603
  this.selectConfigEntity.clearSelectedNodes();
2483
2604
  const mousePos = this.playgroundConfigEntity.getPosFromMouseEvent(e);
@@ -2532,20 +2653,20 @@ var FlowSelectorBoxLayer = class extends import_core16.Layer {
2532
2653
  return;
2533
2654
  }
2534
2655
  const currentState = this.editorStateConfig.getCurrentState();
2535
- if (currentState === import_core16.EditorState.STATE_MOUSE_FRIENDLY_SELECT) {
2656
+ if (currentState === import_core17.EditorState.STATE_MOUSE_FRIENDLY_SELECT) {
2536
2657
  this.selectConfigEntity.clearSelectedNodes();
2537
2658
  }
2538
2659
  this.selectboxDragger.start(e.clientX, e.clientY, this.config);
2539
2660
  return true;
2540
2661
  },
2541
- import_core16.PipelineLayerPriority.BASE_LAYER
2662
+ import_core17.PipelineLayerPriority.BASE_LAYER
2542
2663
  );
2543
2664
  }
2544
2665
  isEnabled() {
2545
2666
  const currentState = this.editorStateConfig.getCurrentState();
2546
- const isMouseFriendly = currentState === import_core16.EditorState.STATE_MOUSE_FRIENDLY_SELECT;
2667
+ const isMouseFriendly = currentState === import_core17.EditorState.STATE_MOUSE_FRIENDLY_SELECT;
2547
2668
  return !this.config.disabled && !this.config.readonly && // 鼠标友好模式下,需要按下 shift 启动框选
2548
- (isMouseFriendly && this.editorStateConfig.isPressingShift || currentState === import_core16.EditorState.STATE_SELECT) && !this.selectorBoxConfigEntity.disabled;
2669
+ (isMouseFriendly && this.editorStateConfig.isPressingShift || currentState === import_core17.EditorState.STATE_SELECT) && !this.selectorBoxConfigEntity.disabled;
2549
2670
  }
2550
2671
  /**
2551
2672
  * Destroy
@@ -2601,22 +2722,22 @@ __decorateClass([
2601
2722
  (0, import_inversify10.inject)(import_document19.FlowDocument)
2602
2723
  ], FlowSelectorBoxLayer.prototype, "flowDocument", 2);
2603
2724
  __decorateClass([
2604
- (0, import_inversify10.inject)(import_core16.ContextMenuService)
2725
+ (0, import_inversify10.inject)(import_core17.ContextMenuService)
2605
2726
  ], FlowSelectorBoxLayer.prototype, "contextMenuService", 2);
2606
2727
  __decorateClass([
2607
- (0, import_core16.observeEntity)(import_core16.PlaygroundConfigEntity)
2728
+ (0, import_core17.observeEntity)(import_core17.PlaygroundConfigEntity)
2608
2729
  ], FlowSelectorBoxLayer.prototype, "playgroundConfigEntity", 2);
2609
2730
  __decorateClass([
2610
- (0, import_inversify10.inject)(import_core16.SelectionService)
2731
+ (0, import_inversify10.inject)(import_core17.SelectionService)
2611
2732
  ], FlowSelectorBoxLayer.prototype, "selectionService", 2);
2612
2733
  __decorateClass([
2613
- (0, import_core16.observeEntity)(SelectorBoxConfigEntity)
2734
+ (0, import_core17.observeEntity)(SelectorBoxConfigEntity)
2614
2735
  ], FlowSelectorBoxLayer.prototype, "selectorBoxConfigEntity", 2);
2615
2736
  __decorateClass([
2616
- (0, import_core16.observeEntity)(FlowSelectConfigEntity)
2737
+ (0, import_core17.observeEntity)(FlowSelectConfigEntity)
2617
2738
  ], FlowSelectorBoxLayer.prototype, "selectConfigEntity", 2);
2618
2739
  __decorateClass([
2619
- (0, import_core16.observeEntity)(import_core16.EditorStateConfigEntity)
2740
+ (0, import_core17.observeEntity)(import_core17.EditorStateConfigEntity)
2620
2741
  ], FlowSelectorBoxLayer.prototype, "editorStateConfig", 2);
2621
2742
  FlowSelectorBoxLayer = __decorateClass([
2622
2743
  (0, import_inversify10.injectable)()
@@ -2625,10 +2746,10 @@ FlowSelectorBoxLayer = __decorateClass([
2625
2746
  // src/layers/flow-selector-bounds-layer.tsx
2626
2747
  var import_react16 = __toESM(require("react"));
2627
2748
  var import_inversify11 = require("inversify");
2628
- var import_document20 = require("@flowgram.ai/document");
2629
- var import_core17 = require("@flowgram.ai/core");
2630
2749
  var import_utils24 = require("@flowgram.ai/utils");
2631
- var FlowSelectorBoundsLayer = class extends import_core17.Layer {
2750
+ var import_document20 = require("@flowgram.ai/document");
2751
+ var import_core18 = require("@flowgram.ai/core");
2752
+ var FlowSelectorBoundsLayer = class extends import_core18.Layer {
2632
2753
  constructor() {
2633
2754
  super(...arguments);
2634
2755
  this.node = import_utils24.domUtils.createDivWithClass("gedit-selector-bounds-layer");
@@ -2643,7 +2764,9 @@ var FlowSelectorBoundsLayer = class extends import_core17.Layer {
2643
2764
  if (this.options.backgroundClassName) {
2644
2765
  this.selectBoundsBackground.classList.add(this.options.backgroundClassName);
2645
2766
  }
2646
- const selectorBoundsLayer = import_utils24.domUtils.createDivWithClass("gedit-playground-layer");
2767
+ const selectorBoundsLayer = import_utils24.domUtils.createDivWithClass(
2768
+ "gedit-selector-bounds-background-layer gedit-playground-layer"
2769
+ );
2647
2770
  selectorBoundsLayer.appendChild(this.selectBoundsBackground);
2648
2771
  this.pipelineNode.insertBefore(selectorBoundsLayer, firstChild);
2649
2772
  }
@@ -2656,7 +2779,7 @@ var FlowSelectorBoundsLayer = class extends import_core17.Layer {
2656
2779
  }
2657
2780
  isEnabled() {
2658
2781
  const currentState = this.editorStateConfig.getCurrentState();
2659
- return currentState === import_core17.EditorState.STATE_SELECT;
2782
+ return currentState === import_core18.EditorState.STATE_SELECT;
2660
2783
  }
2661
2784
  // /**
2662
2785
  // * 渲染工具栏
@@ -2684,6 +2807,7 @@ var FlowSelectorBoundsLayer = class extends import_core17.Layer {
2684
2807
  render() {
2685
2808
  const {
2686
2809
  ignoreOneSelect,
2810
+ ignoreChildrenLength,
2687
2811
  SelectorBoxPopover: SelectorBoxPopoverFromOpts,
2688
2812
  disableBackground,
2689
2813
  CustomBoundsRenderer
@@ -2694,7 +2818,7 @@ var FlowSelectorBoundsLayer = class extends import_core17.Layer {
2694
2818
  const isDragging = !this.selectorBoxConfigEntity.isStart;
2695
2819
  if (bounds.width === 0 || bounds.height === 0 || // 选中单个的时候不显示
2696
2820
  ignoreOneSelect && selectedNodes.length === 1 && // 选中的节点不包含多个子节点
2697
- selectedNodes[0].childrenLength <= 1) {
2821
+ (ignoreChildrenLength || selectedNodes[0].childrenLength <= 1)) {
2698
2822
  import_utils24.domUtils.setStyle(bg, {
2699
2823
  display: "none"
2700
2824
  });
@@ -2744,22 +2868,22 @@ __decorateClass([
2744
2868
  (0, import_inversify11.inject)(FlowRendererRegistry)
2745
2869
  ], FlowSelectorBoundsLayer.prototype, "rendererRegistry", 2);
2746
2870
  __decorateClass([
2747
- (0, import_inversify11.inject)(import_core17.CommandRegistry)
2871
+ (0, import_inversify11.inject)(import_core18.CommandRegistry)
2748
2872
  ], FlowSelectorBoundsLayer.prototype, "commandRegistry", 2);
2749
2873
  __decorateClass([
2750
- (0, import_core17.observeEntity)(FlowSelectConfigEntity)
2874
+ (0, import_core18.observeEntity)(FlowSelectConfigEntity)
2751
2875
  ], FlowSelectorBoundsLayer.prototype, "flowSelectConfigEntity", 2);
2752
2876
  __decorateClass([
2753
- (0, import_core17.observeEntity)(import_core17.EditorStateConfigEntity)
2877
+ (0, import_core18.observeEntity)(import_core18.EditorStateConfigEntity)
2754
2878
  ], FlowSelectorBoundsLayer.prototype, "editorStateConfig", 2);
2755
2879
  __decorateClass([
2756
- (0, import_core17.observeEntity)(SelectorBoxConfigEntity)
2880
+ (0, import_core18.observeEntity)(SelectorBoxConfigEntity)
2757
2881
  ], FlowSelectorBoundsLayer.prototype, "selectorBoxConfigEntity", 2);
2758
2882
  __decorateClass([
2759
- (0, import_core17.observeEntityDatas)(import_document20.FlowNodeEntity, import_document20.FlowNodeRenderData)
2883
+ (0, import_core18.observeEntityDatas)(import_document20.FlowNodeEntity, import_document20.FlowNodeRenderData)
2760
2884
  ], FlowSelectorBoundsLayer.prototype, "renderStates", 2);
2761
2885
  __decorateClass([
2762
- (0, import_core17.observeEntityDatas)(import_document20.FlowNodeEntity, import_document20.FlowNodeTransformData)
2886
+ (0, import_core18.observeEntityDatas)(import_document20.FlowNodeEntity, import_document20.FlowNodeTransformData)
2763
2887
  ], FlowSelectorBoundsLayer.prototype, "_transforms", 2);
2764
2888
  FlowSelectorBoundsLayer = __decorateClass([
2765
2889
  (0, import_inversify11.injectable)()
@@ -2768,9 +2892,9 @@ FlowSelectorBoundsLayer = __decorateClass([
2768
2892
  // src/layers/flow-context-menu-layer.tsx
2769
2893
  var import_react17 = __toESM(require("react"));
2770
2894
  var import_inversify12 = require("inversify");
2771
- var import_core18 = require("@flowgram.ai/core");
2772
2895
  var import_utils25 = require("@flowgram.ai/utils");
2773
- var FlowContextMenuLayer = class extends import_core18.Layer {
2896
+ var import_core19 = require("@flowgram.ai/core");
2897
+ var FlowContextMenuLayer = class extends import_core19.Layer {
2774
2898
  constructor() {
2775
2899
  super(...arguments);
2776
2900
  this.node = import_utils25.domUtils.createDivWithClass("gedit-context-menu-layer");
@@ -2778,7 +2902,7 @@ var FlowContextMenuLayer = class extends import_core18.Layer {
2778
2902
  }
2779
2903
  isEnabled() {
2780
2904
  const currentState = this.editorStateConfig.getCurrentState();
2781
- return !this.config.disabled && !this.config.readonly && currentState === import_core18.EditorState.STATE_SELECT && !this.selectorBoxConfigEntity.disabled;
2905
+ return !this.config.disabled && !this.config.readonly && currentState === import_core19.EditorState.STATE_SELECT && !this.selectorBoxConfigEntity.disabled;
2782
2906
  }
2783
2907
  onReady() {
2784
2908
  this.node.style.zIndex = "30";
@@ -2796,12 +2920,13 @@ var FlowContextMenuLayer = class extends import_core18.Layer {
2796
2920
  e.stopPropagation();
2797
2921
  e.preventDefault();
2798
2922
  this.nodeRef.current?.setVisible(true);
2799
- const dragBlockX = e.clientX - (this.pipelineNode.offsetLeft || 0) - this.playgroundConfigEntity.config.clientX;
2800
- const dragBlockY = e.clientY - (this.pipelineNode.offsetTop || 0) - this.playgroundConfigEntity.config.clientY;
2923
+ const clientBounds = this.playgroundConfigEntity.getClientBounds();
2924
+ const dragBlockX = e.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x;
2925
+ const dragBlockY = e.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y;
2801
2926
  this.node.style.left = `${dragBlockX}px`;
2802
2927
  this.node.style.top = `${dragBlockY}px`;
2803
2928
  },
2804
- import_core18.PipelineLayerPriority.BASE_LAYER
2929
+ import_core19.PipelineLayerPriority.BASE_LAYER
2805
2930
  ),
2806
2931
  this.listenPlaygroundEvent("mousedown", () => {
2807
2932
  this.nodeRef.current?.setVisible(false);
@@ -2849,28 +2974,28 @@ var FlowContextMenuLayer = class extends import_core18.Layer {
2849
2974
  }
2850
2975
  };
2851
2976
  __decorateClass([
2852
- (0, import_inversify12.inject)(import_core18.CommandRegistry)
2977
+ (0, import_inversify12.inject)(import_core19.CommandRegistry)
2853
2978
  ], FlowContextMenuLayer.prototype, "commandRegistry", 2);
2854
2979
  __decorateClass([
2855
2980
  (0, import_inversify12.inject)(FlowRendererRegistry)
2856
2981
  ], FlowContextMenuLayer.prototype, "rendererRegistry", 2);
2857
2982
  __decorateClass([
2858
- (0, import_inversify12.inject)(import_core18.ContextMenuService)
2983
+ (0, import_inversify12.inject)(import_core19.ContextMenuService)
2859
2984
  ], FlowContextMenuLayer.prototype, "contextMenuService", 2);
2860
2985
  __decorateClass([
2861
- (0, import_core18.observeEntity)(FlowSelectConfigEntity)
2986
+ (0, import_core19.observeEntity)(FlowSelectConfigEntity)
2862
2987
  ], FlowContextMenuLayer.prototype, "flowSelectConfigEntity", 2);
2863
2988
  __decorateClass([
2864
- (0, import_inversify12.inject)(import_core18.SelectionService)
2989
+ (0, import_inversify12.inject)(import_core19.SelectionService)
2865
2990
  ], FlowContextMenuLayer.prototype, "selectionService", 2);
2866
2991
  __decorateClass([
2867
- (0, import_core18.observeEntity)(import_core18.PlaygroundConfigEntity)
2992
+ (0, import_core19.observeEntity)(import_core19.PlaygroundConfigEntity)
2868
2993
  ], FlowContextMenuLayer.prototype, "playgroundConfigEntity", 2);
2869
2994
  __decorateClass([
2870
- (0, import_core18.observeEntity)(import_core18.EditorStateConfigEntity)
2995
+ (0, import_core19.observeEntity)(import_core19.EditorStateConfigEntity)
2871
2996
  ], FlowContextMenuLayer.prototype, "editorStateConfig", 2);
2872
2997
  __decorateClass([
2873
- (0, import_core18.observeEntity)(SelectorBoxConfigEntity)
2998
+ (0, import_core19.observeEntity)(SelectorBoxConfigEntity)
2874
2999
  ], FlowContextMenuLayer.prototype, "selectorBoxConfigEntity", 2);
2875
3000
  FlowContextMenuLayer = __decorateClass([
2876
3001
  (0, import_inversify12.injectable)()
@@ -2879,8 +3004,8 @@ FlowContextMenuLayer = __decorateClass([
2879
3004
  // src/layers/flow-scroll-limit-layer.tsx
2880
3005
  var import_inversify13 = require("inversify");
2881
3006
  var import_document21 = require("@flowgram.ai/document");
2882
- var import_core19 = require("@flowgram.ai/core");
2883
- var FlowScrollLimitLayer = class extends import_core19.Layer {
3007
+ var import_core20 = require("@flowgram.ai/core");
3008
+ var FlowScrollLimitLayer = class extends import_core20.Layer {
2884
3009
  getInitScroll() {
2885
3010
  return this.document.layout.getInitScroll(this.pipelineNode.getBoundingClientRect());
2886
3011
  }
@@ -2936,6 +3061,7 @@ var FlowRendererContainerModule = new import_inversify14.ContainerModule((bind)
2936
3061
  MARK_ARROW_ID,
2937
3062
  ScrollBarEvents,
2938
3063
  SelectorBoxConfigEntity,
3064
+ createLines,
2939
3065
  useBaseColor
2940
3066
  });
2941
3067
  //# sourceMappingURL=index.js.map