feat(web): 调整便签节点位置
This commit is contained in:
@@ -1152,12 +1152,15 @@ export const useWorkflowGraph = ({
|
|||||||
name: t('workflow.notes'),
|
name: t('workflow.notes'),
|
||||||
...nodeConfig,
|
...nodeConfig,
|
||||||
};
|
};
|
||||||
const area = graphRef.current.getGraphArea();
|
const container = graphRef.current.container;
|
||||||
const pos = graphRef.current.graphToLocal(area.center.x, area.bottom);
|
const nodeW = graphNodeLibrary.notes?.width || nodeWidth;
|
||||||
|
const nodeH = graphNodeLibrary.notes?.height || 100;
|
||||||
|
const rect = container.getBoundingClientRect();
|
||||||
|
const center = graphRef.current.clientToLocal(rect.left + rect.width / 2, rect.top + rect.height / 2);
|
||||||
graphRef.current.addNode({
|
graphRef.current.addNode({
|
||||||
...(graphNodeLibrary.notes || graphNodeLibrary.default),
|
...(graphNodeLibrary.notes || graphNodeLibrary.default),
|
||||||
x: pos.x - nodeWidth,
|
x: center.x - nodeW / 2,
|
||||||
y: pos.y,
|
y: center.y - nodeH / 2,
|
||||||
id: cleanNodeData.id,
|
id: cleanNodeData.id,
|
||||||
data: { ...cleanNodeData },
|
data: { ...cleanNodeData },
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user