@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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/core",
3
3
  "description": "headless rich text editor",
4
- "version": "2.0.0-beta.141",
4
+ "version": "2.0.0-beta.145",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -44,5 +44,5 @@
44
44
  "url": "https://github.com/ueberdosis/tiptap",
45
45
  "directory": "packages/core"
46
46
  },
47
- "gitHead": "53f6ad47bcb6c6f718faef6245061fe023c94d61"
47
+ "gitHead": "90b092967220b507726fc7a8624198ddd710c598"
48
48
  }
package/src/Extension.ts CHANGED
@@ -352,20 +352,13 @@ export class Extension<Options = any, Storage = any> {
352
352
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`)
353
353
  }
354
354
 
355
- // TODO: remove `addOptions` fallback
356
- extension.options = extendedConfig.defaultOptions
357
- ? extendedConfig.defaultOptions
358
- : extension.parent.options
359
-
360
- if (extendedConfig.addOptions) {
361
- extension.options = callOrReturn(getExtensionField<AnyConfig['addOptions']>(
362
- extension,
363
- 'addOptions',
364
- {
365
- name: extension.name,
366
- },
367
- ))
368
- }
355
+ extension.options = callOrReturn(getExtensionField<AnyConfig['addOptions']>(
356
+ extension,
357
+ 'addOptions',
358
+ {
359
+ name: extension.name,
360
+ },
361
+ ))
369
362
 
370
363
  extension.storage = callOrReturn(getExtensionField<AnyConfig['addStorage']>(
371
364
  extension,
package/src/Mark.ts CHANGED
@@ -466,20 +466,13 @@ export class Mark<Options = any, Storage = any> {
466
466
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`)
467
467
  }
468
468
 
469
- // TODO: remove `addOptions` fallback
470
- extension.options = extendedConfig.defaultOptions
471
- ? extendedConfig.defaultOptions
472
- : extension.parent.options
473
-
474
- if (extendedConfig.addOptions) {
475
- extension.options = callOrReturn(getExtensionField<AnyConfig['addOptions']>(
476
- extension,
477
- 'addOptions',
478
- {
479
- name: extension.name,
480
- },
481
- ))
482
- }
469
+ extension.options = callOrReturn(getExtensionField<AnyConfig['addOptions']>(
470
+ extension,
471
+ 'addOptions',
472
+ {
473
+ name: extension.name,
474
+ },
475
+ ))
483
476
 
484
477
  extension.storage = callOrReturn(getExtensionField<AnyConfig['addStorage']>(
485
478
  extension,
package/src/Node.ts CHANGED
@@ -546,20 +546,13 @@ export class Node<Options = any, Storage = any> {
546
546
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`)
547
547
  }
548
548
 
549
- // TODO: remove `addOptions` fallback
550
- extension.options = extendedConfig.defaultOptions
551
- ? extendedConfig.defaultOptions
552
- : extension.parent.options
553
-
554
- if (extendedConfig.addOptions) {
555
- extension.options = callOrReturn(getExtensionField<AnyConfig['addOptions']>(
556
- extension,
557
- 'addOptions',
558
- {
559
- name: extension.name,
560
- },
561
- ))
562
- }
549
+ extension.options = callOrReturn(getExtensionField<AnyConfig['addOptions']>(
550
+ extension,
551
+ 'addOptions',
552
+ {
553
+ name: extension.name,
554
+ },
555
+ ))
563
556
 
564
557
  extension.storage = callOrReturn(getExtensionField<AnyConfig['addStorage']>(
565
558
  extension,
@@ -44,17 +44,27 @@ declare module '@tiptap/core' {
44
44
  /**
45
45
  * Focus the editor at the given position.
46
46
  */
47
- focus: (position?: FocusPosition) => ReturnType,
47
+ focus: (
48
+ position?: FocusPosition,
49
+ options?: {
50
+ scrollIntoView?: boolean,
51
+ },
52
+ ) => ReturnType,
48
53
  }
49
54
  }
50
55
  }
51
56
 
52
- export const focus: RawCommands['focus'] = (position = null) => ({
57
+ export const focus: RawCommands['focus'] = (position = null, options) => ({
53
58
  editor,
54
59
  view,
55
60
  tr,
56
61
  dispatch,
57
62
  }) => {
63
+ options = {
64
+ scrollIntoView: true,
65
+ ...options,
66
+ }
67
+
58
68
  const delayedFocus = () => {
59
69
  // focus within `requestAnimationFrame` breaks focus on iOS
60
70
  // so we have to call this
@@ -67,7 +77,10 @@ export const focus: RawCommands['focus'] = (position = null) => ({
67
77
  requestAnimationFrame(() => {
68
78
  if (!editor.isDestroyed) {
69
79
  view.focus()
70
- editor.commands.scrollIntoView()
80
+
81
+ if (options?.scrollIntoView) {
82
+ editor.commands.scrollIntoView()
83
+ }
71
84
  }
72
85
  })
73
86
  }
@@ -0,0 +1,13 @@
1
+ import { ContentMatch, NodeType } from 'prosemirror-model'
2
+
3
+ export default function defaultBlockAt(match: ContentMatch): NodeType | null {
4
+ for (let i = 0; i < match.edgeCount; i += 1) {
5
+ const { type } = match.edge(i)
6
+
7
+ if (type.isTextblock && !type.hasRequiredAttrs()) {
8
+ return type
9
+ }
10
+ }
11
+
12
+ return null
13
+ }
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export { default as textPasteRule } from './pasteRules/textPasteRule'
23
23
  export { default as callOrReturn } from './utilities/callOrReturn'
24
24
  export { default as mergeAttributes } from './utilities/mergeAttributes'
25
25
 
26
+ export { default as defaultBlockAt } from './helpers/defaultBlockAt'
26
27
  export { default as getExtensionField } from './helpers/getExtensionField'
27
28
  export { default as findChildren } from './helpers/findChildren'
28
29
  export { default as findChildrenInRange } from './helpers/findChildrenInRange'
@@ -5,6 +5,9 @@ function getType(value: any): string {
5
5
  }
6
6
 
7
7
  export default function isPlainObject(value: any): value is Record<string, any> {
8
- if (getType(value) !== 'Object') return false
8
+ if (getType(value) !== 'Object') {
9
+ return false
10
+ }
11
+
9
12
  return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype
10
13
  }