@tiptap/react 2.0.0-beta.1 → 2.0.0-beta.102

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 (306) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -2
  3. package/dist/packages/core/src/CommandManager.d.ts +20 -0
  4. package/dist/packages/core/src/Editor.d.ts +147 -0
  5. package/dist/packages/core/src/EventEmitter.d.ts +11 -0
  6. package/dist/packages/core/src/Extension.d.ts +227 -0
  7. package/dist/packages/core/src/ExtensionManager.d.ts +18 -0
  8. package/dist/packages/core/src/InputRule.d.ts +42 -0
  9. package/dist/packages/core/src/Mark.d.ts +319 -0
  10. package/dist/packages/core/src/Node.d.ts +388 -0
  11. package/dist/packages/core/src/NodeView.d.ts +27 -0
  12. package/dist/packages/core/src/PasteRule.d.ts +42 -0
  13. package/dist/packages/core/src/Tracker.d.ts +11 -0
  14. package/dist/packages/core/src/commands/blur.d.ts +12 -0
  15. package/dist/packages/core/src/commands/clearContent.d.ts +12 -0
  16. package/dist/packages/core/src/commands/clearNodes.d.ts +12 -0
  17. package/dist/packages/core/src/commands/command.d.ts +12 -0
  18. package/dist/packages/core/src/commands/createParagraphNear.d.ts +12 -0
  19. package/dist/packages/core/src/commands/deleteNode.d.ts +13 -0
  20. package/dist/packages/core/src/commands/deleteRange.d.ts +12 -0
  21. package/dist/packages/core/src/commands/deleteSelection.d.ts +12 -0
  22. package/dist/packages/core/src/commands/enter.d.ts +12 -0
  23. package/dist/packages/core/src/commands/exitCode.d.ts +12 -0
  24. package/dist/packages/core/src/commands/extendMarkRange.d.ts +13 -0
  25. package/dist/packages/core/src/commands/first.d.ts +12 -0
  26. package/dist/packages/core/src/commands/focus.d.ts +14 -0
  27. package/dist/packages/core/src/commands/forEach.d.ts +14 -0
  28. package/dist/packages/core/src/commands/insertContent.d.ts +16 -0
  29. package/dist/packages/core/src/commands/insertContentAt.d.ts +16 -0
  30. package/dist/packages/core/src/commands/joinBackward.d.ts +12 -0
  31. package/dist/packages/core/src/commands/joinForward.d.ts +12 -0
  32. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +12 -0
  33. package/dist/packages/core/src/commands/lift.d.ts +13 -0
  34. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +12 -0
  35. package/dist/packages/core/src/commands/liftListItem.d.ts +13 -0
  36. package/dist/packages/core/src/commands/newlineInCode.d.ts +12 -0
  37. package/dist/packages/core/src/commands/resetAttributes.d.ts +13 -0
  38. package/dist/packages/core/src/commands/scrollIntoView.d.ts +12 -0
  39. package/dist/packages/core/src/commands/selectAll.d.ts +12 -0
  40. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +12 -0
  41. package/dist/packages/core/src/commands/selectNodeForward.d.ts +12 -0
  42. package/dist/packages/core/src/commands/selectParentNode.d.ts +12 -0
  43. package/dist/packages/core/src/commands/setContent.d.ts +13 -0
  44. package/dist/packages/core/src/commands/setMark.d.ts +13 -0
  45. package/dist/packages/core/src/commands/setMeta.d.ts +12 -0
  46. package/dist/packages/core/src/commands/setNode.d.ts +13 -0
  47. package/dist/packages/core/src/commands/setNodeSelection.d.ts +12 -0
  48. package/dist/packages/core/src/commands/setTextSelection.d.ts +12 -0
  49. package/dist/packages/core/src/commands/sinkListItem.d.ts +13 -0
  50. package/dist/packages/core/src/commands/splitBlock.d.ts +14 -0
  51. package/dist/packages/core/src/commands/splitListItem.d.ts +13 -0
  52. package/dist/packages/core/src/commands/toggleList.d.ts +13 -0
  53. package/dist/packages/core/src/commands/toggleMark.d.ts +18 -0
  54. package/dist/packages/core/src/commands/toggleNode.d.ts +13 -0
  55. package/dist/packages/core/src/commands/toggleWrap.d.ts +13 -0
  56. package/dist/packages/core/src/commands/undoInputRule.d.ts +12 -0
  57. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +12 -0
  58. package/dist/packages/core/src/commands/unsetMark.d.ts +18 -0
  59. package/dist/packages/core/src/commands/updateAttributes.d.ts +13 -0
  60. package/dist/packages/core/src/commands/wrapIn.d.ts +13 -0
  61. package/dist/packages/core/src/commands/wrapInList.d.ts +13 -0
  62. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +2 -0
  63. package/dist/packages/core/src/extensions/commands.d.ts +98 -0
  64. package/dist/packages/core/src/extensions/editable.d.ts +2 -0
  65. package/dist/packages/core/src/extensions/focusEvents.d.ts +2 -0
  66. package/dist/packages/core/src/extensions/index.d.ts +6 -0
  67. package/dist/packages/core/src/extensions/keymap.d.ts +2 -0
  68. package/dist/packages/core/src/extensions/tabindex.d.ts +2 -0
  69. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +7 -0
  70. package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
  71. package/dist/packages/core/src/helpers/createDocument.d.ts +3 -0
  72. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +7 -0
  73. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +2 -0
  74. package/dist/packages/core/src/helpers/findChildren.d.ts +3 -0
  75. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +6 -0
  76. package/dist/packages/core/src/helpers/findParentNode.d.ts +9 -0
  77. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +8 -0
  78. package/dist/packages/core/src/helpers/generateHTML.d.ts +2 -0
  79. package/dist/packages/core/src/helpers/generateJSON.d.ts +2 -0
  80. package/dist/packages/core/src/helpers/generateText.d.ts +5 -0
  81. package/dist/packages/core/src/helpers/getAttributes.d.ts +3 -0
  82. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +6 -0
  83. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +11 -0
  84. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +8 -0
  85. package/dist/packages/core/src/helpers/getExtensionField.d.ts +2 -0
  86. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +2 -0
  87. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +3 -0
  88. package/dist/packages/core/src/helpers/getMarkRange.d.ts +3 -0
  89. package/dist/packages/core/src/helpers/getMarkType.d.ts +2 -0
  90. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +3 -0
  91. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +3 -0
  92. package/dist/packages/core/src/helpers/getNodeType.d.ts +2 -0
  93. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +3 -0
  94. package/dist/packages/core/src/helpers/getSchema.d.ts +3 -0
  95. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +3 -0
  96. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +2 -0
  97. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +2 -0
  98. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +2 -0
  99. package/dist/packages/core/src/helpers/getText.d.ts +6 -0
  100. package/dist/packages/core/src/helpers/getTextBetween.d.ts +6 -0
  101. package/dist/packages/core/src/helpers/getTextSeralizersFromSchema.d.ts +3 -0
  102. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +9 -0
  103. package/dist/packages/core/src/helpers/isActive.d.ts +2 -0
  104. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
  105. package/dist/packages/core/src/helpers/isList.d.ts +2 -0
  106. package/dist/packages/core/src/helpers/isMarkActive.d.ts +3 -0
  107. package/dist/packages/core/src/helpers/isNodeActive.d.ts +3 -0
  108. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +2 -0
  109. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +2 -0
  110. package/dist/packages/core/src/helpers/isTextSelection.d.ts +2 -0
  111. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +2 -0
  112. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +4 -0
  113. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +2 -0
  114. package/dist/packages/core/src/helpers/splitExtensions.d.ts +9 -0
  115. package/dist/packages/core/src/index.d.ts +60 -0
  116. package/dist/packages/core/src/inputRules/markInputRule.d.ts +12 -0
  117. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +12 -0
  118. package/dist/packages/core/src/inputRules/textInputRule.d.ts +9 -0
  119. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +14 -0
  120. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +23 -0
  121. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +12 -0
  122. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +9 -0
  123. package/dist/packages/core/src/style.d.ts +1 -0
  124. package/dist/packages/core/src/types.d.ts +210 -0
  125. package/dist/packages/core/src/utilities/callOrReturn.d.ts +9 -0
  126. package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -0
  127. package/dist/packages/core/src/utilities/deleteProps.d.ts +6 -0
  128. package/dist/packages/core/src/utilities/elementFromString.d.ts +1 -0
  129. package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
  130. package/dist/packages/core/src/utilities/fromString.d.ts +1 -0
  131. package/dist/packages/core/src/utilities/isClass.d.ts +1 -0
  132. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +1 -0
  133. package/dist/packages/core/src/utilities/isFunction.d.ts +1 -0
  134. package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
  135. package/dist/packages/core/src/utilities/isObject.d.ts +1 -0
  136. package/dist/packages/core/src/utilities/isPlainObject.d.ts +1 -0
  137. package/dist/packages/core/src/utilities/isRegExp.d.ts +1 -0
  138. package/dist/packages/core/src/utilities/isString.d.ts +1 -0
  139. package/dist/packages/core/src/utilities/isiOS.d.ts +1 -0
  140. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +1 -0
  141. package/dist/packages/core/src/utilities/mergeDeep.d.ts +1 -0
  142. package/dist/packages/core/src/utilities/minMax.d.ts +1 -0
  143. package/dist/packages/core/src/utilities/objectIncludes.d.ts +8 -0
  144. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +8 -0
  145. package/dist/packages/extension-blockquote/src/blockquote.d.ts +24 -0
  146. package/dist/packages/extension-blockquote/src/index.d.ts +3 -0
  147. package/dist/packages/extension-bold/src/bold.d.ts +27 -0
  148. package/dist/packages/extension-bold/src/index.d.ts +3 -0
  149. package/dist/packages/extension-bubble-menu/src/bubble-menu-plugin.d.ts +43 -0
  150. package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +6 -0
  151. package/dist/packages/extension-bubble-menu/src/index.d.ts +4 -0
  152. package/dist/packages/extension-bullet-list/src/bullet-list.d.ts +17 -0
  153. package/dist/packages/extension-bullet-list/src/index.d.ts +3 -0
  154. package/dist/packages/extension-character-count/src/character-count.d.ts +28 -0
  155. package/dist/packages/extension-character-count/src/index.d.ts +3 -0
  156. package/dist/packages/extension-code/src/code.d.ts +25 -0
  157. package/dist/packages/extension-code/src/index.d.ts +3 -0
  158. package/dist/packages/extension-code-block/src/code-block.d.ts +26 -0
  159. package/dist/packages/extension-code-block/src/index.d.ts +3 -0
  160. package/dist/packages/extension-code-block-lowlight/src/code-block-lowlight.d.ts +6 -0
  161. package/dist/packages/extension-code-block-lowlight/src/index.d.ts +3 -0
  162. package/dist/packages/extension-code-block-lowlight/src/lowlight-plugin.d.ts +6 -0
  163. package/dist/packages/extension-collaboration/src/collaboration.d.ts +30 -0
  164. package/dist/packages/extension-collaboration/src/helpers/isChangeOrigin.d.ts +2 -0
  165. package/dist/packages/extension-collaboration/src/index.d.ts +4 -0
  166. package/dist/packages/extension-collaboration-cursor/src/collaboration-cursor.d.ts +37 -0
  167. package/dist/packages/extension-collaboration-cursor/src/index.d.ts +3 -0
  168. package/dist/packages/extension-color/src/color.d.ts +20 -0
  169. package/dist/packages/extension-color/src/index.d.ts +3 -0
  170. package/dist/packages/extension-document/src/document.d.ts +2 -0
  171. package/dist/packages/extension-document/src/index.d.ts +3 -0
  172. package/dist/packages/extension-dropcursor/src/dropcursor.d.ts +7 -0
  173. package/dist/packages/extension-dropcursor/src/index.d.ts +3 -0
  174. package/dist/packages/extension-floating-menu/src/floating-menu-plugin.d.ts +40 -0
  175. package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +6 -0
  176. package/dist/packages/extension-floating-menu/src/index.d.ts +4 -0
  177. package/dist/packages/extension-focus/src/focus.d.ts +6 -0
  178. package/dist/packages/extension-focus/src/index.d.ts +3 -0
  179. package/dist/packages/extension-font-family/src/font-family.d.ts +21 -0
  180. package/dist/packages/extension-font-family/src/index.d.ts +3 -0
  181. package/dist/packages/extension-gapcursor/src/gapcursor.d.ts +15 -0
  182. package/dist/packages/extension-gapcursor/src/index.d.ts +3 -0
  183. package/dist/packages/extension-hard-break/src/hard-break.d.ts +16 -0
  184. package/dist/packages/extension-hard-break/src/index.d.ts +3 -0
  185. package/dist/packages/extension-heading/src/heading.d.ts +26 -0
  186. package/dist/packages/extension-heading/src/index.d.ts +3 -0
  187. package/dist/packages/extension-highlight/src/highlight.d.ts +30 -0
  188. package/dist/packages/extension-highlight/src/index.d.ts +3 -0
  189. package/dist/packages/extension-history/src/history.d.ts +20 -0
  190. package/dist/packages/extension-history/src/index.d.ts +3 -0
  191. package/dist/packages/extension-horizontal-rule/src/horizontal-rule.d.ts +15 -0
  192. package/dist/packages/extension-horizontal-rule/src/index.d.ts +3 -0
  193. package/dist/packages/extension-image/src/image.d.ts +21 -0
  194. package/dist/packages/extension-image/src/index.d.ts +3 -0
  195. package/dist/packages/extension-italic/src/index.d.ts +3 -0
  196. package/dist/packages/extension-italic/src/italic.d.ts +27 -0
  197. package/dist/packages/extension-link/src/helpers/autolink.d.ts +7 -0
  198. package/dist/packages/extension-link/src/helpers/clickHandler.d.ts +7 -0
  199. package/dist/packages/extension-link/src/helpers/pasteHandler.d.ts +9 -0
  200. package/dist/packages/extension-link/src/index.d.ts +3 -0
  201. package/dist/packages/extension-link/src/link.d.ts +44 -0
  202. package/dist/packages/extension-list-item/src/index.d.ts +3 -0
  203. package/dist/packages/extension-list-item/src/list-item.d.ts +5 -0
  204. package/dist/packages/extension-mention/src/index.d.ts +3 -0
  205. package/dist/packages/extension-mention/src/mention.d.ts +14 -0
  206. package/dist/packages/extension-ordered-list/src/index.d.ts +3 -0
  207. package/dist/packages/extension-ordered-list/src/ordered-list.d.ts +17 -0
  208. package/dist/packages/extension-paragraph/src/index.d.ts +3 -0
  209. package/dist/packages/extension-paragraph/src/paragraph.d.ts +15 -0
  210. package/dist/packages/extension-placeholder/src/index.d.ts +3 -0
  211. package/dist/packages/extension-placeholder/src/placeholder.d.ts +15 -0
  212. package/dist/packages/extension-strike/src/index.d.ts +3 -0
  213. package/dist/packages/extension-strike/src/strike.d.ts +25 -0
  214. package/dist/packages/extension-subscript/src/index.d.ts +3 -0
  215. package/dist/packages/extension-subscript/src/subscript.d.ts +23 -0
  216. package/dist/packages/extension-superscript/src/index.d.ts +3 -0
  217. package/dist/packages/extension-superscript/src/superscript.d.ts +23 -0
  218. package/dist/packages/extension-table/src/TableView.d.ts +17 -0
  219. package/dist/packages/extension-table/src/index.d.ts +4 -0
  220. package/dist/packages/extension-table/src/table.d.ts +55 -0
  221. package/dist/packages/extension-table/src/utilities/createCell.d.ts +2 -0
  222. package/dist/packages/extension-table/src/utilities/createTable.d.ts +2 -0
  223. package/dist/packages/extension-table/src/utilities/deleteTableWhenAllCellsSelected.d.ts +2 -0
  224. package/dist/packages/extension-table/src/utilities/getTableNodeTypes.d.ts +4 -0
  225. package/dist/packages/extension-table/src/utilities/isCellSelection.d.ts +2 -0
  226. package/dist/packages/extension-table-cell/src/index.d.ts +3 -0
  227. package/dist/packages/extension-table-cell/src/table-cell.d.ts +5 -0
  228. package/dist/packages/extension-table-header/src/index.d.ts +3 -0
  229. package/dist/packages/extension-table-header/src/table-header.d.ts +5 -0
  230. package/dist/packages/extension-table-row/src/index.d.ts +3 -0
  231. package/dist/packages/extension-table-row/src/table-row.d.ts +5 -0
  232. package/dist/packages/extension-task-item/src/index.d.ts +3 -0
  233. package/dist/packages/extension-task-item/src/task-item.d.ts +7 -0
  234. package/dist/packages/extension-task-list/src/index.d.ts +3 -0
  235. package/dist/packages/extension-task-list/src/task-list.d.ts +16 -0
  236. package/dist/packages/extension-text/src/index.d.ts +3 -0
  237. package/dist/packages/extension-text/src/text.d.ts +2 -0
  238. package/dist/packages/extension-text-align/src/index.d.ts +3 -0
  239. package/dist/packages/extension-text-align/src/text-align.d.ts +21 -0
  240. package/dist/packages/extension-text-style/src/index.d.ts +3 -0
  241. package/dist/packages/extension-text-style/src/text-style.d.ts +15 -0
  242. package/dist/packages/extension-typography/src/index.d.ts +3 -0
  243. package/dist/packages/extension-typography/src/typography.d.ts +23 -0
  244. package/dist/packages/extension-underline/src/index.d.ts +3 -0
  245. package/dist/packages/extension-underline/src/underline.d.ts +23 -0
  246. package/dist/packages/html/src/generateHTML.d.ts +2 -0
  247. package/dist/packages/html/src/generateJSON.d.ts +2 -0
  248. package/dist/packages/html/src/getHTMLFromFragment.d.ts +2 -0
  249. package/dist/packages/html/src/index.d.ts +2 -0
  250. package/dist/packages/react/src/BubbleMenu.d.ts +8 -0
  251. package/dist/packages/react/src/Editor.d.ts +6 -0
  252. package/dist/packages/react/src/EditorContent.d.ts +19 -0
  253. package/dist/packages/react/src/FloatingMenu.d.ts +8 -0
  254. package/dist/packages/react/src/NodeViewContent.d.ts +6 -0
  255. package/dist/packages/react/src/NodeViewWrapper.d.ts +6 -0
  256. package/dist/packages/react/src/ReactNodeViewRenderer.d.ts +13 -1
  257. package/dist/packages/react/src/ReactRenderer.d.ts +26 -1
  258. package/dist/packages/react/src/index.d.ts +9 -3
  259. package/dist/packages/react/src/useEditor.d.ts +4 -0
  260. package/dist/packages/react/src/useReactNodeView.d.ts +7 -0
  261. package/dist/packages/starter-kit/src/index.d.ts +3 -0
  262. package/dist/packages/starter-kit/src/starter-kit.d.ts +37 -0
  263. package/dist/packages/suggestion/src/findSuggestionMatch.d.ts +15 -0
  264. package/dist/packages/suggestion/src/index.d.ts +4 -0
  265. package/dist/packages/suggestion/src/suggestion.d.ts +49 -0
  266. package/dist/tests/cypress/integration/core/can.spec.d.ts +1 -0
  267. package/dist/tests/cypress/integration/core/editorProps.spec.d.ts +1 -0
  268. package/dist/tests/cypress/integration/core/extendExtensions.spec.d.ts +1 -0
  269. package/dist/tests/cypress/integration/core/extendMarkRange.spec.d.ts +1 -0
  270. package/dist/tests/cypress/integration/core/extensionOptions.spec.d.ts +1 -0
  271. package/dist/tests/cypress/integration/core/fromString.spec.d.ts +1 -0
  272. package/dist/tests/cypress/integration/core/generateHTML.spec.d.ts +1 -0
  273. package/dist/tests/cypress/integration/core/generateJSON.spec.d.ts +1 -0
  274. package/dist/tests/cypress/integration/core/isActive.spec.d.ts +1 -0
  275. package/dist/tests/cypress/integration/core/isClass.spec.d.ts +1 -0
  276. package/dist/tests/cypress/integration/core/mergeAttributes.spec.d.ts +1 -0
  277. package/dist/tests/cypress/integration/core/mergeDeep.spec.d.ts +1 -0
  278. package/dist/tests/cypress/integration/core/pluginOrder.spec.d.ts +1 -0
  279. package/dist/tests/cypress/integration/extensions/bold.spec.d.ts +1 -0
  280. package/dist/tests/cypress/integration/extensions/codeBlockLowlight.spec.d.ts +1 -0
  281. package/dist/tests/cypress/integration/html/generateHTML.spec.d.ts +1 -0
  282. package/dist/tests/cypress/integration/html/generateJSON.spec.d.ts +1 -0
  283. package/dist/tiptap-react.cjs.js +353 -30
  284. package/dist/tiptap-react.cjs.js.map +1 -1
  285. package/dist/tiptap-react.esm.js +348 -29
  286. package/dist/tiptap-react.esm.js.map +1 -1
  287. package/dist/tiptap-react.umd.js +355 -35
  288. package/dist/tiptap-react.umd.js.map +1 -1
  289. package/package.json +18 -5
  290. package/src/BubbleMenu.tsx +51 -0
  291. package/src/Editor.ts +7 -0
  292. package/src/EditorContent.tsx +110 -0
  293. package/src/FloatingMenu.tsx +51 -0
  294. package/src/NodeViewContent.tsx +24 -0
  295. package/src/NodeViewWrapper.tsx +25 -0
  296. package/src/ReactNodeViewRenderer.tsx +184 -0
  297. package/src/ReactRenderer.tsx +109 -0
  298. package/src/index.ts +9 -6
  299. package/src/useEditor.ts +34 -0
  300. package/src/useReactNodeView.ts +12 -0
  301. package/CHANGELOG.md +0 -16
  302. package/dist/tiptap-react.bundle.umd.min.js +0 -15
  303. package/dist/tiptap-react.bundle.umd.min.js.map +0 -1
  304. package/src/ReactNodeViewRenderer.ts +0 -1
  305. package/src/ReactRenderer.ts +0 -1
  306. package/src/components/Editor.jsx +0 -34
