@handlewithcare/react-prosemirror 3.1.0-tiptap.53 → 3.1.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/README.md +3 -0
- package/dist/cjs/ReactEditorView.js +18 -7
- package/dist/cjs/components/ChildNodeViews.js +10 -16
- package/dist/cjs/components/CursorWrapper.js +6 -4
- package/dist/cjs/components/ProseMirror.js +12 -4
- package/dist/cjs/components/TextNodeView.js +7 -216
- package/dist/cjs/components/TrailingHackView.js +0 -70
- package/dist/cjs/components/nodes/NodeView.js +40 -4
- package/dist/cjs/contexts/ChildDescriptionsContext.js +1 -3
- package/dist/cjs/contexts/CompositionContext.js +14 -0
- package/dist/cjs/hooks/useMarkViewDescription.js +2 -63
- package/dist/cjs/hooks/useNodeViewDescription.js +2 -66
- package/dist/cjs/plugins/beforeInputPlugin.js +130 -120
- package/dist/cjs/plugins/reactKeys.js +16 -4
- package/dist/cjs/tiptap/tiptapNodeView.js +10 -9
- package/dist/cjs/viewdesc.js +4 -1
- package/dist/esm/ReactEditorView.js +18 -7
- package/dist/esm/components/ChildNodeViews.js +12 -18
- package/dist/esm/components/CursorWrapper.js +6 -4
- package/dist/esm/components/ProseMirror.js +12 -4
- package/dist/esm/components/TextNodeView.js +5 -165
- package/dist/esm/components/TrailingHackView.js +1 -71
- package/dist/esm/components/nodes/NodeView.js +38 -5
- package/dist/esm/contexts/ChildDescriptionsContext.js +1 -3
- package/dist/esm/contexts/CompositionContext.js +4 -0
- package/dist/esm/hooks/useIsEditorStatic.js +4 -1
- package/dist/esm/hooks/useMarkViewDescription.js +3 -64
- package/dist/esm/hooks/useNodeViewDescription.js +3 -67
- package/dist/esm/plugins/beforeInputPlugin.js +131 -121
- package/dist/esm/plugins/reactKeys.js +16 -4
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +1 -1
- package/dist/esm/tiptap/TiptapEditorContent.js +8 -1
- package/dist/esm/tiptap/hooks/useIsInReactProseMirror.js +5 -1
- package/dist/esm/tiptap/tiptapNodeView.js +13 -14
- package/dist/esm/viewdesc.js +4 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ReactEditorView.d.ts +8 -4
- package/dist/types/components/ChildNodeViews.d.ts +2 -2
- package/dist/types/components/CursorWrapper.d.ts +1 -1
- package/dist/types/components/TextNodeView.d.ts +6 -18
- package/dist/types/components/TrailingHackView.d.ts +1 -1
- package/dist/types/components/marks/DefaultMarkView.d.ts +1 -1
- package/dist/types/components/marks/MarkView.d.ts +1 -1
- package/dist/types/components/marks/MarkViewConstructorView.d.ts +1 -1
- package/dist/types/components/marks/ReactMarkView.d.ts +1 -1
- package/dist/types/components/nodes/DefaultNodeView.d.ts +1 -1
- package/dist/types/components/nodes/NodeView.d.ts +3 -1
- package/dist/types/components/nodes/NodeViewConstructorView.d.ts +1 -1
- package/dist/types/components/nodes/ReactNodeView.d.ts +1 -1
- package/dist/types/contexts/ChildDescriptionsContext.d.ts +1 -2
- package/dist/types/contexts/CompositionContext.d.ts +4 -0
- package/dist/types/hooks/useEditor.d.ts +2 -2
- package/dist/types/hooks/useIsEditorStatic.d.ts +4 -0
- package/dist/types/hooks/useMarkViewDescription.d.ts +1 -2
- package/dist/types/hooks/useNodeViewDescription.d.ts +1 -2
- package/dist/types/hooks/useReactKeys.d.ts +2 -5
- package/dist/types/plugins/reactKeys.d.ts +5 -5
- package/dist/types/props.d.ts +225 -225
- package/dist/types/tiptap/ReactProseMirrorNodeView.d.ts +1 -1
- package/dist/types/tiptap/TiptapEditorContent.d.ts +10 -1
- package/dist/types/tiptap/hooks/useIsInReactProseMirror.d.ts +5 -0
- package/dist/types/tiptap/tiptapNodeView.d.ts +5 -6
- package/dist/types/viewdesc.d.ts +2 -1
- package/package.json +20 -6
- package/dist/cjs/plugins/componentEventListeners.js +0 -28
- package/dist/cjs/plugins/componentEventListenersPlugin.js +0 -35
- package/dist/cjs/tiptap/utils/ssrJSDOMPatch.js +0 -59
- package/dist/esm/plugins/componentEventListeners.js +0 -18
- package/dist/esm/plugins/componentEventListenersPlugin.js +0 -25
- package/dist/esm/tiptap/utils/ssrJSDOMPatch.js +0 -56
- package/dist/types/plugins/componentEventListeners.d.ts +0 -3
- package/dist/types/plugins/componentEventListenersPlugin.d.ts +0 -4
- package/dist/types/tiptap/utils/ssrJSDOMPatch.d.ts +0 -1
|
@@ -2,13 +2,18 @@ import { EditorState } from "prosemirror-state";
|
|
|
2
2
|
import { Decoration, DirectEditorProps, EditorProps, EditorView } from "prosemirror-view";
|
|
3
3
|
import { AbstractEditorView, NodeViewSet } from "./AbstractEditorView.js";
|
|
4
4
|
import { DOMNode, DOMSelection, DOMSelectionRange } from "./dom.js";
|
|
5
|
-
import { NodeViewDesc,
|
|
5
|
+
import { NodeViewDesc, ViewDesc } from "./viewdesc.js";
|
|
6
6
|
interface DOMObserver {
|
|
7
7
|
observer: MutationObserver | null;
|
|
8
8
|
queue: MutationRecord[];
|
|
9
9
|
start(): void;
|
|
10
10
|
stop(): void;
|
|
11
11
|
onSelectionChange(): void;
|
|
12
|
+
setCurSelection(): void;
|
|
13
|
+
disconnectSelection(): void;
|
|
14
|
+
connectSelection(): void;
|
|
15
|
+
flush(): void;
|
|
16
|
+
lastChangedTextNode: Text | null;
|
|
12
17
|
}
|
|
13
18
|
interface InputState {
|
|
14
19
|
composing: boolean;
|
|
@@ -33,7 +38,7 @@ interface InputState {
|
|
|
33
38
|
mouseDown: {
|
|
34
39
|
allowDefault: boolean;
|
|
35
40
|
delayedSelectionSync: boolean;
|
|
36
|
-
};
|
|
41
|
+
} | null;
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
39
44
|
* Extends EditorView to make prop and state updates pure, remove the DOM
|
|
@@ -61,8 +66,7 @@ export declare class ReactEditorView extends EditorView implements AbstractEdito
|
|
|
61
66
|
private nextProps;
|
|
62
67
|
private prevState;
|
|
63
68
|
private _destroyed;
|
|
64
|
-
|
|
65
|
-
displacedNodes: TextViewDesc[];
|
|
69
|
+
cursorWrapped: boolean;
|
|
66
70
|
constructor(place: {
|
|
67
71
|
mount: HTMLElement;
|
|
68
72
|
}, props: DirectEditorProps);
|
|
@@ -2,8 +2,8 @@ import { Node } from "prosemirror-model";
|
|
|
2
2
|
import { Decoration, DecorationSource } from "prosemirror-view";
|
|
3
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
|
-
export declare const ChildNodeViews: React.
|
|
5
|
+
export declare const ChildNodeViews: React.MemoExoticComponent<({ getPos, node, innerDecorations, }: {
|
|
6
6
|
getPos: () => number;
|
|
7
7
|
node: Node | undefined;
|
|
8
8
|
innerDecorations: DecorationSource;
|
|
9
|
-
}>;
|
|
9
|
+
}) => React.JSX.Element | null>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { WidgetViewComponentProps } from "./WidgetViewComponentProps.js";
|
|
3
|
-
export declare const CursorWrapper: React.ForwardRefExoticComponent<Omit<WidgetViewComponentProps
|
|
3
|
+
export declare const CursorWrapper: React.ForwardRefExoticComponent<Omit<WidgetViewComponentProps, "ref"> & React.RefAttributes<HTMLImageElement>>;
|
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { Decoration } from "prosemirror-view";
|
|
3
|
+
import { Component, MutableRefObject } from "react";
|
|
4
4
|
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
5
|
-
import {
|
|
6
|
-
import { CompositionViewDesc, TextViewDesc, ViewDesc } from "../viewdesc.js";
|
|
5
|
+
import { TextViewDesc, ViewDesc } from "../viewdesc.js";
|
|
7
6
|
type Props = {
|
|
8
7
|
view: AbstractEditorView;
|
|
9
8
|
node: Node;
|
|
10
9
|
getPos: () => number;
|
|
11
10
|
siblingsRef: MutableRefObject<ViewDesc[]>;
|
|
12
11
|
parentRef: MutableRefObject<ViewDesc | undefined>;
|
|
13
|
-
findCompositionDOM: (compositionViewDesc: CompositionViewDesc) => void;
|
|
14
|
-
forceRemount: () => void;
|
|
15
12
|
decorations: readonly Decoration[];
|
|
16
|
-
registerEventListener<EventType extends keyof DOMEventMap>(eventType: EventType, handler: EventHandler<EventType>): void;
|
|
17
|
-
unregisterEventListener<EventType extends keyof DOMEventMap>(eventType: EventType, handler: EventHandler<EventType>): void;
|
|
18
13
|
};
|
|
19
14
|
export declare class TextNodeView extends Component<Props> {
|
|
20
|
-
viewDescRef:
|
|
21
|
-
|
|
22
|
-
wasProtecting: React.MutableRefObject<boolean | null>;
|
|
23
|
-
containsCompositionNodeText: React.MutableRefObject<boolean | null>;
|
|
24
|
-
shouldProtect(props: Props): boolean;
|
|
25
|
-
handleCompositionEnd: () => void;
|
|
26
|
-
create(): CompositionViewDesc | TextViewDesc | null;
|
|
15
|
+
viewDescRef: MutableRefObject<TextViewDesc | null>;
|
|
16
|
+
create(): TextViewDesc | null;
|
|
27
17
|
update(): boolean;
|
|
28
18
|
destroy(): void;
|
|
29
19
|
updateEffect(): void;
|
|
@@ -31,9 +21,7 @@ export declare class TextNodeView extends Component<Props> {
|
|
|
31
21
|
constructor(props: Props);
|
|
32
22
|
componentDidMount(): void;
|
|
33
23
|
componentDidUpdate(): void;
|
|
34
|
-
private reattachAtCorrectPosition;
|
|
35
24
|
componentWillUnmount(): void;
|
|
36
|
-
render(): JSX.Element
|
|
25
|
+
render(): JSX.Element;
|
|
37
26
|
}
|
|
38
|
-
export declare function RemountableTextNodeView(props: Omit<Props, "forceRemount">): React.JSX.Element;
|
|
39
27
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarkViewComponentProps } from "./MarkViewComponentProps.js";
|
|
3
|
-
export declare const DefaultMarkView: React.ForwardRefExoticComponent<Omit<MarkViewComponentProps
|
|
3
|
+
export declare const DefaultMarkView: React.ForwardRefExoticComponent<Omit<MarkViewComponentProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -8,5 +8,5 @@ interface Props {
|
|
|
8
8
|
getPos: () => number;
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
}
|
|
11
|
-
export declare const MarkViewConstructorView: React.
|
|
11
|
+
export declare const MarkViewConstructorView: React.MemoExoticComponent<({ constructor, mark, inline, getPos, children, }: Props) => React.JSX.Element>;
|
|
12
12
|
export {};
|
|
@@ -8,5 +8,5 @@ interface Props {
|
|
|
8
8
|
inline: boolean;
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
}
|
|
11
|
-
export declare const ReactMarkView: React.
|
|
11
|
+
export declare const ReactMarkView: React.MemoExoticComponent<({ component: Component, mark, inline, getPos, children, }: Props) => React.JSX.Element>;
|
|
12
12
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { NodeViewComponentProps } from "../nodes/NodeViewComponentProps.js";
|
|
3
|
-
export declare const DefaultNodeView: React.ForwardRefExoticComponent<Omit<NodeViewComponentProps
|
|
3
|
+
export declare const DefaultNodeView: React.ForwardRefExoticComponent<Omit<NodeViewComponentProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -6,7 +6,9 @@ type Props = {
|
|
|
6
6
|
getPos: () => number;
|
|
7
7
|
outerDeco: readonly Decoration[];
|
|
8
8
|
innerDeco: DecorationSource;
|
|
9
|
+
forceRemount: () => void;
|
|
9
10
|
};
|
|
10
|
-
export declare const NodeView: React.
|
|
11
|
+
export declare const NodeView: React.MemoExoticComponent<({ forceRemount, ...props }: Props) => JSX.Element | null>;
|
|
11
12
|
export declare const GetPosContext: React.Context<() => number>;
|
|
13
|
+
export declare function RemountableNodeView(props: Omit<Props, "forceRemount">): React.JSX.Element;
|
|
12
14
|
export {};
|
|
@@ -8,5 +8,5 @@ interface Props {
|
|
|
8
8
|
innerDeco: DecorationSource;
|
|
9
9
|
outerDeco: readonly Decoration[];
|
|
10
10
|
}
|
|
11
|
-
export declare const NodeViewConstructorView: React.
|
|
11
|
+
export declare const NodeViewConstructorView: React.MemoExoticComponent<({ constructor, node, getPos, innerDeco, outerDeco, }: Props) => React.FunctionComponentElement<any>>;
|
|
12
12
|
export {};
|
|
@@ -9,5 +9,5 @@ type Props = {
|
|
|
9
9
|
node: Node;
|
|
10
10
|
innerDeco: DecorationSource;
|
|
11
11
|
};
|
|
12
|
-
export declare const ReactNodeView: React.
|
|
12
|
+
export declare const ReactNodeView: React.MemoExoticComponent<({ component: Component, outerDeco, getPos, node, innerDeco, }: Props) => React.JSX.Element>;
|
|
13
13
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { MutableRefObject } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { ViewDesc } from "../viewdesc.js";
|
|
3
3
|
export type ChildDescriptionsContextValue = {
|
|
4
4
|
parentRef: MutableRefObject<ViewDesc | undefined>;
|
|
5
5
|
siblingsRef: MutableRefObject<ViewDesc[]>;
|
|
6
|
-
findCompositionDOM: (compositionViewDesc: CompositionViewDesc) => void;
|
|
7
6
|
};
|
|
8
7
|
export declare const ChildDescriptionsContext: import("react").Context<ChildDescriptionsContextValue>;
|
|
@@ -21,8 +21,8 @@ export declare function useEditor<T extends HTMLElement = HTMLElement>(mount: T
|
|
|
21
21
|
editor: {
|
|
22
22
|
view: AbstractEditorView;
|
|
23
23
|
flushSyncRef: import("react").MutableRefObject<boolean>;
|
|
24
|
-
registerEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("./useComponentEventListeners.js").EventHandler
|
|
25
|
-
unregisterEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("./useComponentEventListeners.js").EventHandler
|
|
24
|
+
registerEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("./useComponentEventListeners.js").EventHandler) => void;
|
|
25
|
+
unregisterEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("./useComponentEventListeners.js").EventHandler) => void;
|
|
26
26
|
isStatic: boolean;
|
|
27
27
|
};
|
|
28
28
|
state: EditorState;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MarkViewConstructor } from "prosemirror-view";
|
|
2
2
|
import { MarkViewComponentProps } from "../components/marks/MarkViewComponentProps.js";
|
|
3
3
|
import { DOMNode } from "../dom.js";
|
|
4
|
-
import {
|
|
4
|
+
import { MarkViewDesc, ViewDesc } from "../viewdesc.js";
|
|
5
5
|
type Props = Omit<MarkViewComponentProps["markProps"], "contentDOMRef">;
|
|
6
6
|
export declare function useMarkViewDescription(getDOM: () => DOMNode | null, getContentDOM: (markView: {
|
|
7
7
|
contentDOM?: HTMLElement | null;
|
|
@@ -9,7 +9,6 @@ export declare function useMarkViewDescription(getDOM: () => DOMNode | null, get
|
|
|
9
9
|
childContextValue: {
|
|
10
10
|
parentRef: import("react").MutableRefObject<MarkViewDesc | undefined>;
|
|
11
11
|
siblingsRef: import("react").MutableRefObject<ViewDesc[]>;
|
|
12
|
-
findCompositionDOM: (compositionViewDesc: CompositionViewDesc) => void;
|
|
13
12
|
};
|
|
14
13
|
contentDOM: HTMLElement | undefined;
|
|
15
14
|
refUpdated: () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NodeViewConstructor } from "prosemirror-view";
|
|
2
2
|
import { NodeViewComponentProps } from "../components/nodes/NodeViewComponentProps.js";
|
|
3
3
|
import { DOMNode } from "../dom.js";
|
|
4
|
-
import {
|
|
4
|
+
import { NodeViewDesc, ViewDesc } from "../viewdesc.js";
|
|
5
5
|
type Props = Omit<NodeViewComponentProps["nodeProps"], "contentDOMRef">;
|
|
6
6
|
export declare function useNodeViewDescription(getDOM: () => DOMNode | null, getContentDOM: (nodeView: {
|
|
7
7
|
contentDOM?: HTMLElement | null;
|
|
@@ -9,7 +9,6 @@ export declare function useNodeViewDescription(getDOM: () => DOMNode | null, get
|
|
|
9
9
|
childContextValue: {
|
|
10
10
|
parentRef: import("react").MutableRefObject<NodeViewDesc | undefined>;
|
|
11
11
|
siblingsRef: import("react").MutableRefObject<ViewDesc[]>;
|
|
12
|
-
findCompositionDOM: (compositionViewDesc: CompositionViewDesc) => void;
|
|
13
12
|
};
|
|
14
13
|
contentDOM: HTMLElement | null;
|
|
15
14
|
refUpdated: () => void;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
keyToPos: Map<string, number>;
|
|
4
|
-
posToNode: Map<number, import("prosemirror-model").Node>;
|
|
5
|
-
} | undefined;
|
|
1
|
+
import { ReactKeysPluginState } from "../plugins/reactKeys.js";
|
|
2
|
+
export declare function useReactKeys(): ReactKeysPluginState | undefined;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
2
|
import { Decoration } from "prosemirror-view";
|
|
3
3
|
export declare function createNodeKey(): string;
|
|
4
|
-
interface ReactKeysPluginState {
|
|
4
|
+
export interface ReactKeysPluginState {
|
|
5
5
|
posToKey: Map<number, string>;
|
|
6
6
|
keyToPos: Map<string, number>;
|
|
7
7
|
cursorWrapper: Decoration | null;
|
|
8
|
+
freezeFrom: number | null;
|
|
8
9
|
}
|
|
9
10
|
export declare const reactKeysPluginKey: PluginKey<ReactKeysPluginState>;
|
|
10
11
|
export type ReactKeysPluginMeta = {
|
|
11
|
-
overrides
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
overrides?: Record<number, number>;
|
|
13
|
+
cursorWrapper?: Decoration | null;
|
|
14
|
+
freezeFrom?: number | null;
|
|
14
15
|
} | undefined;
|
|
15
16
|
/**
|
|
16
17
|
* Tracks a unique key for each (non-text) node in the
|
|
@@ -20,4 +21,3 @@ export type ReactKeysPluginMeta = {
|
|
|
20
21
|
* current position in the document, and vice versa.
|
|
21
22
|
*/
|
|
22
23
|
export declare function reactKeys(): Plugin<ReactKeysPluginState>;
|
|
23
|
-
export {};
|