@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,12 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "EditorContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return EditorContext;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const EditorContext = (0, _react.createContext)(null);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "EditorStateContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return EditorStateContext;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const EditorStateContext = (0, _react.createContext)(null);
@@ -0,0 +1,45 @@
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
+ EditorStateStoreContext: function() {
13
+ return EditorStateStoreContext;
14
+ },
15
+ createEditorStateStore: function() {
16
+ return createEditorStateStore;
17
+ }
18
+ });
19
+ const _react = require("react");
20
+ function createEditorStateStore() {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ let state = null;
23
+ let pendingNotify = false;
24
+ const listeners = new Set();
25
+ return {
26
+ getState: ()=>state,
27
+ subscribe: (listener)=>{
28
+ listeners.add(listener);
29
+ return ()=>listeners.delete(listener);
30
+ },
31
+ setState: (newState)=>{
32
+ if (state !== newState) {
33
+ state = newState;
34
+ pendingNotify = true;
35
+ }
36
+ },
37
+ notifyListeners: ()=>{
38
+ if (pendingNotify) {
39
+ pendingNotify = false;
40
+ listeners.forEach((l)=>l());
41
+ }
42
+ }
43
+ };
44
+ }
45
+ const EditorStateStoreContext = (0, _react.createContext)(null);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "IgnoreMutationContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return IgnoreMutationContext;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const IgnoreMutationContext = (0, _react.createContext)(null);
@@ -0,0 +1,12 @@
1
+ /* Copyright (c) The New York Times Company */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "LayoutGroupContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return LayoutGroupContext;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const LayoutGroupContext = /*#__PURE__*/ (0, _react.createContext)(null);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "NodeViewContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return NodeViewContext;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const NodeViewContext = (0, _react.createContext)(null);
@@ -0,0 +1,54 @@
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
+ RenderStoreContext: function() {
13
+ return RenderStoreContext;
14
+ },
15
+ createRenderStore: function() {
16
+ return createRenderStore;
17
+ },
18
+ useRenderStore: function() {
19
+ return useRenderStore;
20
+ }
21
+ });
22
+ const _react = require("react");
23
+ const createRenderStore = ()=>{
24
+ const listeners = new Set();
25
+ let version = 0;
26
+ const store = {
27
+ state: null,
28
+ doc: null,
29
+ announced: false,
30
+ getVersion: ()=>version,
31
+ subscribe: (listener)=>{
32
+ listeners.add(listener);
33
+ return ()=>{
34
+ listeners.delete(listener);
35
+ };
36
+ },
37
+ announce: ()=>{
38
+ // Nobody to re-render through the store: let the contexts change.
39
+ if (!listeners.size) return;
40
+ store.announced = true;
41
+ version++;
42
+ listeners.forEach((listener)=>listener());
43
+ }
44
+ };
45
+ return store;
46
+ };
47
+ const RenderStoreContext = (0, _react.createContext)(null);
48
+ const inertStore = createRenderStore();
49
+ const useRenderStore = ()=>{
50
+ const store = (0, _react.useContext)(RenderStoreContext);
51
+ const subscribed = store ?? inertStore;
52
+ (0, _react.useSyncExternalStore)(subscribed.subscribe, subscribed.getVersion, subscribed.getVersion);
53
+ return store;
54
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "SelectNodeContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return SelectNodeContext;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const SelectNodeContext = (0, _react.createContext)(null);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "StopEventContext", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return StopEventContext;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ const StopEventContext = (0, _react.createContext)(null);
@@ -0,0 +1,58 @@
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
+ ReactWidgetType: function() {
13
+ return ReactWidgetType;
14
+ },
15
+ widget: function() {
16
+ return widget;
17
+ }
18
+ });
19
+ const _prosemirrorview = require("prosemirror-view");
20
+ function compareObjs(a, b) {
21
+ if (a == b) return true;
22
+ for(const p in a)if (a[p] !== b[p]) return false;
23
+ for(const p in b)if (!(p in a)) return false;
24
+ return true;
25
+ }
26
+ const noSpec = {
27
+ side: 0
28
+ };
29
+ let ReactWidgetType = class ReactWidgetType {
30
+ Component;
31
+ side;
32
+ spec;
33
+ constructor(Component, spec){
34
+ this.Component = Component;
35
+ this.spec = spec ?? noSpec;
36
+ this.side = this.spec.side ?? 0;
37
+ }
38
+ map(mapping, span, offset, oldOffset) {
39
+ const { pos, deleted } = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);
40
+ // @ts-expect-error The Decoration constructor is private/internal, but
41
+ // we need to use it for our custom widget implementation here.
42
+ return deleted ? null : new _prosemirrorview.Decoration(pos - offset, pos - offset, this);
43
+ }
44
+ valid() {
45
+ return true;
46
+ }
47
+ eq(other) {
48
+ return this == other || other instanceof ReactWidgetType && (this.spec.key && this.spec.key == other.spec.key || this.Component == other.Component && compareObjs(this.spec, other.spec));
49
+ }
50
+ destroy() {
51
+ // Can be implemented with React effect hooks
52
+ }
53
+ };
54
+ function widget(pos, component, spec) {
55
+ // @ts-expect-error The Decoration constructor is private/internal, but
56
+ // we need to use it for our custom widget implementation here.
57
+ return new _prosemirrorview.Decoration(pos, pos, new ReactWidgetType(component, spec));
58
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "computeDocDeco", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return computeDocDeco;
9
+ }
10
+ });
11
+ const _prosemirrorview = require("prosemirror-view");
12
+ const DocDecorationsCache = new WeakMap();
13
+ function computeDocDeco(view) {
14
+ const attrs = Object.create(null);
15
+ attrs.class = "ProseMirror";
16
+ attrs.contenteditable = String(view.editable);
17
+ view.someProp("attributes", (value)=>{
18
+ if (typeof value == "function") value = value(view.state);
19
+ if (value) for(const attr in value){
20
+ if (attr == "class") attrs.class += " " + value[attr];
21
+ else if (attr == "style") attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];
22
+ else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName") attrs[attr] = String(value[attr]);
23
+ }
24
+ });
25
+ if (!attrs.translate) attrs.translate = "no";
26
+ const next = [
27
+ _prosemirrorview.Decoration.node(0, view.state.doc.content.size, attrs)
28
+ ];
29
+ const previous = DocDecorationsCache.get(view);
30
+ if (!previous) {
31
+ DocDecorationsCache.set(view, next);
32
+ return next;
33
+ }
34
+ if (previous[0].to !== view.state.doc.content.size) {
35
+ DocDecorationsCache.set(view, next);
36
+ return next;
37
+ }
38
+ // @ts-expect-error Internal property (Decoration.type)
39
+ if (!previous[0].type.eq(next[0].type)) {
40
+ DocDecorationsCache.set(view, next);
41
+ return next;
42
+ }
43
+ return previous;
44
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -0,0 +1,91 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "iterDeco", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return iterDeco;
9
+ }
10
+ });
11
+ const _ReactWidgetType = require("./ReactWidgetType.js");
12
+ function compareSide(a, b) {
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ return a.type.side - b.type.side;
15
+ }
16
+ function iterDeco(parent, deco, // Callbacks have been slightly modified to pass
17
+ // the offset, so that we can pass the position as
18
+ // a prop to components
19
+ onWidget, onNode) {
20
+ const locals = deco.locals(parent);
21
+ let offset = 0;
22
+ // Simple, cheap variant for when there are no local decorations
23
+ if (locals.length == 0) {
24
+ for(let i = 0; i < parent.childCount; i++){
25
+ const child = parent.child(i);
26
+ onNode(child, locals, deco.forChild(offset, child), offset, i);
27
+ offset += child.nodeSize;
28
+ }
29
+ return;
30
+ }
31
+ let decoIndex = 0;
32
+ const active = [];
33
+ let restNode = null;
34
+ for(let parentIndex = 0;;){
35
+ if (decoIndex < locals.length && locals[decoIndex].to == offset) {
36
+ let widget;
37
+ let widgets;
38
+ while(decoIndex < locals.length && locals[decoIndex].to == offset){
39
+ const next = locals[decoIndex++];
40
+ if (next.widget || // FORK: Our custom widget type can't report itself as a widget,
41
+ // so we have to explicitly check
42
+ next.type instanceof _ReactWidgetType.ReactWidgetType) {
43
+ if (!widget) widget = next;
44
+ else (widgets || (widgets = [
45
+ widget
46
+ ])).push(next);
47
+ }
48
+ }
49
+ if (widget) {
50
+ if (widgets) {
51
+ widgets.sort(compareSide);
52
+ for(let i = 0; i < widgets.length; i++)onWidget(widgets[i], // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ !(widgets[i].type instanceof _ReactWidgetType.ReactWidgetType), offset, parentIndex + i, !!restNode);
54
+ } else {
55
+ onWidget(widget, // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ !(widget.type instanceof _ReactWidgetType.ReactWidgetType), offset, parentIndex, !!restNode);
57
+ }
58
+ }
59
+ }
60
+ let child, index;
61
+ if (restNode) {
62
+ index = -1;
63
+ child = restNode;
64
+ restNode = null;
65
+ } else if (parentIndex < parent.childCount) {
66
+ index = parentIndex;
67
+ child = parent.child(parentIndex++);
68
+ } else {
69
+ break;
70
+ }
71
+ for(let i = 0; i < active.length; i++)if (active[i].to <= offset) active.splice(i--, 1);
72
+ while(decoIndex < locals.length && locals[decoIndex].from <= offset && locals[decoIndex].to > offset)active.push(locals[decoIndex++]);
73
+ let end = offset + child.nodeSize;
74
+ if (child.isText) {
75
+ let cutAt = end;
76
+ if (decoIndex < locals.length && locals[decoIndex].from < cutAt) cutAt = locals[decoIndex].from;
77
+ for(let i = 0; i < active.length; i++)if (active[i].to < cutAt) cutAt = active[i].to;
78
+ if (cutAt < end) {
79
+ restNode = child.cut(cutAt - offset);
80
+ child = child.cut(0, cutAt - offset);
81
+ end = cutAt;
82
+ index = -1;
83
+ }
84
+ } else {
85
+ while(decoIndex < locals.length && locals[decoIndex].to < end)decoIndex++;
86
+ }
87
+ const outerDeco = child.isInline && !child.isLeaf ? active.filter((d)=>!d.inline) : active.slice();
88
+ onNode(child, outerDeco, deco.forChild(offset, child), offset, index);
89
+ offset = end;
90
+ }
91
+ }
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "viewDecorations", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return viewDecorations;
9
+ }
10
+ });
11
+ const _prosemirrorview = require("prosemirror-view");
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ const none = [], noSpec = {};
14
+ const empty = _prosemirrorview.DecorationSet.empty;
15
+ // An abstraction that allows the code dealing with decorations to
16
+ // treat multiple DecorationSet objects as if it were a single object
17
+ // with (a subset of) the same interface.
18
+ let DecorationGroup = class DecorationGroup {
19
+ members;
20
+ constructor(members){
21
+ this.members = members;
22
+ }
23
+ map(mapping, doc) {
24
+ const mappedDecos = this.members.map((member)=>member.map(mapping, doc, noSpec));
25
+ return DecorationGroup.from(mappedDecos);
26
+ }
27
+ forChild(offset, child) {
28
+ if (child.isLeaf) return _prosemirrorview.DecorationSet.empty;
29
+ let found = [];
30
+ for(let i = 0; i < this.members.length; i++){
31
+ const result = this.members[i].forChild(offset, child);
32
+ if (result == empty) continue;
33
+ if (result instanceof DecorationGroup) found = found.concat(result.members);
34
+ else found.push(result);
35
+ }
36
+ return DecorationGroup.from(found);
37
+ }
38
+ eq(other) {
39
+ if (!(other instanceof DecorationGroup) || other.members.length != this.members.length) return false;
40
+ for(let i = 0; i < this.members.length; i++)if (!this.members[i].eq(other.members[i])) return false;
41
+ return true;
42
+ }
43
+ locals(node) {
44
+ let result, sorted = true;
45
+ for(let i = 0; i < this.members.length; i++){
46
+ const locals = this.members[i].localsInner(node);
47
+ if (!locals.length) continue;
48
+ if (!result) {
49
+ result = locals;
50
+ } else {
51
+ if (sorted) {
52
+ result = result.slice();
53
+ sorted = false;
54
+ }
55
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
56
+ for(let j = 0; j < locals.length; j++)result.push(locals[j]);
57
+ }
58
+ }
59
+ return result ? removeOverlap(sorted ? result : result.sort(byPos)) : none;
60
+ }
61
+ // Create a group for the given array of decoration sets, or return
62
+ // a single set when possible.
63
+ static from(members) {
64
+ switch(members.length){
65
+ case 0:
66
+ return empty;
67
+ case 1:
68
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
69
+ return members[0];
70
+ default:
71
+ return new DecorationGroup(members.every((m)=>m instanceof _prosemirrorview.DecorationSet) ? members : members.reduce((r, m)=>r.concat(m instanceof _prosemirrorview.DecorationSet ? m : m.members), []));
72
+ }
73
+ }
74
+ forEachSet(f) {
75
+ for(let i = 0; i < this.members.length; i++)// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
76
+ this.members[i].forEachSet(f);
77
+ }
78
+ };
79
+ // Used to sort decorations so that ones with a low start position
80
+ // come first, and within a set with the same start position, those
81
+ // with an smaller end position come first.
82
+ function byPos(a, b) {
83
+ return a.from - b.from || a.to - b.to;
84
+ }
85
+ // Scan a sorted array of decorations for partially overlapping spans,
86
+ // and split those so that only fully overlapping spans are left (to
87
+ // make subsequent rendering easier). Will return the input array if
88
+ // no partially overlapping spans are found (the common case).
89
+ function removeOverlap(spans) {
90
+ let working = spans;
91
+ for(let i = 0; i < working.length - 1; i++){
92
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
93
+ const span = working[i];
94
+ if (span.from != span.to) for(let j = i + 1; j < working.length; j++){
95
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
96
+ const next = working[j];
97
+ if (next.from == span.from) {
98
+ if (next.to != span.to) {
99
+ if (working == spans) working = spans.slice();
100
+ // Followed by a partially overlapping larger span. Split that
101
+ // span.
102
+ working[j] = next.copy(next.from, span.to);
103
+ insertAhead(working, j + 1, next.copy(span.to, next.to));
104
+ }
105
+ continue;
106
+ } else {
107
+ if (next.from < span.to) {
108
+ if (working == spans) working = spans.slice();
109
+ // The end of this one overlaps with a subsequent span. Split
110
+ // this one.
111
+ working[i] = span.copy(span.from, next.from);
112
+ insertAhead(working, j, span.copy(next.from, span.to));
113
+ }
114
+ break;
115
+ }
116
+ }
117
+ }
118
+ return working;
119
+ }
120
+ function insertAhead(array, i, deco) {
121
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
122
+ while(i < array.length && byPos(deco, array[i]) > 0)i++;
123
+ array.splice(i, 0, deco);
124
+ }
125
+ const ViewDecorationsCache = new WeakMap();
126
+ function viewDecorations(view) {
127
+ const found = [];
128
+ view.someProp("decorations", (f)=>{
129
+ const result = f(view.state);
130
+ if (result && result != empty) found.push(result);
131
+ });
132
+ const previous = ViewDecorationsCache.get(view);
133
+ if (!previous) {
134
+ const result = DecorationGroup.from(found);
135
+ ViewDecorationsCache.set(view, result);
136
+ return result;
137
+ }
138
+ let numPrevious = 0;
139
+ let areSetsEqual = true;
140
+ previous.forEachSet((set)=>{
141
+ const next = found[numPrevious++];
142
+ if (next !== set) {
143
+ areSetsEqual = false;
144
+ }
145
+ });
146
+ if (numPrevious !== found.length) {
147
+ areSetsEqual = false;
148
+ }
149
+ if (!areSetsEqual) {
150
+ const result = DecorationGroup.from(found);
151
+ ViewDecorationsCache.set(view, result);
152
+ return result;
153
+ }
154
+ return previous;
155
+ }