@blade-hq/agent-react 2612.0.0-beta.115 → 2612.0.0-beta.117

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 (751) hide show
  1. package/dist/{chunk-AMWLYUD7.js → chunk-34YJQXTM.js} +2 -2
  2. package/dist/{chunk-N2SQZ2HY.js → chunk-63G66FWM.js} +5 -1
  3. package/dist/{chunk-HV3NKRZ2.js → chunk-7DG4JFRS.js} +3 -3
  4. package/dist/{chunk-7UQ3RWAU.js → chunk-DNND32V4.js} +4 -4
  5. package/dist/{chunk-C3G6F7UG.js → chunk-LFC3UTIJ.js} +5 -5
  6. package/dist/{chunk-22JUW3EQ.js → chunk-NPDS3EEK.js} +2 -2
  7. package/dist/{chunk-GZWQVVE7.js → chunk-VUUX2BIU.js} +2818 -2341
  8. package/dist/chunk-VUUX2BIU.js.map +1 -0
  9. package/dist/{chunk-XRNHTA7C.js → chunk-XCASYOA6.js} +3 -3
  10. package/dist/connectors.js +2 -2
  11. package/dist/index.js +7 -7
  12. package/dist/internal.js +8 -8
  13. package/dist/questions.js +3 -3
  14. package/dist/rich-input.js +7023 -6787
  15. package/dist/rich-input.js.map +1 -1
  16. package/dist/tool-details.js +4 -4
  17. package/node_modules/@tiptap/core/dist/index.cjs +7679 -6763
  18. package/node_modules/@tiptap/core/dist/index.cjs.map +1 -1
  19. package/node_modules/@tiptap/core/dist/index.d.cts +4468 -3614
  20. package/node_modules/@tiptap/core/dist/index.d.cts.map +1 -0
  21. package/node_modules/@tiptap/core/dist/index.d.ts +4467 -3614
  22. package/node_modules/@tiptap/core/dist/index.d.ts.map +1 -0
  23. package/node_modules/@tiptap/core/dist/index.js +7508 -6632
  24. package/node_modules/@tiptap/core/dist/index.js.map +1 -1
  25. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.cjs +66 -52
  26. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.cjs.map +1 -1
  27. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.cts +17 -12
  28. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.cts.map +1 -0
  29. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.ts +17 -12
  30. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.d.ts.map +1 -0
  31. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +60 -22
  32. package/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js.map +1 -1
  33. package/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  34. package/node_modules/@tiptap/core/package.json +27 -24
  35. package/node_modules/@tiptap/core/src/CommandManager.ts +72 -2
  36. package/node_modules/@tiptap/core/src/Editor.ts +108 -26
  37. package/node_modules/@tiptap/core/src/EventEmitter.ts +20 -7
  38. package/node_modules/@tiptap/core/src/Extendable.ts +52 -7
  39. package/node_modules/@tiptap/core/src/Extension.ts +7 -3
  40. package/node_modules/@tiptap/core/src/ExtensionManager.ts +158 -15
  41. package/node_modules/@tiptap/core/src/InputRule.ts +30 -3
  42. package/node_modules/@tiptap/core/src/Mark.ts +26 -6
  43. package/node_modules/@tiptap/core/src/MarkView.ts +13 -3
  44. package/node_modules/@tiptap/core/src/Node.ts +19 -6
  45. package/node_modules/@tiptap/core/src/NodePos.ts +17 -4
  46. package/node_modules/@tiptap/core/src/NodeView.ts +31 -9
  47. package/node_modules/@tiptap/core/src/PasteRule.ts +17 -4
  48. package/node_modules/@tiptap/core/src/Tracker.ts +9 -7
  49. package/node_modules/@tiptap/core/src/__tests__/Editor.spec.ts +73 -0
  50. package/node_modules/@tiptap/core/src/__tests__/htmlEntities.test.ts +55 -0
  51. package/node_modules/@tiptap/core/src/__tests__/inputRuleInlineAtoms.test.ts +111 -0
  52. package/node_modules/@tiptap/core/src/__tests__/isAndroid.test.ts +28 -0
  53. package/node_modules/@tiptap/core/src/__tests__/rewriteUnknownContent.test.ts +51 -0
  54. package/node_modules/@tiptap/core/src/__tests__/transformPastedHTML.test.ts +10 -4
  55. package/node_modules/@tiptap/core/src/commands/deleteSelection.ts +90 -2
  56. package/node_modules/@tiptap/core/src/commands/extendMarkRange.ts +3 -2
  57. package/node_modules/@tiptap/core/src/commands/index.ts +2 -0
  58. package/node_modules/@tiptap/core/src/commands/insertContent.ts +5 -1
  59. package/node_modules/@tiptap/core/src/commands/insertContentAt.ts +17 -21
  60. package/node_modules/@tiptap/core/src/commands/insertDefaultBlock.ts +97 -0
  61. package/node_modules/@tiptap/core/src/commands/resetAttributes.ts +9 -2
  62. package/node_modules/@tiptap/core/src/commands/setContent.ts +4 -1
  63. package/node_modules/@tiptap/core/src/commands/setMark.ts +7 -3
  64. package/node_modules/@tiptap/core/src/commands/setTextSelection.ts +2 -1
  65. package/node_modules/@tiptap/core/src/commands/splitBlock.ts +16 -4
  66. package/node_modules/@tiptap/core/src/commands/splitListItem.ts +14 -6
  67. package/node_modules/@tiptap/core/src/commands/toggleList.ts +106 -7
  68. package/node_modules/@tiptap/core/src/commands/undoInputRule.ts +1 -1
  69. package/node_modules/@tiptap/core/src/commands/unsetAllMarks.ts +17 -5
  70. package/node_modules/@tiptap/core/src/commands/updateDecorations.ts +28 -0
  71. package/node_modules/@tiptap/core/src/decorations/Decoration.ts +177 -0
  72. package/node_modules/@tiptap/core/src/decorations/DecorationManager.ts +440 -0
  73. package/node_modules/@tiptap/core/src/decorations/__tests__/DecorationManager.test.ts +821 -0
  74. package/node_modules/@tiptap/core/src/decorations/constants.ts +7 -0
  75. package/node_modules/@tiptap/core/src/decorations/createWidgetDecoration.ts +221 -0
  76. package/node_modules/@tiptap/core/src/decorations/decorationApplyScope.ts +45 -0
  77. package/node_modules/@tiptap/core/src/decorations/helpers/__tests__/getRebuildRanges.test.ts +147 -0
  78. package/node_modules/@tiptap/core/src/decorations/helpers/buildDecorationSet.ts +25 -0
  79. package/node_modules/@tiptap/core/src/decorations/helpers/decorationsToPMDecorations.ts +36 -0
  80. package/node_modules/@tiptap/core/src/decorations/helpers/filterOutOfRangeDecorations.ts +52 -0
  81. package/node_modules/@tiptap/core/src/decorations/helpers/findDuplicateWidgetKeys.ts +37 -0
  82. package/node_modules/@tiptap/core/src/decorations/helpers/getRebuildRanges.ts +96 -0
  83. package/node_modules/@tiptap/core/src/decorations/helpers/hasResolvableChangedRange.ts +24 -0
  84. package/node_modules/@tiptap/core/src/decorations/helpers/isAttrStep.ts +21 -0
  85. package/node_modules/@tiptap/core/src/decorations/helpers/mapDecorationSet.ts +31 -0
  86. package/node_modules/@tiptap/core/src/decorations/helpers/mapDecorations.ts +26 -0
  87. package/node_modules/@tiptap/core/src/decorations/helpers/mergeDecorationSets.ts +16 -0
  88. package/node_modules/@tiptap/core/src/decorations/helpers/rangeOwnsPosition.ts +38 -0
  89. package/node_modules/@tiptap/core/src/decorations/helpers/shouldRecomputeDecoration.ts +24 -0
  90. package/node_modules/@tiptap/core/src/decorations/helpers/unionWidgetKeys.ts +15 -0
  91. package/node_modules/@tiptap/core/src/decorations/helpers/validateDecorationSpec.ts +49 -0
  92. package/node_modules/@tiptap/core/src/decorations/helpers/widgetKeyOf.ts +11 -0
  93. package/node_modules/@tiptap/core/src/decorations/index.ts +28 -0
  94. package/node_modules/@tiptap/core/src/decorations/types.ts +87 -0
  95. package/node_modules/@tiptap/core/src/extensions/clipboardTextSerializer.ts +17 -8
  96. package/node_modules/@tiptap/core/src/extensions/delete.ts +33 -21
  97. package/node_modules/@tiptap/core/src/extensions/focusEvents.ts +6 -2
  98. package/node_modules/@tiptap/core/src/extensions/keymap.ts +8 -3
  99. package/node_modules/@tiptap/core/src/extensions/tabindex.ts +42 -2
  100. package/node_modules/@tiptap/core/src/extensions/textDirection.ts +3 -1
  101. package/node_modules/@tiptap/core/src/helpers/MappablePosition.ts +4 -1
  102. package/node_modules/@tiptap/core/src/helpers/__tests__/getChangedRanges.test.ts +48 -0
  103. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorAddMarkStep.test.ts +19 -0
  104. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorAddNodeMarkStep.test.ts +19 -0
  105. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorAttrStep.test.ts +17 -0
  106. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorCellSelection.test.ts +17 -0
  107. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorDocAttrStep.test.ts +17 -0
  108. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorFragment.test.ts +27 -0
  109. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorNodeSelection.test.ts +35 -0
  110. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorRemoveMarkStep.test.ts +19 -0
  111. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorRemoveNodeMarkStep.test.ts +19 -0
  112. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorReplaceAroundStep.test.ts +19 -0
  113. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorReplaceStep.test.ts +17 -0
  114. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorSlice.test.ts +16 -0
  115. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorStep.test.ts +30 -0
  116. package/node_modules/@tiptap/core/src/helpers/__tests__/isProseMirrorStepResult.test.ts +17 -0
  117. package/node_modules/@tiptap/core/src/helpers/combineTransactionSteps.ts +4 -1
  118. package/node_modules/@tiptap/core/src/helpers/createChainableState.ts +4 -1
  119. package/node_modules/@tiptap/core/src/helpers/createNodeFromContent.ts +15 -6
  120. package/node_modules/@tiptap/core/src/helpers/findChildrenInRange.ts +5 -1
  121. package/node_modules/@tiptap/core/src/helpers/flattenExtensions.ts +5 -1
  122. package/node_modules/@tiptap/core/src/helpers/getAttributes.ts +4 -1
  123. package/node_modules/@tiptap/core/src/helpers/getAttributesFromExtensions.ts +3 -5
  124. package/node_modules/@tiptap/core/src/helpers/getMarkAttributes.ts +4 -1
  125. package/node_modules/@tiptap/core/src/helpers/getMarkRange.ts +20 -5
  126. package/node_modules/@tiptap/core/src/helpers/getMarkType.ts +3 -1
  127. package/node_modules/@tiptap/core/src/helpers/getNodeAtPosition.ts +6 -1
  128. package/node_modules/@tiptap/core/src/helpers/getNodeAttributes.ts +4 -1
  129. package/node_modules/@tiptap/core/src/helpers/getNodeType.ts +3 -1
  130. package/node_modules/@tiptap/core/src/helpers/getPreviousBlockSibling.ts +36 -0
  131. package/node_modules/@tiptap/core/src/helpers/getSchemaByResolvedExtensions.ts +73 -20
  132. package/node_modules/@tiptap/core/src/helpers/getTextBetween.ts +1 -1
  133. package/node_modules/@tiptap/core/src/helpers/getTextContentFromNodes.ts +17 -12
  134. package/node_modules/@tiptap/core/src/helpers/index.ts +16 -0
  135. package/node_modules/@tiptap/core/src/helpers/isActive.ts +5 -1
  136. package/node_modules/@tiptap/core/src/helpers/isFragment.ts +14 -0
  137. package/node_modules/@tiptap/core/src/helpers/isNodeViewSelected.ts +42 -0
  138. package/node_modules/@tiptap/core/src/helpers/isProseMirrorAddMarkStep.ts +31 -0
  139. package/node_modules/@tiptap/core/src/helpers/isProseMirrorAddNodeMarkStep.ts +31 -0
  140. package/node_modules/@tiptap/core/src/helpers/isProseMirrorAttrStep.ts +31 -0
  141. package/node_modules/@tiptap/core/src/helpers/isProseMirrorCellSelection.ts +18 -0
  142. package/node_modules/@tiptap/core/src/helpers/isProseMirrorContent.ts +14 -0
  143. package/node_modules/@tiptap/core/src/helpers/isProseMirrorDocAttrStep.ts +31 -0
  144. package/node_modules/@tiptap/core/src/helpers/isProseMirrorFragment.ts +34 -0
  145. package/node_modules/@tiptap/core/src/helpers/isProseMirrorNodeSelection.ts +18 -0
  146. package/node_modules/@tiptap/core/src/helpers/isProseMirrorRemoveMarkStep.ts +31 -0
  147. package/node_modules/@tiptap/core/src/helpers/isProseMirrorRemoveNodeMarkStep.ts +31 -0
  148. package/node_modules/@tiptap/core/src/helpers/isProseMirrorReplaceAroundStep.ts +31 -0
  149. package/node_modules/@tiptap/core/src/helpers/isProseMirrorReplaceStep.ts +31 -0
  150. package/node_modules/@tiptap/core/src/helpers/isProseMirrorSlice.ts +43 -0
  151. package/node_modules/@tiptap/core/src/helpers/isProseMirrorStep.ts +30 -0
  152. package/node_modules/@tiptap/core/src/helpers/isProseMirrorStepResult.ts +26 -0
  153. package/node_modules/@tiptap/core/src/helpers/resolveFocusPosition.ts +14 -3
  154. package/node_modules/@tiptap/core/src/helpers/rewriteUnknownContent.ts +19 -10
  155. package/node_modules/@tiptap/core/src/helpers/splitExtensions.ts +3 -1
  156. package/node_modules/@tiptap/core/src/helpers/warnOnDuplicatedProseMirrorModel.ts +40 -0
  157. package/node_modules/@tiptap/core/src/index.ts +1 -6
  158. package/node_modules/@tiptap/core/src/inputRules/markInputRule.ts +5 -1
  159. package/node_modules/@tiptap/core/src/inputRules/nodeInputRule.ts +9 -2
  160. package/node_modules/@tiptap/core/src/inputRules/textInputRule.ts +5 -1
  161. package/node_modules/@tiptap/core/src/inputRules/textblockTypeInputRule.ts +8 -2
  162. package/node_modules/@tiptap/core/src/inputRules/wrappingInputRule.ts +8 -2
  163. package/node_modules/@tiptap/core/src/jsx-runtime.ts +91 -11
  164. package/node_modules/@tiptap/core/src/lib/ResizableNodeView.ts +25 -6
  165. package/node_modules/@tiptap/core/src/pasteRules/markPasteRule.ts +12 -1
  166. package/node_modules/@tiptap/core/src/types.ts +65 -18
  167. package/node_modules/@tiptap/core/src/utilities/attrsEqual.ts +27 -0
  168. package/node_modules/@tiptap/core/src/utilities/callOrReturn.ts +5 -1
  169. package/node_modules/@tiptap/core/src/utilities/deleteProps.ts +4 -1
  170. package/node_modules/@tiptap/core/src/utilities/elementFromString.ts +3 -1
  171. package/node_modules/@tiptap/core/src/utilities/getStyleProperty.ts +52 -0
  172. package/node_modules/@tiptap/core/src/utilities/htmlEntities.ts +26 -0
  173. package/node_modules/@tiptap/core/src/utilities/index.ts +4 -0
  174. package/node_modules/@tiptap/core/src/utilities/isAndroid.ts +1 -1
  175. package/node_modules/@tiptap/core/src/utilities/isDev.ts +12 -0
  176. package/node_modules/@tiptap/core/src/utilities/isFunction.ts +1 -1
  177. package/node_modules/@tiptap/core/src/utilities/isSafari.ts +3 -1
  178. package/node_modules/@tiptap/core/src/utilities/isiOS.ts +3 -1
  179. package/node_modules/@tiptap/core/src/utilities/markdown/createAtomBlockMarkdownSpec.ts +2 -4
  180. package/node_modules/@tiptap/core/src/utilities/markdown/createBlockMarkdownSpec.ts +10 -6
  181. package/node_modules/@tiptap/core/src/utilities/markdown/createInlineMarkdownSpec.ts +4 -24
  182. package/node_modules/@tiptap/core/src/utilities/markdown/index.ts +2 -1
  183. package/node_modules/@tiptap/core/src/utilities/markdown/parseAttributes.ts +48 -0
  184. package/node_modules/@tiptap/core/src/utilities/markdown/parseShortcodeAttributes.ts +13 -0
  185. package/node_modules/@tiptap/core/src/utilities/markdown/renderNestedMarkdownContent.ts +2 -1
  186. package/node_modules/@tiptap/core/src/utilities/markdown/serializeAttributes.ts +42 -0
  187. package/node_modules/@tiptap/core/src/utilities/markdown/tokenizeAttributes.ts +163 -0
  188. package/node_modules/@tiptap/core/src/utilities/marksEqual.ts +44 -0
  189. package/node_modules/@tiptap/core/src/utilities/mergeAttributes.ts +22 -3
  190. package/node_modules/@tiptap/core/src/utilities/mergeDeep.ts +4 -1
  191. package/node_modules/@tiptap/extension-bubble-menu/dist/index.cjs +324 -453
  192. package/node_modules/@tiptap/extension-bubble-menu/dist/index.cjs.map +1 -1
  193. package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.cts +152 -151
  194. package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.cts.map +1 -0
  195. package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.ts +152 -151
  196. package/node_modules/@tiptap/extension-bubble-menu/dist/index.d.ts.map +1 -0
  197. package/node_modules/@tiptap/extension-bubble-menu/dist/index.js +316 -433
  198. package/node_modules/@tiptap/extension-bubble-menu/dist/index.js.map +1 -1
  199. package/node_modules/@tiptap/extension-bubble-menu/package.json +25 -23
  200. package/node_modules/@tiptap/extension-bubble-menu/src/bubble-menu-plugin.ts +73 -13
  201. package/node_modules/@tiptap/extension-floating-menu/dist/index.cjs +265 -373
  202. package/node_modules/@tiptap/extension-floating-menu/dist/index.cjs.map +1 -1
  203. package/node_modules/@tiptap/extension-floating-menu/dist/index.d.cts +161 -160
  204. package/node_modules/@tiptap/extension-floating-menu/dist/index.d.cts.map +1 -0
  205. package/node_modules/@tiptap/extension-floating-menu/dist/index.d.ts +161 -160
  206. package/node_modules/@tiptap/extension-floating-menu/dist/index.d.ts.map +1 -0
  207. package/node_modules/@tiptap/extension-floating-menu/dist/index.js +258 -354
  208. package/node_modules/@tiptap/extension-floating-menu/dist/index.js.map +1 -1
  209. package/node_modules/@tiptap/extension-floating-menu/package.json +23 -21
  210. package/node_modules/@tiptap/extension-floating-menu/src/floating-menu-plugin.ts +66 -11
  211. package/node_modules/@tiptap/extension-mention/dist/index.cjs +232 -268
  212. package/node_modules/@tiptap/extension-mention/dist/index.cjs.map +1 -1
  213. package/node_modules/@tiptap/extension-mention/dist/index.d.cts +85 -84
  214. package/node_modules/@tiptap/extension-mention/dist/index.d.cts.map +1 -0
  215. package/node_modules/@tiptap/extension-mention/dist/index.d.ts +85 -84
  216. package/node_modules/@tiptap/extension-mention/dist/index.d.ts.map +1 -0
  217. package/node_modules/@tiptap/extension-mention/dist/index.js +226 -240
  218. package/node_modules/@tiptap/extension-mention/dist/index.js.map +1 -1
  219. package/node_modules/@tiptap/extension-mention/package.json +24 -22
  220. package/node_modules/@tiptap/extension-mention/src/mention.ts +23 -13
  221. package/node_modules/@tiptap/pm/README.md +1 -1
  222. package/node_modules/{prosemirror-markdown/LICENSE → @tiptap/pm/THIRD_PARTY_LICENSES.md} +28 -0
  223. package/node_modules/@tiptap/pm/dist/changeset/index.cjs +9 -2
  224. package/node_modules/@tiptap/pm/dist/changeset/index.d.cts +1 -18
  225. package/node_modules/@tiptap/pm/dist/changeset/index.d.ts +1 -18
  226. package/node_modules/@tiptap/pm/dist/changeset/index.js +1 -1
  227. package/node_modules/@tiptap/pm/dist/commands/index.cjs +9 -2
  228. package/node_modules/@tiptap/pm/dist/commands/index.d.cts +1 -1
  229. package/node_modules/@tiptap/pm/dist/commands/index.d.ts +1 -1
  230. package/node_modules/@tiptap/pm/dist/commands/index.js +1 -1
  231. package/node_modules/@tiptap/pm/dist/dropcursor/index.cjs +9 -2
  232. package/node_modules/@tiptap/pm/dist/dropcursor/index.d.cts +1 -1
  233. package/node_modules/@tiptap/pm/dist/dropcursor/index.d.ts +1 -1
  234. package/node_modules/@tiptap/pm/dist/dropcursor/index.js +1 -1
  235. package/node_modules/@tiptap/pm/dist/gapcursor/index.cjs +9 -2
  236. package/node_modules/@tiptap/pm/dist/gapcursor/index.d.cts +1 -1
  237. package/node_modules/@tiptap/pm/dist/gapcursor/index.d.ts +1 -1
  238. package/node_modules/@tiptap/pm/dist/gapcursor/index.js +1 -1
  239. package/node_modules/@tiptap/pm/dist/history/index.cjs +9 -2
  240. package/node_modules/@tiptap/pm/dist/history/index.d.cts +1 -1
  241. package/node_modules/@tiptap/pm/dist/history/index.d.ts +1 -1
  242. package/node_modules/@tiptap/pm/dist/history/index.js +1 -1
  243. package/node_modules/@tiptap/pm/dist/inputrules/index.cjs +9 -2
  244. package/node_modules/@tiptap/pm/dist/inputrules/index.d.cts +1 -1
  245. package/node_modules/@tiptap/pm/dist/inputrules/index.d.ts +1 -1
  246. package/node_modules/@tiptap/pm/dist/inputrules/index.js +1 -1
  247. package/node_modules/@tiptap/pm/dist/keymap/index.cjs +9 -2
  248. package/node_modules/@tiptap/pm/dist/keymap/index.d.cts +1 -1
  249. package/node_modules/@tiptap/pm/dist/keymap/index.d.ts +1 -1
  250. package/node_modules/@tiptap/pm/dist/keymap/index.js +1 -1
  251. package/node_modules/@tiptap/pm/dist/model/index.cjs +9 -2
  252. package/node_modules/@tiptap/pm/dist/model/index.d.cts +1 -1
  253. package/node_modules/@tiptap/pm/dist/model/index.d.ts +1 -1
  254. package/node_modules/@tiptap/pm/dist/model/index.js +1 -1
  255. package/node_modules/@tiptap/pm/dist/schema-list/index.cjs +9 -2
  256. package/node_modules/@tiptap/pm/dist/schema-list/index.d.cts +1 -1
  257. package/node_modules/@tiptap/pm/dist/schema-list/index.d.ts +1 -1
  258. package/node_modules/@tiptap/pm/dist/schema-list/index.js +1 -1
  259. package/node_modules/@tiptap/pm/dist/state/index.cjs +9 -2
  260. package/node_modules/@tiptap/pm/dist/state/index.d.cts +1 -1
  261. package/node_modules/@tiptap/pm/dist/state/index.d.ts +1 -1
  262. package/node_modules/@tiptap/pm/dist/state/index.js +1 -1
  263. package/node_modules/@tiptap/pm/dist/tables/index.cjs +9 -2
  264. package/node_modules/@tiptap/pm/dist/tables/index.d.cts +1 -1
  265. package/node_modules/@tiptap/pm/dist/tables/index.d.ts +1 -1
  266. package/node_modules/@tiptap/pm/dist/tables/index.js +1 -1
  267. package/node_modules/@tiptap/pm/dist/transform/index.cjs +9 -2
  268. package/node_modules/@tiptap/pm/dist/transform/index.d.cts +1 -1
  269. package/node_modules/@tiptap/pm/dist/transform/index.d.ts +1 -1
  270. package/node_modules/@tiptap/pm/dist/transform/index.js +1 -1
  271. package/node_modules/@tiptap/pm/dist/view/index.cjs +9 -2
  272. package/node_modules/@tiptap/pm/dist/view/index.d.cts +1 -1
  273. package/node_modules/@tiptap/pm/dist/view/index.d.ts +1 -1
  274. package/node_modules/@tiptap/pm/dist/view/index.js +1 -1
  275. package/node_modules/@tiptap/pm/package.json +54 -99
  276. package/node_modules/@tiptap/react/dist/index.cjs +1243 -1141
  277. package/node_modules/@tiptap/react/dist/index.cjs.map +1 -1
  278. package/node_modules/@tiptap/react/dist/index.d.cts +396 -294
  279. package/node_modules/@tiptap/react/dist/index.d.cts.map +1 -0
  280. package/node_modules/@tiptap/react/dist/index.d.ts +396 -294
  281. package/node_modules/@tiptap/react/dist/index.d.ts.map +1 -0
  282. package/node_modules/@tiptap/react/dist/index.js +1188 -1081
  283. package/node_modules/@tiptap/react/dist/index.js.map +1 -1
  284. package/node_modules/@tiptap/react/dist/menus/index.cjs +420 -450
  285. package/node_modules/@tiptap/react/dist/menus/index.cjs.map +1 -1
  286. package/node_modules/@tiptap/react/dist/menus/index.d.cts +13 -11
  287. package/node_modules/@tiptap/react/dist/menus/index.d.cts.map +1 -0
  288. package/node_modules/@tiptap/react/dist/menus/index.d.ts +13 -11
  289. package/node_modules/@tiptap/react/dist/menus/index.d.ts.map +1 -0
  290. package/node_modules/@tiptap/react/dist/menus/index.js +399 -416
  291. package/node_modules/@tiptap/react/dist/menus/index.js.map +1 -1
  292. package/node_modules/@tiptap/react/package.json +29 -27
  293. package/node_modules/@tiptap/react/src/Context.tsx +3 -1
  294. package/node_modules/@tiptap/react/src/Editor.ts +4 -1
  295. package/node_modules/@tiptap/react/src/EditorContent.spec.ts +39 -0
  296. package/node_modules/@tiptap/react/src/EditorContent.tsx +26 -41
  297. package/node_modules/@tiptap/react/src/ReactMarkViewRenderer.tsx +18 -10
  298. package/node_modules/@tiptap/react/src/ReactNodeViewRenderer.spec.ts +415 -0
  299. package/node_modules/@tiptap/react/src/ReactNodeViewRenderer.tsx +126 -24
  300. package/node_modules/@tiptap/react/src/ReactRenderer.tsx +30 -8
  301. package/node_modules/@tiptap/react/src/ReactWidgetRenderer.spec.ts +448 -0
  302. package/node_modules/@tiptap/react/src/ReactWidgetRenderer.tsx +97 -0
  303. package/node_modules/@tiptap/react/src/Tiptap.tsx +22 -15
  304. package/node_modules/@tiptap/react/src/captureDOMSelection.spec.ts +76 -0
  305. package/node_modules/@tiptap/react/src/captureDOMSelection.ts +35 -0
  306. package/node_modules/@tiptap/react/src/index.ts +3 -0
  307. package/node_modules/@tiptap/react/src/menus/BubbleMenu.spec.ts +7 -3
  308. package/node_modules/@tiptap/react/src/menus/BubbleMenu.tsx +10 -3
  309. package/node_modules/@tiptap/react/src/menus/FloatingMenu.spec.ts +7 -3
  310. package/node_modules/@tiptap/react/src/menus/FloatingMenu.tsx +28 -4
  311. package/node_modules/@tiptap/react/src/menus/index.ts +2 -0
  312. package/node_modules/@tiptap/react/src/menus/useMenuElementProps.ts +18 -3
  313. package/node_modules/@tiptap/react/src/use-client.spec.ts +26 -0
  314. package/node_modules/@tiptap/react/src/useEditor.ts +30 -33
  315. package/node_modules/@tiptap/react/src/useEditorState.spec.ts +121 -0
  316. package/node_modules/@tiptap/react/src/useEditorState.ts +17 -3
  317. package/node_modules/@tiptap/react/src/useReactNodeView.ts +12 -2
  318. package/node_modules/@tiptap/suggestion/dist/index.cjs +657 -361
  319. package/node_modules/@tiptap/suggestion/dist/index.cjs.map +1 -1
  320. package/node_modules/@tiptap/suggestion/dist/index.d.cts +395 -189
  321. package/node_modules/@tiptap/suggestion/dist/index.d.cts.map +1 -0
  322. package/node_modules/@tiptap/suggestion/dist/index.d.ts +395 -189
  323. package/node_modules/@tiptap/suggestion/dist/index.d.ts.map +1 -0
  324. package/node_modules/@tiptap/suggestion/dist/index.js +648 -330
  325. package/node_modules/@tiptap/suggestion/dist/index.js.map +1 -1
  326. package/node_modules/@tiptap/suggestion/package.json +25 -21
  327. package/node_modules/@tiptap/suggestion/src/__tests__/suggestion.test.ts +1123 -2
  328. package/node_modules/@tiptap/suggestion/src/findSuggestionMatch.ts +8 -1
  329. package/node_modules/@tiptap/suggestion/src/helpers.ts +129 -0
  330. package/node_modules/@tiptap/suggestion/src/plugin/async.ts +89 -0
  331. package/node_modules/@tiptap/suggestion/src/plugin/floating-ui.ts +204 -0
  332. package/node_modules/@tiptap/suggestion/src/plugin/props.ts +94 -0
  333. package/node_modules/@tiptap/suggestion/src/plugin/state.ts +182 -0
  334. package/node_modules/@tiptap/suggestion/src/plugin/view.ts +236 -0
  335. package/node_modules/@tiptap/suggestion/src/suggestion.ts +101 -535
  336. package/node_modules/@tiptap/suggestion/src/types.ts +439 -0
  337. package/node_modules/prosemirror-changeset/CHANGELOG.md +36 -0
  338. package/node_modules/prosemirror-changeset/README.md +1 -1
  339. package/node_modules/prosemirror-changeset/dist/index.cjs +35 -24
  340. package/node_modules/prosemirror-changeset/dist/index.d.cts +2 -1
  341. package/node_modules/prosemirror-changeset/dist/index.d.ts +2 -1
  342. package/node_modules/prosemirror-changeset/dist/index.js +23 -8
  343. package/node_modules/prosemirror-changeset/package.json +2 -2
  344. package/node_modules/prosemirror-changeset/src/README.md +1 -1
  345. package/node_modules/prosemirror-changeset/src/diff.ts +21 -8
  346. package/node_modules/prosemirror-changeset/src/simplify.ts +1 -1
  347. package/node_modules/prosemirror-changeset/test/test-diff.ts +26 -0
  348. package/node_modules/prosemirror-changeset/test/test-simplify.ts +3 -0
  349. package/node_modules/prosemirror-commands/CHANGELOG.md +6 -0
  350. package/node_modules/prosemirror-commands/CONTRIBUTING.md +19 -19
  351. package/node_modules/prosemirror-commands/README.md +3 -3
  352. package/node_modules/prosemirror-commands/dist/index.cjs +23 -22
  353. package/node_modules/prosemirror-commands/dist/index.js +11 -9
  354. package/node_modules/prosemirror-commands/package.json +2 -2
  355. package/node_modules/prosemirror-commands/src/commands.ts +11 -8
  356. package/node_modules/prosemirror-dropcursor/CHANGELOG.md +12 -0
  357. package/node_modules/prosemirror-dropcursor/CONTRIBUTING.md +22 -18
  358. package/node_modules/prosemirror-dropcursor/README.md +3 -3
  359. package/node_modules/prosemirror-dropcursor/dist/index.cjs +25 -10
  360. package/node_modules/prosemirror-dropcursor/dist/index.js +30 -13
  361. package/node_modules/prosemirror-dropcursor/package.json +2 -2
  362. package/node_modules/prosemirror-dropcursor/src/dropcursor.ts +26 -10
  363. package/node_modules/prosemirror-history/CHANGELOG.md +12 -0
  364. package/node_modules/prosemirror-history/CONTRIBUTING.md +19 -19
  365. package/node_modules/prosemirror-history/README.md +3 -3
  366. package/node_modules/prosemirror-history/dist/index.cjs +32 -11
  367. package/node_modules/prosemirror-history/dist/index.js +21 -4
  368. package/node_modules/prosemirror-history/package.json +2 -2
  369. package/node_modules/prosemirror-history/src/history.ts +24 -5
  370. package/node_modules/prosemirror-model/CHANGELOG.md +58 -0
  371. package/node_modules/prosemirror-model/CONTRIBUTING.md +19 -19
  372. package/node_modules/prosemirror-model/README.md +3 -3
  373. package/node_modules/prosemirror-model/dist/index.cjs +117 -110
  374. package/node_modules/prosemirror-model/dist/index.d.cts +36 -30
  375. package/node_modules/prosemirror-model/dist/index.d.ts +36 -30
  376. package/node_modules/prosemirror-model/dist/index.js +67 -56
  377. package/node_modules/prosemirror-model/package.json +2 -2
  378. package/node_modules/prosemirror-model/src/diff.ts +10 -5
  379. package/node_modules/prosemirror-model/src/fragment.ts +1 -1
  380. package/node_modules/prosemirror-model/src/from_dom.ts +5 -2
  381. package/node_modules/prosemirror-model/src/mark.ts +0 -1
  382. package/node_modules/prosemirror-model/src/node.ts +30 -10
  383. package/node_modules/prosemirror-model/src/replace.ts +8 -16
  384. package/node_modules/prosemirror-model/src/schema.ts +15 -28
  385. package/node_modules/prosemirror-model/src/to_dom.ts +24 -20
  386. package/node_modules/prosemirror-transform/CHANGELOG.md +56 -0
  387. package/node_modules/prosemirror-transform/CONTRIBUTING.md +19 -19
  388. package/node_modules/prosemirror-transform/README.md +3 -3
  389. package/node_modules/prosemirror-transform/dist/index.cjs +288 -176
  390. package/node_modules/prosemirror-transform/dist/index.d.cts +14 -4
  391. package/node_modules/prosemirror-transform/dist/index.d.ts +14 -4
  392. package/node_modules/prosemirror-transform/dist/index.js +156 -55
  393. package/node_modules/prosemirror-transform/package.json +2 -2
  394. package/node_modules/prosemirror-transform/src/attr_step.ts +1 -1
  395. package/node_modules/prosemirror-transform/src/map.ts +11 -6
  396. package/node_modules/prosemirror-transform/src/mark.ts +4 -21
  397. package/node_modules/prosemirror-transform/src/mark_step.ts +81 -10
  398. package/node_modules/prosemirror-transform/src/replace.ts +31 -9
  399. package/node_modules/prosemirror-transform/src/replace_step.ts +11 -2
  400. package/node_modules/prosemirror-transform/src/structure.ts +15 -9
  401. package/node_modules/prosemirror-view/CHANGELOG.md +52 -2
  402. package/node_modules/prosemirror-view/CONTRIBUTING.md +19 -19
  403. package/node_modules/prosemirror-view/README.md +3 -3
  404. package/node_modules/prosemirror-view/dist/index.cjs +287 -183
  405. package/node_modules/prosemirror-view/dist/index.d.cts +10 -2
  406. package/node_modules/prosemirror-view/dist/index.d.ts +10 -2
  407. package/node_modules/prosemirror-view/dist/index.js +180 -93
  408. package/node_modules/prosemirror-view/package.json +3 -3
  409. package/node_modules/prosemirror-view/src/clipboard.ts +21 -5
  410. package/node_modules/prosemirror-view/src/domchange.ts +8 -18
  411. package/node_modules/prosemirror-view/src/domcoords.ts +4 -1
  412. package/node_modules/prosemirror-view/src/domobserver.ts +4 -1
  413. package/node_modules/prosemirror-view/src/index.ts +4 -3
  414. package/node_modules/prosemirror-view/src/input.ts +96 -41
  415. package/node_modules/prosemirror-view/src/selection.ts +6 -6
  416. package/node_modules/prosemirror-view/src/viewdesc.ts +48 -23
  417. package/node_modules/prosemirror-view/style/prosemirror.css +1 -1
  418. package/package.json +19 -55
  419. package/dist/chunk-GZWQVVE7.js.map +0 -1
  420. package/node_modules/@remirror/core-constants/LICENSE +0 -21
  421. package/node_modules/@remirror/core-constants/dist/_tsup-dts-rollup.d.cts +0 -612
  422. package/node_modules/@remirror/core-constants/dist/_tsup-dts-rollup.d.ts +0 -612
  423. package/node_modules/@remirror/core-constants/dist/remirror-core-constants.cjs +0 -314
  424. package/node_modules/@remirror/core-constants/dist/remirror-core-constants.d.cts +0 -20
  425. package/node_modules/@remirror/core-constants/dist/remirror-core-constants.d.ts +0 -20
  426. package/node_modules/@remirror/core-constants/dist/remirror-core-constants.js +0 -269
  427. package/node_modules/@remirror/core-constants/dist-types/core-constants.d.ts +0 -431
  428. package/node_modules/@remirror/core-constants/dist-types/error-constants.d.ts +0 -119
  429. package/node_modules/@remirror/core-constants/dist-types/index.d.ts +0 -2
  430. package/node_modules/@remirror/core-constants/dist-types/tsconfig.tsbuildinfo +0 -1
  431. package/node_modules/@remirror/core-constants/package.json +0 -45
  432. package/node_modules/@remirror/core-constants/readme.md +0 -17
  433. package/node_modules/@tiptap/core/src/utilities/markdown/attributeUtils.ts +0 -130
  434. package/node_modules/@tiptap/pm/collab/index.ts +0 -1
  435. package/node_modules/@tiptap/pm/dist/collab/index.cjs +0 -2
  436. package/node_modules/@tiptap/pm/dist/collab/index.d.cts +0 -1
  437. package/node_modules/@tiptap/pm/dist/collab/index.d.ts +0 -1
  438. package/node_modules/@tiptap/pm/dist/collab/index.js +0 -2
  439. package/node_modules/@tiptap/pm/dist/markdown/index.cjs +0 -2
  440. package/node_modules/@tiptap/pm/dist/markdown/index.d.cts +0 -1
  441. package/node_modules/@tiptap/pm/dist/markdown/index.d.ts +0 -1
  442. package/node_modules/@tiptap/pm/dist/markdown/index.js +0 -2
  443. package/node_modules/@tiptap/pm/dist/menu/index.cjs +0 -2
  444. package/node_modules/@tiptap/pm/dist/menu/index.d.cts +0 -1
  445. package/node_modules/@tiptap/pm/dist/menu/index.d.ts +0 -1
  446. package/node_modules/@tiptap/pm/dist/menu/index.js +0 -2
  447. package/node_modules/@tiptap/pm/dist/schema-basic/index.cjs +0 -2
  448. package/node_modules/@tiptap/pm/dist/schema-basic/index.d.cts +0 -1
  449. package/node_modules/@tiptap/pm/dist/schema-basic/index.d.ts +0 -1
  450. package/node_modules/@tiptap/pm/dist/schema-basic/index.js +0 -2
  451. package/node_modules/@tiptap/pm/dist/trailing-node/index.cjs +0 -2
  452. package/node_modules/@tiptap/pm/dist/trailing-node/index.d.cts +0 -1
  453. package/node_modules/@tiptap/pm/dist/trailing-node/index.d.ts +0 -1
  454. package/node_modules/@tiptap/pm/dist/trailing-node/index.js +0 -2
  455. package/node_modules/@tiptap/pm/markdown/index.ts +0 -1
  456. package/node_modules/@tiptap/pm/menu/index.ts +0 -1
  457. package/node_modules/@tiptap/pm/schema-basic/index.ts +0 -1
  458. package/node_modules/@tiptap/pm/trailing-node/index.ts +0 -1
  459. package/node_modules/@types/linkify-it/LICENSE +0 -21
  460. package/node_modules/@types/linkify-it/README.md +0 -15
  461. package/node_modules/@types/linkify-it/build/index.cjs.d.ts +0 -178
  462. package/node_modules/@types/linkify-it/index.d.mts +0 -174
  463. package/node_modules/@types/linkify-it/index.d.ts +0 -3
  464. package/node_modules/@types/linkify-it/package.json +0 -50
  465. package/node_modules/@types/markdown-it/LICENSE +0 -21
  466. package/node_modules/@types/markdown-it/README.md +0 -15
  467. package/node_modules/@types/markdown-it/dist/index.cjs.d.ts +0 -1236
  468. package/node_modules/@types/markdown-it/dist/markdown-it.d.ts +0 -5
  469. package/node_modules/@types/markdown-it/dist/markdown-it.min.d.ts +0 -5
  470. package/node_modules/@types/markdown-it/index.d.mts +0 -1
  471. package/node_modules/@types/markdown-it/index.d.ts +0 -3
  472. package/node_modules/@types/markdown-it/lib/common/html_blocks.d.mts +0 -7
  473. package/node_modules/@types/markdown-it/lib/common/html_re.d.mts +0 -2
  474. package/node_modules/@types/markdown-it/lib/common/utils.d.mts +0 -62
  475. package/node_modules/@types/markdown-it/lib/helpers/index.d.mts +0 -5
  476. package/node_modules/@types/markdown-it/lib/helpers/parse_link_destination.d.mts +0 -7
  477. package/node_modules/@types/markdown-it/lib/helpers/parse_link_label.d.mts +0 -3
  478. package/node_modules/@types/markdown-it/lib/helpers/parse_link_title.d.mts +0 -29
  479. package/node_modules/@types/markdown-it/lib/index.d.mts +0 -404
  480. package/node_modules/@types/markdown-it/lib/parser_block.d.mts +0 -25
  481. package/node_modules/@types/markdown-it/lib/parser_core.d.mts +0 -18
  482. package/node_modules/@types/markdown-it/lib/parser_inline.d.mts +0 -38
  483. package/node_modules/@types/markdown-it/lib/renderer.d.mts +0 -96
  484. package/node_modules/@types/markdown-it/lib/ruler.d.mts +0 -158
  485. package/node_modules/@types/markdown-it/lib/rules_block/state_block.d.mts +0 -124
  486. package/node_modules/@types/markdown-it/lib/rules_core/state_core.d.mts +0 -18
  487. package/node_modules/@types/markdown-it/lib/rules_inline/state_inline.d.mts +0 -73
  488. package/node_modules/@types/markdown-it/lib/token.d.mts +0 -108
  489. package/node_modules/@types/markdown-it/package.json +0 -54
  490. package/node_modules/@types/mdurl/LICENSE +0 -21
  491. package/node_modules/@types/mdurl/README.md +0 -15
  492. package/node_modules/@types/mdurl/build/index.cjs.d.ts +0 -52
  493. package/node_modules/@types/mdurl/index.d.mts +0 -6
  494. package/node_modules/@types/mdurl/index.d.ts +0 -3
  495. package/node_modules/@types/mdurl/lib/decode.d.mts +0 -10
  496. package/node_modules/@types/mdurl/lib/encode.d.mts +0 -15
  497. package/node_modules/@types/mdurl/lib/format.d.mts +0 -3
  498. package/node_modules/@types/mdurl/lib/parse.d.mts +0 -18
  499. package/node_modules/@types/mdurl/package.json +0 -36
  500. package/node_modules/argparse/LICENSE +0 -254
  501. package/node_modules/argparse/README.md +0 -84
  502. package/node_modules/argparse/argparse.js +0 -3707
  503. package/node_modules/argparse/lib/sub.js +0 -67
  504. package/node_modules/argparse/lib/textwrap.js +0 -440
  505. package/node_modules/argparse/package.json +0 -31
  506. package/node_modules/crelt/LICENSE +0 -19
  507. package/node_modules/crelt/README.md +0 -23
  508. package/node_modules/crelt/dist/index.cjs +0 -31
  509. package/node_modules/crelt/dist/index.d.cts +0 -4
  510. package/node_modules/crelt/index.d.ts +0 -4
  511. package/node_modules/crelt/index.js +0 -28
  512. package/node_modules/crelt/package.json +0 -35
  513. package/node_modules/crelt/rollup.config.js +0 -13
  514. package/node_modules/entities/LICENSE +0 -11
  515. package/node_modules/entities/lib/decode.d.ts +0 -211
  516. package/node_modules/entities/lib/decode.d.ts.map +0 -1
  517. package/node_modules/entities/lib/decode.js +0 -536
  518. package/node_modules/entities/lib/decode.js.map +0 -1
  519. package/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
  520. package/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
  521. package/node_modules/entities/lib/decode_codepoint.js +0 -76
  522. package/node_modules/entities/lib/decode_codepoint.js.map +0 -1
  523. package/node_modules/entities/lib/encode.d.ts +0 -22
  524. package/node_modules/entities/lib/encode.d.ts.map +0 -1
  525. package/node_modules/entities/lib/encode.js +0 -77
  526. package/node_modules/entities/lib/encode.js.map +0 -1
  527. package/node_modules/entities/lib/escape.d.ts +0 -43
  528. package/node_modules/entities/lib/escape.d.ts.map +0 -1
  529. package/node_modules/entities/lib/escape.js +0 -122
  530. package/node_modules/entities/lib/escape.js.map +0 -1
  531. package/node_modules/entities/lib/esm/decode.d.ts +0 -211
  532. package/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
  533. package/node_modules/entities/lib/esm/decode.js +0 -496
  534. package/node_modules/entities/lib/esm/decode.js.map +0 -1
  535. package/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
  536. package/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
  537. package/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
  538. package/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
  539. package/node_modules/entities/lib/esm/encode.d.ts +0 -22
  540. package/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
  541. package/node_modules/entities/lib/esm/encode.js +0 -69
  542. package/node_modules/entities/lib/esm/encode.js.map +0 -1
  543. package/node_modules/entities/lib/esm/escape.d.ts +0 -43
  544. package/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
  545. package/node_modules/entities/lib/esm/escape.js +0 -116
  546. package/node_modules/entities/lib/esm/escape.js.map +0 -1
  547. package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
  548. package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
  549. package/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
  550. package/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
  551. package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
  552. package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
  553. package/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
  554. package/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
  555. package/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
  556. package/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
  557. package/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
  558. package/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
  559. package/node_modules/entities/lib/esm/index.d.ts +0 -96
  560. package/node_modules/entities/lib/esm/index.d.ts.map +0 -1
  561. package/node_modules/entities/lib/esm/index.js +0 -99
  562. package/node_modules/entities/lib/esm/index.js.map +0 -1
  563. package/node_modules/entities/lib/esm/package.json +0 -1
  564. package/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
  565. package/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
  566. package/node_modules/entities/lib/generated/decode-data-html.js +0 -9
  567. package/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
  568. package/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
  569. package/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
  570. package/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
  571. package/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
  572. package/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
  573. package/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
  574. package/node_modules/entities/lib/generated/encode-html.js +0 -12
  575. package/node_modules/entities/lib/generated/encode-html.js.map +0 -1
  576. package/node_modules/entities/lib/index.d.ts +0 -96
  577. package/node_modules/entities/lib/index.d.ts.map +0 -1
  578. package/node_modules/entities/lib/index.js +0 -126
  579. package/node_modules/entities/lib/index.js.map +0 -1
  580. package/node_modules/entities/package.json +0 -90
  581. package/node_modules/entities/readme.md +0 -122
  582. package/node_modules/escape-string-regexp/index.d.ts +0 -18
  583. package/node_modules/escape-string-regexp/index.js +0 -13
  584. package/node_modules/escape-string-regexp/license +0 -9
  585. package/node_modules/escape-string-regexp/package.json +0 -38
  586. package/node_modules/escape-string-regexp/readme.md +0 -34
  587. package/node_modules/linkify-it/LICENSE +0 -22
  588. package/node_modules/linkify-it/README.md +0 -196
  589. package/node_modules/linkify-it/build/index.cjs.js +0 -832
  590. package/node_modules/linkify-it/index.mjs +0 -642
  591. package/node_modules/linkify-it/lib/re.mjs +0 -189
  592. package/node_modules/linkify-it/package.json +0 -58
  593. package/node_modules/markdown-it/LICENSE +0 -22
  594. package/node_modules/markdown-it/README.md +0 -324
  595. package/node_modules/markdown-it/bin/markdown-it.mjs +0 -107
  596. package/node_modules/markdown-it/dist/index.cjs.js +0 -5547
  597. package/node_modules/markdown-it/dist/markdown-it.js +0 -6969
  598. package/node_modules/markdown-it/dist/markdown-it.min.js +0 -2
  599. package/node_modules/markdown-it/index.mjs +0 -1
  600. package/node_modules/markdown-it/lib/common/html_blocks.mjs +0 -67
  601. package/node_modules/markdown-it/lib/common/html_re.mjs +0 -25
  602. package/node_modules/markdown-it/lib/common/utils.mjs +0 -304
  603. package/node_modules/markdown-it/lib/helpers/index.mjs +0 -11
  604. package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +0 -77
  605. package/node_modules/markdown-it/lib/helpers/parse_link_label.mjs +0 -49
  606. package/node_modules/markdown-it/lib/helpers/parse_link_title.mjs +0 -66
  607. package/node_modules/markdown-it/lib/index.mjs +0 -565
  608. package/node_modules/markdown-it/lib/parser_block.mjs +0 -134
  609. package/node_modules/markdown-it/lib/parser_core.mjs +0 -62
  610. package/node_modules/markdown-it/lib/parser_inline.mjs +0 -197
  611. package/node_modules/markdown-it/lib/presets/commonmark.mjs +0 -88
  612. package/node_modules/markdown-it/lib/presets/default.mjs +0 -47
  613. package/node_modules/markdown-it/lib/presets/zero.mjs +0 -70
  614. package/node_modules/markdown-it/lib/renderer.mjs +0 -322
  615. package/node_modules/markdown-it/lib/ruler.mjs +0 -340
  616. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +0 -209
  617. package/node_modules/markdown-it/lib/rules_block/code.mjs +0 -30
  618. package/node_modules/markdown-it/lib/rules_block/fence.mjs +0 -94
  619. package/node_modules/markdown-it/lib/rules_block/heading.mjs +0 -51
  620. package/node_modules/markdown-it/lib/rules_block/hr.mjs +0 -40
  621. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +0 -69
  622. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +0 -82
  623. package/node_modules/markdown-it/lib/rules_block/list.mjs +0 -331
  624. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +0 -46
  625. package/node_modules/markdown-it/lib/rules_block/reference.mjs +0 -212
  626. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +0 -220
  627. package/node_modules/markdown-it/lib/rules_block/table.mjs +0 -228
  628. package/node_modules/markdown-it/lib/rules_core/block.mjs +0 -13
  629. package/node_modules/markdown-it/lib/rules_core/inline.mjs +0 -11
  630. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +0 -134
  631. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +0 -17
  632. package/node_modules/markdown-it/lib/rules_core/replacements.mjs +0 -101
  633. package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +0 -193
  634. package/node_modules/markdown-it/lib/rules_core/state_core.mjs +0 -17
  635. package/node_modules/markdown-it/lib/rules_core/text_join.mjs +0 -43
  636. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +0 -72
  637. package/node_modules/markdown-it/lib/rules_inline/backticks.mjs +0 -60
  638. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +0 -124
  639. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +0 -123
  640. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +0 -51
  641. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +0 -69
  642. package/node_modules/markdown-it/lib/rules_inline/fragments_join.mjs +0 -38
  643. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +0 -50
  644. package/node_modules/markdown-it/lib/rules_inline/image.mjs +0 -138
  645. package/node_modules/markdown-it/lib/rules_inline/link.mjs +0 -139
  646. package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +0 -63
  647. package/node_modules/markdown-it/lib/rules_inline/newline.mjs +0 -42
  648. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +0 -123
  649. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +0 -127
  650. package/node_modules/markdown-it/lib/rules_inline/text.mjs +0 -86
  651. package/node_modules/markdown-it/lib/token.mjs +0 -191
  652. package/node_modules/markdown-it/package.json +0 -92
  653. package/node_modules/mdurl/LICENSE +0 -45
  654. package/node_modules/mdurl/README.md +0 -102
  655. package/node_modules/mdurl/build/index.cjs.js +0 -534
  656. package/node_modules/mdurl/index.mjs +0 -11
  657. package/node_modules/mdurl/lib/decode.mjs +0 -112
  658. package/node_modules/mdurl/lib/encode.mjs +0 -89
  659. package/node_modules/mdurl/lib/format.mjs +0 -21
  660. package/node_modules/mdurl/lib/parse.mjs +0 -308
  661. package/node_modules/mdurl/package.json +0 -37
  662. package/node_modules/prosemirror-collab/.tern-project +0 -8
  663. package/node_modules/prosemirror-collab/CHANGELOG.md +0 -77
  664. package/node_modules/prosemirror-collab/CONTRIBUTING.md +0 -104
  665. package/node_modules/prosemirror-collab/LICENSE +0 -19
  666. package/node_modules/prosemirror-collab/README.md +0 -28
  667. package/node_modules/prosemirror-collab/dist/index.cjs +0 -155
  668. package/node_modules/prosemirror-collab/dist/index.d.cts +0 -60
  669. package/node_modules/prosemirror-collab/dist/index.d.ts +0 -60
  670. package/node_modules/prosemirror-collab/dist/index.js +0 -156
  671. package/node_modules/prosemirror-collab/package.json +0 -40
  672. package/node_modules/prosemirror-collab/src/README.md +0 -11
  673. package/node_modules/prosemirror-collab/src/collab.ts +0 -184
  674. package/node_modules/prosemirror-markdown/.tern-project +0 -8
  675. package/node_modules/prosemirror-markdown/CHANGELOG.md +0 -311
  676. package/node_modules/prosemirror-markdown/CONTRIBUTING.md +0 -100
  677. package/node_modules/prosemirror-markdown/README.md +0 -276
  678. package/node_modules/prosemirror-markdown/dist/index.cjs +0 -966
  679. package/node_modules/prosemirror-markdown/dist/index.d.cts +0 -335
  680. package/node_modules/prosemirror-markdown/dist/index.d.ts +0 -335
  681. package/node_modules/prosemirror-markdown/dist/index.js +0 -878
  682. package/node_modules/prosemirror-markdown/package.json +0 -40
  683. package/node_modules/prosemirror-markdown/src/README.md +0 -42
  684. package/node_modules/prosemirror-markdown/src/from_markdown.ts +0 -272
  685. package/node_modules/prosemirror-markdown/src/index.ts +0 -5
  686. package/node_modules/prosemirror-markdown/src/schema.ts +0 -156
  687. package/node_modules/prosemirror-markdown/src/to_markdown.ts +0 -483
  688. package/node_modules/prosemirror-menu/.tern-project +0 -8
  689. package/node_modules/prosemirror-menu/CHANGELOG.md +0 -107
  690. package/node_modules/prosemirror-menu/CONTRIBUTING.md +0 -100
  691. package/node_modules/prosemirror-menu/LICENSE +0 -19
  692. package/node_modules/prosemirror-menu/README.md +0 -235
  693. package/node_modules/prosemirror-menu/dist/index.cjs +0 -798
  694. package/node_modules/prosemirror-menu/dist/index.d.cts +0 -281
  695. package/node_modules/prosemirror-menu/dist/index.d.ts +0 -281
  696. package/node_modules/prosemirror-menu/dist/index.js +0 -795
  697. package/node_modules/prosemirror-menu/package.json +0 -42
  698. package/node_modules/prosemirror-menu/src/README.md +0 -60
  699. package/node_modules/prosemirror-menu/src/icons.ts +0 -53
  700. package/node_modules/prosemirror-menu/src/index.ts +0 -4
  701. package/node_modules/prosemirror-menu/src/menu.ts +0 -628
  702. package/node_modules/prosemirror-menu/src/menubar.ts +0 -210
  703. package/node_modules/prosemirror-menu/style/menu.css +0 -169
  704. package/node_modules/prosemirror-schema-basic/.tern-project +0 -8
  705. package/node_modules/prosemirror-schema-basic/CHANGELOG.md +0 -81
  706. package/node_modules/prosemirror-schema-basic/CONTRIBUTING.md +0 -100
  707. package/node_modules/prosemirror-schema-basic/LICENSE +0 -19
  708. package/node_modules/prosemirror-schema-basic/README.md +0 -28
  709. package/node_modules/prosemirror-schema-basic/dist/index.cjs +0 -246
  710. package/node_modules/prosemirror-schema-basic/dist/index.d.cts +0 -87
  711. package/node_modules/prosemirror-schema-basic/dist/index.d.ts +0 -87
  712. package/node_modules/prosemirror-schema-basic/dist/index.js +0 -183
  713. package/node_modules/prosemirror-schema-basic/package.json +0 -37
  714. package/node_modules/prosemirror-schema-basic/src/README.md +0 -8
  715. package/node_modules/prosemirror-schema-basic/src/schema-basic.ts +0 -166
  716. package/node_modules/prosemirror-trailing-node/LICENSE +0 -21
  717. package/node_modules/prosemirror-trailing-node/dist/_tsup-dts-rollup.d.cts +0 -41
  718. package/node_modules/prosemirror-trailing-node/dist/_tsup-dts-rollup.d.ts +0 -41
  719. package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.cjs +0 -70
  720. package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.d.cts +0 -2
  721. package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.d.ts +0 -2
  722. package/node_modules/prosemirror-trailing-node/dist/prosemirror-trailing-node.js +0 -43
  723. package/node_modules/prosemirror-trailing-node/dist-types/index.d.ts +0 -2
  724. package/node_modules/prosemirror-trailing-node/dist-types/trailing-node-plugin.d.ts +0 -33
  725. package/node_modules/prosemirror-trailing-node/dist-types/tsconfig.tsbuildinfo +0 -1
  726. package/node_modules/prosemirror-trailing-node/package.json +0 -57
  727. package/node_modules/prosemirror-trailing-node/readme.md +0 -55
  728. package/node_modules/punycode.js/LICENSE-MIT.txt +0 -20
  729. package/node_modules/punycode.js/README.md +0 -148
  730. package/node_modules/punycode.js/package.json +0 -58
  731. package/node_modules/punycode.js/punycode.es6.js +0 -444
  732. package/node_modules/punycode.js/punycode.js +0 -443
  733. package/node_modules/uc.micro/LICENSE.txt +0 -20
  734. package/node_modules/uc.micro/README.md +0 -14
  735. package/node_modules/uc.micro/build/index.cjs.js +0 -20
  736. package/node_modules/uc.micro/categories/Cc/regex.mjs +0 -1
  737. package/node_modules/uc.micro/categories/Cf/regex.mjs +0 -1
  738. package/node_modules/uc.micro/categories/P/regex.mjs +0 -1
  739. package/node_modules/uc.micro/categories/S/regex.mjs +0 -1
  740. package/node_modules/uc.micro/categories/Z/regex.mjs +0 -1
  741. package/node_modules/uc.micro/index.mjs +0 -8
  742. package/node_modules/uc.micro/package.json +0 -37
  743. package/node_modules/uc.micro/properties/Any/regex.mjs +0 -1
  744. /package/dist/{chunk-AMWLYUD7.js.map → chunk-34YJQXTM.js.map} +0 -0
  745. /package/dist/{chunk-N2SQZ2HY.js.map → chunk-63G66FWM.js.map} +0 -0
  746. /package/dist/{chunk-HV3NKRZ2.js.map → chunk-7DG4JFRS.js.map} +0 -0
  747. /package/dist/{chunk-7UQ3RWAU.js.map → chunk-DNND32V4.js.map} +0 -0
  748. /package/dist/{chunk-C3G6F7UG.js.map → chunk-LFC3UTIJ.js.map} +0 -0
  749. /package/dist/{chunk-22JUW3EQ.js.map → chunk-NPDS3EEK.js.map} +0 -0
  750. /package/dist/{chunk-XRNHTA7C.js.map → chunk-XCASYOA6.js.map} +0 -0
  751. /package/node_modules/@tiptap/pm/{LICENSE.md → LICENSE} +0 -0