@@ -1,61 +1,381 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('react')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'react'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/react'] = {}, global.core, global.React));
5
- }(this, (function (exports, core, React) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('react'), require('@tiptap/extension-bubble-menu'), require('@tiptap/extension-floating-menu'), require('react-dom')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'react', '@tiptap/extension-bubble-menu', '@tiptap/extension-floating-menu', 'react-dom'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/react"] = {}, global.core, global.React, global.extensionBubbleMenu, global.extensionFloatingMenu, global.ReactDOM));
5
+ })(this, (function (exports, core, React, extensionBubbleMenu, extensionFloatingMenu, ReactDOM) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
10
11
 
12
+ const BubbleMenu = props => {
13
+ const [element, setElement] = React.useState(null);
14
+ React.useEffect(() => {
15
+ if (!element) {
16
+ return;
17
+ }
18
+ if (props.editor.isDestroyed) {
19
+ return;
20
+ }
21
+ const { pluginKey = 'bubbleMenu', editor, tippyOptions = {}, shouldShow = null, } = props;
22
+ const plugin = extensionBubbleMenu.BubbleMenuPlugin({
23
+ pluginKey,
24
+ editor,
25
+ element,
26
+ tippyOptions,
27
+ shouldShow,
28
+ });
29
+ editor.registerPlugin(plugin);
30
+ return () => editor.unregisterPlugin(pluginKey);
31
+ }, [
32
+ props.editor,
33
+ element,
34
+ ]);
35
+ return (React__default["default"].createElement("div", { ref: setElement, className: props.className, style: { visibility: 'hidden' } }, props.children));
36
+ };
37
+
38
+ class Editor extends core.Editor {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.contentComponent = null;
42
+ }
43
+ }
44
+
45
+ const FloatingMenu = props => {
46
+ const [element, setElement] = React.useState(null);
47
+ React.useEffect(() => {
48
+ if (!element) {
49
+ return;
50
+ }
51
+ if (props.editor.isDestroyed) {
52
+ return;
53
+ }
54
+ const { pluginKey = 'floatingMenu', editor, tippyOptions = {}, shouldShow = null, } = props;
55
+ const plugin = extensionFloatingMenu.FloatingMenuPlugin({
56
+ pluginKey,
57
+ editor,
58
+ element,
59
+ tippyOptions,
60
+ shouldShow,
61
+ });
62
+ editor.registerPlugin(plugin);
63
+ return () => editor.unregisterPlugin(pluginKey);
64
+ }, [
65
+ props.editor,
66
+ element,
67
+ ]);
68
+ return (React__default["default"].createElement("div", { ref: setElement, className: props.className, style: { visibility: 'hidden' } }, props.children));
69
+ };
70
+
71
+ function useForceUpdate() {
72
+ const [, setValue] = React.useState(0);
73
+ return () => setValue(value => value + 1);
74
+ }
75
+ const useEditor = (options = {}, deps = []) => {
76
+ const [editor, setEditor] = React.useState(null);
77
+ const forceUpdate = useForceUpdate();
78
+ React.useEffect(() => {
79
+ const instance = new Editor(options);
80
+ setEditor(instance);
81
+ instance.on('transaction', () => {
82
+ requestAnimationFrame(() => {
83
+ requestAnimationFrame(() => {
84
+ forceUpdate();
85
+ });
86
+ });
87
+ });
88
+ return () => {
89
+ instance.destroy();
90
+ };
91
+ }, deps);
92
+ return editor;
93
+ };
94
+
95
+ function isClassComponent(Component) {
96
+ return !!(typeof Component === 'function'
97
+ && Component.prototype
98
+ && Component.prototype.isReactComponent);
99
+ }
100
+ function isForwardRefComponent(Component) {
101
+ var _a;
102
+ return !!(typeof Component === 'object'
103
+ && ((_a = Component.$$typeof) === null || _a === void 0 ? void 0 : _a.toString()) === 'Symbol(react.forward_ref)');
104
+ }
11
105
  class ReactRenderer {
106
+ constructor(component, { editor, props = {}, as = 'div', className = '', }) {
107
+ this.ref = null;
108
+ this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString();
109
+ this.component = component;
110
+ this.editor = editor;
111
+ this.props = props;
112
+ this.element = document.createElement(as);
113
+ this.element.classList.add('react-renderer');
114
+ if (className) {
115
+ this.element.classList.add(...className.split(' '));
116
+ }
117
+ this.render();
118
+ }
119
+ render() {
120
+ var _a;
121
+ const Component = this.component;
122
+ const props = this.props;
123
+ if (isClassComponent(Component) || isForwardRefComponent(Component)) {
124
+ props.ref = (ref) => {
125
+ this.ref = ref;
126
+ };
127
+ }
128
+ this.reactElement = React__default["default"].createElement(Component, { ...props });
129
+ if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
130
+ this.editor.contentComponent.setState({
131
+ renderers: this.editor.contentComponent.state.renderers.set(this.id, this),
132
+ });
133
+ }
134
+ }
135
+ updateProps(props = {}) {
136
+ this.props = {
137
+ ...this.props,
138
+ ...props,
139
+ };
140
+ this.render();
141
+ }
142
+ destroy() {
143
+ var _a;
144
+ if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
145
+ const { renderers } = this.editor.contentComponent.state;
146
+ renderers.delete(this.id);
147
+ this.editor.contentComponent.setState({
148
+ renderers,
149
+ });
150
+ }
151
+ }
12
152
  }
