@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/esm/index.js CHANGED
@@ -10,12 +10,12 @@ var __decorateClass = (decorators, target, key, kind) => {
10
10
  };
11
11
 
12
12
  // src/entities/flow-drag-entity.tsx
13
+ import { Rectangle } from "@flowgram.ai/utils";
13
14
  import {
14
15
  FlowTransitionLabelEnum,
15
16
  LABEL_SIDE_TYPE
16
17
  } from "@flowgram.ai/document";
17
18
  import { ConfigEntity, PlaygroundConfigEntity } from "@flowgram.ai/core";
18
- import { Rectangle } from "@flowgram.ai/utils";
19
19
 
20
20
  // src/components/utils.tsx
21
21
  import {
@@ -45,7 +45,7 @@ var DEFAULT_LINE_ATTRS = {
45
45
  strokeLinecap: "round",
46
46
  strokeLinejoin: "round"
47
47
  };
48
- var DEFAULT_RADIUS = 16;
48
+ var DEFAULT_RADIUS = DEFAULT_SPACING[DefaultSpacingKey.ROUNDED_LINE_RADIUS];
49
49
  var DEFAULT_LABEL_ACTIVATE_HEIGHT = 32;
50
50
  function getHorizontalVertices(line, xRadius = 16, yRadius = 20) {
51
51
  const { from, to, type } = line || {};
@@ -339,7 +339,6 @@ var FlowDragEntity = class extends ConfigEntity {
339
339
  } else {
340
340
  this.containerX -= SCROLL_DELTA;
341
341
  }
342
- this.setDomStyle();
343
342
  }
344
343
  }, SCROLL_INTERVAL);
345
344
  this._scrollXInterval = { interval, origin };
@@ -368,7 +367,6 @@ var FlowDragEntity = class extends ConfigEntity {
368
367
  } else {
369
368
  this.containerY -= SCROLL_DELTA;
370
369
  }
371
- this.setDomStyle();
372
370
  }
373
371
  }, SCROLL_INTERVAL);
374
372
  this._scrollYInterval = { interval, origin };
@@ -383,34 +381,30 @@ var FlowDragEntity = class extends ConfigEntity {
383
381
  this._stopScrollX();
384
382
  this._stopScrollY();
385
383
  }
