@tiptap/core 2.27.0 → 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.
package/dist/index.umd.js CHANGED
@@ -1869,6 +1869,18 @@
1869
1869
  || (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
1870
1870
  }
1871
1871
 
1872
+ /**
1873
+ * Detects if the current browser is Safari (but not iOS Safari or Chrome).
1874
+ * @returns `true` if the browser is Safari, `false` otherwise.
1875
+ * @example
1876
+ * if (isSafari()) {
1877
+ * // Safari-specific handling
1878
+ * }
1879
+ */
1880
+ function isSafari() {
1881
+ return typeof navigator !== 'undefined' ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
1882
+ }
1883
+
1872
1884
  const focus = (position = null, options = {}) => ({ editor, view, tr, dispatch, }) => {
1873
1885
  options = {
1874
1886
  scrollIntoView: true,
@@ -1885,8 +1897,12 @@
1885
1897
  requestAnimationFrame(() => {
1886
1898
  if (!editor.isDestroyed) {
1887
1899
  view.focus();
1888
- if (options === null || options === void 0 ? void 0 : options.scrollIntoView) {
1889
- editor.commands.scrollIntoView();
1900
+ // Safari requires preventScroll to avoid the browser scrolling to the
1901
+ // top of the editor when focus is called before the selection is set.
1902
+ // We exclude iOS and Android since they are already handled above.
1903
+ // see: https://github.com/ueberdosis/tiptap/issues/7318
1904
+ if (isSafari() && !isiOS() && !isAndroid()) {
1905
+ view.dom.focus({ preventScroll: true });
1890
1906
  }
1891
1907
  }
1892
1908
  });
@@ -5545,6 +5561,7 @@ img.ProseMirror-separator {
5545
5561
  exports.isNumber = isNumber;
5546
5562
  exports.isPlainObject = isPlainObject;
5547
5563
  exports.isRegExp = isRegExp;
5564
+ exports.isSafari = isSafari;
5548
5565
  exports.isString = isString;
5549
5566
  exports.isTextSelection = isTextSelection;
5550
5567
  exports.isiOS = isiOS;