@handlewithcare/react-prosemirror 3.1.0-tiptap.53 → 3.1.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/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 +135 -122
- 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 +136 -123
- 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,7 +2,7 @@ import { Editor, NodeView, NodeViewRendererOptions, NodeViewRendererProps } from
|
|
|
2
2
|
/**
|
|
3
3
|
* Subclass of Tiptap's NodeView to be used in tiptapNodeView.
|
|
4
4
|
*
|
|
5
|
-
* Allows us to pass in an existing dom and
|
|
5
|
+
* Allows us to pass in an existing dom and contentDOM from React ProseMirror's
|
|
6
6
|
* ViewDesc, so that we can call Tiptap's default stopEvent and ignoreMutation
|
|
7
7
|
* methods
|
|
8
8
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Editor } from "@tiptap/core";
|
|
2
2
|
import { ReactRenderer } from "@tiptap/react";
|
|
3
|
-
import React, { ForwardedRef, HTMLProps, ReactPortal } from "react";
|
|
3
|
+
import React, { ElementType, ForwardedRef, HTMLProps, ReactPortal } from "react";
|
|
4
4
|
export type ContentComponent = {
|
|
5
5
|
setRenderer(id: string, renderer: ReactRenderer): void;
|
|
6
6
|
removeRenderer(id: string): void;
|
|
@@ -14,6 +14,15 @@ export interface EditorContentProps extends HTMLProps<HTMLDivElement> {
|
|
|
14
14
|
}
|
|
15
15
|
interface Props extends Omit<HTMLProps<HTMLElement>, "as"> {
|
|
16
16
|
editor: Editor;
|
|
17
|
+
as?: ElementType;
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Renders the actual editable ProseMirror document.
|
|
21
|
+
*
|
|
22
|
+
* This **must** be passed as a child to the `TiptapEditorView`
|
|
23
|
+
* component. It may be wrapped in other components, and other
|
|
24
|
+
* childern may be passed before or after. It must be passed the
|
|
25
|
+
* same `editor` as is passed to the `TiptapEditorView`.
|
|
26
|
+
*/
|
|
18
27
|
export declare function TiptapEditorContent({ editor: editorProp, ...props }: Props): React.JSX.Element;
|
|
19
28
|
export {};
|
|
@@ -20,6 +20,7 @@ export interface TiptapNodeViewProps {
|
|
|
20
20
|
}) => boolean) | null;
|
|
21
21
|
ignoreMutation?: ((props: {
|
|
22
22
|
mutation: ViewMutationRecord;
|
|
23
|
+
defaultIgnoreMutation: (mutation: ViewMutationRecord) => boolean;
|
|
23
24
|
}) => boolean) | null;
|
|
24
25
|
contentDOMElementTag?: ElementType | undefined;
|
|
25
26
|
}
|
|
@@ -36,11 +37,9 @@ export interface TiptapNodeViewProps {
|
|
|
36
37
|
* codeBlock: nodeView({
|
|
37
38
|
* component: function CodeBlock(nodeViewProps) {
|
|
38
39
|
* return (
|
|
39
|
-
* <
|
|
40
|
-
* <
|
|
41
|
-
*
|
|
42
|
-
* </pre>
|
|
43
|
-
* </AnnotatableNodeViewWrapper>
|
|
40
|
+
* <pre>
|
|
41
|
+
* <NodeViewContent as="code" />
|
|
42
|
+
* </pre>
|
|
44
43
|
* )
|
|
45
44
|
* },
|
|
46
45
|
* extension: CodeBlockExtension,
|
|
@@ -48,4 +47,4 @@ export interface TiptapNodeViewProps {
|
|
|
48
47
|
* }
|
|
49
48
|
* ```
|
|
50
49
|
*/
|
|
51
|
-
export declare function tiptapNodeView({ component: WrappedComponent, extension, as, className, attrs, contentDOMElementTag: InnerTag, stopEvent, ignoreMutation, }: TiptapNodeViewProps): React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<NodeViewComponentProps
|
|
50
|
+
export declare function tiptapNodeView({ component: WrappedComponent, extension, as, className, attrs, contentDOMElementTag: InnerTag, stopEvent, ignoreMutation, }: TiptapNodeViewProps): React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<NodeViewComponentProps, "ref"> & React.RefAttributes<HTMLElement | null>>>;
|
package/dist/types/viewdesc.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export declare class NodeViewDesc extends ViewDesc {
|
|
|
119
119
|
parseRule(): Omit<TagParseRule, "tag"> | null;
|
|
120
120
|
matchesNode(node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource): boolean;
|
|
121
121
|
get size(): number;
|
|
122
|
-
get border():
|
|
122
|
+
get border(): 0 | 1;
|
|
123
123
|
updateChildren(_view: EditorView, _pos: number): void;
|
|
124
124
|
update(node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, view: EditorView): boolean;
|
|
125
125
|
updateInner(node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, view: EditorView): void;
|
|
@@ -143,6 +143,7 @@ export declare class TextViewDesc extends NodeViewDesc {
|
|
|
143
143
|
markDirty(from: number, to: number): void;
|
|
144
144
|
get domAtom(): boolean;
|
|
145
145
|
isText(text: string): boolean;
|
|
146
|
+
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
146
147
|
}
|
|
147
148
|
export declare class TrailingHackViewDesc extends ViewDesc {
|
|
148
149
|
parseRule(): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handlewithcare/react-prosemirror",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -63,6 +63,9 @@
|
|
|
63
63
|
"@testing-library/dom": "^10.4.0",
|
|
64
64
|
"@testing-library/react": "^16.3.0",
|
|
65
65
|
"@testing-library/user-event": "^14.6.1",
|
|
66
|
+
"@tiptap/core": "^3.15.3",
|
|
67
|
+
"@tiptap/pm": "^3.15.3",
|
|
68
|
+
"@tiptap/react": "^3.15.3",
|
|
66
69
|
"@types/css-tree": "^2.3.10",
|
|
67
70
|
"@types/jest": "^27.0.0",
|
|
68
71
|
"@types/react": "^18.2.0",
|
|
@@ -105,7 +108,7 @@
|
|
|
105
108
|
"prosemirror-history": "^1.5.0",
|
|
106
109
|
"prosemirror-inputrules": "^1.5.1",
|
|
107
110
|
"prosemirror-keymap": "^1.2.3",
|
|
108
|
-
"prosemirror-model": "^1.25.
|
|
111
|
+
"prosemirror-model": "^1.25.7",
|
|
109
112
|
"prosemirror-schema-list": "^1.5.1",
|
|
110
113
|
"prosemirror-state": "^1.4.4",
|
|
111
114
|
"prosemirror-tables": "^1.8.5",
|
|
@@ -119,7 +122,7 @@
|
|
|
119
122
|
"remark-parse": "^11.0.0",
|
|
120
123
|
"rimraf": "^3.0.2",
|
|
121
124
|
"tsx": "^4.20.3",
|
|
122
|
-
"typescript": "^
|
|
125
|
+
"typescript": "^6.0.3",
|
|
123
126
|
"unified": "^11.0.5",
|
|
124
127
|
"vite": "^5.4.5",
|
|
125
128
|
"webdriver": "^9.18.0",
|
|
@@ -129,6 +132,9 @@
|
|
|
129
132
|
"prosemirror-view": "1.41.7"
|
|
130
133
|
},
|
|
131
134
|
"peerDependencies": {
|
|
135
|
+
"@tiptap/core": "^3.15.3",
|
|
136
|
+
"@tiptap/pm": "^3.15.3",
|
|
137
|
+
"@tiptap/react": "^3.15.3",
|
|
132
138
|
"prosemirror-model": "^1.0.0",
|
|
133
139
|
"prosemirror-state": "^1.0.0",
|
|
134
140
|
"prosemirror-view": "1.41.7",
|
|
@@ -140,10 +146,18 @@
|
|
|
140
146
|
"engines": {
|
|
141
147
|
"node": ">=16.9"
|
|
142
148
|
},
|
|
149
|
+
"peerDependenciesMeta": {
|
|
150
|
+
"@tiptap/core": {
|
|
151
|
+
"optional": true
|
|
152
|
+
},
|
|
153
|
+
"@tiptap/pm": {
|
|
154
|
+
"optional": true
|
|
155
|
+
},
|
|
156
|
+
"@tiptap/react": {
|
|
157
|
+
"optional": true
|
|
158
|
+
}
|
|
159
|
+
},
|
|
143
160
|
"dependencies": {
|
|
144
|
-
"@tiptap/core": "^3.15.3",
|
|
145
|
-
"@tiptap/pm": "^3.15.3",
|
|
146
|
-
"@tiptap/react": "^3.15.3",
|
|
147
161
|
"classnames": "^2.5.1"
|
|
148
162
|
},
|
|
149
163
|
"publishConfig": {
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "componentEventListeners", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return componentEventListeners;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _reactdom = require("react-dom");
|
|
12
|
-
function componentEventListeners(eventHandlerRegistry) {
|
|
13
|
-
const domEventHandlers = {};
|
|
14
|
-
for (const [eventType, handlers] of eventHandlerRegistry.entries()){
|
|
15
|
-
function handleEvent(view, event) {
|
|
16
|
-
for (const handler of handlers){
|
|
17
|
-
let handled = false;
|
|
18
|
-
(0, _reactdom.unstable_batchedUpdates)(()=>{
|
|
19
|
-
handled = !!handler(view, event);
|
|
20
|
-
});
|
|
21
|
-
if (handled || event.defaultPrevented) return true;
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
domEventHandlers[eventType] = handleEvent;
|
|
26
|
-
}
|
|
27
|
-
return domEventHandlers;
|
|
28
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) The New York Times Company */ "use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createComponentEventListenersPlugin", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return createComponentEventListenersPlugin;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _prosemirrorstate = require("prosemirror-state");
|
|
12
|
-
const _reactdom = require("react-dom");
|
|
13
|
-
function createComponentEventListenersPlugin(eventHandlerRegistry) {
|
|
14
|
-
const domEventHandlers = {};
|
|
15
|
-
for (const [eventType, handlers] of eventHandlerRegistry.entries()){
|
|
16
|
-
function handleEvent(view, event) {
|
|
17
|
-
for (const handler of handlers){
|
|
18
|
-
let handled = false;
|
|
19
|
-
(0, _reactdom.unstable_batchedUpdates)(()=>{
|
|
20
|
-
handled = !!handler.call(this, view, event);
|
|
21
|
-
});
|
|
22
|
-
if (handled || event.defaultPrevented) return true;
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
domEventHandlers[eventType] = handleEvent;
|
|
27
|
-
}
|
|
28
|
-
const plugin = new _prosemirrorstate.Plugin({
|
|
29
|
-
key: new _prosemirrorstate.PluginKey("componentEventListeners"),
|
|
30
|
-
props: {
|
|
31
|
-
handleDOMEvents: domEventHandlers
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return plugin;
|
|
35
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is used to patch global DOM variables in a NodeJS environment.
|
|
3
|
-
* This is needed for ProseMirror to work in a NodeJS environment.
|
|
4
|
-
*/ "use strict";
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
if (typeof window === "undefined") {
|
|
9
|
-
// Make sure to import JSDOM only in a NodeJS environment.
|
|
10
|
-
// The magic comments prevent bundlers from statically analyzing this require:
|
|
11
|
-
// - webpackIgnore: true → webpack / Next.js
|
|
12
|
-
// - @vite-ignore → Vite
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
14
|
-
const jsdom = require(/* webpackIgnore: true */ /* @vite-ignore */ "jsdom");
|
|
15
|
-
const html = `
|
|
16
|
-
<!DOCTYPE html>
|
|
17
|
-
<html>
|
|
18
|
-
<head>
|
|
19
|
-
<title>Testing</title>
|
|
20
|
-
</head>
|
|
21
|
-
<body></body>
|
|
22
|
-
</html>
|
|
23
|
-
`;
|
|
24
|
-
const { window: window1 } = new jsdom.JSDOM(html);
|
|
25
|
-
global.window = window1;
|
|
26
|
-
global.document = window1.document;
|
|
27
|
-
// Use Object.defineProperty for navigator since it's read-only in Node.js 22+
|
|
28
|
-
Object.defineProperty(global, "navigator", {
|
|
29
|
-
value: window1.navigator,
|
|
30
|
-
writable: true,
|
|
31
|
-
configurable: true
|
|
32
|
-
});
|
|
33
|
-
global.innerHeight = 0;
|
|
34
|
-
global.SVGElement = window1.SVGElement;
|
|
35
|
-
// @ts-expect-error stub getSelection for SSR
|
|
36
|
-
document.getSelection = ()=>({});
|
|
37
|
-
document.createRange = ()=>({
|
|
38
|
-
setStart () {},
|
|
39
|
-
setEnd () {},
|
|
40
|
-
// @ts-expect-error stub getBoundingClientRect for SSR
|
|
41
|
-
getClientRects () {
|
|
42
|
-
return {
|
|
43
|
-
left: 0,
|
|
44
|
-
top: 0,
|
|
45
|
-
right: 0,
|
|
46
|
-
bottom: 0
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
// @ts-expect-error stub getBoundingClientRect for SSR
|
|
50
|
-
getBoundingClientRect () {
|
|
51
|
-
return {
|
|
52
|
-
left: 0,
|
|
53
|
-
top: 0,
|
|
54
|
-
right: 0,
|
|
55
|
-
bottom: 0
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { unstable_batchedUpdates as batch } from "react-dom";
|
|
2
|
-
export function componentEventListeners(eventHandlerRegistry) {
|
|
3
|
-
const domEventHandlers = {};
|
|
4
|
-
for (const [eventType, handlers] of eventHandlerRegistry.entries()){
|
|
5
|
-
function handleEvent(view, event) {
|
|
6
|
-
for (const handler of handlers){
|
|
7
|
-
let handled = false;
|
|
8
|
-
batch(()=>{
|
|
9
|
-
handled = !!handler(view, event);
|
|
10
|
-
});
|
|
11
|
-
if (handled || event.defaultPrevented) return true;
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
domEventHandlers[eventType] = handleEvent;
|
|
16
|
-
}
|
|
17
|
-
return domEventHandlers;
|
|
18
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) The New York Times Company */ import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
-
import { unstable_batchedUpdates as batch } from "react-dom";
|
|
3
|
-
export function createComponentEventListenersPlugin(eventHandlerRegistry) {
|
|
4
|
-
const domEventHandlers = {};
|
|
5
|
-
for (const [eventType, handlers] of eventHandlerRegistry.entries()){
|
|
6
|
-
function handleEvent(view, event) {
|
|
7
|
-
for (const handler of handlers){
|
|
8
|
-
let handled = false;
|
|
9
|
-
batch(()=>{
|
|
10
|
-
handled = !!handler.call(this, view, event);
|
|
11
|
-
});
|
|
12
|
-
if (handled || event.defaultPrevented) return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
domEventHandlers[eventType] = handleEvent;
|
|
17
|
-
}
|
|
18
|
-
const plugin = new Plugin({
|
|
19
|
-
key: new PluginKey("componentEventListeners"),
|
|
20
|
-
props: {
|
|
21
|
-
handleDOMEvents: domEventHandlers
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return plugin;
|
|
25
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is used to patch global DOM variables in a NodeJS environment.
|
|
3
|
-
* This is needed for ProseMirror to work in a NodeJS environment.
|
|
4
|
-
*/ if (typeof window === "undefined") {
|
|
5
|
-
// Make sure to import JSDOM only in a NodeJS environment.
|
|
6
|
-
// The magic comments prevent bundlers from statically analyzing this require:
|
|
7
|
-
// - webpackIgnore: true → webpack / Next.js
|
|
8
|
-
// - @vite-ignore → Vite
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
|
-
const jsdom = require(/* webpackIgnore: true */ /* @vite-ignore */ "jsdom");
|
|
11
|
-
const html = `
|
|
12
|
-
<!DOCTYPE html>
|
|
13
|
-
<html>
|
|
14
|
-
<head>
|
|
15
|
-
<title>Testing</title>
|
|
16
|
-
</head>
|
|
17
|
-
<body></body>
|
|
18
|
-
</html>
|
|
19
|
-
`;
|
|
20
|
-
const { window: window1 } = new jsdom.JSDOM(html);
|
|
21
|
-
global.window = window1;
|
|
22
|
-
global.document = window1.document;
|
|
23
|
-
// Use Object.defineProperty for navigator since it's read-only in Node.js 22+
|
|
24
|
-
Object.defineProperty(global, "navigator", {
|
|
25
|
-
value: window1.navigator,
|
|
26
|
-
writable: true,
|
|
27
|
-
configurable: true
|
|
28
|
-
});
|
|
29
|
-
global.innerHeight = 0;
|
|
30
|
-
global.SVGElement = window1.SVGElement;
|
|
31
|
-
// @ts-expect-error stub getSelection for SSR
|
|
32
|
-
document.getSelection = ()=>({});
|
|
33
|
-
document.createRange = ()=>({
|
|
34
|
-
setStart () {},
|
|
35
|
-
setEnd () {},
|
|
36
|
-
// @ts-expect-error stub getBoundingClientRect for SSR
|
|
37
|
-
getClientRects () {
|
|
38
|
-
return {
|
|
39
|
-
left: 0,
|
|
40
|
-
top: 0,
|
|
41
|
-
right: 0,
|
|
42
|
-
bottom: 0
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
// @ts-expect-error stub getBoundingClientRect for SSR
|
|
46
|
-
getBoundingClientRect () {
|
|
47
|
-
return {
|
|
48
|
-
left: 0,
|
|
49
|
-
top: 0,
|
|
50
|
-
right: 0,
|
|
51
|
-
bottom: 0
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
export { };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { DOMEventMap, EditorView } from "prosemirror-view";
|
|
2
|
-
export type EventHandler<EventType extends keyof DOMEventMap = keyof DOMEventMap> = (view: EditorView, event: DOMEventMap[EventType]) => boolean | void;
|
|
3
|
-
export declare function componentEventListeners(eventHandlerRegistry: Map<keyof DOMEventMap, Iterable<EventHandler>>): Record<keyof DOMEventMap, EventHandler<keyof DOMEventMap>>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "prosemirror-state";
|
|
2
|
-
import { DOMEventMap, EditorView } from "prosemirror-view";
|
|
3
|
-
export type EventHandler<EventType extends keyof DOMEventMap = keyof DOMEventMap> = (this: Plugin, view: EditorView, event: DOMEventMap[EventType]) => boolean | void;
|
|
4
|
-
export declare function createComponentEventListenersPlugin(eventHandlerRegistry: Map<keyof DOMEventMap, Set<EventHandler>>): Plugin<any>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|