@tiptap/core 2.1.0-rc.1 → 2.1.0-rc.11

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.
Files changed (244) hide show
  1. package/dist/index.cjs +96 -31
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +94 -32
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.js +96 -31
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/packages/core/src/CommandManager.d.ts +2 -2
  8. package/dist/packages/core/src/Editor.d.ts +8 -4
  9. package/dist/packages/core/src/Extension.d.ts +7 -7
  10. package/dist/packages/core/src/ExtensionManager.d.ts +2 -2
  11. package/dist/packages/core/src/InputRule.d.ts +2 -2
  12. package/dist/packages/core/src/Mark.d.ts +6 -6
  13. package/dist/packages/core/src/Node.d.ts +5 -5
  14. package/dist/packages/core/src/NodeView.d.ts +3 -3
  15. package/dist/packages/core/src/PasteRule.d.ts +2 -2
  16. package/dist/packages/core/src/commands/blur.d.ts +1 -1
  17. package/dist/packages/core/src/commands/clearContent.d.ts +1 -1
  18. package/dist/packages/core/src/commands/clearNodes.d.ts +1 -1
  19. package/dist/packages/core/src/commands/command.d.ts +1 -1
  20. package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -1
  21. package/dist/packages/core/src/commands/cut.d.ts +15 -0
  22. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -1
  23. package/dist/packages/core/src/commands/deleteNode.d.ts +1 -1
  24. package/dist/packages/core/src/commands/deleteRange.d.ts +1 -1
  25. package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -1
  26. package/dist/packages/core/src/commands/enter.d.ts +1 -1
  27. package/dist/packages/core/src/commands/exitCode.d.ts +1 -1
  28. package/dist/packages/core/src/commands/extendMarkRange.d.ts +1 -1
  29. package/dist/packages/core/src/commands/first.d.ts +1 -1
  30. package/dist/packages/core/src/commands/focus.d.ts +1 -1
  31. package/dist/packages/core/src/commands/forEach.d.ts +1 -1
  32. package/dist/packages/core/src/commands/index.d.ts +51 -50
  33. package/dist/packages/core/src/commands/insertContent.d.ts +1 -1
  34. package/dist/packages/core/src/commands/insertContentAt.d.ts +1 -1
  35. package/dist/packages/core/src/commands/join.d.ts +1 -1
  36. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +1 -1
  37. package/dist/packages/core/src/commands/lift.d.ts +1 -1
  38. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +1 -1
  39. package/dist/packages/core/src/commands/liftListItem.d.ts +1 -1
  40. package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -1
  41. package/dist/packages/core/src/commands/resetAttributes.d.ts +1 -1
  42. package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -1
  43. package/dist/packages/core/src/commands/selectAll.d.ts +1 -1
  44. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -1
  45. package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -1
  46. package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -1
  47. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -1
  48. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -1
  49. package/dist/packages/core/src/commands/setContent.d.ts +1 -1
  50. package/dist/packages/core/src/commands/setMark.d.ts +1 -1
  51. package/dist/packages/core/src/commands/setMeta.d.ts +1 -1
  52. package/dist/packages/core/src/commands/setNode.d.ts +1 -1
  53. package/dist/packages/core/src/commands/setNodeSelection.d.ts +1 -1
  54. package/dist/packages/core/src/commands/setTextSelection.d.ts +1 -1
  55. package/dist/packages/core/src/commands/sinkListItem.d.ts +1 -1
  56. package/dist/packages/core/src/commands/splitBlock.d.ts +1 -1
  57. package/dist/packages/core/src/commands/splitListItem.d.ts +1 -1
  58. package/dist/packages/core/src/commands/toggleList.d.ts +1 -1
  59. package/dist/packages/core/src/commands/toggleMark.d.ts +1 -1
  60. package/dist/packages/core/src/commands/toggleNode.d.ts +1 -1
  61. package/dist/packages/core/src/commands/toggleWrap.d.ts +1 -1
  62. package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -1
  63. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -1
  64. package/dist/packages/core/src/commands/unsetMark.d.ts +1 -1
  65. package/dist/packages/core/src/commands/updateAttributes.d.ts +1 -1
  66. package/dist/packages/core/src/commands/wrapIn.d.ts +1 -1
  67. package/dist/packages/core/src/commands/wrapInList.d.ts +1 -1
  68. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +1 -1
  69. package/dist/packages/core/src/extensions/commands.d.ts +2 -2
  70. package/dist/packages/core/src/extensions/editable.d.ts +1 -1
  71. package/dist/packages/core/src/extensions/focusEvents.d.ts +1 -1
  72. package/dist/packages/core/src/extensions/index.d.ts +6 -6
  73. package/dist/packages/core/src/extensions/keymap.d.ts +1 -1
  74. package/dist/packages/core/src/extensions/tabindex.d.ts +1 -1
  75. package/dist/packages/core/src/helpers/createDocument.d.ts +1 -1
  76. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +1 -1
  77. package/dist/packages/core/src/helpers/findChildren.d.ts +1 -1
  78. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +1 -1
  79. package/dist/packages/core/src/helpers/findParentNode.d.ts +1 -1
  80. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +1 -1
  81. package/dist/packages/core/src/helpers/generateHTML.d.ts +1 -1
  82. package/dist/packages/core/src/helpers/generateJSON.d.ts +1 -1
  83. package/dist/packages/core/src/helpers/generateText.d.ts +1 -1
  84. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +1 -1
  85. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +1 -1
  86. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +1 -1
  87. package/dist/packages/core/src/helpers/getExtensionField.d.ts +1 -1
  88. package/dist/packages/core/src/helpers/getMarkRange.d.ts +1 -1
  89. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +1 -1
  90. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +11 -0
  91. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +1 -1
  92. package/dist/packages/core/src/helpers/getSchema.d.ts +2 -2
  93. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +2 -2
  94. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +1 -1
  95. package/dist/packages/core/src/helpers/getText.d.ts +1 -1
  96. package/dist/packages/core/src/helpers/getTextBetween.d.ts +1 -1
  97. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +1 -1
  98. package/dist/packages/core/src/helpers/index.d.ts +50 -47
  99. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +1 -1
  100. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +2 -0
  101. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +2 -0
  102. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +1 -1
  103. package/dist/packages/core/src/helpers/isList.d.ts +1 -1
  104. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +1 -1
  105. package/dist/packages/core/src/helpers/splitExtensions.d.ts +4 -4
  106. package/dist/packages/core/src/index.d.ts +15 -15
  107. package/dist/packages/core/src/inputRules/index.d.ts +5 -5
  108. package/dist/packages/core/src/inputRules/markInputRule.d.ts +2 -2
  109. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +2 -2
  110. package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -1
  111. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +2 -2
  112. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +3 -3
  113. package/dist/packages/core/src/pasteRules/index.d.ts +3 -3
  114. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +2 -2
  115. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +2 -2
  116. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -1
  117. package/dist/packages/core/src/types.d.ts +5 -5
  118. package/dist/packages/core/src/utilities/callOrReturn.d.ts +1 -1
  119. package/dist/packages/core/src/utilities/index.d.ts +20 -20
  120. package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -0
  121. package/package.json +2 -2
  122. package/src/CommandManager.ts +4 -8
  123. package/src/Editor.ts +24 -16
  124. package/src/Extension.ts +10 -10
  125. package/src/ExtensionManager.ts +15 -15
  126. package/src/InputRule.ts +6 -6
  127. package/src/Mark.ts +9 -9
  128. package/src/Node.ts +8 -8
  129. package/src/NodeView.ts +8 -6
  130. package/src/PasteRule.ts +6 -6
  131. package/src/commands/blur.ts +1 -1
  132. package/src/commands/clearContent.ts +1 -1
  133. package/src/commands/clearNodes.ts +1 -1
  134. package/src/commands/command.ts +1 -1
  135. package/src/commands/createParagraphNear.ts +1 -1
  136. package/src/commands/cut.ts +27 -0
  137. package/src/commands/deleteCurrentNode.ts +1 -1
  138. package/src/commands/deleteNode.ts +2 -2
  139. package/src/commands/deleteRange.ts +1 -1
  140. package/src/commands/deleteSelection.ts +1 -1
  141. package/src/commands/enter.ts +1 -1
  142. package/src/commands/exitCode.ts +1 -1
  143. package/src/commands/extendMarkRange.ts +3 -3
  144. package/src/commands/first.ts +1 -1
  145. package/src/commands/focus.ts +4 -4
  146. package/src/commands/forEach.ts +1 -1
  147. package/src/commands/index.ts +51 -50
  148. package/src/commands/insertContent.ts +1 -1
  149. package/src/commands/insertContentAt.ts +4 -4
  150. package/src/commands/join.ts +1 -1
  151. package/src/commands/keyboardShortcut.ts +3 -3
  152. package/src/commands/lift.ts +3 -3
  153. package/src/commands/liftEmptyBlock.ts +1 -1
  154. package/src/commands/liftListItem.ts +2 -2
  155. package/src/commands/newlineInCode.ts +1 -1
  156. package/src/commands/resetAttributes.ts +5 -5
  157. package/src/commands/scrollIntoView.ts +1 -1
  158. package/src/commands/selectAll.ts +1 -1
  159. package/src/commands/selectNodeBackward.ts +1 -1
  160. package/src/commands/selectNodeForward.ts +1 -1
  161. package/src/commands/selectParentNode.ts +1 -1
  162. package/src/commands/selectTextblockEnd.ts +1 -1
  163. package/src/commands/selectTextblockStart.ts +1 -1
  164. package/src/commands/setContent.ts +2 -2
  165. package/src/commands/setMark.ts +4 -4
  166. package/src/commands/setMeta.ts +1 -1
  167. package/src/commands/setNode.ts +2 -2
  168. package/src/commands/setNodeSelection.ts +2 -2
  169. package/src/commands/setTextSelection.ts +2 -2
  170. package/src/commands/sinkListItem.ts +2 -2
  171. package/src/commands/splitBlock.ts +3 -3
  172. package/src/commands/splitListItem.ts +3 -3
  173. package/src/commands/toggleList.ts +4 -4
  174. package/src/commands/toggleMark.ts +3 -3
  175. package/src/commands/toggleNode.ts +3 -3
  176. package/src/commands/toggleWrap.ts +3 -3
  177. package/src/commands/undoInputRule.ts +1 -1
  178. package/src/commands/unsetAllMarks.ts +1 -1
  179. package/src/commands/unsetMark.ts +3 -3
  180. package/src/commands/updateAttributes.ts +4 -4
  181. package/src/commands/wrapIn.ts +2 -2
  182. package/src/commands/wrapInList.ts +2 -2
  183. package/src/extensions/clipboardTextSerializer.ts +3 -3
  184. package/src/extensions/commands.ts +3 -3
  185. package/src/extensions/editable.ts +1 -1
  186. package/src/extensions/focusEvents.ts +1 -1
  187. package/src/extensions/index.ts +6 -6
  188. package/src/extensions/keymap.ts +5 -5
  189. package/src/extensions/tabindex.ts +1 -1
  190. package/src/helpers/createDocument.ts +2 -2
  191. package/src/helpers/createNodeFromContent.ts +2 -2
  192. package/src/helpers/findChildren.ts +1 -1
  193. package/src/helpers/findChildrenInRange.ts +1 -1
  194. package/src/helpers/findParentNode.ts +2 -2
  195. package/src/helpers/findParentNodeClosestToPos.ts +1 -1
  196. package/src/helpers/generateHTML.ts +3 -3
  197. package/src/helpers/generateJSON.ts +3 -3
  198. package/src/helpers/generateText.ts +4 -4
  199. package/src/helpers/getAttributes.ts +3 -3
  200. package/src/helpers/getAttributesFromExtensions.ts +4 -4
  201. package/src/helpers/getChangedRanges.ts +2 -2
  202. package/src/helpers/getDebugJSON.ts +1 -1
  203. package/src/helpers/getExtensionField.ts +1 -1
  204. package/src/helpers/getMarkAttributes.ts +1 -1
  205. package/src/helpers/getMarkRange.ts +2 -2
  206. package/src/helpers/getMarksBetween.ts +2 -2
  207. package/src/helpers/getNodeAtPosition.ts +29 -0
  208. package/src/helpers/getNodeAttributes.ts +1 -1
  209. package/src/helpers/getRenderedAttributes.ts +2 -2
  210. package/src/helpers/getSchema.ts +4 -4
  211. package/src/helpers/getSchemaByResolvedExtensions.ts +9 -9
  212. package/src/helpers/getSplittedAttributes.ts +1 -1
  213. package/src/helpers/getText.ts +2 -2
  214. package/src/helpers/getTextBetween.ts +1 -1
  215. package/src/helpers/getTextSerializersFromSchema.ts +1 -1
  216. package/src/helpers/index.ts +50 -47
  217. package/src/helpers/injectExtensionAttributesToParseRule.ts +2 -2
  218. package/src/helpers/isActive.ts +3 -3
  219. package/src/helpers/isAtEndOfNode.ts +11 -0
  220. package/src/helpers/isAtStartOfNode.ts +11 -0
  221. package/src/helpers/isExtensionRulesEnabled.ts +1 -1
  222. package/src/helpers/isList.ts +5 -5
  223. package/src/helpers/isMarkActive.ts +3 -3
  224. package/src/helpers/isNodeActive.ts +3 -3
  225. package/src/helpers/posToDOMRect.ts +1 -1
  226. package/src/helpers/resolveFocusPosition.ts +2 -2
  227. package/src/helpers/splitExtensions.ts +4 -4
  228. package/src/index.ts +15 -15
  229. package/src/inputRules/index.ts +5 -5
  230. package/src/inputRules/markInputRule.ts +5 -6
  231. package/src/inputRules/nodeInputRule.ts +3 -3
  232. package/src/inputRules/textInputRule.ts +1 -1
  233. package/src/inputRules/textblockTypeInputRule.ts +3 -3
  234. package/src/inputRules/wrappingInputRule.ts +4 -4
  235. package/src/pasteRules/index.ts +3 -3
  236. package/src/pasteRules/markPasteRule.ts +4 -4
  237. package/src/pasteRules/nodePasteRule.ts +3 -3
  238. package/src/pasteRules/textPasteRule.ts +1 -1
  239. package/src/types.ts +5 -5
  240. package/src/utilities/callOrReturn.ts +2 -2
  241. package/src/utilities/index.ts +20 -20
  242. package/src/utilities/isAndroid.ts +3 -0
  243. package/src/utilities/mergeDeep.ts +1 -1
  244. package/src/utilities/objectIncludes.ts +1 -1
