@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.d.cts CHANGED
@@ -814,6 +814,15 @@ declare class ExtensionManager {
814
814
  * while letting users override with explicitly configured versions.
815
815
  */
816
816
  private deduplicateExtensions;
817
+ /**
818
+ * Clone every extension so this editor owns its instances. Extensions hold
819
+ * per-editor mutable state (`editor`, plus the `nodeType`/`markType` getters
820
+ * derived from it), and the same extension object is commonly reused across
821
+ * editors (one shared `extensions` array). Without cloning, binding a later
822
+ * editor clobbers an earlier one: its list `Enter` then falls back to a plain
823
+ * block split, dropping an indented "child" paragraph instead of a new `<li>`.
824
+ */
825
+ private cloneExtensions;
817
826
  /**
818
827
  * Sorts extensions by priority (higher priority first)
819
828
  * Default priority is 100
@@ -3480,6 +3489,16 @@ declare class Extension<Options = unknown, Storage = unknown> {
3480
3489
  * // configure({ nested: { ...original.options.nested, b: 3 } })
3481
3490
  */
3482
3491
  configure(options: Partial<Options>): Extension<Options, Storage>;
3492
+ /**
3493
+ * Returns a fresh, unbound copy built from the same `config`: `editor` reset to
3494
+ * null and `options`/`storage` re-derived, while `configure()`/`extend()`
3495
+ * results are preserved (they live in `config`). Polymorphic: a `Node`/`Mark`
3496
+ * clones to its own subclass.
3497
+ *
3498
+ * `ExtensionManager` clones every extension so each editor owns its instances
3499
+ * and binding one editor can't mutate extensions shared with another.
3500
+ */
3501
+ clone(): Extension<Options, Storage>;
3483
3502
  /**
3484
3503
  * Creates a new extension with extended configuration
3485
3504
  * Original extension is not modified
@@ -6304,12 +6323,15 @@ interface StarterKitOptions {
6304
6323
  */
6305
6324
  listKeymap?: false | Partial<ListKeymapOptions>;
6306
6325
  /**
6307
- * Set to false to disable the ListIndent extension. ListIndent adds
6308
- * Tab / Shift-Tab keymap that indents a top-level block under the
6309
- * previous list (and outdents back). Registered AFTER ListKeymap so
6310
- * the in-list-item Tab/Shift-Tab keep priority.
6326
+ * Off by default. Set to `true` to enable the ListIndent extension, which
6327
+ * adds a Tab / Shift-Tab keymap that indents a top-level block under the
6328
+ * previous list (and outdents back). Kept off by default because it captures
6329
+ * Tab on a paragraph that merely follows a list, so Tab no longer moves focus
6330
+ * to the next field in embedded / form usage, and the same nesting is
6331
+ * reachable via the block-menu drag. Registered AFTER ListKeymap so the
6332
+ * in-list-item Tab/Shift-Tab keep priority.
6311
6333
  */
6312
- listIndent?: false;
6334
+ listIndent?: boolean;
6313
6335
  /**
6314
6336
  * Set to false to disable the LinkPopover extension, or pass options to configure it.
6315
6337
  */
package/dist/index.d.ts CHANGED
@@ -814,6 +814,15 @@ declare class ExtensionManager {
814
814
  * while letting users override with explicitly configured versions.
815
815
  */
816
816
  private deduplicateExtensions;
817
+ /**
818
+ * Clone every extension so this editor owns its instances. Extensions hold
819
+ * per-editor mutable state (`editor`, plus the `nodeType`/`markType` getters
820
+ * derived from it), and the same extension object is commonly reused across
821
+ * editors (one shared `extensions` array). Without cloning, binding a later
822
+ * editor clobbers an earlier one: its list `Enter` then falls back to a plain
823
+ * block split, dropping an indented "child" paragraph instead of a new `<li>`.
824
+ */
825
+ private cloneExtensions;
817
826
  /**
818
827
  * Sorts extensions by priority (higher priority first)
819
828
  * Default priority is 100
@@ -3480,6 +3489,16 @@ declare class Extension<Options = unknown, Storage = unknown> {
3480
3489
  * // configure({ nested: { ...original.options.nested, b: 3 } })
3481
3490
  */
3482
3491
  configure(options: Partial<Options>): Extension<Options, Storage>;
3492
+ /**
3493
+ * Returns a fresh, unbound copy built from the same `config`: `editor` reset to
3494
+ * null and `options`/`storage` re-derived, while `configure()`/`extend()`
3495
+ * results are preserved (they live in `config`). Polymorphic: a `Node`/`Mark`
3496
+ * clones to its own subclass.
3497
+ *
3498
+ * `ExtensionManager` clones every extension so each editor owns its instances
3499
+ * and binding one editor can't mutate extensions shared with another.
3500
+ */
3501
+ clone(): Extension<Options, Storage>;
3483
3502
  /**
3484
3503
  * Creates a new extension with extended configuration
3485
3504
  * Original extension is not modified
@@ -6304,12 +6323,15 @@ interface StarterKitOptions {
6304
6323
  */
6305
6324
  listKeymap?: false | Partial<ListKeymapOptions>;
6306
6325
  /**
6307
- * Set to false to disable the ListIndent extension. ListIndent adds
6308
- * Tab / Shift-Tab keymap that indents a top-level block under the
6309
- * previous list (and outdents back). Registered AFTER ListKeymap so
6310
- * the in-list-item Tab/Shift-Tab keep priority.
6326
+ * Off by default. Set to `true` to enable the ListIndent extension, which
6327
+ * adds a Tab / Shift-Tab keymap that indents a top-level block under the
6328
+ * previous list (and outdents back). Kept off by default because it captures
6329
+ * Tab on a paragraph that merely follows a list, so Tab no longer moves focus
6330
+ * to the next field in embedded / form usage, and the same nesting is
6331
+ * reachable via the block-menu drag. Registered AFTER ListKeymap so the
6332
+ * in-list-item Tab/Shift-Tab keep priority.
6311
6333
  */
6312
- listIndent?: false;
6334
+ listIndent?: boolean;
6313
6335
  /**
6314
6336
  * Set to false to disable the LinkPopover extension, or pass options to configure it.
6315
6337
  */
package/dist/index.js CHANGED
@@ -298,7 +298,8 @@ var ExtensionManager = class {
298
298
  }
299
299
  const flattened = this.flattenExtensions(options.extensions);
300
300
  const deduped = this.deduplicateExtensions(flattened);
301
- this._extensions = this.resolveExtensions(deduped);
301
+ const cloned = this.cloneExtensions(deduped);
302
+ this._extensions = this.resolveExtensions(cloned);
302
303
  this.detectConflicts();
303
304
  this.checkDependencies();
304
305
  this.bindEditorToExtensions();
@@ -406,6 +407,17 @@ var ExtensionManager = class {
406
407
  }
407
408
  return extensions.filter((ext, i) => seen.get(ext.name) === i);
408
409
  }
410
+ /**
411
+ * Clone every extension so this editor owns its instances. Extensions hold
412
+ * per-editor mutable state (`editor`, plus the `nodeType`/`markType` getters
413
+ * derived from it), and the same extension object is commonly reused across
414
+ * editors (one shared `extensions` array). Without cloning, binding a later
415
+ * editor clobbers an earlier one: its list `Enter` then falls back to a plain
416
+ * block split, dropping an indented "child" paragraph instead of a new `<li>`.
417
+ */
418
+ cloneExtensions(extensions) {
419
+ return extensions.map((ext) => ext.clone());
420
+ }
409
421
  /**
410
422
  * Sorts extensions by priority (higher priority first)
411
423
  * Default priority is 100
@@ -1538,6 +1550,19 @@ var Extension = class _Extension {
1538
1550
  };
1539
1551
  return new _Extension(newConfig);
1540
1552
  }
1553
+ /**
1554
+ * Returns a fresh, unbound copy built from the same `config`: `editor` reset to
1555
+ * null and `options`/`storage` re-derived, while `configure()`/`extend()`
1556
+ * results are preserved (they live in `config`). Polymorphic: a `Node`/`Mark`
1557
+ * clones to its own subclass.
1558
+ *
1559
+ * `ExtensionManager` clones every extension so each editor owns its instances
1560
+ * and binding one editor can't mutate extensions shared with another.
1561
+ */
1562
+ clone() {
1563
+ const Ctor = this.constructor;
1564
+ return new Ctor(this.config);
1565
+ }
1541
1566
  /**
1542
1567
  * Creates a new extension with extended configuration
1543
1568
  * Original extension is not modified
@@ -8702,8 +8727,13 @@ var SelectionDecoration = Extension.create(
8702
8727
  handleDOMEvents: {
8703
8728
  blur(view, event) {
8704
8729
  const related = event.relatedTarget;
8705
- if (related instanceof HTMLElement && (related.closest("[data-dm-editor-ui]") || related.closest(".dm-toolbar") || related.closest(".dm-bubble-menu"))) {
8706
- return false;
8730
+ if (related instanceof HTMLElement) {
8731
+ const ownContainer = view.dom.closest(".dm-editor");
8732
+ const relatedContainer = related.closest(".dm-editor");
8733
+ const movedToAnotherEditor = ownContainer !== null && relatedContainer !== null && relatedContainer !== ownContainer;
8734
+ if (!movedToAnotherEditor && (related.closest("[data-dm-editor-ui]") || related.closest(".dm-toolbar") || related.closest(".dm-bubble-menu"))) {
8735
+ return false;
8736
+ }
8707
8737
  }
8708
8738
  const { from, to } = view.state.selection;
8709
8739
  if (from !== to) {
@@ -10056,7 +10086,7 @@ var StarterKit = Extension.create({
10056
10086
  maybeAdd(Gapcursor, this.options.gapcursor);
10057
10087
  maybeAdd(TrailingNode, this.options.trailingNode);
10058
10088
  maybeAdd(ListKeymap, this.options.listKeymap);
10059
- maybeAdd(ListIndent, this.options.listIndent);
10089
+ if (this.options.listIndent === true) extensions.push(ListIndent);
10060
10090
  maybeAdd(LinkPopover, this.options.linkPopover);
10061
10091
  maybeAdd(SelectionDecoration, this.options.selectionDecoration);
10062
10092
  return extensions;