@blade-hq/agent-react 2612.0.0-beta.98 → 2612.0.0

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