@handlewithcare/react-prosemirror 2.4.12 → 2.5.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/dist/cjs/AbstractEditorView.js +4 -0
- package/dist/cjs/ReactEditorView.js +156 -0
- package/dist/cjs/StaticEditorView.js +86 -0
- package/dist/cjs/components/ChildNodeViews.js +58 -29
- package/dist/cjs/components/CustomNodeView.js +77 -137
- package/dist/cjs/{hooks/useNodePos.js → components/DefaultNodeView.js} +24 -26
- package/dist/cjs/components/DocNodeView.js +33 -41
- package/dist/cjs/components/MarkView.js +1 -2
- package/dist/cjs/components/NativeWidgetView.js +2 -3
- package/dist/cjs/components/NodeView.js +31 -21
- package/dist/cjs/components/ProseMirror.js +25 -17
- package/dist/cjs/components/ProseMirrorDoc.js +7 -27
- package/dist/cjs/components/ReactNodeView.js +98 -61
- package/dist/cjs/components/SeparatorHackView.js +1 -2
- package/dist/cjs/components/TextNodeView.js +4 -5
- package/dist/cjs/components/TrailingHackView.js +1 -2
- package/dist/cjs/components/WidgetView.js +2 -4
- package/dist/cjs/constants.js +33 -0
- package/dist/cjs/hooks/useEditor.js +33 -229
- package/dist/cjs/hooks/useEditorEffect.js +2 -2
- package/dist/cjs/hooks/useEditorEventCallback.js +8 -5
- package/dist/cjs/hooks/useIgnoreMutation.js +1 -1
- package/dist/cjs/hooks/useNodeViewDescriptor.js +123 -80
- package/dist/cjs/hooks/useReactKeys.js +1 -1
- package/dist/cjs/hooks/useSelectNode.js +9 -7
- package/dist/cjs/hooks/useStopEvent.js +1 -1
- package/dist/cjs/plugins/beforeInputPlugin.js +12 -0
- package/dist/cjs/testing/editorViewTestHelpers.js +0 -2
- package/dist/cjs/viewdesc.js +104 -25
- package/dist/esm/AbstractEditorView.js +1 -0
- package/dist/esm/ReactEditorView.js +156 -0
- package/dist/esm/StaticEditorView.js +76 -0
- package/dist/esm/components/ChildNodeViews.js +59 -31
- package/dist/esm/components/CustomNodeView.js +78 -138
- package/dist/esm/components/DefaultNodeView.js +16 -0
- package/dist/esm/components/DocNodeView.js +33 -41
- package/dist/esm/components/MarkView.js +1 -2
- package/dist/esm/components/NativeWidgetView.js +2 -3
- package/dist/esm/components/NodeView.js +32 -22
- package/dist/esm/components/ProseMirror.js +25 -17
- package/dist/esm/components/ProseMirrorDoc.js +7 -28
- package/dist/esm/components/ReactNodeView.js +99 -62
- package/dist/esm/components/SeparatorHackView.js +1 -2
- package/dist/esm/components/TextNodeView.js +4 -5
- package/dist/esm/components/TrailingHackView.js +1 -2
- package/dist/esm/components/WidgetView.js +2 -4
- package/dist/esm/constants.js +15 -0
- package/dist/esm/hooks/useEditor.js +29 -218
- package/dist/esm/hooks/useEditorEffect.js +2 -2
- package/dist/esm/hooks/useEditorEventCallback.js +8 -5
- package/dist/esm/hooks/useIgnoreMutation.js +1 -1
- package/dist/esm/hooks/useNodeViewDescriptor.js +125 -82
- package/dist/esm/hooks/useReactKeys.js +1 -1
- package/dist/esm/hooks/useSelectNode.js +9 -7
- package/dist/esm/hooks/useStopEvent.js +1 -1
- package/dist/esm/plugins/beforeInputPlugin.js +12 -0
- package/dist/esm/testing/editorViewTestHelpers.js +0 -2
- package/dist/esm/viewdesc.js +94 -18
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AbstractEditorView.d.ts +27 -0
- package/dist/types/ReactEditorView.d.ts +80 -0
- package/dist/types/StaticEditorView.d.ts +24 -0
- package/dist/types/components/ChildNodeViews.d.ts +2 -2
- package/dist/types/components/CustomNodeView.d.ts +3 -3
- package/dist/types/components/DefaultNodeView.d.ts +3 -0
- package/dist/types/components/DocNodeView.d.ts +9 -17
- package/dist/types/components/MarkView.d.ts +2 -2
- package/dist/types/components/NativeWidgetView.d.ts +2 -2
- package/dist/types/components/NodeView.d.ts +5 -5
- package/dist/types/components/NodeViewComponentProps.d.ts +3 -4
- package/dist/types/components/ProseMirrorDoc.d.ts +14 -8
- package/dist/types/components/ReactNodeView.d.ts +4 -2
- package/dist/types/components/SeparatorHackView.d.ts +2 -2
- package/dist/types/components/TextNodeView.d.ts +4 -3
- package/dist/types/components/TrailingHackView.d.ts +2 -2
- package/dist/types/components/WidgetView.d.ts +2 -2
- package/dist/types/constants.d.ts +4 -0
- package/dist/types/contexts/EditorContext.d.ts +6 -4
- package/dist/types/contexts/IgnoreMutationContext.d.ts +2 -1
- package/dist/types/contexts/NodeViewContext.d.ts +3 -1
- package/dist/types/contexts/SelectNodeContext.d.ts +3 -1
- package/dist/types/contexts/StopEventContext.d.ts +2 -1
- package/dist/types/decorations/computeDocDeco.d.ts +3 -2
- package/dist/types/decorations/viewDecorations.d.ts +3 -2
- package/dist/types/hooks/useEditor.d.ts +5 -46
- package/dist/types/hooks/useNodeViewDescriptor.d.ts +18 -10
- package/dist/types/hooks/useReactKeys.d.ts +1 -1
- package/dist/types/hooks/useSelectNode.d.ts +2 -1
- package/dist/types/props.d.ts +3 -3
- package/dist/types/viewdesc.d.ts +29 -11
- package/package.json +7 -3
- package/dist/cjs/components/Editor.js +0 -28
- package/dist/cjs/components/NodeViews.js +0 -73
- package/dist/cjs/components/__tests__/LayoutGroup.test.js +0 -141
- package/dist/cjs/components/__tests__/ProseMirror.test.js +0 -255
- package/dist/cjs/contexts/NodeViewsContext.js +0 -10
- package/dist/cjs/hooks/__tests__/useEditorViewLayoutEffect.test.js +0 -107
- package/dist/cjs/hooks/__tests__/useNodeViews.test.js +0 -159
- package/dist/cjs/hooks/useClientOnly.js +0 -19
- package/dist/cjs/hooks/useEditorView.js +0 -100
- package/dist/cjs/hooks/useNodeViews.js +0 -100
- package/dist/cjs/nodeViews/createReactNodeViewConstructor.js +0 -244
- package/dist/cjs/nodeViews/phrasingContentTags.js +0 -57
- package/dist/cjs/plugins/__tests__/react.test.js +0 -139
- package/dist/cjs/plugins/react.js +0 -71
- package/dist/cjs/selection/SelectionDOMObserver.js +0 -171
- package/dist/cjs/selection/hasFocusAndSelection.js +0 -35
- package/dist/cjs/selection/selectionFromDOM.js +0 -77
- package/dist/cjs/selection/selectionToDOM.js +0 -226
- package/dist/cjs/ssr.js +0 -85
- package/dist/esm/components/Editor.js +0 -15
- package/dist/esm/components/NodeViews.js +0 -26
- package/dist/esm/components/__tests__/LayoutGroup.test.js +0 -98
- package/dist/esm/components/__tests__/ProseMirror.test.js +0 -207
- package/dist/esm/contexts/NodeViewsContext.js +0 -9
- package/dist/esm/hooks/__tests__/useEditorViewLayoutEffect.test.js +0 -98
- package/dist/esm/hooks/__tests__/useNodeViews.test.js +0 -116
- package/dist/esm/hooks/useClientOnly.js +0 -9
- package/dist/esm/hooks/useEditorView.js +0 -99
- package/dist/esm/hooks/useNodePos.js +0 -16
- package/dist/esm/hooks/useNodeViews.js +0 -53
- package/dist/esm/nodeViews/createReactNodeViewConstructor.js +0 -214
- package/dist/esm/nodeViews/phrasingContentTags.js +0 -49
- package/dist/esm/plugins/__tests__/react.test.js +0 -135
- package/dist/esm/plugins/react.js +0 -64
- package/dist/esm/selection/SelectionDOMObserver.js +0 -161
- package/dist/esm/selection/hasFocusAndSelection.js +0 -17
- package/dist/esm/selection/selectionFromDOM.js +0 -59
- package/dist/esm/selection/selectionToDOM.js +0 -196
- package/dist/esm/ssr.js +0 -82
- package/dist/types/components/Editor.d.ts +0 -7
- package/dist/types/components/NodeViews.d.ts +0 -6
- package/dist/types/components/__tests__/LayoutGroup.test.d.ts +0 -1
- package/dist/types/contexts/NodeViewsContext.d.ts +0 -19
- package/dist/types/hooks/__tests__/useEditorViewLayoutEffect.test.d.ts +0 -1
- package/dist/types/hooks/__tests__/useNodeViews.test.d.ts +0 -1
- package/dist/types/hooks/useClientOnly.d.ts +0 -1
- package/dist/types/hooks/useEditorView.d.ts +0 -23
- package/dist/types/hooks/useNodePos.d.ts +0 -9
- package/dist/types/hooks/useNodeViews.d.ts +0 -5
- package/dist/types/nodeViews/createReactNodeViewConstructor.d.ts +0 -48
- package/dist/types/nodeViews/phrasingContentTags.d.ts +0 -1
- package/dist/types/plugins/__tests__/react.test.d.ts +0 -1
- package/dist/types/plugins/react.d.ts +0 -21
- package/dist/types/selection/SelectionDOMObserver.d.ts +0 -33
- package/dist/types/selection/hasFocusAndSelection.d.ts +0 -3
- package/dist/types/selection/selectionFromDOM.d.ts +0 -4
- package/dist/types/selection/selectionToDOM.d.ts +0 -9
- package/dist/types/ssr.d.ts +0 -19
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EditorState } from "prosemirror-state";
|
|
2
|
+
import { DirectEditorProps, EditorProps, MarkViewConstructor, NodeViewConstructor } from "prosemirror-view";
|
|
3
|
+
import { DOMSelection } from "./dom.js";
|
|
4
|
+
export type NodeViewSet = {
|
|
5
|
+
[name: string]: NodeViewConstructor | MarkViewConstructor;
|
|
6
|
+
};
|
|
7
|
+
export interface AbstractEditorView {
|
|
8
|
+
readonly composing: boolean;
|
|
9
|
+
readonly dom: HTMLElement | null;
|
|
10
|
+
readonly editable: boolean;
|
|
11
|
+
readonly nodeViews: NodeViewSet;
|
|
12
|
+
readonly props: DirectEditorProps;
|
|
13
|
+
readonly state: EditorState;
|
|
14
|
+
setProps(props: Partial<DirectEditorProps>): void;
|
|
15
|
+
update(props: DirectEditorProps): void;
|
|
16
|
+
updateState(state: EditorState): void;
|
|
17
|
+
someProp<PropName extends keyof EditorProps>(propName: PropName): EditorProps[PropName] | undefined;
|
|
18
|
+
someProp<PropName extends keyof EditorProps, Result>(propName: PropName, f: (value: NonNullable<EditorProps[PropName]>) => Result): Result | undefined;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
domSelectionRange(): {
|
|
21
|
+
anchorNode: Node | null;
|
|
22
|
+
anchorOffset: number;
|
|
23
|
+
focusNode: Node | null;
|
|
24
|
+
focusOffset: number;
|
|
25
|
+
};
|
|
26
|
+
domSelection(): DOMSelection | null;
|
|
27
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { EditorState } from "prosemirror-state";
|
|
2
|
+
import { Decoration, DirectEditorProps, EditorProps, EditorView } from "prosemirror-view";
|
|
3
|
+
import { AbstractEditorView, NodeViewSet } from "./AbstractEditorView.js";
|
|
4
|
+
import { DOMNode, DOMSelection, DOMSelectionRange } from "./dom.js";
|
|
5
|
+
import { NodeViewDesc, ViewDesc } from "./viewdesc.js";
|
|
6
|
+
interface DOMObserver {
|
|
7
|
+
observer: MutationObserver | null;
|
|
8
|
+
queue: MutationRecord[];
|
|
9
|
+
start(): void;
|
|
10
|
+
stop(): void;
|
|
11
|
+
}
|
|
12
|
+
interface InputState {
|
|
13
|
+
compositionID: number;
|
|
14
|
+
compositionNodes: ViewDesc[];
|
|
15
|
+
compositionPendingChanges: number;
|
|
16
|
+
hideSelectionGuard: (() => void) | null;
|
|
17
|
+
lastClick: {
|
|
18
|
+
time: number;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
type: string;
|
|
22
|
+
button: number;
|
|
23
|
+
};
|
|
24
|
+
lastFocus: number;
|
|
25
|
+
lastIOSEnter: number;
|
|
26
|
+
lastSelectionOrigin: string | null;
|
|
27
|
+
lastSelectionTime: number;
|
|
28
|
+
lastTouch: number;
|
|
29
|
+
mouseDown: {
|
|
30
|
+
allowDefault: boolean;
|
|
31
|
+
delayedSelectionSync: boolean;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Extends EditorView to make prop and state updates pure, remove the DOM
|
|
36
|
+
* Mutation Observer, and use a custom document view managed by React.
|
|
37
|
+
*
|
|
38
|
+
* @privateRemarks
|
|
39
|
+
*
|
|
40
|
+
* The implementation relies on the base class using a private member to store
|
|
41
|
+
* the committed props and having a public getter that we override to return the
|
|
42
|
+
* latest, uncommitted props. The base class can then be told to update when the
|
|
43
|
+
* React effects are commit an update, applying the pending, uncommitted props.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ReactEditorView extends EditorView implements AbstractEditorView {
|
|
46
|
+
cursorWrapper: {
|
|
47
|
+
dom: DOMNode;
|
|
48
|
+
deco: Decoration;
|
|
49
|
+
} | null;
|
|
50
|
+
nodeViews: NodeViewSet;
|
|
51
|
+
lastSelectedViewDesc: ViewDesc | undefined;
|
|
52
|
+
docView: NodeViewDesc;
|
|
53
|
+
input: InputState;
|
|
54
|
+
domObserver: DOMObserver;
|
|
55
|
+
domSelectionRange: () => DOMSelectionRange;
|
|
56
|
+
domSelection: () => DOMSelection | null;
|
|
57
|
+
private nextProps;
|
|
58
|
+
private prevState;
|
|
59
|
+
constructor(place: {
|
|
60
|
+
mount: HTMLElement;
|
|
61
|
+
}, props: DirectEditorProps);
|
|
62
|
+
get props(): DirectEditorProps;
|
|
63
|
+
setProps(props: Partial<DirectEditorProps>): void;
|
|
64
|
+
update(props: DirectEditorProps): void;
|
|
65
|
+
updateState(state: EditorState): void;
|
|
66
|
+
someProp<PropName extends keyof EditorProps>(propName: PropName): EditorProps[PropName] | undefined;
|
|
67
|
+
someProp<PropName extends keyof EditorProps, Result>(propName: PropName, f?: (value: NonNullable<EditorProps[PropName]>) => Result): Result | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Commit effects by appling the pending props and state.
|
|
70
|
+
*
|
|
71
|
+
* Ensures the DOM selection is correct and updates plugin views.
|
|
72
|
+
*
|
|
73
|
+
* @privateRemarks
|
|
74
|
+
*
|
|
75
|
+
* The correctness of this depends on the pure update function ensuring that
|
|
76
|
+
* the node view set is up to date so that it does not try to redraw.
|
|
77
|
+
*/
|
|
78
|
+
commitPendingEffects(): void;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EditorState } from "prosemirror-state";
|
|
2
|
+
import { DirectEditorProps, EditorProps } from "prosemirror-view";
|
|
3
|
+
import { AbstractEditorView, NodeViewSet } from "./AbstractEditorView.js";
|
|
4
|
+
export declare class StaticEditorView implements AbstractEditorView {
|
|
5
|
+
props: DirectEditorProps;
|
|
6
|
+
readonly nodeViews: NodeViewSet;
|
|
7
|
+
constructor(props: DirectEditorProps);
|
|
8
|
+
get composing(): boolean;
|
|
9
|
+
get dom(): null;
|
|
10
|
+
get editable(): boolean;
|
|
11
|
+
get state(): EditorState;
|
|
12
|
+
setProps(props: Partial<DirectEditorProps>): void;
|
|
13
|
+
update(props: DirectEditorProps): void;
|
|
14
|
+
updateState(state: EditorState): void;
|
|
15
|
+
someProp<PropName extends keyof EditorProps>(propName: PropName): EditorProps[PropName] | undefined;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
domSelectionRange(): {
|
|
18
|
+
anchorNode: null;
|
|
19
|
+
anchorOffset: number;
|
|
20
|
+
focusNode: null;
|
|
21
|
+
focusOffset: number;
|
|
22
|
+
};
|
|
23
|
+
domSelection(): null;
|
|
24
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
|
-
import React
|
|
3
|
+
import React from "react";
|
|
4
4
|
export declare function wrapInDeco(reactNode: JSX.Element | string, deco: Decoration): React.DetailedReactHTMLElement<React.HTMLProps<HTMLElement>, HTMLElement> | React.FunctionComponentElement<any>;
|
|
5
5
|
export declare const ChildNodeViews: React.NamedExoticComponent<{
|
|
6
|
-
getPos:
|
|
6
|
+
getPos: () => number;
|
|
7
7
|
node: Node | undefined;
|
|
8
8
|
innerDecorations: DecorationSource;
|
|
9
9
|
}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Decoration, DecorationSource, NodeViewConstructor } from "prosemirror-view";
|
|
3
|
-
import React
|
|
3
|
+
import React from "react";
|
|
4
4
|
interface Props {
|
|
5
|
-
|
|
5
|
+
constructor: NodeViewConstructor;
|
|
6
6
|
node: Node;
|
|
7
|
-
getPos:
|
|
7
|
+
getPos: () => number;
|
|
8
8
|
innerDeco: DecorationSource;
|
|
9
9
|
outerDeco: readonly Decoration[];
|
|
10
10
|
}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
|
-
import React, {
|
|
4
|
-
|
|
5
|
-
export type DocNodeViewProps = {
|
|
6
|
-
className?: string;
|
|
7
|
-
node: Node | undefined;
|
|
8
|
-
innerDeco: DecorationSource;
|
|
9
|
-
outerDeco: Decoration[];
|
|
3
|
+
import React, { HTMLProps, ReactElement } from "react";
|
|
4
|
+
export interface DocNodeViewProps extends Omit<HTMLProps<HTMLElement>, "as"> {
|
|
10
5
|
as?: ReactElement;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
as?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
19
|
-
viewDesc?: NodeViewDesc | undefined;
|
|
20
|
-
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement | null>>>;
|
|
6
|
+
node: Node;
|
|
7
|
+
getPos: () => number;
|
|
8
|
+
decorations: readonly Decoration[];
|
|
9
|
+
innerDecorations: DecorationSource;
|
|
10
|
+
setMount: (mount: HTMLElement | null) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const DocNodeView: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<DocNodeViewProps, "ref"> & React.RefAttributes<HTMLElement>>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Mark } from "prosemirror-model";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
3
|
type Props = {
|
|
4
4
|
mark: Mark;
|
|
5
|
-
getPos:
|
|
5
|
+
getPos: () => number;
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
};
|
|
8
8
|
export declare const MarkView: React.MemoExoticComponent<React.ForwardRefExoticComponent<Props & React.RefAttributes<unknown>>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Decoration } from "prosemirror-view";
|
|
2
|
-
import React
|
|
2
|
+
import React from "react";
|
|
3
3
|
type Props = {
|
|
4
4
|
widget: Decoration;
|
|
5
|
-
getPos:
|
|
5
|
+
getPos: () => number;
|
|
6
6
|
};
|
|
7
7
|
export declare function NativeWidgetView({ widget, getPos }: Props): React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
|
-
import React
|
|
4
|
-
type
|
|
5
|
-
outerDeco: readonly Decoration[];
|
|
6
|
-
getPos: MutableRefObject<() => number>;
|
|
3
|
+
import React from "react";
|
|
4
|
+
type Props = {
|
|
7
5
|
node: Node;
|
|
6
|
+
getPos: () => number;
|
|
7
|
+
outerDeco: readonly Decoration[];
|
|
8
8
|
innerDeco: DecorationSource;
|
|
9
9
|
};
|
|
10
|
-
export declare const NodeView: React.NamedExoticComponent<
|
|
10
|
+
export declare const NodeView: React.NamedExoticComponent<Props>;
|
|
11
11
|
export {};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
3
|
+
import { AllHTMLAttributes, LegacyRef } from "react";
|
|
4
|
+
export interface NodeViewComponentProps extends AllHTMLAttributes<HTMLElement> {
|
|
5
5
|
nodeProps: {
|
|
6
6
|
decorations: readonly Decoration[];
|
|
7
7
|
innerDecorations: DecorationSource;
|
|
8
8
|
node: Node;
|
|
9
|
-
children?: ReactNode | ReactNode[];
|
|
10
9
|
getPos: () => number;
|
|
11
10
|
};
|
|
12
11
|
ref: LegacyRef<any>;
|
|
13
|
-
}
|
|
12
|
+
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
|
+
import React, { HTMLProps, ReactElement } from "react";
|
|
4
|
+
interface DocNodeViewContextValue {
|
|
5
|
+
node: Node;
|
|
6
|
+
getPos: () => number;
|
|
7
|
+
decorations: readonly Decoration[];
|
|
8
|
+
innerDecorations: DecorationSource;
|
|
4
9
|
setMount: (mount: HTMLElement | null) => void;
|
|
5
|
-
}
|
|
10
|
+
}
|
|
6
11
|
export declare const DocNodeViewContext: React.Context<DocNodeViewContextValue>;
|
|
7
|
-
|
|
8
|
-
as?:
|
|
9
|
-
}
|
|
10
|
-
export
|
|
12
|
+
interface Props extends Omit<HTMLProps<HTMLElement>, "as"> {
|
|
13
|
+
as?: ReactElement;
|
|
14
|
+
}
|
|
15
|
+
export declare const ProseMirrorDoc: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
16
|
+
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { ComponentType } from "react";
|
|
4
|
+
import { NodeViewComponentProps } from "./NodeViewComponentProps.js";
|
|
4
5
|
type Props = {
|
|
6
|
+
component: ComponentType<NodeViewComponentProps>;
|
|
5
7
|
outerDeco: readonly Decoration[];
|
|
6
|
-
getPos:
|
|
8
|
+
getPos: () => number;
|
|
7
9
|
node: Node;
|
|
8
10
|
innerDeco: DecorationSource;
|
|
9
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
type Props = {
|
|
3
|
-
getPos:
|
|
3
|
+
getPos: () => number;
|
|
4
4
|
};
|
|
5
5
|
export declare function SeparatorHackView({ getPos }: Props): React.JSX.Element | null;
|
|
6
6
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
|
-
import { Decoration
|
|
2
|
+
import { Decoration } from "prosemirror-view";
|
|
3
3
|
import { Component, MutableRefObject } from "react";
|
|
4
|
+
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
4
5
|
import { ViewDesc } from "../viewdesc.js";
|
|
5
6
|
type Props = {
|
|
6
|
-
view:
|
|
7
|
+
view: AbstractEditorView;
|
|
7
8
|
node: Node;
|
|
8
|
-
getPos:
|
|
9
|
+
getPos: () => number;
|
|
9
10
|
siblingsRef: MutableRefObject<ViewDesc[]>;
|
|
10
11
|
parentRef: MutableRefObject<ViewDesc | undefined>;
|
|
11
12
|
decorations: readonly Decoration[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { ReactWidgetDecoration } from "../decorations/ReactWidgetType.js";
|
|
3
3
|
type Props = {
|
|
4
4
|
widget: ReactWidgetDecoration;
|
|
5
|
-
getPos:
|
|
5
|
+
getPos: () => number;
|
|
6
6
|
};
|
|
7
7
|
export declare function WidgetView({ widget, getPos }: Props): React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { DOMEventMap,
|
|
1
|
+
import type { DOMEventMap, Decoration } from "prosemirror-view";
|
|
2
2
|
import { MutableRefObject } from "react";
|
|
3
|
-
import
|
|
3
|
+
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
4
|
+
import type { EventHandler } from "../plugins/componentEventListeners.js";
|
|
4
5
|
export interface EditorContextValue {
|
|
5
|
-
view:
|
|
6
|
+
view: AbstractEditorView;
|
|
7
|
+
cursorWrapper: Decoration | null;
|
|
8
|
+
flushSyncRef: MutableRefObject<boolean>;
|
|
6
9
|
registerEventListener<EventType extends keyof DOMEventMap>(eventType: EventType, handler: EventHandler<EventType>): void;
|
|
7
10
|
unregisterEventListener<EventType extends keyof DOMEventMap>(eventType: EventType, handler: EventHandler<EventType>): void;
|
|
8
|
-
flushSyncRef: MutableRefObject<boolean>;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Provides the EditorView, as well as the current
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ViewMutationRecord } from "prosemirror-view";
|
|
2
|
-
type
|
|
2
|
+
export type IgnoreMutation = (mutation: ViewMutationRecord) => boolean;
|
|
3
|
+
type IgnoreMutationtContextValue = (ignoreMutation: IgnoreMutation) => void;
|
|
3
4
|
export declare const IgnoreMutationContext: import("react").Context<IgnoreMutationtContextValue>;
|
|
4
5
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
|
+
import { NodeViewSet } from "../AbstractEditorView.js";
|
|
2
3
|
import { NodeViewComponentProps } from "../components/NodeViewComponentProps.js";
|
|
3
4
|
export type NodeViewContextValue = {
|
|
4
|
-
|
|
5
|
+
components: Record<string, ComponentType<NodeViewComponentProps>>;
|
|
6
|
+
constructors: NodeViewSet;
|
|
5
7
|
};
|
|
6
8
|
export declare const NodeViewContext: import("react").Context<NodeViewContextValue>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
type
|
|
1
|
+
export type SelectNode = () => void;
|
|
2
|
+
export type DeselectNode = () => void;
|
|
3
|
+
type SelectNodeContextValue = (selectNode: SelectNode, deselectNode: DeselectNode) => void;
|
|
2
4
|
export declare const SelectNodeContext: import("react").Context<SelectNodeContextValue>;
|
|
3
5
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
type
|
|
1
|
+
export type StopEvent = (event: Event) => boolean;
|
|
2
|
+
type StopEventContextValue = (stopEvent: (event: Event) => boolean) => void;
|
|
2
3
|
export declare const StopEventContext: import("react").Context<StopEventContextValue>;
|
|
3
4
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Decoration
|
|
1
|
+
import { Decoration } from "prosemirror-view";
|
|
2
|
+
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
2
3
|
/**
|
|
3
4
|
* Produces the outer decorations for the doc node, based
|
|
4
5
|
* on the attributes editor prop.
|
|
@@ -10,4 +11,4 @@ import { Decoration, EditorView } from "prosemirror-view";
|
|
|
10
11
|
* This makes it safe to call in a React render function, even
|
|
11
12
|
* if its result is used in a dependencies array for a hook.
|
|
12
13
|
*/
|
|
13
|
-
export declare function computeDocDeco(view:
|
|
14
|
+
export declare function computeDocDeco(view: AbstractEditorView): [Decoration];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Decoration, DecorationSource
|
|
1
|
+
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
2
|
+
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
2
3
|
/**
|
|
3
4
|
* Produces the DecorationSource for the current state, based
|
|
4
5
|
* on the decorations editor prop.
|
|
@@ -10,4 +11,4 @@ import { Decoration, DecorationSource, EditorView } from "prosemirror-view";
|
|
|
10
11
|
* This makes it safe to call in a React render function, even
|
|
11
12
|
* if its result is used in a dependencies array for a hook.
|
|
12
13
|
*/
|
|
13
|
-
export declare function viewDecorations(view:
|
|
14
|
+
export declare function viewDecorations(view: AbstractEditorView, cursorWrapper: Decoration | null): DecorationSource;
|
|
@@ -1,46 +1,6 @@
|
|
|
1
1
|
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
2
|
-
import { Decoration,
|
|
3
|
-
import {
|
|
4
|
-
export declare class ReactEditorView extends EditorView {
|
|
5
|
-
private shouldUpdatePluginViews;
|
|
6
|
-
private oldProps;
|
|
7
|
-
private _props;
|
|
8
|
-
ready: boolean;
|
|
9
|
-
constructor(place: {
|
|
10
|
-
mount: HTMLElement;
|
|
11
|
-
} | null, props: DirectEditorProps & {
|
|
12
|
-
docView: NodeViewDesc;
|
|
13
|
-
ready: boolean;
|
|
14
|
-
});
|
|
15
|
-
/**
|
|
16
|
-
* Whether the EditorView's updateStateInner method thinks that the
|
|
17
|
-
* docView needs to be blown away and redrawn.
|
|
18
|
-
*
|
|
19
|
-
* @privateremarks
|
|
20
|
-
*
|
|
21
|
-
* When ProseMirror View detects that the EditorState has been reconfigured
|
|
22
|
-
* to provide new custom node views, it calls an internal function that
|
|
23
|
-
* we can't override in order to recreate the entire editor DOM.
|
|
24
|
-
*
|
|
25
|
-
* This property mimics that check, so that we can replace the EditorView
|
|
26
|
-
* with another of our own, preventing ProseMirror View from taking over
|
|
27
|
-
* DOM management responsibility.
|
|
28
|
-
*/
|
|
29
|
-
get needsRedraw(): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Like setProps, but without executing any side effects.
|
|
32
|
-
* Safe to use in a component render method.
|
|
33
|
-
*/
|
|
34
|
-
pureSetProps(props: Partial<DirectEditorProps>): void;
|
|
35
|
-
/**
|
|
36
|
-
* Triggers any side effects that have been queued by previous
|
|
37
|
-
* calls to pureSetProps.
|
|
38
|
-
*/
|
|
39
|
-
runPendingEffects(): void;
|
|
40
|
-
update(props: DirectEditorProps): void;
|
|
41
|
-
updatePluginViews(prevState?: EditorState): void;
|
|
42
|
-
destroy(): void;
|
|
43
|
-
}
|
|
2
|
+
import { Decoration, EditorProps, EditorView } from "prosemirror-view";
|
|
3
|
+
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
44
4
|
export interface UseEditorOptions extends EditorProps {
|
|
45
5
|
defaultState?: EditorState;
|
|
46
6
|
state?: EditorState;
|
|
@@ -58,12 +18,11 @@ export interface UseEditorOptions extends EditorProps {
|
|
|
58
18
|
*/
|
|
59
19
|
export declare function useEditor<T extends HTMLElement = HTMLElement>(mount: T | null, options: UseEditorOptions): {
|
|
60
20
|
editor: {
|
|
61
|
-
view:
|
|
62
|
-
registerEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("../plugins/componentEventListeners.js").EventHandler<keyof import("prosemirror-view").DOMEventMap>) => void;
|
|
63
|
-
unregisterEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("../plugins/componentEventListeners.js").EventHandler<keyof import("prosemirror-view").DOMEventMap>) => void;
|
|
21
|
+
view: AbstractEditorView;
|
|
64
22
|
cursorWrapper: Decoration | null;
|
|
65
|
-
docViewDescRef: import("react").MutableRefObject<NodeViewDesc>;
|
|
66
23
|
flushSyncRef: import("react").MutableRefObject<boolean>;
|
|
24
|
+
registerEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("../plugins/componentEventListeners.js").EventHandler<keyof import("prosemirror-view").DOMEventMap>) => void;
|
|
25
|
+
unregisterEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("../plugins/componentEventListeners.js").EventHandler<keyof import("prosemirror-view").DOMEventMap>) => void;
|
|
67
26
|
};
|
|
68
27
|
state: EditorState;
|
|
69
28
|
};
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { NodeViewConstructor } from "prosemirror-view";
|
|
2
|
+
import { NodeViewComponentProps } from "../components/NodeViewComponentProps.js";
|
|
3
|
+
import { DOMNode } from "../dom.js";
|
|
4
4
|
import { NodeViewDesc, ViewDesc } from "../viewdesc.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
type Props = NodeViewComponentProps["nodeProps"];
|
|
6
|
+
export declare function useNodeViewDescriptor(ref: {
|
|
7
|
+
readonly current: DOMNode | null;
|
|
8
|
+
}, constructor: NodeViewConstructor, props: Props): {
|
|
9
|
+
childContextValue: {
|
|
10
|
+
parentRef: import("react").MutableRefObject<NodeViewDesc | undefined>;
|
|
11
|
+
siblingsRef: import("react").MutableRefObject<ViewDesc[]>;
|
|
12
|
+
};
|
|
13
|
+
dom: Node | null;
|
|
14
|
+
contentDOM: HTMLElement | null;
|
|
15
|
+
nodeDOM: Node | null;
|
|
16
|
+
ref: {
|
|
17
|
+
readonly current: DOMNode | null;
|
|
18
|
+
};
|
|
12
19
|
};
|
|
20
|
+
export {};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { EditorView } from "prosemirror-view";
|
|
2
|
+
export declare function useSelectNode(selectNode: (view: EditorView) => void, deselectNode?: (view: EditorView) => void): void;
|
package/dist/types/props.d.ts
CHANGED
|
@@ -919,7 +919,7 @@ export declare function mergeReactProps(a: HTMLProps<HTMLElement>, b: HTMLProps<
|
|
|
919
919
|
spellCheck?: (boolean | "false" | "true") | undefined;
|
|
920
920
|
tabIndex?: number | undefined;
|
|
921
921
|
title?: string | undefined;
|
|
922
|
-
translate?: "
|
|
922
|
+
translate?: "yes" | "no" | undefined;
|
|
923
923
|
radioGroup?: string | undefined;
|
|
924
924
|
role?: import("react").AriaRole | undefined;
|
|
925
925
|
about?: string | undefined;
|
|
@@ -944,7 +944,7 @@ export declare function mergeReactProps(a: HTMLProps<HTMLElement>, b: HTMLProps<
|
|
|
944
944
|
results?: number | undefined;
|
|
945
945
|
security?: string | undefined;
|
|
946
946
|
unselectable?: "off" | "on" | undefined;
|
|
947
|
-
inputMode?: "
|
|
947
|
+
inputMode?: "text" | "none" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
|
948
948
|
is?: string | undefined;
|
|
949
949
|
exportparts?: string | undefined;
|
|
950
950
|
part?: string | undefined;
|
|
@@ -965,7 +965,7 @@ export declare function mergeReactProps(a: HTMLProps<HTMLElement>, b: HTMLProps<
|
|
|
965
965
|
"aria-description"?: string | undefined;
|
|
966
966
|
"aria-details"?: string | undefined;
|
|
967
967
|
"aria-disabled"?: (boolean | "false" | "true") | undefined;
|
|
968
|
-
"aria-dropeffect"?: "
|
|
968
|
+
"aria-dropeffect"?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
|
969
969
|
"aria-errormessage"?: string | undefined;
|
|
970
970
|
"aria-expanded"?: (boolean | "false" | "true") | undefined;
|
|
971
971
|
"aria-flowto"?: string | undefined;
|