@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
package/src/types.ts CHANGED
@@ -1,21 +1,26 @@
1
- import {
2
- Mark as ProseMirrorMark, Node as ProseMirrorNode, NodeType, ParseOptions,
3
- } from '@tiptap/pm/model'
4
- import { EditorState, Transaction } from '@tiptap/pm/state'
5
- import {
6
- Decoration, EditorProps, EditorView, NodeView,
1
+ import type { Mark as ProseMirrorMark, Node as ProseMirrorNode, ParseOptions, Slice } from '@tiptap/pm/model'
2
+ import type { EditorState, Transaction } from '@tiptap/pm/state'
3
+ import type { Mappable, Transform } from '@tiptap/pm/transform'
4
+ import type {
5
+ Decoration,
6
+ DecorationAttrs,
7
+ EditorProps,
8
+ EditorView,
9
+ MarkView,
10
+ MarkViewConstructor,
11
+ NodeView,
12
+ NodeViewConstructor,
13
+ ViewMutationRecord,
7
14
  } from '@tiptap/pm/view'
8
15
 
9
- import { Editor } from './Editor.js'
10
- import { Extension } from './Extension.js'
11
- import {
12
- Commands, ExtensionConfig, MarkConfig, NodeConfig,
13
- } from './index.js'
14
- import { Mark } from './Mark.js'
15
- import { Node } from './Node.js'
16
+ import type { Editor } from './Editor.js'
17
+ import type { Extendable } from './Extendable.js'
18
+ import type { Commands, ExtensionConfig, MarkConfig, NodeConfig } from './index.js'
19
+ import type { Mark } from './Mark.js'
20
+ import type { Node } from './Node.js'
16
21
 
17
22
  export type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig
18
- export type AnyExtension = Extension | Node | Mark
23
+ export type AnyExtension = Extendable
19
24
  export type Extensions = AnyExtension[]
20
25
 
21
26
  export type ParentConfig<T> = Partial<{
@@ -26,57 +31,322 @@ export type ParentConfig<T> = Partial<{
26
31
 
27
32
  export type Primitive = null | undefined | string | number | boolean | symbol | bigint
28
33
 
29
- export type RemoveThis<T> = T extends (...args: any) => any
30
- ? (...args: Parameters<T>) => ReturnType<T>
31
- : T
34
+ export type RemoveThis<T> = T extends (...args: any) => any ? (...args: Parameters<T>) => ReturnType<T> : T
32
35
 
33
36
  export type MaybeReturnType<T> = T extends (...args: any) => any ? ReturnType<T> : T
34
37
 
35
- export type MaybeThisParameterType<T> = Exclude<T, Primitive> extends (...args: any) => any
36
- ? ThisParameterType<Exclude<T, Primitive>>
37
- : any
38
+ export type MaybeThisParameterType<T> =
39
+ Exclude<T, Primitive> extends (...args: any) => any ? ThisParameterType<Exclude<T, Primitive>> : any
38
40
 
39
41
  export interface EditorEvents {
40
- beforeCreate: { editor: Editor }
41
- create: { editor: Editor }
42
+ beforeCreate: {
43
+ /**
44
+ * The editor instance
45
+ */
46
+ editor: Editor
47
+ }
48
+ create: {
49
+ /**
50
+ * The editor instance
51
+ */
52
+ editor: Editor
53
+ }
42
54
  contentError: {
43
- editor: Editor,
44
- error: Error,
55
+ /**
56
+ * The editor instance
57
+ */
58
+ editor: Editor
59
+ /**
60
+ * The error that occurred while parsing the content
61
+ */
62
+ error: Error
45
63
  /**
46
64
  * If called, will re-initialize the editor with the collaboration extension removed.
47
65
  * This will prevent syncing back deletions of content not present in the current schema.
48
66
  */
49
67
  disableCollaboration: () => void
50
68
  }
51
- update: { editor: Editor; transaction: Transaction }
52
- selectionUpdate: { editor: Editor; transaction: Transaction }
53
- beforeTransaction: { editor: Editor; transaction: Transaction, nextState: EditorState }
54
- transaction: { editor: Editor; transaction: Transaction }
55
- focus: { editor: Editor; event: FocusEvent; transaction: Transaction }
56
- blur: { editor: Editor; event: FocusEvent; transaction: Transaction }
69
+ update: {
70
+ /**
71
+ * The editor instance
72
+ */
73
+ editor: Editor
74
+ /**
75
+ * The transaction that caused the update
76
+ */
77
+ transaction: Transaction
78
+ /**
79
+ * Appended transactions that were added to the initial transaction by plugins
80
+ */
81
+ appendedTransactions: Transaction[]
82
+ }
83
+ selectionUpdate: {
84
+ /**
85
+ * The editor instance
86
+ */
87
+ editor: Editor
88
+ /**
89
+ * The transaction that caused the selection update
90
+ */
91
+ transaction: Transaction
92
+ }
93
+ beforeTransaction: {
94
+ /**
95
+ * The editor instance
96
+ */
97
+ editor: Editor
98
+ /**
99
+ * The transaction that will be applied
100
+ */
101
+ transaction: Transaction
102
+ /**
103
+ * The next state of the editor after the transaction is applied
104
+ */
105
+ nextState: EditorState
106
+ }
107
+ transaction: {
108
+ /**
109
+ * The editor instance
110
+ */
111
+ editor: Editor
112
+ /**
113
+ * The initial transaction
114
+ */
115
+ transaction: Transaction
116
+ /**
117
+ * Appended transactions that were added to the initial transaction by plugins
118
+ */
119
+ appendedTransactions: Transaction[]
120
+ }
121
+ focus: {
122
+ /**
123
+ * The editor instance
124
+ */
125
+ editor: Editor
126
+ /**
127
+ * The focus event
128
+ */
129
+ event: FocusEvent
130
+ /**
131
+ * The transaction that caused the focus
132
+ */
133
+ transaction: Transaction
134
+ }
135
+ blur: {
136
+ /**
137
+ * The editor instance
138
+ */
139
+ editor: Editor
140
+ /**
141
+ * The focus event
142
+ */
143
+ event: FocusEvent
144
+ /**
145
+ * The transaction that caused the blur
146
+ */
147
+ transaction: Transaction
148
+ }
57
149
  destroy: void
150
+ paste: {
151
+ /**
152
+ * The editor instance
153
+ */
154
+ editor: Editor
155
+ /**
156
+ * The clipboard event
157
+ */
158
+ event: ClipboardEvent
159
+ /**
160
+ * The slice that was pasted
161
+ */
162
+ slice: Slice
163
+ }
164
+ drop: {
165
+ /**
166
+ * The editor instance
167
+ */
168
+ editor: Editor
169
+ /**
170
+ * The drag event
171
+ */
172
+ event: DragEvent
173
+ /**
174
+ * The slice that was dropped
175
+ */
176
+ slice: Slice
177
+ /**
178
+ * Whether the content was moved (true) or copied (false)
179
+ */
180
+ moved: boolean
181
+ }
182
+ delete: {
183
+ /**
184
+ * The editor instance
185
+ */
186
+ editor: Editor
187
+ /**
188
+ * The range of the deleted content (before the deletion)
189
+ */
190
+ deletedRange: Range
191
+ /**
192
+ * The new range of positions of where the deleted content was in the new document (after the deletion)
193
+ */
194
+ newRange: Range
195
+ /**
196
+ * The transaction that caused the deletion
197
+ */
198
+ transaction: Transaction
199
+ /**
200
+ * The combined transform (including all appended transactions) that caused the deletion
201
+ */
202
+ combinedTransform: Transform
203
+ /**
204
+ * Whether the deletion was partial (only a part of this content was deleted)
205
+ */
206
+ partial: boolean
207
+ /**
208
+ * This is the start position of the mark in the document (before the deletion)
209
+ */
210
+ from: number
211
+ /**
212
+ * This is the end position of the mark in the document (before the deletion)
213
+ */
214
+ to: number
215
+ } & (
216
+ | {
217
+ /**
218
+ * The content that was deleted
219
+ */
220
+ type: 'node'
221
+ /**
222
+ * The node which the deletion occurred in
223
+ * @note This can be a parent node of the deleted content
224
+ */
225
+ node: ProseMirrorNode
226
+ /**
227
+ * The new start position of the node in the document (after the deletion)
228
+ */
229
+ newFrom: number
230
+ /**
231
+ * The new end position of the node in the document (after the deletion)
232
+ */
233
+ newTo: number
234
+ }
235
+ | {
236
+ /**
237
+ * The content that was deleted
238
+ */
239
+ type: 'mark'
240
+ /**
241
+ * The mark that was deleted
242
+ */
243
+ mark: ProseMirrorMark
244
+ }
245
+ )
58
246
  }
59
247
 
60
248
  export type EnableRules = (AnyExtension | string)[] | boolean
61
249
 
62
250
  export interface EditorOptions {
63
- element: Element
251
+ /**
252
+ * The element or selector to bind the editor to
253
+ * If `null` is passed, the editor will not be mounted automatically
254
+ * If a function is passed, it will be called with the editor's root element
255
+ */
256
+ element: Element | null
257
+ /**
258
+ * The content of the editor (HTML, JSON, or a JSON array)
259
+ */
64
260
  content: Content
261
+ /**
262
+ * The extensions to use
263
+ */
65
264
  extensions: Extensions
265
+ /**
266
+ * Whether to inject base CSS styles
267
+ */
66
268
  injectCSS: boolean
269
+ /**
270
+ * A nonce to use for CSP while injecting styles
271
+ */
67
272
  injectNonce: string | undefined
273
+ /**
274
+ * The editor's initial focus position
275
+ */
68
276
  autofocus: FocusPosition
277
+ /**
278
+ * Whether the editor is editable
279
+ */
69
280
  editable: boolean
281
+ /**
282
+ * The editor's props
283
+ */
70
284
  editorProps: EditorProps
285
+ /**
286
+ * The editor's content parser options
287
+ */
71
288
  parseOptions: ParseOptions
289
+ /**
290
+ * The editor's core extension options
291
+ */
72
292
  coreExtensionOptions?: {
73
293
  clipboardTextSerializer?: {
74
294
  blockSeparator?: string
75
295
  }
296
+ delete?: {
297
+ /**
298
+ * Whether the `delete` extension should be called asynchronously to avoid blocking the editor while processing deletions
299
+ * @default true deletion events are called asynchronously
300
+ */
301
+ async?: boolean
302
+ /**
303
+ * Allows filtering the transactions that are processed by the `delete` extension.
304
+ * If the function returns `true`, the transaction will be ignored.
305
+ */
306
+ filterTransaction?: (transaction: Transaction) => boolean
307
+ }
76
308
  }
309
+ /**
310
+ * Whether to enable input rules behavior
311
+ */
77
312
  enableInputRules: EnableRules
313
+ /**
314
+ * Whether to enable paste rules behavior
315
+ */
78
316
  enablePasteRules: EnableRules
79
- enableCoreExtensions: boolean
317
+ /**
318
+ * Determines whether core extensions are enabled.
319
+ *
320
+ * If set to `false`, all core extensions will be disabled.
321
+ * To disable specific core extensions, provide an object where the keys are the extension names and the values are `false`.
322
+ * Extensions not listed in the object will remain enabled.
323
+ *
324
+ * @example
325
+ * // Disable all core extensions
326
+ * enabledCoreExtensions: false
327
+ *
328
+ * @example
329
+ * // Disable only the keymap core extension
330
+ * enabledCoreExtensions: { keymap: false }
331
+ *
332
+ * @default true
333
+ */
334
+ enableCoreExtensions?:
335
+ | boolean
336
+ | Partial<
337
+ Record<
338
+ | 'editable'
339
+ | 'clipboardTextSerializer'
340
+ | 'commands'
341
+ | 'focusEvents'
342
+ | 'keymap'
343
+ | 'tabindex'
344
+ | 'drop'
345
+ | 'paste'
346
+ | 'delete',
347
+ false
348
+ >
349
+ >
80
350
  /**
81
351
  * If `true`, the editor will check the content for errors on initialization.
82
352
  * Emitting the `contentError` event if the content is invalid.
@@ -84,23 +354,74 @@ export interface EditorOptions {
84
354
  * @default false
85
355
  */
86
356
  enableContentCheck: boolean
357
+ /**
358
+ * If `true`, the editor will emit the `contentError` event if invalid content is
359
+ * encountered but `enableContentCheck` is `false`. This lets you preserve the
360
+ * invalid editor content while still showing a warning or error message to
361
+ * the user.
362
+ *
363
+ * @default false
364
+ */
365
+ emitContentError: boolean
366
+ /**
367
+ * Called before the editor is constructed.
368
+ */
87
369
  onBeforeCreate: (props: EditorEvents['beforeCreate']) => void
370
+ /**
371
+ * Called after the editor is constructed.
372
+ */
88
373
  onCreate: (props: EditorEvents['create']) => void
89
374
  /**
90
375
  * Called when the editor encounters an error while parsing the content.
91
376
  * Only enabled if `enableContentCheck` is `true`.
92
377
  */
93
378
  onContentError: (props: EditorEvents['contentError']) => void
379
+ /**
380
+ * Called when the editor's content is updated.
381
+ */
94
382
  onUpdate: (props: EditorEvents['update']) => void
383
+ /**
384
+ * Called when the editor's selection is updated.
385
+ */
95
386
  onSelectionUpdate: (props: EditorEvents['selectionUpdate']) => void
387
+ /**
388
+ * Called after a transaction is applied to the editor.
389
+ */
96
390
  onTransaction: (props: EditorEvents['transaction']) => void
391
+ /**
392
+ * Called on focus events.
393
+ */
97
394
  onFocus: (props: EditorEvents['focus']) => void
395
+ /**
396
+ * Called on blur events.
397
+ */
98
398
  onBlur: (props: EditorEvents['blur']) => void
399
+ /**
400
+ * Called when the editor is destroyed.
401
+ */
99
402
  onDestroy: (props: EditorEvents['destroy']) => void
403
+ /**
404
+ * Called when content is pasted into the editor.
405
+ */
406
+ onPaste: (e: ClipboardEvent, slice: Slice) => void
407
+ /**
408
+ * Called when content is dropped into the editor.
409
+ */
410
+ onDrop: (e: DragEvent, slice: Slice, moved: boolean) => void
411
+ /**
412
+ * Called when content is deleted from the editor.
413
+ */
414
+ onDelete: (props: EditorEvents['delete']) => void
100
415
  }
101
416
 
417
+ /**
418
+ * The editor's content as HTML
419
+ */
102
420
  export type HTMLContent = string
103
421
 
422
+ /**
423
+ * Loosely describes a JSON representation of a Prosemirror document or node
424
+ */
104
425
  export type JSONContent = {
105
426
  type?: string
106
427
  attrs?: Record<string, any>
@@ -114,6 +435,61 @@ export type JSONContent = {
114
435
  [key: string]: any
115
436
  }
116
437
 
438
+ /**
439
+ * A mark type is either a JSON representation of a mark or a Prosemirror mark instance
440
+ */
441
+ export type MarkType<
442
+ Type extends string | { name: string } = any,
443
+ TAttributes extends undefined | Record<string, any> = any,
444
+ > = {
445
+ type: Type
446
+ attrs: TAttributes
447
+ }
448
+
449
+ /**
450
+ * A node type is either a JSON representation of a node or a Prosemirror node instance
451
+ */
452
+ export type NodeType<
453
+ Type extends string | { name: string } = any,
454
+ TAttributes extends undefined | Record<string, any> = any,
455
+ NodeMarkType extends MarkType = any,
456
+ TContent extends (NodeType | TextType)[] = any,
457
+ > = {
458
+ type: Type
459
+ attrs: TAttributes
460
+ content?: TContent
461
+ marks?: NodeMarkType[]
462
+ }
463
+
464
+ /**
465
+ * A node type is either a JSON representation of a doc node or a Prosemirror doc node instance
466
+ */
467
+ export type DocumentType<
468
+ TDocAttributes extends Record<string, any> | undefined = Record<string, any>,
469
+ TContentType extends NodeType[] = NodeType[],
470
+ > = Omit<NodeType<'doc', TDocAttributes, never, TContentType>, 'marks' | 'content'> & { content: TContentType }
471
+
472
+ /**
473
+ * A node type is either a JSON representation of a text node or a Prosemirror text node instance
474
+ */
475
+ export type TextType<TMarkType extends MarkType = MarkType> = {
476
+ type: 'text'
477
+ text: string
478
+ marks: TMarkType[]
479
+ }
480
+
481
+ /**
482
+ * Describes the output of a `renderHTML` function in prosemirror
483
+ * @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec
484
+ */
485
+ export type DOMOutputSpecArray =
486
+ | [string]
487
+ | [string, Record<string, any>]
488
+ | [string, 0]
489
+ | [string, Record<string, any>, 0]
490
+ | [string, Record<string, any>, DOMOutputSpecArray | 0]
491
+ | [string, DOMOutputSpecArray]
492
+
117
493
  export type Content = HTMLContent | JSONContent | JSONContent[] | null
118
494
 
119
495
  export type CommandProps = {
@@ -135,6 +511,7 @@ export type KeyboardShortcutCommand = (props: { editor: Editor }) => boolean
135
511
 
136
512
  export type Attribute = {
137
513
  default?: any
514
+ validate?: string | ((value: any) => void)
138
515
  rendered?: boolean
139
516
  renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null
140
517
  parseHTML?: ((element: HTMLElement) => any | null) | null
@@ -149,7 +526,7 @@ export type Attributes = {
149
526
  export type ExtensionAttribute = {
150
527
  type: string
151
528
  name: string
152
- attribute: Required<Attribute>
529
+ attribute: Required<Omit<Attribute, 'validate'>> & Pick<Attribute, 'validate'>
153
530
  }
154
531
 
155
532
  export type GlobalAttributes = {
@@ -160,18 +537,12 @@ export type GlobalAttributes = {
160
537
  /**
161
538
  * The attributes to add to the node or mark types.
162
539
  */
163
- attributes: {
164
- [key: string]: Attribute
165
- }
540
+ attributes: Record<string, Attribute | undefined>
166
541
  }[]
167
542
 
168
543
  export type PickValue<T, K extends keyof T> = T[K]
169
544
 
170
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
171
- k: infer I,
172
- ) => void
173
- ? I
174
- : never
545
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never
175
546
 
176
547
  export type Diff<T extends keyof any, U extends keyof any> = ({ [P in T]: P } & {
177
548
  [P in U]: never
@@ -183,44 +554,128 @@ export type ValuesOf<T> = T[keyof T]
183
554
 
184
555
  export type KeysWithTypeOf<T, Type> = { [P in keyof T]: T[P] extends Type ? P : never }[keyof T]
185
556
 
557
+ export type DOMNode = InstanceType<typeof window.Node>
558
+
559
+ /**
560
+ * prosemirror-view does not export the `type` property of `Decoration`.
561
+ * So, this defines the `DecorationType` interface to include the `type` property.
562
+ */
563
+ export interface DecorationType {
564
+ spec: any
565
+ map(mapping: Mappable, span: Decoration, offset: number, oldOffset: number): Decoration | null
566
+ valid(node: Node, span: Decoration): boolean
567
+ eq(other: DecorationType): boolean
568
+ destroy(dom: DOMNode): void
569
+ readonly attrs: DecorationAttrs
570
+ }
571
+
572
+ /**
573
+ * prosemirror-view does not export the `type` property of `Decoration`.
574
+ * This adds the `type` property to the `Decoration` type.
575
+ */
186
576
  export type DecorationWithType = Decoration & {
187
- type: NodeType
577
+ type: DecorationType
188
578
  }
189
579
 
190
- export type NodeViewProps = {
191
- editor: Editor
192
- node: ProseMirrorNode
193
- decorations: DecorationWithType[]
580
+ export interface NodeViewProps extends NodeViewRendererProps {
581
+ // TODO this type is not technically correct, but it's the best we can do for now since prosemirror doesn't expose the type of decorations
582
+ decorations: readonly DecorationWithType[]
194
583
  selected: boolean
195
- extension: Node
196
- getPos: () => number
197
584
  updateAttributes: (attributes: Record<string, any>) => void
198
585
  deleteNode: () => void
199
586
  }
200
587
 
201
588
  export interface NodeViewRendererOptions {
202
589
  stopEvent: ((props: { event: Event }) => boolean) | null
203
- ignoreMutation:
204
- | ((props: { mutation: MutationRecord | { type: 'selection'; target: Element } }) => boolean)
205
- | null
590
+ ignoreMutation: ((props: { mutation: ViewMutationRecord }) => boolean) | null
206
591
  contentDOMElementTag: string
207
592
  }
208
593
 
209
- export type NodeViewRendererProps = {
594
+ export interface NodeViewRendererProps {
595
+ // pass-through from prosemirror
596
+ /**
597
+ * The node that is being rendered.
598
+ */
599
+ node: Parameters<NodeViewConstructor>[0]
600
+ /**
601
+ * The editor's view.
602
+ */
603
+ view: Parameters<NodeViewConstructor>[1]
604
+ /**
605
+ * A function that can be called to get the node's current position in the document.
606
+ */
607
+ getPos: Parameters<NodeViewConstructor>[2]
608
+ /**
609
+ * is an array of node or inline decorations that are active around the node.
610
+ * They are automatically drawn in the normal way, and you will usually just want to ignore this, but they can also be used as a way to provide context information to the node view without adding it to the document itself.
611
+ */
612
+ decorations: Parameters<NodeViewConstructor>[3]
613
+ /**
614
+ * holds the decorations for the node's content. You can safely ignore this if your view has no content or a contentDOM property, since the editor will draw the decorations on the content.
615
+ * But if you, for example, want to create a nested editor with the content, it may make sense to provide it with the inner decorations.
616
+ */
617
+ innerDecorations: Parameters<NodeViewConstructor>[4]
618
+ // tiptap-specific
619
+ /**
620
+ * The editor instance.
621
+ */
210
622
  editor: Editor
211
- node: ProseMirrorNode
212
- getPos: (() => number) | boolean
213
- HTMLAttributes: Record<string, any>
214
- decorations: Decoration[]
623
+ /**
624
+ * The extension that is responsible for the node.
625
+ */
215
626
  extension: Node
627
+ /**
628
+ * The HTML attributes that should be added to the node's DOM element.
629
+ */
630
+ HTMLAttributes: Record<string, any>
216
631
  }
217
632
 
218
- export type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView | {}
633
+ export type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView
634
+
635
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
636
+ export interface MarkViewProps extends MarkViewRendererProps {}
637
+
638
+ export interface MarkViewRendererProps {
639
+ // pass-through from prosemirror
640
+ /**
641
+ * The node that is being rendered.
642
+ */
643
+ mark: Parameters<MarkViewConstructor>[0]
644
+ /**
645
+ * The editor's view.
646
+ */
647
+ view: Parameters<MarkViewConstructor>[1]
648
+ /**
649
+ * indicates whether the mark's content is inline
650
+ */
651
+ inline: Parameters<MarkViewConstructor>[2]
652
+ // tiptap-specific
653
+ /**
654
+ * The editor instance.
655
+ */
656
+ editor: Editor
657
+ /**
658
+ * The extension that is responsible for the mark.
659
+ */
660
+ extension: Mark
661
+ /**
662
+ * The HTML attributes that should be added to the mark's DOM element.
663
+ */
664
+ HTMLAttributes: Record<string, any>
665
+
666
+ updateAttributes: (attrs: Record<string, any>) => void
667
+ }
668
+
669
+ export type MarkViewRenderer<Props = MarkViewRendererProps> = (props: Props) => MarkView
670
+
671
+ export interface MarkViewRendererOptions {
672
+ ignoreMutation: ((props: { mutation: ViewMutationRecord }) => boolean) | null
673
+ }
219
674
 
220
675
  export type AnyCommands = Record<string, (...args: any[]) => Command>
221
676
 
222
677
  export type UnionCommands<T = Command> = UnionToIntersection<
223
- ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, {}>>>
678
+ ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, object>>>
224
679
  >
225
680
 
226
681
  export type RawCommands = {
@@ -1,4 +1,4 @@
1
- import { MaybeReturnType } from '../types.js'
1
+ import type { MaybeReturnType } from '../types.js'
2
2
  import { isFunction } from './isFunction.js'
3
3
 
4
4
  /**