@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,283 @@
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
+ htmlAttrsToReactProps: function() {
13
+ return htmlAttrsToReactProps;
14
+ },
15
+ mergeReactProps: function() {
16
+ return mergeReactProps;
17
+ }
18
+ });
19
+ const _classnames = /*#__PURE__*/ _interop_require_default(require("classnames"));
20
+ function _interop_require_default(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+ let patched = false;
26
+ function patchConsoleError() {
27
+ if (patched) return;
28
+ /* eslint-disable no-console */ const consoleError = console.error;
29
+ console.error = function() {
30
+ for(var _len = arguments.length, data = new Array(_len), _key = 0; _key < _len; _key++){
31
+ data[_key] = arguments[_key];
32
+ }
33
+ const [message, prop, correction] = data;
34
+ if (typeof message === "string" && message.includes("Invalid DOM property `%s`. Did you mean `%s`?") && prop === "STYLE" && correction === "style") {
35
+ return;
36
+ }
37
+ consoleError(...data);
38
+ };
39
+ patched = true;
40
+ /* eslint-enable no-console */ }
41
+ function mergeStyleProps(a, b) {
42
+ if (!("STYLE" in a) || typeof a.STYLE !== "string") {
43
+ if (!("STYLE" in b) || typeof b.STYLE !== "string") {
44
+ return undefined;
45
+ }
46
+ return b.STYLE;
47
+ }
48
+ if (!("STYLE" in b) || typeof b.STYLE !== "string") {
49
+ return a.STYLE;
50
+ }
51
+ return `${a.STYLE.match(/;\s*$/) ? a.STYLE : `${a.STYLE};`} ${b.STYLE}`;
52
+ }
53
+ function mergeReactProps(a, b) {
54
+ return {
55
+ ...a,
56
+ ...b,
57
+ className: (0, _classnames.default)(a.className, b.className),
58
+ STYLE: mergeStyleProps(a, b),
59
+ style: {
60
+ ...a.style,
61
+ ...b.style
62
+ }
63
+ };
64
+ }
65
+ function htmlAttrsToReactProps(attrs) {
66
+ patchConsoleError();
67
+ const props = {};
68
+ for (const [attrName, attrValue] of Object.entries(attrs)){
69
+ switch(attrName.toLowerCase()){
70
+ case "class":
71
+ {
72
+ props.className = attrValue;
73
+ break;
74
+ }
75
+ case "style":
76
+ {
77
+ // HACK: React expects the `style` prop to be an
78
+ // object mapping from CSS property name to value.
79
+ // However, it will pass un-recognized props through
80
+ // to the underlying DOM element, and HTML attributes
81
+ // are case insensitive. So we use `STYLE` instead,
82
+ // which React doesn't intercept, but the DOM treats
83
+ // as `style`
84
+ props.STYLE = attrValue;
85
+ break;
86
+ }
87
+ case "autocapitalize":
88
+ {
89
+ props.autoCapitalize = attrValue;
90
+ break;
91
+ }
92
+ case "contenteditable":
93
+ {
94
+ if (attrValue === "" || attrValue === "true") {
95
+ props.contentEditable = true;
96
+ break;
97
+ }
98
+ if (attrValue === "false") {
99
+ props.contentEditable = false;
100
+ break;
101
+ }
102
+ if (attrValue === "plaintext-only") {
103
+ props.contentEditable = "plaintext-only";
104
+ break;
105
+ }
106
+ props.contentEditable = null;
107
+ break;
108
+ }
109
+ case "draggable":
110
+ {
111
+ props.draggable = attrValue != null;
112
+ break;
113
+ }
114
+ case "enterkeyhint":
115
+ {
116
+ props.enterKeyHint = attrValue;
117
+ break;
118
+ }
119
+ case "for":
120
+ {
121
+ props.htmlFor = attrValue;
122
+ break;
123
+ }
124
+ case "hidden":
125
+ {
126
+ props.hidden = attrValue;
127
+ break;
128
+ }
129
+ case "inputmode":
130
+ {
131
+ props.inputMode = attrValue;
132
+ break;
133
+ }
134
+ case "itemprop":
135
+ {
136
+ props.itemProp = attrValue;
137
+ break;
138
+ }
139
+ case "spellcheck":
140
+ {
141
+ if (attrValue === "" || attrValue === "true") {
142
+ props.spellCheck = true;
143
+ break;
144
+ }
145
+ if (attrValue === "false") {
146
+ props.spellCheck = false;
147
+ break;
148
+ }
149
+ props.spellCheck = null;
150
+ break;
151
+ }
152
+ case "tabindex":
153
+ {
154
+ const numValue = parseInt(attrValue, 10);
155
+ if (!Number.isNaN(numValue)) {
156
+ props.tabIndex = numValue;
157
+ }
158
+ break;
159
+ }
160
+ case "autocomplete":
161
+ {
162
+ props.autoComplete = attrValue;
163
+ break;
164
+ }
165
+ case "autofocus":
166
+ {
167
+ props.autoFocus = attrValue != null;
168
+ break;
169
+ }
170
+ case "formaction":
171
+ {
172
+ props.formAction = attrValue;
173
+ break;
174
+ }
175
+ case "formenctype":
176
+ {
177
+ props.formEnctype = attrValue;
178
+ break;
179
+ }
180
+ case "formmethod":
181
+ {
182
+ props.formMethod = attrValue;
183
+ break;
184
+ }
185
+ case "formnovalidate":
186
+ {
187
+ props.formNoValidate = attrValue;
188
+ break;
189
+ }
190
+ case "formtarget":
191
+ {
192
+ props.formTarget = attrValue;
193
+ break;
194
+ }
195
+ case "maxlength":
196
+ {
197
+ const numValue = parseInt(attrValue, 10);
198
+ if (!Number.isNaN(numValue)) {
199
+ props.maxLength = attrValue;
200
+ }
201
+ break;
202
+ }
203
+ case "minlength":
204
+ {
205
+ const numValue = parseInt(attrValue, 10);
206
+ if (!Number.isNaN(numValue)) {
207
+ props.minLength = attrValue;
208
+ }
209
+ break;
210
+ }
211
+ case "max":
212
+ {
213
+ const numValue = parseInt(attrValue, 10);
214
+ if (!Number.isNaN(numValue)) {
215
+ props.max = attrValue;
216
+ }
217
+ break;
218
+ }
219
+ case "min":
220
+ {
221
+ const numValue = parseInt(attrValue, 10);
222
+ if (!Number.isNaN(numValue)) {
223
+ props.min = attrValue;
224
+ }
225
+ break;
226
+ }
227
+ case "multiple":
228
+ {
229
+ props.multiple = attrValue != null;
230
+ break;
231
+ }
232
+ case "readonly":
233
+ {
234
+ props.readOnly = attrValue != null;
235
+ break;
236
+ }
237
+ case "required":
238
+ {
239
+ props.required = attrValue != null;
240
+ break;
241
+ }
242
+ case "size":
243
+ {
244
+ const numValue = parseInt(attrValue, 10);
245
+ if (!Number.isNaN(numValue)) {
246
+ props.size = attrValue;
247
+ }
248
+ break;
249
+ }
250
+ case "step":
251
+ {
252
+ if (attrValue === "any") {
253
+ props.step = attrValue;
254
+ break;
255
+ }
256
+ const numValue = parseInt(attrValue, 10);
257
+ if (!Number.isNaN(numValue) && numValue > 0) {
258
+ props.step = attrValue;
259
+ }
260
+ break;
261
+ }
262
+ case "disabled":
263
+ {
264
+ props.disabled = attrValue != null;
265
+ break;
266
+ }
267
+ case "rows":
268
+ {
269
+ const numValue = parseInt(attrValue, 10);
270
+ if (!Number.isNaN(numValue)) {
271
+ props.rows = attrValue;
272
+ }
273
+ break;
274
+ }
275
+ default:
276
+ {
277
+ props[attrName] = attrValue;
278
+ break;
279
+ }
280
+ }
281
+ }
282
+ return props;
283
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useMergedDOMRefs", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useMergedDOMRefs;
9
+ }
10
+ });
11
+ const _react = require("react");
12
+ function useMergedDOMRefs() {
13
+ for(var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++){
14
+ refs[_key] = arguments[_key];
15
+ }
16
+ return (0, _react.useCallback)((value)=>{
17
+ refs.forEach((ref)=>{
18
+ if (typeof ref === "function") {
19
+ ref(value);
20
+ return;
21
+ }
22
+ if (ref) {
23
+ ref.current = value;
24
+ }
25
+ });
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ }, refs);
28
+ }
@@ -0,0 +1,109 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */ "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
+ findTextNode: function() {
13
+ return findTextNode;
14
+ },
15
+ tempEditor: function() {
16
+ return tempEditor;
17
+ }
18
+ });
19
+ const _react = require("@testing-library/react");
20
+ const _expect = require("expect");
21
+ const _prosemirrormodel = require("prosemirror-model");
22
+ const _prosemirrorstate = require("prosemirror-state");
23
+ const _prosemirrortestbuilder = require("prosemirror-test-builder");
24
+ const _react1 = /*#__PURE__*/ _interop_require_default(require("react"));
25
+ const _ProseMirror = require("../components/ProseMirror.js");
26
+ const _ProseMirrorDoc = require("../components/ProseMirrorDoc.js");
27
+ const _useEditorEffect = require("../hooks/useEditorEffect.js");
28
+ const _reactKeys = require("../plugins/reactKeys.js");
29
+ function _interop_require_default(obj) {
30
+ return obj && obj.__esModule ? obj : {
31
+ default: obj
32
+ };
33
+ }
34
+ const toEqualNode = function(actual, expected) {
35
+ if (!(actual instanceof _prosemirrormodel.Node && expected instanceof _prosemirrormodel.Node)) {
36
+ throw new Error("Must be comparing nodes");
37
+ }
38
+ const pass = (0, _prosemirrortestbuilder.eq)(actual, expected);
39
+ return {
40
+ message: ()=>// `this` context will have correct typings
41
+ `expected ${this.utils.printReceived(actual)} ${pass ? "not " : ""}to equal ${this.utils.printExpected(expected)}`,
42
+ pass
43
+ };
44
+ };
45
+ _expect.expect.extend({
46
+ toEqualNode
47
+ });
48
+ function tempEditor(param) {
49
+ let { doc: startDoc, selection, controlled, plugins, ...props } = param;
50
+ startDoc = startDoc ?? (0, _prosemirrortestbuilder.doc)((0, _prosemirrortestbuilder.p)());
51
+ const state = _prosemirrorstate.EditorState.create({
52
+ doc: startDoc,
53
+ schema: _prosemirrortestbuilder.schema,
54
+ selection: selection ?? (startDoc.tag?.a ? _prosemirrorstate.TextSelection.create(startDoc, startDoc.tag.a, startDoc.tag?.b) : undefined),
55
+ plugins: [
56
+ ...plugins ?? [],
57
+ (0, _reactKeys.reactKeys)()
58
+ ]
59
+ });
60
+ let view = null;
61
+ function Test() {
62
+ (0, _useEditorEffect.useEditorEffect)((v)=>{
63
+ view = v;
64
+ });
65
+ return null;
66
+ }
67
+ const { rerender, unmount } = (0, _react.render)(/*#__PURE__*/ _react1.default.createElement(_ProseMirror.ProseMirror, {
68
+ ...controlled ? {
69
+ state
70
+ } : {
71
+ defaultState: state
72
+ },
73
+ ...props
74
+ }, /*#__PURE__*/ _react1.default.createElement(Test, null), /*#__PURE__*/ _react1.default.createElement(_ProseMirrorDoc.ProseMirrorDoc, null)));
75
+ function rerenderEditor() {
76
+ let { ...newProps } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
77
+ rerender(/*#__PURE__*/ _react1.default.createElement(_ProseMirror.ProseMirror, {
78
+ ...controlled ? {
79
+ state
80
+ } : {
81
+ defaultState: state
82
+ },
83
+ ...props,
84
+ ...newProps
85
+ }, /*#__PURE__*/ _react1.default.createElement(Test, null), /*#__PURE__*/ _react1.default.createElement(_ProseMirrorDoc.ProseMirrorDoc, null)));
86
+ return view;
87
+ }
88
+ return {
89
+ view: view,
90
+ rerender: rerenderEditor,
91
+ unmount
92
+ };
93
+ }
94
+ function findTextNodeInner(node, text) {
95
+ if (node.nodeType == 3) {
96
+ if (node.nodeValue == text) return node;
97
+ } else if (node.nodeType == 1) {
98
+ for(let ch = node.firstChild; ch; ch = ch.nextSibling){
99
+ const found = findTextNodeInner(ch, text);
100
+ if (found) return found;
101
+ }
102
+ }
103
+ return undefined;
104
+ }
105
+ function findTextNode(node, text) {
106
+ const found = findTextNodeInner(node, text);
107
+ if (found) return found;
108
+ throw new Error("Unable to find matching text node");
109
+ }
@@ -0,0 +1,94 @@
1
+ /* Copyright (c) The New York Times Company */ "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
+ setupProseMirrorView: function() {
13
+ return setupProseMirrorView;
14
+ },
15
+ teardownProseMirrorView: function() {
16
+ return teardownProseMirrorView;
17
+ }
18
+ });
19
+ let oldElementFromPoint;
20
+ let oldGetClientRects;
21
+ let oldGetBoundingClientRect;
22
+ const mockElementFromPoint = ()=>globalThis.document.body;
23
+ const mockGetBoundingClientRect = ()=>{
24
+ return {
25
+ bottom: 0,
26
+ height: 0,
27
+ left: 0,
28
+ right: 0,
29
+ top: 0,
30
+ width: 0,
31
+ x: 0,
32
+ y: 0,
33
+ toJSON () {
34
+ return {
35
+ bottom: 0,
36
+ height: 0,
37
+ left: 0,
38
+ right: 0,
39
+ top: 0,
40
+ width: 0,
41
+ x: 0,
42
+ y: 0
43
+ };
44
+ }
45
+ };
46
+ };
47
+ const mockGetClientRects = ()=>{
48
+ const list = [
49
+ {
50
+ bottom: 0,
51
+ height: 0,
52
+ left: 0,
53
+ right: 0,
54
+ top: 0,
55
+ width: 0,
56
+ x: 0,
57
+ y: 0,
58
+ toJSON () {
59
+ return {
60
+ bottom: 0,
61
+ height: 0,
62
+ left: 0,
63
+ right: 0,
64
+ top: 0,
65
+ width: 0,
66
+ x: 0,
67
+ y: 0
68
+ };
69
+ }
70
+ }
71
+ ];
72
+ const domRectList = Object.assign(list, {
73
+ item (index) {
74
+ return list[index] ?? null;
75
+ }
76
+ });
77
+ return domRectList;
78
+ };
79
+ function setupProseMirrorView() {
80
+ oldElementFromPoint = Document.prototype.elementFromPoint;
81
+ Document.prototype.elementFromPoint = mockElementFromPoint;
82
+ oldGetClientRects = Range.prototype.getClientRects;
83
+ Range.prototype.getClientRects = mockGetClientRects;
84
+ oldGetBoundingClientRect = Range.prototype.getBoundingClientRect;
85
+ Range.prototype.getBoundingClientRect = mockGetBoundingClientRect;
86
+ }
87
+ function teardownProseMirrorView() {
88
+ // @ts-expect-error jsdom actually doesn't implement these, so they might be undefined
89
+ Document.prototype.elementFromPoint = oldElementFromPoint;
90
+ // @ts-expect-error jsdom actually doesn't implement these, so they might be undefined
91
+ Range.prototype.getClientRects = oldGetClientRects;
92
+ // @ts-expect-error jsdom actually doesn't implement these, so they might be undefined
93
+ Range.prototype.getBoundingClientRect = oldGetBoundingClientRect;
94
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ReactProseMirrorNodeView", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ReactProseMirrorNodeView;
9
+ }
10
+ });
11
+ const _core = require("@tiptap/core");
12
+ let ReactProseMirrorNodeView = class ReactProseMirrorNodeView extends _core.NodeView {
13
+ _dom;
14
+ _contentDOM;
15
+ constructor(component, props, dom, contentDOM, options){
16
+ super(component, props, options);
17
+ this._dom = dom;
18
+ this._contentDOM = contentDOM;
19
+ }
20
+ get dom() {
21
+ return this._dom;
22
+ }
23
+ get contentDOM() {
24
+ return this._contentDOM;
25
+ }
26
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "TiptapEditor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return TiptapEditor;
9
+ }
10
+ });
11
+ const _core = require("@tiptap/core");
12
+ const _prosemirrorstate = require("prosemirror-state");
13
+ const _StaticEditorView = require("../StaticEditorView.js");
14
+ let TiptapEditor = class TiptapEditor extends _core.Editor {
15
+ constructor(options = {}){
16
+ super({
17
+ ...options,
18
+ element: null
19
+ });
20
+ }
21
+ get view() {
22
+ return(// @ts-expect-error private property
23
+ this.editorView ?? new _StaticEditorView.StaticEditorView({
24
+ state: _prosemirrorstate.EditorState.create({
25
+ schema: this.extensionManager.schema
26
+ }),
27
+ ...this.options.editorProps,
28
+ attributes: {
29
+ role: "textbox",
30
+ ...this.options.editorProps.attributes
31
+ }
32
+ }));
33
+ }
34
+ };