@handlewithcare/react-prosemirror 2.7.0-tiptap.9 → 2.7.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 +5 -71
- package/dist/cjs/StaticEditorView.js +0 -3
- package/dist/cjs/dom.js +8 -3
- package/dist/cjs/plugins/beforeInputPlugin.js +1 -1
- package/dist/cjs/viewdesc.js +6 -0
- package/dist/esm/StaticEditorView.js +0 -3
- package/dist/esm/dom.js +8 -3
- package/dist/esm/hooks/useEditorEffect.js +0 -4
- package/dist/esm/hooks/useEditorEventCallback.js +5 -3
- package/dist/esm/plugins/beforeInputPlugin.js +1 -1
- package/dist/esm/viewdesc.js +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AbstractEditorView.d.ts +0 -1
- package/dist/types/StaticEditorView.d.ts +0 -1
- package/dist/types/hooks/useEditorEffect.d.ts +0 -4
- package/dist/types/hooks/useEditorEventCallback.d.ts +5 -3
- package/dist/types/viewdesc.d.ts +2 -0
- package/package.json +8 -11
- package/dist/cjs/tiptap/TiptapEditor.js +0 -34
- package/dist/cjs/tiptap/TiptapEditorContent.js +0 -136
- package/dist/cjs/tiptap/TiptapEditorView.js +0 -99
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +0 -20
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +0 -29
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +0 -32
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +0 -35
- package/dist/cjs/tiptap/index.js +0 -44
- package/dist/cjs/tiptap/tiptapNodeView.js +0 -188
- package/dist/esm/tiptap/TiptapEditor.js +0 -24
- package/dist/esm/tiptap/TiptapEditorContent.js +0 -85
- package/dist/esm/tiptap/TiptapEditorView.js +0 -50
- package/dist/esm/tiptap/extensions/ReactProseMirror.js +0 -10
- package/dist/esm/tiptap/hooks/useTiptapEditor.js +0 -19
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +0 -39
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +0 -35
- package/dist/esm/tiptap/index.js +0 -8
- package/dist/esm/tiptap/tiptapNodeView.js +0 -156
- package/dist/types/tiptap/TiptapEditor.d.ts +0 -6
- package/dist/types/tiptap/TiptapEditorContent.d.ts +0 -19
- package/dist/types/tiptap/TiptapEditorView.d.ts +0 -13
- package/dist/types/tiptap/extensions/ReactProseMirror.d.ts +0 -2
- package/dist/types/tiptap/hooks/useTiptapEditor.d.ts +0 -4
- package/dist/types/tiptap/hooks/useTiptapEditorEffect.d.ts +0 -21
- package/dist/types/tiptap/hooks/useTiptapEditorEventCallback.d.ts +0 -13
- package/dist/types/tiptap/index.d.ts +0 -8
- package/dist/types/tiptap/tiptapNodeView.d.ts +0 -48
|
@@ -11,7 +11,6 @@ export interface AbstractEditorView {
|
|
|
11
11
|
readonly nodeViews: NodeViewSet;
|
|
12
12
|
readonly props: DirectEditorProps;
|
|
13
13
|
readonly state: EditorState;
|
|
14
|
-
readonly isDestroyed: boolean;
|
|
15
14
|
setProps(props: Partial<DirectEditorProps>): void;
|
|
16
15
|
update(props: DirectEditorProps): void;
|
|
17
16
|
updateState(state: EditorState): void;
|
|
@@ -9,7 +9,6 @@ export declare class StaticEditorView implements AbstractEditorView {
|
|
|
9
9
|
get dom(): null;
|
|
10
10
|
get editable(): boolean;
|
|
11
11
|
get state(): EditorState;
|
|
12
|
-
get isDestroyed(): boolean;
|
|
13
12
|
setProps(props: Partial<DirectEditorProps>): void;
|
|
14
13
|
update(props: DirectEditorProps): void;
|
|
15
14
|
updateState(state: EditorState): void;
|
|
@@ -13,9 +13,5 @@ import type { DependencyList } from "react";
|
|
|
13
13
|
* synchronously after all DOM mutations, but they do so
|
|
14
14
|
* _after_ the EditorView has been updated, even when the
|
|
15
15
|
* EditorView lives in an ancestor component.
|
|
16
|
-
*
|
|
17
|
-
* This hook can only be used in a component that is mounted
|
|
18
|
-
* as a child of the TiptapEditorView component, including
|
|
19
|
-
* React node view components.
|
|
20
16
|
*/
|
|
21
17
|
export declare function useEditorEffect(effect: (editorView: EditorView) => void | (() => void), dependencies?: DependencyList): void;
|
|
@@ -6,8 +6,10 @@ import type { EditorView } from "prosemirror-view";
|
|
|
6
6
|
* The callback will be called with the EditorView instance
|
|
7
7
|
* as its first argument.
|
|
8
8
|
*
|
|
9
|
-
* This hook
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* This hook is dependent on both the
|
|
10
|
+
* `EditorViewContext.Provider` and the
|
|
11
|
+
* `DeferredLayoutEffectProvider`. It can only be used in a
|
|
12
|
+
* component that is mounted as a child of both of these
|
|
13
|
+
* providers.
|
|
12
14
|
*/
|
|
13
15
|
export declare function useEditorEventCallback<T extends unknown[], R>(callback: (view: EditorView, ...args: T) => R): (...args: T) => R;
|
package/dist/types/viewdesc.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export declare class ViewDesc {
|
|
|
62
62
|
markParentsDirty(): void;
|
|
63
63
|
get domAtom(): boolean;
|
|
64
64
|
get ignoreForCoords(): boolean;
|
|
65
|
+
get ignoreForSelection(): boolean;
|
|
65
66
|
}
|
|
66
67
|
export declare class WidgetViewDesc extends ViewDesc {
|
|
67
68
|
widget: Decoration;
|
|
@@ -73,6 +74,7 @@ export declare class WidgetViewDesc extends ViewDesc {
|
|
|
73
74
|
stopEvent(event: Event): any;
|
|
74
75
|
ignoreMutation(mutation: ViewMutationRecord): any;
|
|
75
76
|
get domAtom(): boolean;
|
|
77
|
+
get ignoreForSelection(): boolean;
|
|
76
78
|
get side(): number;
|
|
77
79
|
}
|
|
78
80
|
export declare class CompositionViewDesc extends ViewDesc {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handlewithcare/react-prosemirror",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -12,11 +12,6 @@
|
|
|
12
12
|
"import": "./dist/esm/index.js",
|
|
13
13
|
"require": "./dist/cjs/index.js"
|
|
14
14
|
},
|
|
15
|
-
"./tiptap": {
|
|
16
|
-
"types": "./dist/types/tiptap/index.d.ts",
|
|
17
|
-
"import": "./dist/esm/tiptap/index.js",
|
|
18
|
-
"require": "./dist/cjs/tiptap/index.js"
|
|
19
|
-
},
|
|
20
15
|
"./src": "./src/index.ts"
|
|
21
16
|
},
|
|
22
17
|
"files": [
|
|
@@ -24,6 +19,10 @@
|
|
|
24
19
|
"LICENSE.txt",
|
|
25
20
|
"dist"
|
|
26
21
|
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/handlewithcarecollective/react-prosemirror.git"
|
|
25
|
+
},
|
|
27
26
|
"scripts": {
|
|
28
27
|
"build:cjs": "swc ./src --ignore **/__tests__/** -d ./dist/cjs/ --no-swcrc --config-file .swcrc-cjs",
|
|
29
28
|
"build:esm": "swc ./src --ignore **/__tests__/** -d ./dist/esm/",
|
|
@@ -106,7 +105,7 @@
|
|
|
106
105
|
"prosemirror-tables": "^1.3.7",
|
|
107
106
|
"prosemirror-test-builder": "^1.1.1",
|
|
108
107
|
"prosemirror-transform": "^1.8.0",
|
|
109
|
-
"prosemirror-view": "1.
|
|
108
|
+
"prosemirror-view": "1.41.4",
|
|
110
109
|
"react": "^18.2.0",
|
|
111
110
|
"react-dom": "^18.2.0",
|
|
112
111
|
"react-reconciler": "^0.29.0",
|
|
@@ -125,15 +124,13 @@
|
|
|
125
124
|
"prosemirror-view": "1.39.2",
|
|
126
125
|
"react": ">=17 <20",
|
|
127
126
|
"react-dom": ">=17 <20",
|
|
128
|
-
"react-reconciler": ">=0.26.1 <=0.
|
|
127
|
+
"react-reconciler": ">=0.26.1 <=0.33.0"
|
|
129
128
|
},
|
|
130
|
-
"packageManager": "yarn@4.
|
|
129
|
+
"packageManager": "yarn@4.11.0",
|
|
131
130
|
"engines": {
|
|
132
131
|
"node": ">=16.9"
|
|
133
132
|
},
|
|
134
133
|
"dependencies": {
|
|
135
|
-
"@tiptap/core": "^3.0.0",
|
|
136
|
-
"@tiptap/react": "^3.0.0",
|
|
137
134
|
"classnames": "^2.3.2"
|
|
138
135
|
},
|
|
139
136
|
"publishConfig": {
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "TiptapEditor", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return TiptapEditor;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _core = require("@tiptap/core");
|
|
12
|
-
const _prosemirrorstate = require("prosemirror-state");
|
|
13
|
-
const _StaticEditorView = require("../StaticEditorView.js");
|
|
14
|
-
let TiptapEditor = class TiptapEditor extends _core.Editor {
|
|
15
|
-
constructor(options = {}){
|
|
16
|
-
super({
|
|
17
|
-
...options,
|
|
18
|
-
element: null
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
get view() {
|
|
22
|
-
return(// @ts-expect-error private property
|
|
23
|
-
this.editorView ?? new _StaticEditorView.StaticEditorView({
|
|
24
|
-
state: _prosemirrorstate.EditorState.create({
|
|
25
|
-
schema: this.extensionManager.schema
|
|
26
|
-
}),
|
|
27
|
-
...this.options.editorProps,
|
|
28
|
-
attributes: {
|
|
29
|
-
role: "textbox",
|
|
30
|
-
...this.extensionManager.attributes
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "TiptapEditorContent", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return TiptapEditorContent;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
-
const _reactdom = require("react-dom");
|
|
13
|
-
const _ProseMirrorDoc = require("../components/ProseMirrorDoc.js");
|
|
14
|
-
const _useEditorEffect = require("../hooks/useEditorEffect.js");
|
|
15
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
16
|
-
if (typeof WeakMap !== "function") return null;
|
|
17
|
-
var cacheBabelInterop = new WeakMap();
|
|
18
|
-
var cacheNodeInterop = new WeakMap();
|
|
19
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
20
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
21
|
-
})(nodeInterop);
|
|
22
|
-
}
|
|
23
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
24
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
25
|
-
return obj;
|
|
26
|
-
}
|
|
27
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
28
|
-
return {
|
|
29
|
-
default: obj
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
33
|
-
if (cache && cache.has(obj)) {
|
|
34
|
-
return cache.get(obj);
|
|
35
|
-
}
|
|
36
|
-
var newObj = {
|
|
37
|
-
__proto__: null
|
|
38
|
-
};
|
|
39
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
|
-
for(var key in obj){
|
|
41
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
42
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
43
|
-
if (desc && (desc.get || desc.set)) {
|
|
44
|
-
Object.defineProperty(newObj, key, desc);
|
|
45
|
-
} else {
|
|
46
|
-
newObj[key] = obj[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
newObj.default = obj;
|
|
51
|
-
if (cache) {
|
|
52
|
-
cache.set(obj, newObj);
|
|
53
|
-
}
|
|
54
|
-
return newObj;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* This component renders all of the editor's registered "React renderers".
|
|
58
|
-
*/ const Portals = (param)=>{
|
|
59
|
-
let { contentComponent } = param;
|
|
60
|
-
const renderers = (0, _react.useSyncExternalStore)(contentComponent.subscribe, contentComponent.getSnapshot, contentComponent.getServerSnapshot);
|
|
61
|
-
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, Object.values(renderers));
|
|
62
|
-
};
|
|
63
|
-
function getInstance() {
|
|
64
|
-
const subscribers = new Set();
|
|
65
|
-
let renderers = {};
|
|
66
|
-
return {
|
|
67
|
-
/**
|
|
68
|
-
* Subscribe to the editor instance's changes.
|
|
69
|
-
*/ subscribe (callback) {
|
|
70
|
-
subscribers.add(callback);
|
|
71
|
-
return ()=>{
|
|
72
|
-
subscribers.delete(callback);
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
getSnapshot () {
|
|
76
|
-
return renderers;
|
|
77
|
-
},
|
|
78
|
-
getServerSnapshot () {
|
|
79
|
-
return renderers;
|
|
80
|
-
},
|
|
81
|
-
/**
|
|
82
|
-
* Adds a new React Renderer to the editor.
|
|
83
|
-
*/ setRenderer (id, renderer) {
|
|
84
|
-
renderers = {
|
|
85
|
-
...renderers,
|
|
86
|
-
[id]: /*#__PURE__*/ (0, _reactdom.createPortal)(renderer.reactElement, renderer.element, id)
|
|
87
|
-
};
|
|
88
|
-
subscribers.forEach((subscriber)=>subscriber());
|
|
89
|
-
},
|
|
90
|
-
/**
|
|
91
|
-
* Removes a React Renderer from the editor.
|
|
92
|
-
*/ removeRenderer (id) {
|
|
93
|
-
const nextRenderers = {
|
|
94
|
-
...renderers
|
|
95
|
-
};
|
|
96
|
-
delete nextRenderers[id];
|
|
97
|
-
renderers = nextRenderers;
|
|
98
|
-
subscribers.forEach((subscriber)=>subscriber());
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function TiptapEditorContent(param) {
|
|
103
|
-
let { editor: editorProp, ...props } = param;
|
|
104
|
-
const editor = editorProp;
|
|
105
|
-
(0, _useEditorEffect.useEditorEffect)((view)=>{
|
|
106
|
-
if (editor.view === view) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
// @ts-expect-error private property
|
|
110
|
-
editor.editorView = view;
|
|
111
|
-
editor.contentComponent = getInstance();
|
|
112
|
-
// @ts-expect-error private method
|
|
113
|
-
editor.injectCSS();
|
|
114
|
-
const dom = view.dom;
|
|
115
|
-
dom.editor = editor;
|
|
116
|
-
setTimeout(()=>{
|
|
117
|
-
if (editor.isDestroyed) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
editor.commands.focus(editor.options.autofocus);
|
|
121
|
-
editor.emit("create", {
|
|
122
|
-
editor
|
|
123
|
-
});
|
|
124
|
-
editor.isInitialized = true;
|
|
125
|
-
});
|
|
126
|
-
return ()=>{
|
|
127
|
-
editor.isInitialized = false;
|
|
128
|
-
editor.contentComponent = null;
|
|
129
|
-
};
|
|
130
|
-
}, [
|
|
131
|
-
editor
|
|
132
|
-
]);
|
|
133
|
-
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_ProseMirrorDoc.ProseMirrorDoc, props), editor?.contentComponent && /*#__PURE__*/ _react.default.createElement(Portals, {
|
|
134
|
-
contentComponent: editor.contentComponent
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "TiptapEditorView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return TiptapEditorView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("@tiptap/react");
|
|
12
|
-
const _react1 = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
-
const _ProseMirror = require("../components/ProseMirror.js");
|
|
14
|
-
const _useForceUpdate = require("../hooks/useForceUpdate.js");
|
|
15
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
16
|
-
if (typeof WeakMap !== "function") return null;
|
|
17
|
-
var cacheBabelInterop = new WeakMap();
|
|
18
|
-
var cacheNodeInterop = new WeakMap();
|
|
19
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
20
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
21
|
-
})(nodeInterop);
|
|
22
|
-
}
|
|
23
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
24
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
25
|
-
return obj;
|
|
26
|
-
}
|
|
27
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
28
|
-
return {
|
|
29
|
-
default: obj
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
33
|
-
if (cache && cache.has(obj)) {
|
|
34
|
-
return cache.get(obj);
|
|
35
|
-
}
|
|
36
|
-
var newObj = {
|
|
37
|
-
__proto__: null
|
|
38
|
-
};
|
|
39
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
|
-
for(var key in obj){
|
|
41
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
42
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
43
|
-
if (desc && (desc.get || desc.set)) {
|
|
44
|
-
Object.defineProperty(newObj, key, desc);
|
|
45
|
-
} else {
|
|
46
|
-
newObj[key] = obj[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
newObj.default = obj;
|
|
51
|
-
if (cache) {
|
|
52
|
-
cache.set(obj, newObj);
|
|
53
|
-
}
|
|
54
|
-
return newObj;
|
|
55
|
-
}
|
|
56
|
-
function TiptapEditorView(param) {
|
|
57
|
-
let { editor, nodeViews, children } = param;
|
|
58
|
-
const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
|
|
59
|
-
const dispatchTransaction = (0, _react1.useCallback)((tr)=>{
|
|
60
|
-
// @ts-expect-error calling private method
|
|
61
|
-
editor.dispatchTransaction(tr);
|
|
62
|
-
// Tiptap's dispatchTransaction doesn't trigger
|
|
63
|
-
// a re-render, so we need to manually force
|
|
64
|
-
// one to ensure that React stays in sync.
|
|
65
|
-
forceUpdate();
|
|
66
|
-
}, [
|
|
67
|
-
editor,
|
|
68
|
-
forceUpdate
|
|
69
|
-
]);
|
|
70
|
-
const initialEditorProps = {
|
|
71
|
-
...editor.options.editorProps,
|
|
72
|
-
attributes: {
|
|
73
|
-
role: "textbox",
|
|
74
|
-
...editor.options.editorProps?.attributes
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const { nodeViews: customNodeViews, markViews } = editor.isDestroyed ? {
|
|
78
|
-
nodeViews: undefined,
|
|
79
|
-
markViews: undefined
|
|
80
|
-
} : editor.view.props;
|
|
81
|
-
const contextValue = (0, _react1.useMemo)(()=>({
|
|
82
|
-
editor
|
|
83
|
-
}), [
|
|
84
|
-
editor
|
|
85
|
-
]);
|
|
86
|
-
return /*#__PURE__*/ _react1.default.createElement(_ProseMirror.ProseMirror, {
|
|
87
|
-
className: "tiptap",
|
|
88
|
-
...initialEditorProps,
|
|
89
|
-
markViews: markViews,
|
|
90
|
-
nodeViews: nodeViews,
|
|
91
|
-
customNodeViews: customNodeViews,
|
|
92
|
-
state: editor.isDestroyed || editor.state.plugins.length ? editor.state : editor.state.reconfigure({
|
|
93
|
-
plugins: editor.extensionManager.plugins
|
|
94
|
-
}),
|
|
95
|
-
dispatchTransaction: dispatchTransaction
|
|
96
|
-
}, /*#__PURE__*/ _react1.default.createElement(_react.EditorContext.Provider, {
|
|
97
|
-
value: contextValue
|
|
98
|
-
}, children));
|
|
99
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ReactProseMirror", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ReactProseMirror;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _core = require("@tiptap/core");
|
|
12
|
-
const _reactKeys = require("../../plugins/reactKeys.js");
|
|
13
|
-
const ReactProseMirror = _core.Extension.create({
|
|
14
|
-
name: "@handlewithcare/react-prosemirror/reactKeys",
|
|
15
|
-
addProseMirrorPlugins () {
|
|
16
|
-
return [
|
|
17
|
-
(0, _reactKeys.reactKeys)()
|
|
18
|
-
];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useTiptapEditor", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return useTiptapEditor;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("@tiptap/react");
|
|
12
|
-
const _StaticEditorView = require("../../StaticEditorView.js");
|
|
13
|
-
function useTiptapEditor(options, deps) {
|
|
14
|
-
const editor = (0, _react.useEditor)({
|
|
15
|
-
...options,
|
|
16
|
-
element: null
|
|
17
|
-
}, deps);
|
|
18
|
-
// @ts-expect-error private property
|
|
19
|
-
editor.editorView ??= new _StaticEditorView.StaticEditorView({
|
|
20
|
-
// @ts-expect-error private property
|
|
21
|
-
state: editor.editorState,
|
|
22
|
-
...editor.options.editorProps,
|
|
23
|
-
attributes: {
|
|
24
|
-
role: "textbox",
|
|
25
|
-
...editor.extensionManager.attributes
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return editor;
|
|
29
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useTiptapEditorEffect", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return useTiptapEditorEffect;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("@tiptap/react");
|
|
12
|
-
const _react1 = require("react");
|
|
13
|
-
const _ReactEditorView = require("../../ReactEditorView.js");
|
|
14
|
-
const _EditorContext = require("../../contexts/EditorContext.js");
|
|
15
|
-
const _useEditorEffect = require("../../hooks/useEditorEffect.js");
|
|
16
|
-
function useTiptapEditorEffect(effect, dependencies) {
|
|
17
|
-
const { view } = (0, _react1.useContext)(_EditorContext.EditorContext);
|
|
18
|
-
const { editor } = (0, _react.useCurrentEditor)();
|
|
19
|
-
(0, _useEditorEffect.useEditorEffect)(()=>{
|
|
20
|
-
if (editor?.view instanceof _ReactEditorView.ReactEditorView && view instanceof _ReactEditorView.ReactEditorView) {
|
|
21
|
-
return effect(editor);
|
|
22
|
-
}
|
|
23
|
-
// The rules of hooks want to be able to statically
|
|
24
|
-
// verify the dependencies for the effect, but this will
|
|
25
|
-
// have already happened at the call-site.
|
|
26
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
-
}, dependencies && [
|
|
28
|
-
editor,
|
|
29
|
-
view,
|
|
30
|
-
...dependencies
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useTiptapEditorEventCallback", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return useTiptapEditorEventCallback;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("@tiptap/react");
|
|
12
|
-
const _react1 = require("react");
|
|
13
|
-
const _useEditorEffect = require("../../hooks/useEditorEffect.js");
|
|
14
|
-
function assertEditor(editor) {
|
|
15
|
-
if (editor) return;
|
|
16
|
-
throw new DOMException("Tiptap Editor is not initialized", "InvalidStateError");
|
|
17
|
-
}
|
|
18
|
-
function useTiptapEditorEventCallback(callback) {
|
|
19
|
-
const ref = (0, _react1.useRef)(callback);
|
|
20
|
-
const { editor } = (0, _react.useCurrentEditor)();
|
|
21
|
-
(0, _useEditorEffect.useEditorEffect)(()=>{
|
|
22
|
-
ref.current = callback;
|
|
23
|
-
}, [
|
|
24
|
-
callback
|
|
25
|
-
]);
|
|
26
|
-
return (0, _react1.useCallback)(function() {
|
|
27
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
28
|
-
args[_key] = arguments[_key];
|
|
29
|
-
}
|
|
30
|
-
assertEditor(editor);
|
|
31
|
-
return ref.current(editor, ...args);
|
|
32
|
-
}, [
|
|
33
|
-
editor
|
|
34
|
-
]);
|
|
35
|
-
}
|
package/dist/cjs/tiptap/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
ReactProseMirror: function() {
|
|
13
|
-
return _ReactProseMirror.ReactProseMirror;
|
|
14
|
-
},
|
|
15
|
-
TiptapEditor: function() {
|
|
16
|
-
return _TiptapEditor.TiptapEditor;
|
|
17
|
-
},
|
|
18
|
-
TiptapEditorContent: function() {
|
|
19
|
-
return _TiptapEditorContent.TiptapEditorContent;
|
|
20
|
-
},
|
|
21
|
-
TiptapEditorView: function() {
|
|
22
|
-
return _TiptapEditorView.TiptapEditorView;
|
|
23
|
-
},
|
|
24
|
-
tiptapNodeView: function() {
|
|
25
|
-
return _tiptapNodeView.tiptapNodeView;
|
|
26
|
-
},
|
|
27
|
-
useTiptapEditor: function() {
|
|
28
|
-
return _useTiptapEditor.useTiptapEditor;
|
|
29
|
-
},
|
|
30
|
-
useTiptapEditorEffect: function() {
|
|
31
|
-
return _useTiptapEditorEffect.useTiptapEditorEffect;
|
|
32
|
-
},
|
|
33
|
-
useTiptapEditorEventCallback: function() {
|
|
34
|
-
return _useTiptapEditorEventCallback.useTiptapEditorEventCallback;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const _tiptapNodeView = require("./tiptapNodeView.js");
|
|
38
|
-
const _TiptapEditorView = require("./TiptapEditorView.js");
|
|
39
|
-
const _TiptapEditorContent = require("./TiptapEditorContent.js");
|
|
40
|
-
const _useTiptapEditorEffect = require("./hooks/useTiptapEditorEffect.js");
|
|
41
|
-
const _useTiptapEditorEventCallback = require("./hooks/useTiptapEditorEventCallback.js");
|
|
42
|
-
const _TiptapEditor = require("./TiptapEditor.js");
|
|
43
|
-
const _useTiptapEditor = require("./hooks/useTiptapEditor.js");
|
|
44
|
-
const _ReactProseMirror = require("./extensions/ReactProseMirror.js");
|