@tiptap/core 2.0.0-beta.142 → 2.0.0-beta.146

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.
@@ -5,7 +5,9 @@ declare module '@tiptap/core' {
5
5
  /**
6
6
  * Focus the editor at the given position.
7
7
  */
8
- focus: (position?: FocusPosition) => ReturnType;
8
+ focus: (position?: FocusPosition, options?: {
9
+ scrollIntoView?: boolean;
10
+ }) => ReturnType;
9
11
  };
10
12
  }
11
13
  }
@@ -15,8 +15,9 @@ function getType(value) {
15
15
  return Object.prototype.toString.call(value).slice(8, -1);
16
16
  }
17
17
  function isPlainObject(value) {
18
- if (getType(value) !== 'Object')
18
+ if (getType(value) !== 'Object') {
19
19
  return false;
20
+ }
20
21
  return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;
21
22
  }
22
23
 
@@ -131,15 +132,9 @@ class Extension {
131
132
  if (extendedConfig.defaultOptions) {
132
133
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
133
134
  }
134
- // TODO: remove `addOptions` fallback
135
- extension.options = extendedConfig.defaultOptions
136
- ? extendedConfig.defaultOptions
137
- : extension.parent.options;
138
- if (extendedConfig.addOptions) {
139
- extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
140
- name: extension.name,
141
- }));
142
- }
135
+ extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
136
+ name: extension.name,
137
+ }));
143
138
  extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
144
139
  name: extension.name,
145
140
  options: extension.options,
@@ -531,7 +526,11 @@ function resolveSelection(state, position = null) {
531
526
  to: position,
532
527
  };
533
528
  }
534
- const focus = (position = null) => ({ editor, view, tr, dispatch, }) => {
529
+ const focus = (position = null, options) => ({ editor, view, tr, dispatch, }) => {
530
+ options = {
531
+ scrollIntoView: true,
532
+ ...options,
533
+ };
535
534
  const delayedFocus = () => {
536
535
  // focus within `requestAnimationFrame` breaks focus on iOS
537
536
  // so we have to call this
@@ -543,7 +542,9 @@ const focus = (position = null) => ({ editor, view, tr, dispatch, }) => {
543
542
  requestAnimationFrame(() => {
544
543
  if (!editor.isDestroyed) {
545
544
  view.focus();
546
- editor.commands.scrollIntoView();
545
+ if (options === null || options === void 0 ? void 0 : options.scrollIntoView) {
546
+ editor.commands.scrollIntoView();
547
+ }
547
548
  }
548
549
  });
549
550
  };
@@ -3421,15 +3422,9 @@ class Node {
3421
3422
  if (extendedConfig.defaultOptions) {
3422
3423
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
3423
3424
  }
3424
- // TODO: remove `addOptions` fallback
3425
- extension.options = extendedConfig.defaultOptions
3426
- ? extendedConfig.defaultOptions
3427
- : extension.parent.options;
3428
- if (extendedConfig.addOptions) {
3429
- extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
3430
- name: extension.name,
3431
- }));
3432
- }
3425
+ extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
3426
+ name: extension.name,
3427
+ }));
3433
3428
  extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
3434
3429
  name: extension.name,
3435
3430
  options: extension.options,
@@ -3492,15 +3487,9 @@ class Mark {
3492
3487
  if (extendedConfig.defaultOptions) {
3493
3488
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
3494
3489
  }
3495
- // TODO: remove `addOptions` fallback
3496
- extension.options = extendedConfig.defaultOptions
3497
- ? extendedConfig.defaultOptions
3498
- : extension.parent.options;
3499
- if (extendedConfig.addOptions) {
3500
- extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
3501
- name: extension.name,
3502
- }));
3503
- }
3490
+ extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
3491
+ name: extension.name,
3492
+ }));
3504
3493
  extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
3505
3494
  name: extension.name,
3506
3495
  options: extension.options,