@tiptap/react 2.0.0-beta.7 → 2.0.0-beta.70
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/LICENSE.md +1 -1
- package/README.md +2 -2
- package/dist/packages/react/src/BubbleMenu.d.ts +3 -1
- package/dist/packages/react/src/EditorContent.d.ts +2 -2
- package/dist/packages/react/src/FloatingMenu.d.ts +8 -0
- package/dist/packages/react/src/NodeViewContent.d.ts +2 -2
- package/dist/packages/react/src/NodeViewWrapper.d.ts +2 -2
- package/dist/packages/react/src/ReactNodeViewRenderer.d.ts +9 -5
- package/dist/packages/react/src/ReactRenderer.d.ts +10 -6
- package/dist/packages/react/src/index.d.ts +1 -0
- package/dist/packages/react/src/useEditor.d.ts +2 -1
- package/dist/packages/react/src/useReactNodeView.d.ts +1 -1
- package/dist/tiptap-react.cjs.js +104 -40
- package/dist/tiptap-react.cjs.js.map +1 -1
- package/dist/tiptap-react.esm.js +105 -42
- package/dist/tiptap-react.esm.js.map +1 -1
- package/dist/tiptap-react.umd.js +107 -44
- package/dist/tiptap-react.umd.js.map +1 -1
- package/package.json +17 -9
- package/src/BubbleMenu.tsx +15 -6
- package/src/EditorContent.tsx +8 -7
- package/src/FloatingMenu.tsx +39 -0
- package/src/NodeViewContent.tsx +16 -9
- package/src/NodeViewWrapper.tsx +11 -9
- package/src/ReactNodeViewRenderer.tsx +70 -23
- package/src/ReactRenderer.tsx +19 -8
- package/src/index.ts +1 -0
- package/src/useEditor.ts +3 -3
- package/src/useReactNodeView.ts +1 -2
- package/CHANGELOG.md +0 -64
- package/dist/tiptap-react.bundle.umd.min.js +0 -54
- package/dist/tiptap-react.bundle.umd.min.js.map +0 -1
package/dist/tiptap-react.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('react'), require('@tiptap/extension-bubble-menu'), require('react-dom')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'react', '@tiptap/extension-bubble-menu', 'react-dom'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/react'] = {}, global.core, global.React, global.extensionBubbleMenu, global.ReactDOM));
|
|
5
|
-
}(this, (function (exports, core, React, extensionBubbleMenu, ReactDOM) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('react'), require('@tiptap/extension-bubble-menu'), require('@tiptap/extension-floating-menu'), require('react-dom')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'react', '@tiptap/extension-bubble-menu', '@tiptap/extension-floating-menu', 'react-dom'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/react'] = {}, global.core, global.React, global.extensionBubbleMenu, global.extensionFloatingMenu, global.ReactDOM));
|
|
5
|
+
}(this, (function (exports, core, React, extensionBubbleMenu, extensionFloatingMenu, ReactDOM) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -12,17 +12,19 @@
|
|
|
12
12
|
const BubbleMenu = props => {
|
|
13
13
|
const element = React.useRef(null);
|
|
14
14
|
React.useEffect(() => {
|
|
15
|
-
const { editor,
|
|
15
|
+
const { pluginKey = 'bubbleMenu', editor, tippyOptions = {}, shouldShow = null, } = props;
|
|
16
16
|
editor.registerPlugin(extensionBubbleMenu.BubbleMenuPlugin({
|
|
17
|
+
pluginKey,
|
|
17
18
|
editor,
|
|
18
19
|
element: element.current,
|
|
19
|
-
|
|
20
|
+
tippyOptions,
|
|
21
|
+
shouldShow,
|
|
20
22
|
}));
|
|
21
23
|
return () => {
|
|
22
|
-
editor.unregisterPlugin(
|
|
24
|
+
editor.unregisterPlugin(pluginKey);
|
|
23
25
|
};
|
|
24
26
|
}, []);
|
|
25
|
-
return (React__default['default'].createElement("div", { ref: element, className: props.className }, props.children));
|
|
27
|
+
return (React__default['default'].createElement("div", { ref: element, className: props.className, style: { visibility: 'hidden' } }, props.children));
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
class Editor extends core.Editor {
|
|
@@ -32,11 +34,29 @@
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
const FloatingMenu = props => {
|
|
38
|
+
const element = React.useRef(null);
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
const { pluginKey = 'floatingMenu', editor, tippyOptions = {}, shouldShow = null, } = props;
|
|
41
|
+
editor.registerPlugin(extensionFloatingMenu.FloatingMenuPlugin({
|
|
42
|
+
pluginKey,
|
|
43
|
+
editor,
|
|
44
|
+
element: element.current,
|
|
45
|
+
tippyOptions,
|
|
46
|
+
shouldShow,
|
|
47
|
+
}));
|
|
48
|
+
return () => {
|
|
49
|
+
editor.unregisterPlugin(pluginKey);
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
return (React__default['default'].createElement("div", { ref: element, className: props.className, style: { visibility: 'hidden' } }, props.children));
|
|
53
|
+
};
|
|
54
|
+
|
|
35
55
|
function useForceUpdate() {
|
|
36
56
|
const [, setValue] = React.useState(0);
|
|
37
57
|
return () => setValue(value => value + 1);
|
|
38
58
|
}
|
|
39
|
-
const useEditor = (options = {}) => {
|
|
59
|
+
const useEditor = (options = {}, deps = []) => {
|
|
40
60
|
const [editor, setEditor] = React.useState(null);
|
|
41
61
|
const forceUpdate = useForceUpdate();
|
|
42
62
|
React.useEffect(() => {
|
|
@@ -46,7 +66,7 @@
|
|
|
46
66
|
return () => {
|
|
47
67
|
instance.destroy();
|
|
48
68
|
};
|
|
49
|
-
},
|
|
69
|
+
}, deps);
|
|
50
70
|
return editor;
|
|
51
71
|
};
|
|
52
72
|
|
|
@@ -55,14 +75,19 @@
|
|
|
55
75
|
&& Component.prototype
|
|
56
76
|
&& Component.prototype.isReactComponent);
|
|
57
77
|
}
|
|
78
|
+
function isForwardRefComponent(Component) {
|
|
79
|
+
var _a;
|
|
80
|
+
return !!(typeof Component === 'object'
|
|
81
|
+
&& ((_a = Component.$$typeof) === null || _a === void 0 ? void 0 : _a.toString()) === 'Symbol(react.forward_ref)');
|
|
82
|
+
}
|
|
58
83
|
class ReactRenderer {
|
|
59
|
-
constructor(component, { props = {},
|
|
84
|
+
constructor(component, { editor, props = {}, as = 'div' }) {
|
|
60
85
|
this.ref = null;
|
|
61
86
|
this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString();
|
|
62
87
|
this.component = component;
|
|
63
88
|
this.editor = editor;
|
|
64
89
|
this.props = props;
|
|
65
|
-
this.element = document.createElement(
|
|
90
|
+
this.element = document.createElement(as);
|
|
66
91
|
this.element.classList.add('react-renderer');
|
|
67
92
|
this.render();
|
|
68
93
|
}
|
|
@@ -70,12 +95,12 @@
|
|
|
70
95
|
var _a;
|
|
71
96
|
const Component = this.component;
|
|
72
97
|
const props = this.props;
|
|
73
|
-
if (isClassComponent(Component)) {
|
|
98
|
+
if (isClassComponent(Component) || isForwardRefComponent(Component)) {
|
|
74
99
|
props.ref = (ref) => {
|
|
75
100
|
this.ref = ref;
|
|
76
101
|
};
|
|
77
102
|
}
|
|
78
|
-
this.reactElement = React__default['default'].createElement(Component,
|
|
103
|
+
this.reactElement = React__default['default'].createElement(Component, { ...props });
|
|
79
104
|
if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
|
|
80
105
|
this.editor.contentComponent.setState({
|
|
81
106
|
renderers: this.editor.contentComponent.state.renderers.set(this.id, this),
|
|
@@ -102,7 +127,6 @@
|
|
|
102
127
|
}
|
|
103
128
|
|
|
104
129
|
const ReactNodeViewContext = React.createContext({
|
|
105
|
-
isEditable: undefined,
|
|
106
130
|
onDragStart: undefined,
|
|
107
131
|
});
|
|
108
132
|
const useReactNodeView = () => React.useContext(ReactNodeViewContext);
|
|
@@ -117,38 +141,44 @@
|
|
|
117
141
|
extension: this.extension,
|
|
118
142
|
getPos: () => this.getPos(),
|
|
119
143
|
updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
|
|
144
|
+
deleteNode: () => this.deleteNode(),
|
|
120
145
|
};
|
|
121
146
|
if (!this.component.displayName) {
|
|
122
147
|
const capitalizeFirstChar = (string) => {
|
|
123
148
|
return string.charAt(0).toUpperCase() + string.substring(1);
|
|
124
149
|
};
|
|
125
|
-
|
|
126
|
-
this.component.displayName = capitalizeFirstChar(this.extension.config.name);
|
|
150
|
+
this.component.displayName = capitalizeFirstChar(this.extension.name);
|
|
127
151
|
}
|
|
128
152
|
const ReactNodeViewProvider = componentProps => {
|
|
129
|
-
const [isEditable, setIsEditable] = React.useState(this.editor.isEditable);
|
|
130
153
|
const onDragStart = this.onDragStart.bind(this);
|
|
131
|
-
const
|
|
154
|
+
const maybeMoveContentDOM = this.maybeMoveContentDOM.bind(this);
|
|
132
155
|
const Component = this.component;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return () => {
|
|
136
|
-
this.editor.off('viewUpdate', onViewUpdate);
|
|
137
|
-
};
|
|
138
|
-
}, []);
|
|
139
|
-
return (React__default['default'].createElement(ReactNodeViewContext.Provider, { value: { onDragStart, isEditable } },
|
|
140
|
-
React__default['default'].createElement(Component, Object.assign({}, componentProps))));
|
|
156
|
+
return (React__default['default'].createElement(ReactNodeViewContext.Provider, { value: { onDragStart, maybeMoveContentDOM } },
|
|
157
|
+
React__default['default'].createElement(Component, { ...componentProps })));
|
|
141
158
|
};
|
|
142
159
|
ReactNodeViewProvider.displayName = 'ReactNodeView';
|
|
160
|
+
this.contentDOMElement = this.node.isLeaf
|
|
161
|
+
? null
|
|
162
|
+
: document.createElement(this.node.isInline ? 'span' : 'div');
|
|
163
|
+
if (this.contentDOMElement) {
|
|
164
|
+
// For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
|
|
165
|
+
// With this fix it seems to work fine
|
|
166
|
+
// See: https://github.com/ueberdosis/tiptap/issues/1197
|
|
167
|
+
this.contentDOMElement.style.whiteSpace = 'inherit';
|
|
168
|
+
}
|
|
143
169
|
this.renderer = new ReactRenderer(ReactNodeViewProvider, {
|
|
144
170
|
editor: this.editor,
|
|
145
171
|
props,
|
|
172
|
+
as: this.node.isInline
|
|
173
|
+
? 'span'
|
|
174
|
+
: 'div',
|
|
146
175
|
});
|
|
147
176
|
}
|
|
148
177
|
get dom() {
|
|
149
178
|
var _a;
|
|
150
|
-
if (
|
|
151
|
-
|
|
179
|
+
if (this.renderer.element.firstElementChild
|
|
180
|
+
&& !((_a = this.renderer.element.firstElementChild) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-node-view-wrapper'))) {
|
|
181
|
+
throw Error('Please use the NodeViewWrapper component for your node view.');
|
|
152
182
|
}
|
|
153
183
|
return this.renderer.element;
|
|
154
184
|
}
|
|
@@ -156,12 +186,34 @@
|
|
|
156
186
|
if (this.node.isLeaf) {
|
|
157
187
|
return null;
|
|
158
188
|
}
|
|
189
|
+
this.maybeMoveContentDOM();
|
|
190
|
+
return this.contentDOMElement;
|
|
191
|
+
}
|
|
192
|
+
maybeMoveContentDOM() {
|
|
159
193
|
const contentElement = this.dom.querySelector('[data-node-view-content]');
|
|
160
|
-
|
|
194
|
+
if (this.contentDOMElement
|
|
195
|
+
&& contentElement
|
|
196
|
+
&& !contentElement.contains(this.contentDOMElement)) {
|
|
197
|
+
contentElement.appendChild(this.contentDOMElement);
|
|
198
|
+
}
|
|
161
199
|
}
|
|
162
200
|
update(node, decorations) {
|
|
201
|
+
const updateProps = (props) => {
|
|
202
|
+
this.renderer.updateProps(props);
|
|
203
|
+
this.maybeMoveContentDOM();
|
|
204
|
+
};
|
|
163
205
|
if (typeof this.options.update === 'function') {
|
|
164
|
-
|
|
206
|
+
const oldNode = this.node;
|
|
207
|
+
const oldDecorations = this.decorations;
|
|
208
|
+
this.node = node;
|
|
209
|
+
this.decorations = decorations;
|
|
210
|
+
return this.options.update({
|
|
211
|
+
oldNode,
|
|
212
|
+
oldDecorations,
|
|
213
|
+
newNode: node,
|
|
214
|
+
newDecorations: decorations,
|
|
215
|
+
updateProps: () => updateProps({ node, decorations }),
|
|
216
|
+
});
|
|
165
217
|
}
|
|
166
218
|
if (node.type !== this.node.type) {
|
|
167
219
|
return false;
|
|
@@ -171,7 +223,7 @@
|
|
|
171
223
|
}
|
|
172
224
|
this.node = node;
|
|
173
225
|
this.decorations = decorations;
|
|
174
|
-
|
|
226
|
+
updateProps({ node, decorations });
|
|
175
227
|
return true;
|
|
176
228
|
}
|
|
177
229
|
selectNode() {
|
|
@@ -186,6 +238,7 @@
|
|
|
186
238
|
}
|
|
187
239
|
destroy() {
|
|
188
240
|
this.renderer.destroy();
|
|
241
|
+
this.contentDOMElement = null;
|
|
189
242
|
}
|
|
190
243
|
}
|
|
191
244
|
function ReactNodeViewRenderer(component, options) {
|
|
@@ -226,13 +279,12 @@
|
|
|
226
279
|
return;
|
|
227
280
|
}
|
|
228
281
|
const element = this.editorContentRef.current;
|
|
229
|
-
element.
|
|
282
|
+
element.append(...editor.options.element.childNodes);
|
|
230
283
|
editor.setOptions({
|
|
231
284
|
element,
|
|
232
285
|
});
|
|
233
286
|
editor.contentComponent = this;
|
|
234
|
-
|
|
235
|
-
setTimeout(() => editor.createNodeViews(), 0);
|
|
287
|
+
editor.createNodeViews();
|
|
236
288
|
}
|
|
237
289
|
}
|
|
238
290
|
componentWillUnmount() {
|
|
@@ -250,34 +302,45 @@
|
|
|
250
302
|
return;
|
|
251
303
|
}
|
|
252
304
|
const newElement = document.createElement('div');
|
|
253
|
-
newElement.
|
|
305
|
+
newElement.append(...editor.options.element.childNodes);
|
|
254
306
|
editor.setOptions({
|
|
255
307
|
element: newElement,
|
|
256
308
|
});
|
|
257
309
|
}
|
|
258
310
|
render() {
|
|
311
|
+
const { editor, ...rest } = this.props;
|
|
259
312
|
return (React__default['default'].createElement(React__default['default'].Fragment, null,
|
|
260
|
-
React__default['default'].createElement("div", { ref: this.editorContentRef }),
|
|
313
|
+
React__default['default'].createElement("div", { ref: this.editorContentRef, ...rest }),
|
|
261
314
|
React__default['default'].createElement(Portals, { renderers: this.state.renderers })));
|
|
262
315
|
}
|
|
263
316
|
}
|
|
264
317
|
const EditorContent = React__default['default'].memo(PureEditorContent);
|
|
265
318
|
|
|
266
|
-
const NodeViewWrapper = props => {
|
|
319
|
+
const NodeViewWrapper = React__default['default'].forwardRef((props, ref) => {
|
|
267
320
|
const { onDragStart } = useReactNodeView();
|
|
268
321
|
const Tag = props.as || 'div';
|
|
269
|
-
return (React__default['default'].createElement(Tag, {
|
|
270
|
-
|
|
322
|
+
return (React__default['default'].createElement(Tag, { ...props, ref: ref, "data-node-view-wrapper": "", onDragStart: onDragStart, style: {
|
|
323
|
+
...props.style,
|
|
324
|
+
whiteSpace: 'normal',
|
|
325
|
+
} }));
|
|
326
|
+
});
|
|
271
327
|
|
|
272
|
-
const NodeViewContent = props => {
|
|
273
|
-
const { isEditable } = useReactNodeView();
|
|
328
|
+
const NodeViewContent = React__default['default'].forwardRef((props, ref) => {
|
|
274
329
|
const Tag = props.as || 'div';
|
|
275
|
-
|
|
276
|
-
|
|
330
|
+
const { maybeMoveContentDOM } = useReactNodeView();
|
|
331
|
+
React.useEffect(() => {
|
|
332
|
+
maybeMoveContentDOM === null || maybeMoveContentDOM === void 0 ? void 0 : maybeMoveContentDOM();
|
|
333
|
+
}, []);
|
|
334
|
+
return (React__default['default'].createElement(Tag, { ...props, ref: ref, "data-node-view-content": "", style: {
|
|
335
|
+
...props.style,
|
|
336
|
+
whiteSpace: 'pre-wrap',
|
|
337
|
+
} }));
|
|
338
|
+
});
|
|
277
339
|
|
|
278
340
|
exports.BubbleMenu = BubbleMenu;
|
|
279
341
|
exports.Editor = Editor;
|
|
280
342
|
exports.EditorContent = EditorContent;
|
|
343
|
+
exports.FloatingMenu = FloatingMenu;
|
|
281
344
|
exports.NodeViewContent = NodeViewContent;
|
|
282
345
|
exports.NodeViewWrapper = NodeViewWrapper;
|
|
283
346
|
exports.PureEditorContent = PureEditorContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-react.umd.js","sources":["../src/BubbleMenu.tsx","../src/Editor.ts","../src/useEditor.ts","../src/ReactRenderer.tsx","../src/useReactNodeView.ts","../src/ReactNodeViewRenderer.tsx","../src/EditorContent.tsx","../src/NodeViewWrapper.tsx","../src/NodeViewContent.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport { BubbleMenuPlugin, BubbleMenuPluginKey, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\n\nexport type BubbleMenuProps = Omit<BubbleMenuPluginProps, 'element'> & {\n className?: string,\n}\n\nexport const BubbleMenu: React.FC<BubbleMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n const { editor, keepInBounds = true } = props\n\n editor.registerPlugin(BubbleMenuPlugin({\n editor,\n element: element.current as HTMLElement,\n keepInBounds,\n }))\n\n return () => {\n editor.unregisterPlugin(BubbleMenuPluginKey)\n }\n }, [])\n\n return (\n <div ref={element} className={props.className}>\n {props.children}\n </div>\n )\n}\n","import React from 'react'\nimport { Editor as CoreEditor } from '@tiptap/core'\nimport { EditorContentProps, EditorContentState } from './EditorContent'\n\nexport class Editor extends CoreEditor {\n public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null\n}\n","import { useState, useEffect } from 'react'\nimport { EditorOptions } from '@tiptap/core'\nimport { Editor } from './Editor'\n\nfunction useForceUpdate() {\n const [, setValue] = useState(0)\n\n return () => setValue(value => value + 1)\n}\n\nexport const useEditor = (options: Partial<EditorOptions> = {}) => {\n const [editor, setEditor] = useState<Editor | null>(null)\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n const instance = new Editor(options)\n\n setEditor(instance)\n\n instance.on('transaction', forceUpdate)\n\n return () => {\n instance.destroy()\n }\n }, [])\n\n return editor\n}\n","import React from 'react'\nimport { AnyObject } from '@tiptap/core'\nimport { Editor } from './Editor'\n\nfunction isClassComponent(Component: any) {\n return !!(\n typeof Component === 'function'\n && Component.prototype\n && Component.prototype.isReactComponent\n )\n}\n\nexport interface ReactRendererOptions {\n as?: string,\n editor: Editor,\n props?: AnyObject,\n}\n\nexport class ReactRenderer {\n id: string\n\n editor: Editor\n\n component: any\n\n element: Element\n\n props: AnyObject\n\n reactElement: React.ReactNode\n\n ref: React.Component | null = null\n\n constructor(component: React.Component | React.FunctionComponent, { props = {}, editor }: ReactRendererOptions) {\n this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString()\n this.component = component\n this.editor = editor\n this.props = props\n this.element = document.createElement('div')\n this.element.classList.add('react-renderer')\n this.render()\n }\n\n render(): void {\n const Component = this.component\n const props = this.props\n\n if (isClassComponent(Component)) {\n props.ref = (ref: React.Component) => {\n this.ref = ref\n }\n }\n\n this.reactElement = <Component {...props } />\n\n if (this.editor?.contentComponent) {\n this.editor.contentComponent.setState({\n renderers: this.editor.contentComponent.state.renderers.set(\n this.id,\n this,\n ),\n })\n }\n }\n\n updateProps(props: AnyObject = {}): void {\n this.props = {\n ...this.props,\n ...props,\n }\n\n this.render()\n }\n\n destroy(): void {\n if (this.editor?.contentComponent) {\n const { renderers } = this.editor.contentComponent.state\n\n renderers.delete(this.id)\n\n this.editor.contentComponent.setState({\n renderers,\n })\n }\n }\n}\n","import { createContext, useContext } from 'react'\n\nexport interface ReactNodeViewContextProps {\n isEditable: boolean,\n onDragStart: (event: DragEvent) => void,\n}\n\nexport const ReactNodeViewContext = createContext<Partial<ReactNodeViewContextProps>>({\n isEditable: undefined,\n onDragStart: undefined,\n})\n\nexport const useReactNodeView = () => useContext(ReactNodeViewContext)\n","import React, { useState, useEffect } from 'react'\nimport {\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererProps,\n} from '@tiptap/core'\nimport { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\nimport { ReactNodeViewContext } from './useReactNodeView'\n\ninterface ReactNodeViewRendererOptions {\n stopEvent: ((event: Event) => boolean) | null,\n update: ((node: ProseMirrorNode, decorations: Decoration[]) => boolean) | null,\n}\n\nclass ReactNodeView extends NodeView<React.FunctionComponent, Editor> {\n\n renderer!: ReactRenderer\n\n mount() {\n const props: NodeViewProps = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations,\n selected: false,\n extension: this.extension,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n }\n\n if (!(this.component as any).displayName) {\n const capitalizeFirstChar = (string: string): string => {\n return string.charAt(0).toUpperCase() + string.substring(1)\n }\n\n // @ts-ignore\n this.component.displayName = capitalizeFirstChar(this.extension.config.name)\n }\n\n const ReactNodeViewProvider: React.FunctionComponent = componentProps => {\n const [isEditable, setIsEditable] = useState(this.editor.isEditable)\n const onDragStart = this.onDragStart.bind(this)\n const onViewUpdate = () => setIsEditable(this.editor.isEditable)\n const Component = this.component\n\n useEffect(() => {\n this.editor.on('viewUpdate', onViewUpdate)\n\n return () => {\n this.editor.off('viewUpdate', onViewUpdate)\n }\n }, [])\n\n return (\n <ReactNodeViewContext.Provider value={{ onDragStart, isEditable }}>\n <Component {...componentProps} />\n </ReactNodeViewContext.Provider>\n )\n }\n\n ReactNodeViewProvider.displayName = 'ReactNodeView'\n\n this.renderer = new ReactRenderer(ReactNodeViewProvider, {\n editor: this.editor,\n props,\n })\n }\n\n get dom() {\n if (!this.renderer.element.firstElementChild?.hasAttribute('data-node-view-wrapper')) {\n throw Error('Please use the ReactViewWrapper component for your node view.')\n }\n\n return this.renderer.element\n }\n\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n const contentElement = this.dom.querySelector('[data-node-view-content]')\n\n return contentElement || this.dom\n }\n\n update(node: ProseMirrorNode, decorations: Decoration[]) {\n if (typeof this.options.update === 'function') {\n return this.options.update(node, decorations)\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (node === this.node && this.decorations === decorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n this.renderer.updateProps({ node, decorations })\n\n return true\n }\n\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n }\n\n destroy() {\n this.renderer.destroy()\n }\n}\n\nexport function ReactNodeViewRenderer(component: any, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer {\n return (props: NodeViewRendererProps) => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {}\n }\n\n return new ReactNodeView(component, props, options) as ProseMirrorNodeView\n }\n}\n","import React from 'react'\nimport ReactDOM from 'react-dom'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\n\nconst Portals: React.FC<{ renderers: Map<string, ReactRenderer> }> = ({ renderers }) => {\n return (\n <>\n {Array.from(renderers).map(([key, renderer]) => {\n return ReactDOM.createPortal(\n renderer.reactElement,\n renderer.element,\n key,\n )\n })}\n </>\n )\n}\n\nexport interface EditorContentProps {\n editor: Editor | null,\n}\n\nexport interface EditorContentState {\n renderers: Map<string, ReactRenderer>\n}\n\nexport class PureEditorContent extends React.Component<EditorContentProps, EditorContentState> {\n editorContentRef: React.RefObject<any>\n\n constructor(props: EditorContentProps) {\n super(props)\n this.editorContentRef = React.createRef()\n\n this.state = {\n renderers: new Map(),\n }\n }\n\n componentDidMount() {\n this.init()\n }\n\n componentDidUpdate() {\n this.init()\n }\n\n init() {\n const { editor } = this.props\n\n if (editor && editor.options.element) {\n if (editor.contentComponent) {\n return\n }\n\n const element = this.editorContentRef.current\n\n element.appendChild(editor.options.element.firstChild)\n\n editor.setOptions({\n element,\n })\n\n editor.contentComponent = this\n\n // TODO: alternative to setTimeout?\n setTimeout(() => editor.createNodeViews(), 0)\n }\n }\n\n componentWillUnmount() {\n const { editor } = this.props\n\n if (!editor) {\n return\n }\n\n if (!editor.isDestroyed) {\n editor.view.setProps({\n nodeViews: {},\n })\n }\n\n editor.contentComponent = null\n\n if (!editor.options.element.firstChild) {\n return\n }\n\n const newElement = document.createElement('div')\n\n newElement.appendChild(editor.options.element.firstChild)\n\n editor.setOptions({\n element: newElement,\n })\n }\n\n render() {\n return (\n <>\n <div ref={this.editorContentRef} />\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\nexport const EditorContent = React.memo(PureEditorContent)\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewWrapperProps {\n className?: string,\n as: React.ElementType,\n}\n\nexport const NodeViewWrapper: React.FC<NodeViewWrapperProps> = props => {\n const { onDragStart } = useReactNodeView()\n const Tag = props.as || 'div'\n\n return (\n <Tag\n className={props.className}\n data-node-view-wrapper=\"\"\n onDragStart={onDragStart}\n style={{ whiteSpace: 'normal' }}\n >\n {props.children}\n </Tag>\n )\n}\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewContentProps {\n className?: string,\n as: React.ElementType,\n}\n\nexport const NodeViewContent: React.FC<NodeViewContentProps> = props => {\n const { isEditable } = useReactNodeView()\n const Tag = props.as || 'div'\n\n return (\n <Tag\n className={props.className}\n data-node-view-content=\"\"\n contentEditable={isEditable}\n style={{ whiteSpace: 'pre-wrap' }}\n />\n )\n}\n"],"names":["useRef","useEffect","BubbleMenuPlugin","BubbleMenuPluginKey","React","CoreEditor","useState","createContext","useContext","NodeView","ReactDOM"],"mappings":";;;;;;;;;;;QAOa,UAAU,GAA8B,KAAK;MACxD,MAAM,OAAO,GAAGA,YAAM,CAAiB,IAAI,CAAC,CAAA;MAE5CC,eAAS,CAAC;UACR,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,GAAG,KAAK,CAAA;UAE7C,MAAM,CAAC,cAAc,CA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MAAM,EAAE,UAAU,EAAE,GAAG,gBAAgB,EAAE,CAAA;MACzC,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;MAE7B,QACEA,wCAAC,GAAG,IACF,SAAS,EAAE,KAAK,CAAC,SAAS,4BACH,EAAE,EACzB,eAAe,EAAE,UAAU,EAC3B,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,GACjC,EACH;EACH;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"tiptap-react.umd.js","sources":["../src/BubbleMenu.tsx","../src/Editor.ts","../src/FloatingMenu.tsx","../src/useEditor.ts","../src/ReactRenderer.tsx","../src/useReactNodeView.ts","../src/ReactNodeViewRenderer.tsx","../src/EditorContent.tsx","../src/NodeViewWrapper.tsx","../src/NodeViewContent.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const BubbleMenu: React.FC<BubbleMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n const {\n pluginKey = 'bubbleMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n editor.registerPlugin(BubbleMenuPlugin({\n pluginKey,\n editor,\n element: element.current as HTMLElement,\n tippyOptions,\n shouldShow,\n }))\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n }\n }, [])\n\n return (\n <div ref={element} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import React from 'react'\nimport { Editor as CoreEditor } from '@tiptap/core'\nimport { EditorContentProps, EditorContentState } from './EditorContent'\n\nexport class Editor extends CoreEditor {\n public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null\n}\n","import React, { useEffect, useRef } from 'react'\nimport { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n editor.registerPlugin(FloatingMenuPlugin({\n pluginKey,\n editor,\n element: element.current as HTMLElement,\n tippyOptions,\n shouldShow,\n }))\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n }\n }, [])\n\n return (\n <div ref={element} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { useState, useEffect, DependencyList } from 'react'\nimport { EditorOptions } from '@tiptap/core'\nimport { Editor } from './Editor'\n\nfunction useForceUpdate() {\n const [, setValue] = useState(0)\n\n return () => setValue(value => value + 1)\n}\n\nexport const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {\n const [editor, setEditor] = useState<Editor | null>(null)\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n const instance = new Editor(options)\n\n setEditor(instance)\n\n instance.on('transaction', forceUpdate)\n\n return () => {\n instance.destroy()\n }\n }, deps)\n\n return editor\n}\n","import React from 'react'\nimport { Editor } from './Editor'\n\nfunction isClassComponent(Component: any) {\n return !!(\n typeof Component === 'function'\n && Component.prototype\n && Component.prototype.isReactComponent\n )\n}\n\nfunction isForwardRefComponent(Component: any) {\n return !!(\n typeof Component === 'object'\n && Component.$$typeof?.toString() === 'Symbol(react.forward_ref)'\n )\n}\n\nexport interface ReactRendererOptions {\n editor: Editor,\n props?: Record<string, any>,\n as?: string,\n}\n\ntype ComponentType =\n | React.ComponentClass\n | React.FunctionComponent\n | React.ForwardRefExoticComponent<{ items: any[], command: any } & React.RefAttributes<unknown>>\n\nexport class ReactRenderer {\n id: string\n\n editor: Editor\n\n component: any\n\n element: Element\n\n props: Record<string, any>\n\n reactElement: React.ReactNode\n\n ref: React.Component | null = null\n\n constructor(component: ComponentType, { editor, props = {}, as = 'div' }: ReactRendererOptions) {\n this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString()\n this.component = component\n this.editor = editor\n this.props = props\n this.element = document.createElement(as)\n this.element.classList.add('react-renderer')\n this.render()\n }\n\n render(): void {\n const Component = this.component\n const props = this.props\n\n if (isClassComponent(Component) || isForwardRefComponent(Component)) {\n props.ref = (ref: React.Component) => {\n this.ref = ref\n }\n }\n\n this.reactElement = <Component {...props } />\n\n if (this.editor?.contentComponent) {\n this.editor.contentComponent.setState({\n renderers: this.editor.contentComponent.state.renderers.set(\n this.id,\n this,\n ),\n })\n }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n this.props = {\n ...this.props,\n ...props,\n }\n\n this.render()\n }\n\n destroy(): void {\n if (this.editor?.contentComponent) {\n const { renderers } = this.editor.contentComponent.state\n\n renderers.delete(this.id)\n\n this.editor.contentComponent.setState({\n renderers,\n })\n }\n }\n}\n","import { createContext, useContext } from 'react'\n\nexport interface ReactNodeViewContextProps {\n onDragStart: (event: DragEvent) => void,\n maybeMoveContentDOM: () => void,\n}\n\nexport const ReactNodeViewContext = createContext<Partial<ReactNodeViewContextProps>>({\n onDragStart: undefined,\n})\n\nexport const useReactNodeView = () => useContext(ReactNodeViewContext)\n","import React from 'react'\nimport {\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererProps,\n NodeViewRendererOptions,\n} from '@tiptap/core'\nimport { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\nimport { ReactNodeViewContext } from './useReactNodeView'\n\nexport interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {\n update: ((props: {\n oldNode: ProseMirrorNode,\n oldDecorations: Decoration[],\n newNode: ProseMirrorNode,\n newDecorations: Decoration[],\n updateProps: () => void,\n }) => boolean) | null,\n}\n\nclass ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeViewRendererOptions> {\n\n renderer!: ReactRenderer\n\n contentDOMElement!: HTMLElement | null\n\n mount() {\n const props: NodeViewProps = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations,\n selected: false,\n extension: this.extension,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n deleteNode: () => this.deleteNode(),\n }\n\n if (!(this.component as any).displayName) {\n const capitalizeFirstChar = (string: string): string => {\n return string.charAt(0).toUpperCase() + string.substring(1)\n }\n\n this.component.displayName = capitalizeFirstChar(this.extension.name)\n }\n\n const ReactNodeViewProvider: React.FunctionComponent = componentProps => {\n const onDragStart = this.onDragStart.bind(this)\n const maybeMoveContentDOM = this.maybeMoveContentDOM.bind(this)\n const Component = this.component\n\n return (\n <ReactNodeViewContext.Provider value={{ onDragStart, maybeMoveContentDOM }}>\n <Component {...componentProps} />\n </ReactNodeViewContext.Provider>\n )\n }\n\n ReactNodeViewProvider.displayName = 'ReactNodeView'\n\n this.contentDOMElement = this.node.isLeaf\n ? null\n : document.createElement(this.node.isInline ? 'span' : 'div')\n\n if (this.contentDOMElement) {\n // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari\n // With this fix it seems to work fine\n // See: https://github.com/ueberdosis/tiptap/issues/1197\n this.contentDOMElement.style.whiteSpace = 'inherit'\n }\n\n this.renderer = new ReactRenderer(ReactNodeViewProvider, {\n editor: this.editor,\n props,\n as: this.node.isInline\n ? 'span'\n : 'div',\n })\n }\n\n get dom() {\n if (\n this.renderer.element.firstElementChild\n && !this.renderer.element.firstElementChild?.hasAttribute('data-node-view-wrapper')\n ) {\n throw Error('Please use the NodeViewWrapper component for your node view.')\n }\n\n return this.renderer.element\n }\n\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n this.maybeMoveContentDOM()\n\n return this.contentDOMElement\n }\n\n maybeMoveContentDOM(): void {\n const contentElement = this.dom.querySelector('[data-node-view-content]')\n\n if (\n this.contentDOMElement\n && contentElement\n && !contentElement.contains(this.contentDOMElement)\n ) {\n contentElement.appendChild(this.contentDOMElement)\n }\n }\n\n update(node: ProseMirrorNode, decorations: Decoration[]) {\n const updateProps = (props?: Record<string, any>) => {\n this.renderer.updateProps(props)\n this.maybeMoveContentDOM()\n }\n\n if (typeof this.options.update === 'function') {\n const oldNode = this.node\n const oldDecorations = this.decorations\n\n this.node = node\n this.decorations = decorations\n\n return this.options.update({\n oldNode,\n oldDecorations,\n newNode: node,\n newDecorations: decorations,\n updateProps: () => updateProps({ node, decorations }),\n })\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (node === this.node && this.decorations === decorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n\n updateProps({ node, decorations })\n\n return true\n }\n\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n }\n\n destroy() {\n this.renderer.destroy()\n this.contentDOMElement = null\n }\n}\n\nexport function ReactNodeViewRenderer(component: any, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer {\n return (props: NodeViewRendererProps) => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {}\n }\n\n return new ReactNodeView(component, props, options) as ProseMirrorNodeView\n }\n}\n","import React, { HTMLProps } from 'react'\nimport ReactDOM from 'react-dom'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\n\nconst Portals: React.FC<{ renderers: Map<string, ReactRenderer> }> = ({ renderers }) => {\n return (\n <>\n {Array.from(renderers).map(([key, renderer]) => {\n return ReactDOM.createPortal(\n renderer.reactElement,\n renderer.element,\n key,\n )\n })}\n </>\n )\n}\n\nexport interface EditorContentProps extends HTMLProps<HTMLDivElement> {\n editor: Editor | null,\n}\n\nexport interface EditorContentState {\n renderers: Map<string, ReactRenderer>\n}\n\nexport class PureEditorContent extends React.Component<EditorContentProps, EditorContentState> {\n editorContentRef: React.RefObject<any>\n\n constructor(props: EditorContentProps) {\n super(props)\n this.editorContentRef = React.createRef()\n\n this.state = {\n renderers: new Map(),\n }\n }\n\n componentDidMount() {\n this.init()\n }\n\n componentDidUpdate() {\n this.init()\n }\n\n init() {\n const { editor } = this.props\n\n if (editor && editor.options.element) {\n if (editor.contentComponent) {\n return\n }\n\n const element = this.editorContentRef.current\n\n element.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element,\n })\n\n editor.contentComponent = this\n\n editor.createNodeViews()\n }\n }\n\n componentWillUnmount() {\n const { editor } = this.props\n\n if (!editor) {\n return\n }\n\n if (!editor.isDestroyed) {\n editor.view.setProps({\n nodeViews: {},\n })\n }\n\n editor.contentComponent = null\n\n if (!editor.options.element.firstChild) {\n return\n }\n\n const newElement = document.createElement('div')\n\n newElement.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element: newElement,\n })\n }\n\n render() {\n const { editor, ...rest } = this.props\n\n return (\n <>\n <div ref={this.editorContentRef} {...rest} />\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\nexport const EditorContent = React.memo(PureEditorContent)\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewWrapperProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewWrapper: React.FC<NodeViewWrapperProps> = React.forwardRef((props, ref) => {\n const { onDragStart } = useReactNodeView()\n const Tag = props.as || 'div'\n\n return (\n <Tag\n {...props}\n ref={ref}\n data-node-view-wrapper=\"\"\n onDragStart={onDragStart}\n style={{\n ...props.style,\n whiteSpace: 'normal',\n }}\n />\n )\n})\n","import React, { useEffect } from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewContentProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewContent: React.FC<NodeViewContentProps> = React.forwardRef((props, ref) => {\n const Tag = props.as || 'div'\n const { maybeMoveContentDOM } = useReactNodeView()\n\n useEffect(() => {\n maybeMoveContentDOM?.()\n }, [])\n\n return (\n <Tag\n {...props}\n ref={ref}\n data-node-view-content=\"\"\n style={{\n ...props.style,\n whiteSpace: 'pre-wrap',\n }}\n />\n )\n})\n"],"names":["useRef","useEffect","BubbleMenuPlugin","React","CoreEditor","FloatingMenuPlugin","useState","createContext","useContext","NodeView","ReactDOM"],"mappings":";;;;;;;;;;;QASa,UAAU,GAA8B,KAAK;MACxD,MAAM,OAAO,GAAGA,YAAM,CAAiB,IAAI,CAAC,CAAA;MAE5CC,eAAS,CAAC;UACR,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,GAClB,GAAG,KAAK,CAAA;UAET,MAAM,CAAC,cAAc,CAACC,oCAAgB,CAAC;cACrC,SAAS;cACT,MAAM;cACN,OAAO,EAAE,OAAO,CAAC,OAAsB;cACvC,YAAY;cACZ,UAAU;WACX,CAAC,CAAC,CAAA;UAEH,OAAO;cACL,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;WACnC,CAAA;OACF,EAAE,EAAE,CAAC,CAAA;MAEN,QACEC,iDAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,IAC3E,KAAK,CAAC,QAAQ,CACX,EACP;EACH;;QClCa,MAAO,SAAQC,WAAU;MAAtC;;UACS,qBAAgB,GAAmE,IAAI,CAAA;OAC/F;;;QCGY,YAAY,GAAgC,KAAK;MAC5D,MAAM,OAAO,GAAGJ,YAAM,CAAiB,IAAI,CAAC,CAAA;MAE5CC,eAAS,CAAC;UACR,M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,UAAU,EAAE,QAAQ;WACrB,GACD,EACH;EACH,CAAC;;QChBY,eAAe,GAAmCA,yBAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG;MACzF,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;MAC7B,MAAM,EAAE,mBAAmB,EAAE,GAAG,gBAAgB,EAAE,CAAA;MAElDF,eAAS,CAAC;UACR,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,EAAI,CAAA;OACxB,EAAE,EAAE,CAAC,CAAA;MAEN,QACEE,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,GAAG,4BACe,EAAE,EACzB,KAAK,EAAE;cACL,GAAG,KAAK,CAAC,KAAK;cACd,UAAU,EAAE,UAAU;WACvB,GACD,EACH;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/react",
|
|
3
3
|
"description": "React components for tiptap",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.70",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,23 +15,31 @@
|
|
|
15
15
|
"main": "dist/tiptap-react.cjs.js",
|
|
16
16
|
"umd": "dist/tiptap-react.umd.js",
|
|
17
17
|
"module": "dist/tiptap-react.esm.js",
|
|
18
|
-
"unpkg": "dist/tiptap-react.bundle.umd.min.js",
|
|
19
18
|
"types": "dist/packages/react/src/index.d.ts",
|
|
20
19
|
"files": [
|
|
21
20
|
"src",
|
|
22
21
|
"dist"
|
|
23
22
|
],
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/react": "^17.0.23",
|
|
25
|
+
"@types/react-dom": "^17.0.7",
|
|
26
|
+
"react": "^17.0.0",
|
|
27
|
+
"react-dom": "^17.0.0"
|
|
28
|
+
},
|
|
24
29
|
"peerDependencies": {
|
|
25
30
|
"@tiptap/core": "^2.0.0-beta.1",
|
|
26
|
-
"react": "^17.0.
|
|
27
|
-
"react-dom": "^17.0.
|
|
31
|
+
"react": "^17.0.0",
|
|
32
|
+
"react-dom": "^17.0.0"
|
|
28
33
|
},
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"@tiptap/extension-bubble-menu": "^2.0.0-beta.
|
|
31
|
-
"
|
|
35
|
+
"@tiptap/extension-bubble-menu": "^2.0.0-beta.34",
|
|
36
|
+
"@tiptap/extension-floating-menu": "^2.0.0-beta.28",
|
|
37
|
+
"prosemirror-view": "^1.20.1"
|
|
32
38
|
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/ueberdosis/tiptap",
|
|
42
|
+
"directory": "packages/react"
|
|
35
43
|
},
|
|
36
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "41dddb0fcded5c03b4d629c003f85d015da5c6ce"
|
|
37
45
|
}
|
package/src/BubbleMenu.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react'
|
|
2
|
-
import { BubbleMenuPlugin,
|
|
2
|
+
import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
|
5
|
+
|
|
6
|
+
export type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {
|
|
5
7
|
className?: string,
|
|
6
8
|
}
|
|
7
9
|
|
|
@@ -9,21 +11,28 @@ export const BubbleMenu: React.FC<BubbleMenuProps> = props => {
|
|
|
9
11
|
const element = useRef<HTMLDivElement>(null)
|
|
10
12
|
|
|
11
13
|
useEffect(() => {
|
|
12
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
pluginKey = 'bubbleMenu',
|
|
16
|
+
editor,
|
|
17
|
+
tippyOptions = {},
|
|
18
|
+
shouldShow = null,
|
|
19
|
+
} = props
|
|
13
20
|
|
|
14
21
|
editor.registerPlugin(BubbleMenuPlugin({
|
|
22
|
+
pluginKey,
|
|
15
23
|
editor,
|
|
16
24
|
element: element.current as HTMLElement,
|
|
17
|
-
|
|
25
|
+
tippyOptions,
|
|
26
|
+
shouldShow,
|
|
18
27
|
}))
|
|
19
28
|
|
|
20
29
|
return () => {
|
|
21
|
-
editor.unregisterPlugin(
|
|
30
|
+
editor.unregisterPlugin(pluginKey)
|
|
22
31
|
}
|
|
23
32
|
}, [])
|
|
24
33
|
|
|
25
34
|
return (
|
|
26
|
-
<div ref={element} className={props.className}>
|
|
35
|
+
<div ref={element} className={props.className} style={{ visibility: 'hidden' }}>
|
|
27
36
|
{props.children}
|
|
28
37
|
</div>
|
|
29
38
|
)
|
package/src/EditorContent.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { HTMLProps } from 'react'
|
|
2
2
|
import ReactDOM from 'react-dom'
|
|
3
3
|
import { Editor } from './Editor'
|
|
4
4
|
import { ReactRenderer } from './ReactRenderer'
|
|
@@ -17,7 +17,7 @@ const Portals: React.FC<{ renderers: Map<string, ReactRenderer> }> = ({ renderer
|
|
|
17
17
|
)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export interface EditorContentProps {
|
|
20
|
+
export interface EditorContentProps extends HTMLProps<HTMLDivElement> {
|
|
21
21
|
editor: Editor | null,
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -55,7 +55,7 @@ export class PureEditorContent extends React.Component<EditorContentProps, Edito
|
|
|
55
55
|
|
|
56
56
|
const element = this.editorContentRef.current
|
|
57
57
|
|
|
58
|
-
element.
|
|
58
|
+
element.append(...editor.options.element.childNodes)
|
|
59
59
|
|
|
60
60
|
editor.setOptions({
|
|
61
61
|
element,
|
|
@@ -63,8 +63,7 @@ export class PureEditorContent extends React.Component<EditorContentProps, Edito
|
|
|
63
63
|
|
|
64
64
|
editor.contentComponent = this
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
setTimeout(() => editor.createNodeViews(), 0)
|
|
66
|
+
editor.createNodeViews()
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
@@ -89,7 +88,7 @@ export class PureEditorContent extends React.Component<EditorContentProps, Edito
|
|
|
89
88
|
|
|
90
89
|
const newElement = document.createElement('div')
|
|
91
90
|
|
|
92
|
-
newElement.
|
|
91
|
+
newElement.append(...editor.options.element.childNodes)
|
|
93
92
|
|
|
94
93
|
editor.setOptions({
|
|
95
94
|
element: newElement,
|
|
@@ -97,9 +96,11 @@ export class PureEditorContent extends React.Component<EditorContentProps, Edito
|
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
render() {
|
|
99
|
+
const { editor, ...rest } = this.props
|
|
100
|
+
|
|
100
101
|
return (
|
|
101
102
|
<>
|
|
102
|
-
<div ref={this.editorContentRef} />
|
|
103
|
+
<div ref={this.editorContentRef} {...rest} />
|
|
103
104
|
<Portals renderers={this.state.renderers} />
|
|
104
105
|
</>
|
|
105
106
|
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react'
|
|
2
|
+
import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'
|
|
3
|
+
|
|
4
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
|
5
|
+
|
|
6
|
+
export type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey'>, 'element'> & {
|
|
7
|
+
className?: string,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const FloatingMenu: React.FC<FloatingMenuProps> = props => {
|
|
11
|
+
const element = useRef<HTMLDivElement>(null)
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const {
|
|
15
|
+
pluginKey = 'floatingMenu',
|
|
16
|
+
editor,
|
|
17
|
+
tippyOptions = {},
|
|
18
|
+
shouldShow = null,
|
|
19
|
+
} = props
|
|
20
|
+
|
|
21
|
+
editor.registerPlugin(FloatingMenuPlugin({
|
|
22
|
+
pluginKey,
|
|
23
|
+
editor,
|
|
24
|
+
element: element.current as HTMLElement,
|
|
25
|
+
tippyOptions,
|
|
26
|
+
shouldShow,
|
|
27
|
+
}))
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
editor.unregisterPlugin(pluginKey)
|
|
31
|
+
}
|
|
32
|
+
}, [])
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div ref={element} className={props.className} style={{ visibility: 'hidden' }}>
|
|
36
|
+
{props.children}
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
package/src/NodeViewContent.tsx
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
2
|
import { useReactNodeView } from './useReactNodeView'
|
|
3
3
|
|
|
4
4
|
export interface NodeViewContentProps {
|
|
5
|
-
|
|
6
|
-
as
|
|
5
|
+
[key: string]: any,
|
|
6
|
+
as?: React.ElementType,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const NodeViewContent: React.FC<NodeViewContentProps> = props => {
|
|
10
|
-
const { isEditable } = useReactNodeView()
|
|
9
|
+
export const NodeViewContent: React.FC<NodeViewContentProps> = React.forwardRef((props, ref) => {
|
|
11
10
|
const Tag = props.as || 'div'
|
|
11
|
+
const { maybeMoveContentDOM } = useReactNodeView()
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
maybeMoveContentDOM?.()
|
|
15
|
+
}, [])
|
|
12
16
|
|
|
13
17
|
return (
|
|
14
18
|
<Tag
|
|
15
|
-
|
|
19
|
+
{...props}
|
|
20
|
+
ref={ref}
|
|
16
21
|
data-node-view-content=""
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
style={{
|
|
23
|
+
...props.style,
|
|
24
|
+
whiteSpace: 'pre-wrap',
|
|
25
|
+
}}
|
|
19
26
|
/>
|
|
20
27
|
)
|
|
21
|
-
}
|
|
28
|
+
})
|