@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.
@@ -1 +1 @@
1
- {"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../src/commands/focus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAIxD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,KAAK,EAAE;YACL;;;;;;eAMG;YACH,KAAK,EAAE;YACL;;eAEG;YACH,QAAQ,CAAC,EAAE,aAAa;YAExB;;;eAGG;YACH,OAAO,CAAC,EAAE;gBACR,cAAc,CAAC,EAAE,OAAO,CAAC;aAC1B,KACE,UAAU,CAAC;SACjB,CAAA;KACF;CACF;AAED,eAAO,MAAM,KAAK,EAAE,WAAW,CAAC,OAAO,CA6DtC,CAAA"}
1
+ {"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../src/commands/focus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAKxD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,KAAK,EAAE;YACL;;;;;;eAMG;YACH,KAAK,EAAE;YACL;;eAEG;YACH,QAAQ,CAAC,EAAE,aAAa;YAExB;;;eAGG;YACH,OAAO,CAAC,EAAE;gBACR,cAAc,CAAC,EAAE,OAAO,CAAC;aAC1B,KACE,UAAU,CAAC;SACjB,CAAA;KACF;CACF;AAED,eAAO,MAAM,KAAK,EAAE,WAAW,CAAC,OAAO,CAiEtC,CAAA"}
package/dist/index.cjs CHANGED
@@ -1873,6 +1873,18 @@ function isiOS() {
1873
1873
  || (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
1874
1874
  }
1875
1875
 
1876
+ /**
1877
+ * Detects if the current browser is Safari (but not iOS Safari or Chrome).
1878
+ * @returns `true` if the browser is Safari, `false` otherwise.
1879
+ * @example
1880
+ * if (isSafari()) {
1881
+ * // Safari-specific handling
1882
+ * }
1883
+ */
1884
+ function isSafari() {
1885
+ return typeof navigator !== 'undefined' ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
1886
+ }
1887
+
1876
1888
  const focus = (position = null, options = {}) => ({ editor, view, tr, dispatch, }) => {
1877
1889
  options = {
1878
1890
  scrollIntoView: true,
@@ -1889,8 +1901,12 @@ const focus = (position = null, options = {}) => ({ editor, view, tr, dispatch,
1889
1901
  requestAnimationFrame(() => {
1890
1902
  if (!editor.isDestroyed) {
1891
1903
  view.focus();
1892
- if (options === null || options === void 0 ? void 0 : options.scrollIntoView) {
1893
- editor.commands.scrollIntoView();
1904
+ // Safari requires preventScroll to avoid the browser scrolling to the
1905
+ // top of the editor when focus is called before the selection is set.
1906
+ // We exclude iOS and Android since they are already handled above.
1907
+ // see: https://github.com/ueberdosis/tiptap/issues/7318
1908
+ if (isSafari() && !isiOS() && !isAndroid()) {
1909
+ view.dom.focus({ preventScroll: true });
1894
1910
  }
1895
1911
  }
1896
1912
  });
@@ -5549,6 +5565,7 @@ exports.isNodeSelection = isNodeSelection;
5549
5565
  exports.isNumber = isNumber;
5550
5566
  exports.isPlainObject = isPlainObject;
5551
5567
  exports.isRegExp = isRegExp;
5568
+ exports.isSafari = isSafari;
5552
5569
  exports.isString = isString;
5553
5570
  exports.isTextSelection = isTextSelection;
5554
5571
  exports.isiOS = isiOS;