@@ -1,1131 +1,1238 @@
1
- // src/Context.tsx
2
- import { createContext, useContext, useMemo } from "react";
3
-
4
- // src/EditorContent.tsx
5
- import React, { forwardRef } from "react";
6
- import ReactDOM from "react-dom";
1
+ "use client";
2
+ import React, { createContext, createElement, createRef, forwardRef, memo, useContext, useDebugValue, useEffect, useLayoutEffect, useMemo, useRef, useState, version } from "react";
3
+ import ReactDOM, { flushSync } from "react-dom";
7
4
  import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
8
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
- var mergeRefs = (...refs) => {
10
- return (node) => {
11
- refs.forEach((ref) => {
12
- if (typeof ref === "function") {
13
- ref(node);
14
- } else if (ref) {
15
- ;
16
- ref.current = node;
17
- }
18
- });
19
- };
6
+ import { Editor, MarkView, NodeView, createWidgetDecoration, getRenderedAttributes, isNodeViewSelected } from "@tiptap/core";
7
+ import { deepEqual } from "fast-equals";
8
+ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
9
+ export * from "@tiptap/core";
10
+ //#region src/EditorContent.tsx
11
+ const mergeRefs = (...refs) => {
12
+ return (node) => {
13
+ refs.forEach((ref) => {
14
+ if (typeof ref === "function") ref(node);
15
+ else if (ref) ref.current = node;
16
+ });
17
+ };
20
18
  };
21
- var Portals = ({ contentComponent }) => {
22
- const renderers = useSyncExternalStore(
23
- contentComponent.subscribe,
24
- contentComponent.getSnapshot,
25
- contentComponent.getServerSnapshot
26
- );
27
- return /* @__PURE__ */ jsx(Fragment, { children: Object.values(renderers) });
19
+ /**
20
+ * This component renders all of the editor's node views.
21
+ */
22
+ const Portals = ({ contentComponent }) => {
23
+ const renderers = useSyncExternalStore(contentComponent.subscribe, contentComponent.getSnapshot, contentComponent.getServerSnapshot);
24
+ return /* @__PURE__ */ jsx(Fragment, { children: Object.values(renderers) });
28
25
  };
29
- function getInstance() {
30
- const subscribers = /* @__PURE__ */ new Set();
31
- let renderers = {};
32
- return {
33
- /**
34
- * Subscribe to the editor instance's changes.
35
- */
36
- subscribe(callback) {
37
- subscribers.add(callback);
38
- return () => {
39
- subscribers.delete(callback);
40
- };
41
- },
42
- getSnapshot() {
43
- return renderers;
44
- },
45
- getServerSnapshot() {
46
- return renderers;
47
- },
48
- /**
49
- * Adds a new NodeView Renderer to the editor.
50
- */
51
- setRenderer(id, renderer) {
52
- renderers = {
53
- ...renderers,
54
- [id]: ReactDOM.createPortal(renderer.reactElement, renderer.element, id)
55
- };
56
- subscribers.forEach((subscriber) => subscriber());
57
- },
58
- /**
59
- * Removes a NodeView Renderer from the editor.
60
- */
61
- removeRenderer(id) {
62
- const nextRenderers = { ...renderers };
63
- delete nextRenderers[id];
64
- renderers = nextRenderers;
65
- subscribers.forEach((subscriber) => subscriber());
66
- }
67
- };
26
+ function createContentComponent() {
27
+ const subscribers = /* @__PURE__ */ new Set();
28
+ let renderers = {};
29
+ let isNotificationQueued = false;
30
+ const notifySubscribers = () => {
31
+ if (isNotificationQueued || !subscribers.size) return;
32
+ isNotificationQueued = true;
33
+ queueMicrotask(() => {
34
+ isNotificationQueued = false;
35
+ subscribers.forEach((subscriber) => subscriber());
36
+ });
37
+ };
38
+ return {
39
+ /**
40
+ * Subscribe to the editor instance's changes.
41
+ */
42
+ subscribe(callback) {
43
+ subscribers.add(callback);
44
+ return () => {
45
+ subscribers.delete(callback);
46
+ };
47
+ },
48
+ getSnapshot() {
49
+ return renderers;
50
+ },
51
+ getServerSnapshot() {
52
+ return renderers;
53
+ },
54
+ /**
55
+ * Adds a new NodeView Renderer to the editor.
56
+ */
57
+ setRenderer(id, renderer) {
58
+ renderers = {
59
+ ...renderers,
60
+ [id]: ReactDOM.createPortal(renderer.reactElement, renderer.element, id)
61
+ };
62
+ notifySubscribers();
63
+ },
64
+ /**
65
+ * Removes a NodeView Renderer from the editor.
66
+ */
67
+ removeRenderer(id) {
68
+ const nextRenderers = { ...renderers };
69
+ delete nextRenderers[id];
70
+ renderers = nextRenderers;
71
+ notifySubscribers();
72
+ }
73
+ };
68
74
  }
69
75
  var PureEditorContent = class extends React.Component {
70
- constructor(props) {
71
- var _a;
72
- super(props);
73
- this.editorContentRef = React.createRef();
74
- this.initialized = false;
75
- this.state = {
76
- hasContentComponentInitialized: Boolean((_a = props.editor) == null ? void 0 : _a.contentComponent)
77
- };
78
- }
79
- componentDidMount() {
80
- this.init();
81
- }
82
- componentDidUpdate() {
83
- this.init();
84
- }
85
- init() {
86
- var _a;
87
- const editor = this.props.editor;
88
- if (editor && !editor.isDestroyed && ((_a = editor.view.dom) == null ? void 0 : _a.parentNode)) {
89
- if (editor.contentComponent) {
90
- return;
91
- }
92
- const element = this.editorContentRef.current;
93
- element.append(...editor.view.dom.parentNode.childNodes);
94
- editor.setOptions({
95
- element
96
- });
97
- editor.contentComponent = getInstance();
98
- if (!this.state.hasContentComponentInitialized) {
99
- this.unsubscribeToContentComponent = editor.contentComponent.subscribe(() => {
100
- this.setState((prevState) => {
101
- if (!prevState.hasContentComponentInitialized) {
102
- return {
103
- hasContentComponentInitialized: true
104
- };
105
- }
106
- return prevState;
107
- });
108
- if (this.unsubscribeToContentComponent) {
109
- this.unsubscribeToContentComponent();
110
- }
111
- });
112
- }
113
- editor.createNodeViews();
114
- this.initialized = true;
115
- }
116
- }
117
- componentWillUnmount() {
118
- var _a;
119
- const editor = this.props.editor;
120
- if (!editor) {
121
- return;
122
- }
123
- this.initialized = false;
124
- if (!editor.isDestroyed) {
125
- editor.view.setProps({
126
- nodeViews: {}
127
- });
128
- }
129
- if (this.unsubscribeToContentComponent) {
130
- this.unsubscribeToContentComponent();
131
- }
132
- editor.contentComponent = null;
133
- try {
134
- if (!((_a = editor.view.dom) == null ? void 0 : _a.parentNode)) {
135
- return;
136
- }
137
- const newElement = document.createElement("div");
138
- newElement.append(...editor.view.dom.parentNode.childNodes);
139
- editor.setOptions({
140
- element: newElement
141
- });
142
- } catch {
143
- }
144
- }
145
- render() {
146
- const { editor, innerRef, ...rest } = this.props;
147
- return /* @__PURE__ */ jsxs(Fragment, { children: [
148
- /* @__PURE__ */ jsx("div", { ref: mergeRefs(innerRef, this.editorContentRef), ...rest }),
149
- (editor == null ? void 0 : editor.contentComponent) && /* @__PURE__ */ jsx(Portals, { contentComponent: editor.contentComponent })
150
- ] });
151
- }
76
+ constructor(props) {
77
+ super(props);
78
+ this.editorContentRef = React.createRef();
79
+ }
80
+ componentDidMount() {
81
+ this.init();
82
+ }
83
+ componentDidUpdate() {
84
+ this.init();
85
+ }
86
+ init() {
87
+ var _editor$view$dom;
88
+ const editor = this.props.editor;
89
+ if (editor && !editor.isDestroyed && ((_editor$view$dom = editor.view.dom) === null || _editor$view$dom === void 0 ? void 0 : _editor$view$dom.parentNode)) {
90
+ if (editor.contentComponent) return;
91
+ const element = this.editorContentRef.current;
92
+ element.append(...editor.view.dom.parentNode.childNodes);
93
+ editor.setOptions({ element });
94
+ editor.contentComponent = createContentComponent();
95
+ editor.createNodeViews();
96
+ editor.isEditorContentInitialized = true;
97
+ this.forceUpdate();
98
+ }
99
+ }
100
+ componentWillUnmount() {
101
+ const editor = this.props.editor;
102
+ if (!editor) return;
103
+ editor.isEditorContentInitialized = false;
104
+ if (!editor.isDestroyed) editor.view.setProps({ nodeViews: {} });
105
+ editor.contentComponent = null;
106
+ try {
107
+ var _editor$view$dom2;
108
+ if (!((_editor$view$dom2 = editor.view.dom) === null || _editor$view$dom2 === void 0 ? void 0 : _editor$view$dom2.parentNode)) return;
109
+ const newElement = document.createElement("div");
110
+ newElement.append(...editor.view.dom.parentNode.childNodes);
111
+ editor.setOptions({ element: newElement });
112
+ } catch {}
113
+ }
114
+ render() {
115
+ const { editor, innerRef, ...rest } = this.props;
116
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
117
+ ref: mergeRefs(innerRef, this.editorContentRef),
118
+ ...rest
119
+ }), (editor === null || editor === void 0 ? void 0 : editor.contentComponent) && /* @__PURE__ */ jsx(Portals, { contentComponent: editor.contentComponent })] });
120
+ }
152
121
  };
