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)`;
|
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();
|
const node = new NodeClass();
|
||||||
node.setAttribute('part', 'node');
|
node.setAttribute('part', 'node');
|
||||||
node.setAttribute('exportparts', 'node-content');
|
node.setAttribute('exportparts', 'node-content');
|
||||||
node.importData({
|
node.importData({
|
||||||
id: `node_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
|
id: `node_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
|
||||||
position: { x, y },
|
position: { x: adjustedX, y: adjustedY },
|
||||||
data: initialData
|
data: initialData
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -231,9 +235,8 @@ export class TpFlowNodes extends zoom(panning(connections(LitElement))) {
|
|||||||
_dispatchChangeEvent(detail = {}) {
|
_dispatchChangeEvent(detail = {}) {
|
||||||
this.dispatchEvent(new CustomEvent('flow-changed', {
|
this.dispatchEvent(new CustomEvent('flow-changed', {
|
||||||
detail: {
|
detail: {
|
||||||
type: detail.type, // Type of change: 'node-added', 'node-removed', 'node-moved', 'connection-added', etc.
|
type: detail.type, // Type of change: 'node-added', 'node-removed', 'node-moved', 'connection-added', 'node-data-changed'.
|
||||||
data: detail.data, // Additional data specific to the change
|
data: detail.data,
|
||||||
flow: this.exportFlow() // Current state of the entire flow
|
|
||||||
},
|
},
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
composed: true
|
composed: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user