@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,40 @@
1
+ import { Mark } from "prosemirror-model";
2
+ import { Mappable } from "prosemirror-transform";
3
+ import { Decoration } from "prosemirror-view";
4
+ import { ForwardRefExoticComponent, RefAttributes } from "react";
5
+ import { WidgetViewComponentProps } from "../components/WidgetViewComponentProps.js";
6
+ import { DOMNode } from "../dom.js";
7
+ export interface DecorationType {
8
+ spec: unknown;
9
+ map(mapping: Mappable, span: Decoration, offset: number, oldOffset: number): Decoration | null;
10
+ valid(node: Node, span: Decoration): boolean;
11
+ eq(other: DecorationType): boolean;
12
+ destroy(dom: DOMNode): void;
13
+ }
14
+ export type DecorationWithType = Decoration & {
15
+ type: DecorationType;
16
+ };
17
+ type ReactWidgetSpec = {
18
+ side?: number;
19
+ marks?: readonly Mark[];
20
+ stopEvent?: (event: Event) => boolean;
21
+ ignoreSelection?: boolean;
22
+ key?: string;
23
+ [key: string]: unknown;
24
+ };
25
+ export declare class ReactWidgetType implements DecorationType {
26
+ Component: ForwardRefExoticComponent<RefAttributes<HTMLElement> & WidgetViewComponentProps>;
27
+ side: number;
28
+ spec: ReactWidgetSpec;
29
+ constructor(Component: ForwardRefExoticComponent<RefAttributes<HTMLElement> & WidgetViewComponentProps>, spec?: ReactWidgetSpec);
30
+ map(mapping: Mappable, span: Decoration, offset: number, oldOffset: number): Decoration | null;
31
+ valid(): boolean;
32
+ eq(other: DecorationType): boolean;
33
+ destroy(): void;
34
+ }
35
+ export declare function widget<E extends HTMLElement>(pos: number, component: ForwardRefExoticComponent<RefAttributes<E> & WidgetViewComponentProps>, spec?: ReactWidgetSpec): Decoration;
36
+ export interface ReactWidgetDecoration extends Decoration {
37
+ type: ReactWidgetType;
38
+ inline: false;
39
+ }
40
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Decoration } from "prosemirror-view";
2
+ import { AbstractEditorView } from "../AbstractEditorView.js";
3
+ /**
4
+ * Produces the outer decorations for the doc node, based
5
+ * on the attributes editor prop.
6
+ *
7
+ * The return value of this function is memoized; if it is to
8
+ * return an equivalent value to the last time it was called for
9
+ * a given EditorView, it will return exactly that previous value.
10
+ *
11
+ * This makes it safe to call in a React render function, even
12
+ * if its result is used in a dependencies array for a hook.
13
+ */
14
+ export declare function computeDocDeco(view: AbstractEditorView): [Decoration];
@@ -0,0 +1,20 @@
1
+ import { Node } from "prosemirror-model";
2
+ import { Mapping } from "prosemirror-transform";
3
+ import { Decoration, DecorationSet, DecorationSource } from "prosemirror-view";
4
+ import { DecorationType } from "./ReactWidgetType.js";
5
+ export interface InternalDecorationSource {
6
+ map: (mapping: Mapping, node: Node) => DecorationSource;
7
+ locals(node: Node): readonly Decoration[];
8
+ forChild(offset: number, child: Node): DecorationSource;
9
+ eq(other: DecorationSource): boolean;
10
+ forEachSet(f: (set: DecorationSet) => void): void;
11
+ }
12
+ export interface InternalDecorationSet extends InternalDecorationSource {
13
+ localsInner(node: Node): readonly Decoration[];
14
+ }
15
+ export interface InternalDecoration extends Decoration {
16
+ type: DecorationType;
17
+ copy(from: number, to: number): Decoration;
18
+ widget: boolean;
19
+ inline: boolean;
20
+ }
@@ -0,0 +1,3 @@
1
+ import { Node } from "prosemirror-model";
2
+ import { Decoration, DecorationSource } from "prosemirror-view";
3
+ export declare function iterDeco(parent: Node, deco: DecorationSource, onWidget: (widget: Decoration, isNative: boolean, offset: number, index: number, insideNode: boolean) => void, onNode: (node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, offset: number, index: number) => void): void;
@@ -0,0 +1,14 @@
1
+ import { DecorationSource } from "prosemirror-view";
2
+ import { AbstractEditorView } from "../AbstractEditorView.js";
3
+ /**
4
+ * Produces the DecorationSource for the current state, based
5
+ * on the decorations editor prop.
6
+ *
7
+ * The return value of this function is memoized; if it is to
8
+ * return an equivalent value to the last time it was called for
9
+ * a given EditorView, it will return exactly that previous value.
10
+ *
11
+ * This makes it safe to call in a React render function, even
12
+ * if its result is used in a dependencies array for a hook.
13
+ */
14
+ export declare function viewDecorations(view: AbstractEditorView): DecorationSource;
@@ -0,0 +1,22 @@
1
+ export type DOMNode = InstanceType<typeof window.Node>;
2
+ export type DOMSelection = InstanceType<typeof window.Selection>;
3
+ export type DOMSelectionRange = {
4
+ focusNode: DOMNode | null;
5
+ focusOffset: number;
6
+ anchorNode: DOMNode | null;
7
+ anchorOffset: number;
8
+ };
9
+ export declare const domIndex: (node: Node) => number;
10
+ export declare const parentNode: (node: Node) => Node | null;
11
+ export declare const textRange: (node: Text, from?: number, to?: number) => Range;
12
+ export declare const isEquivalentPosition: (node: Node, off: number, targetNode: Node, targetOff: number) => boolean;
13
+ export declare function nodeSize(node: Node): number;
14
+ export declare function isOnEdge(node: Node, offset: number, parent: Node): boolean;
15
+ export declare function hasBlockDesc(dom: Node): boolean | null | undefined;
16
+ export declare const selectionCollapsed: (domSel: DOMSelectionRange) => boolean | null;
17
+ export declare function keyEvent(keyCode: number, key: string): KeyboardEvent;
18
+ export declare function deepActiveElement(doc: Document): Element | null;
19
+ export declare function caretFromPoint(doc: Document, x: number, y: number): {
20
+ node: Node;
21
+ offset: number;
22
+ } | undefined;
@@ -0,0 +1,3 @@
1
+ import { Component } from "react";
2
+ export declare function getInstance(key: Component): unknown;
3
+ export declare function findDOMNode(componentOrElement: Component<unknown, unknown>): null | Element | Text;
@@ -0,0 +1,2 @@
1
+ import { useLayoutEffect } from "react";
2
+ export declare function useClientLayoutEffect(...args: Parameters<typeof useLayoutEffect>): void;
@@ -0,0 +1,34 @@
1
+ import type { DOMEventMap, EditorView } from "prosemirror-view";
2
+ export type EventHandler<EventType extends keyof DOMEventMap = keyof DOMEventMap> = (view: EditorView, event: DOMEventMap[EventType]) => boolean | void;
3
+ export type HandleDOMEvents = Record<keyof DOMEventMap, EventHandler | undefined>;
4
+ /**
5
+ * Produces a plugin that can be used with ProseMirror to handle DOM
6
+ * events at the EditorView.dom element.
7
+ *
8
+ * - `reactEventsPlugin` is a ProseMirror plugin for handling DOM events
9
+ * at the EditorView.dom element. It should be passed to `useEditorView`,
10
+ * along with any other plugins.
11
+ *
12
+ * - `registerEventListener` and `unregisterEventListener` should be
13
+ * passed to `EditorContext.Provider`.
14
+ *
15
+ * @privateRemarks
16
+ *
17
+ * This hook uses a combination of mutable and immutable updates to give
18
+ * us precise control over when we re-create the event listeners.
19
+ *
20
+ * The hook has a mutable reference to the set of handlers for each
21
+ * event type, but the set of event types is static. This means that we
22
+ * need to produce a new handleDOMEVents record whenever a new event type is
23
+ * registered. We avoid producing a new record in any other
24
+ * scenario to avoid the performance overhead of re-registering the event
25
+ * listeners in the EditorView.
26
+ *
27
+ * To accomplish this, we shallowly clone the registry whenever a new event
28
+ * type is registered.
29
+ */
30
+ export declare function useComponentEventListeners(handleDOMEventsProp: HandleDOMEvents | undefined): {
31
+ registerEventListener: (eventType: keyof DOMEventMap, handler: EventHandler) => void;
32
+ unregisterEventListener: (eventType: keyof DOMEventMap, handler: EventHandler) => void;
33
+ handleDOMEvents: HandleDOMEvents;
34
+ };
@@ -0,0 +1,37 @@
1
+ import { EditorState, Plugin, Transaction } from "prosemirror-state";
2
+ import { EditorProps, EditorView } from "prosemirror-view";
3
+ import { AbstractEditorView } from "../AbstractEditorView.js";
4
+ export interface UseEditorOptions extends EditorProps {
5
+ defaultState?: EditorState;
6
+ state?: EditorState;
7
+ plugins?: readonly Plugin[];
8
+ dispatchTransaction?(this: EditorView, tr: Transaction): void;
9
+ static?: boolean;
10
+ /**
11
+ * Keep the editor's state and doc contexts stable across transactions
12
+ * dispatched synchronously, so that a transaction does not make React scan
13
+ * every memoised node view. Leave off when transactions carry the `async`
14
+ * meta.
15
+ */
16
+ stableContexts?: boolean;
17
+ }
18
+ /**
19
+ * Creates, mounts, and manages a ProseMirror `EditorView`.
20
+ *
21
+ * All state and props updates are executed in a layout effect.
22
+ * To ensure that the EditorState and EditorView are never out of
23
+ * sync, it's important that the EditorView produced by this hook
24
+ * is only accessed through the `useEditorViewEvent` and
25
+ * `useEditorViewLayoutEffect` hooks.
26
+ */
27
+ export declare function useEditor<T extends HTMLElement = HTMLElement>(mount: T | null, options: UseEditorOptions): {
28
+ editor: {
29
+ view: AbstractEditorView;
30
+ flushSyncRef: import("react").MutableRefObject<boolean>;
31
+ registerEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("./useComponentEventListeners.js").EventHandler) => void;
32
+ unregisterEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("./useComponentEventListeners.js").EventHandler) => void;
33
+ isStatic: boolean;
34
+ };
35
+ state: EditorState;
36
+ renderStore: import("../contexts/RenderStoreContext.js").RenderStore | null;
37
+ };
@@ -0,0 +1,21 @@
1
+ import type { EditorView } from "prosemirror-view";
2
+ import type { DependencyList } from "react";
3
+ /**
4
+ * Registers a layout effect to run after the EditorView has
5
+ * been updated with the latest EditorState and Decorations.
6
+ *
7
+ * Effects can take an EditorView instance as an argument.
8
+ * This hook should be used to execute layout effects that
9
+ * depend on the EditorView, such as for positioning DOM
10
+ * nodes based on ProseMirror positions.
11
+ *
12
+ * Layout effects registered with this hook still fire
13
+ * synchronously after all DOM mutations, but they do so
14
+ * _after_ the EditorView has been updated, even when the
15
+ * EditorView lives in an ancestor component.
16
+ *
17
+ * This hook can only be used in a component that is mounted
18
+ * as a child of the TiptapEditorView component, including
19
+ * React node view components.
20
+ */
21
+ export declare function useEditorEffect(effect: (editorView: EditorView) => void | (() => void), dependencies?: DependencyList): void;
@@ -0,0 +1,13 @@
1
+ import type { EditorView } from "prosemirror-view";
2
+ /**
3
+ * Returns a stable function reference to be used as an
4
+ * event handler callback.
5
+ *
6
+ * The callback will be called with the EditorView instance
7
+ * as its first argument.
8
+ *
9
+ * This hook can only be used in a component that is mounted
10
+ * as a child of the TiptapEditorView component, including
11
+ * React node view components.
12
+ */
13
+ export declare function useEditorEventCallback<This, T extends unknown[], R>(callback: (this: This, view: EditorView, ...args: T) => R): (this: This, ...args: T) => R;
@@ -0,0 +1,8 @@
1
+ import type { DOMEventMap } from "prosemirror-view";
2
+ import type { EventHandler } from "./useComponentEventListeners.js";
3
+ /**
4
+ * Attaches an event listener at the `EditorView`'s DOM node. See
5
+ * [the ProseMirror docs](https://prosemirror.net/docs/ref/#view.EditorProps.handleDOMEvents)
6
+ * for more details.
7
+ */
8
+ export declare function useEditorEventListener<EventType extends keyof DOMEventMap>(eventType: EventType, handler: EventHandler<EventType>): void;
@@ -0,0 +1,5 @@
1
+ import type { EditorState } from "prosemirror-state";
2
+ /**
3
+ * Provides access to the current EditorState value.
4
+ */
5
+ export declare function useEditorState(): EditorState;
@@ -0,0 +1,10 @@
1
+ import { EditorState } from "prosemirror-state";
2
+ /**
3
+ * Select a piece of the EditorState, a la Redux’s
4
+ * `useSelector`.
5
+ *
6
+ * This hook will only trigger a re-render of the
7
+ * consuming component if the return value of the selector
8
+ * changes.
9
+ */
10
+ export declare function useEditorStateSelector<Result>(selector: (state: EditorState) => Result): Result;
@@ -0,0 +1 @@
1
+ export declare function useEffectEvent<P extends unknown[], R>(fn: (...args: P) => R): (...funcArgs: P) => R;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Provides a function that forces an update of the
3
+ * component.
4
+ */
5
+ export declare function useForceUpdate(): () => void;
@@ -0,0 +1,2 @@
1
+ import { EditorView, MarkView, NodeView, ViewMutationRecord } from "prosemirror-view";
2
+ export declare function useIgnoreMutation(ignoreMutation: (this: NodeView | MarkView, view: EditorView, mutation: ViewMutationRecord) => boolean): void;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns true while an IME composition is active inside the current node.
3
+ */
4
+ export declare function useIsComposingIn(): boolean;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Returns true if the nearest ProseMirror component
3
+ * is rendered with the `static` prop set to `true`.
4
+ */
5
+ export declare function useIsEditorStatic(): boolean;
@@ -0,0 +1 @@
1
+ export declare function useIsNodeSelected(): boolean;
@@ -0,0 +1,3 @@
1
+ import type { DependencyList, EffectCallback } from "react";
2
+ /** Registers a layout effect to run at the nearest `LayoutGroup` boundary. */
3
+ export declare function useLayoutGroupEffect(effect: EffectCallback, deps?: DependencyList): void;
@@ -0,0 +1,15 @@
1
+ import { MarkViewConstructor } from "prosemirror-view";
2
+ import { MarkViewComponentProps } from "../components/marks/MarkViewComponentProps.js";
3
+ import { MarkViewDesc, ViewDesc } from "../viewdesc.js";
4
+ type Props = Omit<MarkViewComponentProps["markProps"], "contentDOMRef">;
5
+ export declare function useMarkViewDescription(getDOM: () => HTMLElement | null, getContentDOM: (markView: {
6
+ contentDOM?: HTMLElement | null;
7
+ } | null) => HTMLElement | null, constructor: MarkViewConstructor, props: Props): {
8
+ childContextValue: {
9
+ parentRef: import("react").MutableRefObject<MarkViewDesc | undefined>;
10
+ siblingsRef: import("react").MutableRefObject<ViewDesc[]>;
11
+ };
12
+ contentDOM: HTMLElement | undefined;
13
+ refUpdated: () => void;
14
+ };
15
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get this node's current position in the document.
3
+ *
4
+ * Using this hook will subscribe this node to the
5
+ * EditorState, which means that it will be re-rendered
6
+ * on every EditorState update. This may have performance
7
+ * implications for large documents.
8
+ */
9
+ export declare function useNodePos(): number;
@@ -0,0 +1,16 @@
1
+ import { NodeViewConstructor } from "prosemirror-view";
2
+ import { NodeViewComponentProps } from "../components/nodes/NodeViewComponentProps.js";
3
+ import { NodeViewDesc, ViewDesc } from "../viewdesc.js";
4
+ type Props = Omit<NodeViewComponentProps["nodeProps"], "contentDOMRef">;
5
+ export declare function useNodeViewDescription(getDOM: () => HTMLElement | null, getContentDOM: (nodeView: {
6
+ contentDOM?: HTMLElement | null;
7
+ } | null) => HTMLElement | null, constructor: NodeViewConstructor, props: Props): {
8
+ childContextValue: {
9
+ parentRef: import("react").MutableRefObject<NodeViewDesc | undefined>;
10
+ siblingsRef: import("react").MutableRefObject<ViewDesc[]>;
11
+ };
12
+ contentDOM: HTMLElement | null;
13
+ refUpdated: () => void;
14
+ isMounted: () => boolean;
15
+ };
16
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ReactKeysPluginState } from "../plugins/reactKeys.js";
2
+ export declare function useReactKeys(): ReactKeysPluginState | undefined;
@@ -0,0 +1,2 @@
1
+ import { EditorView } from "prosemirror-view";
2
+ export declare function useSelectNode(selectNode: (view: EditorView) => void, deselectNode?: (view: EditorView) => void): void;
@@ -0,0 +1,2 @@
1
+ import { MutableRefObject } from "react";
2
+ export declare function useSetDom(domRef: MutableRefObject<HTMLElement | null>, refUpdated: () => void, isMounted?: () => boolean, forceUpdate?: () => void): (el: HTMLElement | null) => void;
@@ -0,0 +1,2 @@
1
+ import { EditorView, NodeView } from "prosemirror-view";
2
+ export declare function useStopEvent(stopEvent: (this: NodeView, view: EditorView, event: Event) => boolean): void;
@@ -0,0 +1,21 @@
1
+ export { ProseMirror } from "./components/ProseMirror.js";
2
+ export { ProseMirrorDoc } from "./components/ProseMirrorDoc.js";
3
+ export { reorderSiblings } from "./commands/reorderSiblings.js";
4
+ export { useIsComposingIn } from "./hooks/useIsComposingIn.js";
5
+ export { useEditorEffect } from "./hooks/useEditorEffect.js";
6
+ export { useEditorEventCallback } from "./hooks/useEditorEventCallback.js";
7
+ export { useEditorEventListener } from "./hooks/useEditorEventListener.js";
8
+ export { useEditorState } from "./hooks/useEditorState.js";
9
+ export { useNodePos } from "./hooks/useNodePos.js";
10
+ export { useEditorStateSelector } from "./hooks/useEditorStateSelector.js";
11
+ export { useStopEvent } from "./hooks/useStopEvent.js";
12
+ export { useSelectNode } from "./hooks/useSelectNode.js";
13
+ export { useIgnoreMutation } from "./hooks/useIgnoreMutation.js";
14
+ export { useIsEditorStatic } from "./hooks/useIsEditorStatic.js";
15
+ export { useIsNodeSelected } from "./hooks/useIsNodeSelected.js";
16
+ export { reactKeys } from "./plugins/reactKeys.js";
17
+ export { widget } from "./decorations/ReactWidgetType.js";
18
+ export { useMergedDOMRefs } from "./refs.js";
19
+ export type { NodeViewComponentProps } from "./components/nodes/NodeViewComponentProps.js";
20
+ export type { MarkViewComponentProps } from "./components/marks/MarkViewComponentProps.js";
21
+ export type { WidgetViewComponentProps } from "./components/WidgetViewComponentProps.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ export declare function beforeInputPlugin(): Plugin<any>;
@@ -0,0 +1,23 @@
1
+ import { Plugin, PluginKey } from "prosemirror-state";
2
+ import { Decoration } from "prosemirror-view";
3
+ export declare function createNodeKey(): string;
4
+ export interface ReactKeysPluginState {
5
+ posToKey: Map<number, string>;
6
+ keyToPos: Map<string, number>;
7
+ cursorWrapper: Decoration | null;
8
+ freezeFrom: number | null;
9
+ }
10
+ export declare const reactKeysPluginKey: PluginKey<ReactKeysPluginState>;
11
+ export type ReactKeysPluginMeta = {
12
+ overrides?: Record<number, number>;
13
+ cursorWrapper?: Decoration | null;
14
+ freezeFrom?: number | null;
15
+ } | undefined;
16
+ /**
17
+ * Tracks a unique key for each (non-text) node in the
18
+ * document, identified by its current position. Keys are
19
+ * (mostly) stable across transaction applications. The
20
+ * key for a given node can be accessed by that node's
21
+ * current position in the document, and vice versa.
22
+ */
23
+ export declare function reactKeys(): Plugin<ReactKeysPluginState>;