13
153
 
14
- class ReactNodeViewRenderer {
154
+ const ReactNodeViewContext = React.createContext({
155
+ onDragStart: undefined,
156
+ });
157
+ const useReactNodeView = () => React.useContext(ReactNodeViewContext);
158
+
159
+ class ReactNodeView extends core.NodeView {
160
+ mount() {
161
+ const props = {
162
+ editor: this.editor,
163
+ node: this.node,
164
+ decorations: this.decorations,
165
+ selected: false,
166
+ extension: this.extension,
167
+ getPos: () => this.getPos(),
168
+ updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
169
+ deleteNode: () => this.deleteNode(),
170
+ };
171
+ if (!this.component.displayName) {
172
+ const capitalizeFirstChar = (string) => {
173
+ return string.charAt(0).toUpperCase() + string.substring(1);
174
+ };
175
+ this.component.displayName = capitalizeFirstChar(this.extension.name);
176
+ }
177
+ const ReactNodeViewProvider = componentProps => {
178
+ const Component = this.component;
179
+ const onDragStart = this.onDragStart.bind(this);
180
+ const nodeViewContentRef = element => {
181
+ if (element
182
+ && this.contentDOMElement
183
+ && element.firstChild !== this.contentDOMElement) {
184
+ element.appendChild(this.contentDOMElement);
185
+ }
186
+ };
187
+ return (React__default["default"].createElement(ReactNodeViewContext.Provider, { value: { onDragStart, nodeViewContentRef } },
188
+ React__default["default"].createElement(Component, { ...componentProps })));
189
+ };
190
+ ReactNodeViewProvider.displayName = 'ReactNodeView';
191
+ this.contentDOMElement = this.node.isLeaf
192
+ ? null
193
+ : document.createElement(this.node.isInline ? 'span' : 'div');
194
+ if (this.contentDOMElement) {
195
+ // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
196
+ // With this fix it seems to work fine
197
+ // See: https://github.com/ueberdosis/tiptap/issues/1197
198
+ this.contentDOMElement.style.whiteSpace = 'inherit';
199
+ }
200
+ let as = this.node.isInline ? 'span' : 'div';
201
+ if (this.options.as) {
202
+ as = this.options.as;
203
+ }
204
+ this.renderer = new ReactRenderer(ReactNodeViewProvider, {
205
+ editor: this.editor,
206
+ props,
207
+ as,
208
+ className: `node-${this.node.type.name}`,
209
+ });
210
+ }
211
+ get dom() {
212
+ var _a;
213
+ if (this.renderer.element.firstElementChild
214
+ && !((_a = this.renderer.element.firstElementChild) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-node-view-wrapper'))) {
215
+ throw Error('Please use the NodeViewWrapper component for your node view.');
216
+ }
217
+ return this.renderer.element;
218
+ }
219
+ get contentDOM() {
220
+ if (this.node.isLeaf) {
221
+ return null;
222
+ }
223
+ return this.contentDOMElement;
224
+ }
225
+ update(node, decorations) {
226
+ const updateProps = (props) => {
227
+ this.renderer.updateProps(props);
228
+ };
229
+ if (node.type !== this.node.type) {
230
+ return false;
231
+ }
232
+ if (typeof this.options.update === 'function') {
233
+ const oldNode = this.node;
234
+ const oldDecorations = this.decorations;
235
+ this.node = node;
236
+ this.decorations = decorations;
237
+ return this.options.update({
238
+ oldNode,
239
+ oldDecorations,
240
+ newNode: node,
241
+ newDecorations: decorations,
242
+ updateProps: () => updateProps({ node, decorations }),
243
+ });
244
+ }
245
+ if (node === this.node && this.decorations === decorations) {
246
+ return true;
247
+ }
248
+ this.node = node;
249
+ this.decorations = decorations;
250
+ updateProps({ node, decorations });
251
+ return true;
252
+ }
253
+ selectNode() {
254
+ this.renderer.updateProps({
255
+ selected: true,
256
+ });
257
+ }
258
+ deselectNode() {
259
+ this.renderer.updateProps({
260
+ selected: false,
261
+ });
262
+ }
263
+ destroy() {
264
+ this.renderer.destroy();
265
+ this.contentDOMElement = null;
266
+ }
267
+ }
268
+ function ReactNodeViewRenderer(component, options) {
269
+ return (props) => {
270
+ // try to get the parent component
271
+ // this is important for vue devtools to show the component hierarchy correctly
272
+ // maybe it’s `undefined` because <editor-content> isn’t rendered yet
273
+ if (!props.editor.contentComponent) {
274
+ return {};
275
+ }
276
+ return new ReactNodeView(component, props, options);
277
+ };
15
278
  }
16
279
 
17
- const EditorContext = /*#__PURE__*/React.createContext({});
18
- const useEditor = () => React.useContext(EditorContext);
19
- const Editor = ({
20
- value,
21
- onChange,
22
- children,
23
- ...props
24
- }) => {
25
- const [editor, setEditor] = React.useState(null);
26
- const editorRef = React.useRef(null);
27
- React.useEffect(() => {
28
- const e = new core.Editor({
29
- element: editorRef.current,
30
- content: value,
31
- ...props
32
- }).on('transaction', () => {
33
- onChange(e.getJSON());
34
- });
35
- setEditor(e);
36
- }, []);
37
- return /*#__PURE__*/React__default['default'].createElement(EditorContext.Provider, {
38
- value: editor
39
- }, editorRef.current && children, /*#__PURE__*/React__default['default'].createElement("div", {
40
- ref: editorRef
41
- }));
280
+ const Portals = ({ renderers }) => {
281
+ return (React__default["default"].createElement(React__default["default"].Fragment, null, Array.from(renderers).map(([key, renderer]) => {
282
+ return ReactDOM__default["default"].createPortal(renderer.reactElement, renderer.element, key);
283
+ })));
284
+ };
285
+ class PureEditorContent extends React__default["default"].Component {
286
+ constructor(props) {
287
+ super(props);
288
+ this.editorContentRef = React__default["default"].createRef();
289
+ this.state = {
290
+ renderers: new Map(),
291
+ };
292
+ }
293
+ componentDidMount() {
294
+ this.init();
295
+ }
296
+ componentDidUpdate() {
297
+ this.init();
298
+ }
299
+ init() {
300
+ const { editor } = this.props;
301
+ if (editor && editor.options.element) {
302
+ if (editor.contentComponent) {
303
+ return;
304
+ }
305
+ const element = this.editorContentRef.current;
306
+ element.append(...editor.options.element.childNodes);
307
+ editor.setOptions({
308
+ element,
309
+ });
310
+ editor.contentComponent = this;
311
+ editor.createNodeViews();
312
+ }
313
+ }
314
+ componentWillUnmount() {
315
+ const { editor } = this.props;
316
+ if (!editor) {
317
+ return;
318
+ }
319
+ if (!editor.isDestroyed) {
320
+ editor.view.setProps({
321
+ nodeViews: {},
322
+ });
323
+ }
324
+ editor.contentComponent = null;
325
+ if (!editor.options.element.firstChild) {
326
+ return;
327
+ }
328
+ const newElement = document.createElement('div');
329
+ newElement.append(...editor.options.element.childNodes);
330
+ editor.setOptions({
331
+ element: newElement,
332
+ });
333
+ }
334
+ render() {
335
+ const { editor, ...rest } = this.props;
336
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
337
+ React__default["default"].createElement("div", { ref: this.editorContentRef, ...rest }),
338
+ React__default["default"].createElement(Portals, { renderers: this.state.renderers })));
339
+ }
340
+ }
341
+ const EditorContent = React__default["default"].memo(PureEditorContent);
342
+
343
+ const NodeViewWrapper = React__default["default"].forwardRef((props, ref) => {
344
+ const { onDragStart } = useReactNodeView();
345
+ const Tag = props.as || 'div';
346
+ return (React__default["default"].createElement(Tag, { ...props, ref: ref, "data-node-view-wrapper": "", onDragStart: onDragStart, style: {
347
+ ...props.style,
348
+ whiteSpace: 'normal',
349
+ } }));
350
+ });
351
+
352
+ const NodeViewContent = props => {
353
+ const Tag = props.as || 'div';
354
+ const { nodeViewContentRef } = useReactNodeView();
355
+ return (React__default["default"].createElement(Tag, { ...props, ref: nodeViewContentRef, "data-node-view-content": "", style: {
356
+ ...props.style,
357
+ whiteSpace: 'pre-wrap',
358
+ } }));
42
359
  };
43
360
 
361
+ exports.BubbleMenu = BubbleMenu;
44
362
  exports.Editor = Editor;
45
- exports.EditorContext = EditorContext;
363
+ exports.EditorContent = EditorContent;
364
+ exports.FloatingMenu = FloatingMenu;
365
+ exports.NodeViewContent = NodeViewContent;
366
+ exports.NodeViewWrapper = NodeViewWrapper;
367
+ exports.PureEditorContent = PureEditorContent;
46
368
  exports.ReactNodeViewRenderer = ReactNodeViewRenderer;
47
369
  exports.ReactRenderer = ReactRenderer;
48
370
  exports.useEditor = useEditor;
49
371
  Object.keys(core).forEach(function (k) {
50
372
  if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
51
373
  enumerable: true,
52
- get: function () {
53
- return core[k];
54
- }
374
+ get: function () { return core[k]; }
55
375
  });
56
376
  });
