big cmap refactoring

This commit is contained in:
2026-09-03 08:40:15 +02:00
parent f0562a06cc
commit 2c141b6d3f
32 changed files with 5616 additions and 4216 deletions
+48
View File
@@ -0,0 +1,48 @@
import {
DiagramComponent,
pickAttributes,
validateOptionalHandler
} from "./diagram-component.js";
import { DrawingNode } from "./drawing-core.js";
const NODE_ATTRIBUTES = [
"content",
"contentType",
"x",
"y",
"width",
"height",
"backgroundColor",
"borderColor",
"borderWidth",
"textColor"
];
/**
* Public rendering handle for one diagram node.
*
* DiagramEngine creates nodes and owns their lifetime. The editor uses this
* handle to update presentation attributes and receive completed moves.
*/
export class DiagramNode extends DiagramComponent {
constructor(engine, attributes) {
const component = new DrawingNode(pickAttributes(attributes, NODE_ATTRIBUTES));
super(engine, component, NODE_ATTRIBUTES);
}
/** Constrain or observe the node while it is being dragged. */
onMove(handler) {
validateOptionalHandler(handler, "move");
this.component.moveHandler = handler ?
(x, y) => handler(this, x, y) : null;
return this;
}
/** Register a callback for the end of a node drag gesture. */
onMoveEnd(handler) {
validateOptionalHandler(handler, "move-end");
this.component.moveEndHandler = handler ?
(x, y, event) => handler(this, x, y, event) : null;
return this;
}
}