@tiptap/core 2.27.1 → 2.27.2

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.
@@ -13,6 +13,7 @@ export * from './isMacOS.js';
13
13
  export * from './isNumber.js';
14
14
  export * from './isPlainObject.js';
15
15
  export * from './isRegExp.js';
16
+ export * from './isSafari.js';
16
17
  export * from './isString.js';
17
18
  export * from './mergeAttributes.js';
18
19
  export * from './mergeDeep.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,10 @@
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 declare function isSafari(): boolean;
10
+ //# sourceMappingURL=isSafari.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSafari.d.ts","sourceRoot":"","sources":["../../src/utilities/isSafari.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAElC"}
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.27.1",
4
+ "version": "2.27.2",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -32,7 +32,7 @@
32
32
  "dist"
33
33
  ],
34
34
  "devDependencies": {
35
- "@tiptap/pm": "^2.27.1"
35
+ "@tiptap/pm": "^2.27.2"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@tiptap/pm": "^2.7.0"
@@ -3,6 +3,7 @@ import { resolveFocusPosition } from '../helpers/resolveFocusPosition.js'
3
3
  import { 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> {
@@ -56,8 +57,12 @@ export const focus: RawCommands['focus'] = (position = null, options = {}) => ({
56
57
  if (!editor.isDestroyed) {
57
58
  view.focus()
58
59
 
59
- if (options?.scrollIntoView) {
60
- editor.commands.scrollIntoView()
60
+ // Safari requires preventScroll to avoid the browser scrolling to the
61
+ // top of the editor when focus is called before the selection is set.
62
+ // We exclude iOS and Android since they are already handled above.
63
+ // see: https://github.com/ueberdosis/tiptap/issues/7318
64
+ if (isSafari() && !isiOS() && !isAndroid()) {
65
+ (view.dom as HTMLElement).focus({ preventScroll: true })
61
66
  }
62
67
  }
63
68
  })
@@ -13,6 +13,7 @@ export * from './isMacOS.js'
13
13
  export * from './isNumber.js'
14
14
  export * from './isPlainObject.js'
15
15
  export * from './isRegExp.js'
16
+ export * from './isSafari.js'
16
17
  export * from './isString.js'
17
18
  export * from './mergeAttributes.js'
18
19
  export * from './mergeDeep.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
+ }