57
377
 
58
378
  Object.defineProperty(exports, '__esModule', { value: true });
59
379
 
60
- })));
380
+ }));
61
381
  //# sourceMappingURL=tiptap-react.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-react.umd.js","sources":["../src/ReactRenderer.ts","../src/ReactNodeViewRenderer.ts","../src/components/Editor.jsx"],"sourcesContent":["export default class ReactRenderer {}\n","export default class ReactNodeViewRenderer {}\n","import React, {\n useState, useRef, useEffect, createContext, useContext,\n} from 'react'\nimport { Editor as Tiptap } from '@tiptap/core'\n\nexport const EditorContext = createContext({})\n\nexport const useEditor = () => useContext(EditorContext)\n\nexport const Editor = ({\n value, onChange, children, ...props\n}) => {\n const [editor, setEditor] = useState(null)\n const editorRef = useRef(null)\n\n useEffect(() => {\n const e = new Tiptap({\n element: editorRef.current,\n content: value,\n ...props,\n }).on('transaction', () => {\n onChange(e.getJSON())\n })\n\n setEditor(e)\n }, [])\n\n return (\n <EditorContext.Provider value={editor}>\n {editorRef.current && children}\n <div ref={editorRef} />\n </EditorContext.Provider>\n )\n}\n"],"names":["EditorContext","createContext","useEditor","useContext","Editor","value","onChange","children","props","editor","setEditor","useState","editorRef","useRef","useEffect","e","Tiptap","element","current","content","on","getJSON","React"],"mappings":";;;;;;;;;;QAAqB,aAAa;;;QCAb,qBAAqB;;;QCK7BA,aAAa,gBAAGC,mBAAa,CAAC,EAAD;QAE7BC,SAAS,GAAG,MAAMC,gBAAU,CAACH,aAAD;QAE5BI,MAAM,GAAG,CAAC;EACrBC,EAAAA,KADqB;EACdC,EAAAA,QADc;EACJC,EAAAA,QADI;EACM,KAAGC;EADT,CAAD,KAEhB;EACJ,QAAM,CAACC,MAAD,EAASC,SAAT,IAAsBC,cAAQ,CAAC,IAAD,CAApC;EACA,QAAMC,SAAS,GAAGC,YAAM,CAAC,IAAD,CAAxB;EAEAC,EAAAA,eAAS,CAAC,MAAM;EACd,UAAMC,CAAC,GAAG,IAAIC,WAAJ,CAAW;EACnBC,MAAAA,OAAO,EAAEL,SAAS,CAACM,OADA;EAEnBC,MAAAA,OAAO,EAAEd,KAFU;EAGnB,SAAGG;EAHgB,KAAX,EAIPY,EAJO,CAIJ,aAJI,EAIW,MAAM;EACzBd,MAAAA,QAAQ,CAACS,CAAC,CAACM,OAAF,EAAD,CAAR;EACD,KANS,CAAV;EAQAX,IAAAA,SAAS,CAACK,CAAD,CAAT;EACD,GAVQ,EAUN,EAVM,CAAT;EAYA,sBACEO,wCAAC,aAAD,CAAe,QAAf;EAAwB,IAAA,KAAK,EAAEb;EAA/B,KACGG,SAAS,CAACM,OAAV,IAAqBX,QADxB,eAEEe;EAAK,IAAA,GAAG,EAAEV;EAAV,IAFF,CADF;EAMD;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"tiptap-react.umd.js","sources":["../src/BubbleMenu.tsx","../src/Editor.ts","../src/FloatingMenu.tsx","../src/useEditor.ts","../src/ReactRenderer.tsx","../src/useReactNodeView.ts","../src/ReactNodeViewRenderer.tsx","../src/EditorContent.tsx","../src/NodeViewWrapper.tsx","../src/NodeViewContent.tsx"],"sourcesContent":["import React, {\n useEffect, useState,\n} from 'react'\nimport { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const BubbleMenu: React.FC<BubbleMenuProps> = props => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const plugin = BubbleMenuPlugin({\n pluginKey,\n editor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n editor.registerPlugin(plugin)\n return () => editor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n element,\n ])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import React from 'react'\nimport { Editor as CoreEditor } from '@tiptap/core'\nimport { EditorContentProps, EditorContentState } from './EditorContent'\n\nexport class Editor extends CoreEditor {\n public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null\n}\n","import React, {\n useEffect, useState,\n} from 'react'\nimport { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = props => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const plugin = FloatingMenuPlugin({\n pluginKey,\n editor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n editor.registerPlugin(plugin)\n return () => editor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n element,\n ])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { useState, useEffect, DependencyList } from 'react'\nimport { EditorOptions } from '@tiptap/core'\nimport { Editor } from './Editor'\n\nfunction useForceUpdate() {\n const [, setValue] = useState(0)\n\n return () => setValue(value => value + 1)\n}\n\nexport const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {\n const [editor, setEditor] = useState<Editor | null>(null)\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n const instance = new Editor(options)\n\n setEditor(instance)\n\n instance.on('transaction', () => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n forceUpdate()\n })\n })\n })\n\n return () => {\n instance.destroy()\n }\n }, deps)\n\n return editor\n}\n","import React from 'react'\nimport { Editor } from '@tiptap/core'\nimport { Editor as ExtendedEditor } from './Editor'\n\nfunction isClassComponent(Component: any) {\n return !!(\n typeof Component === 'function'\n && Component.prototype\n && Component.prototype.isReactComponent\n )\n}\n\nfunction isForwardRefComponent(Component: any) {\n return !!(\n typeof Component === 'object'\n && Component.$$typeof?.toString() === 'Symbol(react.forward_ref)'\n )\n}\n\nexport interface ReactRendererOptions {\n editor: Editor,\n props?: Record<string, any>,\n as?: string,\n className?: string,\n}\n\ntype ComponentType<R> =\n | React.ComponentClass\n | React.FunctionComponent\n | React.ForwardRefExoticComponent<{ items: any[], command: any } & React.RefAttributes<R>>\n\nexport class ReactRenderer<R = unknown> {\n id: string\n\n editor: ExtendedEditor\n\n component: any\n\n element: Element\n\n props: Record<string, any>\n\n reactElement: React.ReactNode\n\n ref: R | null = null\n\n constructor(component: ComponentType<R>, {\n editor,\n props = {},\n as = 'div',\n className = '',\n }: ReactRendererOptions) {\n this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString()\n this.component = component\n this.editor = editor as ExtendedEditor\n this.props = props\n this.element = document.createElement(as)\n this.element.classList.add('react-renderer')\n\n if (className) {\n this.element.classList.add(...className.split(' '))\n }\n\n this.render()\n }\n\n render(): void {\n const Component = this.component\n const props = this.props\n\n if (isClassComponent(Component) || isForwardRefComponent(Component)) {\n props.ref = (ref: R) => {\n this.ref = ref\n }\n }\n\n this.reactElement = <Component {...props } />\n\n if (this.editor?.contentComponent) {\n this.editor.contentComponent.setState({\n renderers: this.editor.contentComponent.state.renderers.set(\n this.id,\n this,\n ),\n })\n }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n this.props = {\n ...this.props,\n ...props,\n }\n\n this.render()\n }\n\n destroy(): void {\n if (this.editor?.contentComponent) {\n const { renderers } = this.editor.contentComponent.state\n\n renderers.delete(this.id)\n\n this.editor.contentComponent.setState({\n renderers,\n })\n }\n }\n}\n","import { createContext, useContext } from 'react'\n\nexport interface ReactNodeViewContextProps {\n onDragStart: (event: DragEvent) => void,\n nodeViewContentRef: (element: HTMLElement | null) => void,\n}\n\nexport const ReactNodeViewContext = createContext<Partial<ReactNodeViewContextProps>>({\n onDragStart: undefined,\n})\n\nexport const useReactNodeView = () => useContext(ReactNodeViewContext)\n","import React from 'react'\nimport {\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererProps,\n NodeViewRendererOptions,\n} from '@tiptap/core'\nimport { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView'\n\nexport interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {\n update: ((props: {\n oldNode: ProseMirrorNode,\n oldDecorations: Decoration[],\n newNode: ProseMirrorNode,\n newDecorations: Decoration[],\n updateProps: () => void,\n }) => boolean) | null,\n as?: string,\n}\n\nclass ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeViewRendererOptions> {\n\n renderer!: ReactRenderer\n\n contentDOMElement!: HTMLElement | null\n\n mount() {\n const props: NodeViewProps = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations,\n selected: false,\n extension: this.extension,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n deleteNode: () => this.deleteNode(),\n }\n\n if (!(this.component as any).displayName) {\n const capitalizeFirstChar = (string: string): string => {\n return string.charAt(0).toUpperCase() + string.substring(1)\n }\n\n this.component.displayName = capitalizeFirstChar(this.extension.name)\n }\n\n const ReactNodeViewProvider: React.FunctionComponent = componentProps => {\n const Component = this.component\n const onDragStart = this.onDragStart.bind(this)\n const nodeViewContentRef: ReactNodeViewContextProps['nodeViewContentRef'] = element => {\n if (\n element\n && this.contentDOMElement\n && element.firstChild !== this.contentDOMElement\n ) {\n element.appendChild(this.contentDOMElement)\n }\n }\n\n return (\n <ReactNodeViewContext.Provider value={{ onDragStart, nodeViewContentRef }}>\n <Component {...componentProps} />\n </ReactNodeViewContext.Provider>\n )\n }\n\n ReactNodeViewProvider.displayName = 'ReactNodeView'\n\n this.contentDOMElement = this.node.isLeaf\n ? null\n : document.createElement(this.node.isInline ? 'span' : 'div')\n\n if (this.contentDOMElement) {\n // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari\n // With this fix it seems to work fine\n // See: https://github.com/ueberdosis/tiptap/issues/1197\n this.contentDOMElement.style.whiteSpace = 'inherit'\n }\n\n let as = this.node.isInline ? 'span' : 'div'\n\n if (this.options.as) {\n as = this.options.as\n }\n\n this.renderer = new ReactRenderer(ReactNodeViewProvider, {\n editor: this.editor,\n props,\n as,\n className: `node-${this.node.type.name}`,\n })\n }\n\n get dom() {\n if (\n this.renderer.element.firstElementChild\n && !this.renderer.element.firstElementChild?.hasAttribute('data-node-view-wrapper')\n ) {\n throw Error('Please use the NodeViewWrapper component for your node view.')\n }\n\n return this.renderer.element\n }\n\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.contentDOMElement\n }\n\n update(node: ProseMirrorNode, decorations: Decoration[]) {\n const updateProps = (props?: Record<string, any>) => {\n this.renderer.updateProps(props)\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (typeof this.options.update === 'function') {\n const oldNode = this.node\n const oldDecorations = this.decorations\n\n this.node = node\n this.decorations = decorations\n\n return this.options.update({\n oldNode,\n oldDecorations,\n newNode: node,\n newDecorations: decorations,\n updateProps: () => updateProps({ node, decorations }),\n })\n }\n\n if (node === this.node && this.decorations === decorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n\n updateProps({ node, decorations })\n\n return true\n }\n\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n }\n\n destroy() {\n this.renderer.destroy()\n this.contentDOMElement = null\n }\n}\n\nexport function ReactNodeViewRenderer(component: any, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer {\n return (props: NodeViewRendererProps) => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {}\n }\n\n return new ReactNodeView(component, props, options) as ProseMirrorNodeView\n }\n}\n","import React, { HTMLProps } from 'react'\nimport ReactDOM from 'react-dom'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\n\nconst Portals: React.FC<{ renderers: Map<string, ReactRenderer> }> = ({ renderers }) => {\n return (\n <>\n {Array.from(renderers).map(([key, renderer]) => {\n return ReactDOM.createPortal(\n renderer.reactElement,\n renderer.element,\n key,\n )\n })}\n </>\n )\n}\n\nexport interface EditorContentProps extends HTMLProps<HTMLDivElement> {\n editor: Editor | null,\n}\n\nexport interface EditorContentState {\n renderers: Map<string, ReactRenderer>\n}\n\nexport class PureEditorContent extends React.Component<EditorContentProps, EditorContentState> {\n editorContentRef: React.RefObject<any>\n\n constructor(props: EditorContentProps) {\n super(props)\n this.editorContentRef = React.createRef()\n\n this.state = {\n renderers: new Map(),\n }\n }\n\n componentDidMount() {\n this.init()\n }\n\n componentDidUpdate() {\n this.init()\n }\n\n init() {\n const { editor } = this.props\n\n if (editor && editor.options.element) {\n if (editor.contentComponent) {\n return\n }\n\n const element = this.editorContentRef.current\n\n element.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element,\n })\n\n editor.contentComponent = this\n\n editor.createNodeViews()\n }\n }\n\n componentWillUnmount() {\n const { editor } = this.props\n\n if (!editor) {\n return\n }\n\n if (!editor.isDestroyed) {\n editor.view.setProps({\n nodeViews: {},\n })\n }\n\n editor.contentComponent = null\n\n if (!editor.options.element.firstChild) {\n return\n }\n\n const newElement = document.createElement('div')\n\n newElement.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element: newElement,\n })\n }\n\n render() {\n const { editor, ...rest } = this.props\n\n return (\n <>\n <div ref={this.editorContentRef} {...rest} />\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\nexport const EditorContent = React.memo(PureEditorContent)\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewWrapperProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewWrapper: React.FC<NodeViewWrapperProps> = React.forwardRef((props, ref) => {\n const { onDragStart } = useReactNodeView()\n const Tag = props.as || 'div'\n\n return (\n <Tag\n {...props}\n ref={ref}\n data-node-view-wrapper=\"\"\n onDragStart={onDragStart}\n style={{\n ...props.style,\n whiteSpace: 'normal',\n }}\n />\n )\n})\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewContentProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewContent: React.FC<NodeViewContentProps> = props => {\n const Tag = props.as || 'div'\n const { nodeViewContentRef } = useReactNodeView()\n\n return (\n <Tag\n {...props}\n ref={nodeViewContentRef}\n data-node-view-content=\"\"\n style={{\n ...props.style,\n whiteSpace: 'pre-wrap',\n }}\n />\n )\n}\n"],"names":["useState","useEffect","BubbleMenuPlugin","React","CoreEditor","FloatingMenuPlugin","createContext","useContext","NodeView","ReactDOM"],"mappings":";;;;;;;;;;;QAWa,UAAU,GAA8B,KAAK;MACxD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAwB,IAAI,CAAC,CAAA;MAEnEC,eAAS,CAAC;UACR,IAAI,CAAC,OAAO,EAAE;cACZ,OAAM;WACP;UAED,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;cAC5B,OAAM;WACP;UAED,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,GAClB,GAAG,KAAK,CAAA;UAET,MAAM,MAAM,GAAGC,oCAAgB,CAAC;cAC9B,SAAS;cACT,MAAM;cACN,OAAO;cACP,YAAY;cACZ,UAAU;WACX,CAAC,CAAA;UAEF,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;UAC7B,OAAO,MAAM,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;OAChD,EAAE;UACD,KAAK,CAAC,MAAM;UACZ,OAAO;OACR,CAAC,CAAA;MAEF,QACEC,iDAAK,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,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ACJ,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;UAEtC,QACEA;cACEA,iDAAK,GAAG,EAAE,IAAI,CAAC,gBAAgB,KAAM,IAAI,GAAI;cAC7CA,wCAAC,OAAO,IAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAI,CAC3C,EACJ;OACF;GACF;QAEY,aAAa,GAAGA,yBAAK,CAAC,IAAI,CAAC,iBAAiB;;QCrG5C,eAAe,GAAmCA,yBAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG;MACzF,MAAM,EAAE,WAAW,EAAE,GAAG,gBAAgB,EAAE,CAAA;MAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;MAE7B,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,GAAG,4BACe,EAAE,EACzB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE;cACL,GAAG,KAAK,CAAC,KAAK;cACd,UAAU,EAAE,QAAQ;WACrB,GACD,EACH;EACH,CAAC;;QChBY,eAAe,GAAmC,KAAK;MAClE,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;MAC7B,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;MAEjD,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,kBAAkB,4BACA,EAAE,EACzB,KAAK,EAAE;cACL,GAAG,KAAK,CAAC,KAAK;cACd,UAAU,EAAE,UAAU;WACvB,GACD,EACH;EACH;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/react",