153
- var EditorContentWithKey = forwardRef(
154
- (props, ref) => {
155
- const key = React.useMemo(() => {
156
- return Math.floor(Math.random() * 4294967295).toString();
157
- }, [props.editor]);
158
- return React.createElement(PureEditorContent, {
159
- key,
160
- innerRef: ref,
161
- ...props
162
- });
163
- }
164
- );
165
- var EditorContent = React.memo(EditorContentWithKey);
166
-
167
- // src/useEditor.ts
168
- import { Editor } from "@tiptap/core";
169
- import { useDebugValue as useDebugValue2, useEffect as useEffect2, useRef, useState as useState2 } from "react";
170
- import { useSyncExternalStore as useSyncExternalStore2 } from "use-sync-external-store/shim/index.js";
171
-
172
- // src/useEditorState.ts
173
- import { deepEqual } from "fast-equals";
174
- import { useDebugValue, useEffect, useLayoutEffect, useState } from "react";
175
- import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
176
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
122
+ const EditorContentWithKey = forwardRef((props, ref) => {
123
+ const key = React.useMemo(() => {
124
+ return Math.floor(Math.random() * 4294967295).toString();
125
+ }, [props.editor]);
126
+ return React.createElement(PureEditorContent, {
127
+ key,
128
+ innerRef: ref,
129
+ ...props
130
+ });
131
+ });
132
+ const EditorContent = React.memo(EditorContentWithKey);
133
+ //#endregion
134
+ //#region src/useEditorState.ts
135
+ const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
136
+ /**
137
+ * To synchronize the editor instance with the component state,
138
+ * we need to create a separate instance that is not affected by the component re-renders.
139
+ */
177
140
  var EditorStateManager = class {
178
- constructor(initialEditor) {
179
- this.transactionNumber = 0;
180
- this.lastTransactionNumber = 0;
181
- this.subscribers = /* @__PURE__ */ new Set();
182
- this.editor = initialEditor;
183
- this.lastSnapshot = { editor: initialEditor, transactionNumber: 0 };
184
- this.getSnapshot = this.getSnapshot.bind(this);
185
- this.getServerSnapshot = this.getServerSnapshot.bind(this);
186
- this.watch = this.watch.bind(this);
187
- this.subscribe = this.subscribe.bind(this);
188
- }
189
- /**
190
- * Get the current editor instance.
191
- */
192
- getSnapshot() {
193
- if (this.transactionNumber === this.lastTransactionNumber) {
194
- return this.lastSnapshot;
195
- }
196
- this.lastTransactionNumber = this.transactionNumber;
197
- this.lastSnapshot = { editor: this.editor, transactionNumber: this.transactionNumber };
198
- return this.lastSnapshot;
199
- }
200
- /**
201
- * Always disable the editor on the server-side.
202
- */
203
- getServerSnapshot() {
204
- return { editor: null, transactionNumber: 0 };
205
- }
206
- /**
207
- * Subscribe to the editor instance's changes.
208
- */
209
- subscribe(callback) {
210
- this.subscribers.add(callback);
211
- return () => {
212
- this.subscribers.delete(callback);
213
- };
214
- }
215
- /**
216
- * Watch the editor instance for changes.
217
- */
218
- watch(nextEditor) {
219
- this.editor = nextEditor;
220
- if (this.editor) {
221
- const fn = () => {
222
- this.transactionNumber += 1;
223
- this.subscribers.forEach((callback) => callback());
224
- };
225
- const currentEditor = this.editor;
226
- currentEditor.on("transaction", fn);
227
- return () => {
228
- currentEditor.off("transaction", fn);
229
- };
230
- }
231
- return void 0;
232
- }
141
+ constructor(initialEditor) {
142
+ this.transactionNumber = 0;
143
+ this.lastTransactionNumber = 0;
144
+ this.subscribers = /* @__PURE__ */ new Set();
145
+ this.editor = initialEditor;
146
+ this.lastSnapshot = {
147
+ editor: initialEditor,
148
+ transactionNumber: 0
149
+ };
150
+ this.getSnapshot = this.getSnapshot.bind(this);
151
+ this.getServerSnapshot = this.getServerSnapshot.bind(this);
152
+ this.watch = this.watch.bind(this);
153
+ this.subscribe = this.subscribe.bind(this);
154
+ }
155
+ /**
156
+ * Get the current editor instance.
157
+ */
158
+ getSnapshot() {
159
+ if (this.transactionNumber === this.lastTransactionNumber) return this.lastSnapshot;
160
+ this.lastTransactionNumber = this.transactionNumber;
161
+ this.lastSnapshot = {
162
+ editor: this.editor,
163
+ transactionNumber: this.transactionNumber
164
+ };
165
+ return this.lastSnapshot;
166
+ }
167
+ /**
168
+ * Always disable the editor on the server-side.
169
+ */
170
+ getServerSnapshot() {
171
+ return {
172
+ editor: null,
173
+ transactionNumber: 0
174
+ };
175
+ }
176
+ /**
177
+ * Subscribe to the editor instance's changes.
178
+ */
179
+ subscribe(callback) {
180
+ this.subscribers.add(callback);
181
+ return () => {
182
+ this.subscribers.delete(callback);
183
+ };
184
+ }
185
+ /**
186
+ * Watch the editor instance for changes.
187
+ */
188
+ watch(nextEditor) {
189
+ this.editor = nextEditor;
190
+ if (this.editor) {
191
+ /**
192
+ * This will force a re-render when the editor state changes.
193
+ * This is to support things like `editor.can().toggleBold()` in components that `useEditor`.
194
+ * This could be more efficient, but it's a good trade-off for now.
195
+ */
196
+ let lastTransaction;
197
+ const fn = (props) => {
198
+ if ((props === null || props === void 0 ? void 0 : props.transaction) !== void 0 && props.transaction === lastTransaction) return;
199
+ lastTransaction = props === null || props === void 0 ? void 0 : props.transaction;
200
+ this.transactionNumber += 1;
201
+ this.subscribers.forEach((callback) => callback());
202
+ };
203
+ const currentEditor = this.editor;
204
+ currentEditor.on("transaction", fn);
205
+ currentEditor.on("update", fn);
206
+ return () => {
207
+ currentEditor.off("transaction", fn);
208
+ currentEditor.off("update", fn);
209
+ };
210
+ }
211
+ }
233
212
  };
