@stesura/react-prosemirror 3.2.11-stesura.1

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 (296) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +939 -0
  3. package/dist/cjs/AbstractEditorView.js +4 -0
  4. package/dist/cjs/ReactEditorView.js +194 -0
  5. package/dist/cjs/StaticEditorView.js +89 -0
  6. package/dist/cjs/browser.js +53 -0
  7. package/dist/cjs/commands/reorderSiblings.js +72 -0
  8. package/dist/cjs/components/ChildNodeViews.js +418 -0
  9. package/dist/cjs/components/CursorWrapper.js +84 -0
  10. package/dist/cjs/components/EditorStateSelectorsProvider.js +90 -0
  11. package/dist/cjs/components/LayoutGroup.js +112 -0
  12. package/dist/cjs/components/NativeWidgetView.js +108 -0
  13. package/dist/cjs/components/OutputSpec.js +121 -0
  14. package/dist/cjs/components/ProseMirror.js +146 -0
  15. package/dist/cjs/components/ProseMirrorDoc.js +74 -0
  16. package/dist/cjs/components/SeparatorHackView.js +99 -0
  17. package/dist/cjs/components/TextNodeView.js +113 -0
  18. package/dist/cjs/components/TrailingHackView.js +87 -0
  19. package/dist/cjs/components/WidgetView.js +94 -0
  20. package/dist/cjs/components/WidgetViewComponentProps.js +4 -0
  21. package/dist/cjs/components/marks/DefaultMarkView.js +70 -0
  22. package/dist/cjs/components/marks/MarkView.js +85 -0
  23. package/dist/cjs/components/marks/MarkViewComponentProps.js +4 -0
  24. package/dist/cjs/components/marks/MarkViewConstructorView.js +116 -0
  25. package/dist/cjs/components/marks/ReactMarkView.js +109 -0
  26. package/dist/cjs/components/nodes/DefaultNodeView.js +68 -0
  27. package/dist/cjs/components/nodes/DocNodeView.js +97 -0
  28. package/dist/cjs/components/nodes/NodeView.js +129 -0
  29. package/dist/cjs/components/nodes/NodeViewComponentProps.js +4 -0
  30. package/dist/cjs/components/nodes/NodeViewConstructorView.js +145 -0
  31. package/dist/cjs/components/nodes/ReactNodeView.js +189 -0
  32. package/dist/cjs/constants.js +33 -0
  33. package/dist/cjs/contexts/ChildDescriptionsContext.js +19 -0
  34. package/dist/cjs/contexts/EditorContext.js +12 -0
  35. package/dist/cjs/contexts/EditorStateContext.js +12 -0
  36. package/dist/cjs/contexts/EditorStateStoreContext.js +45 -0
  37. package/dist/cjs/contexts/IgnoreMutationContext.js +12 -0
  38. package/dist/cjs/contexts/LayoutGroupContext.js +12 -0
  39. package/dist/cjs/contexts/NodeViewContext.js +12 -0
  40. package/dist/cjs/contexts/RenderStoreContext.js +54 -0
  41. package/dist/cjs/contexts/SelectNodeContext.js +12 -0
  42. package/dist/cjs/contexts/StopEventContext.js +12 -0
  43. package/dist/cjs/decorations/ReactWidgetType.js +58 -0
  44. package/dist/cjs/decorations/computeDocDeco.js +44 -0
  45. package/dist/cjs/decorations/internalTypes.js +4 -0
  46. package/dist/cjs/decorations/iterDeco.js +91 -0
  47. package/dist/cjs/decorations/viewDecorations.js +155 -0
  48. package/dist/cjs/dom.js +147 -0
  49. package/dist/cjs/findDOMNode.js +46 -0
  50. package/dist/cjs/hooks/useClientLayoutEffect.js +19 -0
  51. package/dist/cjs/hooks/useComponentEventListeners.js +72 -0
  52. package/dist/cjs/hooks/useEditor.js +130 -0
  53. package/dist/cjs/hooks/useEditorEffect.js +39 -0
  54. package/dist/cjs/hooks/useEditorEventCallback.js +38 -0
  55. package/dist/cjs/hooks/useEditorEventListener.js +34 -0
  56. package/dist/cjs/hooks/useEditorState.js +18 -0
  57. package/dist/cjs/hooks/useEditorStateSelector.js +17 -0
  58. package/dist/cjs/hooks/useEffectEvent.js +34 -0
  59. package/dist/cjs/hooks/useForceUpdate.js +15 -0
  60. package/dist/cjs/hooks/useIgnoreMutation.js +24 -0
  61. package/dist/cjs/hooks/useIsComposingIn.js +25 -0
  62. package/dist/cjs/hooks/useIsEditorStatic.js +15 -0
  63. package/dist/cjs/hooks/useIsNodeSelected.js +21 -0
  64. package/dist/cjs/hooks/useLayoutGroupEffect.js +20 -0
  65. package/dist/cjs/hooks/useMarkViewDescription.js +134 -0
  66. package/dist/cjs/hooks/useNodePos.js +18 -0
  67. package/dist/cjs/hooks/useNodeViewDescription.js +154 -0
  68. package/dist/cjs/hooks/useReactKeys.js +17 -0
  69. package/dist/cjs/hooks/useSelectNode.js +30 -0
  70. package/dist/cjs/hooks/useSetDom.js +57 -0
  71. package/dist/cjs/hooks/useStopEvent.js +24 -0
  72. package/dist/cjs/index.js +85 -0
  73. package/dist/cjs/package.json +3 -0
  74. package/dist/cjs/plugins/beforeInputPlugin.js +356 -0
  75. package/dist/cjs/plugins/reactKeys.js +121 -0
  76. package/dist/cjs/props.js +283 -0
  77. package/dist/cjs/refs.js +28 -0
  78. package/dist/cjs/testing/editorViewTestHelpers.js +109 -0
  79. package/dist/cjs/testing/setupProseMirrorView.js +94 -0
  80. package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +26 -0
  81. package/dist/cjs/tiptap/TiptapEditor.js +34 -0
  82. package/dist/cjs/tiptap/TiptapEditorContent.js +143 -0
  83. package/dist/cjs/tiptap/TiptapEditorView.js +130 -0
  84. package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +12 -0
  85. package/dist/cjs/tiptap/extensions/ReactProseMirror.js +40 -0
  86. package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +21 -0
  87. package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +104 -0
  88. package/dist/cjs/tiptap/hooks/useEditor.js +318 -0
  89. package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +15 -0
  90. package/dist/cjs/tiptap/hooks/useTiptapEditor.js +35 -0
  91. package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +35 -0
  92. package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +35 -0
  93. package/dist/cjs/tiptap/index.js +48 -0
  94. package/dist/cjs/tiptap/tiptapNodeView.js +245 -0
  95. package/dist/cjs/viewdesc.js +862 -0
  96. package/dist/esm/AbstractEditorView.js +1 -0
  97. package/dist/esm/ReactEditorView.js +194 -0
  98. package/dist/esm/StaticEditorView.js +79 -0
  99. package/dist/esm/browser.js +43 -0
  100. package/dist/esm/commands/reorderSiblings.js +63 -0
  101. package/dist/esm/components/ChildNodeViews.js +359 -0
  102. package/dist/esm/components/CursorWrapper.js +33 -0
  103. package/dist/esm/components/EditorStateSelectorsProvider.js +31 -0
  104. package/dist/esm/components/LayoutGroup.js +67 -0
  105. package/dist/esm/components/NativeWidgetView.js +57 -0
  106. package/dist/esm/components/OutputSpec.js +71 -0
  107. package/dist/esm/components/ProseMirror.js +95 -0
  108. package/dist/esm/components/ProseMirrorDoc.js +15 -0
  109. package/dist/esm/components/SeparatorHackView.js +48 -0
  110. package/dist/esm/components/TextNodeView.js +103 -0
  111. package/dist/esm/components/TrailingHackView.js +36 -0
  112. package/dist/esm/components/WidgetView.js +43 -0
  113. package/dist/esm/components/WidgetViewComponentProps.js +1 -0
  114. package/dist/esm/components/marks/DefaultMarkView.js +19 -0
  115. package/dist/esm/components/marks/MarkView.js +34 -0
  116. package/dist/esm/components/marks/MarkViewComponentProps.js +1 -0
  117. package/dist/esm/components/marks/MarkViewConstructorView.js +65 -0
  118. package/dist/esm/components/marks/ReactMarkView.js +58 -0
  119. package/dist/esm/components/nodes/DefaultNodeView.js +17 -0
  120. package/dist/esm/components/nodes/DocNodeView.js +46 -0
  121. package/dist/esm/components/nodes/NodeView.js +67 -0
  122. package/dist/esm/components/nodes/NodeViewComponentProps.js +1 -0
  123. package/dist/esm/components/nodes/NodeViewConstructorView.js +94 -0
  124. package/dist/esm/components/nodes/ReactNodeView.js +138 -0
  125. package/dist/esm/constants.js +15 -0
  126. package/dist/esm/contexts/ChildDescriptionsContext.js +9 -0
  127. package/dist/esm/contexts/EditorContext.js +7 -0
  128. package/dist/esm/contexts/EditorStateContext.js +2 -0
  129. package/dist/esm/contexts/EditorStateStoreContext.js +27 -0
  130. package/dist/esm/contexts/IgnoreMutationContext.js +2 -0
  131. package/dist/esm/contexts/LayoutGroupContext.js +2 -0
  132. package/dist/esm/contexts/NodeViewContext.js +2 -0
  133. package/dist/esm/contexts/RenderStoreContext.js +33 -0
  134. package/dist/esm/contexts/SelectNodeContext.js +2 -0
  135. package/dist/esm/contexts/StopEventContext.js +2 -0
  136. package/dist/esm/decorations/ReactWidgetType.js +40 -0
  137. package/dist/esm/decorations/computeDocDeco.js +44 -0
  138. package/dist/esm/decorations/internalTypes.js +1 -0
  139. package/dist/esm/decorations/iterDeco.js +85 -0
  140. package/dist/esm/decorations/viewDecorations.js +155 -0
  141. package/dist/esm/dom.js +110 -0
  142. package/dist/esm/findDOMNode.js +31 -0
  143. package/dist/esm/hooks/useClientLayoutEffect.js +9 -0
  144. package/dist/esm/hooks/useComponentEventListeners.js +87 -0
  145. package/dist/esm/hooks/useEditor.js +128 -0
  146. package/dist/esm/hooks/useEditorEffect.js +46 -0
  147. package/dist/esm/hooks/useEditorEventCallback.js +38 -0
  148. package/dist/esm/hooks/useEditorEventListener.js +28 -0
  149. package/dist/esm/hooks/useEditorState.js +10 -0
  150. package/dist/esm/hooks/useEditorStateSelector.js +14 -0
  151. package/dist/esm/hooks/useEffectEvent.js +24 -0
  152. package/dist/esm/hooks/useForceUpdate.js +8 -0
  153. package/dist/esm/hooks/useIgnoreMutation.js +14 -0
  154. package/dist/esm/hooks/useIsComposingIn.js +17 -0
  155. package/dist/esm/hooks/useIsEditorStatic.js +8 -0
  156. package/dist/esm/hooks/useIsNodeSelected.js +11 -0
  157. package/dist/esm/hooks/useLayoutGroupEffect.js +10 -0
  158. package/dist/esm/hooks/useMarkViewDescription.js +124 -0
  159. package/dist/esm/hooks/useNodePos.js +15 -0
  160. package/dist/esm/hooks/useNodeViewDescription.js +144 -0
  161. package/dist/esm/hooks/useReactKeys.js +7 -0
  162. package/dist/esm/hooks/useSelectNode.js +20 -0
  163. package/dist/esm/hooks/useSetDom.js +47 -0
  164. package/dist/esm/hooks/useStopEvent.js +14 -0
  165. package/dist/esm/index.js +19 -0
  166. package/dist/esm/plugins/beforeInputPlugin.js +346 -0
  167. package/dist/esm/plugins/reactKeys.js +106 -0
  168. package/dist/esm/props.js +267 -0
  169. package/dist/esm/refs.js +18 -0
  170. package/dist/esm/testing/editorViewTestHelpers.js +86 -0
  171. package/dist/esm/testing/setupProseMirrorView.js +76 -0
  172. package/dist/esm/tiptap/ReactProseMirrorNodeView.js +22 -0
  173. package/dist/esm/tiptap/TiptapEditor.js +24 -0
  174. package/dist/esm/tiptap/TiptapEditorContent.js +99 -0
  175. package/dist/esm/tiptap/TiptapEditorView.js +76 -0
  176. package/dist/esm/tiptap/contexts/TiptapEditorContext.js +2 -0
  177. package/dist/esm/tiptap/extensions/ReactProseMirror.js +30 -0
  178. package/dist/esm/tiptap/extensions/ReactProseMirrorCommands.js +11 -0
  179. package/dist/esm/tiptap/extensions/commands/updateAttributes.js +96 -0
  180. package/dist/esm/tiptap/hooks/useEditor.js +308 -0
  181. package/dist/esm/tiptap/hooks/useIsInReactProseMirror.js +9 -0
  182. package/dist/esm/tiptap/hooks/useTiptapEditor.js +31 -0
  183. package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +42 -0
  184. package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +35 -0
  185. package/dist/esm/tiptap/index.js +9 -0
  186. package/dist/esm/tiptap/tiptapNodeView.js +211 -0
  187. package/dist/esm/viewdesc.js +844 -0
  188. package/dist/tsconfig.tsbuildinfo +1 -0
  189. package/dist/types/AbstractEditorView.d.ts +28 -0
  190. package/dist/types/ReactEditorView.d.ts +102 -0
  191. package/dist/types/StaticEditorView.d.ts +26 -0
  192. package/dist/types/__tests__/viewdesc.test.d.ts +1 -0
  193. package/dist/types/browser.d.ts +15 -0
  194. package/dist/types/commands/__tests__/reorderSiblings.test.d.ts +1 -0
  195. package/dist/types/commands/reorderSiblings.d.ts +14 -0
  196. package/dist/types/components/ChildNodeViews.d.ts +9 -0
  197. package/dist/types/components/CursorWrapper.d.ts +3 -0
  198. package/dist/types/components/EditorStateSelectorsProvider.d.ts +10 -0
  199. package/dist/types/components/LayoutGroup.d.ts +12 -0
  200. package/dist/types/components/NativeWidgetView.d.ts +8 -0
  201. package/dist/types/components/OutputSpec.d.ts +10 -0
  202. package/dist/types/components/ProseMirror.d.ts +14 -0
  203. package/dist/types/components/ProseMirrorDoc.d.ts +16 -0
  204. package/dist/types/components/SeparatorHackView.d.ts +6 -0
  205. package/dist/types/components/TextNodeView.d.ts +27 -0
  206. package/dist/types/components/TrailingHackView.d.ts +6 -0
  207. package/dist/types/components/WidgetView.d.ts +8 -0
  208. package/dist/types/components/WidgetViewComponentProps.d.ts +7 -0
  209. package/dist/types/components/__tests__/ProseMirror.composition.test.d.ts +17 -0
  210. package/dist/types/components/__tests__/ProseMirror.domchange.test.d.ts +1 -0
  211. package/dist/types/components/__tests__/ProseMirror.draw-decoration.test.d.ts +1 -0
  212. package/dist/types/components/__tests__/ProseMirror.draw.test.d.ts +1 -0
  213. package/dist/types/components/__tests__/ProseMirror.memory-leak.test.d.ts +6 -0
  214. package/dist/types/components/__tests__/ProseMirror.mobile.test.d.ts +1 -0
  215. package/dist/types/components/__tests__/ProseMirror.node-view.test.d.ts +1 -0
  216. package/dist/types/components/__tests__/ProseMirror.selection.test.d.ts +1 -0
  217. package/dist/types/components/__tests__/ProseMirror.test.d.ts +1 -0
  218. package/dist/types/components/__tests__/stableContexts.test.d.ts +10 -0
  219. package/dist/types/components/marks/DefaultMarkView.d.ts +3 -0
  220. package/dist/types/components/marks/MarkView.d.ts +10 -0
  221. package/dist/types/components/marks/MarkViewComponentProps.d.ts +11 -0
  222. package/dist/types/components/marks/MarkViewConstructorView.d.ts +12 -0
  223. package/dist/types/components/marks/ReactMarkView.d.ts +12 -0
  224. package/dist/types/components/nodes/DefaultNodeView.d.ts +3 -0
  225. package/dist/types/components/nodes/DocNodeView.d.ts +12 -0
  226. package/dist/types/components/nodes/NodeView.d.ts +14 -0
  227. package/dist/types/components/nodes/NodeViewComponentProps.d.ts +13 -0
  228. package/dist/types/components/nodes/NodeViewConstructorView.d.ts +12 -0
  229. package/dist/types/components/nodes/ReactNodeView.d.ts +13 -0
  230. package/dist/types/constants.d.ts +4 -0
  231. package/dist/types/contexts/ChildDescriptionsContext.d.ts +7 -0
  232. package/dist/types/contexts/EditorContext.d.ts +18 -0
  233. package/dist/types/contexts/EditorStateContext.d.ts +2 -0
  234. package/dist/types/contexts/EditorStateStoreContext.d.ts +9 -0
  235. package/dist/types/contexts/IgnoreMutationContext.d.ts +5 -0
  236. package/dist/types/contexts/LayoutGroupContext.d.ts +5 -0
  237. package/dist/types/contexts/NodeViewContext.d.ts +9 -0
  238. package/dist/types/contexts/RenderStoreContext.d.ts +24 -0
  239. package/dist/types/contexts/SelectNodeContext.d.ts +5 -0
  240. package/dist/types/contexts/StopEventContext.d.ts +5 -0
  241. package/dist/types/contexts/__tests__/DeferredLayoutEffects.test.d.ts +1 -0
  242. package/dist/types/decorations/ReactWidgetType.d.ts +40 -0
  243. package/dist/types/decorations/computeDocDeco.d.ts +14 -0
  244. package/dist/types/decorations/internalTypes.d.ts +20 -0
  245. package/dist/types/decorations/iterDeco.d.ts +3 -0
  246. package/dist/types/decorations/viewDecorations.d.ts +14 -0
  247. package/dist/types/dom.d.ts +22 -0
  248. package/dist/types/findDOMNode.d.ts +3 -0
  249. package/dist/types/hooks/__tests__/useEditorEffect.test.d.ts +1 -0
  250. package/dist/types/hooks/useClientLayoutEffect.d.ts +2 -0
  251. package/dist/types/hooks/useComponentEventListeners.d.ts +34 -0
  252. package/dist/types/hooks/useEditor.d.ts +37 -0
  253. package/dist/types/hooks/useEditorEffect.d.ts +21 -0
  254. package/dist/types/hooks/useEditorEventCallback.d.ts +13 -0
  255. package/dist/types/hooks/useEditorEventListener.d.ts +8 -0
  256. package/dist/types/hooks/useEditorState.d.ts +5 -0
  257. package/dist/types/hooks/useEditorStateSelector.d.ts +10 -0
  258. package/dist/types/hooks/useEffectEvent.d.ts +1 -0
  259. package/dist/types/hooks/useForceUpdate.d.ts +5 -0
  260. package/dist/types/hooks/useIgnoreMutation.d.ts +2 -0
  261. package/dist/types/hooks/useIsComposingIn.d.ts +4 -0
  262. package/dist/types/hooks/useIsEditorStatic.d.ts +5 -0
  263. package/dist/types/hooks/useIsNodeSelected.d.ts +1 -0
  264. package/dist/types/hooks/useLayoutGroupEffect.d.ts +3 -0
  265. package/dist/types/hooks/useMarkViewDescription.d.ts +15 -0
  266. package/dist/types/hooks/useNodePos.d.ts +9 -0
  267. package/dist/types/hooks/useNodeViewDescription.d.ts +16 -0
  268. package/dist/types/hooks/useReactKeys.d.ts +2 -0
  269. package/dist/types/hooks/useSelectNode.d.ts +2 -0
  270. package/dist/types/hooks/useSetDom.d.ts +2 -0
  271. package/dist/types/hooks/useStopEvent.d.ts +2 -0
  272. package/dist/types/index.d.ts +21 -0
  273. package/dist/types/plugins/__tests__/reactKeys.test.d.ts +1 -0
  274. package/dist/types/plugins/beforeInputPlugin.d.ts +2 -0
  275. package/dist/types/plugins/reactKeys.d.ts +23 -0
  276. package/dist/types/props.d.ts +1173 -0
  277. package/dist/types/refs.d.ts +2 -0
  278. package/dist/types/testing/editorViewTestHelpers.d.ts +24 -0
  279. package/dist/types/testing/setupProseMirrorView.d.ts +2 -0
  280. package/dist/types/tiptap/ReactProseMirrorNodeView.d.ts +15 -0
  281. package/dist/types/tiptap/TiptapEditor.d.ts +6 -0
  282. package/dist/types/tiptap/TiptapEditorContent.d.ts +28 -0
  283. package/dist/types/tiptap/TiptapEditorView.d.ts +16 -0
  284. package/dist/types/tiptap/contexts/TiptapEditorContext.d.ts +6 -0
  285. package/dist/types/tiptap/extensions/ReactProseMirror.d.ts +9 -0
  286. package/dist/types/tiptap/extensions/ReactProseMirrorCommands.d.ts +2 -0
  287. package/dist/types/tiptap/extensions/commands/updateAttributes.d.ts +24 -0
  288. package/dist/types/tiptap/hooks/useEditor.d.ts +38 -0
  289. package/dist/types/tiptap/hooks/useIsInReactProseMirror.d.ts +6 -0
  290. package/dist/types/tiptap/hooks/useTiptapEditor.d.ts +11 -0
  291. package/dist/types/tiptap/hooks/useTiptapEditorEffect.d.ts +21 -0
  292. package/dist/types/tiptap/hooks/useTiptapEditorEventCallback.d.ts +13 -0
  293. package/dist/types/tiptap/index.d.ts +9 -0
  294. package/dist/types/tiptap/tiptapNodeView.d.ts +50 -0
  295. package/dist/types/viewdesc.d.ts +179 -0
  296. package/package.json +167 -0
