@flowgram.ai/document 0.1.0-alpha.18 → 0.1.0-alpha.19

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";
@@ -289,13 +288,14 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
289
288
  stackIndex: 0
290
289
  };
291
290
  }
292
- updateExtInfo(info) {
293
- if (Compare.isChanged(this.data.extInfo, info)) {
294
- const oldInfo = this.data.extInfo;
291
+ updateExtInfo(info, fullUpdate) {
292
+ const oldInfo = this.data.extInfo;
293
+ const newInfo = fullUpdate ? info : { ...oldInfo, ...info };
294
+ if (Compare.isChanged(oldInfo, newInfo)) {
295
295
  this.update({
296
- extInfo: info
296
+ extInfo: newInfo
297
297
  });
298
- this.onExtInfoChangeEmitter.fire({ oldInfo, newInfo: info });
298
+ this.onExtInfoChangeEmitter.fire({ oldInfo, newInfo });
299
299
  }
300
300
  }
301
301
  getExtInfo() {
@@ -1041,8 +1041,8 @@ var FlowNodeEntity = class extends Entity {
1041
1041
  * 修改节点扩展信息
1042
1042
  * @param info
1043
1043
  */
1044
- updateExtInfo(extInfo) {
1045
- this.getData(FlowNodeRenderData).updateExtInfo(extInfo);
1044
+ updateExtInfo(extInfo, fullUpdate) {
1045
+ this.getData(FlowNodeRenderData).updateExtInfo(extInfo, fullUpdate);
1046
1046
  }
1047
1047
  /**
1048
1048
  * 获取节点扩展信息
@@ -1194,6 +1194,22 @@ var FlowRendererStateEntity = class extends ConfigEntity2 {
1194
1194
  nodeHoveredId: node?.id
1195
1195
  });
1196
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
+ }
1197
1213
  getDragLabelSide() {
1198
1214
  return this.config.dragLabelSide;
1199
1215
  }
@@ -2450,15 +2466,14 @@ var FlowDragService = class {
2450
2466
  }
2451
2467
  // 是否在拖拽分支
2452
2468
  get isDragBranch() {
2453
- return this.dragStartNode?.isInlineBlock;
2469
+ return this.renderState.isBranch || this.dragStartNode?.isInlineBlock;
2454
2470
  }
2455
2471
  // 拖拽的所有节点及其自节点
2456
2472
  get nodeDragIdsWithChildren() {
2457
2473
  return this.renderState.config.nodeDragIdsWithChildren || [];
2458
2474
  }
2459
2475
  get dragging() {
2460
- const renderData = this.dragStartNode?.getData(FlowNodeRenderData);
2461
- return !!renderData?.dragging;
2476
+ return !!this.renderState.dragging;
2462
2477
  }
2463
2478
  get labelSide() {
2464
2479
  return this.renderState.config.dragLabelSide;
@@ -2469,6 +2484,24 @@ var FlowDragService = class {
2469
2484
  dropBranch() {
2470
2485
  this.dropNode();
2471
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
+ }
2472
2505
  /**
2473
2506
  * 移动到目标节点
2474
2507
  */
@@ -2524,6 +2557,9 @@ var FlowDragService = class {
2524
2557
  * @param side 分支的前面还是后面
2525
2558
  */
2526
2559
  isDroppableBranch(node, side = "normal_branch" /* NORMAL_BRANCH */) {
2560
+ if (this.renderState.isBranch) {
2561
+ return true;
2562
+ }
2527
2563
  if (this.isDragBranch) {
2528
2564
  if (
2529
2565
  // 拖拽到分支