213
+ /**
214
+ * This hook allows you to watch for changes on the editor instance.
215
+ * It will allow you to select a part of the editor state and re-render the component when it changes.
216
+ * @example
217
+ * ```tsx
218
+ * const editor = useEditor({...options})
219
+ * const { currentSelection } = useEditorState({
220
+ * editor,
221
+ * selector: snapshot => ({ currentSelection: snapshot.editor.state.selection }),
222
+ * })
223
+ */
234
224
  function useEditorState(options) {
235
- var _a;
236
- const [editorStateManager] = useState(() => new EditorStateManager(options.editor));
237
- const selectedState = useSyncExternalStoreWithSelector(
238
- editorStateManager.subscribe,
239
- editorStateManager.getSnapshot,
240
- editorStateManager.getServerSnapshot,
241
- options.selector,
242
- (_a = options.equalityFn) != null ? _a : deepEqual
243
- );
244
- useIsomorphicLayoutEffect(() => {
245
- return editorStateManager.watch(options.editor);
246
- }, [options.editor, editorStateManager]);
247
- useDebugValue(selectedState);
248
- return selectedState;
225
+ var _options$equalityFn;
226
+ const [editorStateManager] = useState(() => new EditorStateManager(options.editor));
227
+ const selectedState = useSyncExternalStoreWithSelector(editorStateManager.subscribe, editorStateManager.getSnapshot, editorStateManager.getServerSnapshot, options.selector, (_options$equalityFn = options.equalityFn) !== null && _options$equalityFn !== void 0 ? _options$equalityFn : deepEqual);
228
+ useIsomorphicLayoutEffect(() => {
229
+ return editorStateManager.watch(options.editor);
230
+ }, [options.editor, editorStateManager]);
231
+ useDebugValue(selectedState);
232
+ return selectedState;
249
233
  }