@@ -0,0 +1,359 @@
1
+ import React, { cloneElement, createElement, memo, useCallback, useContext, useRef } from "react";
2
+ import { ChildDescriptionsContext } from "../contexts/ChildDescriptionsContext.js";
3
+ import { EditorContext } from "../contexts/EditorContext.js";
4
+ import { iterDeco } from "../decorations/iterDeco.js";
5
+ import { reactKeysPluginKey } from "../plugins/reactKeys.js";
6
+ import { htmlAttrsToReactProps, mergeReactProps } from "../props.js";
7
+ import { sameOuterDeco } from "../viewdesc.js";
8
+ import { NativeWidgetView } from "./NativeWidgetView.js";
9
+ import { SeparatorHackView } from "./SeparatorHackView.js";
10
+ import { TextNodeView } from "./TextNodeView.js";
11
+ import { TrailingHackView } from "./TrailingHackView.js";
12
+ import { WidgetView } from "./WidgetView.js";
13
+ import { MarkView } from "./marks/MarkView.js";
14
+ import { RemountableNodeView } from "./nodes/NodeView.js";
15
+ export function wrapInDeco(reactNode, deco) {
16
+ const { nodeName, ...attrs } = deco.type.attrs;
17
+ const props = htmlAttrsToReactProps(attrs);
18
+ // We auto-wrap text nodes in spans so that we can apply attributes
19
+ // and styles, but we want to avoid double-wrapping the same
20
+ // text node
21
+ if (nodeName || typeof reactNode === "string") {
22
+ return /*#__PURE__*/ createElement(nodeName ?? "span", props, reactNode);
23
+ }
24
+ return /*#__PURE__*/ cloneElement(reactNode, mergeReactProps(reactNode.props, props));
25
+ }
26
+ function areChildrenEqual(a, b) {
27
+ return a.type === b.type && a.marks.every((mark)=>mark.isInSet(b.marks)) && b.marks.every((mark)=>mark.isInSet(a.marks)) && a.key === b.key && (a.type !== "node" || b.type !== "node" || a.node.eq(b.node) && sameOuterDeco(a.outerDeco, b.outerDeco) && a.innerDeco.eq(b.innerDeco)) && a.widget === b.widget;
28
+ }
29
+ const ChildView = /*#__PURE__*/ memo(function ChildView(param) {
30
+ let { child, getInnerPos } = param;
31
+ const { view } = useContext(EditorContext);
32
+ const childRef = useRef(child);
33
+ childRef.current = child;
34
+ const getPos = useCallback(()=>{
35
+ return getInnerPos() + childRef.current.offset;
36
+ }, [
37
+ getInnerPos
38
+ ]);
39
+ return child.type === "widget" ? /*#__PURE__*/ React.createElement(WidgetView, {
40
+ key: child.key,
41
+ widget: child.widget,
42
+ getPos: getPos
43
+ }) : child.type === "native-widget" ? /*#__PURE__*/ React.createElement(NativeWidgetView, {
44
+ key: child.key,
45
+ widget: child.widget,
46
+ getPos: getPos
47
+ }) : child.type === "hack" ? /*#__PURE__*/ React.createElement(child.component, {
48
+ key: child.key,
49
+ getPos: getPos
50
+ }) : child.node.isText ? /*#__PURE__*/ React.createElement(ChildDescriptionsContext.Consumer, {
51
+ key: child.key
52
+ }, (param)=>{
53
+ let { siblingsRef, parentRef } = param;
54
+ return /*#__PURE__*/ React.createElement(TextNodeView, {
55
+ view: view,
56
+ node: child.node,
57
+ getPos: getPos,
58
+ siblingsRef: siblingsRef,
59
+ parentRef: parentRef,
60
+ decorations: child.outerDeco
61
+ });
62
+ }) : /*#__PURE__*/ React.createElement(RemountableNodeView, {
63
+ key: child.key,
64
+ node: child.node,
65
+ getPos: getPos,
66
+ outerDeco: child.outerDeco,
67
+ innerDeco: child.innerDeco
68
+ });
69
+ });
70
+ const InlinePartition = /*#__PURE__*/ memo(function InlinePartition(param) {
71
+ let { childViews, getInnerPos } = param;
72
+ const firstChild = childViews[0];
73
+ const firstChildRef = useRef(firstChild);
74
+ firstChildRef.current = firstChild;
75
+ const getPos = useCallback(()=>{
76
+ return getInnerPos() + firstChildRef.current.offset;
77
+ }, [
78
+ getInnerPos
79
+ ]);
80
+ const firstMark = firstChild.marks[0];
81
+ if (!firstMark) {
82
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, childViews.map((child)=>{
83
+ return /*#__PURE__*/ React.createElement(ChildView, {
84
+ key: child.key,
85
+ child: child,
86
+ getInnerPos: getInnerPos
87
+ });
88
+ }));
89
+ }
90
+ return /*#__PURE__*/ React.createElement(MarkView, {
91
+ key: firstChild.key,
92
+ mark: firstMark,
93
+ getPos: getPos,
94
+ inline: true
95
+ }, /*#__PURE__*/ React.createElement(InlineView, {
96
+ key: firstChild.key,
97
+ getInnerPos: getInnerPos,
98
+ childViews: childViews.map((child)=>({
99
+ ...child,
100
+ marks: child.marks.slice(1)
101
+ }))
102
+ }));
103
+ });
104
+ const InlineView = /*#__PURE__*/ memo(function InlineView(param) {
105
+ let { getInnerPos, childViews } = param;
106
+ // const editorState = useEditorState();
107
+ const partitioned = childViews.reduce((acc, child)=>{
108
+ const lastPartition = acc[acc.length - 1];
109
+ if (!lastPartition) {
110
+ return [
111
+ [
112
+ child
113
+ ]
114
+ ];
115
+ }
116
+ const lastChild = lastPartition[lastPartition.length - 1];
117
+ if (!lastChild) {
118
+ return [
119
+ ...acc.slice(0, acc.length),
120
+ [
121
+ child
122
+ ]
123
+ ];
124
+ }
125
+ if (!child.marks.length && !lastChild.marks.length || child.marks.length && lastChild.marks.length && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
126
+ child.marks[0]?.eq(lastChild.marks[0])) {
127
+ return [
128
+ ...acc.slice(0, acc.length - 1),
129
+ [
130
+ ...lastPartition.slice(0, lastPartition.length),
131
+ child
132
+ ]
133
+ ];
134
+ }
135
+ return [
136
+ ...acc,
137
+ [
138
+ child
139
+ ]
140
+ ];
141
+ }, []);
142
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, partitioned.map((childViews)=>{
143
+ const firstChild = childViews[0];
144
+ if (!firstChild) return null;
145
+ return /*#__PURE__*/ React.createElement(InlinePartition, {
146
+ key: firstChild.key,
147
+ childViews: childViews,
148
+ getInnerPos: getInnerPos
149
+ });
150
+ }));
151
+ });
152
+ function createKey(innerPos, offset, index, type, posToKey, widget) {
153
+ const pos = innerPos + offset;
154
+ const key = posToKey?.get(pos);
155
+ if (type === "widget" || type === "native-widget") {
156
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
+ if (widget.type.spec.key) // eslint-disable-next-line @typescript-eslint/no-explicit-any
158
+ return widget.type.spec.key;
159
+ if (type === "widget") {
160
+ // eslint-disable-next-line no-console
161
+ console.warn(`Widget at position ${pos} doesn't have a key specified. React ProseMirror will generate a key partially based on this widget’s index into its parent’s children. This can cause issues if there are multiple adjacent widgets.`);
162
+ }
163
+ return `${key}-${index}`;
164
+ }
165
+ if (key) return key;
166
+ // if (!doc) return pos;
167
+ const parentPos = innerPos - 1;
168
+ const parentKey = posToKey?.get(parentPos);
169
+ if (parentKey) return `${parentKey}-${offset}`;
170
+ return pos;
171
+ }
172
+ function adjustWidgetMarksForward(lastNodeChild, widgetChild) {
173
+ if (!widgetChild || // Using internal Decoration property, "type"
174
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
175
+ widgetChild.widget.type.side >= 0) return;
176
+ if (!lastNodeChild || !lastNodeChild.node.isInline) return;
177
+ const marksToSpread = lastNodeChild.marks;
178
+ widgetChild.marks = widgetChild.marks.reduce((acc, mark)=>mark.addToSet(acc), marksToSpread);
179
+ }
180
+ function adjustWidgetMarksBack(widgetChildren, nodeChild) {
181
+ if (!nodeChild.node.isInline) return;
182
+ const marksToSpread = nodeChild.marks;
183
+ for(let i = widgetChildren.length - 1; i >= 0; i--){
184
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
185
+ const child = widgetChildren[i];
186
+ if (// Using internal Decoration property, "type"
187
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
188
+ child.widget.type.side < 0 || // Using internal Decoration property, "type"
189
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
+ child.widget.type.spec.marks) {
191
+ continue;
192
+ }
193
+ child.marks = child.marks.reduce((acc, mark)=>mark.addToSet(acc), marksToSpread);
194
+ }
195
+ }
196
+ const ChildElement = /*#__PURE__*/ memo(function ChildElement(param) {
197
+ let { child, getInnerPos } = param;
198
+ const childRef = useRef(child);
199
+ childRef.current = child;
200
+ const getPos = useCallback(()=>{
201
+ return getInnerPos() + childRef.current.offset;
202
+ }, [
203
+ getInnerPos
204
+ ]);
205
+ if (child.type === "node") {
206
+ return child.marks.reduce((element, mark)=>/*#__PURE__*/ React.createElement(MarkView, {
207
+ mark: mark,
208
+ getPos: getPos,
209
+ inline: false
210
+ }, element), /*#__PURE__*/ React.createElement(RemountableNodeView, {
211
+ key: child.key,
212
+ outerDeco: child.outerDeco,
213
+ node: child.node,
214
+ innerDeco: child.innerDeco,
215
+ getPos: getPos
216
+ }));
217
+ } else {
218
+ return /*#__PURE__*/ React.createElement(InlineView, {
219
+ key: child.key,
220
+ childViews: [
221
+ child
222
+ ],
223
+ getInnerPos: getInnerPos
224
+ });
225
+ }
226
+ });
227
+ function createChildElements(children, getInnerPos) {
228
+ if (!children.length) return [];
229
+ if (children.every((child)=>child.type !== "node" || child.node.isInline)) {
230
+ return [
231
+ /*#__PURE__*/ React.createElement(InlineView, {
232
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
233
+ key: children[0].key,
234
+ childViews: children,
235
+ getInnerPos: getInnerPos
236
+ })
237
+ ];
238
+ }
239
+ return children.map((child)=>{
240
+ return /*#__PURE__*/ React.createElement(ChildElement, {
241
+ key: child.key,
242
+ child: child,
243
+ getInnerPos: getInnerPos
244
+ });
245
+ });
246
+ }
247
+ export const ChildNodeViews = /*#__PURE__*/ memo(function ChildNodeViews(param) {
248
+ let { getPos, node, innerDecorations } = param;
249
+ const { view } = useContext(EditorContext);
250
+ const getInnerPos = useCallback(()=>getPos() + 1, [
251
+ getPos
252
+ ]);
253
+ const childMap = useRef(new Map()).current;
254
+ if (!node) return null;
255
+ const keysSeen = new Map();
256
+ let widgetChildren = [];
257
+ let lastNodeChild = null;
258
+ iterDeco(node, innerDecorations, (widget, isNative, offset, index)=>{
259
+ const posToKey = reactKeysPluginKey.getState(view.state)?.posToKey;
260
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
261
+ const widgetMarks = widget.type.spec.marks ?? [];
262
+ let key;
263
+ if (isNative) {
264
+ key = createKey(getInnerPos(), offset, index, "native-widget", posToKey, widget);
265
+ const child = {
266
+ type: "native-widget",
267
+ widget,
268
+ marks: widgetMarks,
269
+ offset,
270
+ index,
271
+ key
272
+ };
273
+ const prevChild = childMap.get(key);
274
+ if (prevChild && areChildrenEqual(prevChild, child)) {
275
+ prevChild.offset = offset;
276
+ } else {
277
+ childMap.set(key, child);
278
+ }
279
+ keysSeen.set(key, keysSeen.size);
280
+ } else {
281
+ key = createKey(getInnerPos(), offset, index, "widget", posToKey, widget);
282
+ const child = {
283
+ type: "widget",
284
+ widget: widget,
285
+ marks: widgetMarks,
286
+ offset,
287
+ index,
288
+ key
289
+ };
290
+ const prevChild = childMap.get(key);
291
+ if (prevChild && areChildrenEqual(prevChild, child)) {
292
+ prevChild.offset = offset;
293
+ } else {
294
+ childMap.set(key, child);
295
+ }
296
+ keysSeen.set(key, keysSeen.size);
297
+ }
298
+ const child = childMap.get(key);
299
+ widgetChildren.push(child);
300
+ adjustWidgetMarksForward(lastNodeChild, childMap.get(key));
301
+ }, (childNode, outerDeco, innerDeco, offset, index)=>{
302
+ const posToKey = reactKeysPluginKey.getState(view.state)?.posToKey;
303
+ const key = createKey(getInnerPos(), offset, index, "node", posToKey);
304
+ const child = {
305
+ type: "node",
306
+ node: childNode,
307
+ marks: childNode.marks,
308
+ innerDeco,
309
+ outerDeco,
310
+ offset,
311
+ index,
312
+ key
313
+ };
314
+ const prevChild = childMap.get(key);
315
+ if (prevChild && areChildrenEqual(prevChild, child)) {
316
+ prevChild.offset = offset;
317
+ lastNodeChild = prevChild;
318
+ } else {
319
+ childMap.set(key, child);
320
+ lastNodeChild = child;
321
+ }
322
+ keysSeen.set(key, keysSeen.size);
323
+ adjustWidgetMarksBack(widgetChildren, lastNodeChild);
324
+ widgetChildren = [];
325
+ });
326
+ for (const key of childMap.keys()){
327
+ if (!keysSeen.has(key)) {
328
+ childMap.delete(key);
329
+ }
330
+ }
331
+ const children = Array.from(childMap.values()).sort(// We already ensured that these existed in keysSeen in the previous
332
+ // step
333
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
334
+ (a, b)=>keysSeen.get(a.key) - keysSeen.get(b.key));
335
+ if (node.isTextblock) {
336
+ const lastChild = children[children.length - 1];
337
+ if (!lastChild || lastChild.type !== "node" || lastChild.node.isInline && !lastChild.node.isText || // RegExp.test actually handles undefined just fine
338
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
339
+ /\n$/.test(lastChild.node.text)) {
340
+ children.push({
341
+ type: "hack",
342
+ component: SeparatorHackView,
343
+ marks: [],
344
+ offset: lastChild?.offset ?? 0,
345
+ index: (lastChild?.index ?? 0) + 1,
346
+ key: "trailing-hack-img"
347
+ }, {
348
+ type: "hack",
349
+ component: TrailingHackView,
350
+ marks: [],
351
+ offset: lastChild?.offset ?? 0,
352
+ index: (lastChild?.index ?? 0) + 2,
353
+ key: "trailing-hack-br"
354
+ });
355
+ }
356
+ }
357
+ const childElements = createChildElements(children, getInnerPos);
358
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, childElements);
359
+ });
@@ -0,0 +1,33 @@
1
+ import React, { forwardRef, useImperativeHandle, useRef } from "react";
2
+ import { ReactEditorView } from "../ReactEditorView.js";
3
+ import { domIndex } from "../dom.js";
4
+ import { useEditorEffect } from "../hooks/useEditorEffect.js";
5
+ export const CursorWrapper = /*#__PURE__*/ forwardRef(function CursorWrapper(param, ref) {
6
+ let { widget, getPos, ...props } = param;
7
+ const innerRef = useRef(null);
8
+ useImperativeHandle(ref, ()=>{
9
+ return innerRef.current;
10
+ }, []);
11
+ useEditorEffect((view)=>{
12
+ if (!(view instanceof ReactEditorView) || !innerRef.current) return;
13
+ view.domObserver.disconnectSelection();
14
+ const domSel = view.domSelection();
15
+ if (!domSel.isCollapsed) return;
16
+ const node = innerRef.current;
17
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
18
+ domSel.collapse(node.parentNode, domIndex(node) + 1);
19
+ view.cursorWrapped = true;
20
+ view.domObserver.connectSelection();
21
+ return ()=>{
22
+ view.cursorWrapped = false;
23
+ };
24
+ }, []);
25
+ return /*#__PURE__*/ React.createElement("img", {
26
+ ref: innerRef,
27
+ className: "ProseMirror-separator",
28
+ // eslint-disable-next-line react/no-unknown-property
29
+ "mark-placeholder": "true",
30
+ alt: "",
31
+ ...props
32
+ });
33
+ });
@@ -0,0 +1,31 @@
1
+ import React, { useContext, useLayoutEffect, useMemo } from "react";
2
+ import { EditorStateStoreContext, createEditorStateStore } from "../contexts/EditorStateStoreContext.js";
3
+ import { useEditorState } from "../hooks/useEditorState.js";
4
+ export function EditorStateSelectorsRegistrar(param) {
5
+ let { children } = param;
6
+ const store = useMemo(()=>createEditorStateStore(), []);
7
+ return /*#__PURE__*/ React.createElement(EditorStateStoreContext.Provider, {
8
+ value: store
9
+ }, children);
10
+ }
11
+ export function EditorStateSelectorsProvider(param) {
12
+ let { children } = param;
13
+ const editorState = useEditorState();
14
+ const store = useContext(EditorStateStoreContext);
15
+ // This _must_ be set during render so that child components
16
+ // get the latest values from their selectors during render,
17
+ // if they happen to render before store.notifyListeners()
18
+ // is called
19
+ store.setState(editorState);
20
+ // This means that we get a double-render whenever the selectors update,
21
+ // but everything is consistent during both renders.
22
+ // Only components with new selector values will render on
23
+ // the second render cycle
24
+ useLayoutEffect(()=>{
25
+ store.notifyListeners();
26
+ }, [
27
+ editorState,
28
+ store
29
+ ]);
30
+ return children;
31
+ }
@@ -0,0 +1,67 @@
1
+ /* Copyright (c) The New York Times Company */ import React, { useCallback, useRef } from "react";
2
+ import { LayoutGroupContext } from "../contexts/LayoutGroupContext.js";
3
+ import { useClientLayoutEffect } from "../hooks/useClientLayoutEffect.js";
4
+ import { useForceUpdate } from "../hooks/useForceUpdate.js";
5
+ /**
6
+ * Provides a boundary for grouping layout effects.
7
+ *
8
+ * Descendant components can invoke the `useLayoutGroupEffect` hook to register
9
+ * effects that run after all descendants within the group have processed their
10
+ * regular layout effects.
11
+ */ export function LayoutGroup(param) {
12
+ let { children } = param;
13
+ const createQueue = useRef(new Set()).current;
14
+ const destroyQueue = useRef(new Set()).current;
15
+ const isMounted = useRef(false);
16
+ const forceUpdate = useForceUpdate();
17
+ const isUpdatePending = useRef(true);
18
+ const ensureFlush = useCallback(()=>{
19
+ if (!isUpdatePending.current) {
20
+ forceUpdate();
21
+ isUpdatePending.current = true;
22
+ }
23
+ }, [
24
+ forceUpdate
25
+ ]);
26
+ const register = useCallback((effect)=>{
27
+ let destroy;
28
+ const create = ()=>{
29
+ destroy = effect();
30
+ };
31
+ createQueue.add(create);
32
+ ensureFlush();
33
+ return ()=>{
34
+ createQueue.delete(create);
35
+ if (destroy) {
36
+ if (isMounted.current) {
37
+ destroyQueue.add(destroy);
38
+ ensureFlush();
39
+ } else {
40
+ destroy();
41
+ }
42
+ }
43
+ };
44
+ }, [
45
+ createQueue,
46
+ destroyQueue,
47
+ ensureFlush
48
+ ]);
49
+ useClientLayoutEffect(()=>{
50
+ isUpdatePending.current = false;
51
+ createQueue.forEach((create)=>create());
52
+ createQueue.clear();
53
+ return ()=>{
54
+ destroyQueue.forEach((destroy)=>destroy());
55
+ destroyQueue.clear();
56
+ };
57
+ });
58
+ useClientLayoutEffect(()=>{
59
+ isMounted.current = true;
60
+ return ()=>{
61
+ isMounted.current = false;
62
+ };
63
+ }, []);
64
+ return /*#__PURE__*/ React.createElement(LayoutGroupContext.Provider, {
65
+ value: register
66
+ }, children);
67
+ }
@@ -0,0 +1,57 @@
1
+ import React, { useContext, useRef } from "react";
2
+ import { ChildDescriptionsContext } from "../contexts/ChildDescriptionsContext.js";
3
+ import { useClientLayoutEffect } from "../hooks/useClientLayoutEffect.js";
4
+ import { useEditorEffect } from "../hooks/useEditorEffect.js";
5
+ import { WidgetViewDesc, placeViewDesc } from "../viewdesc.js";
6
+ export function NativeWidgetView(param) {
7
+ let { widget, getPos } = param;
8
+ const { siblingsRef, parentRef } = useContext(ChildDescriptionsContext);
9
+ const viewDescRef = useRef(null);
10
+ const rootDomRef = useRef(null);
11
+ useClientLayoutEffect(()=>{
12
+ const siblings = siblingsRef.current;
13
+ return ()=>{
14
+ if (!viewDescRef.current) return;
15
+ if (siblings.includes(viewDescRef.current)) {
16
+ const index = siblings.indexOf(viewDescRef.current);
17
+ siblings.splice(index, 1);
18
+ }
19
+ };
20
+ }, [
21
+ siblingsRef
22
+ ]);
23
+ useEditorEffect((view)=>{
24
+ if (!rootDomRef.current) return;
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ const toDOM = widget.type.toDOM;
27
+ let dom = typeof toDOM === "function" ? toDOM(view, getPos) : toDOM;
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ if (!widget.type.spec.raw) {
30
+ if (dom.nodeType != 1) {
31
+ const wrap = document.createElement("span");
32
+ wrap.appendChild(dom);
33
+ dom = wrap;
34
+ }
35
+ if (!dom.hasAttribute("contenteditable")) {
36
+ dom.contentEditable = "false";
37
+ }
38
+ dom.classList.add("ProseMirror-widget");
39
+ }
40
+ if (rootDomRef.current.firstElementChild === dom) return;
41
+ rootDomRef.current.replaceChildren(dom);
42
+ });
43
+ useClientLayoutEffect(()=>{
44
+ if (!rootDomRef.current) return;
45
+ if (!viewDescRef.current) {
46
+ viewDescRef.current = new WidgetViewDesc(parentRef.current, getPos, widget, rootDomRef.current);
47
+ } else {
48
+ viewDescRef.current.parent = parentRef.current;
49
+ viewDescRef.current.widget = widget;
50
+ viewDescRef.current.dom = rootDomRef.current;
51
+ }
52
+ placeViewDesc(siblingsRef.current, viewDescRef.current);
53
+ });
54
+ return /*#__PURE__*/ React.createElement("span", {
55
+ ref: rootDomRef
56
+ });
57
+ }
@@ -0,0 +1,71 @@
1
+ import React, { createElement, forwardRef, memo } from "react";
2
+ import { htmlAttrsToReactProps, mergeReactProps } from "../props.js";
3
+ import { useMergedDOMRefs } from "../refs.js";
4
+ /**
5
+ * Whether an output spec contains a hole
6
+ */ function hasHole(outputSpec) {
7
+ if (!Array.isArray(outputSpec)) {
8
+ throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");
9
+ }
10
+ const attrs = outputSpec[1];
11
+ let start = 1;
12
+ if (attrs && typeof attrs === "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
13
+ start = 2;
14
+ }
15
+ for(let i = start; i < outputSpec.length; i++){
16
+ const child = outputSpec[i];
17
+ if (child === 0) {
18
+ return true;
19
+ }
20
+ if (hasHole(child)) return true;
21
+ }
22
+ return false;
23
+ }
24
+ const ForwardedOutputSpec = /*#__PURE__*/ memo(/*#__PURE__*/ forwardRef(function OutputSpec(param, ref) {
25
+ let { outputSpec, isMark, contentDOMRef, children, ...propOverrides } = param;
26
+ const mergedRef = useMergedDOMRefs(ref, contentDOMRef);
27
+ if (typeof outputSpec === "string") {
28
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, outputSpec);
29
+ }
30
+ if (!Array.isArray(outputSpec)) {
31
+ throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");
32
+ }
33
+ const tagSpec = outputSpec[0];
34
+ const tagName = tagSpec.replace(" ", ":");
35
+ const attrs = outputSpec[1];
36
+ let props = {
37
+ ref,
38
+ ...propOverrides
39
+ };
40
+ let start = 1;
41
+ if (attrs && typeof attrs === "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
42
+ start = 2;
43
+ props = mergeReactProps(htmlAttrsToReactProps(attrs), props);
44
+ }
45
+ const content = [];
46
+ for(let i = start; i < outputSpec.length; i++){
47
+ const child = outputSpec[i];
48
+ if (child === 0) {
49
+ if (i < outputSpec.length - 1 || i > start) {
50
+ throw new RangeError("Content hole must be the only child of its parent node");
51
+ }
52
+ return /*#__PURE__*/ createElement(tagName, {
53
+ ...props,
54
+ ref: ref ? mergedRef : contentDOMRef
55
+ }, children);
56
+ }
57
+ content.push(/*#__PURE__*/ React.createElement(ForwardedOutputSpec, {
58
+ outputSpec: child,
59
+ contentDOMRef: contentDOMRef
60
+ }, children));
61
+ }
62
+ // https://prosemirror.net/docs/ref/#model.MarkSpec.toDOM
63
+ // When the resulting spec contains a hole, that is where the
64
+ // marked content is placed. Otherwise, it is appended to the top node.
65
+ if (isMark && !hasHole(outputSpec)) {
66
+ content.push(children);
67
+ props.ref = mergedRef;
68
+ }
69
+ return /*#__PURE__*/ createElement(tagName, props, ...content);
70
+ }));
71
+ export { ForwardedOutputSpec as OutputSpec };