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

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.142",
4
+ "version": "2.0.0-beta.143",
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": "7c5223fc926e27a231190e0c8ad1b8351768375c"
47
+ "gitHead": "7a04a32f1a11de0bc2e39d9c6d15626e158a4e39"
48
48
  }
@@ -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
  }