Fixes and improvements

This commit is contained in:
2025-02-25 19:07:21 +01:00
parent 6d77ff13c9
commit 083a25f302
6 changed files with 247 additions and 85 deletions

View File

@@ -8,6 +8,7 @@ import { LitElement, html, css } from 'lit';
import { connections, connectionStyles } from './connections.js';
import { panning } from './panning.js';
import { zoom } from './zoom.js';
import { repeat } from 'lit/directives/repeat.js';
export class TpFlowNodes extends zoom(panning(connections(LitElement))) {
static nodeTypes = new Map();
@@ -36,10 +37,11 @@ export class TpFlowNodes extends zoom(panning(connections(LitElement))) {
];
}
// Using the repeat directive to render the nodes is important here to prevent the nodes from running into a inconsistent data state when nodes are removed.
render() {
return html`
<div class="canvas">
${this.nodes.map(node => html`${node}`)}
${repeat(this.nodes, node => node.id, node => html`${node}`)}
${this._renderConnections()}
</div>
`;
@@ -61,6 +63,9 @@ export class TpFlowNodes extends zoom(panning(connections(LitElement))) {
connectedCallback() {
super.connectedCallback();
this.addEventListener('node-delete-requested', this._boundDeleteHandler);
this.addEventListener('update-layout', () => {
this.requestUpdate();
})
}
disconnectedCallback() {