@handlewithcare/react-prosemirror 3.1.0-tiptap.52 → 3.1.0-tiptap.53
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/ReactEditorView.js +6 -0
- package/dist/cjs/components/ChildNodeViews.js +16 -10
- package/dist/cjs/components/CursorWrapper.js +3 -7
- package/dist/cjs/components/ProseMirror.js +5 -3
- package/dist/cjs/components/TextNodeView.js +260 -47
- package/dist/cjs/components/TrailingHackView.js +70 -0
- package/dist/cjs/components/WidgetView.js +3 -1
- package/dist/cjs/contexts/ChildDescriptionsContext.js +3 -1
- package/dist/cjs/decorations/viewDecorations.js +1 -6
- package/dist/cjs/hooks/useEditor.js +2 -10
- package/dist/cjs/hooks/useMarkViewDescription.js +61 -3
- package/dist/cjs/hooks/useNodeViewDescription.js +64 -21
- package/dist/cjs/plugins/beforeInputPlugin.js +147 -45
- package/dist/cjs/plugins/reactKeys.js +21 -14
- package/dist/cjs/viewdesc.js +52 -4
- package/dist/esm/ReactEditorView.js +6 -0
- package/dist/esm/components/ChildNodeViews.js +17 -11
- package/dist/esm/components/CursorWrapper.js +3 -7
- package/dist/esm/components/ProseMirror.js +5 -3
- package/dist/esm/components/TextNodeView.js +209 -45
- package/dist/esm/components/TrailingHackView.js +71 -1
- package/dist/esm/components/WidgetView.js +3 -1
- package/dist/esm/contexts/ChildDescriptionsContext.js +3 -1
- package/dist/esm/decorations/viewDecorations.js +1 -6
- package/dist/esm/hooks/useEditor.js +2 -10
- package/dist/esm/hooks/useMarkViewDescription.js +62 -4
- package/dist/esm/hooks/useNodeViewDescription.js +65 -22
- package/dist/esm/plugins/beforeInputPlugin.js +147 -45
- package/dist/esm/plugins/reactKeys.js +21 -14
- package/dist/esm/viewdesc.js +51 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ReactEditorView.d.ts +6 -1
- package/dist/types/components/TextNodeView.d.ts +20 -5
- package/dist/types/components/TrailingHackView.d.ts +1 -1
- package/dist/types/components/__tests__/ProseMirror.composition.test.d.ts +17 -1
- package/dist/types/contexts/ChildDescriptionsContext.d.ts +5 -3
- package/dist/types/decorations/viewDecorations.d.ts +2 -2
- package/dist/types/hooks/useEditor.d.ts +1 -2
- package/dist/types/hooks/useMarkViewDescription.d.ts +2 -1
- package/dist/types/hooks/useNodeViewDescription.d.ts +2 -1
- package/dist/types/plugins/beforeInputPlugin.d.ts +1 -2
- package/dist/types/plugins/reactKeys.d.ts +9 -8
- package/dist/types/viewdesc.d.ts +3 -2
- package/package.json +3 -1
|
@@ -2,7 +2,7 @@ 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, ViewDesc } from "./viewdesc.js";
|
|
5
|
+
import { NodeViewDesc, TextViewDesc, ViewDesc } from "./viewdesc.js";
|
|
6
6
|
interface DOMObserver {
|
|
7
7
|
observer: MutationObserver | null;
|
|
8
8
|
queue: MutationRecord[];
|
|
@@ -11,7 +11,10 @@ interface DOMObserver {
|
|
|
11
11
|
onSelectionChange(): void;
|
|
12
12
|
}
|
|
13
13
|
interface InputState {
|
|
14
|
+
composing: boolean;
|
|
14
15
|
compositionID: number;
|
|
16
|
+
compositionNode: Text | null;
|
|
17
|
+
compositionEndedAt: number;
|
|
15
18
|
compositionNodes: ViewDesc[];
|
|
16
19
|
compositionPendingChanges: number;
|
|
17
20
|
hideSelectionGuard: (() => void) | null;
|
|
@@ -58,6 +61,8 @@ export declare class ReactEditorView extends EditorView implements AbstractEdito
|
|
|
58
61
|
private nextProps;
|
|
59
62
|
private prevState;
|
|
60
63
|
private _destroyed;
|
|
64
|
+
compositionStarting: boolean;
|
|
65
|
+
displacedNodes: TextViewDesc[];
|
|
61
66
|
constructor(place: {
|
|
62
67
|
mount: HTMLElement;
|
|
63
68
|
}, props: DirectEditorProps);
|
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
|
-
import { Decoration } from "prosemirror-view";
|
|
3
|
-
import { Component, MutableRefObject } from "react";
|
|
2
|
+
import { DOMEventMap, Decoration } from "prosemirror-view";
|
|
3
|
+
import React, { Component, MutableRefObject } from "react";
|
|
4
4
|
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
5
|
-
import {
|
|
5
|
+
import { EventHandler } from "../hooks/useComponentEventListeners.js";
|
|
6
|
+
import { CompositionViewDesc, TextViewDesc, ViewDesc } from "../viewdesc.js";
|
|
6
7
|
type Props = {
|
|
7
8
|
view: AbstractEditorView;
|
|
8
9
|
node: Node;
|
|
9
10
|
getPos: () => number;
|
|
10
11
|
siblingsRef: MutableRefObject<ViewDesc[]>;
|
|
11
12
|
parentRef: MutableRefObject<ViewDesc | undefined>;
|
|
13
|
+
findCompositionDOM: (compositionViewDesc: CompositionViewDesc) => void;
|
|
14
|
+
forceRemount: () => void;
|
|
12
15
|
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;
|
|
13
18
|
};
|
|
14
19
|
export declare class TextNodeView extends Component<Props> {
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
viewDescRef: React.MutableRefObject<CompositionViewDesc | TextViewDesc | null>;
|
|
21
|
+
renderRef: React.MutableRefObject<JSX.Element | null>;
|
|
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;
|
|
27
|
+
update(): boolean;
|
|
28
|
+
destroy(): void;
|
|
17
29
|
updateEffect(): void;
|
|
18
30
|
shouldComponentUpdate(nextProps: Props): boolean;
|
|
31
|
+
constructor(props: Props);
|
|
19
32
|
componentDidMount(): void;
|
|
20
33
|
componentDidUpdate(): void;
|
|
34
|
+
private reattachAtCorrectPosition;
|
|
21
35
|
componentWillUnmount(): void;
|
|
22
36
|
render(): JSX.Element | null;
|
|
23
37
|
}
|
|
38
|
+
export declare function RemountableTextNodeView(props: Omit<Props, "forceRemount">): React.JSX.Element;
|
|
24
39
|
export {};
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import "@wdio/types";
|
|
2
|
+
declare global {
|
|
3
|
+
namespace WebdriverIO {
|
|
4
|
+
interface Browser {
|
|
5
|
+
imeSetComposition(params: {
|
|
6
|
+
text: string;
|
|
7
|
+
selectionStart?: number;
|
|
8
|
+
selectionEnd?: number;
|
|
9
|
+
replacementStart?: number;
|
|
10
|
+
replacementEnd?: number;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
imeInsertText(params: {
|
|
13
|
+
text: string;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MutableRefObject } from "react";
|
|
2
|
-
import { ViewDesc } from "../viewdesc.js";
|
|
3
|
-
export
|
|
2
|
+
import { CompositionViewDesc, ViewDesc } from "../viewdesc.js";
|
|
3
|
+
export type ChildDescriptionsContextValue = {
|
|
4
4
|
parentRef: MutableRefObject<ViewDesc | undefined>;
|
|
5
5
|
siblingsRef: MutableRefObject<ViewDesc[]>;
|
|
6
|
-
|
|
6
|
+
findCompositionDOM: (compositionViewDesc: CompositionViewDesc) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const ChildDescriptionsContext: import("react").Context<ChildDescriptionsContextValue>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DecorationSource } from "prosemirror-view";
|
|
2
2
|
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
3
3
|
/**
|
|
4
4
|
* Produces the DecorationSource for the current state, based
|
|
@@ -11,4 +11,4 @@ import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
|
11
11
|
* This makes it safe to call in a React render function, even
|
|
12
12
|
* if its result is used in a dependencies array for a hook.
|
|
13
13
|
*/
|
|
14
|
-
export declare function viewDecorations(view: AbstractEditorView
|
|
14
|
+
export declare function viewDecorations(view: AbstractEditorView): DecorationSource;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
2
|
-
import {
|
|
2
|
+
import { EditorProps, EditorView } from "prosemirror-view";
|
|
3
3
|
import { AbstractEditorView } from "../AbstractEditorView.js";
|
|
4
4
|
export interface UseEditorOptions extends EditorProps {
|
|
5
5
|
defaultState?: EditorState;
|
|
@@ -25,6 +25,5 @@ export declare function useEditor<T extends HTMLElement = HTMLElement>(mount: T
|
|
|
25
25
|
unregisterEventListener: (eventType: keyof import("prosemirror-view").DOMEventMap, handler: import("./useComponentEventListeners.js").EventHandler<keyof import("prosemirror-view").DOMEventMap>) => void;
|
|
26
26
|
isStatic: boolean;
|
|
27
27
|
};
|
|
28
|
-
cursorWrapper: Decoration | null;
|
|
29
28
|
state: EditorState;
|
|
30
29
|
};
|
|
@@ -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 { MarkViewDesc, ViewDesc } from "../viewdesc.js";
|
|
4
|
+
import { CompositionViewDesc, 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,6 +9,7 @@ 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;
|
|
12
13
|
};
|
|
13
14
|
contentDOM: HTMLElement | undefined;
|
|
14
15
|
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 { NodeViewDesc, ViewDesc } from "../viewdesc.js";
|
|
4
|
+
import { CompositionViewDesc, 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,6 +9,7 @@ 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;
|
|
12
13
|
};
|
|
13
14
|
contentDOM: HTMLElement | null;
|
|
14
15
|
refUpdated: () => void;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { Node } from "prosemirror-model";
|
|
2
1
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
+
import { Decoration } from "prosemirror-view";
|
|
3
3
|
export declare function createNodeKey(): string;
|
|
4
|
-
|
|
4
|
+
interface ReactKeysPluginState {
|
|
5
5
|
posToKey: Map<number, string>;
|
|
6
6
|
keyToPos: Map<string, number>;
|
|
7
|
-
|
|
8
|
-
}
|
|
7
|
+
cursorWrapper: Decoration | null;
|
|
8
|
+
}
|
|
9
|
+
export declare const reactKeysPluginKey: PluginKey<ReactKeysPluginState>;
|
|
9
10
|
export type ReactKeysPluginMeta = {
|
|
10
11
|
overrides: Record<number, number>;
|
|
12
|
+
} | {
|
|
13
|
+
cursorWrapper: Decoration | null;
|
|
11
14
|
} | undefined;
|
|
12
15
|
/**
|
|
13
16
|
* Tracks a unique key for each (non-text) node in the
|
|
@@ -16,7 +19,5 @@ export type ReactKeysPluginMeta = {
|
|
|
16
19
|
* key for a given node can be accessed by that node's
|
|
17
20
|
* current position in the document, and vice versa.
|
|
18
21
|
*/
|
|
19
|
-
export declare function reactKeys(): Plugin<
|
|
20
|
-
|
|
21
|
-
keyToPos: Map<string, number>;
|
|
22
|
-
}>;
|
|
22
|
+
export declare function reactKeys(): Plugin<ReactKeysPluginState>;
|
|
23
|
+
export {};
|
package/dist/types/viewdesc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mark, Node, TagParseRule } from "prosemirror-model";
|
|
1
|
+
import { Fragment, Mark, Node, TagParseRule } from "prosemirror-model";
|
|
2
2
|
import { Decoration, DecorationSource, EditorView, NodeView } from "prosemirror-view";
|
|
3
3
|
import { ReactEditorView } from "./ReactEditorView.js";
|
|
4
4
|
import { DOMNode } from "./dom.js";
|
|
@@ -133,7 +133,7 @@ export declare class TextViewDesc extends NodeViewDesc {
|
|
|
133
133
|
parseRule(): {
|
|
134
134
|
skip: any;
|
|
135
135
|
};
|
|
136
|
-
update(
|
|
136
|
+
update(node: Node, outerDeco: readonly Decoration[], _innerDeco: DecorationSource, _view: ReactEditorView): boolean;
|
|
137
137
|
inParent(): boolean;
|
|
138
138
|
domFromPos(pos: number): {
|
|
139
139
|
node: globalThis.Node;
|
|
@@ -172,4 +172,5 @@ export declare class ReactNodeViewDesc extends CustomNodeViewDesc {
|
|
|
172
172
|
destroy(): void;
|
|
173
173
|
}
|
|
174
174
|
export declare function sameOuterDeco(a: readonly Decoration[], b: readonly Decoration[]): boolean;
|
|
175
|
+
export declare function findTextInFragment(frag: Fragment, text: string, from: number, to: number): number;
|
|
175
176
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handlewithcare/react-prosemirror",
|
|
3
|
-
"version": "3.1.0-tiptap.
|
|
3
|
+
"version": "3.1.0-tiptap.53",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
72
72
|
"@typescript-eslint/parser": "^5.51.0",
|
|
73
73
|
"@uiw/react-codemirror": "^4.23.7",
|
|
74
|
+
"@vitejs/plugin-basic-ssl": "^2.3.0",
|
|
74
75
|
"@vitejs/plugin-react": "^4.3.1",
|
|
75
76
|
"@wdio/browser-runner": "^9.18.1",
|
|
76
77
|
"@wdio/cli": "^9.18.1",
|
|
@@ -111,6 +112,7 @@
|
|
|
111
112
|
"prosemirror-test-builder": "^1.1.1",
|
|
112
113
|
"prosemirror-transform": "^1.12.0",
|
|
113
114
|
"prosemirror-view": "1.41.7",
|
|
115
|
+
"puppeteer-core": "^25.0.4",
|
|
114
116
|
"react": "^18.2.0",
|
|
115
117
|
"react-dom": "^18.2.0",
|
|
116
118
|
"react-reconciler": "^0.29.0",
|