LogicFlow icon indicating copy to clipboard operation
LogicFlow copied to clipboard

[Bug report] 拖拽时生成的faker node的virtual字段拿不到

Open wangzhengbo opened this issue 2 years ago • 2 comments

拖拽时生成的faker node的virtual字段拿不到,希望能够暴露出virtual字段。 因为非virtual node上需要通过logicflow.on来注册一些事件,但不希望在virtual node上注册。 目前的做法是在Model的构造函数中去拿第一个参数nodeConfig的virtual属性,并自己记录下来,希望官方能提供,类似于edge。

目前官网的edge上应该是可以拿到virtual字段的。

createVirtualEdge(edgeData) {
    edgeData.pointsList = undefined;
    const model = this.graphModel.addEdge(edgeData);
    model.virtual = true;
    // 强制不保存group连线数据
    model.getData = () => null;
    model.text.editable = false;
    model.isFoldedEdge = true;
  }

wangzhengbo avatar Apr 14 '22 01:04 wangzhengbo

没有您的想法,目前faker node本来就会有virtual属性. 用来区分拖拽时的节点与画布上的节点。https://github.com/didi/LogicFlow/blob/751c8e067b300e4d58c3263d382e0e4c07b68c09/packages/core/src/LogicFlow.tsx#L991

towersxu avatar Apr 16 '22 03:04 towersxu

没有您的想法,目前faker node本来就会有virtual属性. 用来区分拖拽时的节点与画布上的节点。

https://github.com/didi/LogicFlow/blob/751c8e067b300e4d58c3263d382e0e4c07b68c09/packages/core/src/LogicFlow.tsx#L991

在BaseNodeModel的构造函数中调用了this.initNodeData(data);

  constructor(data: NodeConfig, graphModel: GraphModel) {
    this.graphModel = graphModel;
    this.initNodeData(data);
    this.setAttributes();
  }

在initNodeData中调用了 assign(this, pickNodeConfig(data));

在pickNodeConfig中

export const pickNodeConfig = (data): NodeConfig => {
  const nodeData = pick(data, [
    'id',
    'type',
    'x',
    'y',
    'text',
    'properties',
  ]);
  return nodeData;
};

没有pick virtual字段,导致外部不能确认一个节点到底是不是faker node.

wangzhengbo avatar Apr 18 '22 01:04 wangzhengbo