@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,112 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "LayoutGroup", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return LayoutGroup;
9
+ }
10
+ });
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _LayoutGroupContext = require("../contexts/LayoutGroupContext.js");
13
+ const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
14
+ const _useForceUpdate = require("../hooks/useForceUpdate.js");
15
+ function _getRequireWildcardCache(nodeInterop) {
16
+ if (typeof WeakMap !== "function") return null;
17
+ var cacheBabelInterop = new WeakMap();
18
+ var cacheNodeInterop = new WeakMap();
19
+ return (_getRequireWildcardCache = function(nodeInterop) {
20
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
21
+ })(nodeInterop);
22
+ }
23
+ function _interop_require_wildcard(obj, nodeInterop) {
24
+ if (!nodeInterop && obj && obj.__esModule) {
25
+ return obj;
26
+ }
27
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
28
+ return {
29
+ default: obj
30
+ };
31
+ }
32
+ var cache = _getRequireWildcardCache(nodeInterop);
33
+ if (cache && cache.has(obj)) {
34
+ return cache.get(obj);
35
+ }
36
+ var newObj = {
37
+ __proto__: null
38
+ };
39
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
40
+ for(var key in obj){
41
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
42
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
43
+ if (desc && (desc.get || desc.set)) {
44
+ Object.defineProperty(newObj, key, desc);
45
+ } else {
46
+ newObj[key] = obj[key];
47
+ }
48
+ }
49
+ }
50
+ newObj.default = obj;
51
+ if (cache) {
52
+ cache.set(obj, newObj);
53
+ }
54
+ return newObj;
55
+ }
56
+ function LayoutGroup(param) {
57
+ let { children } = param;
58
+ const createQueue = (0, _react.useRef)(new Set()).current;
59
+ const destroyQueue = (0, _react.useRef)(new Set()).current;
60
+ const isMounted = (0, _react.useRef)(false);
61
+ const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
62
+ const isUpdatePending = (0, _react.useRef)(true);
63
+ const ensureFlush = (0, _react.useCallback)(()=>{
64
+ if (!isUpdatePending.current) {
65
+ forceUpdate();
66
+ isUpdatePending.current = true;
67
+ }
68
+ }, [
69
+ forceUpdate
70
+ ]);
71
+ const register = (0, _react.useCallback)((effect)=>{
72
+ let destroy;
73
+ const create = ()=>{
74
+ destroy = effect();
75
+ };
76
+ createQueue.add(create);
77
+ ensureFlush();
78
+ return ()=>{
79
+ createQueue.delete(create);
80
+ if (destroy) {
81
+ if (isMounted.current) {
82
+ destroyQueue.add(destroy);
83
+ ensureFlush();
84
+ } else {
85
+ destroy();
86
+ }
87
+ }
88
+ };
89
+ }, [
90
+ createQueue,
91
+ destroyQueue,
92
+ ensureFlush
93
+ ]);
94
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
95
+ isUpdatePending.current = false;
96
+ createQueue.forEach((create)=>create());
97
+ createQueue.clear();
98
+ return ()=>{
99
+ destroyQueue.forEach((destroy)=>destroy());
100
+ destroyQueue.clear();
101
+ };
102
+ });
103
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
104
+ isMounted.current = true;
105
+ return ()=>{
106
+ isMounted.current = false;
107
+ };
108
+ }, []);
109
+ return /*#__PURE__*/ _react.default.createElement(_LayoutGroupContext.LayoutGroupContext.Provider, {
110
+ value: register
111
+ }, children);
112
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "NativeWidgetView", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return NativeWidgetView;
9
+ }
10
+ });
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
13
+ const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
14
+ const _useEditorEffect = require("../hooks/useEditorEffect.js");
15
+ const _viewdesc = require("../viewdesc.js");
16
+ function _getRequireWildcardCache(nodeInterop) {
17
+ if (typeof WeakMap !== "function") return null;
18
+ var cacheBabelInterop = new WeakMap();
19
+ var cacheNodeInterop = new WeakMap();
20
+ return (_getRequireWildcardCache = function(nodeInterop) {
21
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
22
+ })(nodeInterop);
23
+ }
24
+ function _interop_require_wildcard(obj, nodeInterop) {
25
+ if (!nodeInterop && obj && obj.__esModule) {
26
+ return obj;
27
+ }
28
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
29
+ return {
30
+ default: obj
31
+ };
32
+ }
33
+ var cache = _getRequireWildcardCache(nodeInterop);
34
+ if (cache && cache.has(obj)) {
35
+ return cache.get(obj);
36
+ }
37
+ var newObj = {
38
+ __proto__: null
39
+ };
40
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
41
+ for(var key in obj){
42
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
43
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
44
+ if (desc && (desc.get || desc.set)) {
45
+ Object.defineProperty(newObj, key, desc);
46
+ } else {
47
+ newObj[key] = obj[key];
48
+ }
49
+ }
50
+ }
51
+ newObj.default = obj;
52
+ if (cache) {
53
+ cache.set(obj, newObj);
54
+ }
55
+ return newObj;
56
+ }
57
+ function NativeWidgetView(param) {
58
+ let { widget, getPos } = param;
59
+ const { siblingsRef, parentRef } = (0, _react.useContext)(_ChildDescriptionsContext.ChildDescriptionsContext);
60
+ const viewDescRef = (0, _react.useRef)(null);
61
+ const rootDomRef = (0, _react.useRef)(null);
62
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
63
+ const siblings = siblingsRef.current;
64
+ return ()=>{
65
+ if (!viewDescRef.current) return;
66
+ if (siblings.includes(viewDescRef.current)) {
67
+ const index = siblings.indexOf(viewDescRef.current);
68
+ siblings.splice(index, 1);
69
+ }
70
+ };
71
+ }, [
72
+ siblingsRef
73
+ ]);
74
+ (0, _useEditorEffect.useEditorEffect)((view)=>{
75
+ if (!rootDomRef.current) return;
76
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
+ const toDOM = widget.type.toDOM;
78
+ let dom = typeof toDOM === "function" ? toDOM(view, getPos) : toDOM;
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ if (!widget.type.spec.raw) {
81
+ if (dom.nodeType != 1) {
82
+ const wrap = document.createElement("span");
83
+ wrap.appendChild(dom);
84
+ dom = wrap;
85
+ }
86
+ if (!dom.hasAttribute("contenteditable")) {
87
+ dom.contentEditable = "false";
88
+ }
89
+ dom.classList.add("ProseMirror-widget");
90
+ }
91
+ if (rootDomRef.current.firstElementChild === dom) return;
92
+ rootDomRef.current.replaceChildren(dom);
93
+ });
94
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
95
+ if (!rootDomRef.current) return;
96
+ if (!viewDescRef.current) {
97
+ viewDescRef.current = new _viewdesc.WidgetViewDesc(parentRef.current, getPos, widget, rootDomRef.current);
98
+ } else {
99
+ viewDescRef.current.parent = parentRef.current;
100
+ viewDescRef.current.widget = widget;
101
+ viewDescRef.current.dom = rootDomRef.current;
102
+ }
103
+ (0, _viewdesc.placeViewDesc)(siblingsRef.current, viewDescRef.current);
104
+ });
105
+ return /*#__PURE__*/ _react.default.createElement("span", {
106
+ ref: rootDomRef
107
+ });
108
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "OutputSpec", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ForwardedOutputSpec;
9
+ }
10
+ });
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _props = require("../props.js");
13
+ const _refs = require("../refs.js");
14
+ function _getRequireWildcardCache(nodeInterop) {
15
+ if (typeof WeakMap !== "function") return null;
16
+ var cacheBabelInterop = new WeakMap();
17
+ var cacheNodeInterop = new WeakMap();
18
+ return (_getRequireWildcardCache = function(nodeInterop) {
19
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
20
+ })(nodeInterop);
21
+ }
22
+ function _interop_require_wildcard(obj, nodeInterop) {
23
+ if (!nodeInterop && obj && obj.__esModule) {
24
+ return obj;
25
+ }
26
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
27
+ return {
28
+ default: obj
29
+ };
30
+ }
31
+ var cache = _getRequireWildcardCache(nodeInterop);
32
+ if (cache && cache.has(obj)) {
33
+ return cache.get(obj);
34
+ }
35
+ var newObj = {
36
+ __proto__: null
37
+ };
38
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
39
+ for(var key in obj){
40
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
41
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
42
+ if (desc && (desc.get || desc.set)) {
43
+ Object.defineProperty(newObj, key, desc);
44
+ } else {
45
+ newObj[key] = obj[key];
46
+ }
47
+ }
48
+ }
49
+ newObj.default = obj;
50
+ if (cache) {
51
+ cache.set(obj, newObj);
52
+ }
53
+ return newObj;
54
+ }
55
+ /**
56
+ * Whether an output spec contains a hole
57
+ */ function hasHole(outputSpec) {
58
+ if (!Array.isArray(outputSpec)) {
59
+ throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");
60
+ }
61
+ const attrs = outputSpec[1];
62
+ let start = 1;
63
+ if (attrs && typeof attrs === "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
64
+ start = 2;
65
+ }
66
+ for(let i = start; i < outputSpec.length; i++){
67
+ const child = outputSpec[i];
68
+ if (child === 0) {
69
+ return true;
70
+ }
71
+ if (hasHole(child)) return true;
72
+ }
73
+ return false;
74
+ }
75
+ const ForwardedOutputSpec = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ (0, _react.forwardRef)(function OutputSpec(param, ref) {
76
+ let { outputSpec, isMark, contentDOMRef, children, ...propOverrides } = param;
77
+ const mergedRef = (0, _refs.useMergedDOMRefs)(ref, contentDOMRef);
78
+ if (typeof outputSpec === "string") {
79
+ return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, outputSpec);
80
+ }
81
+ if (!Array.isArray(outputSpec)) {
82
+ throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");
83
+ }
84
+ const tagSpec = outputSpec[0];
85
+ const tagName = tagSpec.replace(" ", ":");
86
+ const attrs = outputSpec[1];
87
+ let props = {
88
+ ref,
89
+ ...propOverrides
90
+ };
91
+ let start = 1;
92
+ if (attrs && typeof attrs === "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
93
+ start = 2;
94
+ props = (0, _props.mergeReactProps)((0, _props.htmlAttrsToReactProps)(attrs), props);
95
+ }
96
+ const content = [];
97
+ for(let i = start; i < outputSpec.length; i++){
98
+ const child = outputSpec[i];
99
+ if (child === 0) {
100
+ if (i < outputSpec.length - 1 || i > start) {
101
+ throw new RangeError("Content hole must be the only child of its parent node");
102
+ }
103
+ return /*#__PURE__*/ (0, _react.createElement)(tagName, {
104
+ ...props,
105
+ ref: ref ? mergedRef : contentDOMRef
106
+ }, children);
107
+ }
108
+ content.push(/*#__PURE__*/ _react.default.createElement(ForwardedOutputSpec, {
109
+ outputSpec: child,
110
+ contentDOMRef: contentDOMRef
111
+ }, children));
112
+ }
113
+ // https://prosemirror.net/docs/ref/#model.MarkSpec.toDOM
114
+ // When the resulting spec contains a hole, that is where the
115
+ // marked content is placed. Otherwise, it is appended to the top node.
116
+ if (isMark && !hasHole(outputSpec)) {
117
+ content.push(children);
118
+ props.ref = mergedRef;
119
+ }
120
+ return /*#__PURE__*/ (0, _react.createElement)(tagName, props, ...content);
121
+ }));
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ProseMirror", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ProseMirror;
9
+ }
10
+ });
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
13
+ const _EditorContext = require("../contexts/EditorContext.js");
14
+ const _EditorStateContext = require("../contexts/EditorStateContext.js");
15
+ const _NodeViewContext = require("../contexts/NodeViewContext.js");
16
+ const _RenderStoreContext = require("../contexts/RenderStoreContext.js");
17
+ const _computeDocDeco = require("../decorations/computeDocDeco.js");
18
+ const _viewDecorations = require("../decorations/viewDecorations.js");
19
+ const _useEditor = require("../hooks/useEditor.js");
20
+ const _EditorStateSelectorsProvider = require("./EditorStateSelectorsProvider.js");
21
+ const _LayoutGroup = require("./LayoutGroup.js");
22
+ const _ProseMirrorDoc = require("./ProseMirrorDoc.js");
23
+ function _getRequireWildcardCache(nodeInterop) {
24
+ if (typeof WeakMap !== "function") return null;
25
+ var cacheBabelInterop = new WeakMap();
26
+ var cacheNodeInterop = new WeakMap();
27
+ return (_getRequireWildcardCache = function(nodeInterop) {
28
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
29
+ })(nodeInterop);
30
+ }
31
+ function _interop_require_wildcard(obj, nodeInterop) {
32
+ if (!nodeInterop && obj && obj.__esModule) {
33
+ return obj;
34
+ }
35
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
36
+ return {
37
+ default: obj
38
+ };
39
+ }
40
+ var cache = _getRequireWildcardCache(nodeInterop);
41
+ if (cache && cache.has(obj)) {
42
+ return cache.get(obj);
43
+ }
44
+ var newObj = {
45
+ __proto__: null
46
+ };
47
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
48
+ for(var key in obj){
49
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
50
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
51
+ if (desc && (desc.get || desc.set)) {
52
+ Object.defineProperty(newObj, key, desc);
53
+ } else {
54
+ newObj[key] = obj[key];
55
+ }
56
+ }
57
+ }
58
+ newObj.default = obj;
59
+ if (cache) {
60
+ cache.set(obj, newObj);
61
+ }
62
+ return newObj;
63
+ }
64
+ function getPos() {
65
+ return -1;
66
+ }
67
+ const rootChildDescriptionsContextValue = {
68
+ parentRef: {
69
+ current: undefined
70
+ },
71
+ siblingsRef: {
72
+ current: []
73
+ }
74
+ };
75
+ function ProseMirrorInner(param) {
76
+ let { children, nodeViewComponents, markViewComponents, ...props } = param;
77
+ const [mount, setMount] = (0, _react.useState)(null);
78
+ const { editor, state, renderStore } = (0, _useEditor.useEditor)(mount, props);
79
+ const nodeViewConstructors = editor.view.nodeViews;
80
+ const nodeViewContextValue = (0, _react.useMemo)(()=>{
81
+ return {
82
+ components: {
83
+ ...nodeViewComponents,
84
+ ...markViewComponents
85
+ },
86
+ constructors: nodeViewConstructors
87
+ };
88
+ }, [
89
+ markViewComponents,
90
+ nodeViewComponents,
91
+ nodeViewConstructors
92
+ ]);
93
+ const node = state.doc;
94
+ const decorations = (0, _computeDocDeco.computeDocDeco)(editor.view);
95
+ const innerDecorations = (0, _viewDecorations.viewDecorations)(editor.view);
96
+ const docNodeViewContextValue = (0, _react.useMemo)(()=>({
97
+ setMount,
98
+ node,
99
+ getPos,
100
+ decorations,
101
+ innerDecorations
102
+ }), [
103
+ node,
104
+ decorations,
105
+ innerDecorations
106
+ ]);
107
+ // An announced render keeps the previous context values: the consumers
108
+ // re-render through the store in this pass anyway. The flag is consumed
109
+ // here, so that a render the announcement did not cover (a transaction
110
+ // dispatched from a layout effect, say) changes the contexts again.
111
+ const contextValuesRef = (0, _react.useRef)({
112
+ state,
113
+ doc: docNodeViewContextValue
114
+ });
115
+ if (renderStore) {
116
+ renderStore.state = state;
117
+ renderStore.doc = docNodeViewContextValue;
118
+ if (!renderStore.announced) {
119
+ contextValuesRef.current = {
120
+ state,
121
+ doc: docNodeViewContextValue
122
+ };
123
+ }
124
+ renderStore.announced = false;
125
+ }
126
+ const contextValues = renderStore ? contextValuesRef.current : {
127
+ state,
128
+ doc: docNodeViewContextValue
129
+ };
130
+ return /*#__PURE__*/ _react.default.createElement(_EditorContext.EditorContext.Provider, {
131
+ value: editor
132
+ }, /*#__PURE__*/ _react.default.createElement(_RenderStoreContext.RenderStoreContext.Provider, {
133
+ value: renderStore
134
+ }, /*#__PURE__*/ _react.default.createElement(_EditorStateContext.EditorStateContext.Provider, {
135
+ value: contextValues.state
136
+ }, /*#__PURE__*/ _react.default.createElement(_EditorStateSelectorsProvider.EditorStateSelectorsProvider, null, /*#__PURE__*/ _react.default.createElement(_NodeViewContext.NodeViewContext.Provider, {
137
+ value: nodeViewContextValue
138
+ }, /*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Provider, {
139
+ value: rootChildDescriptionsContextValue
140
+ }, /*#__PURE__*/ _react.default.createElement(_ProseMirrorDoc.DocNodeViewContext.Provider, {
141
+ value: contextValues.doc
142
+ }, children)))))));
143
+ }
144
+ function ProseMirror(props) {
145
+ return /*#__PURE__*/ _react.default.createElement(_LayoutGroup.LayoutGroup, null, /*#__PURE__*/ _react.default.createElement(_EditorStateSelectorsProvider.EditorStateSelectorsRegistrar, null, /*#__PURE__*/ _react.default.createElement(ProseMirrorInner, props)));
146
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ DocNodeViewContext: function() {
13
+ return DocNodeViewContext;
14
+ },
15
+ ProseMirrorDoc: function() {
16
+ return ProseMirrorDoc;
17
+ }
18
+ });
19
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
20
+ const _RenderStoreContext = require("../contexts/RenderStoreContext.js");
21
+ const _DocNodeView = require("./nodes/DocNodeView.js");
22
+ function _getRequireWildcardCache(nodeInterop) {
23
+ if (typeof WeakMap !== "function") return null;
24
+ var cacheBabelInterop = new WeakMap();
25
+ var cacheNodeInterop = new WeakMap();
26
+ return (_getRequireWildcardCache = function(nodeInterop) {
27
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
28
+ })(nodeInterop);
29
+ }
30
+ function _interop_require_wildcard(obj, nodeInterop) {
31
+ if (!nodeInterop && obj && obj.__esModule) {
32
+ return obj;
33
+ }
34
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
35
+ return {
36
+ default: obj
37
+ };
38
+ }
39
+ var cache = _getRequireWildcardCache(nodeInterop);
40
+ if (cache && cache.has(obj)) {
41
+ return cache.get(obj);
42
+ }
43
+ var newObj = {
44
+ __proto__: null
45
+ };
46
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
47
+ for(var key in obj){
48
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
49
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
50
+ if (desc && (desc.get || desc.set)) {
51
+ Object.defineProperty(newObj, key, desc);
52
+ } else {
53
+ newObj[key] = obj[key];
54
+ }
55
+ }
56
+ }
57
+ newObj.default = obj;
58
+ if (cache) {
59
+ cache.set(obj, newObj);
60
+ }
61
+ return newObj;
62
+ }
63
+ const DocNodeViewContext = /*#__PURE__*/ (0, _react.createContext)(null);
64
+ const ProseMirrorDoc = /*#__PURE__*/ (0, _react.forwardRef)(function ProseMirrorDoc(param, ref) {
65
+ let { as, ...props } = param;
66
+ const docProps = (0, _react.useContext)(DocNodeViewContext);
67
+ const store = (0, _RenderStoreContext.useRenderStore)();
68
+ return /*#__PURE__*/ _react.default.createElement(_DocNodeView.DocNodeView, {
69
+ ref: ref,
70
+ ...props,
71
+ ...store?.doc ?? docProps,
72
+ as: as
73
+ });
74
+ });
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "SeparatorHackView", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return SeparatorHackView;
9
+ }
10
+ });
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _browser = require("../browser.js");
13
+ const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
14
+ const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
15
+ const _viewdesc = require("../viewdesc.js");
16
+ function _getRequireWildcardCache(nodeInterop) {
17
+ if (typeof WeakMap !== "function") return null;
18
+ var cacheBabelInterop = new WeakMap();
19
+ var cacheNodeInterop = new WeakMap();
20
+ return (_getRequireWildcardCache = function(nodeInterop) {
21
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
22
+ })(nodeInterop);
23
+ }
24
+ function _interop_require_wildcard(obj, nodeInterop) {
25
+ if (!nodeInterop && obj && obj.__esModule) {
26
+ return obj;
27
+ }
28
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
29
+ return {
30
+ default: obj
31
+ };
32
+ }
33
+ var cache = _getRequireWildcardCache(nodeInterop);
34
+ if (cache && cache.has(obj)) {
35
+ return cache.get(obj);
36
+ }
37
+ var newObj = {
38
+ __proto__: null
39
+ };
40
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
41
+ for(var key in obj){
42
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
43
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
44
+ if (desc && (desc.get || desc.set)) {
45
+ Object.defineProperty(newObj, key, desc);
46
+ } else {
47
+ newObj[key] = obj[key];
48
+ }
49
+ }
50
+ }
51
+ newObj.default = obj;
52
+ if (cache) {
53
+ cache.set(obj, newObj);
54
+ }
55
+ return newObj;
56
+ }
57
+ function SeparatorHackView(param) {
58
+ let { getPos } = param;
59
+ const { siblingsRef, parentRef } = (0, _react.useContext)(_ChildDescriptionsContext.ChildDescriptionsContext);
60
+ const viewDescRef = (0, _react.useRef)(null);
61
+ const ref = (0, _react.useRef)(null);
62
+ const [shouldRender, setShouldRender] = (0, _react.useState)(false);
63
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
64
+ const siblings = siblingsRef.current;
65
+ return ()=>{
66
+ if (!viewDescRef.current) return;
67
+ if (siblings.includes(viewDescRef.current)) {
68
+ const index = siblings.indexOf(viewDescRef.current);
69
+ siblings.splice(index, 1);
70
+ }
71
+ };
72
+ }, [
73
+ siblingsRef
74
+ ]);
75
+ // There's no risk of an infinite loop here, because
76
+ // we call setShouldRender conditionally
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
78
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
79
+ const nonHackSiblings = siblingsRef.current.filter((viewdesc)=>!(viewdesc instanceof _viewdesc.TrailingHackViewDesc));
80
+ const lastSibling = nonHackSiblings[nonHackSiblings.length - 1];
81
+ if (!shouldRender && (_browser.browser.safari || _browser.browser.chrome) && lastSibling?.dom?.contentEditable == "false") {
82
+ setShouldRender(true);
83
+ return;
84
+ }
85
+ if (!ref.current) return;
86
+ if (!viewDescRef.current) {
87
+ viewDescRef.current = new _viewdesc.TrailingHackViewDesc(parentRef.current, [], getPos, ref.current, null);
88
+ } else {
89
+ viewDescRef.current.parent = parentRef.current;
90
+ viewDescRef.current.dom = ref.current;
91
+ }
92
+ (0, _viewdesc.placeViewDesc)(siblingsRef.current, viewDescRef.current);
93
+ });
94
+ return shouldRender ? /*#__PURE__*/ _react.default.createElement("img", {
95
+ ref: ref,
96
+ className: "ProseMirror-separator",
97
+ alt: ""
98
+ }) : null;
99
+ }