big cmap refactoring
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user