@tiptap/core 2.0.0-beta.141 → 2.0.0-beta.145

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.
@@ -9,8 +9,9 @@
9
9
  return Object.prototype.toString.call(value).slice(8, -1);
10
10
  }
11
11
  function isPlainObject(value) {
12
- if (getType(value) !== 'Object')
12
+ if (getType(value) !== 'Object') {
13
13
  return false;
14
+ }
14
15
  return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;
15
16
  }
16
17
 
@@ -125,15 +126,9 @@
125
126
  if (extendedConfig.defaultOptions) {
126
127
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
127
128
  }
128
- // TODO: remove `addOptions` fallback
129
- extension.options = extendedConfig.defaultOptions
130
- ? extendedConfig.defaultOptions
131
- : extension.parent.options;
132
- if (extendedConfig.addOptions) {
133
- extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
134
- name: extension.name,
135
- }));
136
- }
129
+ extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
130
+ name: extension.name,
131
+ }));
137
132
  extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
138
133
  name: extension.name,
139
134
  options: extension.options,
@@ -525,7 +520,11 @@
525
520
  to: position,
526
521
  };
527
522
  }
528
- const focus = (position = null) => ({ editor, view, tr, dispatch, }) => {
523
+ const focus = (position = null, options) => ({ editor, view, tr, dispatch, }) => {
524
+ options = {
525
+ scrollIntoView: true,
526
+ ...options,
527
+ };
529
528
  const delayedFocus = () => {
530
529
  // focus within `requestAnimationFrame` breaks focus on iOS
531
530
  // so we have to call this
@@ -537,7 +536,9 @@
537
536
  requestAnimationFrame(() => {
538
537
  if (!editor.isDestroyed) {
539
538
  view.focus();
540
- editor.commands.scrollIntoView();
539
+ if (options === null || options === void 0 ? void 0 : options.scrollIntoView) {
540
+ editor.commands.scrollIntoView();
541
+ }
541
542
  }
542
543
  });
543
544
  };
@@ -1177,7 +1178,7 @@
1177
1178
  }));
1178
1179
  }
1179
1180
 
1180
- function defaultBlockAt(match) {
1181
+ function defaultBlockAt$1(match) {
1181
1182
  for (let i = 0; i < match.edgeCount; i += 1) {
1182
1183
  const { type } = match.edge(i);
1183
1184
  if (type.isTextblock && !type.hasRequiredAttrs()) {
@@ -1221,7 +1222,7 @@
1221
1222
  }
1222
1223
  const deflt = $from.depth === 0
1223
1224
  ? undefined
1224
- : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
1225
+ : defaultBlockAt$1($from.node(-1).contentMatchAt($from.indexAfter(-1)));
1225
1226
  let types = atEnd && deflt
1226
1227
  ? [{
1227
1228
  type: deflt,
@@ -3415,15 +3416,9 @@ img.ProseMirror-separator {
3415
3416
  if (extendedConfig.defaultOptions) {
3416
3417
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
3417
3418
  }
3418
- // TODO: remove `addOptions` fallback
3419
- extension.options = extendedConfig.defaultOptions
3420
- ? extendedConfig.defaultOptions
3421
- : extension.parent.options;
3422
- if (extendedConfig.addOptions) {
3423
- extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
3424
- name: extension.name,
3425
- }));
3426
- }
3419
+ extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
3420
+ name: extension.name,
3421
+ }));
3427
3422
  extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
3428
3423
  name: extension.name,
3429
3424
  options: extension.options,
@@ -3486,15 +3481,9 @@ img.ProseMirror-separator {
3486
3481
  if (extendedConfig.defaultOptions) {
3487
3482
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
3488
3483
  }
3489
- // TODO: remove `addOptions` fallback
3490
- extension.options = extendedConfig.defaultOptions
3491
- ? extendedConfig.defaultOptions
3492
- : extension.parent.options;
3493
- if (extendedConfig.addOptions) {
3494
- extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
3495
- name: extension.name,
3496
- }));
3497
- }
3484
+ extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
3485
+ name: extension.name,
3486
+ }));
3498
3487
  extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
3499
3488
  name: extension.name,
3500
3489
  options: extension.options,
@@ -3958,6 +3947,16 @@ img.ProseMirror-separator {
3958
3947
  });
3959
3948
  }
3960
3949
 
3950
+ function defaultBlockAt(match) {
3951
+ for (let i = 0; i < match.edgeCount; i += 1) {
3952
+ const { type } = match.edge(i);
3953
+ if (type.isTextblock && !type.hasRequiredAttrs()) {
3954
+ return type;
3955
+ }
3956
+ }
3957
+ return null;
3958
+ }
3959
+
3961
3960
  function findChildren(node, predicate) {
3962
3961
  const nodesWithPos = [];
3963
3962
  node.descendants((child, pos) => {
@@ -4106,6 +4105,7 @@ img.ProseMirror-separator {
4106
4105
  exports.PasteRule = PasteRule;
4107
4106
  exports.Tracker = Tracker;
4108
4107
  exports.callOrReturn = callOrReturn;
4108
+ exports.defaultBlockAt = defaultBlockAt;
4109
4109
  exports.extensions = extensions;
4110
4110
  exports.findChildren = findChildren;
4111
4111
  exports.findChildrenInRange = findChildrenInRange;