@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.js CHANGED
@@ -1871,6 +1871,18 @@ function isiOS() {
1871
1871
  || (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
1872
1872
  }
1873
1873
 
1874
+ /**
1875
+ * Detects if the current browser is Safari (but not iOS Safari or Chrome).
1876
+ * @returns `true` if the browser is Safari, `false` otherwise.
1877
+ * @example
1878
+ * if (isSafari()) {
1879
+ * // Safari-specific handling
1880
+ * }
1881
+ */
1882
+ function isSafari() {
1883
+ return typeof navigator !== 'undefined' ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
1884
+ }
1885
+
1874
1886
  const focus = (position = null, options = {}) => ({ editor, view, tr, dispatch, }) => {
1875
1887
  options = {
1876
1888
  scrollIntoView: true,
@@ -1887,8 +1899,12 @@ const focus = (position = null, options = {}) => ({ editor, view, tr, dispatch,
1887
1899
  requestAnimationFrame(() => {
1888
1900
  if (!editor.isDestroyed) {
1889
1901
  view.focus();
1890
- if (options === null || options === void 0 ? void 0 : options.scrollIntoView) {
1891
- editor.commands.scrollIntoView();
1902
+ // Safari requires preventScroll to avoid the browser scrolling to the
1903
+ // top of the editor when focus is called before the selection is set.
1904
+ // We exclude iOS and Android since they are already handled above.
1905
+ // see: https://github.com/ueberdosis/tiptap/issues/7318
1906
+ if (isSafari() && !isiOS() && !isAndroid()) {
1907
+ view.dom.focus({ preventScroll: true });
1892
1908
  }
1893
1909
  }
1894
1910
  });
@@ -5476,5 +5492,5 @@ class Tracker {
5476
5492
  }
5477
5493
  }
5478
5494
 
5479
- export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodePos, NodeView, PasteRule, Tracker, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
5495
+ export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodePos, NodeView, PasteRule, Tracker, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isSafari, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
5480
5496
  //# sourceMappingURL=index.js.map