wip
This commit is contained in:
parent
48fd8fef73
commit
6d77ff13c9
@ -185,4 +185,15 @@ export class TpFlowNode extends LitElement {
|
||||
this.style.transform = `translate(${data.position.x}px, ${data.position.y}px)`;
|
||||
}
|
||||
}
|
||||
|
||||
dispatchDataUpdate() {
|
||||
this.dispatchEvent(new CustomEvent('flow-changed', {
|
||||
detail: {
|
||||
type: 'node-data-changed',
|
||||
data: this.exportData()
|
||||
},
|
||||
bubbles: true,
|
||||
composed: true
|
||||
}));
|
||||
}
|
||||
}
|
@ -163,12 +163,16 @@ export class TpFlowNodes extends zoom(panning(connections(LitElement))) {
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust position for current canvas translation and scale
|
||||
const adjustedX = (x - this.currentX) / this.scale;
|
||||
const adjustedY = (y - this.currentY) / this.scale;
|
||||
|
||||
const node = new NodeClass();
|
||||
node.setAttribute('part', 'node');
|
||||
node.setAttribute('exportparts', 'node-content');
|
||||
node.importData({
|
||||
id: `node_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
|
||||
position: { x, y },
|
||||
position: { x: adjustedX, y: adjustedY },
|
||||
data: initialData
|
||||
});
|
||||
|
||||
@ -231,9 +235,8 @@ export class TpFlowNodes extends zoom(panning(connections(LitElement))) {
|
||||
_dispatchChangeEvent(detail = {}) {
|
||||
this.dispatchEvent(new CustomEvent('flow-changed', {
|
||||
detail: {
|
||||
type: detail.type, // Type of change: 'node-added', 'node-removed', 'node-moved', 'connection-added', etc.
|
||||
data: detail.data, // Additional data specific to the change
|
||||
flow: this.exportFlow() // Current state of the entire flow
|
||||
type: detail.type, // Type of change: 'node-added', 'node-removed', 'node-moved', 'connection-added', 'node-data-changed'.
|
||||
data: detail.data,
|
||||
},
|
||||
bubbles: true,
|
||||
composed: true
|
||||
|
Loading…
x
Reference in New Issue
Block a user