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
+7 -3
View File
@@ -1,3 +1,5 @@
import { DiagramEngine } from "./cmap.js";
/**
* Present a CMap through the bundled drawing engine.
*
@@ -6,11 +8,13 @@
* rules; CmapEditor remains responsible for interpreting user interaction.
*/
export class CmapView {
constructor(canvas, CmapFactory, onSelection, onActivation) {
constructor(canvas, onSelection, onActivation, createEngine = null) {
if (!(canvas instanceof Object)) throw new TypeError("A CMap canvas is required");
if (typeof CmapFactory !== "function") throw new TypeError("A CMap factory is required");
if (createEngine !== null && typeof createEngine !== "function") {
throw new TypeError("A diagram-engine factory must be a function");
}
this.canvas = canvas;
this.map = CmapFactory(canvas);
this.map = createEngine ? createEngine(canvas) : new DiagramEngine(canvas);
this.map.onSelection(onSelection);
this.map.onActivation(onActivation);
}