package/dist/index.js CHANGED
@@ -117,9 +117,6 @@ class CommandManager {
117
117
  buildProps(tr, shouldDispatch = true) {
118
118
  const { rawCommands, editor, state } = this;
119
119
  const { view } = editor;
120
- if (state.storedMarks) {
121
- tr.setStoredMarks(state.storedMarks);
122
- }
123
120
  const props = {
124
121
  tr,
125
122
  editor,
@@ -129,7 +126,7 @@ class CommandManager {
129
126
  transaction: tr,
130
127
  }),
131
128
  dispatch: shouldDispatch ? () => undefined : undefined,
132
- chain: () => this.createChain(tr),
129
+ chain: () => this.createChain(tr, shouldDispatch),
133
130
  can: () => this.createCan(tr),
134
131
  get commands() {
135
132
  return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
@@ -1308,6 +1305,19 @@ const createParagraphNear = () => ({ state, dispatch }) => {
1308
1305
  return createParagraphNear$1(state, dispatch);
1309
1306
  };
1310
1307
 
1308
+ const cut = (originRange, targetPos) => ({ editor }) => {
1309
+ const { state } = editor;
1310
+ const contentSlice = state.doc.slice(originRange.from, originRange.to);
1311
+ return editor
1312
+ .chain()
1313
+ .deleteRange(originRange)
1314
+ .command(({ commands, tr }) => {
1315
+ return commands.insertContentAt(tr.mapping.map(targetPos), contentSlice.content.toJSON());
1316
+ })
1317
+ .focus()
1318
+ .run();
1319
+ };
1320
+
1311
1321
  const deleteCurrentNode = () => ({ tr, dispatch }) => {
1312
1322
  const { selection } = tr;
1313
1323
  const currentNode = selection.$anchor.node();
@@ -1637,7 +1647,7 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
1637
1647
  if (content.toString() === '<>') {
1638
1648
  return true;
1639
1649
  }
1640
- let { from, to } = typeof position === 'number' ? { from: position, to: position } : position;
1650
+ let { from, to } = typeof position === 'number' ? { from: position, to: position } : { from: position.from, to: position.to };
1641
1651
  let isOnlyTextContent = true;
1642
1652
  let isOnlyBlockContent = true;
1643
1653
  const nodes = isFragment(content) ? content : [content];
@@ -1945,6 +1955,28 @@ const setContent = (content, emitUpdate = false, parseOptions = {}) => ({ tr, ed
1945
1955
  return true;
1946
1956
  };
1947
1957
 
1958
+ function getMarkAttributes(state, typeOrName) {
1959
+ const type = getMarkType(typeOrName, state.schema);
1960
+ const { from, to, empty } = state.selection;
1961
+ const marks = [];
1962
+ if (empty) {
1963
+ if (state.storedMarks) {
1964
+ marks.push(...state.storedMarks);
1965
+ }
1966
+ marks.push(...state.selection.$head.marks());
1967
+ }
1968
+ else {
1969
+ state.doc.nodesBetween(from, to, node => {
1970
+ marks.push(...node.marks);
1971
+ });
1972
+ }
1973
+ const mark = marks.find(markItem => markItem.type.name === type.name);
1974
+ if (!mark) {
1975
+ return {};
1976
+ }
1977
+ return { ...mark.attrs };
1978
+ }
1979
+
1948
1980
  /**
1949
1981
  * Returns a new `Transform` based on all steps of the passed transactions.
1950
1982
  */
@@ -2070,28 +2102,6 @@ function generateText(doc, extensions, options) {
2070
2102
  });
2071
2103
  }
2072
2104
 
2073
- function getMarkAttributes(state, typeOrName) {
2074
- const type = getMarkType(typeOrName, state.schema);
2075
- const { from, to, empty } = state.selection;
2076
- const marks = [];
2077
- if (empty) {
2078
- if (state.storedMarks) {
2079
- marks.push(...state.storedMarks);
2080
- }
2081
- marks.push(...state.selection.$head.marks());
2082
- }
2083
- else {
2084
- state.doc.nodesBetween(from, to, node => {
2085
- marks.push(...node.marks);
2086
- });
2087
- }
2088
- const mark = marks.find(markItem => markItem.type.name === type.name);
2089
- if (!mark) {
2090
- return {};
2091
- }
2092
- return { ...mark.attrs };
2093
- }
2094
-
2095
2105
  function getNodeAttributes(state, typeOrName) {
2096
2106
  const type = getNodeType(typeOrName, state.schema);
2097
2107
  const { from, to } = state.selection;
@@ -2263,6 +2273,30 @@ function getMarksBetween(from, to, doc) {
2263
2273
  return marks;
2264
2274
  }
2265
2275
 
2276
+ /**
2277
+ * Finds the first node of a given type or name in the current selection.
2278
+ * @param state The editor state.
2279
+ * @param typeOrName The node type or name.
2280
+ * @param pos The position to start searching from.
2281
+ * @param maxDepth The maximum depth to search.
2282
+ * @returns The node and the depth as an array.
2283
+ */
2284
+ const getNodeAtPosition = (state, typeOrName, pos, maxDepth = 20) => {
2285
+ const $pos = state.doc.resolve(pos);
2286
+ let currentDepth = maxDepth;
2287
+ let node = null;
2288
+ while (currentDepth > 0 && node === null) {
2289
+ const currentNode = $pos.node(currentDepth);
2290
+ if ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type.name) === typeOrName) {
2291
+ node = currentNode;
2292
+ }
2293
+ else {
2294
+ currentDepth -= 1;
2295
+ }
2296
+ }
2297
+ return [node, currentDepth];
2298
+ };
2299
+
2266
2300
  function getSplittedAttributes(extensionAttributes, typeName, attributes) {
2267
2301
  return Object.fromEntries(Object
2268
2302
  .entries(attributes)
@@ -2353,6 +2387,22 @@ function isActive(state, name, attributes = {}) {
2353
2387
  return false;
2354
2388
  }
2355
2389
 
2390
+ const istAtEndOfNode = (state) => {
2391
+ const { $from, $to } = state.selection;
2392
+ if ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) {
2393
+ return false;
2394
+ }
2395
+ return true;
2396
+ };
2397
+
2398
+ const isAtStartOfNode = (state) => {
2399
+ const { $from, $to } = state.selection;
2400
+ if ($from.parentOffset > 0 || $from.pos !== $to.pos) {
2401
+ return false;
2402
+ }
2403
+ return true;
2404
+ };
2405
+
2356
2406
  function isList(name, extensions) {
2357
2407
  const { nodeExtensions } = splitExtensions(extensions);
2358
2408
  const extension = nodeExtensions.find(item => item.name === name);
@@ -2960,6 +3010,7 @@ var commands = /*#__PURE__*/Object.freeze({
2960
3010
  clearNodes: clearNodes,
2961
3011
  command: command,
2962
3012
  createParagraphNear: createParagraphNear,
3013
+ cut: cut,
2963
3014
  deleteCurrentNode: deleteCurrentNode,
2964
3015
  deleteNode: deleteNode,
2965
3016
  deleteRange: deleteRange,
@@ -3493,6 +3544,7 @@ class Editor extends EventEmitter {
3493
3544
  });
3494
3545
  this.view.updateState(newState);
3495
3546
  this.createNodeViews();
3547
+ this.prependClass();
3496
3548
  // Let’s store the editor instance in the DOM element.
3497
3549
  // So we’ll have access to it for tests.
3498
3550
  const dom = this.view.dom;
@@ -3506,6 +3558,12 @@ class Editor extends EventEmitter {
3506
3558
  nodeViews: this.extensionManager.nodeViews,
3507
3559
  });
3508
3560
  }
3561
+ /**
3562
+ * Prepend class name to element.
3563
+ */
3564
+ prependClass() {
3565
+ this.view.dom.className = `tiptap ${this.view.dom.className}`;
3566
+ }
3509
3567
  captureTransaction(fn) {
3510
3568
  this.isCapturingTransaction = true;
3511
3569
  fn();
@@ -3656,7 +3714,6 @@ function markInputRule(config) {
3656
3714
  const { tr } = state;
3657
3715
  const captureGroup = match[match.length - 1];
3658
3716
  const fullMatch = match[0];
3659
- let markEnd = range.to;
3660
3717
  if (captureGroup) {
3661
3718
  const startSpaces = fullMatch.search(/\S/);
3662
3719
  const textStart = range.from + fullMatch.indexOf(captureGroup);
@@ -3677,7 +3734,7 @@ function markInputRule(config) {
3677
3734
  if (textStart > range.from) {
3678
3735
  tr.delete(range.from + startSpaces, textStart);
3679
3736
  }
3680
- markEnd = range.from + startSpaces + captureGroup.length;
3737
+ const markEnd = range.from + startSpaces + captureGroup.length;
3681
3738
  tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
3682
3739
  tr.removeStoredMark(config.type);
3683
3740
  }
@@ -3965,6 +4022,10 @@ class Node {
3965
4022
  }
3966
4023
  }
3967
4024
 
4025
+ function isAndroid() {
4026
+ return navigator.platform === 'Android' || /android/i.test(navigator.userAgent);
4027
+ }
4028
+
3968
4029
  class NodeView {
3969
4030
  constructor(component, props, options) {
3970
4031
  this.isDragging = false;
@@ -4105,13 +4166,14 @@ class NodeView {
4105
4166
  if (mutation.type === 'selection') {
4106
4167
  return false;
4107
4168
  }
4108
- // try to prevent a bug on iOS that will break node views on enter
4169
+ // try to prevent a bug on iOS and Android that will break node views on enter
4109
4170
  // this is because ProseMirror can’t preventDispatch on enter
4110
4171
  // this will lead to a re-render of the node view on enter
4111
4172
  // see: https://github.com/ueberdosis/tiptap/issues/1214
4173
+ // see: https://github.com/ueberdosis/tiptap/issues/2534
4112
4174
  if (this.dom.contains(mutation.target)
4113
4175
  && mutation.type === 'childList'
4114
- && isiOS()
4176
+ && (isiOS() || isAndroid())
4115
4177
  && this.editor.isFocused) {
4116
4178
  const changedNodes = [
4117
4179
  ...Array.from(mutation.addedNodes),
@@ -4275,5 +4337,5 @@ class Tracker {
4275
4337
  }
4276
4338
  }
4277
4339
 
4278
- export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, combineTransactionSteps, createChainableState, createDocument, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, 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, selectionToInsertionEnd, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
4340
+ export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, combineTransactionSteps, createChainableState, createDocument, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, 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, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, istAtEndOfNode, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveFocusPosition, selectionToInsertionEnd, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
4279
4341
  //# sourceMappingURL=index.js.map