refactoring of cmaps, widgets, etc.

This commit is contained in:
2026-09-02 16:06:26 +02:00
parent 38f255c1a4
commit f0562a06cc
52 changed files with 3626 additions and 2642 deletions
+19
View File
@@ -1153,6 +1153,12 @@ import { CmapView } from "./cmap-view.js";
return true;
}
/** Replace the editor contents with a public CMap domain model. */
replaceModel(model) {
if (!(model instanceof CmapModel)) throw new TypeError("A CmapModel is required");
return this.replaceDocument(model.toDocument());
}
setZoom(percent) {
const next = Math.max(25, Math.min(300, Number(percent) || 100));
this.zoomFactor = next / 100;
@@ -1866,6 +1872,19 @@ import { CmapView } from "./cmap-view.js";
return this.synchronizeModel().toDocument();
}
/** Return the synchronized domain model currently edited by this view. */
currentModel() {
this.saveCurrentContextLayout();
this.refreshConceptMapReferences();
return this.synchronizeModel();
}
/** Load a public CMap domain model into an empty editor. */
loadModel(model) {
if (!(model instanceof CmapModel)) throw new TypeError("A CmapModel is required");
this.loadDocument(model.toDocument());
}
loadDocument(document = {}) {
if (this.items.length || this.connectors.length || this.unresolvedConnectors.length) {
throw new Error("A concept map document can only be loaded into an empty editor");