@handlewithcare/react-prosemirror 2.0.0

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 (209) hide show
  1. package/LICENSE.txt +12 -0
  2. package/README.md +705 -0
  3. package/dist/cjs/browser.js +53 -0
  4. package/dist/cjs/components/ChildNodeViews.js +376 -0
  5. package/dist/cjs/components/CursorWrapper.js +91 -0
  6. package/dist/cjs/components/CustomNodeView.js +79 -0
  7. package/dist/cjs/components/DocNodeView.js +104 -0
  8. package/dist/cjs/components/LayoutGroup.js +111 -0
  9. package/dist/cjs/components/MarkView.js +115 -0
  10. package/dist/cjs/components/NativeWidgetView.js +109 -0
  11. package/dist/cjs/components/NodeView.js +196 -0
  12. package/dist/cjs/components/NodeViewComponentProps.js +4 -0
  13. package/dist/cjs/components/OutputSpec.js +88 -0
  14. package/dist/cjs/components/ProseMirror.js +103 -0
  15. package/dist/cjs/components/ProseMirrorDoc.js +92 -0
  16. package/dist/cjs/components/SeparatorHackView.js +100 -0
  17. package/dist/cjs/components/TextNodeView.js +112 -0
  18. package/dist/cjs/components/TrailingHackView.js +90 -0
  19. package/dist/cjs/components/WidgetView.js +95 -0
  20. package/dist/cjs/components/WidgetViewComponentProps.js +4 -0
  21. package/dist/cjs/components/__tests__/ProseMirror.composition.test.js +398 -0
  22. package/dist/cjs/components/__tests__/ProseMirror.domchange.test.js +270 -0
  23. package/dist/cjs/components/__tests__/ProseMirror.draw-decoration.test.js +1010 -0
  24. package/dist/cjs/components/__tests__/ProseMirror.draw.test.js +337 -0
  25. package/dist/cjs/components/__tests__/ProseMirror.node-view.test.js +315 -0
  26. package/dist/cjs/components/__tests__/ProseMirror.selection.test.js +444 -0
  27. package/dist/cjs/components/__tests__/ProseMirror.test.js +382 -0
  28. package/dist/cjs/contexts/ChildDescriptorsContext.js +19 -0
  29. package/dist/cjs/contexts/EditorContext.js +12 -0
  30. package/dist/cjs/contexts/EditorStateContext.js +12 -0
  31. package/dist/cjs/contexts/LayoutGroupContext.js +12 -0
  32. package/dist/cjs/contexts/NodeViewContext.js +12 -0
  33. package/dist/cjs/contexts/SelectNodeContext.js +12 -0
  34. package/dist/cjs/contexts/StopEventContext.js +12 -0
  35. package/dist/cjs/contexts/__tests__/DeferredLayoutEffects.test.js +141 -0
  36. package/dist/cjs/decorations/ReactWidgetType.js +58 -0
  37. package/dist/cjs/decorations/computeDocDeco.js +44 -0
  38. package/dist/cjs/decorations/internalTypes.js +4 -0
  39. package/dist/cjs/decorations/iterDeco.js +79 -0
  40. package/dist/cjs/decorations/viewDecorations.js +163 -0
  41. package/dist/cjs/dom.js +142 -0
  42. package/dist/cjs/hooks/__tests__/useEditorViewLayoutEffect.test.js +108 -0
  43. package/dist/cjs/hooks/useClientOnly.js +18 -0
  44. package/dist/cjs/hooks/useComponentEventListeners.js +39 -0
  45. package/dist/cjs/hooks/useEditor.js +287 -0
  46. package/dist/cjs/hooks/useEditorEffect.js +35 -0
  47. package/dist/cjs/hooks/useEditorEventCallback.js +33 -0
  48. package/dist/cjs/hooks/useEditorEventListener.js +34 -0
  49. package/dist/cjs/hooks/useEditorState.js +16 -0
  50. package/dist/cjs/hooks/useForceUpdate.js +15 -0
  51. package/dist/cjs/hooks/useLayoutGroupEffect.js +19 -0
  52. package/dist/cjs/hooks/useNodeViewDescriptor.js +115 -0
  53. package/dist/cjs/hooks/useReactKeys.js +17 -0
  54. package/dist/cjs/hooks/useSelectNode.js +28 -0
  55. package/dist/cjs/hooks/useStopEvent.js +24 -0
  56. package/dist/cjs/index.js +53 -0
  57. package/dist/cjs/package.json +3 -0
  58. package/dist/cjs/plugins/__tests__/reactKeys.test.js +81 -0
  59. package/dist/cjs/plugins/beforeInputPlugin.js +143 -0
  60. package/dist/cjs/plugins/componentEventListeners.js +35 -0
  61. package/dist/cjs/plugins/componentEventListenersPlugin.js +35 -0
  62. package/dist/cjs/plugins/reactKeys.js +96 -0
  63. package/dist/cjs/props.js +269 -0
  64. package/dist/cjs/selection/SelectionDOMObserver.js +174 -0
  65. package/dist/cjs/selection/hasFocusAndSelection.js +35 -0
  66. package/dist/cjs/selection/selectionFromDOM.js +77 -0
  67. package/dist/cjs/selection/selectionToDOM.js +226 -0
  68. package/dist/cjs/ssr.js +85 -0
  69. package/dist/cjs/testing/editorViewTestHelpers.js +111 -0
  70. package/dist/cjs/testing/setupProseMirrorView.js +94 -0
  71. package/dist/cjs/viewdesc.js +664 -0
  72. package/dist/esm/browser.js +43 -0
  73. package/dist/esm/components/ChildNodeViews.js +318 -0
  74. package/dist/esm/components/CursorWrapper.js +40 -0
  75. package/dist/esm/components/CustomNodeView.js +28 -0
  76. package/dist/esm/components/DocNodeView.js +53 -0
  77. package/dist/esm/components/LayoutGroup.js +66 -0
  78. package/dist/esm/components/MarkView.js +64 -0
  79. package/dist/esm/components/NativeWidgetView.js +58 -0
  80. package/dist/esm/components/NodeView.js +145 -0
  81. package/dist/esm/components/NodeViewComponentProps.js +1 -0
  82. package/dist/esm/components/OutputSpec.js +38 -0
  83. package/dist/esm/components/ProseMirror.js +52 -0
  84. package/dist/esm/components/ProseMirrorDoc.js +34 -0
  85. package/dist/esm/components/SeparatorHackView.js +49 -0
  86. package/dist/esm/components/TextNodeView.js +102 -0
  87. package/dist/esm/components/TrailingHackView.js +39 -0
  88. package/dist/esm/components/WidgetView.js +44 -0
  89. package/dist/esm/components/WidgetViewComponentProps.js +1 -0
  90. package/dist/esm/components/__tests__/ProseMirror.composition.test.js +395 -0
  91. package/dist/esm/components/__tests__/ProseMirror.domchange.test.js +266 -0
  92. package/dist/esm/components/__tests__/ProseMirror.draw-decoration.test.js +967 -0
  93. package/dist/esm/components/__tests__/ProseMirror.draw.test.js +294 -0
  94. package/dist/esm/components/__tests__/ProseMirror.node-view.test.js +272 -0
  95. package/dist/esm/components/__tests__/ProseMirror.selection.test.js +440 -0
  96. package/dist/esm/components/__tests__/ProseMirror.test.js +339 -0
  97. package/dist/esm/contexts/ChildDescriptorsContext.js +9 -0
  98. package/dist/esm/contexts/EditorContext.js +7 -0
  99. package/dist/esm/contexts/EditorStateContext.js +2 -0
  100. package/dist/esm/contexts/LayoutGroupContext.js +2 -0
  101. package/dist/esm/contexts/NodeViewContext.js +2 -0
  102. package/dist/esm/contexts/SelectNodeContext.js +2 -0
  103. package/dist/esm/contexts/StopEventContext.js +2 -0
  104. package/dist/esm/contexts/__tests__/DeferredLayoutEffects.test.js +98 -0
  105. package/dist/esm/decorations/ReactWidgetType.js +40 -0
  106. package/dist/esm/decorations/computeDocDeco.js +44 -0
  107. package/dist/esm/decorations/internalTypes.js +1 -0
  108. package/dist/esm/decorations/iterDeco.js +73 -0
  109. package/dist/esm/decorations/viewDecorations.js +163 -0
  110. package/dist/esm/dom.js +105 -0
  111. package/dist/esm/hooks/__tests__/useEditorViewLayoutEffect.test.js +99 -0
  112. package/dist/esm/hooks/useClientOnly.js +8 -0
  113. package/dist/esm/hooks/useComponentEventListeners.js +54 -0
  114. package/dist/esm/hooks/useEditor.js +278 -0
  115. package/dist/esm/hooks/useEditorEffect.js +38 -0
  116. package/dist/esm/hooks/useEditorEventCallback.js +35 -0
  117. package/dist/esm/hooks/useEditorEventListener.js +28 -0
  118. package/dist/esm/hooks/useEditorState.js +8 -0
  119. package/dist/esm/hooks/useForceUpdate.js +8 -0
  120. package/dist/esm/hooks/useLayoutGroupEffect.js +9 -0
  121. package/dist/esm/hooks/useNodeViewDescriptor.js +105 -0
  122. package/dist/esm/hooks/useReactKeys.js +7 -0
  123. package/dist/esm/hooks/useSelectNode.js +18 -0
  124. package/dist/esm/hooks/useStopEvent.js +14 -0
  125. package/dist/esm/index.js +11 -0
  126. package/dist/esm/plugins/__tests__/reactKeys.test.js +77 -0
  127. package/dist/esm/plugins/beforeInputPlugin.js +133 -0
  128. package/dist/esm/plugins/componentEventListeners.js +25 -0
  129. package/dist/esm/plugins/componentEventListenersPlugin.js +25 -0
  130. package/dist/esm/plugins/reactKeys.js +81 -0
  131. package/dist/esm/props.js +251 -0
  132. package/dist/esm/selection/SelectionDOMObserver.js +164 -0
  133. package/dist/esm/selection/hasFocusAndSelection.js +17 -0
  134. package/dist/esm/selection/selectionFromDOM.js +59 -0
  135. package/dist/esm/selection/selectionToDOM.js +196 -0
  136. package/dist/esm/ssr.js +82 -0
  137. package/dist/esm/testing/editorViewTestHelpers.js +88 -0
  138. package/dist/esm/testing/setupProseMirrorView.js +76 -0
  139. package/dist/esm/viewdesc.js +654 -0
  140. package/dist/tsconfig.tsbuildinfo +1 -0
  141. package/dist/types/browser.d.ts +15 -0
  142. package/dist/types/components/ChildNodeViews.d.ts +9 -0
  143. package/dist/types/components/CursorWrapper.d.ts +5 -0
  144. package/dist/types/components/CustomNodeView.d.ts +21 -0
  145. package/dist/types/components/DocNodeView.d.ts +20 -0
  146. package/dist/types/components/LayoutGroup.d.ts +12 -0
  147. package/dist/types/components/MarkView.d.ts +9 -0
  148. package/dist/types/components/NativeWidgetView.d.ts +8 -0
  149. package/dist/types/components/NodeView.d.ts +11 -0
  150. package/dist/types/components/NodeViewComponentProps.d.ts +12 -0
  151. package/dist/types/components/OutputSpec.d.ts +8 -0
  152. package/dist/types/components/ProseMirror.d.ts +15 -0
  153. package/dist/types/components/ProseMirrorDoc.d.ts +10 -0
  154. package/dist/types/components/SeparatorHackView.d.ts +6 -0
  155. package/dist/types/components/TextNodeView.d.ts +23 -0
  156. package/dist/types/components/TrailingHackView.d.ts +6 -0
  157. package/dist/types/components/WidgetView.d.ts +8 -0
  158. package/dist/types/components/WidgetViewComponentProps.d.ts +6 -0
  159. package/dist/types/components/__tests__/ProseMirror.composition.test.d.ts +1 -0
  160. package/dist/types/components/__tests__/ProseMirror.domchange.test.d.ts +1 -0
  161. package/dist/types/components/__tests__/ProseMirror.draw-decoration.test.d.ts +1 -0
  162. package/dist/types/components/__tests__/ProseMirror.draw.test.d.ts +1 -0
  163. package/dist/types/components/__tests__/ProseMirror.node-view.test.d.ts +1 -0
  164. package/dist/types/components/__tests__/ProseMirror.selection.test.d.ts +1 -0
  165. package/dist/types/components/__tests__/ProseMirror.test.d.ts +1 -0
  166. package/dist/types/contexts/ChildDescriptorsContext.d.ts +6 -0
  167. package/dist/types/contexts/EditorContext.d.ts +14 -0
  168. package/dist/types/contexts/EditorStateContext.d.ts +2 -0
  169. package/dist/types/contexts/LayoutGroupContext.d.ts +5 -0
  170. package/dist/types/contexts/NodeViewContext.d.ts +6 -0
  171. package/dist/types/contexts/SelectNodeContext.d.ts +3 -0
  172. package/dist/types/contexts/StopEventContext.d.ts +3 -0
  173. package/dist/types/contexts/__tests__/DeferredLayoutEffects.test.d.ts +1 -0
  174. package/dist/types/decorations/ReactWidgetType.d.ts +39 -0
  175. package/dist/types/decorations/computeDocDeco.d.ts +13 -0
  176. package/dist/types/decorations/internalTypes.d.ts +16 -0
  177. package/dist/types/decorations/iterDeco.d.ts +3 -0
  178. package/dist/types/decorations/viewDecorations.d.ts +13 -0
  179. package/dist/types/dom.d.ts +22 -0
  180. package/dist/types/hooks/__tests__/useEditorViewLayoutEffect.test.d.ts +1 -0
  181. package/dist/types/hooks/useClientOnly.d.ts +1 -0
  182. package/dist/types/hooks/useComponentEventListeners.d.ts +33 -0
  183. package/dist/types/hooks/useEditor.d.ts +66 -0
  184. package/dist/types/hooks/useEditorEffect.d.ts +17 -0
  185. package/dist/types/hooks/useEditorEventCallback.d.ts +15 -0
  186. package/dist/types/hooks/useEditorEventListener.d.ts +8 -0
  187. package/dist/types/hooks/useEditorState.d.ts +5 -0
  188. package/dist/types/hooks/useForceUpdate.d.ts +5 -0
  189. package/dist/types/hooks/useLayoutGroupEffect.d.ts +3 -0
  190. package/dist/types/hooks/useNodeViewDescriptor.d.ts +11 -0
  191. package/dist/types/hooks/useReactKeys.d.ts +5 -0
  192. package/dist/types/hooks/useSelectNode.d.ts +1 -0
  193. package/dist/types/hooks/useStopEvent.d.ts +2 -0
  194. package/dist/types/index.d.ts +12 -0
  195. package/dist/types/plugins/__tests__/reactKeys.test.d.ts +1 -0
  196. package/dist/types/plugins/beforeInputPlugin.d.ts +3 -0
  197. package/dist/types/plugins/componentEventListeners.d.ts +4 -0
  198. package/dist/types/plugins/componentEventListenersPlugin.d.ts +4 -0
  199. package/dist/types/plugins/reactKeys.d.ts +19 -0
  200. package/dist/types/props.d.ts +1174 -0
  201. package/dist/types/selection/SelectionDOMObserver.d.ts +34 -0
  202. package/dist/types/selection/hasFocusAndSelection.d.ts +3 -0
  203. package/dist/types/selection/selectionFromDOM.d.ts +4 -0
  204. package/dist/types/selection/selectionToDOM.d.ts +9 -0
  205. package/dist/types/ssr.d.ts +19 -0
  206. package/dist/types/testing/editorViewTestHelpers.d.ts +23 -0
  207. package/dist/types/testing/setupProseMirrorView.d.ts +2 -0
  208. package/dist/types/viewdesc.d.ts +131 -0
  209. package/package.json +113 -0
