@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.
- package/LICENSE.txt +21 -0
- package/README.md +939 -0
- package/dist/cjs/AbstractEditorView.js +4 -0
- package/dist/cjs/ReactEditorView.js +194 -0
- package/dist/cjs/StaticEditorView.js +89 -0
- package/dist/cjs/browser.js +53 -0
- package/dist/cjs/commands/reorderSiblings.js +72 -0
- package/dist/cjs/components/ChildNodeViews.js +418 -0
- package/dist/cjs/components/CursorWrapper.js +84 -0
- package/dist/cjs/components/EditorStateSelectorsProvider.js +90 -0
- package/dist/cjs/components/LayoutGroup.js +112 -0
- package/dist/cjs/components/NativeWidgetView.js +108 -0
- package/dist/cjs/components/OutputSpec.js +121 -0
- package/dist/cjs/components/ProseMirror.js +146 -0
- package/dist/cjs/components/ProseMirrorDoc.js +74 -0
- package/dist/cjs/components/SeparatorHackView.js +99 -0
- package/dist/cjs/components/TextNodeView.js +113 -0
- package/dist/cjs/components/TrailingHackView.js +87 -0
- package/dist/cjs/components/WidgetView.js +94 -0
- package/dist/cjs/components/WidgetViewComponentProps.js +4 -0
- package/dist/cjs/components/marks/DefaultMarkView.js +70 -0
- package/dist/cjs/components/marks/MarkView.js +85 -0
- package/dist/cjs/components/marks/MarkViewComponentProps.js +4 -0
- package/dist/cjs/components/marks/MarkViewConstructorView.js +116 -0
- package/dist/cjs/components/marks/ReactMarkView.js +109 -0
- package/dist/cjs/components/nodes/DefaultNodeView.js +68 -0
- package/dist/cjs/components/nodes/DocNodeView.js +97 -0
- package/dist/cjs/components/nodes/NodeView.js +129 -0
- package/dist/cjs/components/nodes/NodeViewComponentProps.js +4 -0
- package/dist/cjs/components/nodes/NodeViewConstructorView.js +145 -0
- package/dist/cjs/components/nodes/ReactNodeView.js +189 -0
- package/dist/cjs/constants.js +33 -0
- package/dist/cjs/contexts/ChildDescriptionsContext.js +19 -0
- package/dist/cjs/contexts/EditorContext.js +12 -0
- package/dist/cjs/contexts/EditorStateContext.js +12 -0
- package/dist/cjs/contexts/EditorStateStoreContext.js +45 -0
- package/dist/cjs/contexts/IgnoreMutationContext.js +12 -0
- package/dist/cjs/contexts/LayoutGroupContext.js +12 -0
- package/dist/cjs/contexts/NodeViewContext.js +12 -0
- package/dist/cjs/contexts/RenderStoreContext.js +54 -0
- package/dist/cjs/contexts/SelectNodeContext.js +12 -0
- package/dist/cjs/contexts/StopEventContext.js +12 -0
- package/dist/cjs/decorations/ReactWidgetType.js +58 -0
- package/dist/cjs/decorations/computeDocDeco.js +44 -0
- package/dist/cjs/decorations/internalTypes.js +4 -0
- package/dist/cjs/decorations/iterDeco.js +91 -0
- package/dist/cjs/decorations/viewDecorations.js +155 -0
- package/dist/cjs/dom.js +147 -0
- package/dist/cjs/findDOMNode.js +46 -0
- package/dist/cjs/hooks/useClientLayoutEffect.js +19 -0
- package/dist/cjs/hooks/useComponentEventListeners.js +72 -0
- package/dist/cjs/hooks/useEditor.js +130 -0
- package/dist/cjs/hooks/useEditorEffect.js +39 -0
- package/dist/cjs/hooks/useEditorEventCallback.js +38 -0
- package/dist/cjs/hooks/useEditorEventListener.js +34 -0
- package/dist/cjs/hooks/useEditorState.js +18 -0
- package/dist/cjs/hooks/useEditorStateSelector.js +17 -0
- package/dist/cjs/hooks/useEffectEvent.js +34 -0
- package/dist/cjs/hooks/useForceUpdate.js +15 -0
- package/dist/cjs/hooks/useIgnoreMutation.js +24 -0
- package/dist/cjs/hooks/useIsComposingIn.js +25 -0
- package/dist/cjs/hooks/useIsEditorStatic.js +15 -0
- package/dist/cjs/hooks/useIsNodeSelected.js +21 -0
- package/dist/cjs/hooks/useLayoutGroupEffect.js +20 -0
- package/dist/cjs/hooks/useMarkViewDescription.js +134 -0
- package/dist/cjs/hooks/useNodePos.js +18 -0
- package/dist/cjs/hooks/useNodeViewDescription.js +154 -0
- package/dist/cjs/hooks/useReactKeys.js +17 -0
- package/dist/cjs/hooks/useSelectNode.js +30 -0
- package/dist/cjs/hooks/useSetDom.js +57 -0
- package/dist/cjs/hooks/useStopEvent.js +24 -0
- package/dist/cjs/index.js +85 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/plugins/beforeInputPlugin.js +356 -0
- package/dist/cjs/plugins/reactKeys.js +121 -0
- package/dist/cjs/props.js +283 -0
- package/dist/cjs/refs.js +28 -0
- package/dist/cjs/testing/editorViewTestHelpers.js +109 -0
- package/dist/cjs/testing/setupProseMirrorView.js +94 -0
- package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +26 -0
- package/dist/cjs/tiptap/TiptapEditor.js +34 -0
- package/dist/cjs/tiptap/TiptapEditorContent.js +143 -0
- package/dist/cjs/tiptap/TiptapEditorView.js +130 -0
- package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +12 -0
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +40 -0
- package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +21 -0
- package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +104 -0
- package/dist/cjs/tiptap/hooks/useEditor.js +318 -0
- package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +15 -0
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +35 -0
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +35 -0
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +35 -0
- package/dist/cjs/tiptap/index.js +48 -0
- package/dist/cjs/tiptap/tiptapNodeView.js +245 -0
- package/dist/cjs/viewdesc.js +862 -0
- package/dist/esm/AbstractEditorView.js +1 -0
- package/dist/esm/ReactEditorView.js +194 -0
- package/dist/esm/StaticEditorView.js +79 -0
- package/dist/esm/browser.js +43 -0
- package/dist/esm/commands/reorderSiblings.js +63 -0
- package/dist/esm/components/ChildNodeViews.js +359 -0
- package/dist/esm/components/CursorWrapper.js +33 -0
- package/dist/esm/components/EditorStateSelectorsProvider.js +31 -0
- package/dist/esm/components/LayoutGroup.js +67 -0
- package/dist/esm/components/NativeWidgetView.js +57 -0
- package/dist/esm/components/OutputSpec.js +71 -0
- package/dist/esm/components/ProseMirror.js +95 -0
- package/dist/esm/components/ProseMirrorDoc.js +15 -0
- package/dist/esm/components/SeparatorHackView.js +48 -0
- package/dist/esm/components/TextNodeView.js +103 -0
- package/dist/esm/components/TrailingHackView.js +36 -0
- package/dist/esm/components/WidgetView.js +43 -0
- package/dist/esm/components/WidgetViewComponentProps.js +1 -0
- package/dist/esm/components/marks/DefaultMarkView.js +19 -0
- package/dist/esm/components/marks/MarkView.js +34 -0
- package/dist/esm/components/marks/MarkViewComponentProps.js +1 -0
- package/dist/esm/components/marks/MarkViewConstructorView.js +65 -0
- package/dist/esm/components/marks/ReactMarkView.js +58 -0
- package/dist/esm/components/nodes/DefaultNodeView.js +17 -0
- package/dist/esm/components/nodes/DocNodeView.js +46 -0
- package/dist/esm/components/nodes/NodeView.js +67 -0
- package/dist/esm/components/nodes/NodeViewComponentProps.js +1 -0
- package/dist/esm/components/nodes/NodeViewConstructorView.js +94 -0
- package/dist/esm/components/nodes/ReactNodeView.js +138 -0
- package/dist/esm/constants.js +15 -0
- package/dist/esm/contexts/ChildDescriptionsContext.js +9 -0
- package/dist/esm/contexts/EditorContext.js +7 -0
- package/dist/esm/contexts/EditorStateContext.js +2 -0
- package/dist/esm/contexts/EditorStateStoreContext.js +27 -0
- package/dist/esm/contexts/IgnoreMutationContext.js +2 -0
- package/dist/esm/contexts/LayoutGroupContext.js +2 -0
- package/dist/esm/contexts/NodeViewContext.js +2 -0
- package/dist/esm/contexts/RenderStoreContext.js +33 -0
- package/dist/esm/contexts/SelectNodeContext.js +2 -0
- package/dist/esm/contexts/StopEventContext.js +2 -0
- package/dist/esm/decorations/ReactWidgetType.js +40 -0
- package/dist/esm/decorations/computeDocDeco.js +44 -0
- package/dist/esm/decorations/internalTypes.js +1 -0
- package/dist/esm/decorations/iterDeco.js +85 -0
- package/dist/esm/decorations/viewDecorations.js +155 -0
- package/dist/esm/dom.js +110 -0
- package/dist/esm/findDOMNode.js +31 -0
- package/dist/esm/hooks/useClientLayoutEffect.js +9 -0
- package/dist/esm/hooks/useComponentEventListeners.js +87 -0
- package/dist/esm/hooks/useEditor.js +128 -0
- package/dist/esm/hooks/useEditorEffect.js +46 -0
- package/dist/esm/hooks/useEditorEventCallback.js +38 -0
- package/dist/esm/hooks/useEditorEventListener.js +28 -0
- package/dist/esm/hooks/useEditorState.js +10 -0
- package/dist/esm/hooks/useEditorStateSelector.js +14 -0
- package/dist/esm/hooks/useEffectEvent.js +24 -0
- package/dist/esm/hooks/useForceUpdate.js +8 -0
- package/dist/esm/hooks/useIgnoreMutation.js +14 -0
- package/dist/esm/hooks/useIsComposingIn.js +17 -0
- package/dist/esm/hooks/useIsEditorStatic.js +8 -0
- package/dist/esm/hooks/useIsNodeSelected.js +11 -0
- package/dist/esm/hooks/useLayoutGroupEffect.js +10 -0
- package/dist/esm/hooks/useMarkViewDescription.js +124 -0
- package/dist/esm/hooks/useNodePos.js +15 -0
- package/dist/esm/hooks/useNodeViewDescription.js +144 -0
- package/dist/esm/hooks/useReactKeys.js +7 -0
- package/dist/esm/hooks/useSelectNode.js +20 -0
- package/dist/esm/hooks/useSetDom.js +47 -0
- package/dist/esm/hooks/useStopEvent.js +14 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/plugins/beforeInputPlugin.js +346 -0
- package/dist/esm/plugins/reactKeys.js +106 -0
- package/dist/esm/props.js +267 -0
- package/dist/esm/refs.js +18 -0
- package/dist/esm/testing/editorViewTestHelpers.js +86 -0
- package/dist/esm/testing/setupProseMirrorView.js +76 -0
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +22 -0
- package/dist/esm/tiptap/TiptapEditor.js +24 -0
- package/dist/esm/tiptap/TiptapEditorContent.js +99 -0
- package/dist/esm/tiptap/TiptapEditorView.js +76 -0
- package/dist/esm/tiptap/contexts/TiptapEditorContext.js +2 -0
- package/dist/esm/tiptap/extensions/ReactProseMirror.js +30 -0
- package/dist/esm/tiptap/extensions/ReactProseMirrorCommands.js +11 -0
- package/dist/esm/tiptap/extensions/commands/updateAttributes.js +96 -0
- package/dist/esm/tiptap/hooks/useEditor.js +308 -0
- package/dist/esm/tiptap/hooks/useIsInReactProseMirror.js +9 -0
- package/dist/esm/tiptap/hooks/useTiptapEditor.js +31 -0
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +42 -0
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +35 -0
- package/dist/esm/tiptap/index.js +9 -0
- package/dist/esm/tiptap/tiptapNodeView.js +211 -0
- package/dist/esm/viewdesc.js +844 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/AbstractEditorView.d.ts +28 -0
- package/dist/types/ReactEditorView.d.ts +102 -0
- package/dist/types/StaticEditorView.d.ts +26 -0
- package/dist/types/__tests__/viewdesc.test.d.ts +1 -0
- package/dist/types/browser.d.ts +15 -0
- package/dist/types/commands/__tests__/reorderSiblings.test.d.ts +1 -0
- package/dist/types/commands/reorderSiblings.d.ts +14 -0
- package/dist/types/components/ChildNodeViews.d.ts +9 -0
- package/dist/types/components/CursorWrapper.d.ts +3 -0
- package/dist/types/components/EditorStateSelectorsProvider.d.ts +10 -0
- package/dist/types/components/LayoutGroup.d.ts +12 -0
- package/dist/types/components/NativeWidgetView.d.ts +8 -0
- package/dist/types/components/OutputSpec.d.ts +10 -0
- package/dist/types/components/ProseMirror.d.ts +14 -0
- package/dist/types/components/ProseMirrorDoc.d.ts +16 -0
- package/dist/types/components/SeparatorHackView.d.ts +6 -0
- package/dist/types/components/TextNodeView.d.ts +27 -0
- package/dist/types/components/TrailingHackView.d.ts +6 -0
- package/dist/types/components/WidgetView.d.ts +8 -0
- package/dist/types/components/WidgetViewComponentProps.d.ts +7 -0
- package/dist/types/components/__tests__/ProseMirror.composition.test.d.ts +17 -0
- package/dist/types/components/__tests__/ProseMirror.domchange.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.draw-decoration.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.draw.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.memory-leak.test.d.ts +6 -0
- package/dist/types/components/__tests__/ProseMirror.mobile.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.node-view.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.selection.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.test.d.ts +1 -0
- package/dist/types/components/__tests__/stableContexts.test.d.ts +10 -0
- package/dist/types/components/marks/DefaultMarkView.d.ts +3 -0
- package/dist/types/components/marks/MarkView.d.ts +10 -0
- package/dist/types/components/marks/MarkViewComponentProps.d.ts +11 -0
- package/dist/types/components/marks/MarkViewConstructorView.d.ts +12 -0
- package/dist/types/components/marks/ReactMarkView.d.ts +12 -0
- package/dist/types/components/nodes/DefaultNodeView.d.ts +3 -0
- package/dist/types/components/nodes/DocNodeView.d.ts +12 -0
- package/dist/types/components/nodes/NodeView.d.ts +14 -0
- package/dist/types/components/nodes/NodeViewComponentProps.d.ts +13 -0
- package/dist/types/components/nodes/NodeViewConstructorView.d.ts +12 -0
- package/dist/types/components/nodes/ReactNodeView.d.ts +13 -0
- package/dist/types/constants.d.ts +4 -0
- package/dist/types/contexts/ChildDescriptionsContext.d.ts +7 -0
- package/dist/types/contexts/EditorContext.d.ts +18 -0
- package/dist/types/contexts/EditorStateContext.d.ts +2 -0
- package/dist/types/contexts/EditorStateStoreContext.d.ts +9 -0
- package/dist/types/contexts/IgnoreMutationContext.d.ts +5 -0
- package/dist/types/contexts/LayoutGroupContext.d.ts +5 -0
- package/dist/types/contexts/NodeViewContext.d.ts +9 -0
- package/dist/types/contexts/RenderStoreContext.d.ts +24 -0
- package/dist/types/contexts/SelectNodeContext.d.ts +5 -0
- package/dist/types/contexts/StopEventContext.d.ts +5 -0
- package/dist/types/contexts/__tests__/DeferredLayoutEffects.test.d.ts +1 -0
- package/dist/types/decorations/ReactWidgetType.d.ts +40 -0
- package/dist/types/decorations/computeDocDeco.d.ts +14 -0
- package/dist/types/decorations/internalTypes.d.ts +20 -0
- package/dist/types/decorations/iterDeco.d.ts +3 -0
- package/dist/types/decorations/viewDecorations.d.ts +14 -0
- package/dist/types/dom.d.ts +22 -0
- package/dist/types/findDOMNode.d.ts +3 -0
- package/dist/types/hooks/__tests__/useEditorEffect.test.d.ts +1 -0
- package/dist/types/hooks/useClientLayoutEffect.d.ts +2 -0
- package/dist/types/hooks/useComponentEventListeners.d.ts +34 -0
- package/dist/types/hooks/useEditor.d.ts +37 -0
- package/dist/types/hooks/useEditorEffect.d.ts +21 -0
- package/dist/types/hooks/useEditorEventCallback.d.ts +13 -0
- package/dist/types/hooks/useEditorEventListener.d.ts +8 -0
- package/dist/types/hooks/useEditorState.d.ts +5 -0
- package/dist/types/hooks/useEditorStateSelector.d.ts +10 -0
- package/dist/types/hooks/useEffectEvent.d.ts +1 -0
- package/dist/types/hooks/useForceUpdate.d.ts +5 -0
- package/dist/types/hooks/useIgnoreMutation.d.ts +2 -0
- package/dist/types/hooks/useIsComposingIn.d.ts +4 -0
- package/dist/types/hooks/useIsEditorStatic.d.ts +5 -0
- package/dist/types/hooks/useIsNodeSelected.d.ts +1 -0
- package/dist/types/hooks/useLayoutGroupEffect.d.ts +3 -0
- package/dist/types/hooks/useMarkViewDescription.d.ts +15 -0
- package/dist/types/hooks/useNodePos.d.ts +9 -0
- package/dist/types/hooks/useNodeViewDescription.d.ts +16 -0
- package/dist/types/hooks/useReactKeys.d.ts +2 -0
- package/dist/types/hooks/useSelectNode.d.ts +2 -0
- package/dist/types/hooks/useSetDom.d.ts +2 -0
- package/dist/types/hooks/useStopEvent.d.ts +2 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/plugins/__tests__/reactKeys.test.d.ts +1 -0
- package/dist/types/plugins/beforeInputPlugin.d.ts +2 -0
- package/dist/types/plugins/reactKeys.d.ts +23 -0
- package/dist/types/props.d.ts +1173 -0
- package/dist/types/refs.d.ts +2 -0
- package/dist/types/testing/editorViewTestHelpers.d.ts +24 -0
- package/dist/types/testing/setupProseMirrorView.d.ts +2 -0
- package/dist/types/tiptap/ReactProseMirrorNodeView.d.ts +15 -0
- package/dist/types/tiptap/TiptapEditor.d.ts +6 -0
- package/dist/types/tiptap/TiptapEditorContent.d.ts +28 -0
- package/dist/types/tiptap/TiptapEditorView.d.ts +16 -0
- package/dist/types/tiptap/contexts/TiptapEditorContext.d.ts +6 -0
- package/dist/types/tiptap/extensions/ReactProseMirror.d.ts +9 -0
- package/dist/types/tiptap/extensions/ReactProseMirrorCommands.d.ts +2 -0
- package/dist/types/tiptap/extensions/commands/updateAttributes.d.ts +24 -0
- package/dist/types/tiptap/hooks/useEditor.d.ts +38 -0
- package/dist/types/tiptap/hooks/useIsInReactProseMirror.d.ts +6 -0
- package/dist/types/tiptap/hooks/useTiptapEditor.d.ts +11 -0
- package/dist/types/tiptap/hooks/useTiptapEditorEffect.d.ts +21 -0
- package/dist/types/tiptap/hooks/useTiptapEditorEventCallback.d.ts +13 -0
- package/dist/types/tiptap/index.d.ts +9 -0
- package/dist/types/tiptap/tiptapNodeView.d.ts +50 -0
- package/dist/types/viewdesc.d.ts +179 -0
- package/package.json +167 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,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 @@
|
|
|
1
|
+
export declare function useIsNodeSelected(): boolean;
|
|
@@ -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,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,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>;
|