@flowgram.ai/document 0.5.0 → 0.5.2

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
@@ -289,13 +289,14 @@ var _FlowNodeRenderData = class _FlowNodeRenderData extends EntityData {
289
289
  stackIndex: 0
290
290
  };
291
291
  }
292
- updateExtInfo(info) {
293
- if (Compare.isChanged(this.data.extInfo, info)) {
294
- const oldInfo = this.data.extInfo;
292
+ updateExtInfo(info, fullUpdate) {
293
+ const oldInfo = this.data.extInfo;
294
+ const newInfo = fullUpdate ? info : { ...oldInfo, ...info };
295
+ if (Compare.isChanged(oldInfo, newInfo)) {
295
296
  this.update({
296
- extInfo: info
297
+ extInfo: newInfo
297
298
  });
298
- this.onExtInfoChangeEmitter.fire({ oldInfo, newInfo: info });
299
+ this.onExtInfoChangeEmitter.fire({ oldInfo, newInfo });
299
300
  }
300
301
  }
301
302
  getExtInfo() {
@@ -1041,8 +1042,8 @@ var FlowNodeEntity = class extends Entity {
1041
1042
  * 修改节点扩展信息
1042
1043
  * @param info
1043
1044
  */
1044
- updateExtInfo(extInfo) {
1045
- this.getData(FlowNodeRenderData).updateExtInfo(extInfo);
1045
+ updateExtInfo(extInfo, fullUpdate) {
1046
+ this.getData(FlowNodeRenderData).updateExtInfo(extInfo, fullUpdate);
1046
1047
  }
1047
1048
  /**
1048
1049
  * 获取节点扩展信息
@@ -1194,6 +1195,14 @@ var FlowRendererStateEntity = class extends ConfigEntity2 {
1194
1195
  nodeHoveredId: node?.id
1195
1196
  });
1196
1197
  }
1198
+ get dragging() {
1199
+ return this.config.dragging;
1200
+ }
1201
+ setDragging(dragging) {
1202
+ this.updateConfig({
1203
+ dragging
1204
+ });
1205
+ }
1197
1206
  getDragLabelSide() {
1198
1207
  return this.config.dragLabelSide;
1199
1208
  }
@@ -2457,8 +2466,7 @@ var FlowDragService = class {
2457
2466
  return this.renderState.config.nodeDragIdsWithChildren || [];
2458
2467
  }
2459
2468
  get dragging() {
2460
- const renderData = this.dragStartNode?.getData(FlowNodeRenderData);
2461
- return !!renderData?.dragging;
2469
+ return !!this.renderState.dragging;
2462
2470
  }
2463
2471
  get labelSide() {
2464
2472
  return this.renderState.config.dragLabelSide;
@@ -2469,6 +2477,24 @@ var FlowDragService = class {
2469
2477
  dropBranch() {
2470
2478
  this.dropNode();
2471
2479
  }
2480
+ /**
2481
+ * 移动并且创建节点
2482
+ * Move and create node
2483
+ */
2484
+ async dropCreateNode(json, onCreateNode) {
2485
+ const dropEntity = this.document.getNode(this.dropNodeId);
2486
+ if (!dropEntity) {
2487
+ return;
2488
+ }
2489
+ if (json) {
2490
+ const dragNodes = await onCreateNode?.(json, dropEntity);
2491
+ this.onDropEmitter.fire({
2492
+ dropNode: dropEntity,
2493
+ dragNodes: dragNodes ? [dragNodes] : [],
2494
+ dragJSON: json
2495
+ });
2496
+ }
2497
+ }
2472
2498
  /**
2473
2499
  * 移动到目标节点
2474
2500
  */