@@ -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 @@
1
+ export declare function useClientOnly(): boolean;
@@ -0,0 +1,33 @@
1
+ import type { DOMEventMap } from "prosemirror-view";
2
+ import { EventHandler } from "../plugins/componentEventListeners.js";
3
+ /**
4
+ * Produces a plugin that can be used with ProseMirror to handle DOM
5
+ * events at the EditorView.dom element.
6
+ *
7
+ * - `reactEventsPlugin` is a ProseMirror plugin for handling DOM events
8
+ * at the EditorView.dom element. It should be passed to `useEditorView`,
9
+ * along with any other plugins.
10
+ *
11
+ * - `registerEventListener` and `unregisterEventListener` should be
12
+ * passed to `EditorContext.Provider`.
13
+ *
14
+ * @privateRemarks
15
+ *
16
+ * This hook uses a combination of mutable and immutable updates to give
17
+ * us precise control over when we re-create the ProseMirror plugin.
18
+ *
19
+ * The plugin has a mutable reference to the set of handlers for each
20
+ * event type, but the set of event types is static. This means that we
21
+ * need to produce a new ProseMirror plugin whenever a new event type is
22
+ * registered. We avoid producing a new ProseMirrer plugin in any other
23
+ * scenario to avoid the performance overhead of reconfiguring the plugins
24
+ * in the EditorView.
25
+ *
26
+ * To accomplish this, we shallowly clone the registry whenever a new event
27
+ * type is registered.
28
+ */
29
+ export declare function useComponentEventListeners(): {
30
+ registerEventListener: (eventType: keyof DOMEventMap, handler: EventHandler) => void;
31
+ unregisterEventListener: (eventType: keyof DOMEventMap, handler: EventHandler) => void;
32
+ componentEventListenersPlugin: import("prosemirror-state").Plugin<any>;
33
+ };
@@ -0,0 +1,66 @@
1
+ import { EditorState, Plugin, Transaction } from "prosemirror-state";
2
+ import { Decoration, DirectEditorProps, EditorProps, EditorView } from "prosemirror-view";
3
+ import { NodeViewDesc } from "../viewdesc.js";
4
+ export declare class ReactEditorView extends EditorView {
5
+ private shouldUpdatePluginViews;
6
+ private oldProps;
7
+ private _props;
8
+ constructor(place: {
9
+ mount: HTMLElement;
10
+ } | null, props: DirectEditorProps & {
11
+ docView: NodeViewDesc;
12
+ });
13
+ /**
14
+ * Whether the EditorView's updateStateInner method thinks that the
15
+ * docView needs to be blown away and redrawn.
16
+ *
17
+ * @privateremarks
18
+ *
19
+ * When ProseMirror View detects that the EditorState has been reconfigured
20
+ * to provide new custom node views, it calls an internal function that
21
+ * we can't override in order to recreate the entire editor DOM.
22
+ *
23
+ * This property mimics that check, so that we can replace the EditorView
24
+ * with another of our own, preventing ProseMirror View from taking over
25
+ * DOM management responsibility.
26
+ */
27
+ get needsRedraw(): boolean;
28
+ /**
29
+ * Like setProps, but without executing any side effects.
30
+ * Safe to use in a component render method.
31
+ */
32
+ pureSetProps(props: Partial<DirectEditorProps>): void;
33
+ /**
34
+ * Triggers any side effects that have been queued by previous
35
+ * calls to pureSetProps.
36
+ */
37
+ runPendingEffects(): void;
38
+ update(props: DirectEditorProps): void;
39
+ updatePluginViews(prevState?: EditorState): void;
40
+ destroy(): void;
41
+ }
42
+ export interface UseEditorOptions extends EditorProps {
43
+ defaultState?: EditorState;
44
+ state?: EditorState;
45
+ plugins?: Plugin[];
46
+ dispatchTransaction?(this: EditorView, tr: Transaction): void;
47
+ }
48
+ /**
49
+ * Creates, mounts, and manages a ProseMirror `EditorView`.
50
+ *
51
+ * All state and props updates are executed in a layout effect.
52
+ * To ensure that the EditorState and EditorView are never out of
53
+ * sync, it's important that the EditorView produced by this hook
54
+ * is only accessed through the `useEditorViewEvent` and
55
+ * `useEditorViewLayoutEffect` hooks.
56
+ */
57
+ export declare function useEditor<T extends HTMLElement = HTMLElement>(mount: T | null, options: UseEditorOptions): {
58
+ editor: {
59
+ view: EditorView | null;
60
+ registerEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("../plugins/componentEventListeners.js").EventHandler<keyof import("prosemirror-view").DOMEventMap>) => void;
61
+ unregisterEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("../plugins/componentEventListeners.js").EventHandler<keyof import("prosemirror-view").DOMEventMap>) => void;
62
+ cursorWrapper: Decoration | null;
63
+ docViewDescRef: import("react").MutableRefObject<NodeViewDesc>;
64
+ };
65
+ state: EditorState;
66
+ };
@@ -0,0 +1,17 @@
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
+ export declare function useEditorEffect(effect: (editorView: EditorView) => void | (() => void), dependencies?: DependencyList): void;
@@ -0,0 +1,15 @@
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 is dependent on both the
10
+ * `EditorViewContext.Provider` and the
11
+ * `DeferredLayoutEffectProvider`. It can only be used in a
12
+ * component that is mounted as a child of both of these
13
+ * providers.
14
+ */
15
+ export declare function useEditorEventCallback<T extends unknown[], R>(callback: (view: EditorView, ...args: T) => R): (...args: T) => R | undefined;
@@ -0,0 +1,8 @@
1
+ import type { DOMEventMap } from "prosemirror-view";
2
+ import type { EventHandler } from "../plugins/componentEventListeners.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,5 @@
1
+ /**
2
+ * Provides a function that forces an update of the
3
+ * component.
4
+ */
5
+ export declare function useForceUpdate(): () => void;
@@ -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,11 @@
1
+ import { Node } from "prosemirror-model";
2
+ import { Decoration, DecorationSource } from "prosemirror-view";
3
+ import { MutableRefObject } from "react";
4
+ import { NodeViewDesc, ViewDesc } from "../viewdesc.js";
5
+ export declare function useNodeViewDescriptor(node: Node | undefined, getPos: () => number, domRef: undefined | MutableRefObject<HTMLElement | null>, nodeDomRef: MutableRefObject<HTMLElement | null>, innerDecorations: DecorationSource, outerDecorations: readonly Decoration[], viewDesc?: NodeViewDesc, contentDOMRef?: MutableRefObject<HTMLElement | null>): {
6
+ hasContentDOM: boolean;
7
+ childDescriptors: MutableRefObject<ViewDesc[]>;
8
+ nodeViewDescRef: MutableRefObject<NodeViewDesc | undefined>;
9
+ setStopEvent: (newStopEvent: (event: Event) => boolean | undefined) => void;
10
+ setSelectNode: (newSelectNode: () => void, newDeselectNode: () => void) => void;
11
+ };
@@ -0,0 +1,5 @@
1
+ export declare function useReactKeys(): {
2
+ posToKey: Map<number, string>;
3
+ keyToPos: Map<string, number>;
4
+ posToNode: Map<number, import("prosemirror-model").Node>;
5
+ } | null | undefined;
@@ -0,0 +1 @@
1
+ export declare function useSelectNode(selectNode: () => void, deselectNode?: () => void): void;
@@ -0,0 +1,2 @@
1
+ import { EditorView } from "prosemirror-view";
2
+ export declare function useStopEvent(stopEvent: (view: EditorView, event: Event) => boolean): void;
@@ -0,0 +1,12 @@
1
+ export { ProseMirror } from "./components/ProseMirror.js";
2
+ export { ProseMirrorDoc } from "./components/ProseMirrorDoc.js";
3
+ export { useEditorEffect } from "./hooks/useEditorEffect.js";
4
+ export { useEditorEventCallback } from "./hooks/useEditorEventCallback.js";
5
+ export { useEditorEventListener } from "./hooks/useEditorEventListener.js";
6
+ export { useEditorState } from "./hooks/useEditorState.js";
7
+ export { useStopEvent } from "./hooks/useStopEvent.js";
8
+ export { useSelectNode } from "./hooks/useSelectNode.js";
9
+ export { reactKeys } from "./plugins/reactKeys.js";
10
+ export { widget } from "./decorations/ReactWidgetType.js";
11
+ export type { NodeViewComponentProps } from "./components/NodeViewComponentProps.js";
12
+ export type { WidgetViewComponentProps } from "./components/WidgetViewComponentProps.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ import { Decoration } from "prosemirror-view";
3
+ export declare function beforeInputPlugin(setCursorWrapper: (deco: Decoration | null) => void): Plugin<any>;
@@ -0,0 +1,4 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ import { DOMEventMap, EditorView } from "prosemirror-view";
3
+ export type EventHandler<EventType extends keyof DOMEventMap = keyof DOMEventMap> = (this: Plugin, view: EditorView, event: DOMEventMap[EventType]) => boolean | void;
4
+ export declare function componentEventListeners(eventHandlerRegistry: Map<keyof DOMEventMap, Iterable<EventHandler>>): Plugin<any>;
@@ -0,0 +1,4 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ import { DOMEventMap, EditorView } from "prosemirror-view";
3
+ export type EventHandler<EventType extends keyof DOMEventMap = keyof DOMEventMap> = (this: Plugin, view: EditorView, event: DOMEventMap[EventType]) => boolean | void;
4
+ export declare function createComponentEventListenersPlugin(eventHandlerRegistry: Map<keyof DOMEventMap, Set<EventHandler>>): Plugin<any>;
@@ -0,0 +1,19 @@
1
+ import { Node } from "prosemirror-model";
2
+ import { Plugin, PluginKey } from "prosemirror-state";
3
+ export declare function createNodeKey(): string;
4
+ export declare const reactKeysPluginKey: PluginKey<{
5
+ posToKey: Map<number, string>;
6
+ keyToPos: Map<string, number>;
7
+ posToNode: Map<number, Node>;
8
+ }>;
9
+ /**
10
+ * Tracks a unique key for each (non-text) node in the
11
+ * document, identified by its current position. Keys are
12
+ * (mostly) stable across transaction applications. The
13
+ * key for a given node can be accessed by that node's
14
+ * current position in the document, and vice versa.
15
+ */
16
+ export declare function reactKeys(): Plugin<{
17
+ posToKey: Map<number, string>;
18
+ keyToPos: Map<string, number>;
19
+ }>;