@mocanvas/editor 4.8.2 → 4.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -8173,7 +8173,17 @@ interface EditorOptions {
8173
8173
  engine?: EngineBridge;
8174
8174
  /** Id of the tool to start in. Defaults to the first tool. */
8175
8175
  initialState?: string;
8176
- getContainer: () => HTMLElement;
8176
+ /**
8177
+ * The element the editor lives in. Optional, and optional is the point: an
8178
+ * editor with no screen — an agent on a server, a fold job, a test — has no
8179
+ * element to give, and requiring one made the headless path start by
8180
+ * inventing a fake DOM node. Everything inside already copes (see
8181
+ * `safeContainer`); it was only the type that insisted.
8182
+ *
8183
+ * Omitted, {@link Editor.getContainer} throws if anything asks for it, which
8184
+ * is a sentence rather than a mystery further down.
8185
+ */
8186
+ getContainer?: () => HTMLElement;
8177
8187
  options?: Partial<EditorConfig>;
8178
8188
  /**
8179
8189
  * Where asset bytes live. Defaults to the store's own
package/dist/index.js CHANGED
@@ -7974,7 +7974,11 @@ var Editor = class extends EventEmitter {
7974
7974
  super();
7975
7975
  this.store = opts.store;
7976
7976
  this.engine = opts.engine ?? requireEngine();
7977
- this.getContainer = opts.getContainer;
7977
+ this.getContainer = opts.getContainer ?? (() => {
7978
+ throw new Error(
7979
+ "mocanvas: this editor was built without `getContainer`, so it has no container \u2014 which is expected for a headless editor. Pass one if something needs the element."
7980
+ );
7981
+ });
7978
7982
  this.options = { ...DEFAULT_EDITOR_CONFIG, ...opts.options };
7979
7983
  this.sideEffects = this.store.sideEffects;
7980
7984
  this.snaps = new SnapManager(this);