3
3
  "description": "React components for tiptap",
4
- "version": "2.0.0-beta.1",
4
+ "version": "2.0.0-beta.102",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,18 +15,31 @@
15
15
  "main": "dist/tiptap-react.cjs.js",
16
16
  "umd": "dist/tiptap-react.umd.js",
17
17
  "module": "dist/tiptap-react.esm.js",
18
- "unpkg": "dist/tiptap-react.bundle.umd.min.js",
19
18
  "types": "dist/packages/react/src/index.d.ts",
20
19
  "files": [
21
20
  "src",
22
21
  "dist"
23
22
  ],
23
+ "devDependencies": {
24
+ "@types/react": "^17.0.37",
25
+ "@types/react-dom": "^17.0.11",
26
+ "react": "^17.0.0",
27
+ "react-dom": "^17.0.0"
28
+ },
24
29
  "peerDependencies": {
25
30
  "@tiptap/core": "^2.0.0-beta.1",
26
- "react": "^17.0.1"
31
+ "react": "^17.0.0",
32
+ "react-dom": "^17.0.0"
27
33
  },
28
34
  "dependencies": {
29
- "prosemirror-view": "^1.17.8"
35
+ "@tiptap/extension-bubble-menu": "^2.0.0-beta.53",
36
+ "@tiptap/extension-floating-menu": "^2.0.0-beta.48",
37
+ "prosemirror-view": "^1.23.3"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/ueberdosis/tiptap",
42
+ "directory": "packages/react"
30
43
  },
