@tiptap/core 3.0.0-beta.15 → 3.0.0-beta.17

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
@@ -183,13 +183,17 @@ interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
183
183
  */
184
184
  declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
185
185
  type: string;
186
- static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>>): Mark<O, S>;
186
+ /**
187
+ * Create a new Mark instance
188
+ * @param config - Mark configuration object or a function that returns a configuration object
189
+ */
190
+ static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>> | (() => Partial<MarkConfig<O, S>>)): Mark<O, S>;
187
191
  static handleExit({ editor, mark }: {
188
192
  editor: Editor;
189
193
  mark: Mark;
190
194
  }): boolean;
191
195
  configure(options?: Partial<Options>): Mark<Options, Storage>;
192
- extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Mark<ExtendedOptions, ExtendedStorage>;
196
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Mark<ExtendedOptions, ExtendedStorage>;
193
197
  }
194
198
 
195
199
  interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
@@ -470,9 +474,13 @@ interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
470
474
  */
471
475
  declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
472
476
  type: string;
473
- static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>>): Node<O, S>;
477
+ /**
478
+ * Create a new Node instance
479
+ * @param config - Node configuration object or a function that returns a configuration object
480
+ */
481
+ static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>> | (() => Partial<NodeConfig<O, S>>)): Node<O, S>;
474
482
  configure(options?: Partial<Options>): Node<Options, Storage>;
475
- extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Node<ExtendedOptions, ExtendedStorage>;
483
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Node<ExtendedOptions, ExtendedStorage>;
476
484
  }
477
485
 
478
486
  type PasteRuleMatch = {
@@ -1631,9 +1639,13 @@ interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig
1631
1639
  */
1632
1640
  declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
1633
1641
  type: string;
1634
- static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
1642
+ /**
1643
+ * Create a new Extension instance
1644
+ * @param config - Extension configuration object or a function that returns a configuration object
1645
+ */
1646
+ static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>)): Extension<O, S>;
1635
1647
  configure(options?: Partial<Options>): Extension<Options, Storage>;
1636
- extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extension<ExtendedOptions, ExtendedStorage>;
1648
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Extension<ExtendedOptions, ExtendedStorage>;
1637
1649
  }
1638
1650
 
1639
1651
  /**
package/dist/index.d.ts CHANGED
@@ -183,13 +183,17 @@ interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
183
183
  */
184
184
  declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
185
185
  type: string;
186
- static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>>): Mark<O, S>;
186
+ /**
187
+ * Create a new Mark instance
188
+ * @param config - Mark configuration object or a function that returns a configuration object
189
+ */
190
+ static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>> | (() => Partial<MarkConfig<O, S>>)): Mark<O, S>;
187
191
  static handleExit({ editor, mark }: {
188
192
  editor: Editor;
189
193
  mark: Mark;
190
194
  }): boolean;
191
195
  configure(options?: Partial<Options>): Mark<Options, Storage>;
192
- extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Mark<ExtendedOptions, ExtendedStorage>;
196
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Mark<ExtendedOptions, ExtendedStorage>;
193
197
  }
194
198
 
195
199
  interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
@@ -470,9 +474,13 @@ interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
470
474
  */
471
475
  declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
472
476
  type: string;
473
- static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>>): Node<O, S>;
477
+ /**
478
+ * Create a new Node instance
479
+ * @param config - Node configuration object or a function that returns a configuration object
480
+ */
481
+ static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>> | (() => Partial<NodeConfig<O, S>>)): Node<O, S>;
474
482
  configure(options?: Partial<Options>): Node<Options, Storage>;
475
- extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Node<ExtendedOptions, ExtendedStorage>;
483
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Node<ExtendedOptions, ExtendedStorage>;
476
484
  }
477
485
 
478
486
  type PasteRuleMatch = {
@@ -1631,9 +1639,13 @@ interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig
1631
1639
  */
1632
1640
  declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
1633
1641
  type: string;
1634
- static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
1642
+ /**
1643
+ * Create a new Extension instance
1644
+ * @param config - Extension configuration object or a function that returns a configuration object
1645
+ */
1646
+ static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>)): Extension<O, S>;
1635
1647
  configure(options?: Partial<Options>): Extension<Options, Storage>;
