refactoring

This commit is contained in:
2026-09-02 08:38:03 +02:00
parent 649ff0d7c5
commit 38f255c1a4
48 changed files with 6998 additions and 5577 deletions
+37
View File
@@ -0,0 +1,37 @@
/**
* Present a CMap through the bundled drawing engine.
*
* CmapView owns the canvas and concrete cmap.js instance. It creates and
* destroys drawing objects but contains no concept, placement or persistence
* rules; CmapEditor remains responsible for interpreting user interaction.
*/
export class CmapView {
constructor(canvas, CmapFactory, onSelection, onActivation) {
if (!(canvas instanceof Object)) throw new TypeError("A CMap canvas is required");
if (typeof CmapFactory !== "function") throw new TypeError("A CMap factory is required");
this.canvas = canvas;
this.map = CmapFactory(canvas);
this.map.onSelection(onSelection);
this.map.onActivation(onActivation);
}
createNode(attributes) {
return this.map.node(attributes);
}
createConnector(attributes) {
return this.map.link(attributes);
}
setZoom(factor) {
this.map.zoom(factor);
}
surfaceElement() {
return this.canvas.querySelector(":scope > .rw-cmap-surface");
}
destroy() {
if (typeof this.map.destroy === "function") this.map.destroy();
}
}