@tiptap/core 3.0.0 → 3.0.2-beta.0

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 (340) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +5169 -4654
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +3356 -0
  6. package/dist/index.d.ts +3356 -0
  7. package/dist/index.js +5051 -4561
  8. package/dist/index.js.map +1 -1
  9. package/dist/jsx-runtime/jsx-runtime.cjs +56 -0
  10. package/dist/jsx-runtime/jsx-runtime.cjs.map +1 -0
  11. package/dist/jsx-runtime/jsx-runtime.d.cts +22 -0
  12. package/dist/jsx-runtime/jsx-runtime.d.ts +22 -0
  13. package/dist/jsx-runtime/jsx-runtime.js +26 -0
  14. package/dist/jsx-runtime/jsx-runtime.js.map +1 -0
  15. package/jsx-dev-runtime/index.cjs +1 -0
  16. package/jsx-dev-runtime/index.d.cts +1 -0
  17. package/jsx-dev-runtime/index.d.ts +1 -0
  18. package/jsx-dev-runtime/index.js +1 -0
  19. package/jsx-runtime/index.cjs +1 -0
  20. package/jsx-runtime/index.d.cts +1 -0
  21. package/jsx-runtime/index.d.ts +1 -0
  22. package/jsx-runtime/index.js +1 -0
  23. package/package.json +30 -10
  24. package/src/CommandManager.ts +4 -11
  25. package/src/Editor.ts +273 -100
  26. package/src/EventEmitter.ts +16 -10
  27. package/src/Extendable.ts +484 -0
  28. package/src/Extension.ts +29 -493
  29. package/src/ExtensionManager.ts +100 -143
  30. package/src/InputRule.ts +28 -24
  31. package/src/Mark.ts +157 -624
  32. package/src/MarkView.ts +122 -0
  33. package/src/Node.ts +343 -807
  34. package/src/NodePos.ts +18 -9
  35. package/src/NodeView.ts +58 -35
  36. package/src/PasteRule.ts +68 -24
  37. package/src/Tracker.ts +8 -10
  38. package/src/commands/blur.ts +15 -13
  39. package/src/commands/clearContent.ts +13 -6
  40. package/src/commands/clearNodes.ts +33 -31
  41. package/src/commands/command.ts +2 -2
  42. package/src/commands/createParagraphNear.ts +6 -4
  43. package/src/commands/cut.ts +13 -11
  44. package/src/commands/deleteCurrentNode.ts +24 -22
  45. package/src/commands/deleteNode.ts +20 -18
  46. package/src/commands/deleteRange.ts +11 -9
  47. package/src/commands/deleteSelection.ts +6 -4
  48. package/src/commands/enter.ts +7 -5
  49. package/src/commands/exitCode.ts +6 -4
  50. package/src/commands/extendMarkRange.ts +16 -14
  51. package/src/commands/first.ts +3 -5
  52. package/src/commands/focus.ts +51 -53
  53. package/src/commands/forEach.ts +3 -3
  54. package/src/commands/insertContent.ts +8 -10
  55. package/src/commands/insertContentAt.ts +131 -76
  56. package/src/commands/join.ts +21 -13
  57. package/src/commands/joinItemBackward.ts +17 -19
  58. package/src/commands/joinItemForward.ts +17 -19
  59. package/src/commands/joinTextblockBackward.ts +6 -4
  60. package/src/commands/joinTextblockForward.ts +6 -4
  61. package/src/commands/keyboardShortcut.ts +30 -35
  62. package/src/commands/lift.ts +12 -10
  63. package/src/commands/liftEmptyBlock.ts +7 -5
  64. package/src/commands/liftListItem.ts +8 -6
  65. package/src/commands/newlineInCode.ts +6 -4
  66. package/src/commands/resetAttributes.ts +38 -43
  67. package/src/commands/scrollIntoView.ts +10 -8
  68. package/src/commands/selectAll.ts +15 -8
  69. package/src/commands/selectNodeBackward.ts +6 -4
  70. package/src/commands/selectNodeForward.ts +6 -4
  71. package/src/commands/selectParentNode.ts +6 -4
  72. package/src/commands/selectTextblockEnd.ts +6 -4
  73. package/src/commands/selectTextblockStart.ts +6 -4
  74. package/src/commands/setContent.ts +37 -40
  75. package/src/commands/setMark.ts +58 -60
  76. package/src/commands/setMeta.ts +10 -6
  77. package/src/commands/setNode.ts +36 -27
  78. package/src/commands/setNodeSelection.ts +12 -10
  79. package/src/commands/setTextSelection.ts +16 -14
  80. package/src/commands/sinkListItem.ts +8 -6
  81. package/src/commands/splitBlock.ts +60 -68
  82. package/src/commands/splitListItem.ts +99 -101
  83. package/src/commands/toggleList.ts +76 -74
  84. package/src/commands/toggleMark.ts +13 -11
  85. package/src/commands/toggleNode.ts +22 -11
  86. package/src/commands/toggleWrap.ts +12 -10
  87. package/src/commands/undoInputRule.ts +32 -30
  88. package/src/commands/unsetAllMarks.ts +17 -15
  89. package/src/commands/unsetMark.ts +29 -27
  90. package/src/commands/updateAttributes.ts +97 -45
  91. package/src/commands/wrapIn.ts +8 -6
  92. package/src/commands/wrapInList.ts +8 -6
  93. package/src/extensions/clipboardTextSerializer.ts +2 -4
  94. package/src/extensions/delete.ts +89 -0
  95. package/src/extensions/drop.ts +26 -0
  96. package/src/extensions/focusEvents.ts +5 -7
  97. package/src/extensions/index.ts +4 -1
  98. package/src/extensions/keymap.ts +63 -52
  99. package/src/extensions/paste.ts +25 -0
  100. package/src/extensions/tabindex.ts +1 -1
  101. package/src/helpers/combineTransactionSteps.ts +3 -6
  102. package/src/helpers/createChainableState.ts +2 -5
  103. package/src/helpers/createDocument.ts +3 -3
  104. package/src/helpers/createNodeFromContent.ts +37 -25
  105. package/src/helpers/defaultBlockAt.ts +1 -1
  106. package/src/helpers/findChildren.ts +2 -2
  107. package/src/helpers/findChildrenInRange.ts +3 -7
  108. package/src/helpers/findParentNode.ts +5 -3
  109. package/src/helpers/findParentNodeClosestToPos.ts +2 -2
  110. package/src/helpers/flattenExtensions.ts +30 -0
  111. package/src/helpers/generateHTML.ts +1 -1
  112. package/src/helpers/generateJSON.ts +1 -1
  113. package/src/helpers/generateText.ts +1 -1
  114. package/src/helpers/getAttributes.ts +3 -6
  115. package/src/helpers/getAttributesFromExtensions.ts +29 -38
  116. package/src/helpers/getChangedRanges.ts +15 -13
  117. package/src/helpers/getDebugJSON.ts +2 -2
  118. package/src/helpers/getExtensionField.ts +12 -12
  119. package/src/helpers/getHTMLFromFragment.ts +2 -1
  120. package/src/helpers/getMarkAttributes.ts +3 -6
  121. package/src/helpers/getMarkRange.ts +36 -19
  122. package/src/helpers/getMarkType.ts +2 -4
  123. package/src/helpers/getMarksBetween.ts +3 -3
  124. package/src/helpers/getNodeAtPosition.ts +2 -2
  125. package/src/helpers/getNodeAttributes.ts +3 -6
  126. package/src/helpers/getNodeType.ts +2 -4
  127. package/src/helpers/getRenderedAttributes.ts +3 -2
  128. package/src/helpers/getSchema.ts +5 -5
  129. package/src/helpers/getSchemaByResolvedExtensions.ts +49 -79
  130. package/src/helpers/getSchemaTypeByName.ts +1 -1
  131. package/src/helpers/getSchemaTypeNameByName.ts +1 -1
  132. package/src/helpers/getSplittedAttributes.ts +5 -5
  133. package/src/helpers/getText.ts +2 -2
  134. package/src/helpers/getTextBetween.ts +2 -2
  135. package/src/helpers/getTextContentFromNodes.ts +9 -12
  136. package/src/helpers/getTextSerializersFromSchema.ts +2 -2
  137. package/src/helpers/index.ts +4 -0
  138. package/src/helpers/injectExtensionAttributesToParseRule.ts +3 -3
  139. package/src/helpers/isActive.ts +2 -6
  140. package/src/helpers/isAtEndOfNode.ts +1 -1
  141. package/src/helpers/isAtStartOfNode.ts +1 -1
  142. package/src/helpers/isExtensionRulesEnabled.ts +2 -4
  143. package/src/helpers/isList.ts +2 -2
  144. package/src/helpers/isMarkActive.ts +3 -3
  145. package/src/helpers/isNodeActive.ts +3 -3
  146. package/src/helpers/isNodeEmpty.ts +56 -5
  147. package/src/helpers/posToDOMRect.ts +1 -1
  148. package/src/helpers/resolveExtensions.ts +25 -0
  149. package/src/helpers/resolveFocusPosition.ts +5 -16
  150. package/src/helpers/rewriteUnknownContent.ts +149 -0
  151. package/src/helpers/selectionToInsertionEnd.ts +2 -1
  152. package/src/helpers/sortExtensions.ts +26 -0
  153. package/src/helpers/splitExtensions.ts +4 -4
  154. package/src/index.ts +3 -7
  155. package/src/inputRules/markInputRule.ts +6 -9
  156. package/src/inputRules/nodeInputRule.ts +7 -13
  157. package/src/inputRules/textInputRule.ts +4 -6
  158. package/src/inputRules/textblockTypeInputRule.ts +7 -12
  159. package/src/inputRules/wrappingInputRule.ts +19 -24
  160. package/src/jsx-runtime.ts +64 -0
  161. package/src/pasteRules/markPasteRule.ts +6 -7
  162. package/src/pasteRules/nodePasteRule.ts +15 -11
  163. package/src/pasteRules/textPasteRule.ts +4 -6
  164. package/src/style.ts +2 -6
  165. package/src/types.ts +513 -58
  166. package/src/utilities/callOrReturn.ts +1 -1
  167. package/src/utilities/canInsertNode.ts +30 -0
  168. package/src/utilities/createStyleTag.ts +3 -1
  169. package/src/utilities/deleteProps.ts +7 -11
  170. package/src/utilities/elementFromString.ts +3 -0
  171. package/src/utilities/findDuplicates.ts +5 -2
  172. package/src/utilities/index.ts +2 -0
  173. package/src/utilities/isFunction.ts +1 -0
  174. package/src/utilities/isMacOS.ts +1 -3
  175. package/src/utilities/isiOS.ts +5 -10
  176. package/src/utilities/mergeAttributes.ts +32 -5
  177. package/src/utilities/removeDuplicates.ts +1 -3
  178. package/dist/index.umd.js +0 -5098
  179. package/dist/index.umd.js.map +0 -1
  180. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  181. package/dist/packages/core/src/Editor.d.ts +0 -161
  182. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  183. package/dist/packages/core/src/Extension.d.ts +0 -343
  184. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  185. package/dist/packages/core/src/InputRule.d.ts +0 -42
  186. package/dist/packages/core/src/Mark.d.ts +0 -451
  187. package/dist/packages/core/src/Node.d.ts +0 -611
  188. package/dist/packages/core/src/NodePos.d.ts +0 -44
  189. package/dist/packages/core/src/NodeView.d.ts +0 -31
  190. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  191. package/dist/packages/core/src/Tracker.d.ts +0 -11
  192. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  193. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  194. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  195. package/dist/packages/core/src/commands/command.d.ts +0 -18
  196. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  197. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  198. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  199. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  200. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  201. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  202. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  203. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  204. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  205. package/dist/packages/core/src/commands/first.d.ts +0 -14
  206. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  207. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  208. package/dist/packages/core/src/commands/index.d.ts +0 -55
  209. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  210. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  211. package/dist/packages/core/src/commands/join.d.ts +0 -41
  212. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  213. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  214. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  215. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  216. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  217. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  218. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  219. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  220. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  221. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  222. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  223. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  224. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  225. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  226. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  227. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  228. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  229. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  230. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  231. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  232. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  233. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  234. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  235. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  236. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  237. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  238. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  239. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  240. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  241. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  242. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  243. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  244. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  245. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  246. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  247. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  248. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  249. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  250. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  251. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  252. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  253. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  254. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  255. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  256. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  257. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  258. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  259. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  260. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  261. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  262. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  263. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  264. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  265. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  266. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  267. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  268. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  269. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  270. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  271. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  272. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  273. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  274. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  275. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  276. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  277. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  278. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  279. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  280. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  281. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  282. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  283. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  284. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  285. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  286. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  287. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  288. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  289. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  290. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  291. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  292. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  293. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  294. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  295. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  296. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  297. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  298. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  299. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  300. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  301. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  302. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  303. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  304. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  305. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  306. package/dist/packages/core/src/index.d.ts +0 -24
  307. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  308. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  309. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  310. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  311. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  312. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  313. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  314. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  315. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  316. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  317. package/dist/packages/core/src/style.d.ts +0 -1
  318. package/dist/packages/core/src/types.d.ts +0 -255
  319. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  320. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  321. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  322. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  323. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  324. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  325. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  326. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  327. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  328. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  329. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  330. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  331. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  332. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  333. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  334. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  335. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  336. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  337. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  338. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  339. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  340. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