31
- "gitHead": "67781052b0ac805fbf82099a50e27f1dd28f8061"
44
+ "gitHead": "8844627773ac1cfb0d01eaf1f52b3be937701b2d"
32
45
  }
@@ -0,0 +1,51 @@
1
+ import React, {
2
+ useEffect, useState,
3
+ } from 'react'
4
+ import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
5
+
6
+ type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
7
+
8
+ export type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {
9
+ className?: string,
10
+ }
11
+
12
+ export const BubbleMenu: React.FC<BubbleMenuProps> = props => {
13
+ const [element, setElement] = useState<HTMLDivElement | null>(null)
14
+
15
+ useEffect(() => {
16
+ if (!element) {
17
+ return
18
+ }
19
+
20
+ if (props.editor.isDestroyed) {
21
+ return
22
+ }
23
+
24
+ const {
25
+ pluginKey = 'bubbleMenu',
26
+ editor,
27
+ tippyOptions = {},
28
+ shouldShow = null,
29
+ } = props
30
+
31
+ const plugin = BubbleMenuPlugin({
32
+ pluginKey,
33
+ editor,
34
+ element,
35
+ tippyOptions,
36
+ shouldShow,
37
+ })
38
+
39
+ editor.registerPlugin(plugin)
40
+ return () => editor.unregisterPlugin(pluginKey)
41
+ }, [
42
+ props.editor,
43
+ element,
44
+ ])
45
+
46
+ return (
47
+ <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>
48
+ {props.children}
49
+ </div>
50
+ )
51
+ }
package/src/Editor.ts ADDED
@@ -0,0 +1,7 @@
1
+ import React from 'react'
2
+ import { Editor as CoreEditor } from '@tiptap/core'
3
+ import { EditorContentProps, EditorContentState } from './EditorContent'
4
+
5
+ export class Editor extends CoreEditor {
6
+ public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null
7
+ }