@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,147 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ "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
+ caretFromPoint: function() {
13
+ return caretFromPoint;
14
+ },
15
+ deepActiveElement: function() {
16
+ return deepActiveElement;
17
+ },
18
+ domIndex: function() {
19
+ return domIndex;
20
+ },
21
+ hasBlockDesc: function() {
22
+ return hasBlockDesc;
23
+ },
24
+ isEquivalentPosition: function() {
25
+ return isEquivalentPosition;
26
+ },
27
+ isOnEdge: function() {
28
+ return isOnEdge;
29
+ },
30
+ keyEvent: function() {
31
+ return keyEvent;
32
+ },
33
+ nodeSize: function() {
34
+ return nodeSize;
35
+ },
36
+ parentNode: function() {
37
+ return parentNode;
38
+ },
39
+ selectionCollapsed: function() {
40
+ return selectionCollapsed;
41
+ },
42
+ textRange: function() {
43
+ return textRange;
44
+ }
45
+ });
46
+ const domIndex = function(node) {
47
+ for(let index = 0;; index++){
48
+ node = node.previousSibling;
49
+ if (!node) return index;
50
+ }
51
+ };
52
+ const parentNode = function(node) {
53
+ const parent = node.assignedSlot || node.parentNode;
54
+ return parent && parent.nodeType == 11 ? parent.host : parent;
55
+ };
56
+ let reusedRange = null;
57
+ const textRange = function(node, from, to) {
58
+ const range = reusedRange || (reusedRange = document.createRange());
59
+ range.setEnd(node, to == null ? node.nodeValue.length : to);
60
+ range.setStart(node, from || 0);
61
+ return range;
62
+ };
63
+ const isEquivalentPosition = function(node, off, targetNode, targetOff) {
64
+ return targetNode && (scanFor(node, off, targetNode, targetOff, -1) || scanFor(node, off, targetNode, targetOff, 1));
65
+ };
66
+ const atomElements = /^(img|br|input|textarea|hr)$/i;
67
+ function scanFor(node, off, targetNode, targetOff, dir) {
68
+ for(;;){
69
+ if (node == targetNode && off == targetOff) return true;
70
+ if (off == (dir < 0 ? 0 : nodeSize(node))) {
71
+ const parent = node.parentNode;
72
+ if (!parent || parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false") return false;
73
+ off = domIndex(node) + (dir < 0 ? 0 : 1);
74
+ node = parent;
75
+ } else if (node.nodeType == 1) {
76
+ const child = node.childNodes[off + (dir < 0 ? -1 : 0)];
77
+ if (child.nodeType == 1 && child.contentEditable == "false") {
78
+ if (child.pmViewDesc?.ignoreForSelection) off += dir;
79
+ else return false;
80
+ } else {
81
+ node = child;
82
+ off = dir < 0 ? nodeSize(node) : 0;
83
+ }
84
+ } else {
85
+ return false;
86
+ }
87
+ }
88
+ }
89
+ function nodeSize(node) {
90
+ return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
91
+ }
92
+ function isOnEdge(node, offset, parent) {
93
+ for(let atStart = offset == 0, atEnd = offset == nodeSize(node); atStart || atEnd;){
94
+ if (node == parent) return true;
95
+ const index = domIndex(node);
96
+ node = node.parentNode;
97
+ if (!node) return false;
98
+ atStart = atStart && index == 0;
99
+ atEnd = atEnd && index == nodeSize(node);
100
+ }
101
+ return false;
102
+ }
103
+ function hasBlockDesc(dom) {
104
+ let desc;
105
+ for(let cur = dom; cur; cur = cur.parentNode)if (desc = cur.pmViewDesc) break;
106
+ return desc && desc.node && desc.node.isBlock && (desc.dom == dom || desc.contentDOM == dom);
107
+ }
108
+ const selectionCollapsed = function(domSel) {
109
+ return domSel.focusNode && isEquivalentPosition(domSel.focusNode, domSel.focusOffset, domSel.anchorNode, domSel.anchorOffset);
110
+ };
111
+ function keyEvent(keyCode, key) {
112
+ const event = document.createEvent("Event");
113
+ event.initEvent("keydown", true, true);
114
+ event.keyCode = keyCode;
115
+ event.key = event.code = key;
116
+ return event;
117
+ }
118
+ function deepActiveElement(doc) {
119
+ let elt = doc.activeElement;
120
+ while(elt && elt.shadowRoot)elt = elt.shadowRoot.activeElement;
121
+ return elt;
122
+ }
123
+ function caretFromPoint(doc, x, y) {
124
+ if (doc.caretPositionFromPoint) {
125
+ try {
126
+ // Firefox throws for this call in hard-to-predict circumstances (#994)
127
+ const pos = doc.caretPositionFromPoint(x, y);
128
+ // Clip the offset, because Chrome will return a text offset
129
+ // into <input> nodes, which can't be treated as a regular DOM
130
+ // offset
131
+ if (pos) return {
132
+ node: pos.offsetNode,
133
+ offset: Math.min(nodeSize(pos.offsetNode), pos.offset)
134
+ };
135
+ } catch (_) {
136
+ // pass
137
+ }
138
+ }
139
+ if (doc.caretRangeFromPoint) {
140
+ const range = doc.caretRangeFromPoint(x, y);
141
+ if (range) return {
142
+ node: range.startContainer,
143
+ offset: Math.min(nodeSize(range.startContainer), range.startOffset)
144
+ };
145
+ }
146
+ return;
147
+ }
@@ -0,0 +1,46 @@
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
+ findDOMNode: function() {
13
+ return findDOMNode;
14
+ },
15
+ getInstance: function() {
16
+ return getInstance;
17
+ }
18
+ });
19
+ const _reflection = require("react-reconciler/reflection.js");
20
+ function getInstance(key) {
21
+ return key._reactInternals;
22
+ }
23
+ // https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js#L322
24
+ function getPublicInstance(instance) {
25
+ return instance;
26
+ }
27
+ // https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactFiberReconciler.js#L153
28
+ function findHostInstance(component) {
29
+ const fiber = getInstance(component);
30
+ if (fiber === undefined) {
31
+ if (typeof component.render === "function") {
32
+ throw new Error("Unable to find node on an unmounted component.");
33
+ } else {
34
+ const keys = Object.keys(component).join(",");
35
+ throw new Error(`Argument appears to not be a ReactComponent. Keys: ${keys}`);
36
+ }
37
+ }
38
+ const hostFiber = (0, _reflection.findCurrentHostFiber)(fiber);
39
+ if (hostFiber === null) {
40
+ return null;
41
+ }
42
+ return getPublicInstance(hostFiber.stateNode);
43
+ }
44
+ function findDOMNode(componentOrElement) {
45
+ return findHostInstance(componentOrElement);
46
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useClientLayoutEffect", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useClientLayoutEffect;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ function useClientLayoutEffect() {
13
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14
+ args[_key] = arguments[_key];
15
+ }
16
+ if (typeof document === "undefined") return;
17
+ // eslint-disable-next-line react-hooks/rules-of-hooks, react-hooks/exhaustive-deps
18
+ (0, _react.useLayoutEffect)(...args);
19
+ }
@@ -0,0 +1,72 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useComponentEventListeners", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useComponentEventListeners;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _reactdom = require("react-dom");
13
+ function useComponentEventListeners(handleDOMEventsProp) {
14
+ const [registry, setRegistry] = (0, _react.useState)(new Map());
15
+ const registerEventListener = (0, _react.useCallback)((eventType, handler)=>{
16
+ const handlers = registry.get(eventType) ?? [];
17
+ handlers.unshift(handler);
18
+ if (!registry.has(eventType)) {
19
+ registry.set(eventType, handlers);
20
+ setRegistry(new Map(registry));
21
+ }
22
+ }, [
23
+ registry
24
+ ]);
25
+ const unregisterEventListener = (0, _react.useCallback)((eventType, handler)=>{
26
+ const handlers = registry.get(eventType);
27
+ handlers?.splice(handlers.indexOf(handler), 1);
28
+ }, [
29
+ registry
30
+ ]);
31
+ (0, _react.useLayoutEffect)(()=>{
32
+ if (!handleDOMEventsProp) return;
33
+ for (const [eventType, handler] of Object.entries(handleDOMEventsProp)){
34
+ if (!handler) return;
35
+ registerEventListener(eventType, handler);
36
+ }
37
+ return ()=>{
38
+ for (const [eventType, handler] of Object.entries(handleDOMEventsProp)){
39
+ if (!handler) return;
40
+ unregisterEventListener(eventType, handler);
41
+ }
42
+ };
43
+ }, [
44
+ handleDOMEventsProp,
45
+ registerEventListener,
46
+ unregisterEventListener
47
+ ]);
48
+ const handleDOMEvents = (0, _react.useMemo)(()=>{
49
+ const domEventHandlers = {};
50
+ for (const [eventType, handlers] of registry.entries()){
51
+ function handleEvent(view, event) {
52
+ for (const handler of handlers){
53
+ let handled = false;
54
+ (0, _reactdom.unstable_batchedUpdates)(()=>{
55
+ handled = !!handler(view, event);
56
+ });
57
+ if (handled || event.defaultPrevented) return true;
58
+ }
59
+ return false;
60
+ }
61
+ domEventHandlers[eventType] = handleEvent;
62
+ }
63
+ return domEventHandlers;
64
+ }, [
65
+ registry
66
+ ]);
67
+ return {
68
+ registerEventListener,
69
+ unregisterEventListener,
70
+ handleDOMEvents
71
+ };
72
+ }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEditor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useEditor;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _reactdom = require("react-dom");
13
+ const _ReactEditorView = require("../ReactEditorView.js");
14
+ const _StaticEditorView = require("../StaticEditorView.js");
15
+ const _constants = require("../constants.js");
16
+ const _RenderStoreContext = require("../contexts/RenderStoreContext.js");
17
+ const _beforeInputPlugin = require("../plugins/beforeInputPlugin.js");
18
+ const _useClientLayoutEffect = require("./useClientLayoutEffect.js");
19
+ const _useComponentEventListeners = require("./useComponentEventListeners.js");
20
+ const _useEffectEvent = require("./useEffectEvent.js");
21
+ const _useForceUpdate = require("./useForceUpdate.js");
22
+ let didWarnValueDefaultValue = false;
23
+ function useEditor(mount, options) {
24
+ if (process.env.NODE_ENV !== "production") {
25
+ if (options.defaultState !== undefined && options.state !== undefined && !didWarnValueDefaultValue) {
26
+ console.error("A component contains a ProseMirror editor with both state and defaultState props. " + "ProseMirror editors must be either controlled or uncontrolled " + "(specify either the state prop, or the defaultState prop, but not both). " + "Decide between using a controlled or uncontrolled ProseMirror editor " + "and remove one of these props. More info: " + "https://reactjs.org/link/controlled-components");
27
+ didWarnValueDefaultValue = true;
28
+ }
29
+ }
30
+ const flushSyncRef = (0, _react.useRef)(true);
31
+ const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
32
+ const defaultState = options.defaultState ?? _constants.EMPTY_STATE;
33
+ const [_state, setState] = (0, _react.useState)(defaultState);
34
+ const state = options.state ?? _state;
35
+ const [renderStore] = (0, _react.useState)(_RenderStoreContext.createRenderStore);
36
+ const { handleDOMEvents, registerEventListener, unregisterEventListener } = (0, _useComponentEventListeners.useComponentEventListeners)(options.handleDOMEvents);
37
+ const plugins = (0, _react.useMemo)(()=>[
38
+ ...options.plugins ?? [],
39
+ (0, _beforeInputPlugin.beforeInputPlugin)()
40
+ ], [
41
+ options.plugins
42
+ ]);
43
+ const dispatchTransaction = (0, _react.useCallback)(function dispatchTransaction(tr) {
44
+ const async = tr.getMeta("async");
45
+ if (flushSyncRef.current && !async) {
46
+ (0, _reactdom.flushSync)(()=>{
47
+ if (!options.state) {
48
+ setState((s)=>s.apply(tr));
49
+ }
50
+ if (options.dispatchTransaction) {
51
+ options.dispatchTransaction.call(this, tr);
52
+ }
53
+ if (options.stableContexts) {
54
+ renderStore.announce();
55
+ }
56
+ });
57
+ renderStore.announced = false;
58
+ } else {
59
+ if (!options.state) {
60
+ setState((s)=>s.apply(tr));
61
+ }
62
+ if (options.dispatchTransaction) {
63
+ options.dispatchTransaction.call(this, tr);
64
+ }
65
+ }
66
+ }, [
67
+ options.dispatchTransaction,
68
+ options.state,
69
+ options.stableContexts,
70
+ renderStore
71
+ ]);
72
+ const directEditorProps = {
73
+ ...options,
74
+ state,
75
+ plugins,
76
+ dispatchTransaction,
77
+ handleDOMEvents
78
+ };
79
+ const [view, setView] = (0, _react.useState)(()=>{
80
+ return new _StaticEditorView.StaticEditorView(directEditorProps);
81
+ });
82
+ const createEditorView = (0, _useEffectEvent.useEffectEvent)((mount)=>{
83
+ if (mount && !options.static) {
84
+ const view = new _ReactEditorView.ReactEditorView({
85
+ mount
86
+ }, directEditorProps);
87
+ view.dom.addEventListener("compositionend", forceUpdate);
88
+ return view;
89
+ }
90
+ return new _StaticEditorView.StaticEditorView(directEditorProps);
91
+ });
92
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
93
+ const view = createEditorView(mount);
94
+ setView(view);
95
+ return ()=>{
96
+ view.destroy();
97
+ };
98
+ }, [
99
+ createEditorView,
100
+ mount
101
+ ]);
102
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
103
+ // Ensure that the EditorView hasn't been destroyed before
104
+ // running effects. Running effects will reattach selection
105
+ // change listeners if the EditorView has been destroyed.
106
+ if (view instanceof _ReactEditorView.ReactEditorView && !view.isDestroyed && view.domSelection()) {
107
+ flushSyncRef.current = false;
108
+ view.commitPendingEffects();
109
+ flushSyncRef.current = true;
110
+ }
111
+ });
112
+ view.update(directEditorProps);
113
+ const editor = (0, _react.useMemo)(()=>({
114
+ view,
115
+ flushSyncRef,
116
+ registerEventListener,
117
+ unregisterEventListener,
118
+ isStatic: options.static ?? false
119
+ }), [
120
+ options.static,
121
+ registerEventListener,
122
+ unregisterEventListener,
123
+ view
124
+ ]);
125
+ return {
126
+ editor,
127
+ state,
128
+ renderStore: options.stableContexts ? renderStore : null
129
+ };
130
+ }
@@ -0,0 +1,39 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEditorEffect", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useEditorEffect;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _ReactEditorView = require("../ReactEditorView.js");
13
+ const _EditorContext = require("../contexts/EditorContext.js");
14
+ const _useLayoutGroupEffect = require("./useLayoutGroupEffect.js");
15
+ function useEditorEffect(effect, dependencies) {
16
+ const { view, flushSyncRef } = (0, _react.useContext)(_EditorContext.EditorContext);
17
+ // The rules of hooks want `effect` to be included in the
18
+ // dependency list, but dependency issues for `effect` will
19
+ // be caught by the linter at the call-site for
20
+ // `useEditorViewLayoutEffect`.
21
+ // Note: we specifically don't want to re-run the effect
22
+ // every time it changes, because it will most likely
23
+ // be defined inline and run on every re-render.
24
+ (0, _useLayoutGroupEffect.useLayoutGroupEffect)(()=>{
25
+ if (view instanceof _ReactEditorView.ReactEditorView) {
26
+ flushSyncRef.current = false;
27
+ const result = effect(view);
28
+ flushSyncRef.current = true;
29
+ return result;
30
+ }
31
+ }, // The rules of hooks want to be able to statically
32
+ // verify the dependencies for the effect, but this will
33
+ // have already happened at the call-site.
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ dependencies && [
36
+ view,
37
+ ...dependencies
38
+ ]);
39
+ }
@@ -0,0 +1,38 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEditorEventCallback", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useEditorEventCallback;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _ReactEditorView = require("../ReactEditorView.js");
13
+ const _EditorContext = require("../contexts/EditorContext.js");
14
+ const _useEditorEffect = require("./useEditorEffect.js");
15
+ function assertIsReactEditorView(view) {
16
+ if (view instanceof _ReactEditorView.ReactEditorView) {
17
+ return;
18
+ }
19
+ throw new DOMException("ProseMirror document is not mounted", "InvalidStateError");
20
+ }
21
+ function useEditorEventCallback(callback) {
22
+ const ref = (0, _react.useRef)(callback);
23
+ const { view } = (0, _react.useContext)(_EditorContext.EditorContext);
24
+ (0, _useEditorEffect.useEditorEffect)(()=>{
25
+ ref.current = callback;
26
+ }, [
27
+ callback
28
+ ]);
29
+ return (0, _react.useCallback)(function() {
30
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
31
+ args[_key] = arguments[_key];
32
+ }
33
+ assertIsReactEditorView(view);
34
+ return ref.current.call(this, view, ...args);
35
+ }, [
36
+ view
37
+ ]);
38
+ }
@@ -0,0 +1,34 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEditorEventListener", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useEditorEventListener;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _EditorContext = require("../contexts/EditorContext.js");
13
+ const _useEditorEffect = require("./useEditorEffect.js");
14
+ function useEditorEventListener(eventType, handler) {
15
+ const { registerEventListener, unregisterEventListener } = (0, _react.useContext)(_EditorContext.EditorContext);
16
+ const ref = (0, _react.useRef)(handler);
17
+ (0, _useEditorEffect.useEditorEffect)(()=>{
18
+ ref.current = handler;
19
+ }, [
20
+ handler
21
+ ]);
22
+ const eventHandler = (0, _react.useCallback)(function(view, event) {
23
+ return ref.current.call(this, view, event);
24
+ }, []);
25
+ (0, _useEditorEffect.useEditorEffect)(()=>{
26
+ registerEventListener(eventType, eventHandler);
27
+ return ()=>unregisterEventListener(eventType, eventHandler);
28
+ }, [
29
+ eventHandler,
30
+ eventType,
31
+ registerEventListener,
32
+ unregisterEventListener
33
+ ]);
34
+ }
@@ -0,0 +1,18 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEditorState", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useEditorState;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _EditorStateContext = require("../contexts/EditorStateContext.js");
13
+ const _RenderStoreContext = require("../contexts/RenderStoreContext.js");
14
+ function useEditorState() {
15
+ const editorState = (0, _react.useContext)(_EditorStateContext.EditorStateContext);
16
+ const store = (0, _RenderStoreContext.useRenderStore)();
17
+ return store?.state ?? editorState;
18
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEditorStateSelector", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useEditorStateSelector;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _EditorStateStoreContext = require("../contexts/EditorStateStoreContext.js");
13
+ function useEditorStateSelector(selector) {
14
+ const store = (0, _react.useContext)(_EditorStateStoreContext.EditorStateStoreContext);
15
+ const getSnapshot = ()=>selector(store.getState());
16
+ return (0, _react.useSyncExternalStore)(store.subscribe, getSnapshot, getSnapshot);
17
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useEffectEvent", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useEffectEvent;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ function useEffectEvent(fn) {
13
+ const ref = (0, _react.useRef)(fn);
14
+ // Ideally this would be a useInsertionEffect, but
15
+ // that was introduced in React 18 and we still
16
+ // support React 17. useLayoutEffect is safe
17
+ // here as long as the function returned by
18
+ // useEffectEvent isn't called in a layout effect
19
+ // that's defined _before_ the useEffectEvent
20
+ // call, and effect events are never passed
21
+ // to child components.
22
+ (0, _react.useLayoutEffect)(()=>{
23
+ ref.current = fn;
24
+ }, [
25
+ fn
26
+ ]);
27
+ return (0, _react.useCallback)(function() {
28
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
29
+ args[_key] = arguments[_key];
30
+ }
31
+ const f = ref.current;
32
+ return f(...args);
33
+ }, []);
34
+ }
@@ -0,0 +1,15 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useForceUpdate", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useForceUpdate;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ function useForceUpdate() {
13
+ const [, forceUpdate] = (0, _react.useReducer)((x)=>x + 1, 0);
14
+ return forceUpdate;
15
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useIgnoreMutation", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useIgnoreMutation;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _IgnoreMutationContext = require("../contexts/IgnoreMutationContext.js");
13
+ const _useEditorEffect = require("./useEditorEffect.js");
14
+ const _useEditorEventCallback = require("./useEditorEventCallback.js");
15
+ function useIgnoreMutation(ignoreMutation) {
16
+ const register = (0, _react.useContext)(_IgnoreMutationContext.IgnoreMutationContext);
17
+ const ignoreMutationMemo = (0, _useEditorEventCallback.useEditorEventCallback)(ignoreMutation);
18
+ (0, _useEditorEffect.useEditorEffect)(()=>{
19
+ return register(ignoreMutationMemo);
20
+ }, [
21
+ register,
22
+ ignoreMutationMemo
23
+ ]);
24
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useIsComposingIn", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useIsComposingIn;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const _NodeView = require("../components/nodes/NodeView.js");
13
+ const _index = require("../index.js");
14
+ function useIsComposingIn() {
15
+ const [isComposing, setIsComposing] = (0, _react.useState)(false);
16
+ const getPos = (0, _react.useContext)(_NodeView.GetPosContext);
17
+ (0, _index.useEditorEventListener)("compositionstart", (view)=>{
18
+ const compositionRoot = view.state.selection.$from.before();
19
+ setIsComposing(compositionRoot === getPos());
20
+ });
21
+ (0, _index.useEditorEventListener)("compositionend", ()=>{
22
+ setIsComposing(false);
23
+ });
24
+ return isComposing;
25
+ }