@handlewithcare/react-prosemirror 2.4.11 → 2.5.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.
- 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 +59 -30
- package/dist/cjs/components/CustomNodeView.js +9 -25
- package/dist/cjs/components/DocNodeView.js +6 -15
- package/dist/cjs/components/MarkView.js +1 -2
- package/dist/cjs/components/NativeWidgetView.js +2 -3
- package/dist/cjs/components/NodeView.js +1 -1
- package/dist/cjs/components/ProseMirror.js +11 -14
- package/dist/cjs/components/ReactNodeView.js +3 -4
- 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 +32 -230
- package/dist/cjs/hooks/useEditorEffect.js +2 -2
- package/dist/cjs/hooks/useEditorEventCallback.js +8 -5
- package/dist/cjs/hooks/useNodeViewDescriptor.js +10 -10
- package/dist/cjs/hooks/useReactKeys.js +1 -1
- package/dist/cjs/testing/editorViewTestHelpers.js +0 -2
- package/dist/cjs/viewdesc.js +10 -9
- 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 +60 -32
- package/dist/esm/components/CustomNodeView.js +9 -25
- package/dist/esm/components/DocNodeView.js +6 -15
- package/dist/esm/components/MarkView.js +1 -2
- package/dist/esm/components/NativeWidgetView.js +2 -3
- package/dist/esm/components/NodeView.js +1 -1
- package/dist/esm/components/ProseMirror.js +11 -14
- package/dist/esm/components/ReactNodeView.js +3 -4
- 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 +28 -219
- package/dist/esm/hooks/useEditorEffect.js +2 -2
- package/dist/esm/hooks/useEditorEventCallback.js +8 -5
- package/dist/esm/hooks/useNodeViewDescriptor.js +10 -10
- package/dist/esm/hooks/useReactKeys.js +1 -1
- package/dist/esm/testing/editorViewTestHelpers.js +0 -2
- package/dist/esm/viewdesc.js +3 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AbstractEditorView.d.ts +27 -0
- package/dist/types/ReactEditorView.d.ts +79 -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 +2 -2
- package/dist/types/components/DocNodeView.d.ts +2 -5
- 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 +2 -2
- package/dist/types/components/ReactNodeView.d.ts +2 -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/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 +1 -1
- package/dist/types/hooks/useReactKeys.d.ts +1 -1
- package/dist/types/props.d.ts +26 -26
- package/dist/types/viewdesc.d.ts +6 -5
- package/package.json +6 -2
- package/dist/cjs/components/__tests__/ProseMirror.composition.test.js +0 -398
- package/dist/cjs/components/__tests__/ProseMirror.domchange.test.js +0 -270
- package/dist/cjs/components/__tests__/ProseMirror.draw-decoration.test.js +0 -1010
- package/dist/cjs/components/__tests__/ProseMirror.draw.test.js +0 -337
- package/dist/cjs/components/__tests__/ProseMirror.node-view.test.js +0 -315
- package/dist/cjs/components/__tests__/ProseMirror.selection.test.js +0 -444
- package/dist/cjs/components/__tests__/ProseMirror.test.js +0 -382
- package/dist/cjs/contexts/__tests__/DeferredLayoutEffects.test.js +0 -141
- package/dist/cjs/hooks/__tests__/useEditorViewLayoutEffect.test.js +0 -108
- package/dist/cjs/plugins/__tests__/reactKeys.test.js +0 -81
- 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/__tests__/ProseMirror.composition.test.js +0 -395
- package/dist/esm/components/__tests__/ProseMirror.domchange.test.js +0 -266
- package/dist/esm/components/__tests__/ProseMirror.draw-decoration.test.js +0 -967
- package/dist/esm/components/__tests__/ProseMirror.draw.test.js +0 -294
- package/dist/esm/components/__tests__/ProseMirror.node-view.test.js +0 -272
- package/dist/esm/components/__tests__/ProseMirror.selection.test.js +0 -440
- package/dist/esm/components/__tests__/ProseMirror.test.js +0 -339
- package/dist/esm/contexts/__tests__/DeferredLayoutEffects.test.js +0 -98
- package/dist/esm/hooks/__tests__/useEditorViewLayoutEffect.test.js +0 -99
- package/dist/esm/plugins/__tests__/reactKeys.test.js +0 -77
- 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/hooks/__tests__/useEditorViewLayoutEffect.test.d.ts +0 -1
- 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,79 @@
|
|
|
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
|
+
lastFocus: number;
|
|
17
|
+
lastClick: {
|
|
18
|
+
time: number;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
type: string;
|
|
22
|
+
button: number;
|
|
23
|
+
};
|
|
24
|
+
lastSelectionOrigin: string | null;
|
|
25
|
+
lastSelectionTime: number;
|
|
26
|
+
lastTouch: number;
|
|
27
|
+
mouseDown: {
|
|
28
|
+
allowDefault: boolean;
|
|
29
|
+
delayedSelectionSync: boolean;
|
|
30
|
+
};
|
|
31
|
+
hideSelectionGuard: (() => void) | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Extends EditorView to make prop and state updates pure, remove the DOM
|
|
35
|
+
* Mutation Observer, and use a custom document view managed by React.
|
|
36
|
+
*
|
|
37
|
+
* @privateRemarks
|
|
38
|
+
*
|
|
39
|
+
* The implementation relies on the base class using a private member to store
|
|
40
|
+
* the committed props and having a public getter that we override to return the
|
|
41
|
+
* latest, uncommitted props. The base class can then be told to update when the
|
|
42
|
+
* React effects are commit an update, applying the pending, uncommitted props.
|
|
43
|
+
*/
|
|
44
|
+
export declare class ReactEditorView extends EditorView implements AbstractEditorView {
|
|
45
|
+
cursorWrapper: {
|
|
46
|
+
dom: DOMNode;
|
|
47
|
+
deco: Decoration;
|
|
48
|
+
} | null;
|
|
49
|
+
nodeViews: NodeViewSet;
|
|
50
|
+
lastSelectedViewDesc: ViewDesc | undefined;
|
|
51
|
+
docView: NodeViewDesc;
|
|
52
|
+
input: InputState;
|
|
53
|
+
domObserver: DOMObserver;
|
|
54
|
+
domSelectionRange: () => DOMSelectionRange;
|
|
55
|
+
domSelection: () => DOMSelection | null;
|
|
56
|
+
private nextProps;
|
|
57
|
+
private prevState;
|
|
58
|
+
constructor(place: {
|
|
59
|
+
mount: HTMLElement;
|
|
60
|
+
}, props: DirectEditorProps);
|
|
61
|
+
get props(): DirectEditorProps;
|
|
62
|
+
setProps(props: Partial<DirectEditorProps>): void;
|
|
63
|
+
update(props: DirectEditorProps): void;
|
|
64
|
+
updateState(state: EditorState): void;
|
|
65
|
+
someProp<PropName extends keyof EditorProps>(propName: PropName): EditorProps[PropName] | undefined;
|
|
66
|
+
someProp<PropName extends keyof EditorProps, Result>(propName: PropName, f?: (value: NonNullable<EditorProps[PropName]>) => Result): Result | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Commit effects by appling the pending props and state.
|
|
69
|
+
*
|
|
70
|
+
* Ensures the DOM selection is correct and updates plugin views.
|
|
71
|
+
*
|
|
72
|
+
* @privateRemarks
|
|
73
|
+
*
|
|
74
|
+
* The correctness of this depends on the pure update function ensuring that
|
|
75
|
+
* the node view set is up to date so that it does not try to redraw.
|
|
76
|
+
*/
|
|
77
|
+
commitPendingEffects(): void;
|
|
78
|
+
}
|
|
79
|
+
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
|
customNodeView: NodeViewConstructor;
|
|
6
6
|
node: Node;
|
|
7
|
-
getPos:
|
|
7
|
+
getPos: () => number;
|
|
8
8
|
innerDeco: DecorationSource;
|
|
9
9
|
outerDeco: readonly Decoration[];
|
|
10
10
|
}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
3
|
import React, { DetailedHTMLProps, HTMLAttributes, ReactElement } from "react";
|
|
4
|
-
import { NodeViewDesc } from "../viewdesc.js";
|
|
5
4
|
export type DocNodeViewProps = {
|
|
6
5
|
className?: string;
|
|
7
|
-
node: Node
|
|
6
|
+
node: Node;
|
|
8
7
|
innerDeco: DecorationSource;
|
|
9
8
|
outerDeco: Decoration[];
|
|
10
9
|
as?: ReactElement;
|
|
11
|
-
viewDesc?: NodeViewDesc;
|
|
12
10
|
} & Omit<DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLDivElement>, "ref">;
|
|
13
11
|
export declare const DocNodeView: React.MemoExoticComponent<React.ForwardRefExoticComponent<{
|
|
14
12
|
className?: string | undefined;
|
|
15
|
-
node: Node
|
|
13
|
+
node: Node;
|
|
16
14
|
innerDeco: DecorationSource;
|
|
17
15
|
outerDeco: Decoration[];
|
|
18
16
|
as?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
19
|
-
viewDesc?: NodeViewDesc | undefined;
|
|
20
17
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement | null>>>;
|
|
@@ -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,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
|
type NodeViewProps = {
|
|
5
5
|
outerDeco: readonly Decoration[];
|
|
6
|
-
getPos:
|
|
6
|
+
getPos: () => number;
|
|
7
7
|
node: Node;
|
|
8
8
|
innerDeco: DecorationSource;
|
|
9
9
|
};
|
|
@@ -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
|
type Props = {
|
|
5
5
|
outerDeco: readonly Decoration[];
|
|
6
|
-
getPos:
|
|
6
|
+
getPos: () => number;
|
|
7
7
|
node: Node;
|
|
8
8
|
innerDeco: DecorationSource;
|
|
9
9
|
};
|
|
@@ -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
|
-
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
|
};
|
|
@@ -2,7 +2,7 @@ import { Node } from "prosemirror-model";
|
|
|
2
2
|
import { Decoration, DecorationSource, ViewMutationRecord } from "prosemirror-view";
|
|
3
3
|
import { MutableRefObject } from "react";
|
|
4
4
|
import { NodeViewDesc, ViewDesc } from "../viewdesc.js";
|
|
5
|
-
export declare function useNodeViewDescriptor(node: Node
|
|
5
|
+
export declare function useNodeViewDescriptor(node: Node, getPos: () => number, domRef: undefined | MutableRefObject<HTMLElement | null>, nodeDomRef: MutableRefObject<HTMLElement | null>, innerDecorations: DecorationSource, outerDecorations: readonly Decoration[], contentDOMRef?: MutableRefObject<HTMLElement | null>): {
|
|
6
6
|
hasContentDOM: boolean;
|
|
7
7
|
childDescriptors: MutableRefObject<ViewDesc[]>;
|
|
8
8
|
nodeViewDescRef: MutableRefObject<NodeViewDesc | undefined>;
|
package/dist/types/props.d.ts
CHANGED
|
@@ -904,19 +904,19 @@ export declare function mergeReactProps(a: HTMLProps<HTMLElement>, b: HTMLProps<
|
|
|
904
904
|
suppressContentEditableWarning?: boolean | undefined;
|
|
905
905
|
suppressHydrationWarning?: boolean | undefined;
|
|
906
906
|
accessKey?: string | undefined;
|
|
907
|
-
autoCapitalize?: "
|
|
907
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | (string & {}) | undefined;
|
|
908
908
|
autoFocus?: boolean | undefined;
|
|
909
|
-
contentEditable?: (boolean | "
|
|
909
|
+
contentEditable?: (boolean | "false" | "true") | "inherit" | "plaintext-only" | undefined;
|
|
910
910
|
contextMenu?: string | undefined;
|
|
911
911
|
dir?: string | undefined;
|
|
912
|
-
draggable?: (boolean | "
|
|
913
|
-
enterKeyHint?: "
|
|
912
|
+
draggable?: (boolean | "false" | "true") | undefined;
|
|
913
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
914
914
|
hidden?: boolean | undefined;
|
|
915
915
|
id?: string | undefined;
|
|
916
916
|
lang?: string | undefined;
|
|
917
917
|
nonce?: string | undefined;
|
|
918
918
|
slot?: string | undefined;
|
|
919
|
-
spellCheck?: (boolean | "
|
|
919
|
+
spellCheck?: (boolean | "false" | "true") | undefined;
|
|
920
920
|
tabIndex?: number | undefined;
|
|
921
921
|
title?: string | undefined;
|
|
922
922
|
translate?: "yes" | "no" | undefined;
|
|
@@ -944,57 +944,57 @@ 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;
|
|
951
951
|
"aria-activedescendant"?: string | undefined;
|
|
952
|
-
"aria-atomic"?: (boolean | "
|
|
953
|
-
"aria-autocomplete"?: "
|
|
952
|
+
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|
|
953
|
+
"aria-autocomplete"?: "none" | "list" | "inline" | "both" | undefined;
|
|
954
954
|
"aria-braillelabel"?: string | undefined;
|
|
955
955
|
"aria-brailleroledescription"?: string | undefined;
|
|
956
|
-
"aria-busy"?: (boolean | "
|
|
957
|
-
"aria-checked"?: boolean | "
|
|
956
|
+
"aria-busy"?: (boolean | "false" | "true") | undefined;
|
|
957
|
+
"aria-checked"?: boolean | "false" | "true" | "mixed" | undefined;
|
|
958
958
|
"aria-colcount"?: number | undefined;
|
|
959
959
|
"aria-colindex"?: number | undefined;
|
|
960
960
|
"aria-colindextext"?: string | undefined;
|
|
961
961
|
"aria-colspan"?: number | undefined;
|
|
962
962
|
"aria-controls"?: string | undefined;
|
|
963
|
-
"aria-current"?: boolean | "
|
|
963
|
+
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
|
|
964
964
|
"aria-describedby"?: string | undefined;
|
|
965
965
|
"aria-description"?: string | undefined;
|
|
966
966
|
"aria-details"?: string | undefined;
|
|
967
|
-
"aria-disabled"?: (boolean | "
|
|
968
|
-
"aria-dropeffect"?: "
|
|
967
|
+
"aria-disabled"?: (boolean | "false" | "true") | undefined;
|
|
968
|
+
"aria-dropeffect"?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
|
969
969
|
"aria-errormessage"?: string | undefined;
|
|
970
|
-
"aria-expanded"?: (boolean | "
|
|
970
|
+
"aria-expanded"?: (boolean | "false" | "true") | undefined;
|
|
971
971
|
"aria-flowto"?: string | undefined;
|
|
972
|
-
"aria-grabbed"?: (boolean | "
|
|
973
|
-
"aria-haspopup"?: boolean | "
|
|
974
|
-
"aria-hidden"?: (boolean | "
|
|
975
|
-
"aria-invalid"?: boolean | "
|
|
972
|
+
"aria-grabbed"?: (boolean | "false" | "true") | undefined;
|
|
973
|
+
"aria-haspopup"?: boolean | "false" | "true" | "dialog" | "grid" | "listbox" | "menu" | "tree" | undefined;
|
|
974
|
+
"aria-hidden"?: (boolean | "false" | "true") | undefined;
|
|
975
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
|
976
976
|
"aria-keyshortcuts"?: string | undefined;
|
|
977
977
|
"aria-label"?: string | undefined;
|
|
978
978
|
"aria-labelledby"?: string | undefined;
|
|
979
979
|
"aria-level"?: number | undefined;
|
|
980
980
|
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
|
981
|
-
"aria-modal"?: (boolean | "
|
|
982
|
-
"aria-multiline"?: (boolean | "
|
|
983
|
-
"aria-multiselectable"?: (boolean | "
|
|
981
|
+
"aria-modal"?: (boolean | "false" | "true") | undefined;
|
|
982
|
+
"aria-multiline"?: (boolean | "false" | "true") | undefined;
|
|
983
|
+
"aria-multiselectable"?: (boolean | "false" | "true") | undefined;
|
|
984
984
|
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
985
985
|
"aria-owns"?: string | undefined;
|
|
986
986
|
"aria-placeholder"?: string | undefined;
|
|
987
987
|
"aria-posinset"?: number | undefined;
|
|
988
|
-
"aria-pressed"?: boolean | "
|
|
989
|
-
"aria-readonly"?: (boolean | "
|
|
990
|
-
"aria-relevant"?: "text" | "
|
|
991
|
-
"aria-required"?: (boolean | "
|
|
988
|
+
"aria-pressed"?: boolean | "false" | "true" | "mixed" | undefined;
|
|
989
|
+
"aria-readonly"?: (boolean | "false" | "true") | undefined;
|
|
990
|
+
"aria-relevant"?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
|
991
|
+
"aria-required"?: (boolean | "false" | "true") | undefined;
|
|
992
992
|
"aria-roledescription"?: string | undefined;
|
|
993
993
|
"aria-rowcount"?: number | undefined;
|
|
994
994
|
"aria-rowindex"?: number | undefined;
|
|
995
995
|
"aria-rowindextext"?: string | undefined;
|
|
996
996
|
"aria-rowspan"?: number | undefined;
|
|
997
|
-
"aria-selected"?: (boolean | "
|
|
997
|
+
"aria-selected"?: (boolean | "false" | "true") | undefined;
|
|
998
998
|
"aria-setsize"?: number | undefined;
|
|
999
999
|
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
1000
1000
|
"aria-valuemax"?: number | undefined;
|
package/dist/types/viewdesc.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Mark, Node, TagParseRule } from "prosemirror-model";
|
|
2
|
-
import { Decoration, DecorationSource
|
|
2
|
+
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
|
+
import { ReactEditorView } from "./ReactEditorView.js";
|
|
3
4
|
import { DOMNode } from "./dom.js";
|
|
4
5
|
declare global {
|
|
5
6
|
interface Node {
|
|
@@ -54,7 +55,7 @@ export declare class ViewDesc {
|
|
|
54
55
|
};
|
|
55
56
|
emptyChildAt(side: number): boolean;
|
|
56
57
|
domAfterPos(pos: number): DOMNode;
|
|
57
|
-
setSelection(anchor: number, head: number, view:
|
|
58
|
+
setSelection(anchor: number, head: number, view: ReactEditorView, force?: boolean): void;
|
|
58
59
|
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
59
60
|
get contentLost(): boolean | null;
|
|
60
61
|
markDirty(from: number, to: number): void;
|
|
@@ -120,8 +121,8 @@ export declare class NodeViewDesc extends ViewDesc {
|
|
|
120
121
|
parseRule(): Omit<TagParseRule, "tag"> | null;
|
|
121
122
|
matchesNode(node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource): boolean;
|
|
122
123
|
get size(): number;
|
|
123
|
-
get border():
|
|
124
|
-
update(_node: Node, _outerDeco: readonly Decoration[], _innerDeco: DecorationSource, _view:
|
|
124
|
+
get border(): 0 | 1;
|
|
125
|
+
update(_node: Node, _outerDeco: readonly Decoration[], _innerDeco: DecorationSource, _view: ReactEditorView): boolean;
|
|
125
126
|
get domAtom(): boolean;
|
|
126
127
|
}
|
|
127
128
|
export declare class TextViewDesc extends NodeViewDesc {
|
|
@@ -129,7 +130,7 @@ export declare class TextViewDesc extends NodeViewDesc {
|
|
|
129
130
|
parseRule(): {
|
|
130
131
|
skip: any;
|
|
131
132
|
};
|
|
132
|
-
update(_node: Node, _outerDeco: readonly Decoration[], _innerDeco: DecorationSource, _view:
|
|
133
|
+
update(_node: Node, _outerDeco: readonly Decoration[], _innerDeco: DecorationSource, _view: ReactEditorView): boolean;
|
|
133
134
|
inParent(): boolean;
|
|
134
135
|
domFromPos(pos: number): {
|
|
135
136
|
node: globalThis.Node;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handlewithcare/react-prosemirror",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -119,7 +119,8 @@
|
|
|
119
119
|
"prosemirror-state": "^1.0.0",
|
|
120
120
|
"prosemirror-view": "1.39.2",
|
|
121
121
|
"react": ">=17 <=19.1.0",
|
|
122
|
-
"react-dom": ">=17 <=19.1.0"
|
|
122
|
+
"react-dom": ">=17 <=19.1.0",
|
|
123
|
+
"react-reconciler": ">=0.26.1 <=0.32.0"
|
|
123
124
|
},
|
|
124
125
|
"packageManager": "yarn@4.6.0",
|
|
125
126
|
"engines": {
|
|
@@ -127,5 +128,8 @@
|
|
|
127
128
|
},
|
|
128
129
|
"dependencies": {
|
|
129
130
|
"classnames": "^2.3.2"
|
|
131
|
+
},
|
|
132
|
+
"publishConfig": {
|
|
133
|
+
"access": "public"
|
|
130
134
|
}
|
|
131
135
|
}
|