@tiptap/core 2.11.2 → 2.11.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/dist/index.js CHANGED
@@ -1854,13 +1854,34 @@ function resolveFocusPosition(doc, position = null) {
1854
1854
  return TextSelection.create(doc, minMax(position, minPos, maxPos), minMax(position, minPos, maxPos));
1855
1855
  }
1856
1856
 
1857
+ function isAndroid() {
1858
+ return navigator.platform === 'Android' || /android/i.test(navigator.userAgent);
1859
+ }
1860
+
1861
+ function isiOS() {
1862
+ return [
1863
+ 'iPad Simulator',
1864
+ 'iPhone Simulator',
1865
+ 'iPod Simulator',
1866
+ 'iPad',
1867
+ 'iPhone',
1868
+ 'iPod',
1869
+ ].includes(navigator.platform)
1870
+ // iPad on iOS 13 detection
1871
+ || (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
1872
+ }
1873
+
1857
1874
  const focus = (position = null, options = {}) => ({ editor, view, tr, dispatch, }) => {
1858
1875
  options = {
1859
1876
  scrollIntoView: true,
1860
1877
  ...options,
1861
1878
  };
1862
1879
  const delayedFocus = () => {
1863
- view.dom.focus();
1880
+ // focus within `requestAnimationFrame` breaks focus on iOS and Android
1881
+ // so we have to call this
1882
+ if (isiOS() || isAndroid()) {
1883
+ view.dom.focus();
1884
+ }
1864
1885
  // For React we have to focus asynchronously. Otherwise wild things happen.
1865
1886
  // see: https://github.com/ueberdosis/tiptap/issues/1520
1866
1887
  requestAnimationFrame(() => {
@@ -2191,19 +2212,6 @@ const joinTextblockForward = () => ({ state, dispatch }) => {
2191
2212
  return joinTextblockForward$1(state, dispatch);
2192
2213
  };
2193
2214
 
2194
- function isiOS() {
2195
- return [
2196
- 'iPad Simulator',
2197
- 'iPhone Simulator',
2198
- 'iPod Simulator',
2199
- 'iPad',
2200
- 'iPhone',
2201
- 'iPod',
2202
- ].includes(navigator.platform)
2203
- // iPad on iOS 13 detection
2204
- || (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
2205
- }
2206
-
2207
2215
  function isMacOS() {
2208
2216
  return typeof navigator !== 'undefined'
2209
2217
  ? /Mac/.test(navigator.platform)
@@ -4003,6 +4011,9 @@ const Keymap = Extension.create({
4003
4011
  new Plugin({
4004
4012
  key: new PluginKey('clearDocument'),
4005
4013
  appendTransaction: (transactions, oldState, newState) => {
4014
+ if (transactions.some(tr => tr.getMeta('composition'))) {
4015
+ return;
4016
+ }
4006
4017
  const docChanges = transactions.some(transaction => transaction.docChanged)
4007
4018
  && !oldState.doc.eq(newState.doc);
4008
4019
  const ignoreTr = transactions.some(transaction => transaction.getMeta('preventClearDocument'));
@@ -5072,10 +5083,6 @@ class Node {
5072
5083
  }
5073
5084
  }
5074
5085
 
5075
- function isAndroid() {
5076
- return navigator.platform === 'Android' || /android/i.test(navigator.userAgent);
5077
- }
5078
-
5079
5086
  /**
5080
5087
  * Node views are used to customize the rendered DOM structure of a node.
5081
5088
  * @see https://tiptap.dev/guide/node-views