250
-
251
- // src/useEditor.ts
252
- var isDev = process.env.NODE_ENV !== "production";
253
- var isSSR = typeof window === "undefined";
254
- var isNext = isSSR || Boolean(typeof window !== "undefined" && window.next);
255
- var EditorInstanceManager = class _EditorInstanceManager {
256
- constructor(options) {
257
- /**
258
- * The current editor instance.
259
- */
260
- this.editor = null;
261
- /**
262
- * The subscriptions to notify when the editor instance
263
- * has been created or destroyed.
264
- */
265
- this.subscriptions = /* @__PURE__ */ new Set();
266
- /**
267
- * Whether the editor has been mounted.
268
- */
269
- this.isComponentMounted = false;
270
- /**
271
- * The most recent dependencies array.
272
- */
273
- this.previousDeps = null;
274
- /**
275
- * The unique instance ID. This is used to identify the editor instance. And will be re-generated for each new instance.
276
- */
277
- this.instanceId = "";
278
- this.options = options;
279
- this.subscriptions = /* @__PURE__ */ new Set();
280
- this.setEditor(this.getInitialEditor());
281
- this.scheduleDestroy();
282
- this.getEditor = this.getEditor.bind(this);
283
- this.getServerSnapshot = this.getServerSnapshot.bind(this);
284
- this.subscribe = this.subscribe.bind(this);
285
- this.refreshEditorInstance = this.refreshEditorInstance.bind(this);
286
- this.scheduleDestroy = this.scheduleDestroy.bind(this);
287
- this.onRender = this.onRender.bind(this);
288
- this.createEditor = this.createEditor.bind(this);
289
- }
290
- setEditor(editor) {
291
- this.editor = editor;
292
- this.instanceId = Math.random().toString(36).slice(2, 9);
293
- this.subscriptions.forEach((cb) => cb());
294
- }
295
- getInitialEditor() {
296
- if (this.options.current.immediatelyRender === void 0) {
297
- if (isSSR || isNext) {
298
- if (isDev) {
299
- throw new Error(
300
- "Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."
301
- );
302
- }
303
- return null;
304
- }
305
- return this.createEditor();
306
- }
307
- if (this.options.current.immediatelyRender && isSSR && isDev) {
308
- throw new Error(
309
- "Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches."
310
- );
311
- }
312
- if (this.options.current.immediatelyRender) {
313
- return this.createEditor();
314
- }
315
- return null;
316
- }
317
- /**
318
- * Create a new editor instance. And attach event listeners.
319
- */
320
- createEditor() {
321
- const optionsToApply = {
322
- ...this.options.current,
323
- // Always call the most recent version of the callback function by default
324
- onBeforeCreate: (...args) => {
325
- var _a, _b;
326
- return (_b = (_a = this.options.current).onBeforeCreate) == null ? void 0 : _b.call(_a, ...args);
327
- },
328
- onBlur: (...args) => {
329
- var _a, _b;
330
- return (_b = (_a = this.options.current).onBlur) == null ? void 0 : _b.call(_a, ...args);
331
- },
332
- onCreate: (...args) => {
333
- var _a, _b;
334
- return (_b = (_a = this.options.current).onCreate) == null ? void 0 : _b.call(_a, ...args);
335
- },
336
- onDestroy: (...args) => {
337
- var _a, _b;
338
- return (_b = (_a = this.options.current).onDestroy) == null ? void 0 : _b.call(_a, ...args);
339
- },
340
- onFocus: (...args) => {
341
- var _a, _b;
342
- return (_b = (_a = this.options.current).onFocus) == null ? void 0 : _b.call(_a, ...args);
343
- },
344
- onSelectionUpdate: (...args) => {
345
- var _a, _b;
346
- return (_b = (_a = this.options.current).onSelectionUpdate) == null ? void 0 : _b.call(_a, ...args);
347
- },
348
- onTransaction: (...args) => {
349
- var _a, _b;
350
- return (_b = (_a = this.options.current).onTransaction) == null ? void 0 : _b.call(_a, ...args);
351
- },
352
- onUpdate: (...args) => {
353
- var _a, _b;
354
- return (_b = (_a = this.options.current).onUpdate) == null ? void 0 : _b.call(_a, ...args);
355
- },
356
- onContentError: (...args) => {
357
- var _a, _b;
358
- return (_b = (_a = this.options.current).onContentError) == null ? void 0 : _b.call(_a, ...args);
359
- },
360
- onDrop: (...args) => {
361
- var _a, _b;
362
- return (_b = (_a = this.options.current).onDrop) == null ? void 0 : _b.call(_a, ...args);
363
- },
364
- onPaste: (...args) => {
365
- var _a, _b;
366
- return (_b = (_a = this.options.current).onPaste) == null ? void 0 : _b.call(_a, ...args);
367
- },
368
- onDelete: (...args) => {
369
- var _a, _b;
370
- return (_b = (_a = this.options.current).onDelete) == null ? void 0 : _b.call(_a, ...args);
371
- }
372
- };
373
- const editor = new Editor(optionsToApply);
374
- return editor;
375
- }
376
- /**
377
- * Get the current editor instance.
378
- */
379
- getEditor() {
380
- return this.editor;
381
- }
382
- /**
383
- * Always disable the editor on the server-side.
384
- */
385
- getServerSnapshot() {
386
- return null;
387
- }
388
- /**
389
- * Subscribe to the editor instance's changes.
390
- */
391
- subscribe(onStoreChange) {
392
- this.subscriptions.add(onStoreChange);
393
- return () => {
394
- this.subscriptions.delete(onStoreChange);
395
- };
396
- }
397
- static compareOptions(a, b) {
398
- return Object.keys(a).every((key) => {
399
- if ([
400
- "onCreate",
401
- "onBeforeCreate",
402
- "onDestroy",
403
- "onUpdate",
404
- "onTransaction",
405
- "onFocus",
406
- "onBlur",
407
- "onSelectionUpdate",
408
- "onContentError",
409
- "onDrop",
410
- "onPaste"
411
- ].includes(key)) {
412
- return true;
413
- }
414
- if (key === "extensions" && a.extensions && b.extensions) {
415
- if (a.extensions.length !== b.extensions.length) {
416
- return false;
417
- }
418
- return a.extensions.every((extension, index) => {
419
- var _a;
420
- if (extension !== ((_a = b.extensions) == null ? void 0 : _a[index])) {
421
- return false;
422
- }
423
- return true;
424
- });
425
- }
426
- if (a[key] !== b[key]) {
427
- return false;
428
- }
429
- return true;
430
- });
431
- }
432
- /**
433
- * On each render, we will create, update, or destroy the editor instance.
434
- * @param deps The dependencies to watch for changes
435
- * @returns A cleanup function
436
- */
437
- onRender(deps) {
438
- return () => {
439
- this.isComponentMounted = true;
440
- clearTimeout(this.scheduledDestructionTimeout);
441
- if (this.editor && !this.editor.isDestroyed && deps.length === 0) {
442
- if (!_EditorInstanceManager.compareOptions(this.options.current, this.editor.options)) {
443
- this.editor.setOptions({
444
- ...this.options.current,
445
- editable: this.editor.isEditable
446
- });
447
- }
448
- } else {
449
- this.refreshEditorInstance(deps);
450
- }
451
- return () => {
452
- this.isComponentMounted = false;
453
- this.scheduleDestroy();
454
- };
455
- };
456
- }
457
- /**
458
- * Recreate the editor instance if the dependencies have changed.
459
- */
460
- refreshEditorInstance(deps) {
461
- if (this.editor && !this.editor.isDestroyed) {
462
- if (this.previousDeps === null) {
463
- this.previousDeps = deps;
464
- return;
465
- }
466
- const depsAreEqual = this.previousDeps.length === deps.length && this.previousDeps.every((dep, index) => dep === deps[index]);
467
- if (depsAreEqual) {
468
- return;
469
- }
470
- }
471
- if (this.editor && !this.editor.isDestroyed) {
472
- this.editor.destroy();
473
- }
474
- this.setEditor(this.createEditor());
475
- this.previousDeps = deps;
476
- }
477
- /**
478
- * Schedule the destruction of the editor instance.
479
- * This will only destroy the editor if it was not mounted on the next tick.
480
- * This is to avoid destroying the editor instance when it's actually still mounted.
481
- */
482
- scheduleDestroy() {
483
- const currentInstanceId = this.instanceId;
484
- const currentEditor = this.editor;
485
- this.scheduledDestructionTimeout = setTimeout(() => {
486
- if (this.isComponentMounted && this.instanceId === currentInstanceId) {
487
- if (currentEditor) {
488
- currentEditor.setOptions(this.options.current);
489
- }
490
- return;
491
- }
492
- if (currentEditor && !currentEditor.isDestroyed) {
493
- currentEditor.destroy();
494
- if (this.instanceId === currentInstanceId) {
495
- this.setEditor(null);
496
- }
497
- }
498
- }, 1);
499
- }
234
+ //#endregion
235
+ //#region src/useEditor.ts
236
+ const isDev = process.env.NODE_ENV !== "production";
237
+ const isSSR = typeof window === "undefined";
238
+ const isNext = isSSR || Boolean(typeof window !== "undefined" && window.next);
239
+ /**
240
+ * This class handles the creation, destruction, and re-creation of the editor instance.
241
+ */
242
+ var EditorInstanceManager = class EditorInstanceManager {
243
+ constructor(options) {
244
+ this.editor = null;
245
+ this.subscriptions = /* @__PURE__ */ new Set();
246
+ this.isComponentMounted = false;
247
+ this.previousDeps = null;
248
+ this.instanceId = "";
249
+ this.options = options;
250
+ this.subscriptions = /* @__PURE__ */ new Set();
251
+ this.setEditor(this.getInitialEditor());
252
+ this.scheduleDestroy();
253
+ this.getEditor = this.getEditor.bind(this);
254
+ this.getServerSnapshot = this.getServerSnapshot.bind(this);
255
+ this.subscribe = this.subscribe.bind(this);
256
+ this.refreshEditorInstance = this.refreshEditorInstance.bind(this);
257
+ this.scheduleDestroy = this.scheduleDestroy.bind(this);
258
+ this.onRender = this.onRender.bind(this);
259
+ this.createEditor = this.createEditor.bind(this);
260
+ }
261
+ setEditor(editor) {
262
+ this.editor = editor;
263
+ this.instanceId = Math.random().toString(36).slice(2, 9);
264
+ this.subscriptions.forEach((cb) => cb());
265
+ }
266
+ getInitialEditor() {
267
+ const explicit = this.options.current.immediatelyRender;
268
+ let immediatelyRender = explicit !== null && explicit !== void 0 ? explicit : true;
269
+ if (isSSR) {
270
+ if (immediatelyRender && isDev) console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches");
271
+ immediatelyRender = false;
272
+ } else if (isNext && explicit === void 0) {
273
+ immediatelyRender = false;
274
+ if (isDev) console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.");
275
+ }
276
+ return immediatelyRender ? this.createEditor() : null;
277
+ }
278
+ /**
279
+ * Create a new editor instance. And attach event listeners.
280
+ */
281
+ createEditor() {
282
+ const optionsToApply = {
283
+ ...this.options.current,
284
+ onBeforeCreate: (...args) => {
285
+ var _this$options$current, _this$options$current2;
286
+ return (_this$options$current = (_this$options$current2 = this.options.current).onBeforeCreate) === null || _this$options$current === void 0 ? void 0 : _this$options$current.call(_this$options$current2, ...args);
287
+ },
288
+ onBlur: (...args) => {
289
+ var _this$options$current3, _this$options$current4;
290
+ return (_this$options$current3 = (_this$options$current4 = this.options.current).onBlur) === null || _this$options$current3 === void 0 ? void 0 : _this$options$current3.call(_this$options$current4, ...args);
291
+ },
292
+ onCreate: (...args) => {
293
+ var _this$options$current5, _this$options$current6;
294
+ return (_this$options$current5 = (_this$options$current6 = this.options.current).onCreate) === null || _this$options$current5 === void 0 ? void 0 : _this$options$current5.call(_this$options$current6, ...args);
295
+ },
296
+ onDestroy: (...args) => {
297
+ var _this$options$current7, _this$options$current8;
298
+ return (_this$options$current7 = (_this$options$current8 = this.options.current).onDestroy) === null || _this$options$current7 === void 0 ? void 0 : _this$options$current7.call(_this$options$current8, ...args);
299
+ },
300
+ onFocus: (...args) => {
301
+ var _this$options$current9, _this$options$current10;
302
+ return (_this$options$current9 = (_this$options$current10 = this.options.current).onFocus) === null || _this$options$current9 === void 0 ? void 0 : _this$options$current9.call(_this$options$current10, ...args);
303
+ },
304
+ onSelectionUpdate: (...args) => {
305
+ var _this$options$current11, _this$options$current12;
306
+ return (_this$options$current11 = (_this$options$current12 = this.options.current).onSelectionUpdate) === null || _this$options$current11 === void 0 ? void 0 : _this$options$current11.call(_this$options$current12, ...args);
307
+ },
308
+ onTransaction: (...args) => {
309
+ var _this$options$current13, _this$options$current14;
310
+ return (_this$options$current13 = (_this$options$current14 = this.options.current).onTransaction) === null || _this$options$current13 === void 0 ? void 0 : _this$options$current13.call(_this$options$current14, ...args);
311
+ },
312
+ onUpdate: (...args) => {
313
+ var _this$options$current15, _this$options$current16;
314
+ return (_this$options$current15 = (_this$options$current16 = this.options.current).onUpdate) === null || _this$options$current15 === void 0 ? void 0 : _this$options$current15.call(_this$options$current16, ...args);
315
+ },
316
+ onContentError: (...args) => {
317
+ var _this$options$current17, _this$options$current18;
318
+ return (_this$options$current17 = (_this$options$current18 = this.options.current).onContentError) === null || _this$options$current17 === void 0 ? void 0 : _this$options$current17.call(_this$options$current18, ...args);
319
+ },
320
+ onDrop: (...args) => {
321
+ var _this$options$current19, _this$options$current20;
322
+ return (_this$options$current19 = (_this$options$current20 = this.options.current).onDrop) === null || _this$options$current19 === void 0 ? void 0 : _this$options$current19.call(_this$options$current20, ...args);
323
+ },
324
+ onPaste: (...args) => {
325
+ var _this$options$current21, _this$options$current22;
326
+ return (_this$options$current21 = (_this$options$current22 = this.options.current).onPaste) === null || _this$options$current21 === void 0 ? void 0 : _this$options$current21.call(_this$options$current22, ...args);
327
+ },
328
+ onDelete: (...args) => {
329
+ var _this$options$current23, _this$options$current24;
330
+ return (_this$options$current23 = (_this$options$current24 = this.options.current).onDelete) === null || _this$options$current23 === void 0 ? void 0 : _this$options$current23.call(_this$options$current24, ...args);
331
+ },
332
+ onMount: (...args) => {
333
+ var _this$options$current25, _this$options$current26;
334
+ return (_this$options$current25 = (_this$options$current26 = this.options.current).onMount) === null || _this$options$current25 === void 0 ? void 0 : _this$options$current25.call(_this$options$current26, ...args);
335
+ },
336
+ onUnmount: (...args) => {
337
+ var _this$options$current27, _this$options$current28;
338
+ return (_this$options$current27 = (_this$options$current28 = this.options.current).onUnmount) === null || _this$options$current27 === void 0 ? void 0 : _this$options$current27.call(_this$options$current28, ...args);
339
+ }
340
+ };
341
+ return new Editor(optionsToApply);
342
+ }
343
+ /**
344
+ * Get the current editor instance.
345
+ */
346
+ getEditor() {
347
+ return this.editor;
348
+ }
349
+ /**
350
+ * Always disable the editor on the server-side.
351
+ */
352
+ getServerSnapshot() {
353
+ return null;
354
+ }
355
+ /**
356
+ * Subscribe to the editor instance's changes.
357
+ */
358
+ subscribe(onStoreChange) {
359
+ this.subscriptions.add(onStoreChange);
360
+ return () => {
361
+ this.subscriptions.delete(onStoreChange);
362
+ };
363
+ }
364
+ static compareOptions(a, b) {
365
+ return Object.keys(a).every((key) => {
366
+ if ([
367
+ "onCreate",
368
+ "onBeforeCreate",
369
+ "onDestroy",
370
+ "onUpdate",
371
+ "onTransaction",
372
+ "onFocus",
373
+ "onBlur",
374
+ "onSelectionUpdate",
375
+ "onContentError",
376
+ "onDrop",
377
+ "onPaste"
378
+ ].includes(key)) return true;
379
+ if (key === "extensions" && a.extensions && b.extensions) {
380
+ if (a.extensions.length !== b.extensions.length) return false;
381
+ return a.extensions.every((extension, index) => {
382
+ var _b$extensions;
383
+ if (extension !== ((_b$extensions = b.extensions) === null || _b$extensions === void 0 ? void 0 : _b$extensions[index])) return false;
384
+ return true;
385
+ });
386
+ }
387
+ if (a[key] !== b[key]) return false;
388
+ return true;
389
+ });
390
+ }
391
+ /**
392
+ * On each render, we will create, update, or destroy the editor instance.
393
+ * @param deps The dependencies to watch for changes
394
+ * @returns A cleanup function
395
+ */
396
+ onRender(deps) {
397
+ return () => {
398
+ this.isComponentMounted = true;
399
+ clearTimeout(this.scheduledDestructionTimeout);
400
+ if (this.editor && !this.editor.isDestroyed && deps.length === 0) {
401
+ if (!EditorInstanceManager.compareOptions(this.options.current, this.editor.options)) this.editor.setOptions({
402
+ ...this.options.current,
403
+ editable: this.editor.isEditable
404
+ });
405
+ } else this.refreshEditorInstance(deps);
406
+ return () => {
407
+ this.isComponentMounted = false;
408
+ this.scheduleDestroy();
409
+ };
410
+ };
411
+ }
412
+ /**
413
+ * Recreate the editor instance if the dependencies have changed.
414
+ */
415
+ refreshEditorInstance(deps) {
416
+ if (this.editor && !this.editor.isDestroyed) {
417
+ if (this.previousDeps === null) {
418
+ this.previousDeps = deps;
419
+ return;
420
+ }
421
+ if (this.previousDeps.length === deps.length && this.previousDeps.every((dep, index) => dep === deps[index])) return;
422
+ }
423
+ if (this.editor && !this.editor.isDestroyed) this.editor.destroy();
424
+ this.setEditor(this.createEditor());
425
+ this.previousDeps = deps;
426
+ }
427
+ /**
428
+ * Schedule the destruction of the editor instance.
429
+ * This will only destroy the editor if it was not mounted on the next tick.
430
+ * This is to avoid destroying the editor instance when it's actually still mounted.
431
+ */
432
+ scheduleDestroy() {
433
+ const currentInstanceId = this.instanceId;
434
+ const currentEditor = this.editor;
435
+ this.scheduledDestructionTimeout = setTimeout(() => {
436
+ if (this.isComponentMounted && this.instanceId === currentInstanceId) {
437
+ if (currentEditor) currentEditor.setOptions(this.options.current);
438
+ return;
439
+ }
440
+ if (currentEditor && !currentEditor.isDestroyed) {
441
+ currentEditor.destroy();
442
+ if (this.instanceId === currentInstanceId) this.setEditor(null);
443
+ }
444
+ }, 1);
445
+ }
500
446
  };
501
447
  function useEditor(options = {}, deps = []) {
502
- const mostRecentOptions = useRef(options);
503
- mostRecentOptions.current = options;
504
- const [instanceManager] = useState2(() => new EditorInstanceManager(mostRecentOptions));
505
- const editor = useSyncExternalStore2(
506
- instanceManager.subscribe,
507
- instanceManager.getEditor,
508
- instanceManager.getServerSnapshot
509
- );
510
- useDebugValue2(editor);
511
- useEffect2(instanceManager.onRender(deps));
512
- useEditorState({
513
- editor,
514
- selector: ({ transactionNumber }) => {
515
- if (options.shouldRerenderOnTransaction === false || options.shouldRerenderOnTransaction === void 0) {
516
- return null;
517
- }
518
- if (options.immediatelyRender && transactionNumber === 0) {
519
- return 0;
520
- }
521
- return transactionNumber + 1;
522
- }
523
- });
524
- return editor;
448
+ const mostRecentOptions = useRef(options);
449
+ mostRecentOptions.current = options;
450
+ const [instanceManager] = useState(() => new EditorInstanceManager(mostRecentOptions));
451
+ const editor = useSyncExternalStore(instanceManager.subscribe, instanceManager.getEditor, instanceManager.getServerSnapshot);
452
+ useDebugValue(editor);
453
+ useEffect(instanceManager.onRender(deps));
454
+ useEditorState({
455
+ editor,
456
+ selector: ({ transactionNumber }) => {
457
+ if (options.shouldRerenderOnTransaction === false || options.shouldRerenderOnTransaction === void 0) return null;
458
+ if (options.immediatelyRender && transactionNumber === 0) return 0;
459
+ return transactionNumber + 1;
460
+ }
461
+ });
462
+ return editor;
525
463
  }
526
-
527
- // src/Context.tsx
528
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
529
- var EditorContext = createContext({
530
- editor: null
531
- });
532
- var EditorConsumer = EditorContext.Consumer;
533
- var useCurrentEditor = () => useContext(EditorContext);
534
- function EditorProvider({
535
- children,
536
- slotAfter,
537
- slotBefore,
538
- editorContainerProps = {},
539
- ...editorOptions
540
- }) {
541
- const editor = useEditor(editorOptions);
542
- const contextValue = useMemo(() => ({ editor }), [editor]);
543
- if (!editor) {
544
- return null;
545
- }
546
- return /* @__PURE__ */ jsxs2(EditorContext.Provider, { value: contextValue, children: [
547
- slotBefore,
548
- /* @__PURE__ */ jsx2(EditorConsumer, { children: ({ editor: currentEditor }) => /* @__PURE__ */ jsx2(EditorContent, { editor: currentEditor, ...editorContainerProps }) }),
549
- children,
550
- slotAfter
551
- ] });
464
+ //#endregion
465
+ //#region src/Context.tsx
466
+ const EditorContext = createContext({ editor: null });
467
+ const EditorConsumer = EditorContext.Consumer;
468
+ /**
469
+ * A hook to get the current editor instance.
470
+ */
471
+ const useCurrentEditor = () => useContext(EditorContext);
472
+ /**
473
+ * This is the provider component for the editor.
474
+ * It allows the editor to be accessible across the entire component tree
475
+ * with `useCurrentEditor`.
476
+ */
477
+ function EditorProvider({ children, slotAfter, slotBefore, editorContainerProps = {}, ...editorOptions }) {
478
+ const editor = useEditor(editorOptions);
479
+ const contextValue = useMemo(() => ({ editor }), [editor]);
480
+ if (!editor) return null;
481
+ return /* @__PURE__ */ jsxs(EditorContext.Provider, {
482
+ value: contextValue,
483
+ children: [
484
+ slotBefore,
485
+ /* @__PURE__ */ jsx(EditorConsumer, { children: ({ editor: currentEditor }) => /* @__PURE__ */ jsx(EditorContent, {
486
+ editor: currentEditor,
487
+ ...editorContainerProps
488
+ }) }),
489
+ children,
490
+ slotAfter
491
+ ]
492
+ });
552
493
  }
553
-
554
- // src/useReactNodeView.ts
555
- import { createContext as createContext2, createElement, useContext as useContext2 } from "react";
556
- var ReactNodeViewContext = createContext2({
557
- onDragStart: () => {
558
- },
559
- nodeViewContentChildren: void 0,
560
- nodeViewContentRef: () => {
561
- }
494
+ //#endregion
495
+ //#region src/useReactNodeView.ts
496
+ const ReactNodeViewContext = createContext({
497
+ onDragStart: () => {},
498
+ nodeViewContentChildren: void 0,
499
+ nodeViewContentRef: () => {}
562
500
  });
563
- var ReactNodeViewContentProvider = ({ children, content }) => {
564
- return createElement(ReactNodeViewContext.Provider, { value: { nodeViewContentChildren: content } }, children);
501
+ const ReactNodeViewContentProvider = ({ children, content }) => {
502
+ return createElement(ReactNodeViewContext.Provider, { value: { nodeViewContentChildren: content } }, children);
565
503
  };
566
- var useReactNodeView = () => useContext2(ReactNodeViewContext);
567
-
568
- // src/NodeViewContent.tsx
569
- import { jsx as jsx3 } from "react/jsx-runtime";
570
- function NodeViewContent({
571
- as: Tag = "div",
572
- ...props
573
- }) {
574
- const { nodeViewContentRef, nodeViewContentChildren } = useReactNodeView();
575
- return (
576
- // @ts-ignore
577
- /* @__PURE__ */ jsx3(
578
- Tag,
579
- {
580
- ...props,
581
- ref: nodeViewContentRef,
582
- "data-node-view-content": "",
583
- style: {
584
- whiteSpace: "pre-wrap",
585
- ...props.style
586
- },
587
- children: nodeViewContentChildren
588
- }
589
- )
590
- );
504
+ const useReactNodeView = () => useContext(ReactNodeViewContext);
505
+ //#endregion
506
+ //#region src/NodeViewContent.tsx
507
+ function NodeViewContent({ as: Tag = "div", ...props }) {
508
+ const { nodeViewContentRef, nodeViewContentChildren } = useReactNodeView();
509
+ return /* @__PURE__ */ jsx(Tag, {
510
+ ...props,
511
+ ref: nodeViewContentRef,
512
+ "data-node-view-content": "",
513
+ style: {
514
+ whiteSpace: "pre-wrap",
515
+ ...props.style
516
+ },
517
+ children: nodeViewContentChildren
518
+ });
591
519
  }
592
-
593
- // src/NodeViewWrapper.tsx
594
- import React3 from "react";
595
- import { jsx as jsx4 } from "react/jsx-runtime";
596
- var NodeViewWrapper = React3.forwardRef((props, ref) => {
597
- const { onDragStart } = useReactNodeView();
598
- const Tag = props.as || "div";
599
- return (
600
- // @ts-ignore
601
- /* @__PURE__ */ jsx4(
602
- Tag,
603
- {
604
- ...props,
605
- ref,
606
- "data-node-view-wrapper": "",
607
- onDragStart,
608
- style: {
609
- whiteSpace: "normal",
610
- ...props.style
611
- }
612
- }
613
- )
614
- );
520
+ //#endregion
521
+ //#region src/NodeViewWrapper.tsx
522
+ const NodeViewWrapper = React.forwardRef((props, ref) => {
523
+ const { onDragStart } = useReactNodeView();
524
+ const Tag = props.as || "div";
525
+ return /* @__PURE__ */ jsx(Tag, {
526
+ ...props,
527
+ ref,
528
+ "data-node-view-wrapper": "",
529
+ onDragStart,
530
+ style: {
531
+ whiteSpace: "normal",
532
+ ...props.style
533
+ }
534
+ });
615
535
  });
616
-
617
- // src/ReactMarkViewRenderer.tsx
618
- import { MarkView } from "@tiptap/core";
619
- import React4 from "react";
620
-
621
- // src/ReactRenderer.tsx
622
- import { version as reactVersion } from "react";
623
- import { flushSync } from "react-dom";
624
- import { jsx as jsx5 } from "react/jsx-runtime";
536
+ //#endregion
537
+ //#region src/ReactRenderer.tsx
538
+ /**
539
+ * Check if a component is a class component.
540
+ * @param Component
541
+ * @returns {boolean}
542
+ */
625
543
  function isClassComponent(Component) {
626
- return !!(typeof Component === "function" && Component.prototype && Component.prototype.isReactComponent);
544
+ return !!(typeof Component === "function" && Component.prototype && Component.prototype.isReactComponent);
627
545
  }
546
+ /**
547
+ * Check if a component is a forward ref component.
548
+ * @param Component
549
+ * @returns {boolean}
550
+ */
628
551
  function isForwardRefComponent(Component) {
629
- return !!(typeof Component === "object" && Component.$$typeof && (Component.$$typeof.toString() === "Symbol(react.forward_ref)" || Component.$$typeof.description === "react.forward_ref"));
552
+ return !!(typeof Component === "object" && Component.$$typeof && (Component.$$typeof.toString() === "Symbol(react.forward_ref)" || Component.$$typeof.description === "react.forward_ref"));
630
553
  }
554
+ /**
555
+ * Check if a component is a memoized component.
556
+ * @param Component
557
+ * @returns {boolean}
558
+ */
631
559
  function isMemoComponent(Component) {
632
- return !!(typeof Component === "object" && Component.$$typeof && (Component.$$typeof.toString() === "Symbol(react.memo)" || Component.$$typeof.description === "react.memo"));
560
+ return !!(typeof Component === "object" && Component.$$typeof && (Component.$$typeof.toString() === "Symbol(react.memo)" || Component.$$typeof.description === "react.memo"));
633
561
  }
562
+ /**
563
+ * Check if a component can safely receive a ref prop.
564
+ * This includes class components, forwardRef components, and memoized components
565
+ * that wrap forwardRef or class components.
566
+ * @param Component
567
+ * @returns {boolean}
568
+ */
634
569
  function canReceiveRef(Component) {
635
- if (isClassComponent(Component)) {
636
- return true;
637
- }
638
- if (isForwardRefComponent(Component)) {
639
- return true;
640
- }
641
- if (isMemoComponent(Component)) {
642
- const wrappedComponent = Component.type;
643
- if (wrappedComponent) {
644
- return isClassComponent(wrappedComponent) || isForwardRefComponent(wrappedComponent);
645
- }
646
- }
647
- return false;
570
+ if (isClassComponent(Component)) return true;
571
+ if (isForwardRefComponent(Component)) return true;
572
+ if (isMemoComponent(Component)) {
573
+ const wrappedComponent = Component.type;
574
+ if (wrappedComponent) return isClassComponent(wrappedComponent) || isForwardRefComponent(wrappedComponent);
575
+ }
576
+ return false;
648
577
  }
578
+ /**
579
+ * Check if we're running React 19+ by detecting if function components support ref props
580
+ * @returns {boolean}
581
+ */
649
582
  function isReact19Plus() {
650
- try {
651
- if (reactVersion) {
652
- const majorVersion = parseInt(reactVersion.split(".")[0], 10);
653
- return majorVersion >= 19;
654
- }
655
- } catch {
656
- }
657
- return false;
583
+ try {
584
+ if (version) return parseInt(version.split(".")[0], 10) >= 19;
585
+ } catch {}
586
+ return false;
658
587
  }
588
+ /**
589
+ * The ReactRenderer class. It's responsible for rendering React components inside the editor.
590
+ * @example
591
+ * new ReactRenderer(MyComponent, {
592
+ * editor,
593
+ * props: {
594
+ * foo: 'bar',
595
+ * },
596
+ * as: 'span',
597
+ * })
598
+ */
659
599
  var ReactRenderer = class {
660
- /**
661
- * Immediately creates element and renders the provided React component.
662
- */
663
- constructor(component, { editor, props = {}, as = "div", className = "" }) {
664
- this.ref = null;
665
- /**
666
- * Flag to track if the renderer has been destroyed, preventing queued or asynchronous renders from executing after teardown.
667
- */
668
- this.destroyed = false;
669
- this.id = Math.floor(Math.random() * 4294967295).toString();
670
- this.component = component;
671
- this.editor = editor;
672
- this.props = props;
673
- this.element = document.createElement(as);
674
- this.element.classList.add("react-renderer");
675
- if (className) {
676
- this.element.classList.add(...className.split(" "));
677
- }
678
- if (this.editor.isInitialized) {
679
- flushSync(() => {
680
- this.render();
681
- });
682
- } else {
683
- queueMicrotask(() => {
684
- if (this.destroyed) {
685
- return;
686
- }
687
- this.render();
688
- });
689
- }
690
- }
691
- /**
692
- * Render the React component.
693
- */
694
- render() {
695
- var _a;
696
- if (this.destroyed) {
697
- return;
698
- }
699
- const Component = this.component;
700
- const props = this.props;
701
- const editor = this.editor;
702
- const isReact19 = isReact19Plus();
703
- const componentCanReceiveRef = canReceiveRef(Component);
704
- const elementProps = { ...props };
705
- if (elementProps.ref && !(isReact19 || componentCanReceiveRef)) {
706
- delete elementProps.ref;
707
- }
708
- if (!elementProps.ref && (isReact19 || componentCanReceiveRef)) {
709
- elementProps.ref = (ref) => {
710
- this.ref = ref;
711
- };
712
- }
713
- this.reactElement = /* @__PURE__ */ jsx5(Component, { ...elementProps });
714
- (_a = editor == null ? void 0 : editor.contentComponent) == null ? void 0 : _a.setRenderer(this.id, this);
715
- }
716
- /**
717
- * Re-renders the React component with new props.
718
- */
719
- updateProps(props = {}) {
720
- if (this.destroyed) {
721
- return;
722
- }
723
- this.props = {
724
- ...this.props,
725
- ...props
726
- };
727
- this.render();
728
- }
729
- /**
730
- * Destroy the React component.
731
- */
732
- destroy() {
733
- var _a;
734
- this.destroyed = true;
735
- const editor = this.editor;
736
- (_a = editor == null ? void 0 : editor.contentComponent) == null ? void 0 : _a.removeRenderer(this.id);
737
- try {
738
- if (this.element && this.element.parentNode) {
739
- this.element.parentNode.removeChild(this.element);
740
- }
741
- } catch {
742
- }
743
- }
744
- /**
745
- * Update the attributes of the element that holds the React component.
746
- */
747
- updateAttributes(attributes) {
748
- Object.keys(attributes).forEach((key) => {
749
- this.element.setAttribute(key, attributes[key]);
750
- });
751
- }
600
+ /**
601
+ * Immediately creates element and renders the provided React component.
602
+ */
603
+ constructor(component, { editor, props = {}, as = "div", className = "" }) {
604
+ this.ref = null;
605
+ this.destroyed = false;
606
+ this.id = Math.floor(Math.random() * 4294967295).toString();
607
+ this.component = component;
608
+ this.editor = editor;
609
+ this.props = props;
610
+ this.element = document.createElement(as);
611
+ this.element.classList.add("react-renderer");
612
+ if (className) this.element.classList.add(...className.split(" "));
613
+ if (this.editor.isEditorContentInitialized) flushSync(() => {
614
+ this.render();
615
+ });
616
+ else queueMicrotask(() => {
617
+ if (this.destroyed) return;
618
+ this.render();
619
+ });
620
+ }
621
+ /**
622
+ * Render the React component.
623
+ */
624
+ render() {
625
+ var _editor$contentCompon;
626
+ if (this.destroyed) return;
627
+ const Component = this.component;
628
+ const props = this.props;
629
+ const editor = this.editor;
630
+ const isReact19 = isReact19Plus();
631
+ const componentCanReceiveRef = canReceiveRef(Component);
632
+ const elementProps = { ...props };
633
+ if (elementProps.ref && !(isReact19 || componentCanReceiveRef)) delete elementProps.ref;
634
+ if (!elementProps.ref && (isReact19 || componentCanReceiveRef)) elementProps.ref = (ref) => {
635
+ this.ref = ref;
636
+ };
637
+ this.reactElement = /* @__PURE__ */ jsx(Component, { ...elementProps });
638
+ editor === null || editor === void 0 || (_editor$contentCompon = editor.contentComponent) === null || _editor$contentCompon === void 0 || _editor$contentCompon.setRenderer(this.id, this);
639
+ }
640
+ /**
641
+ * Re-renders the React component with new props.
642
+ * Skips the render if none of the supplied props actually changed,
643
+ * to avoid unnecessary portal re-creation.
644
+ */
645
+ updateProps(props = {}) {
646
+ if (this.destroyed) return;
647
+ let changed = false;
648
+ const keys = Object.keys(props);
649
+ for (let i = 0; i < keys.length; i += 1) {
650
+ const key = keys[i];
651
+ if (props[key] !== this.props[key]) {
652
+ changed = true;
653
+ break;
654
+ }
655
+ }
656
+ if (!changed) return;
657
+ this.props = {
658
+ ...this.props,
659
+ ...props
660
+ };
661
+ this.render();
662
+ }
663
+ /**
664
+ * Destroy the React component.
665
+ */
666
+ destroy() {
667
+ var _editor$contentCompon2;
668
+ this.destroyed = true;
669
+ const editor = this.editor;
670
+ editor === null || editor === void 0 || (_editor$contentCompon2 = editor.contentComponent) === null || _editor$contentCompon2 === void 0 || _editor$contentCompon2.removeRenderer(this.id);
671
+ try {
672
+ if (this.element && this.element.parentNode) this.element.parentNode.removeChild(this.element);
673
+ } catch {}
674
+ }
675
+ /**
676
+ * Update the attributes of the element that holds the React component.
677
+ */
678
+ updateAttributes(attributes) {
679
+ Object.keys(attributes).forEach((key) => {
680
+ this.element.setAttribute(key, attributes[key]);
681
+ });
682
+ }
752
683
  };
753
-
754
- // src/ReactMarkViewRenderer.tsx
755
- import { jsx as jsx6 } from "react/jsx-runtime";
756
- var ReactMarkViewContext = React4.createContext({
757
- markViewContentRef: () => {
758
- }
759
- });
760
- var MarkViewContent = (props) => {
761
- const { as: Tag = "span", ...rest } = props;
762
- const { markViewContentRef } = React4.useContext(ReactMarkViewContext);
763
- return (
764
- // @ts-ignore
765
- /* @__PURE__ */ jsx6(Tag, { ...rest, ref: markViewContentRef, "data-mark-view-content": "" })
766
- );
684
+ //#endregion
685
+ //#region src/ReactMarkViewRenderer.tsx
686
+ const ReactMarkViewContext = React.createContext({ markViewContentRef: () => {} });
687
+ const MarkViewContent = (props) => {
688
+ const { as: Tag = "span", ...rest } = props;
689
+ const { markViewContentRef } = React.useContext(ReactMarkViewContext);
690
+ return /* @__PURE__ */ jsx(Tag, {
691
+ ...rest,
692
+ ref: markViewContentRef,
693
+ "data-mark-view-content": ""
694
+ });
767
695
  };
768
696
  var ReactMarkView = class extends MarkView {
769
- constructor(component, props, options) {
770
- super(component, props, options);
771
- const { as = "span", attrs, className = "" } = options || {};
772
- const componentProps = { ...props, updateAttributes: this.updateAttributes.bind(this) };
773
- this.contentDOMElement = document.createElement("span");
774
- const markViewContentRef = (el) => {
775
- if (el && !el.contains(this.contentDOMElement)) {
776
- el.appendChild(this.contentDOMElement);
777
- }
778
- };
779
- const context = {
780
- markViewContentRef
781
- };
782
- const ReactMarkViewProvider = React4.memo((componentProps2) => {
783
- return /* @__PURE__ */ jsx6(ReactMarkViewContext.Provider, { value: context, children: React4.createElement(component, componentProps2) });
784
- });
785
- ReactMarkViewProvider.displayName = "ReactMarkView";
786
- this.renderer = new ReactRenderer(ReactMarkViewProvider, {
787
- editor: props.editor,
788
- props: componentProps,
789
- as,
790
- className: `mark-${props.mark.type.name} ${className}`.trim()
791
- });
792
- if (attrs) {
793
- this.renderer.updateAttributes(attrs);
794
- }
795
- }
796
- get dom() {
797
- return this.renderer.element;
798
- }
799
- get contentDOM() {
800
- return this.contentDOMElement;
801
- }
697
+ constructor(component, props, options) {
698
+ super(component, props, options);
699
+ const { as = "span", attrs, className = "" } = options || {};
700
+ const componentProps = {
701
+ ...props,
702
+ updateAttributes: this.updateAttributes.bind(this)
703
+ };
704
+ this.contentDOMElement = document.createElement("span");
705
+ const markViewContentRef = (el) => {
706
+ if (el && !el.contains(this.contentDOMElement)) el.appendChild(this.contentDOMElement);
707
+ };
708
+ const context = { markViewContentRef };
709
+ const ReactMarkViewProvider = React.memo((componentProps) => {
710
+ return /* @__PURE__ */ jsx(ReactMarkViewContext.Provider, {
711
+ value: context,
712
+ children: React.createElement(component, componentProps)
713
+ });
714
+ });
715
+ ReactMarkViewProvider.displayName = "ReactMarkView";
716
+ this.renderer = new ReactRenderer(ReactMarkViewProvider, {
717
+ editor: props.editor,
718
+ props: componentProps,
719
+ as,
720
+ className: `mark-${props.mark.type.name} ${className}`.trim()
721
+ });
722
+ if (attrs) this.renderer.updateAttributes(attrs);
723
+ }
724
+ get dom() {
725
+ return this.renderer.element;
726
+ }
727
+ get contentDOM() {
728
+ return this.contentDOMElement;
729
+ }
802
730
  };
803
731
  function ReactMarkViewRenderer(component, options = {}) {
804
- return (props) => new ReactMarkView(component, props, options);
732
+ return (props) => new ReactMarkView(component, props, options);
805
733
  }
806
-
807
- // src/ReactNodeViewRenderer.tsx
808
- import { getRenderedAttributes, NodeView } from "@tiptap/core";
809
- import { createElement as createElement2, createRef, memo } from "react";
810
- import { jsx as jsx7 } from "react/jsx-runtime";
734
+ //#endregion
735
+ //#region src/captureDOMSelection.ts
736
+ /**
737
+ * Saves the DOM selection inside `element`, returns a function to put it back.
738
+ * Browsers drop the selection when an element moves, so restore it after the move.
739
+ */
740
+ function captureDOMSelection(element) {
741
+ var _element$ownerDocumen;
742
+ const root = element.getRootNode();
743
+ const selection = typeof root.getSelection === "function" ? root.getSelection() : (_element$ownerDocumen = element.ownerDocument) === null || _element$ownerDocumen === void 0 || (_element$ownerDocumen = _element$ownerDocumen.defaultView) === null || _element$ownerDocumen === void 0 ? void 0 : _element$ownerDocumen.getSelection();
744
+ if (!selection || selection.rangeCount === 0) return null;
745
+ const { anchorNode, anchorOffset, focusNode, focusOffset } = selection;
746
+ if (!anchorNode || !focusNode) return null;
747
+ if (!element.contains(anchorNode) || !element.contains(focusNode)) return null;
748
+ return () => {
749
+ try {
750
+ selection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
751
+ } catch {}
752
+ };
753
+ }
754
+ //#endregion
755
+ //#region src/ReactNodeViewRenderer.tsx
811
756
  var ReactNodeView = class extends NodeView {
812
- constructor(component, props, options) {
813
- super(component, props, options);
814
- /**
815
- * The requestAnimationFrame ID used for selection updates.
816
- */
817
- this.selectionRafId = null;
818
- this.cachedExtensionWithSyncedStorage = null;
819
- if (!this.node.isLeaf) {
820
- if (this.options.contentDOMElementTag) {
821
- this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
822
- } else {
823
- this.contentDOMElement = document.createElement(this.node.isInline ? "span" : "div");
824
- }
825
- this.contentDOMElement.dataset.nodeViewContentReact = "";
826
- this.contentDOMElement.dataset.nodeViewWrapper = "";
827
- this.contentDOMElement.style.whiteSpace = "inherit";
828
- const contentTarget = this.dom.querySelector("[data-node-view-content]");
829
- if (!contentTarget) {
830
- return;
831
- }
832
- contentTarget.appendChild(this.contentDOMElement);
833
- }
834
- }
835
- /**
836
- * Returns a proxy of the extension that redirects storage access to the editor's mutable storage.
837
- * This preserves the original prototype chain (instanceof checks, methods like configure/extend work).
838
- * Cached to avoid proxy creation on every update.
839
- */
840
- get extensionWithSyncedStorage() {
841
- if (!this.cachedExtensionWithSyncedStorage) {
842
- const editor = this.editor;
843
- const extension = this.extension;
844
- this.cachedExtensionWithSyncedStorage = new Proxy(extension, {
845
- get(target, prop, receiver) {
846
- var _a;
847
- if (prop === "storage") {
848
- return (_a = editor.storage[extension.name]) != null ? _a : {};
849
- }
850
- return Reflect.get(target, prop, receiver);
851
- }
852
- });
853
- }
854
- return this.cachedExtensionWithSyncedStorage;
855
- }
856
- /**
857
- * Setup the React component.
858
- * Called on initialization.
859
- */
860
- mount() {
861
- const props = {
862
- editor: this.editor,
863
- node: this.node,
864
- decorations: this.decorations,
865
- innerDecorations: this.innerDecorations,
866
- view: this.view,
867
- selected: false,
868
- extension: this.extensionWithSyncedStorage,
869
- HTMLAttributes: this.HTMLAttributes,
870
- getPos: () => this.getPos(),
871
- updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
872
- deleteNode: () => this.deleteNode(),
873
- ref: createRef()
874
- };
875
- if (!this.component.displayName) {
876
- const capitalizeFirstChar = (string) => {
877
- return string.charAt(0).toUpperCase() + string.substring(1);
878
- };
879
- this.component.displayName = capitalizeFirstChar(this.extension.name);
880
- }
881
- const onDragStart = this.onDragStart.bind(this);
882
- const nodeViewContentRef = (element) => {
883
- if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
884
- if (element.hasAttribute("data-node-view-wrapper")) {
885
- element.removeAttribute("data-node-view-wrapper");
886
- }
887
- element.appendChild(this.contentDOMElement);
888
- }
889
- };
890
- const context = { onDragStart, nodeViewContentRef };
891
- const Component = this.component;
892
- const ReactNodeViewProvider = memo((componentProps) => {
893
- return /* @__PURE__ */ jsx7(ReactNodeViewContext.Provider, { value: context, children: createElement2(Component, componentProps) });
894
- });
895
- ReactNodeViewProvider.displayName = "ReactNodeView";
896
- let as = this.node.isInline ? "span" : "div";
897
- if (this.options.as) {
898
- as = this.options.as;
899
- }
900
- const { className = "" } = this.options;
901
- this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this);
902
- this.renderer = new ReactRenderer(ReactNodeViewProvider, {
903
- editor: this.editor,
904
- props,
905
- as,
906
- className: `node-${this.node.type.name} ${className}`.trim()
907
- });
908
- this.editor.on("selectionUpdate", this.handleSelectionUpdate);
909
- this.updateElementAttributes();
910
- }
911
- /**
912
- * Return the DOM element.
913
- * This is the element that will be used to display the node view.
914
- */
915
- get dom() {
916
- var _a;
917
- if (this.renderer.element.firstElementChild && !((_a = this.renderer.element.firstElementChild) == null ? void 0 : _a.hasAttribute("data-node-view-wrapper"))) {
918
- throw Error("Please use the NodeViewWrapper component for your node view.");
919
- }
920
- return this.renderer.element;
921
- }
922
- /**
923
- * Return the content DOM element.
924
- * This is the element that will be used to display the rich-text content of the node.
925
- */
926
- get contentDOM() {
927
- if (this.node.isLeaf) {
928
- return null;
929
- }
930
- return this.contentDOMElement;
931
- }
932
- /**
933
- * On editor selection update, check if the node is selected.
934
- * If it is, call `selectNode`, otherwise call `deselectNode`.
935
- */
936
- handleSelectionUpdate() {
937
- if (this.selectionRafId) {
938
- cancelAnimationFrame(this.selectionRafId);
939
- this.selectionRafId = null;
940
- }
941
- this.selectionRafId = requestAnimationFrame(() => {
942
- this.selectionRafId = null;
943
- const { from, to } = this.editor.state.selection;
944
- const pos = this.getPos();
945
- if (typeof pos !== "number") {
946
- return;
947
- }
948
- if (from <= pos && to >= pos + this.node.nodeSize) {
949
- if (this.renderer.props.selected) {
950
- return;
951
- }
952
- this.selectNode();
953
- } else {
954
- if (!this.renderer.props.selected) {
955
- return;
956
- }
957
- this.deselectNode();
958
- }
959
- });
960
- }
961
- /**
962
- * On update, update the React component.
963
- * To prevent unnecessary updates, the `update` option can be used.
964
- */
965
- update(node, decorations, innerDecorations) {
966
- const rerenderComponent = (props) => {
967
- this.renderer.updateProps(props);
968
- if (typeof this.options.attrs === "function") {
969
- this.updateElementAttributes();
970
- }
971
- };
972
- if (node.type !== this.node.type) {
973
- return false;
974
- }
975
- if (typeof this.options.update === "function") {
976
- const oldNode = this.node;
977
- const oldDecorations = this.decorations;
978
- const oldInnerDecorations = this.innerDecorations;
979
- this.node = node;
980
- this.decorations = decorations;
981
- this.innerDecorations = innerDecorations;
982
- return this.options.update({
983
- oldNode,
984
- oldDecorations,
985
- newNode: node,
986
- newDecorations: decorations,
987
- oldInnerDecorations,
988
- innerDecorations,
989
- updateProps: () => rerenderComponent({ node, decorations, innerDecorations, extension: this.extensionWithSyncedStorage })
990
- });
991
- }
992
- if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {
993
- return true;
994
- }
995
- this.node = node;
996
- this.decorations = decorations;
997
- this.innerDecorations = innerDecorations;
998
- rerenderComponent({ node, decorations, innerDecorations, extension: this.extensionWithSyncedStorage });
999
- return true;
1000
- }
1001
- /**
1002
- * Select the node.
1003
- * Add the `selected` prop and the `ProseMirror-selectednode` class.
1004
- */
1005
- selectNode() {
1006
- this.renderer.updateProps({
1007
- selected: true
1008
- });
1009
- this.renderer.element.classList.add("ProseMirror-selectednode");
1010
- }
1011
- /**
1012
- * Deselect the node.
1013
- * Remove the `selected` prop and the `ProseMirror-selectednode` class.
1014
- */
1015
- deselectNode() {
1016
- this.renderer.updateProps({
1017
- selected: false
1018
- });
1019
- this.renderer.element.classList.remove("ProseMirror-selectednode");
1020
- }
1021
- /**
1022
- * Destroy the React component instance.
1023
- */
1024
- destroy() {
1025
- this.renderer.destroy();
1026
- this.editor.off("selectionUpdate", this.handleSelectionUpdate);
1027
- this.contentDOMElement = null;
1028
- if (this.selectionRafId) {
1029
- cancelAnimationFrame(this.selectionRafId);
1030
- this.selectionRafId = null;
1031
- }
1032
- }
1033
- /**
1034
- * Update the attributes of the top-level element that holds the React component.
1035
- * Applying the attributes defined in the `attrs` option.
1036
- */
1037
- updateElementAttributes() {
1038
- if (this.options.attrs) {
1039
- let attrsObj = {};
1040
- if (typeof this.options.attrs === "function") {
1041
- const extensionAttributes = this.editor.extensionManager.attributes;
1042
- const HTMLAttributes = getRenderedAttributes(this.node, extensionAttributes);
1043
- attrsObj = this.options.attrs({ node: this.node, HTMLAttributes });
1044
- } else {
1045
- attrsObj = this.options.attrs;
1046
- }
1047
- this.renderer.updateAttributes(attrsObj);
1048
- }
1049
- }
757
+ constructor(component, props, options) {
758
+ super(component, props, options);
759
+ this.selectionRafId = null;
760
+ this.handlePositionUpdate = () => {
761
+ const newPos = this.getPos();
762
+ if (typeof newPos !== "number" || newPos === this.currentPos) return;
763
+ this.currentPos = newPos;
764
+ this.renderer.updateProps({ getPos: () => this.getPos() });
765
+ if (typeof this.options.attrs === "function") this.updateElementAttributes();
766
+ };
767
+ this.cachedExtensionWithSyncedStorage = null;
768
+ if (!this.node.isLeaf) {
769
+ if (this.options.contentDOMElementTag) this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
770
+ else this.contentDOMElement = document.createElement(this.node.isInline ? "span" : "div");
771
+ this.contentDOMElement.dataset.nodeViewContentReact = "";
772
+ this.contentDOMElement.dataset.nodeViewWrapper = "";
773
+ this.contentDOMElement.style.whiteSpace = "inherit";
774
+ const contentTarget = this.dom.querySelector("[data-node-view-content]");
775
+ if (contentTarget) contentTarget.appendChild(this.contentDOMElement);
776
+ else this.dom.appendChild(this.contentDOMElement);
777
+ }
778
+ if (this.options.trackNodeViewPosition) this.editor.on("update", this.handlePositionUpdate);
779
+ }
780
+ /**
781
+ * Returns a proxy of the extension that redirects storage access to the editor's mutable storage.
782
+ * This preserves the original prototype chain (instanceof checks, methods like configure/extend work).
783
+ * Cached to avoid proxy creation on every update.
784
+ */
785
+ get extensionWithSyncedStorage() {
786
+ if (!this.cachedExtensionWithSyncedStorage) {
787
+ const editor = this.editor;
788
+ const extension = this.extension;
789
+ this.cachedExtensionWithSyncedStorage = new Proxy(extension, { get(target, prop, receiver) {
790
+ if (prop === "storage") {
791
+ var _editor$storage;
792
+ return (_editor$storage = editor.storage[extension.name]) !== null && _editor$storage !== void 0 ? _editor$storage : {};
793
+ }
794
+ return Reflect.get(target, prop, receiver);
795
+ } });
796
+ }
797
+ return this.cachedExtensionWithSyncedStorage;
798
+ }
799
+ /**
800
+ * Setup the React component.
801
+ * Called on initialization.
802
+ */
803
+ mount() {
804
+ const mountProps = {
805
+ editor: this.editor,
806
+ node: this.node,
807
+ decorations: this.decorations,
808
+ innerDecorations: this.innerDecorations,
809
+ view: this.view,
810
+ selected: false,
811
+ extension: this.extensionWithSyncedStorage,
812
+ HTMLAttributes: this.HTMLAttributes,
813
+ getPos: () => this.getPos(),
814
+ updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
815
+ deleteNode: () => this.deleteNode(),
816
+ ref: createRef()
817
+ };
818
+ if (!this.component.displayName) {
819
+ const capitalizeFirstChar = (string) => {
820
+ return string.charAt(0).toUpperCase() + string.substring(1);
821
+ };
822
+ this.component.displayName = capitalizeFirstChar(this.extension.name);
823
+ }
824
+ const onDragStart = this.onDragStart.bind(this);
825
+ const nodeViewContentRef = (element) => {
826
+ if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
827
+ if (element.hasAttribute("data-node-view-wrapper")) element.removeAttribute("data-node-view-wrapper");
828
+ const restoreSelection = captureDOMSelection(this.contentDOMElement);
829
+ element.appendChild(this.contentDOMElement);
830
+ restoreSelection === null || restoreSelection === void 0 || restoreSelection();
831
+ }
832
+ };
833
+ const context = {
834
+ onDragStart,
835
+ nodeViewContentRef
836
+ };
837
+ const Component = this.component;
838
+ const ReactNodeViewProvider = memo((componentProps) => {
839
+ return /* @__PURE__ */ jsx(ReactNodeViewContext.Provider, {
840
+ value: context,
841
+ children: createElement(Component, componentProps)
842
+ });
843
+ });
844
+ ReactNodeViewProvider.displayName = "ReactNodeView";
845
+ let as = this.node.isInline ? "span" : "div";
846
+ if (this.options.as) as = this.options.as;
847
+ const { className = "" } = this.options;
848
+ this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this);
849
+ this.renderer = new ReactRenderer(ReactNodeViewProvider, {
850
+ editor: this.editor,
851
+ props: mountProps,
852
+ as,
853
+ className: `node-${this.node.type.name} ${className}`.trim()
854
+ });
855
+ this.editor.on("selectionUpdate", this.handleSelectionUpdate);
856
+ this.updateElementAttributes();
857
+ this.currentPos = this.getPos();
858
+ }
859
+ /**
860
+ * Return the DOM element.
861
+ * This is the element that will be used to display the node view.
862
+ */
863
+ get dom() {
864
+ var _this$renderer$elemen;
865
+ if (this.renderer.element.firstElementChild && !((_this$renderer$elemen = this.renderer.element.firstElementChild) === null || _this$renderer$elemen === void 0 ? void 0 : _this$renderer$elemen.hasAttribute("data-node-view-wrapper"))) throw Error("Please use the NodeViewWrapper component for your node view.");
866
+ return this.renderer.element;
867
+ }
868
+ /**
869
+ * Return the content DOM element.
870
+ * This is the element that will be used to display the rich-text content of the node.
871
+ */
872
+ get contentDOM() {
873
+ if (this.node.isLeaf) return null;
874
+ return this.contentDOMElement;
875
+ }
876
+ /**
877
+ * On editor selection update, check if the node is selected.
878
+ * If it is, call `selectNode`, otherwise call `deselectNode`.
879
+ */
880
+ handleSelectionUpdate() {
881
+ if (this.selectionRafId) {
882
+ cancelAnimationFrame(this.selectionRafId);
883
+ this.selectionRafId = null;
884
+ }
885
+ this.selectionRafId = requestAnimationFrame(() => {
886
+ var _this$getPos;
887
+ this.selectionRafId = null;
888
+ const pos = (_this$getPos = this.getPos()) !== null && _this$getPos !== void 0 ? _this$getPos : this.currentPos;
889
+ if (typeof pos !== "number") return;
890
+ if (isNodeViewSelected({
891
+ selection: this.editor.state.selection,
892
+ pos,
893
+ nodeSize: this.node.nodeSize,
894
+ selectedOnTextSelection: this.options.selectedOnTextSelection
895
+ })) {
896
+ if (this.renderer.props.selected) return;
897
+ this.selectNode();
898
+ } else {
899
+ if (!this.renderer.props.selected) return;
900
+ this.deselectNode();
901
+ }
902
+ });
903
+ }
904
+ /**
905
+ * On update, update the React component.
906
+ * To prevent unnecessary updates, the `update` option can be used.
907
+ */
908
+ update(node, decorations, innerDecorations) {
909
+ const rerenderComponent = (props) => {
910
+ this.renderer.updateProps(props);
911
+ if (typeof this.options.attrs === "function") this.updateElementAttributes();
912
+ };
913
+ if (node.type !== this.node.type) return false;
914
+ if (typeof this.options.update === "function") {
915
+ const oldNode = this.node;
916
+ const oldDecorations = this.decorations;
917
+ const oldInnerDecorations = this.innerDecorations;
918
+ this.node = node;
919
+ this.decorations = decorations;
920
+ this.innerDecorations = innerDecorations;
921
+ this.currentPos = this.getPos();
922
+ return this.options.update({
923
+ oldNode,
924
+ oldDecorations,
925
+ newNode: node,
926
+ newDecorations: decorations,
927
+ oldInnerDecorations,
928
+ innerDecorations,
929
+ updateProps: () => rerenderComponent({
930
+ node,
931
+ decorations,
932
+ innerDecorations,
933
+ extension: this.extensionWithSyncedStorage
934
+ })
935
+ });
936
+ }
937
+ if (!(node !== this.node)) {
938
+ this.node = node;
939
+ this.decorations = decorations;
940
+ this.innerDecorations = innerDecorations;
941
+ return true;
942
+ }
943
+ const newPos = this.getPos();
944
+ this.node = node;
945
+ this.decorations = decorations;
946
+ this.innerDecorations = innerDecorations;
947
+ this.currentPos = newPos;
948
+ const extraProps = {
949
+ node,
950
+ decorations,
951
+ innerDecorations,
952
+ extension: this.extensionWithSyncedStorage
953
+ };
954
+ if (this.options.trackNodeViewPosition) extraProps.getPos = () => this.getPos();
955
+ rerenderComponent(extraProps);
956
+ return true;
957
+ }
958
+ /**
959
+ * Select the node.
960
+ * Add the `selected` prop and the `ProseMirror-selectednode` class.
961
+ */
962
+ selectNode() {
963
+ this.renderer.updateProps({ selected: true });
964
+ this.renderer.element.classList.add("ProseMirror-selectednode");
965
+ }
966
+ /**
967
+ * Deselect the node.
968
+ * Remove the `selected` prop and the `ProseMirror-selectednode` class.
969
+ */
970
+ deselectNode() {
971
+ this.renderer.updateProps({ selected: false });
972
+ this.renderer.element.classList.remove("ProseMirror-selectednode");
973
+ }
974
+ /**
975
+ * Destroy the React component instance.
976
+ */
977
+ destroy() {
978
+ this.renderer.destroy();
979
+ this.editor.off("selectionUpdate", this.handleSelectionUpdate);
980
+ if (this.options.trackNodeViewPosition) this.editor.off("update", this.handlePositionUpdate);
981
+ this.contentDOMElement = null;
982
+ if (this.selectionRafId) {
983
+ cancelAnimationFrame(this.selectionRafId);
984
+ this.selectionRafId = null;
985
+ }
986
+ }
987
+ /**
988
+ * Update the attributes of the top-level element that holds the React component.
989
+ * Applying the attributes defined in the `attrs` option.
990
+ */
991
+ updateElementAttributes() {
992
+ if (this.options.attrs) {
993
+ let attrsObj = {};
994
+ if (typeof this.options.attrs === "function") {
995
+ const extensionAttributes = this.editor.extensionManager.attributes;
996
+ const HTMLAttributes = getRenderedAttributes(this.node, extensionAttributes);
997
+ attrsObj = this.options.attrs({
998
+ node: this.node,
999
+ HTMLAttributes
1000
+ });
1001
+ } else attrsObj = this.options.attrs;
1002
+ this.renderer.updateAttributes(attrsObj);
1003
+ }
1004
+ }
1050
1005
  };
1006
+ /**
1007
+ * Create a React node view renderer.
1008
+ */
1051
1009
  function ReactNodeViewRenderer(component, options) {
1052
- return (props) => {
1053
- if (!props.editor.contentComponent) {
1054
- return {};
1055
- }
1056
- return new ReactNodeView(component, props, options);
1057
- };
1010
+ return (props) => {
1011
+ if (!props.editor.contentComponent) return {
1012
+ dom: document.createElement("span"),
1013
+ contentDOM: null,
1014
+ update: () => false,
1015
+ destroy: () => {},
1016
+ selectNode: () => {},
1017
+ deselectNode: () => {},
1018
+ stopEvent: () => false,
1019
+ ignoreMutation: () => true
1020
+ };
1021
+ return new ReactNodeView(component, props, options);
1022
+ };
1058
1023
  }
1059
-
1060
- // src/Tiptap.tsx
1061
- import { createContext as createContext3, useContext as useContext3, useMemo as useMemo2 } from "react";
1062
- import { jsx as jsx8 } from "react/jsx-runtime";
1063
- var TiptapContext = createContext3({
1064
- get editor() {
1065
- throw new Error("useTiptap must be used within a <Tiptap> provider");
1066
- }
1067
- });
1024
+ //#endregion
1025
+ //#region src/ReactWidgetRenderer.tsx
1026
+ const WIDGET_CACHE = Symbol("tiptapReactWidgetCache");
1027
+ /**
1028
+ * Renders a React component into a ProseMirror widget decoration.
1029
+ * Reuses Tiptap's `ReactRenderer` so the component lives in the editor's
1030
+ * React tree (context and hooks work as usual). Use a stable `key` for
1031
+ * stateful widgets.
1032
+ * @example
1033
+ * addDecorations() {
1034
+ * return {
1035
+ * create: ({ editor, state }) =>
1036
+ * findMatches(state.doc).map(match =>
1037
+ * ReactWidgetRenderer(MyWidget, {
1038
+ * editor, pos: match.pos, key: `match-${match.id}`,
1039
+ * props: { label: match.label },
1040
+ * }),
1041
+ * ),
1042
+ * }
1043
+ * }
1044
+ */
1045
+ function ReactWidgetRenderer(component, options) {
1046
+ const { editor, props = {}, as = "span", className } = options;
1047
+ return createWidgetDecoration({
1048
+ ...options,
1049
+ props,
1050
+ cacheKey: WIDGET_CACHE,
1051
+ context: (getPos) => ({
1052
+ editor,
1053
+ getPos
1054
+ }),
1055
+ create: (renderProps) => new ReactRenderer(component, {
1056
+ editor,
1057
+ as,
1058
+ className,
1059
+ props: renderProps
1060
+ }),
1061
+ materialize: (renderer) => {
1062
+ renderer.render();
1063
+ return renderer.element;
1064
+ }
1065
+ });
1066
+ }
1067
+ //#endregion
1068
+ //#region src/Tiptap.tsx
1069
+ /**
1070
+ * React context that stores the current editor instance.
1071
+ *
1072
+ * Use `useTiptap()` to read from this context in child components.
1073
+ */
1074
+ const TiptapContext = createContext({ get editor() {
1075
+ throw new Error("useTiptap must be used within a <Tiptap> provider");
1076
+ } });
1068
1077
  TiptapContext.displayName = "TiptapContext";
1069
- var useTiptap = () => useContext3(TiptapContext);
1078
+ /**
1079
+ * Hook to read the Tiptap context and access the editor instance.
1080
+ *
1081
+ * This is a small convenience wrapper around `useContext(TiptapContext)`.
1082
+ * The editor is always available when used within a `<Tiptap>` provider.
1083
+ *
1084
+ * @returns The current `TiptapContextType` value from the provider.
1085
+ *
1086
+ * @example
1087
+ * ```tsx
1088
+ * import { useTiptap } from '@tiptap/react'
1089
+ *
1090
+ * function Toolbar() {
1091
+ * const { editor } = useTiptap()
1092
+ *
1093
+ * return (
1094
+ * <button onClick={() => editor.chain().focus().toggleBold().run()}>
1095
+ * Bold
1096
+ * </button>
1097
+ * )
1098
+ * }
1099
+ * ```
1100
+ */
1101
+ const useTiptap = () => useContext(TiptapContext);
1102
+ /**
1103
+ * Select a slice of the editor state using the context-provided editor.
1104
+ *
1105
+ * This is a thin wrapper around `useEditorState` that reads the `editor`
1106
+ * instance from `useTiptap()` so callers don't have to pass it manually.
1107
+ *
1108
+ * @typeParam TSelectorResult - The type returned by the selector.
1109
+ * @param selector - Function that receives the editor state snapshot and
1110
+ * returns the piece of state you want to subscribe to.
1111
+ * @param equalityFn - Optional function to compare previous/next selected
1112
+ * values and avoid unnecessary updates.
1113
+ * @returns The selected slice of the editor state.
1114
+ *
1115
+ * @example
1116
+ * ```tsx
1117
+ * function WordCount() {
1118
+ * const wordCount = useTiptapState(state => {
1119
+ * const text = state.editor.state.doc.textContent
1120
+ * return text.split(/\s+/).filter(Boolean).length
1121
+ * })
1122
+ *
1123
+ * return <span>{wordCount} words</span>
1124
+ * }
1125
+ * ```
1126
+ */
1070
1127
  function useTiptapState(selector, equalityFn) {
1071
- const { editor } = useTiptap();
1072
- return useEditorState({
1073
- editor,
1074
- selector,
1075
- equalityFn
1076
- });
1128
+ const { editor } = useTiptap();
1129
+ return useEditorState({
1130
+ editor,
1131
+ selector,
1132
+ equalityFn
1133
+ });
1077
1134
  }
1078
- function TiptapWrapper({ editor, instance, children }) {
1079
- const resolvedEditor = editor != null ? editor : instance;
1080
- if (!resolvedEditor) {
1081
- throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");
1082
- }
1083
- const tiptapContextValue = useMemo2(() => ({ editor: resolvedEditor }), [resolvedEditor]);
1084
- const legacyContextValue = useMemo2(() => ({ editor: resolvedEditor }), [resolvedEditor]);
1085
- return /* @__PURE__ */ jsx8(EditorContext.Provider, { value: legacyContextValue, children: /* @__PURE__ */ jsx8(TiptapContext.Provider, { value: tiptapContextValue, children }) });
1135
+ /**
1136
+ * Top-level provider component that makes the editor instance available via
1137
+ * React context to all child components.
1138
+ *
1139
+ * This component also provides backwards compatibility with the legacy
1140
+ * `EditorContext`, so components using `useCurrentEditor()` will work
1141
+ * inside a `<Tiptap>` provider.
1142
+ *
1143
+ * @param props - Component props.
1144
+ * @returns A context provider element wrapping `children`.
1145
+ *
1146
+ * @example
1147
+ * ```tsx
1148
+ * import { Tiptap, useEditor } from '@tiptap/react'
1149
+ *
1150
+ * function App() {
1151
+ * const editor = useEditor({ extensions: [...] })
1152
+ *
1153
+ * return (
1154
+ * <Tiptap editor={editor}>
1155
+ * <Toolbar />
1156
+ * <Tiptap.Content />
1157
+ * </Tiptap>
1158
+ * )
1159
+ * }
1160
+ * ```
1161
+ */
1162
+ function TiptapWrapper({ children, ...props }) {
1163
+ const resolvedEditor = "editor" in props ? props.editor : props.instance;
1164
+ if (!resolvedEditor) throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");
1165
+ const tiptapContextValue = useMemo(() => ({ editor: resolvedEditor }), [resolvedEditor]);
1166
+ const legacyContextValue = useMemo(() => ({ editor: resolvedEditor }), [resolvedEditor]);
1167
+ return /* @__PURE__ */ jsx(EditorContext.Provider, {
1168
+ value: legacyContextValue,
1169
+ children: /* @__PURE__ */ jsx(TiptapContext.Provider, {
1170
+ value: tiptapContextValue,
1171
+ children
1172
+ })
1173
+ });
1086
1174
  }
1087
1175
  TiptapWrapper.displayName = "Tiptap";
1176
+ /**
1177
+ * Convenience component that renders `EditorContent` using the context-provided
1178
+ * editor instance. Use this instead of manually passing the `editor` prop.
1179
+ *
1180
+ * @param props - All `EditorContent` props except `editor` and `ref`.
1181
+ * @returns An `EditorContent` element bound to the context editor.
1182
+ *
1183
+ * @example
1184
+ * ```tsx
1185
+ * // inside a Tiptap provider
1186
+ * <Tiptap.Content className="editor" />
1187
+ * ```
1188
+ */
1088
1189
  function TiptapContent({ ...rest }) {
1089
- const { editor } = useTiptap();
1090
- return /* @__PURE__ */ jsx8(EditorContent, { editor, ...rest });
1190
+ const { editor } = useTiptap();
1191
+ return /* @__PURE__ */ jsx(EditorContent, {
1192
+ editor,
1193
+ ...rest
1194
+ });
1091
1195
  }
1092
1196
  TiptapContent.displayName = "Tiptap.Content";
1093
- var Tiptap = Object.assign(TiptapWrapper, {
1094
- /**
1095
- * The Tiptap Content component that renders the EditorContent with the editor instance from the context.
1096
- * @see TiptapContent
1097
- */
1098
- Content: TiptapContent
1099
- });
1197
+ /**
1198
+ * Root `Tiptap` component. Use it as the provider for all child components.
1199
+ *
1200
+ * The exported object includes the `Content` subcomponent for rendering the
1201
+ * editor content area.
1202
+ *
1203
+ * This component provides both the new `TiptapContext` (accessed via `useTiptap()`)
1204
+ * and the legacy `EditorContext` (accessed via `useCurrentEditor()`) for
1205
+ * backwards compatibility.
1206
+ *
1207
+ * For bubble menus and floating menus, import them separately from
1208
+ * `@tiptap/react/menus` to keep floating-ui as an optional dependency.
1209
+ *
1210
+ * @example
1211
+ * ```tsx
1212
+ * import { Tiptap, useEditor } from '@tiptap/react'
1213
+ * import { BubbleMenu } from '@tiptap/react/menus'
1214
+ *
1215
+ * function App() {
1216
+ * const editor = useEditor({ extensions: [...] })
1217
+ *
1218
+ * return (
1219
+ * <Tiptap editor={editor}>
1220
+ * <Tiptap.Content />
1221
+ * <BubbleMenu>
1222
+ * <button onClick={() => editor.chain().focus().toggleBold().run()}>Bold</button>
1223
+ * </BubbleMenu>
1224
+ * </Tiptap>
1225
+ * )
1226
+ * }
1227
+ * ```
1228
+ */
1229
+ const Tiptap = Object.assign(TiptapWrapper, {
1230
+ /**
1231
+ * The Tiptap Content component that renders the EditorContent with the editor instance from the context.
1232
+ * @see TiptapContent
1233
+ */
1234
+ Content: TiptapContent });
1235
+ //#endregion
1236
+ export { EditorConsumer, EditorContent, EditorContext, EditorProvider, MarkViewContent, NodeViewContent, NodeViewWrapper, PureEditorContent, ReactMarkView, ReactMarkViewContext, ReactMarkViewRenderer, ReactNodeView, ReactNodeViewContentProvider, ReactNodeViewContext, ReactNodeViewRenderer, ReactRenderer, ReactWidgetRenderer, Tiptap, TiptapContent, TiptapContext, TiptapWrapper, createContentComponent, useCurrentEditor, useEditor, useEditorState, useReactNodeView, useTiptap, useTiptapState };
1100
1237
 
1101
- // src/index.ts
1102
- export * from "@tiptap/core";
1103
- export {
1104
- EditorConsumer,
1105
- EditorContent,
1106
- EditorContext,
1107
- EditorProvider,
1108
- MarkViewContent,
1109
- NodeViewContent,
1110
- NodeViewWrapper,
1111
- PureEditorContent,
1112
- ReactMarkView,
1113
- ReactMarkViewContext,
1114
- ReactMarkViewRenderer,
1115
- ReactNodeView,
1116
- ReactNodeViewContentProvider,
1117
- ReactNodeViewContext,
1118
- ReactNodeViewRenderer,
1119
- ReactRenderer,
1120
- Tiptap,
1121
- TiptapContent,
1122
- TiptapContext,
1123
- TiptapWrapper,
1124
- useCurrentEditor,
1125
- useEditor,
1126
- useEditorState,
1127
- useReactNodeView,
1128
- useTiptap,
1129
- useTiptapState
1130
- };
1131
1238
  //# sourceMappingURL=index.js.map