@tiptap/core 3.15.2 → 3.15.3

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": "3.15.2",
4
+ "version": "3.15.3",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -52,10 +52,10 @@
52
52
  "jsx-dev-runtime"
53
53
  ],
54
54
  "devDependencies": {
55
- "@tiptap/pm": "^3.15.2"
55
+ "@tiptap/pm": "^3.15.3"
56
56
  },
57
57
  "peerDependencies": {
58
- "@tiptap/pm": "^3.15.2"
58
+ "@tiptap/pm": "^3.15.3"
59
59
  },
60
60
  "repository": {
61
61
  "type": "git",
@@ -3,6 +3,7 @@ import { resolveFocusPosition } from '../helpers/resolveFocusPosition.js'
3
3
  import type { FocusPosition, RawCommands } from '../types.js'
4
4
  import { isAndroid } from '../utilities/isAndroid.js'
5
5
  import { isiOS } from '../utilities/isiOS.js'
6
+ import { isSafari } from '../utilities/isSafari.js'
6
7
 
7
8
  declare module '@tiptap/core' {
8
9
  interface Commands<ReturnType> {
@@ -47,6 +48,14 @@ export const focus: RawCommands['focus'] =
47
48
  ;(view.dom as HTMLElement).focus()
48
49
  }
49
50
 
51
+ // Safari requires preventScroll to avoid the browser scrolling to the
52
+ // top of the editor when focus is called before the selection is set.
53
+ // We exclude iOS and Android since they are already handled above.
54
+ // see: https://github.com/ueberdosis/tiptap/issues/7318
55
+ if (isSafari() && !isiOS() && !isAndroid()) {
56
+ ;(view.dom as HTMLElement).focus({ preventScroll: true })
57
+ }
58
+
50
59
  // For React we have to focus asynchronously. Otherwise wild things happen.
51
60
  // see: https://github.com/ueberdosis/tiptap/issues/1520
52
61
  requestAnimationFrame(() => {
@@ -14,6 +14,7 @@ export * from './isMacOS.js'
14
14
  export * from './isNumber.js'
15
15
  export * from './isPlainObject.js'
16
16
  export * from './isRegExp.js'
17
+ export * from './isSafari.js'
17
18
  export * from './isString.js'
18
19
  export * from './markdown/index.js'
19
20
  export * as markdown from './markdown/index.js'
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Detects if the current browser is Safari (but not iOS Safari or Chrome).
3
+ * @returns `true` if the browser is Safari, `false` otherwise.
4
+ * @example
5
+ * if (isSafari()) {
6
+ * // Safari-specific handling
7
+ * }
8
+ */
9
+ export function isSafari(): boolean {
10
+ return typeof navigator !== 'undefined' ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false
11
+ }