@flowgram.ai/document 0.5.1 → 0.5.3

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
@@ -240,7 +240,6 @@ var OperationType = /* @__PURE__ */ ((OperationType2) => {
240
240
  OperationType2["moveChildNodes"] = "moveChildNodes";
241
241
  OperationType2["addNodes"] = "addNodes";
242
242
  OperationType2["deleteNodes"] = "deleteNodes";
243
- OperationType2["changeNode"] = "changeNode";
244
243
  OperationType2["addChildNode"] = "addChildNode";
245
244
  OperationType2["deleteChildNode"] = "deleteChildNode";
246
245
  OperationType2["addNode"] = "addNode";
@@ -1195,6 +1194,22 @@ var FlowRendererStateEntity = class extends ConfigEntity2 {
1195
1194
  nodeHoveredId: node?.id
1196
1195
  });
1197
1196
  }
1197
+ get dragging() {
1198
+ return this.config.dragging;
1199
+ }
1200
+ setDragging(dragging) {
1201
+ this.updateConfig({
1202
+ dragging
1203
+ });
1204
+ }
1205
+ get isBranch() {
1206
+ return this.config.isBranch;
1207
+ }
1208
+ setIsBranch(isBranch) {
1209
+ this.updateConfig({
1210
+ isBranch
1211
+ });
1212
+ }
1198
1213
  getDragLabelSide() {
1199
1214
  return this.config.dragLabelSide;
1200
1215
  }
@@ -2451,15 +2466,14 @@ var FlowDragService = class {
2451
2466
  }
2452
2467
  // 是否在拖拽分支
2453
2468
  get isDragBranch() {
2454
- return this.dragStartNode?.isInlineBlock;
2469
+ return this.renderState.isBranch || this.dragStartNode?.isInlineBlock;
2455
2470
  }
2456
2471
  // 拖拽的所有节点及其自节点
2457
2472
  get nodeDragIdsWithChildren() {
2458
2473
  return this.renderState.config.nodeDragIdsWithChildren || [];
2459
2474
  }
2460
2475
  get dragging() {
2461
- const renderData = this.dragStartNode?.getData(FlowNodeRenderData);
2462
- return !!renderData?.dragging;
2476
+ return !!this.renderState.dragging;
2463
2477
  }
2464
2478
  get labelSide() {
2465
2479
  return this.renderState.config.dragLabelSide;
@@ -2470,6 +2484,24 @@ var FlowDragService = class {
2470
2484
  dropBranch() {
2471
2485
  this.dropNode();
2472
2486
  }
2487
+ /**
2488
+ * 移动并且创建节点
2489
+ * Move and create node
2490
+ */
2491
+ async dropCreateNode(json, onCreateNode) {
2492
+ const dropEntity = this.document.getNode(this.dropNodeId);
2493
+ if (!dropEntity) {
2494
+ return;
2495
+ }
2496
+ if (json) {
2497
+ const dragNodes = await onCreateNode?.(json, dropEntity);
2498
+ this.onDropEmitter.fire({
2499
+ dropNode: dropEntity,
2500
+ dragNodes: dragNodes ? [dragNodes] : [],
2501
+ dragJSON: json
2502
+ });
2503
+ }
2504
+ }
2473
2505
  /**
2474
2506
  * 移动到目标节点
2475
2507
  */
@@ -2525,6 +2557,9 @@ var FlowDragService = class {
2525
2557
  * @param side 分支的前面还是后面
2526
2558
  */
2527
2559
  isDroppableBranch(node, side = "normal_branch" /* NORMAL_BRANCH */) {
2560
+ if (this.renderState.isBranch) {
2561
+ return true;
2562
+ }
2528
2563
  if (this.isDragBranch) {
2529
2564
  if (
2530
2565
  // 拖拽到分支