386
- setDomStyle() {
387
- this.containerDom.style.left = `${this.containerX}px`;
388
- this.containerDom.style.top = `${this.containerY}px`;
389
- }
390
- scrollDirection(e, containerDom, x, y) {
384
+ scrollDirection(e, x, y) {
391
385
  const playgroundConfig = this.playgroundConfigEntity.config;
392
386
  const currentScrollX = playgroundConfig.scrollX;
393
387
  const currentScrollY = playgroundConfig.scrollY;
394
- this.containerDom = containerDom;
395
388
  this.containerX = x;
396
389
  this.containerY = y;
397
- const mouseToBottom = playgroundConfig.height + playgroundConfig.clientY - e.clientY;
390
+ const clientRect = this.playgroundConfigEntity.playgroundDomNode.getBoundingClientRect();
391
+ const mouseToBottom = playgroundConfig.height + clientRect.y - e.clientY;
398
392
  if (mouseToBottom < SCROLL_BOUNDING) {
399
393
  this._startScrollY(currentScrollY, true);
400
394
  return 1 /* BOTTOM */;
401
395
  }
402
- const mouseToTop = e.clientY - playgroundConfig.clientY;
396
+ const mouseToTop = e.clientY - clientRect.y;
403
397
  if (mouseToTop < SCROLL_BOUNDING) {
404
398
  this._startScrollY(currentScrollY, false);
405
399
  return 0 /* TOP */;
406
400
  }
407
401
  this._stopScrollY();
408
- const mouseToRight = playgroundConfig.width + playgroundConfig.clientX - e.clientX;
402
+ const mouseToRight = playgroundConfig.width + clientRect.x - e.clientX;
409
403
  if (mouseToRight < SCROLL_BOUNDING) {
410
404
  this._startScrollX(currentScrollX, true);
411
405
  return 3 /* RIGHT */;
412
406
  }
413
- const mouseToLeft = e.clientX - playgroundConfig.clientX;
407
+ const mouseToLeft = e.clientX - clientRect.x;
414
408
  if (mouseToLeft < SCROLL_BOUNDING + EDITOR_LEFT_BAR_WIDTH) {
415
409
  this._startScrollX(currentScrollX, false);
416
410
  return 2 /* LEFT */;
@@ -433,7 +427,7 @@ import { ConfigEntity as ConfigEntity2 } from "@flowgram.ai/core";
433
427
  import { Compare, Rectangle as Rectangle2 } from "@flowgram.ai/utils";
434
428
 
435
429
  // src/utils/find-selected-nodes.ts
436
- import { uniq } from "lodash";
430
+ import { uniq } from "lodash-es";
437
431
  function getNodePath(node) {
438
432
  const path = [node];
439
433
  node = node.parent;
@@ -626,10 +620,16 @@ import { injectable } from "inversify";
626
620
  import { Disposable } from "@flowgram.ai/utils";
627
621
 
628
622
  // src/utils/element.ts
629
- import { isNil } from "lodash";
623
+ import { isNil } from "lodash-es";
630
624
  var isHidden = (dom) => {
625
+ if (!dom || isNil(dom?.offsetParent)) {
626
+ return true;
627
+ }
631
628
  const style = window.getComputedStyle(dom);
632
- return isNil(dom?.offsetParent) || style?.display === "none";
629
+ if (style?.display === "none") {
630
+ return true;
631
+ }
632
+ return false;
633
633
  };
634
634
  var isRectInit = (rect) => {
635
635
  if (!rect) {
@@ -698,7 +698,9 @@ var FlowNodesTransformLayer = class extends Layer {
698
698
  const append = () => {
699
699
  if (resizeDispose) return;
700
700
  this.renderElement.appendChild(node);
701
- resizeDispose = this.resizeObserver.observe(node, transform);
701
+ if (!entity.getNodeMeta().autoResizeDisable) {
702
+ resizeDispose = this.resizeObserver.observe(node, transform);
703
+ }
702
704
  };
703
705
  const dispose = () => {
704
706
  if (!resizeDispose) return;
@@ -713,7 +715,9 @@ var FlowNodesTransformLayer = class extends Layer {
713
715
  dispose,
714
716
  updateBounds: () => {
715
717
  const { bounds } = transform;
716
- if (node.style.left !== `${bounds.x}px` || node.style.top !== `${bounds.y}px`) {
718
+ const rawX = parseFloat(node.style.left);
719
+ const rawY = parseFloat(node.style.top);
720
+ if (!this.isCoordEqual(rawX, bounds.x) || !this.isCoordEqual(rawY, bounds.y)) {
717
721
  node.style.left = `${bounds.x}px`;
718
722
  node.style.top = `${bounds.y}px`;
719
723
  }
@@ -736,6 +740,10 @@ var FlowNodesTransformLayer = class extends Layer {
736
740
  this.renderCache.dispose();
737
741
  super.dispose();
738
742
  }
743
+ isCoordEqual(a, b) {
744
+ const browserCoordEpsilon = 0.05;
745
+ return Math.abs(a - b) < browserCoordEpsilon;
746
+ }
739
747
  onReady() {
740
748
  this.node.style.zIndex = "10";
741
749
  }
@@ -828,6 +836,10 @@ var FlowRendererKey = /* @__PURE__ */ ((FlowRendererKey2) => {
828
836
  FlowRendererKey2["SELECTOR_BOX_POPOVER"] = "selector-box-popover";
829
837
  FlowRendererKey2["CONTEXT_MENU_POPOVER"] = "context-menu-popover";
830
838
  FlowRendererKey2["SUB_CANVAS"] = "sub-canvas";
839
+ FlowRendererKey2["SLOT_ADDER"] = "slot-adder";
840
+ FlowRendererKey2["SLOT_LABEL"] = "slot-label";
841
+ FlowRendererKey2["SLOT_COLLAPSE"] = "slot-collapse";
842
+ FlowRendererKey2["ARROW_RENDERER"] = "arrow-renderer";
831
843
  FlowRendererKey2["MARKER_ARROW"] = "marker-arrow";
832
844
  FlowRendererKey2["MARKER_ACTIVATE_ARROW"] = "marker-active-arrow";
833
845
  return FlowRendererKey2;
@@ -875,7 +887,7 @@ var FlowRendererRegistry = class {
875
887
  });
876
888
  }
877
889
  getText(textKey) {
878
- return I18n.t(textKey, { disableReturnKey: true }) || this.textMap.get(textKey);
890
+ return I18n.t(textKey, { defaultValue: "" }) || this.textMap.get(textKey);
879
891
  }
880
892
  /**
881
893
  * TODO: support memo
@@ -929,7 +941,7 @@ var FlowNodesContentLayer = class extends Layer2 {
929
941
  const PortalRenderer = this.getPortalRenderer(data);
930
942
  function Portal() {
931
943
  React.useEffect(() => {
932
- if (node.clientWidth && node.clientHeight) {
944
+ if (!entity.getNodeMeta().autoResizeDisable && node.clientWidth && node.clientHeight) {
933
945
  const transform = entity.getData(FlowNodeTransformData4);
934
946
  if (transform)
935
947
  transform.size = {
@@ -937,7 +949,7 @@ var FlowNodesContentLayer = class extends Layer2 {
937
949
  height: node.clientHeight
938
950
  };
939
951
  }
940
- }, []);
952
+ }, [entity, node]);
941
953
  return ReactDOM.createPortal(
942
954
  /* @__PURE__ */ React.createElement(PlaygroundEntityContext.Provider, { value: entity }, /* @__PURE__ */ React.createElement(
943
955
  PortalRenderer,
@@ -1024,7 +1036,7 @@ FlowNodesContentLayer = __decorateClass([
1024
1036
 
1025
1037
  // src/layers/flow-lines-layer.tsx
1026
1038
  import React8 from "react";
1027
- import { groupBy, throttle } from "lodash";
1039
+ import { groupBy, throttle } from "lodash-es";
1028
1040
  import { inject as inject4, injectable as injectable5 } from "inversify";
1029
1041
  import { domUtils as domUtils3 } from "@flowgram.ai/utils";
1030
1042
  import {
@@ -1037,32 +1049,49 @@ import {
1037
1049
  } from "@flowgram.ai/document";
1038
1050
  import { Layer as Layer3, observeEntity as observeEntity3, observeEntityDatas as observeEntityDatas3 } from "@flowgram.ai/core";
1039
1051
 
1040
- // src/components/MarkerArrow.tsx
1052
+ // src/components/LinesRenderer.tsx
1053
+ import React7 from "react";
1054
+ import { Rectangle as Rectangle4 } from "@flowgram.ai/utils";
1055
+ import {
1056
+ FlowTransitionLineEnum as FlowTransitionLineEnum2,
1057
+ DefaultSpacingKey as DefaultSpacingKey2
1058
+ } from "@flowgram.ai/document";
1059
+ import { getDefaultSpacing } from "@flowgram.ai/document";
1060
+
1061
+ // src/components/StraightLine.tsx
1041
1062
  import React2 from "react";
1042
- var MARK_ARROW_ID = "line-marker-arrow";
1043
- var MARK_ARROW_URL = `url(#${MARK_ARROW_ID})`;
1044
- function MarkerArrow() {
1045
- const { baseColor } = useBaseColor();
1046
- return /* @__PURE__ */ React2.createElement("marker", { id: MARK_ARROW_ID, markerWidth: "11", markerHeight: "14", refX: "10", refY: "7", orient: "auto" }, /* @__PURE__ */ React2.createElement(
1063
+ function StraightLine(props) {
1064
+ const { from, to, activated, style } = props;
1065
+ const { baseColor, baseActivatedColor } = useBaseColor();
1066
+ return /* @__PURE__ */ React2.createElement(
1047
1067
  "path",
1048
1068
  {
1049
- 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",
1050
- fill: baseColor
1069
+ "data-line-id": props.lineId,
1070
+ d: `M ${from.x} ${from.y} L ${to.x} ${to.y}`,
1071
+ ...DEFAULT_LINE_ATTRS,
1072
+ stroke: activated ? baseActivatedColor : baseColor,
1073
+ style
1051
1074
  }
1052
- ));
1075
+ );
1053
1076
  }
1054
- var MarkerArrow_default = MarkerArrow;
1077
+ var StraightLine_default = StraightLine;
1055
1078
 
1056
- // src/components/MarkerActivatedArrow.tsx
1079
+ // src/components/RoundedTurningLine.tsx
1080
+ import React5, { useMemo } from "react";
1081
+ import { isNil as isNil2 } from "lodash-es";
1082
+ import { Point } from "@flowgram.ai/utils";
1083
+ import { useService as useService2 } from "@flowgram.ai/core";
1084
+
1085
+ // src/components/MarkerArrow.tsx
1057
1086
  import React3 from "react";
1058
- var MARK_ACTIVATED_ARROW_ID = "line-marker-arrow-activated";
1059
- var MARK_ACTIVATED_ARROW_URL = `url(#${MARK_ACTIVATED_ARROW_ID})`;
1060
- function MarkerActivatedArrow() {
1061
- const { baseActivatedColor } = useBaseColor();
1087
+ var MARK_ARROW_ID = "$marker_arrow$";
1088
+ function MarkerArrow(props) {
1089
+ const { baseColor } = useBaseColor();
1062
1090
  return /* @__PURE__ */ React3.createElement(
1063
1091
  "marker",
1064
1092
  {
1065
- id: MARK_ACTIVATED_ARROW_ID,
1093
+ "data-line-id": props.id,
1094
+ id: props.id || MARK_ARROW_ID,
1066
1095
  markerWidth: "11",
1067
1096
  markerHeight: "14",
1068
1097
  refX: "10",
@@ -1073,43 +1102,54 @@ function MarkerActivatedArrow() {
1073
1102
  "path",
1074
1103
  {
1075
1104
  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",
1076
- fill: baseActivatedColor
1105
+ fill: baseColor
1077
1106
  }
1078
1107
  )
1079
1108
  );
1080
1109
  }
1081
- var MarkerActivatedArrow_default = MarkerActivatedArrow;
1082
-
1083
- // src/components/LinesRenderer.tsx
1084
- import React7 from "react";
1085
- import { Rectangle as Rectangle4 } from "@flowgram.ai/utils";
1086
- import {
1087
- FlowTransitionLineEnum as FlowTransitionLineEnum2,
1088
- DefaultSpacingKey as DefaultSpacingKey2
1089
- } from "@flowgram.ai/document";
1090
- import { getDefaultSpacing } from "@flowgram.ai/document";
1110
+ var MarkerArrow_default = MarkerArrow;
1091
1111
 
1092
- // src/components/StraightLine.tsx
1112
+ // src/components/MarkerActivatedArrow.tsx
1093
1113
  import React4 from "react";
1094
- function StraightLine(props) {
1095
- const { from, to, activated, style } = props;
1096
- const { baseColor, baseActivatedColor } = useBaseColor();
1114
+ var MARK_ACTIVATED_ARROW_ID = "$marker_arrow_activated$";
1115
+ function MarkerActivatedArrow(props) {
1116
+ const { baseActivatedColor } = useBaseColor();
1097
1117
  return /* @__PURE__ */ React4.createElement(
1098
- "path",
1118
+ "marker",
1099
1119
  {
1100
- d: `M ${from.x} ${from.y} L ${to.x} ${to.y}`,
1101
- ...DEFAULT_LINE_ATTRS,
1102
- stroke: activated ? baseActivatedColor : baseColor,
1103
- style
1104
- }
1120
+ "data-line-id": props.id,
1121
+ id: props.id || MARK_ACTIVATED_ARROW_ID,
1122
+ markerWidth: "11",
1123
+ markerHeight: "14",
1124
+ refX: "10",
1125
+ refY: "7",
1126
+ orient: "auto"
1127
+ },
1128
+ /* @__PURE__ */ React4.createElement(
1129
+ "path",
1130
+ {
1131
+ 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",
1132
+ fill: baseActivatedColor
1133
+ }
1134
+ )
1105
1135
  );
1106
1136
  }
1107
- var StraightLine_default = StraightLine;
1137
+ var MarkerActivatedArrow_default = MarkerActivatedArrow;
1108
1138
 
1109
1139
  // src/components/RoundedTurningLine.tsx
1110
- import React5, { useMemo } from "react";
1111
- import { isNil as isNil2 } from "lodash";
1112
- import { Point } from "@flowgram.ai/utils";
1140
+ function MarkerDefs(props) {
1141
+ const renderRegistry = useService2(FlowRendererRegistry);
1142
+ const ArrowRenderer = renderRegistry?.tryToGetRendererComponent(
1143
+ props.activated ? "marker-active-arrow" /* MARKER_ACTIVATE_ARROW */ : "marker-arrow" /* MARKER_ARROW */
1144
+ );
1145
+ if (ArrowRenderer) {
1146
+ return /* @__PURE__ */ React5.createElement(ArrowRenderer.renderer, { ...props });
1147
+ }
1148
+ if (props.activated) {
1149
+ return /* @__PURE__ */ React5.createElement("defs", null, /* @__PURE__ */ React5.createElement(MarkerActivatedArrow_default, { id: props.id }));
1150
+ }
1151
+ return /* @__PURE__ */ React5.createElement("defs", null, /* @__PURE__ */ React5.createElement(MarkerArrow_default, { id: props.id }));
1152
+ }
1113
1153
  function RoundedTurningLine(props) {
1114
1154
  const { vertices, radius = DEFAULT_RADIUS, hide, xRadius, yRadius, ...line } = props;
1115
1155
  const { from, to, arrow, activated, style } = line || {};
@@ -1149,6 +1189,10 @@ function RoundedTurningLine(props) {
1149
1189
  const moveY = isNil2(point.moveY) ? ry : point.moveY;
1150
1190
  outPoint.y += to.y < point.y ? -moveY : +moveY;
1151
1191
  }
1192
+ if (point.radiusOverflow === "truncate") {
1193
+ rx = radiusX;
1194
+ ry = radiusY;
1195
+ }
1152
1196
  const crossProduct = (point.x - inPoint.x) * (outPoint.y - inPoint.y) - (point.y - inPoint.y) * (outPoint.x - inPoint.x);
1153
1197
  const isClockWise = crossProduct > 0;
1154
1198
  return `L ${inPoint.x} ${inPoint.y} A ${rx} ${ry} 0 0 ${isClockWise ? 1 : 0} ${outPoint.x} ${outPoint.y}`;
@@ -1159,18 +1203,20 @@ function RoundedTurningLine(props) {
1159
1203
  return null;
1160
1204
  }
1161
1205
  const pathStr = `M ${from.x} ${from.y} ${middleStr} L ${to.x} ${to.y}`;
1162
- return /* @__PURE__ */ React5.createElement(
1206
+ const markerId = activated ? `${MARK_ACTIVATED_ARROW_ID}${props.lineId}` : `${MARK_ARROW_ID}${props.lineId}`;
1207
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, arrow ? /* @__PURE__ */ React5.createElement(MarkerDefs, { id: markerId, activated }) : null, /* @__PURE__ */ React5.createElement(
1163
1208
  "path",
1164
1209
  {
1210
+ "data-line-id": props.lineId,
1165
1211
  d: pathStr,
1166
1212
  ...DEFAULT_LINE_ATTRS,
1167
1213
  stroke: activated ? baseActivatedColor : baseColor,
1168
1214
  ...arrow ? {
1169
- markerEnd: activated ? MARK_ACTIVATED_ARROW_URL : MARK_ARROW_URL
1215
+ markerEnd: `url(#${markerId})`
1170
1216
  } : {},
1171
1217
  style
1172
1218
  }
1173
- );
1219
+ ));
1174
1220
  }
1175
1221
  var RoundedTurningLine_default = RoundedTurningLine;
1176
1222
 
@@ -1186,7 +1232,7 @@ function CustomLine(props) {
1186
1232
  return /* @__PURE__ */ React6.createElement(React6.Fragment, null);
1187
1233
  }
1188
1234
  const Component = renderer.renderer;
1189
- return /* @__PURE__ */ React6.createElement(Component, { ...line });
1235
+ return /* @__PURE__ */ React6.createElement(Component, { lineId: props.lineId, ...line });
1190
1236
  }
1191
1237
  var CustomLine_default = CustomLine;
1192
1238
 
@@ -1194,17 +1240,26 @@ var CustomLine_default = CustomLine;
1194
1240
  function createLines(props) {
1195
1241
  const { data, rendererRegistry, linesSave, dragService } = props;
1196
1242
  const { lines, entity } = data || {};
1243
+ const radius = getDefaultSpacing(entity, DefaultSpacingKey2.ROUNDED_LINE_RADIUS);
1197
1244
  const xRadius = getDefaultSpacing(entity, DefaultSpacingKey2.ROUNDED_LINE_X_RADIUS);
1198
1245
  const yRadius = getDefaultSpacing(entity, DefaultSpacingKey2.ROUNDED_LINE_Y_RADIUS);
1199
1246
  const renderLine = (line, index) => {
1200
1247
  const { renderData } = data;
1201
1248
  const { isVertical } = data.entity;
1202
1249
  const { lineActivated } = renderData || {};
1203
- const draggingLineHide = line.type === FlowTransitionLineEnum2.DRAGGING_LINE && !dragService.isDroppableBranch(data.entity, line.side);
1204
- const draggingLineActivated = line.type === FlowTransitionLineEnum2.DRAGGING_LINE && data.entity?.id === dragService.dropNodeId && line.side === dragService.labelSide;
1250
+ const draggingLineHide = (line.type === FlowTransitionLineEnum2.DRAGGING_LINE || line.isDraggingLine) && !dragService.isDroppableBranch(data.entity, line.side);
1251
+ const draggingLineActivated = (line.type === FlowTransitionLineEnum2.DRAGGING_LINE || line.isDraggingLine) && data.entity?.id === dragService.dropNodeId && line.side === dragService.labelSide;
1205
1252
  switch (line.type) {
1206
1253
  case FlowTransitionLineEnum2.STRAIGHT_LINE:
1207
- return /* @__PURE__ */ React7.createElement(StraightLine_default, { key: `${data.entity.id}${index}`, activated: lineActivated, ...line });
1254
+ return /* @__PURE__ */ React7.createElement(
1255
+ StraightLine_default,
1256
+ {
1257
+ key: `${data.entity.id}_${index}`,
1258
+ lineId: data.entity.id,
1259
+ activated: lineActivated,
1260
+ ...line
1261
+ }
1262
+ );
1208
1263
  case FlowTransitionLineEnum2.DIVERGE_LINE:
1209
1264
  case FlowTransitionLineEnum2.DRAGGING_LINE:
1210
1265
  case FlowTransitionLineEnum2.MERGE_LINE:
@@ -1212,9 +1267,11 @@ function createLines(props) {
1212
1267
  return /* @__PURE__ */ React7.createElement(
1213
1268
  RoundedTurningLine_default,
1214
1269
  {
1215
- key: `${data.entity.id}${index}`,
1270
+ key: `${data.entity.id}_${index}`,
1271
+ lineId: data.entity.id,
1216
1272
  isHorizontal: !isVertical,
1217
1273
  activated: lineActivated || draggingLineActivated,
1274
+ radius,
1218
1275
  ...line,
1219
1276
  xRadius,
1220
1277
  yRadius,
@@ -1225,7 +1282,8 @@ function createLines(props) {
1225
1282
  return /* @__PURE__ */ React7.createElement(
1226
1283
  CustomLine_default,
1227
1284
  {
1228
- key: `${data.entity.id}${index}`,
1285
+ key: `${data.entity.id}_${index}`,
1286
+ lineId: data.entity.id,
1229
1287
  ...line,
1230
1288
  rendererRegistry
1231
1289
  }
@@ -1289,14 +1347,6 @@ var FlowLinesLayer = class extends Layer3 {
1289
1347
  (line) => line.props.activated ? "activateLines" : "normalLines"
1290
1348
  );
1291
1349
  const resultLines = [...normalLines, ...activateLines];
1292
- const arrowRenderer = this.rendererRegistry.tryToGetRendererComponent(
1293
- "marker-arrow" /* MARKER_ARROW */
1294
- );
1295
- const activateArrowRenderer = this.rendererRegistry.tryToGetRendererComponent(
1296
- "marker-active-arrow" /* MARKER_ACTIVATE_ARROW */
1297
- );
1298
- const arrow = arrowRenderer ? React8.createElement(arrowRenderer.renderer) : null;
1299
- const activateArrow = activateArrowRenderer ? React8.createElement(activateArrowRenderer.renderer) : null;
1300
1350
  return /* @__PURE__ */ React8.createElement(
1301
1351
  "svg",
1302
1352
  {
@@ -1307,7 +1357,6 @@ var FlowLinesLayer = class extends Layer3 {
1307
1357
  viewBox: this.viewBox,
1308
1358
  xmlns: "http://www.w3.org/2000/svg"
1309
1359
  },
1310
- /* @__PURE__ */ React8.createElement("defs", null, arrowRenderer ? arrow : /* @__PURE__ */ React8.createElement(MarkerArrow_default, null), activateArrow ? activateArrow : /* @__PURE__ */ React8.createElement(MarkerActivatedArrow_default, null)),
1311
1360
  resultLines
1312
1361
  );
1313
1362
  }
@@ -1336,7 +1385,7 @@ FlowLinesLayer = __decorateClass([
1336
1385
 
1337
1386
  // src/layers/flow-labels-layer.tsx
1338
1387
  import React14 from "react";
1339
- import { throttle as throttle2 } from "lodash";
1388
+ import { throttle as throttle2 } from "lodash-es";
1340
1389
  import { inject as inject5, injectable as injectable6 } from "inversify";
1341
1390
  import { domUtils as domUtils4 } from "@flowgram.ai/utils";
1342
1391
  import {
@@ -1423,7 +1472,7 @@ import React10, { useCallback as useCallback2, useState as useState2 } from "rea
1423
1472
  import {
1424
1473
  FlowDragService as FlowDragService3
1425
1474
  } from "@flowgram.ai/document";
1426
- import { useService as useService2 } from "@flowgram.ai/core";
1475
+ import { useService as useService3 } from "@flowgram.ai/core";
1427
1476
  var getFlowRenderKey = (node, { dragService }) => {
1428
1477
  if (dragService && dragService.dragging && dragService.isDroppableNode(node)) {
1429
1478
  if (dragService.dropNodeId === node.id) {
@@ -1445,7 +1494,7 @@ function Adder(props) {
1445
1494
  const handleMouseEnter = useCallback2(() => setHoverActivated(true), []);
1446
1495
  const handleMouseLeave = useCallback2(() => setHoverActivated(false), []);
1447
1496
  const node = data.entity;
1448
- const dragService = useService2(FlowDragService3);
1497
+ const dragService = useService3(FlowDragService3);
1449
1498
  const flowRenderKey = getFlowRenderKey(node, { dragService });
1450
1499
  const adder = rendererRegistry.getRendererComponent(flowRenderKey);
1451
1500
  const from = node;
@@ -1555,7 +1604,7 @@ import React12 from "react";
1555
1604
  import {
1556
1605
  FlowDragService as FlowDragService4
1557
1606
  } from "@flowgram.ai/document";
1558
- import { useService as useService3 } from "@flowgram.ai/core";
1607
+ import { useService as useService4 } from "@flowgram.ai/core";
1559
1608
  var getFlowRenderKey2 = (node, { dragService, side }) => {
1560
1609
  if (dragService.isDragBranch && side && dragService.labelSide === side && dragService.isDroppableBranch(node, side)) {
1561
1610
  if (dragService.dropNodeId === node.id) {
@@ -1568,7 +1617,7 @@ var getFlowRenderKey2 = (node, { dragService, side }) => {
1568
1617
  function BranchDraggableRenderer(props) {
1569
1618
  const { data, rendererRegistry, side, ...restProps } = props;
1570
1619
  const node = data.entity;
1571
- const dragService = useService3(FlowDragService4);
1620
+ const dragService = useService4(FlowDragService4);
1572
1621
  const flowRenderKey = getFlowRenderKey2(node, { side, dragService });
1573
1622
  if (!flowRenderKey) {
1574
1623
  return null;
@@ -1614,22 +1663,54 @@ function createLabels(labelProps) {
1614
1663
  const { labels, renderData } = data || {};
1615
1664
  const { activated } = renderData || {};
1616
1665
  const renderLabel = (label, index) => {
1617
- const { offset, renderKey, props, rotate, type } = label || {};
1666
+ const { offset, renderKey, props, rotate, origin, type } = label || {};
1618
1667
  const offsetX = offset.x;
1619
1668
  const offsetY = offset.y;
1620
1669
  let child = null;
1621
1670
  switch (type) {
1622
1671
  case FlowTransitionLabelEnum2.BRANCH_DRAGGING_LABEL:
1623
- child = /* @__PURE__ */ React13.createElement(BranchDraggableRenderer, { rendererRegistry, data, ...props });
1672
+ child = /* @__PURE__ */ React13.createElement(
1673
+ BranchDraggableRenderer,
1674
+ {
1675
+ labelId: label.labelId || labelProps.data.entity.id,
1676
+ rendererRegistry,
1677
+ data,
1678
+ ...props
1679
+ }
1680
+ );
1624
1681
  break;
1625
1682
  case FlowTransitionLabelEnum2.ADDER_LABEL:
1626
- child = /* @__PURE__ */ React13.createElement(Adder, { rendererRegistry, data, ...props });
1683
+ child = /* @__PURE__ */ React13.createElement(
1684
+ Adder,
1685
+ {
1686
+ labelId: label.labelId || labelProps.data.entity.id,
1687
+ rendererRegistry,
1688
+ data,
1689
+ ...props
1690
+ }
1691
+ );
1627
1692
  break;
1628
1693
  case FlowTransitionLabelEnum2.COLLAPSE_LABEL:
1629
- child = /* @__PURE__ */ React13.createElement(Collapse, { rendererRegistry, data, ...props });
1694
+ child = /* @__PURE__ */ React13.createElement(
1695
+ Collapse,
1696
+ {
1697
+ labelId: label.labelId || labelProps.data.entity.id,
1698
+ rendererRegistry,
1699
+ data,
1700
+ ...props
1701
+ }
1702
+ );
1630
1703
  break;
1631
1704
  case FlowTransitionLabelEnum2.COLLAPSE_ADDER_LABEL:
1632
- child = /* @__PURE__ */ React13.createElement(CollapseAdder, { rendererRegistry, data, ...props });
1705
+ child = /* @__PURE__ */ React13.createElement(
1706
+ CollapseAdder,
1707
+ {
1708
+ labelId: label.labelId || labelProps.data.entity.id,
1709
+ rendererRegistry,
1710
+ data,
1711
+ ...props
1712
+ }
1713
+ );
1633
1714
  break;
1634
1715
  case FlowTransitionLabelEnum2.TEXT_LABEL:
1635
1716
  if (!renderKey) {
@@ -1639,6 +1720,7 @@ function createLabels(labelProps) {
1639
1720
  child = /* @__PURE__ */ React13.createElement(
1640
1721
  "div",
1641
1722
  {
1723
+ "data-label-id": label.labelId || labelProps.data.entity.id,
1642
1724
  style: {
1643
1725
  ...TEXT_LABEL_STYLE,
1644
1726
  ...props?.style,
@@ -1659,6 +1741,7 @@ function createLabels(labelProps) {
1659
1741
  renderer.renderer,
1660
1742
  {
1661
1743
  node: data.entity,
1744
+ labelId: label.labelId || labelProps.data.entity.id,
1662
1745
  ...props
1663
1746
  }
1664
1747
  );
@@ -1670,15 +1753,18 @@ function createLabels(labelProps) {
1670
1753
  default:
1671
1754
  break;
1672
1755
  }
1756
+ const originX = typeof origin?.[0] === "number" ? origin?.[0] : 0.5;
1757
+ const originY = typeof origin?.[1] === "number" ? origin?.[1] : 0.5;
1673
1758
  return /* @__PURE__ */ React13.createElement(
1674
1759
  "div",
1675
1760
  {
1676
1761
  key: `${data.entity.id}${index}`,
1762
+ "data-label-id": label.labelId || labelProps.data.entity.id,
1677
1763
  style: {
1678
1764
  position: "absolute",
1679
1765
  left: offsetX,
1680
1766
  top: offsetY,
1681
- transform: "translate(-50%, -50%)"
1767
+ transform: `translate(-${originX * 100}%, -${originY * 100}%)`
1682
1768
  }
1683
1769
  },
1684
1770
  child
@@ -2241,6 +2327,7 @@ FlowScrollBarLayer = __decorateClass([
2241
2327
  ], FlowScrollBarLayer);
2242
2328
 
2243
2329
  // src/layers/flow-drag-layer.tsx
2330
+ import ReactDOM2 from "react-dom";
2244
2331
  import React15 from "react";
2245
2332
  import { inject as inject8, injectable as injectable9 } from "inversify";
2246
2333
  import { Rectangle as Rectangle8 } from "@flowgram.ai/utils";
@@ -2269,6 +2356,7 @@ var DEFAULT_DRAG_OFFSET_Y = 8;
2269
2356
  var FlowDragLayer = class extends Layer7 {
2270
2357
  constructor() {
2271
2358
  super(...arguments);
2359
+ this.disableDragScroll = false;
2272
2360
  this.dragOffset = {
2273
2361
  x: DEFAULT_DRAG_OFFSET_X,
2274
2362
  y: DEFAULT_DRAG_OFFSET_Y
@@ -2309,26 +2397,28 @@ var FlowDragLayer = class extends Layer7 {
2309
2397
  return currentState === EditorState.STATE_GRAB;
2310
2398
  }
2311
2399
  setDraggingStatus(status) {
2312
- if (this.service.nodeDragIdsWithChildren.length) {
2313
- this.service.nodeDragIdsWithChildren.forEach((_id) => {
2400
+ if (this.flowDragService.nodeDragIdsWithChildren.length) {
2401
+ this.flowDragService.nodeDragIdsWithChildren.forEach((_id) => {
2314
2402
  const node = this.entityManager.getEntityById(_id);
2315
2403
  const data = node?.getData(FlowNodeRenderData5);
2316
2404
  data.dragging = status;
2317
2405
  });
2318
2406
  }
2407
+ this.flowRenderStateEntity.setDragging(status);
2319
2408
  }
2320
2409
  dragEnable(e) {
2321
2410
  return Math.abs(e.clientX - this.initialPosition.x) > DRAG_OFFSET || Math.abs(e.clientY - this.initialPosition.y) > DRAG_OFFSET;
2322
2411
  }
2323
2412
  handleMouseMove(event) {
2324
- if (this.dragStartEntity && this.dragEnable(event)) {
2413
+ if ((this.dragJSON || this.dragStartEntity) && this.dragEnable(event)) {
2325
2414
  this.setDraggingStatus(true);
2326
2415
  const scale = this.playgroundConfigEntity.finalScale;
2327
2416
  if (this.containerRef.current) {
2328
2417
  const dragNode = this.containerRef.current.children?.[0];
2329
- const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - this.playgroundConfigEntity.config.clientX - (dragNode.clientWidth - this.dragOffset.x) * scale;
2330
- const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - this.playgroundConfigEntity.config.clientY - (dragNode.clientHeight - this.dragOffset.y) * scale;
2331
- const isBranch = this.service.isDragBranch;
2418
+ const clientBounds = this.playgroundConfigEntity.getClientBounds();
2419
+ const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x - (dragNode.clientWidth - this.dragOffset.x) * scale;
2420
+ const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y - (dragNode.clientHeight - this.dragOffset.y) * scale;
2421
+ const isBranch = this.flowDragService.isDragBranch;
2332
2422
  const draggingRect = new Rectangle8(
2333
2423
  dragBlockX,
2334
2424
  dragBlockY,
@@ -2348,7 +2438,7 @@ var FlowDragLayer = class extends Layer7 {
2348
2438
  side = labelOffsetType;
2349
2439
  return hasCollision;
2350
2440
  });
2351
- if (collisionTransition && (isBranch ? this.service.isDroppableBranch(collisionTransition.entity, side) : this.service.isDroppableNode(collisionTransition.entity)) && (!this.options.canDrop || this.options.canDrop({
2441
+ if (collisionTransition && (isBranch ? this.flowDragService.isDroppableBranch(collisionTransition.entity, side) : this.flowDragService.isDroppableNode(collisionTransition.entity)) && (!this.options.canDrop || this.options.canDrop({
2352
2442
  dragNodes: this.dragEntities,
2353
2443
  dropNode: collisionTransition.entity,
2354
2444
  isBranch
@@ -2360,37 +2450,45 @@ var FlowDragLayer = class extends Layer7 {
2360
2450
  this.flowRenderStateEntity.setDragLabelSide(side);
2361
2451
  this.containerRef.current.style.visibility = "visible";
2362
2452
  this.pipelineNode.parentElement.appendChild(this.draggingNodeMask);
2363
- this.containerRef.current.style.left = `${dragBlockX}px`;
2364
- this.containerRef.current.style.top = `${dragBlockY}px`;
2453
+ this.containerRef.current.style.left = `${dragBlockX + this.pipelineNode.offsetLeft + clientBounds.x + window.scrollX}px`;
2454
+ this.containerRef.current.style.top = `${dragBlockY + this.pipelineNode.offsetTop + clientBounds.y + window.scrollY}px`;
2365
2455
  this.containerRef.current.style.transformOrigin = "top left";
2366
2456
  this.containerRef.current.style.transform = `scale(${scale})`;
2367
- this.flowDragConfigEntity.scrollDirection(
2368
- event,
2369
- this.containerRef.current,
2370
- dragBlockX,
2371
- dragBlockY
2372
- );
2457
+ if (!this.disableDragScroll) {
2458
+ this.flowDragConfigEntity.scrollDirection(event, dragBlockX, dragBlockY);
2459
+ }
2373
2460
  }
2374
2461
  }
2375
2462
  }
2376
- handleMouseUp() {
2463
+ async handleMouseUp() {
2377
2464
  this.setDraggingStatus(false);
2378
- if (this.dragStartEntity) {
2379
- const activatedNodeId = this.service.dropNodeId;
2465
+ if (this.dragStartEntity || this.dragJSON) {
2466
+ const activatedNodeId = this.flowDragService.dropNodeId;
2380
2467
  if (activatedNodeId) {
2381
- if (this.service.isDragBranch) {
2382
- this.service.dropBranch();
2468
+ if (this.flowDragService.isDragBranch) {
2469
+ if (this.dragJSON) {
2470
+ await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
2471
+ } else {
2472
+ this.flowDragService.dropBranch();
2473
+ }
2383
2474
  } else {
2384
- this.service.dropNode();
2475
+ if (this.dragJSON) {
2476
+ await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
2477
+ } else {
2478
+ this.flowDragService.dropNode();
2479
+ }
2385
2480
  this.selectConfigEntity.clearSelectedNodes();
2386
2481
  }
2387
2482
  }
2388
2483
  this.flowRenderStateEntity.setNodeDroppingId("");
2389
2484
  this.flowRenderStateEntity.setDragLabelSide();
2485
+ this.flowRenderStateEntity.setIsBranch(false);
2390
2486
  this.dragStartEntity = void 0;
2391
2487
  this.dragEntities = [];
2392
2488
  this.flowDragConfigEntity.stopAllScroll();
2393
2489
  }
2490
+ this.disableDragScroll = false;
2491
+ this.dragJSON = void 0;
2394
2492
  if (this.containerRef.current) {
2395
2493
  this.containerRef.current.style.visibility = "hidden";
2396
2494
  if (this.pipelineNode.parentElement.contains(this.draggingNodeMask)) {
@@ -2404,17 +2502,25 @@ var FlowDragLayer = class extends Layer7 {
2404
2502
  */
2405
2503
  async startDrag(e, {
2406
2504
  dragStartEntity: startEntityFromProps,
2407
- dragEntities
2505
+ dragEntities,
2506
+ dragJSON,
2507
+ isBranch,
2508
+ onCreateNode
2408
2509
  }, options) {
2409
2510
  if (this.isGrab() || this.config.disabled || this.config.readonly) {
2410
2511
  return;
2411
2512
  }
2513
+ this.disableDragScroll = Boolean(options?.disableDragScroll);
2514
+ this.dragJSON = dragJSON;
2515
+ this.onCreateNode = onCreateNode;
2516
+ this.flowRenderStateEntity.setIsBranch(Boolean(isBranch));
2412
2517
  this.dragOffset.x = options?.dragOffsetX || DEFAULT_DRAG_OFFSET_X;
2413
2518
  this.dragOffset.y = options?.dragOffsetY || DEFAULT_DRAG_OFFSET_Y;
2414
- const isIcon = startEntityFromProps.flowNodeType === FlowNodeBaseType.BLOCK_ICON;
2415
- const isOrderIcon = startEntityFromProps.flowNodeType === FlowNodeBaseType.BLOCK_ORDER_ICON;
2519
+ const type = startEntityFromProps?.flowNodeType || dragJSON?.type;
2520
+ const isIcon = type === FlowNodeBaseType.BLOCK_ICON;
2521
+ const isOrderIcon = type === FlowNodeBaseType.BLOCK_ORDER_ICON;
2416
2522
  const dragStartEntity = isIcon || isOrderIcon ? startEntityFromProps.parent : startEntityFromProps;
2417
- if (!dragStartEntity.getData(FlowNodeRenderData5).draggable) {
2523
+ if (dragStartEntity && !dragStartEntity.getData(FlowNodeRenderData5).draggable) {
2418
2524
  return;
2419
2525
  }
2420
2526
  this.initialPosition = {
@@ -2422,7 +2528,7 @@ var FlowDragLayer = class extends Layer7 {
2422
2528
  y: e.clientY
2423
2529
  };
2424
2530
  this.dragStartEntity = dragStartEntity;
2425
- this.dragEntities = dragEntities || [this.dragStartEntity];
2531
+ this.dragEntities = dragEntities || (this.dragStartEntity ? [this.dragStartEntity] : []);
2426
2532
  return this._dragger.start(e.clientX, e.clientY);
2427
2533
  }
2428
2534
  onReady() {
@@ -2434,19 +2540,33 @@ var FlowDragLayer = class extends Layer7 {
2434
2540
  this.draggingNodeMask.style.cursor = "pointer";
2435
2541
  this.dragNodeComp = this.rendererRegistry.getRendererComponent("drag-node" /* DRAG_NODE */);
2436
2542
  if (this.options.onDrop) {
2437
- this.toDispose.push(this.service.onDrop(this.options.onDrop));
2543
+ this.toDispose.push(this.flowDragService.onDrop(this.options.onDrop));
2438
2544
  }
2439
2545
  }
2546
+ dispose() {
2547
+ this._dragger.dispose();
2548
+ super.dispose();
2549
+ }
2440
2550
  render() {
2441
2551
  const DragComp = this.dragNodeComp.renderer;
2442
- return /* @__PURE__ */ React15.createElement(
2443
- "div",
2444
- {
2445
- ref: this.containerRef,
2446
- style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
2447
- onMouseEnter: (e) => e.stopPropagation()
2448
- },
2449
- /* @__PURE__ */ React15.createElement(DragComp, { dragStart: this.dragStartEntity, dragNodes: this.dragEntities })
2552
+ return ReactDOM2.createPortal(
2553
+ /* @__PURE__ */ React15.createElement(
2554
+ "div",
2555
+ {
2556
+ ref: this.containerRef,
2557
+ style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
2558
+ onMouseEnter: (e) => e.stopPropagation()
2559
+ },
2560
+ /* @__PURE__ */ React15.createElement(
2561
+ DragComp,
2562
+ {
2563
+ dragJSON: this.dragJSON,
2564
+ dragStart: this.dragStartEntity,
2565
+ dragNodes: this.dragEntities
2566
+ }
2567
+ )
2568
+ ),
2569
+ document.body
2450
2570
  );
2451
2571
  }
2452
2572
  };
@@ -2455,7 +2575,7 @@ __decorateClass([
2455
2575
  ], FlowDragLayer.prototype, "document", 2);
2456
2576
  __decorateClass([
2457
2577
  inject8(FlowDragService5)
2458
- ], FlowDragLayer.prototype, "service", 2);
2578
+ ], FlowDragLayer.prototype, "flowDragService", 2);
2459
2579
  __decorateClass([
2460
2580
  observeEntityDatas6(FlowNodeEntity6, FlowNodeTransformData7)
2461
2581
  ], FlowDragLayer.prototype, "transforms", 2);
@@ -2659,11 +2779,8 @@ FlowSelectorBoxLayer = __decorateClass([
2659
2779
  // src/layers/flow-selector-bounds-layer.tsx
2660
2780
  import React16 from "react";
2661
2781
  import { inject as inject10, injectable as injectable11 } from "inversify";
2662
- import {
2663
- FlowNodeEntity as FlowNodeEntity8,
2664
- FlowNodeRenderData as FlowNodeRenderData6,
2665
- FlowNodeTransformData as FlowNodeTransformData9
2666
- } from "@flowgram.ai/document";
2782
+ import { domUtils as domUtils8 } from "@flowgram.ai/utils";
2783
+ import { FlowNodeEntity as FlowNodeEntity8, FlowNodeRenderData as FlowNodeRenderData6, FlowNodeTransformData as FlowNodeTransformData9 } from "@flowgram.ai/document";
2667
2784
  import {
2668
2785
  CommandRegistry,
2669
2786
  EditorState as EditorState3,
@@ -2672,7 +2789,6 @@ import {
2672
2789
  observeEntity as observeEntity9,
2673
2790
  observeEntityDatas as observeEntityDatas7
2674
2791
  } from "@flowgram.ai/core";
2675
- import { domUtils as domUtils8 } from "@flowgram.ai/utils";
2676
2792
  var FlowSelectorBoundsLayer = class extends Layer9 {
2677
2793
  constructor() {
2678
2794
  super(...arguments);
@@ -2688,7 +2804,9 @@ var FlowSelectorBoundsLayer = class extends Layer9 {
2688
2804
  if (this.options.backgroundClassName) {
2689
2805
  this.selectBoundsBackground.classList.add(this.options.backgroundClassName);
2690
2806
  }
2691
- const selectorBoundsLayer = domUtils8.createDivWithClass("gedit-playground-layer");
2807
+ const selectorBoundsLayer = domUtils8.createDivWithClass(
2808
+ "gedit-selector-bounds-background-layer gedit-playground-layer"
2809
+ );
2692
2810
  selectorBoundsLayer.appendChild(this.selectBoundsBackground);
2693
2811
  this.pipelineNode.insertBefore(selectorBoundsLayer, firstChild);
2694
2812
  }
@@ -2729,6 +2847,7 @@ var FlowSelectorBoundsLayer = class extends Layer9 {
2729
2847
  render() {
2730
2848
  const {
2731
2849
  ignoreOneSelect,
2850
+ ignoreChildrenLength,
2732
2851
  SelectorBoxPopover: SelectorBoxPopoverFromOpts,
2733
2852
  disableBackground,
2734
2853
  CustomBoundsRenderer
@@ -2739,7 +2858,7 @@ var FlowSelectorBoundsLayer = class extends Layer9 {
2739
2858
  const isDragging = !this.selectorBoxConfigEntity.isStart;
2740
2859
  if (bounds.width === 0 || bounds.height === 0 || // 选中单个的时候不显示
2741
2860
  ignoreOneSelect && selectedNodes.length === 1 && // 选中的节点不包含多个子节点
2742
- selectedNodes[0].childrenLength <= 1) {
2861
+ (ignoreChildrenLength || selectedNodes[0].childrenLength <= 1)) {
2743
2862
  domUtils8.setStyle(bg, {
2744
2863
  display: "none"
2745
2864
  });
@@ -2813,6 +2932,7 @@ FlowSelectorBoundsLayer = __decorateClass([
2813
2932
  // src/layers/flow-context-menu-layer.tsx
2814
2933
  import React17 from "react";
2815
2934
  import { inject as inject11, injectable as injectable12 } from "inversify";
2935
+ import { domUtils as domUtils9 } from "@flowgram.ai/utils";
2816
2936
  import {
2817
2937
  CommandRegistry as CommandRegistry2,
2818
2938
  ContextMenuService as ContextMenuService2,
@@ -2824,7 +2944,6 @@ import {
2824
2944
  PlaygroundConfigEntity as PlaygroundConfigEntity5,
2825
2945
  SelectionService as SelectionService2
2826
2946
  } from "@flowgram.ai/core";
2827
- import { domUtils as domUtils9 } from "@flowgram.ai/utils";
2828
2947
  var FlowContextMenuLayer = class extends Layer10 {
2829
2948
  constructor() {
2830
2949
  super(...arguments);
@@ -2851,8 +2970,9 @@ var FlowContextMenuLayer = class extends Layer10 {
2851
2970
  e.stopPropagation();
2852
2971
  e.preventDefault();
2853
2972
  this.nodeRef.current?.setVisible(true);
2854
- const dragBlockX = e.clientX - (this.pipelineNode.offsetLeft || 0) - this.playgroundConfigEntity.config.clientX;
2855
- const dragBlockY = e.clientY - (this.pipelineNode.offsetTop || 0) - this.playgroundConfigEntity.config.clientY;
2973
+ const clientBounds = this.playgroundConfigEntity.getClientBounds();
2974
+ const dragBlockX = e.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x;
2975
+ const dragBlockY = e.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y;
2856
2976
  this.node.style.left = `${dragBlockX}px`;
2857
2977
  this.node.style.top = `${dragBlockY}px`;
2858
2978
  },
@@ -2990,6 +3110,7 @@ export {
2990
3110
  MARK_ARROW_ID,
2991
3111
  ScrollBarEvents,
2992
3112
  SelectorBoxConfigEntity,
3113
+ createLines,
2993
3114
  useBaseColor
2994
3115
  };
2995
3116
  //# sourceMappingURL=index.js.map