1636
- extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extension<ExtendedOptions, ExtendedStorage>;
1648
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Extension<ExtendedOptions, ExtendedStorage>;
1637
1649
  }
1638
1650
 
1639
1651
  /**
package/dist/index.js CHANGED
@@ -1831,8 +1831,13 @@ var Mark = class _Mark extends Extendable {
1831
1831
  super(...arguments);
1832
1832
  this.type = "mark";
1833
1833
  }
1834
+ /**
1835
+ * Create a new Mark instance
1836
+ * @param config - Mark configuration object or a function that returns a configuration object
1837
+ */
1834
1838
  static create(config = {}) {
1835
- return new _Mark(config);
1839
+ const resolvedConfig = typeof config === "function" ? config() : config;
1840
+ return new _Mark(resolvedConfig);
1836
1841
  }
1837
1842
  static handleExit({ editor, mark }) {
1838
1843
  const { tr } = editor.state;
@@ -1858,7 +1863,8 @@ var Mark = class _Mark extends Extendable {
1858
1863
  return super.configure(options);
1859
1864
  }
1860
1865
  extend(extendedConfig) {
1861
- return super.extend(extendedConfig);
1866
+ const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
1867
+ return super.extend(resolvedConfig);
1862
1868
  }
1863
1869
  };
1864
1870
 
@@ -2026,7 +2032,7 @@ function pasteRulesPlugin(props) {
2026
2032
  dropEvent = event;
2027
2033
  if (!isDroppedFromProseMirror) {
2028
2034
  const dragFromOtherEditor = tiptapDragFromOtherEditor;
2029
- if (dragFromOtherEditor) {
2035
+ if (dragFromOtherEditor == null ? void 0 : dragFromOtherEditor.isEditable) {
2030
2036
  setTimeout(() => {
2031
2037
  const selection = dragFromOtherEditor.state.selection;
2032
2038
  if (selection) {
@@ -2363,14 +2369,20 @@ var Extension = class _Extension extends Extendable {
2363
2369
  super(...arguments);
2364
2370
  this.type = "extension";
2365
2371
  }
2372
+ /**
2373
+ * Create a new Extension instance
2374
+ * @param config - Extension configuration object or a function that returns a configuration object
2375
+ */
2366
2376
  static create(config = {}) {
2367
- return new _Extension(config);
2377
+ const resolvedConfig = typeof config === "function" ? config() : config;
2378
+ return new _Extension(resolvedConfig);
2368
2379
  }
2369
2380
  configure(options) {
2370
2381
  return super.configure(options);
2371
2382
  }
2372
2383
  extend(extendedConfig) {
2373
- return super.extend(extendedConfig);
2384
+ const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
2385
+ return super.extend(resolvedConfig);
2374
2386
  }
2375
2387
  };
2376
2388
 
@@ -2790,7 +2802,8 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
2790
2802
  newContent = content;
2791
2803
  const fromSelectionAtStart = selection.$from.parentOffset === 0;
2792
2804
  const isTextSelection2 = selection.$from.node().isText || selection.$from.node().isTextblock;
2793
- if (fromSelectionAtStart && isTextSelection2) {
2805
+ const hasContent = selection.$from.node().content.size > 0;
2806
+ if (fromSelectionAtStart && isTextSelection2 && hasContent) {
2794
2807
  from = Math.max(0, from - 1);
2795
2808
  }
2796
2809
  tr.replaceWith(from, to, newContent);
@@ -5026,14 +5039,20 @@ var Node3 = class _Node extends Extendable {
5026
5039
  super(...arguments);
5027
5040
  this.type = "node";
5028
5041
  }
5042
+ /**
5043
+ * Create a new Node instance
5044
+ * @param config - Node configuration object or a function that returns a configuration object
5045
+ */
5029
5046
  static create(config = {}) {
5030
- return new _Node(config);
5047
+ const resolvedConfig = typeof config === "function" ? config() : config;
5048
+ return new _Node(resolvedConfig);
5031
5049
  }
5032
5050
  configure(options) {
5033
5051
  return super.configure(options);
5034
5052
  }
5035
5053
  extend(extendedConfig) {
5036
- return super.extend(extendedConfig);
5054
+ const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
5055
+ return super.extend(resolvedConfig);
5037
5056
  }
5038
5057
  };
5039
5058