You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
921 B
23 lines
921 B
import { idOf } from '../utils/id';
|
|
import { BaseTransform } from './base-transform';
|
|
/**
|
|
* 如果更新了节点 / combo,需要更新连接的边
|
|
* If the node / combo is updated, the connected edge and the combo it is in need to be updated
|
|
*/
|
|
export class UpdateRelatedEdge extends BaseTransform {
|
|
beforeDraw(input, context) {
|
|
const { stage } = context;
|
|
if (stage === 'visibility')
|
|
return input;
|
|
const { model } = this.context;
|
|
const { update: { nodes, edges, combos }, } = input;
|
|
const addRelatedEdges = (_, id) => {
|
|
const relatedEdgesData = model.getRelatedEdgesData(id);
|
|
relatedEdgesData.forEach((edge) => !edges.has(idOf(edge)) && edges.set(idOf(edge), edge));
|
|
};
|
|
nodes.forEach(addRelatedEdges);
|
|
combos.forEach(addRelatedEdges);
|
|
return input;
|
|
}
|
|
}
|
|
//# sourceMappingURL=update-related-edge.js.map
|