@@ -1,9 +1,8 @@
1
- import {
2
- MarkSpec, NodeSpec, Schema, TagParseRule,
3
- } from '@tiptap/pm/model'
1
+ import type { MarkSpec, NodeSpec, TagParseRule } from '@tiptap/pm/model'
2
+ import { Schema } from '@tiptap/pm/model'
4
3
 
5
- import { Editor, MarkConfig, NodeConfig } from '../index.js'
6
- import { AnyConfig, Extensions } from '../types.js'
4
+ import type { Editor, MarkConfig, NodeConfig } from '../index.js'
5
+ import type { AnyConfig, Extensions } from '../types.js'
7
6
  import { callOrReturn } from '../utilities/callOrReturn.js'
8
7
  import { isEmptyObject } from '../utilities/isEmptyObject.js'
9
8
  import { getAttributesFromExtensions } from './getAttributesFromExtensions.js'
@@ -16,7 +15,7 @@ function cleanUpSchemaItem<T>(data: T) {
16
15
  return Object.fromEntries(
17
16
  // @ts-ignore
18
17
  Object.entries(data).filter(([key, value]) => {
19
- if (key === 'attrs' && isEmptyObject(value as {} | undefined)) {
18
+ if (key === 'attrs' && isEmptyObject(value as object | undefined)) {
20
19
  return false
21
20
  }
22
21
 
@@ -38,9 +37,7 @@ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: E
38
37
 
39
38
  const nodes = Object.fromEntries(
40
39
  nodeExtensions.map(extension => {
41
- const extensionAttributes = allAttributes.filter(
42
- attribute => attribute.type === extension.name,
43
- )
40
+ const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name)
44
41
  const context = {
45
42
  name: extension.name,
46
43
  options: extension.options,
@@ -49,11 +46,7 @@ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: E
49
46
  }
50
47
 
51
48
  const extraNodeFields = extensions.reduce((fields, e) => {
52
- const extendNodeSchema = getExtensionField<AnyConfig['extendNodeSchema']>(
53
- e,
54
- 'extendNodeSchema',
55
- context,
56
- )
49
+ const extendNodeSchema = getExtensionField<AnyConfig['extendNodeSchema']>(e, 'extendNodeSchema', context)
57
50
 
58
51
  return {
59
52
  ...fields,
@@ -63,60 +56,49 @@ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: E
63
56
 
64
57
  const schema: NodeSpec = cleanUpSchemaItem({
65
58
  ...extraNodeFields,
66
- content: callOrReturn(
67
- getExtensionField<NodeConfig['content']>(extension, 'content', context),
68
- ),
59
+ content: callOrReturn(getExtensionField<NodeConfig['content']>(extension, 'content', context)),
69
60
  marks: callOrReturn(getExtensionField<NodeConfig['marks']>(extension, 'marks', context)),
70
61
  group: callOrReturn(getExtensionField<NodeConfig['group']>(extension, 'group', context)),
71
62
  inline: callOrReturn(getExtensionField<NodeConfig['inline']>(extension, 'inline', context)),
72
63
  atom: callOrReturn(getExtensionField<NodeConfig['atom']>(extension, 'atom', context)),
73
- selectable: callOrReturn(
74
- getExtensionField<NodeConfig['selectable']>(extension, 'selectable', context),
75
- ),
76
- draggable: callOrReturn(
77
- getExtensionField<NodeConfig['draggable']>(extension, 'draggable', context),
78
- ),
64
+ selectable: callOrReturn(getExtensionField<NodeConfig['selectable']>(extension, 'selectable', context)),
65
+ draggable: callOrReturn(getExtensionField<NodeConfig['draggable']>(extension, 'draggable', context)),
79
66
  code: callOrReturn(getExtensionField<NodeConfig['code']>(extension, 'code', context)),
80
67
  whitespace: callOrReturn(getExtensionField<NodeConfig['whitespace']>(extension, 'whitespace', context)),
81
- defining: callOrReturn(
82
- getExtensionField<NodeConfig['defining']>(extension, 'defining', context),
83
- ),
84
- isolating: callOrReturn(
85
- getExtensionField<NodeConfig['isolating']>(extension, 'isolating', context),
68
+ linebreakReplacement: callOrReturn(
69
+ getExtensionField<NodeConfig['linebreakReplacement']>(extension, 'linebreakReplacement', context),
86
70
  ),
71
+ defining: callOrReturn(getExtensionField<NodeConfig['defining']>(extension, 'defining', context)),
72
+ isolating: callOrReturn(getExtensionField<NodeConfig['isolating']>(extension, 'isolating', context)),
87
73
  attrs: Object.fromEntries(
88
74
  extensionAttributes.map(extensionAttribute => {
89
- return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }]
75
+ return [
76
+ extensionAttribute.name,
77
+ { default: extensionAttribute?.attribute?.default, validate: extensionAttribute?.attribute?.validate },
78
+ ]
90
79
  }),
91
80
  ),
92
81
  })
93
82
 
94
- const parseHTML = callOrReturn(
95
- getExtensionField<NodeConfig['parseHTML']>(extension, 'parseHTML', context),
96
- )
83
+ const parseHTML = callOrReturn(getExtensionField<NodeConfig['parseHTML']>(extension, 'parseHTML', context))
97
84
 
98
85
  if (parseHTML) {
99
- schema.parseDOM = parseHTML.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes)) as TagParseRule[]
86
+ schema.parseDOM = parseHTML.map(parseRule =>
87
+ injectExtensionAttributesToParseRule(parseRule, extensionAttributes),
88
+ ) as TagParseRule[]
100
89
  }
101
90
 
102
- const renderHTML = getExtensionField<NodeConfig['renderHTML']>(
103
- extension,
104
- 'renderHTML',
105
- context,
106
- )
91
+ const renderHTML = getExtensionField<NodeConfig['renderHTML']>(extension, 'renderHTML', context)
107
92
 
108
93
  if (renderHTML) {
109
- schema.toDOM = node => renderHTML({
110
- node,
111
- HTMLAttributes: getRenderedAttributes(node, extensionAttributes),
112
- })
94
+ schema.toDOM = node =>
95
+ renderHTML({
96
+ node,
97
+ HTMLAttributes: getRenderedAttributes(node, extensionAttributes),
98
+ })
113
99
  }
114
100
 
115
- const renderText = getExtensionField<NodeConfig['renderText']>(
116
- extension,
117
- 'renderText',
118
- context,
119
- )
101
+ const renderText = getExtensionField<NodeConfig['renderText']>(extension, 'renderText', context)
120
102
 
121
103
  if (renderText) {
122
104
  schema.toText = renderText
@@ -128,9 +110,7 @@ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: E
128
110
 
129
111
  const marks = Object.fromEntries(
130
112
  markExtensions.map(extension => {
131
- const extensionAttributes = allAttributes.filter(
132
- attribute => attribute.type === extension.name,
133
- )
113
+ const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name)
134
114
  const context = {
135
115
  name: extension.name,
136
116
  options: extension.options,
@@ -139,57 +119,47 @@ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: E
139
119
  }
140
120
 
141
121
  const extraMarkFields = extensions.reduce((fields, e) => {
142
- const extendMarkSchema = getExtensionField<AnyConfig['extendMarkSchema']>(
143
- e,
144
- 'extendMarkSchema',
145
- context,
146
- )
122
+ const extendMarkSchema = getExtensionField<AnyConfig['extendMarkSchema']>(e, 'extendMarkSchema', context)
147
123
 
148
124
  return {
149
125
  ...fields,
150
- ...(extendMarkSchema ? extendMarkSchema(extension) : {}),
126
+ ...(extendMarkSchema ? extendMarkSchema(extension as any) : {}),
151
127
  }
152
128
  }, {})
153
129
 
154
130
  const schema: MarkSpec = cleanUpSchemaItem({
155
131
  ...extraMarkFields,
156
- inclusive: callOrReturn(
157
- getExtensionField<MarkConfig['inclusive']>(extension, 'inclusive', context),
158
- ),
159
- excludes: callOrReturn(
160
- getExtensionField<MarkConfig['excludes']>(extension, 'excludes', context),
161
- ),
132
+ inclusive: callOrReturn(getExtensionField<MarkConfig['inclusive']>(extension, 'inclusive', context)),
133
+ excludes: callOrReturn(getExtensionField<MarkConfig['excludes']>(extension, 'excludes', context)),
162
134
  group: callOrReturn(getExtensionField<MarkConfig['group']>(extension, 'group', context)),
163
- spanning: callOrReturn(
164
- getExtensionField<MarkConfig['spanning']>(extension, 'spanning', context),
165
- ),
135
+ spanning: callOrReturn(getExtensionField<MarkConfig['spanning']>(extension, 'spanning', context)),
166
136
  code: callOrReturn(getExtensionField<MarkConfig['code']>(extension, 'code', context)),
167
137
  attrs: Object.fromEntries(
168
138
  extensionAttributes.map(extensionAttribute => {
169
- return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }]
139
+ return [
140
+ extensionAttribute.name,
141
+ { default: extensionAttribute?.attribute?.default, validate: extensionAttribute?.attribute?.validate },
142
+ ]
170
143
  }),
171
144
  ),
172
145
  })
173
146
 
174
- const parseHTML = callOrReturn(
175
- getExtensionField<MarkConfig['parseHTML']>(extension, 'parseHTML', context),
176
- )
147
+ const parseHTML = callOrReturn(getExtensionField<MarkConfig['parseHTML']>(extension, 'parseHTML', context))
177
148
 
178
149
  if (parseHTML) {
179
- schema.parseDOM = parseHTML.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes))
150
+ schema.parseDOM = parseHTML.map(parseRule =>
151
+ injectExtensionAttributesToParseRule(parseRule, extensionAttributes),
152
+ )
180
153
  }
181
154
 
182
- const renderHTML = getExtensionField<MarkConfig['renderHTML']>(
183
- extension,
184
- 'renderHTML',
185
- context,
186
- )
155
+ const renderHTML = getExtensionField<MarkConfig['renderHTML']>(extension, 'renderHTML', context)
187
156
 
188
157
  if (renderHTML) {
189
- schema.toDOM = mark => renderHTML({
190
- mark,
191
- HTMLAttributes: getRenderedAttributes(mark, extensionAttributes),
192
- })
158
+ schema.toDOM = mark =>
159
+ renderHTML({
160
+ mark,
161
+ HTMLAttributes: getRenderedAttributes(mark, extensionAttributes),
162
+ })
193
163
  }
194
164
 
195
165
  return [extension.name, schema]
@@ -1,4 +1,4 @@
1
- import { MarkType, NodeType, Schema } from '@tiptap/pm/model'
1
+ import type { MarkType, NodeType, Schema } from '@tiptap/pm/model'
2
2
 
3
3
  /**
4
4
  * Tries to get a node or mark type by its name.
@@ -1,4 +1,4 @@
1
- import { Schema } from '@tiptap/pm/model'
1
+ import type { Schema } from '@tiptap/pm/model'
2
2
 
3
3
  /**
4
4
  * Get the type of a schema item by its name.
@@ -1,4 +1,4 @@
1
- import { ExtensionAttribute } from '../types.js'
1
+ import type { ExtensionAttribute } from '../types.js'
2
2
 
3
3
  /**
4
4
  * Return attributes of an extension that should be splitted by keepOnSplit flag
@@ -12,9 +12,8 @@ export function getSplittedAttributes(
12
12
  typeName: string,
13
13
  attributes: Record<string, any>,
14
14
  ): Record<string, any> {
15
- return Object.fromEntries(Object
16
- .entries(attributes)
17
- .filter(([name]) => {
15
+ return Object.fromEntries(
16
+ Object.entries(attributes).filter(([name]) => {
18
17
  const extensionAttribute = extensionAttributes.find(item => {
19
18
  return item.type === typeName && item.name === name
20
19
  })
@@ -24,5 +23,6 @@ export function getSplittedAttributes(
24
23
  }
25
24
 
26
25
  return extensionAttribute.attribute.keepOnSplit
27
- }))
26
+ }),
27
+ )
28
28
  }
@@ -1,6 +1,6 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
- import { TextSerializer } from '../types.js'
3
+ import type { TextSerializer } from '../types.js'
4
4
  import { getTextBetween } from './getTextBetween.js'
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
- import { Range, TextSerializer } from '../types.js'
3
+ import type { Range, TextSerializer } from '../types.js'
4
4
 
5
5
  /**
6
6
  * Gets the text between two positions in a Prosemirror node
@@ -1,4 +1,4 @@
1
- import { ResolvedPos } from '@tiptap/pm/model'
1
+ import type { ResolvedPos } from '@tiptap/pm/model'
2
2
 
3
3
  /**
4
4
  * Returns the text content of a resolved prosemirror position
@@ -11,22 +11,19 @@ export const getTextContentFromNodes = ($from: ResolvedPos, maxMatch = 500) => {
11
11
 
12
12
  const sliceEndPos = $from.parentOffset
13
13
 
14
- $from.parent.nodesBetween(
15
- Math.max(0, sliceEndPos - maxMatch),
16
- sliceEndPos,
17
- (node, pos, parent, index) => {
18
- const chunk = node.type.spec.toText?.({
14
+ $from.parent.nodesBetween(Math.max(0, sliceEndPos - maxMatch), sliceEndPos, (node, pos, parent, index) => {
15
+ const chunk =
16
+ node.type.spec.toText?.({
19
17
  node,
20
18
  pos,
21
19
  parent,
22
20
  index,
23
- })
24
- || node.textContent
25
- || '%leaf%'
21
+ }) ||
22
+ node.textContent ||
23
+ '%leaf%'
26
24
 
27
- textBefore += chunk.slice(0, Math.max(0, sliceEndPos - pos))
28
- },
29
- )
25
+ textBefore += node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos))
26
+ })
30
27
 
31
28
  return textBefore
32
29
  }
@@ -1,6 +1,6 @@
1
- import { Schema } from '@tiptap/pm/model'
1
+ import type { Schema } from '@tiptap/pm/model'
2
2
 
3
- import { TextSerializer } from '../types.js'
3
+ import type { TextSerializer } from '../types.js'
4
4
 
5
5
  /**
6
6
  * Find text serializers `toText` in a Prosemirror schema
@@ -7,6 +7,7 @@ export * from './findChildren.js'
7
7
  export * from './findChildrenInRange.js'
8
8
  export * from './findParentNode.js'
9
9
  export * from './findParentNodeClosestToPos.js'
10
+ export * from './flattenExtensions.js'
10
11
  export * from './generateHTML.js'
11
12
  export * from './generateJSON.js'
12
13
  export * from './generateText.js'
@@ -45,6 +46,9 @@ export * from './isNodeEmpty.js'
45
46
  export * from './isNodeSelection.js'
46
47
  export * from './isTextSelection.js'
47
48
  export * from './posToDOMRect.js'
49
+ export * from './resolveExtensions.js'
48
50
  export * from './resolveFocusPosition.js'
51
+ export * from './rewriteUnknownContent.js'
49
52
  export * from './selectionToInsertionEnd.js'
53
+ export * from './sortExtensions.js'
50
54
  export * from './splitExtensions.js'
@@ -1,6 +1,6 @@
1
- import { ParseRule } from '@tiptap/pm/model'
1
+ import type { ParseRule } from '@tiptap/pm/model'
2
2
 
3
- import { ExtensionAttribute } from '../types.js'
3
+ import type { ExtensionAttribute } from '../types.js'
4
4
  import { fromString } from '../utilities/fromString.js'
5
5
 
6
6
  /**
@@ -29,7 +29,7 @@ export function injectExtensionAttributesToParseRule(
29
29
  const newAttributes = extensionAttributes.reduce((items, item) => {
30
30
  const value = item.attribute.parseHTML
31
31
  ? item.attribute.parseHTML(node)
32
- : fromString((node).getAttribute(item.name))
32
+ : fromString(node.getAttribute(item.name))
33
33
 
34
34
  if (value === null || value === undefined) {
35
35
  return items
@@ -1,14 +1,10 @@
1
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { EditorState } from '@tiptap/pm/state'
2
2
 
3
3
  import { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'
4
4
  import { isMarkActive } from './isMarkActive.js'
5
5
  import { isNodeActive } from './isNodeActive.js'
6
6
 
7
- export function isActive(
8
- state: EditorState,
9
- name: string | null,
10
- attributes: Record<string, any> = {},
11
- ): boolean {
7
+ export function isActive(state: EditorState, name: string | null, attributes: Record<string, any> = {}): boolean {
12
8
  if (!name) {
13
9
  return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes)
14
10
  }
@@ -1,4 +1,4 @@
1
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { EditorState } from '@tiptap/pm/state'
2
2
 
3
3
  import { findParentNode } from './findParentNode.js'
4
4
 
@@ -1,4 +1,4 @@
1
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { EditorState } from '@tiptap/pm/state'
2
2
 
3
3
  export const isAtStartOfNode = (state: EditorState) => {
4
4
  const { $from, $to } = state.selection
@@ -1,11 +1,9 @@
1
- import { AnyExtension, EnableRules } from '../types.js'
1
+ import type { AnyExtension, EnableRules } from '../types.js'
2
2
 
3
3
  export function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean {
4
4
  if (Array.isArray(enabled)) {
5
5
  return enabled.some(enabledExtension => {
6
- const name = typeof enabledExtension === 'string'
7
- ? enabledExtension
8
- : enabledExtension.name
6
+ const name = typeof enabledExtension === 'string' ? enabledExtension : enabledExtension.name
9
7
 
10
8
  return name === extension.name
11
9
  })
@@ -1,6 +1,6 @@
1
1
  import { getExtensionField } from '../helpers/getExtensionField.js'
2
- import { NodeConfig } from '../index.js'
3
- import { Extensions } from '../types.js'
2
+ import type { NodeConfig } from '../index.js'
3
+ import type { Extensions } from '../types.js'
4
4
  import { callOrReturn } from '../utilities/callOrReturn.js'
5
5
  import { splitExtensions } from './splitExtensions.js'
6
6
 
@@ -1,7 +1,7 @@
1
- import { MarkType } from '@tiptap/pm/model'
2
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { MarkType } from '@tiptap/pm/model'
2
+ import type { EditorState } from '@tiptap/pm/state'
3
3
 
4
- import { MarkRange } from '../types.js'
4
+ import type { MarkRange } from '../types.js'
5
5
  import { objectIncludes } from '../utilities/objectIncludes.js'
6
6
  import { getMarkType } from './getMarkType.js'
7
7
 
@@ -1,7 +1,7 @@
1
- import { NodeType } from '@tiptap/pm/model'
2
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { NodeType } from '@tiptap/pm/model'
2
+ import type { EditorState } from '@tiptap/pm/state'
3
3
 
4
- import { NodeRange } from '../types.js'
4
+ import type { NodeRange } from '../types.js'
5
5
  import { objectIncludes } from '../utilities/objectIncludes.js'
6
6
  import { getNodeType } from './getNodeType.js'
7
7
 
@@ -1,11 +1,62 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
- export function isNodeEmpty(node: ProseMirrorNode): boolean {
4
- const defaultContent = node.type.createAndFill()
3
+ /**
4
+ * Returns true if the given prosemirror node is empty.
5
+ */
6
+ export function isNodeEmpty(
7
+ node: ProseMirrorNode,
8
+ {
9
+ checkChildren = true,
10
+ ignoreWhitespace = false,
11
+ }: {
12
+ /**
13
+ * When true (default), it will also check if all children are empty.
14
+ */
15
+ checkChildren?: boolean
16
+ /**
17
+ * When true, it will ignore whitespace when checking for emptiness.
18
+ */
19
+ ignoreWhitespace?: boolean
20
+ } = {},
21
+ ): boolean {
22
+ if (ignoreWhitespace) {
23
+ if (node.type.name === 'hardBreak') {
24
+ // Hard breaks are considered empty
25
+ return true
26
+ }
27
+ if (node.isText) {
28
+ return /^\s*$/m.test(node.text ?? '')
29
+ }
30
+ }
31
+
32
+ if (node.isText) {
33
+ return !node.text
34
+ }
5
35
 
6
- if (!defaultContent) {
36
+ if (node.isAtom || node.isLeaf) {
7
37
  return false
8
38
  }
9
39
 
10
- return node.eq(defaultContent)
40
+ if (node.content.childCount === 0) {
41
+ return true
42
+ }
43
+
44
+ if (checkChildren) {
45
+ let isContentEmpty = true
46
+
47
+ node.content.forEach(childNode => {
48
+ if (isContentEmpty === false) {
49
+ // Exit early for perf
50
+ return
51
+ }
52
+
53
+ if (!isNodeEmpty(childNode, { ignoreWhitespace, checkChildren })) {
54
+ isContentEmpty = false
55
+ }
56
+ })
57
+
58
+ return isContentEmpty
59
+ }
60
+
61
+ return false
11
62
  }
@@ -1,4 +1,4 @@
1
- import { EditorView } from '@tiptap/pm/view'
1
+ import type { EditorView } from '@tiptap/pm/view'
2
2
 
3
3
  import { minMax } from '../utilities/minMax.js'
4
4
 
@@ -0,0 +1,25 @@
1
+ import type { Extensions } from '../types.js'
2
+ import { findDuplicates } from '../utilities/findDuplicates.js'
3
+ import { flattenExtensions } from './flattenExtensions.js'
4
+ import { sortExtensions } from './sortExtensions.js'
5
+
6
+ /**
7
+ * Returns a flattened and sorted extension list while
8
+ * also checking for duplicated extensions and warns the user.
9
+ * @param extensions An array of Tiptap extensions
10
+ * @returns An flattened and sorted array of Tiptap extensions
11
+ */
12
+ export function resolveExtensions(extensions: Extensions): Extensions {
13
+ const resolvedExtensions = sortExtensions(flattenExtensions(extensions))
14
+ const duplicatedNames = findDuplicates(resolvedExtensions.map(extension => extension.name))
15
+
16
+ if (duplicatedNames.length) {
17
+ console.warn(
18
+ `[tiptap warn]: Duplicate extension names found: [${duplicatedNames
19
+ .map(item => `'${item}'`)
20
+ .join(', ')}]. This can lead to issues.`,
21
+ )
22
+ }
23
+
24
+ return resolvedExtensions
25
+ }
@@ -1,13 +1,10 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
  import { Selection, TextSelection } from '@tiptap/pm/state'
3
3
 
4
- import { FocusPosition } from '../types.js'
4
+ import type { FocusPosition } from '../types.js'
5
5
  import { minMax } from '../utilities/minMax.js'
6
6
 
7
- export function resolveFocusPosition(
8
- doc: ProseMirrorNode,
9
- position: FocusPosition = null,
10
- ): Selection | null {
7
+ export function resolveFocusPosition(doc: ProseMirrorNode, position: FocusPosition = null): Selection | null {
11
8
  if (!position) {
12
9
  return null
13
10
  }
@@ -27,16 +24,8 @@ export function resolveFocusPosition(
27
24
  const maxPos = selectionAtEnd.to
28
25
 
29
26
  if (position === 'all') {
30
- return TextSelection.create(
31
- doc,
32
- minMax(0, minPos, maxPos),
33
- minMax(doc.content.size, minPos, maxPos),
34
- )
27
+ return TextSelection.create(doc, minMax(0, minPos, maxPos), minMax(doc.content.size, minPos, maxPos))
35
28
  }
36
29
 
37
- return TextSelection.create(
38
- doc,
39
- minMax(position, minPos, maxPos),
40
- minMax(position, minPos, maxPos),
41
- )
30
+ return TextSelection.create(doc, minMax(position, minPos, maxPos), minMax(position, minPos, maxPos))
42
31
  }