@domternal/core 0.7.4 → 0.7.5

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.cjs CHANGED
@@ -299,7 +299,8 @@ var ExtensionManager = class {
299
299
  }
300
300
  const flattened = this.flattenExtensions(options.extensions);
301
301
  const deduped = this.deduplicateExtensions(flattened);
302
- this._extensions = this.resolveExtensions(deduped);
302
+ const cloned = this.cloneExtensions(deduped);
303
+ this._extensions = this.resolveExtensions(cloned);
303
304
  this.detectConflicts();
304
305
  this.checkDependencies();
305
306
  this.bindEditorToExtensions();
@@ -407,6 +408,17 @@ var ExtensionManager = class {
407
408
  }
408
409
  return extensions.filter((ext, i) => seen.get(ext.name) === i);
409
410
  }
411
+ /**
412
+ * Clone every extension so this editor owns its instances. Extensions hold
413
+ * per-editor mutable state (`editor`, plus the `nodeType`/`markType` getters
414
+ * derived from it), and the same extension object is commonly reused across
415
+ * editors (one shared `extensions` array). Without cloning, binding a later
416
+ * editor clobbers an earlier one: its list `Enter` then falls back to a plain
417
+ * block split, dropping an indented "child" paragraph instead of a new `<li>`.
418
+ */
419
+ cloneExtensions(extensions) {
420
+ return extensions.map((ext) => ext.clone());
421
+ }
410
422
  /**
411
423
  * Sorts extensions by priority (higher priority first)
412
424
  * Default priority is 100
@@ -1539,6 +1551,19 @@ var Extension = class _Extension {
1539
1551
  };
1540
1552
  return new _Extension(newConfig);
1541
1553
  }
1554
+ /**
1555
+ * Returns a fresh, unbound copy built from the same `config`: `editor` reset to
1556
+ * null and `options`/`storage` re-derived, while `configure()`/`extend()`
1557
+ * results are preserved (they live in `config`). Polymorphic: a `Node`/`Mark`
1558
+ * clones to its own subclass.
1559
+ *
1560
+ * `ExtensionManager` clones every extension so each editor owns its instances
1561
+ * and binding one editor can't mutate extensions shared with another.
1562
+ */
1563
+ clone() {
1564
+ const Ctor = this.constructor;
1565
+ return new Ctor(this.config);
1566
+ }
1542
1567
  /**
1543
1568
  * Creates a new extension with extended configuration
1544
1569
  * Original extension is not modified
@@ -8703,8 +8728,13 @@ var SelectionDecoration = Extension.create(
8703
8728
  handleDOMEvents: {
8704
8729
  blur(view, event) {
8705
8730
  const related = event.relatedTarget;
8706
- if (related instanceof HTMLElement && (related.closest("[data-dm-editor-ui]") || related.closest(".dm-toolbar") || related.closest(".dm-bubble-menu"))) {
8707
- return false;
8731
+ if (related instanceof HTMLElement) {
8732
+ const ownContainer = view.dom.closest(".dm-editor");
8733
+ const relatedContainer = related.closest(".dm-editor");
8734
+ const movedToAnotherEditor = ownContainer !== null && relatedContainer !== null && relatedContainer !== ownContainer;
8735
+ if (!movedToAnotherEditor && (related.closest("[data-dm-editor-ui]") || related.closest(".dm-toolbar") || related.closest(".dm-bubble-menu"))) {
8736
+ return false;
8737
+ }
8708
8738
  }
8709
8739
  const { from, to } = view.state.selection;
8710
8740
  if (from !== to) {
@@ -10057,7 +10087,7 @@ var StarterKit = Extension.create({
10057
10087
  maybeAdd(Gapcursor, this.options.gapcursor);
10058
10088
  maybeAdd(TrailingNode, this.options.trailingNode);
10059
10089
  maybeAdd(ListKeymap, this.options.listKeymap);
10060
- maybeAdd(ListIndent, this.options.listIndent);
10090
+ if (this.options.listIndent === true) extensions.push(ListIndent);
10061
10091
  maybeAdd(LinkPopover, this.options.linkPopover);
10062
10092
  maybeAdd(SelectionDecoration, this.options.selectionDecoration);
10063
10093
  return extensions;