@tiptap/react 2.0.0-beta.2 → 2.0.0-beta.200
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 +2 -2
- package/dist/packages/react/src/BubbleMenu.d.ts +9 -0
- package/dist/packages/react/src/Editor.d.ts +3 -2
- package/dist/packages/react/src/EditorContent.d.ts +11 -5
- package/dist/packages/react/src/FloatingMenu.d.ts +9 -0
- package/dist/packages/react/src/NodeViewContent.d.ts +6 -0
- package/dist/packages/react/src/NodeViewWrapper.d.ts +6 -0
- package/dist/packages/react/src/ReactNodeViewRenderer.d.ts +15 -0
- package/dist/packages/react/src/ReactRenderer.d.ts +24 -0
- package/dist/packages/react/src/index.d.ts +8 -2
- package/dist/packages/react/src/useEditor.d.ts +2 -1
- package/dist/packages/react/src/useReactNodeView.d.ts +7 -0
- package/dist/tiptap-react.cjs.js +346 -32
- package/dist/tiptap-react.cjs.js.map +1 -1
- package/dist/tiptap-react.esm.js +337 -28
- package/dist/tiptap-react.esm.js.map +1 -1
- package/dist/tiptap-react.umd.js +347 -36
- package/dist/tiptap-react.umd.js.map +1 -1
- package/package.json +18 -9
- package/src/BubbleMenu.tsx +52 -0
- package/src/Editor.ts +4 -2
- package/src/EditorContent.tsx +75 -12
- package/src/FloatingMenu.tsx +52 -0
- package/src/NodeViewContent.tsx +25 -0
- package/src/NodeViewWrapper.tsx +26 -0
- package/src/ReactNodeViewRenderer.tsx +192 -0
- package/src/ReactRenderer.tsx +119 -0
- package/src/index.ts +8 -5
- package/src/useEditor.ts +16 -4
- package/src/useReactNodeView.ts +12 -0
- package/CHANGELOG.md +0 -24
- package/LICENSE.md +0 -21
- package/dist/tiptap-react.bundle.umd.min.js +0 -15
- package/dist/tiptap-react.bundle.umd.min.js.map +0 -1
- package/src/ReactNodeViewRenderer.ts +0 -208
- package/src/ReactRenderer.ts +0 -58
package/dist/tiptap-react.umd.js
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('react')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'react'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global[
|
|
5
|
-
}(this, (function (exports, core,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/extension-bubble-menu'), require('react'), require('@tiptap/core'), require('react-dom'), require('@tiptap/extension-floating-menu')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/extension-bubble-menu', 'react', '@tiptap/core', 'react-dom', '@tiptap/extension-floating-menu'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/react"] = {}, global.extensionBubbleMenu, global.React, global.core, global.ReactDOM, global.extensionFloatingMenu));
|
|
5
|
+
})(this, (function (exports, extensionBubbleMenu, React, core, ReactDOM, extensionFloatingMenu) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
11
|
+
|
|
12
|
+
const BubbleMenu = (props) => {
|
|
13
|
+
const [element, setElement] = React.useState(null);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
if (!element) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (props.editor.isDestroyed) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const { pluginKey = 'bubbleMenu', editor, tippyOptions = {}, shouldShow = null, } = props;
|
|
22
|
+
const plugin = extensionBubbleMenu.BubbleMenuPlugin({
|
|
23
|
+
pluginKey,
|
|
24
|
+
editor,
|
|
25
|
+
element,
|
|
26
|
+
tippyOptions,
|
|
27
|
+
shouldShow,
|
|
28
|
+
});
|
|
29
|
+
editor.registerPlugin(plugin);
|
|
30
|
+
return () => editor.unregisterPlugin(pluginKey);
|
|
31
|
+
}, [
|
|
32
|
+
props.editor,
|
|
33
|
+
element,
|
|
34
|
+
]);
|
|
35
|
+
return (React__default["default"].createElement("div", { ref: setElement, className: props.className, style: { visibility: 'hidden' } }, props.children));
|
|
36
|
+
};
|
|
10
37
|
|
|
11
38
|
class Editor extends core.Editor {
|
|
12
39
|
constructor() {
|
|
@@ -15,67 +42,351 @@
|
|
|
15
42
|
}
|
|
16
43
|
}
|
|
17
44
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const forceUpdate = useForceUpdate();
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
const instance = new Editor(options);
|
|
27
|
-
setEditor(instance);
|
|
28
|
-
instance.on('transaction', forceUpdate);
|
|
29
|
-
return () => {
|
|
30
|
-
instance.destroy();
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
return editor;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
class PureEditorContent extends React__default['default'].Component {
|
|
45
|
+
const Portals = ({ renderers }) => {
|
|
46
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, Array.from(renderers).map(([key, renderer]) => {
|
|
47
|
+
return ReactDOM__default["default"].createPortal(renderer.reactElement, renderer.element, key);
|
|
48
|
+
})));
|
|
49
|
+
};
|
|
50
|
+
class PureEditorContent extends React__default["default"].Component {
|
|
37
51
|
constructor(props) {
|
|
38
52
|
super(props);
|
|
39
|
-
this.editorContentRef = React__default[
|
|
53
|
+
this.editorContentRef = React__default["default"].createRef();
|
|
40
54
|
this.state = {
|
|
41
|
-
|
|
55
|
+
renderers: new Map(),
|
|
42
56
|
};
|
|
43
57
|
}
|
|
58
|
+
componentDidMount() {
|
|
59
|
+
this.init();
|
|
60
|
+
}
|
|
44
61
|
componentDidUpdate() {
|
|
62
|
+
this.init();
|
|
63
|
+
}
|
|
64
|
+
init() {
|
|
45
65
|
const { editor } = this.props;
|
|
46
66
|
if (editor && editor.options.element) {
|
|
67
|
+
if (editor.contentComponent) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
47
70
|
const element = this.editorContentRef.current;
|
|
48
|
-
element.
|
|
71
|
+
element.append(...editor.options.element.childNodes);
|
|
49
72
|
editor.setOptions({
|
|
50
73
|
element,
|
|
51
74
|
});
|
|
52
75
|
editor.contentComponent = this;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
editor.createNodeViews();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
componentWillUnmount() {
|
|
80
|
+
const { editor } = this.props;
|
|
81
|
+
if (!editor) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (!editor.isDestroyed) {
|
|
85
|
+
editor.view.setProps({
|
|
86
|
+
nodeViews: {},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
editor.contentComponent = null;
|
|
90
|
+
if (!editor.options.element.firstChild) {
|
|
91
|
+
return;
|
|
57
92
|
}
|
|
93
|
+
const newElement = document.createElement('div');
|
|
94
|
+
newElement.append(...editor.options.element.childNodes);
|
|
95
|
+
editor.setOptions({
|
|
96
|
+
element: newElement,
|
|
97
|
+
});
|
|
58
98
|
}
|
|
59
99
|
render() {
|
|
60
|
-
|
|
100
|
+
const { editor, ...rest } = this.props;
|
|
101
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
102
|
+
React__default["default"].createElement("div", { ref: this.editorContentRef, ...rest }),
|
|
103
|
+
React__default["default"].createElement(Portals, { renderers: this.state.renderers })));
|
|
61
104
|
}
|
|
62
105
|
}
|
|
63
|
-
const EditorContent = React__default[
|
|
106
|
+
const EditorContent = React__default["default"].memo(PureEditorContent);
|
|
107
|
+
|
|
108
|
+
const FloatingMenu = (props) => {
|
|
109
|
+
const [element, setElement] = React.useState(null);
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
if (!element) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (props.editor.isDestroyed) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const { pluginKey = 'floatingMenu', editor, tippyOptions = {}, shouldShow = null, } = props;
|
|
118
|
+
const plugin = extensionFloatingMenu.FloatingMenuPlugin({
|
|
119
|
+
pluginKey,
|
|
120
|
+
editor,
|
|
121
|
+
element,
|
|
122
|
+
tippyOptions,
|
|
123
|
+
shouldShow,
|
|
124
|
+
});
|
|
125
|
+
editor.registerPlugin(plugin);
|
|
126
|
+
return () => editor.unregisterPlugin(pluginKey);
|
|
127
|
+
}, [
|
|
128
|
+
props.editor,
|
|
129
|
+
element,
|
|
130
|
+
]);
|
|
131
|
+
return (React__default["default"].createElement("div", { ref: setElement, className: props.className, style: { visibility: 'hidden' } }, props.children));
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const ReactNodeViewContext = React.createContext({
|
|
135
|
+
onDragStart: undefined,
|
|
136
|
+
});
|
|
137
|
+
const useReactNodeView = () => React.useContext(ReactNodeViewContext);
|
|
138
|
+
|
|
139
|
+
const NodeViewContent = props => {
|
|
140
|
+
const Tag = props.as || 'div';
|
|
141
|
+
const { nodeViewContentRef } = useReactNodeView();
|
|
142
|
+
return (React__default["default"].createElement(Tag, { ...props, ref: nodeViewContentRef, "data-node-view-content": "", style: {
|
|
143
|
+
whiteSpace: 'pre-wrap',
|
|
144
|
+
...props.style,
|
|
145
|
+
} }));
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const NodeViewWrapper = React__default["default"].forwardRef((props, ref) => {
|
|
149
|
+
const { onDragStart } = useReactNodeView();
|
|
150
|
+
const Tag = props.as || 'div';
|
|
151
|
+
return (React__default["default"].createElement(Tag, { ...props, ref: ref, "data-node-view-wrapper": "", onDragStart: onDragStart, style: {
|
|
152
|
+
whiteSpace: 'normal',
|
|
153
|
+
...props.style,
|
|
154
|
+
} }));
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
function isClassComponent(Component) {
|
|
158
|
+
return !!(typeof Component === 'function'
|
|
159
|
+
&& Component.prototype
|
|
160
|
+
&& Component.prototype.isReactComponent);
|
|
161
|
+
}
|
|
162
|
+
function isForwardRefComponent(Component) {
|
|
163
|
+
var _a;
|
|
164
|
+
return !!(typeof Component === 'object'
|
|
165
|
+
&& ((_a = Component.$$typeof) === null || _a === void 0 ? void 0 : _a.toString()) === 'Symbol(react.forward_ref)');
|
|
166
|
+
}
|
|
167
|
+
class ReactRenderer {
|
|
168
|
+
constructor(component, { editor, props = {}, as = 'div', className = '', }) {
|
|
169
|
+
this.ref = null;
|
|
170
|
+
this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString();
|
|
171
|
+
this.component = component;
|
|
172
|
+
this.editor = editor;
|
|
173
|
+
this.props = props;
|
|
174
|
+
this.element = document.createElement(as);
|
|
175
|
+
this.element.classList.add('react-renderer');
|
|
176
|
+
if (className) {
|
|
177
|
+
this.element.classList.add(...className.split(' '));
|
|
178
|
+
}
|
|
179
|
+
this.render();
|
|
180
|
+
}
|
|
181
|
+
render() {
|
|
182
|
+
const Component = this.component;
|
|
183
|
+
const props = this.props;
|
|
184
|
+
if (isClassComponent(Component) || isForwardRefComponent(Component)) {
|
|
185
|
+
props.ref = (ref) => {
|
|
186
|
+
this.ref = ref;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
this.reactElement = React__default["default"].createElement(Component, { ...props });
|
|
190
|
+
queueMicrotask(() => {
|
|
191
|
+
ReactDOM.flushSync(() => {
|
|
192
|
+
var _a;
|
|
193
|
+
if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
|
|
194
|
+
this.editor.contentComponent.setState({
|
|
195
|
+
renderers: this.editor.contentComponent.state.renderers.set(this.id, this),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
updateProps(props = {}) {
|
|
202
|
+
this.props = {
|
|
203
|
+
...this.props,
|
|
204
|
+
...props,
|
|
205
|
+
};
|
|
206
|
+
this.render();
|
|
207
|
+
}
|
|
208
|
+
destroy() {
|
|
209
|
+
queueMicrotask(() => {
|
|
210
|
+
ReactDOM.flushSync(() => {
|
|
211
|
+
var _a;
|
|
212
|
+
if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
|
|
213
|
+
const { renderers } = this.editor.contentComponent.state;
|
|
214
|
+
renderers.delete(this.id);
|
|
215
|
+
this.editor.contentComponent.setState({
|
|
216
|
+
renderers,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
class ReactNodeView extends core.NodeView {
|
|
225
|
+
mount() {
|
|
226
|
+
const props = {
|
|
227
|
+
editor: this.editor,
|
|
228
|
+
node: this.node,
|
|
229
|
+
decorations: this.decorations,
|
|
230
|
+
selected: false,
|
|
231
|
+
extension: this.extension,
|
|
232
|
+
getPos: () => this.getPos(),
|
|
233
|
+
updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
|
|
234
|
+
deleteNode: () => this.deleteNode(),
|
|
235
|
+
};
|
|
236
|
+
if (!this.component.displayName) {
|
|
237
|
+
const capitalizeFirstChar = (string) => {
|
|
238
|
+
return string.charAt(0).toUpperCase() + string.substring(1);
|
|
239
|
+
};
|
|
240
|
+
this.component.displayName = capitalizeFirstChar(this.extension.name);
|
|
241
|
+
}
|
|
242
|
+
const ReactNodeViewProvider = componentProps => {
|
|
243
|
+
const Component = this.component;
|
|
244
|
+
const onDragStart = this.onDragStart.bind(this);
|
|
245
|
+
const nodeViewContentRef = element => {
|
|
246
|
+
if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
|
|
247
|
+
element.appendChild(this.contentDOMElement);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
return (React__default["default"].createElement(ReactNodeViewContext.Provider, { value: { onDragStart, nodeViewContentRef } },
|
|
251
|
+
React__default["default"].createElement(Component, { ...componentProps })));
|
|
252
|
+
};
|
|
253
|
+
ReactNodeViewProvider.displayName = 'ReactNodeView';
|
|
254
|
+
this.contentDOMElement = this.node.isLeaf
|
|
255
|
+
? null
|
|
256
|
+
: document.createElement(this.node.isInline ? 'span' : 'div');
|
|
257
|
+
if (this.contentDOMElement) {
|
|
258
|
+
// For some reason the whiteSpace prop is not inherited properly in Chrome and Safari
|
|
259
|
+
// With this fix it seems to work fine
|
|
260
|
+
// See: https://github.com/ueberdosis/tiptap/issues/1197
|
|
261
|
+
this.contentDOMElement.style.whiteSpace = 'inherit';
|
|
262
|
+
}
|
|
263
|
+
let as = this.node.isInline ? 'span' : 'div';
|
|
264
|
+
if (this.options.as) {
|
|
265
|
+
as = this.options.as;
|
|
266
|
+
}
|
|
267
|
+
const { className = '' } = this.options;
|
|
268
|
+
this.renderer = new ReactRenderer(ReactNodeViewProvider, {
|
|
269
|
+
editor: this.editor,
|
|
270
|
+
props,
|
|
271
|
+
as,
|
|
272
|
+
className: `node-${this.node.type.name} ${className}`.trim(),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
get dom() {
|
|
276
|
+
var _a;
|
|
277
|
+
if (this.renderer.element.firstElementChild
|
|
278
|
+
&& !((_a = this.renderer.element.firstElementChild) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-node-view-wrapper'))) {
|
|
279
|
+
throw Error('Please use the NodeViewWrapper component for your node view.');
|
|
280
|
+
}
|
|
281
|
+
return this.renderer.element;
|
|
282
|
+
}
|
|
283
|
+
get contentDOM() {
|
|
284
|
+
if (this.node.isLeaf) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
return this.contentDOMElement;
|
|
288
|
+
}
|
|
289
|
+
update(node, decorations) {
|
|
290
|
+
const updateProps = (props) => {
|
|
291
|
+
this.renderer.updateProps(props);
|
|
292
|
+
};
|
|
293
|
+
if (node.type !== this.node.type) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (typeof this.options.update === 'function') {
|
|
297
|
+
const oldNode = this.node;
|
|
298
|
+
const oldDecorations = this.decorations;
|
|
299
|
+
this.node = node;
|
|
300
|
+
this.decorations = decorations;
|
|
301
|
+
return this.options.update({
|
|
302
|
+
oldNode,
|
|
303
|
+
oldDecorations,
|
|
304
|
+
newNode: node,
|
|
305
|
+
newDecorations: decorations,
|
|
306
|
+
updateProps: () => updateProps({ node, decorations }),
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
if (node === this.node && this.decorations === decorations) {
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
this.node = node;
|
|
313
|
+
this.decorations = decorations;
|
|
314
|
+
updateProps({ node, decorations });
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
selectNode() {
|
|
318
|
+
this.renderer.updateProps({
|
|
319
|
+
selected: true,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
deselectNode() {
|
|
323
|
+
this.renderer.updateProps({
|
|
324
|
+
selected: false,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
destroy() {
|
|
328
|
+
this.renderer.destroy();
|
|
329
|
+
this.contentDOMElement = null;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function ReactNodeViewRenderer(component, options) {
|
|
333
|
+
return (props) => {
|
|
334
|
+
// try to get the parent component
|
|
335
|
+
// this is important for vue devtools to show the component hierarchy correctly
|
|
336
|
+
// maybe it’s `undefined` because <editor-content> isn’t rendered yet
|
|
337
|
+
if (!props.editor.contentComponent) {
|
|
338
|
+
return {};
|
|
339
|
+
}
|
|
340
|
+
return new ReactNodeView(component, props, options);
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function useForceUpdate() {
|
|
345
|
+
const [, setValue] = React.useState(0);
|
|
346
|
+
return () => setValue(value => value + 1);
|
|
347
|
+
}
|
|
348
|
+
const useEditor = (options = {}, deps = []) => {
|
|
349
|
+
const [editor, setEditor] = React.useState(null);
|
|
350
|
+
const forceUpdate = useForceUpdate();
|
|
351
|
+
React.useEffect(() => {
|
|
352
|
+
let isMounted = true;
|
|
353
|
+
const instance = new Editor(options);
|
|
354
|
+
setEditor(instance);
|
|
355
|
+
instance.on('transaction', () => {
|
|
356
|
+
requestAnimationFrame(() => {
|
|
357
|
+
requestAnimationFrame(() => {
|
|
358
|
+
if (isMounted) {
|
|
359
|
+
forceUpdate();
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
return () => {
|
|
365
|
+
instance.destroy();
|
|
366
|
+
isMounted = false;
|
|
367
|
+
};
|
|
368
|
+
}, deps);
|
|
369
|
+
return editor;
|
|
370
|
+
};
|
|
64
371
|
|
|
372
|
+
exports.BubbleMenu = BubbleMenu;
|
|
65
373
|
exports.Editor = Editor;
|
|
66
374
|
exports.EditorContent = EditorContent;
|
|
375
|
+
exports.FloatingMenu = FloatingMenu;
|
|
376
|
+
exports.NodeViewContent = NodeViewContent;
|
|
377
|
+
exports.NodeViewWrapper = NodeViewWrapper;
|
|
67
378
|
exports.PureEditorContent = PureEditorContent;
|
|
379
|
+
exports.ReactNodeViewRenderer = ReactNodeViewRenderer;
|
|
380
|
+
exports.ReactRenderer = ReactRenderer;
|
|
68
381
|
exports.useEditor = useEditor;
|
|
69
382
|
Object.keys(core).forEach(function (k) {
|
|
70
383
|
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
71
384
|
enumerable: true,
|
|
72
|
-
get: function () {
|
|
73
|
-
return core[k];
|
|
74
|
-
}
|
|
385
|
+
get: function () { return core[k]; }
|
|
75
386
|
});
|
|
76
387
|
});
|
|
77
388
|
|
|
78
389
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
79
390
|
|
|
80
|
-
}))
|
|
391
|
+
}));
|
|
81
392
|
//# sourceMappingURL=tiptap-react.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-react.umd.js","sources":["../src/Editor.ts","../src/useEditor.ts","../src/EditorContent.tsx"],"sourcesContent":["import React from 'react'\nimport { Editor as CoreEditor } from '@tiptap/core'\n\nexport class Editor extends CoreEditor {\n public contentComponent: React.Component | 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 { Editor } from './Editor'\n\ntype EditorContentProps = {\n editor: Editor | null\n}\n\nexport class PureEditorContent extends React.Component<EditorContentProps, EditorContentProps> {\n editorContentRef: React.RefObject<any>\n\n constructor(props: EditorContentProps) {\n super(props)\n this.editorContentRef = React.createRef()\n\n this.state = {\n editor: this.props.editor\n }\n }\n\n componentDidUpdate() {\n const { editor } = this.props\n\n if (editor && editor.options.element) {\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: why setTimeout?\n setTimeout(() => {\n editor.createNodeViews()\n }, 0)\n }\n }\n\n render() {\n return (\n <div ref={this.editorContentRef} />\n )\n }\n}\n\nexport const EditorContent = React.memo(PureEditorContent);\n"],"names":["CoreEditor","useState","useEffect","React"],"mappings":";;;;;;;;;;QAGa,MAAO,SAAQA,WAAU;MAAtC;;UACS,qBAAgB,GAA2B,IAAI,CAAA;OACvD;;;ECDD,SAAS,cAAc;MAC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AAM,CAAC,gBAAgB,GAAG,IAAI,CAAA;;cAG9B,UAAU,CAAC;kBACT,MAAM,CAAC,eAAe,EAAE,CAAA;eACzB,EAAE,CAAC,CAAC,CAAA;WACN;OACF;MAED,MAAM;UACJ,QACEA,iDAAK,GAAG,EAAE,IAAI,CAAC,gBAAgB,GAAI,EACpC;OACF;GACF;QAEY,aAAa,GAAGA,yBAAK,CAAC,IAAI,CAAC,iBAAiB;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"tiptap-react.umd.js","sources":["../src/BubbleMenu.tsx","../src/Editor.ts","../src/EditorContent.tsx","../src/FloatingMenu.tsx","../src/useReactNodeView.ts","../src/NodeViewContent.tsx","../src/NodeViewWrapper.tsx","../src/ReactRenderer.tsx","../src/ReactNodeViewRenderer.tsx","../src/useEditor.ts"],"sourcesContent":["import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport React, {\n useEffect, useState,\n} from 'react'\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 children: React.ReactNode\n}\n\nexport const BubbleMenu = (props: BubbleMenuProps) => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const plugin = BubbleMenuPlugin({\n pluginKey,\n editor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n editor.registerPlugin(plugin)\n return () => editor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n element,\n ])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { Editor as CoreEditor } from '@tiptap/core'\nimport React from 'react'\n\nimport { EditorContentProps, EditorContentState } from './EditorContent'\n\nexport class Editor extends CoreEditor {\n public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null\n}\n","import React, { HTMLProps } from 'react'\nimport ReactDOM from 'react-dom'\n\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 { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport React, {\n useEffect, useState,\n} from 'react'\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 children: React.ReactNode\n}\n\nexport const FloatingMenu = (props: FloatingMenuProps) => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const plugin = FloatingMenuPlugin({\n pluginKey,\n editor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n editor.registerPlugin(plugin)\n return () => editor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n element,\n ])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { createContext, useContext } from 'react'\n\nexport interface ReactNodeViewContextProps {\n onDragStart: (event: DragEvent) => void,\n nodeViewContentRef: (element: HTMLElement | null) => void,\n}\n\nexport const ReactNodeViewContext = createContext<Partial<ReactNodeViewContextProps>>({\n onDragStart: undefined,\n})\n\nexport const useReactNodeView = () => useContext(ReactNodeViewContext)\n","import React from 'react'\n\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewContentProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewContent: React.FC<NodeViewContentProps> = props => {\n const Tag = props.as || 'div'\n const { nodeViewContentRef } = useReactNodeView()\n\n return (\n <Tag\n {...props}\n ref={nodeViewContentRef}\n data-node-view-content=\"\"\n style={{\n whiteSpace: 'pre-wrap',\n ...props.style,\n }}\n />\n )\n}\n","import React from 'react'\n\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 whiteSpace: 'normal',\n ...props.style,\n }}\n />\n )\n})\n","import { Editor } from '@tiptap/core'\nimport React from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { Editor as ExtendedEditor } 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 className?: string,\n}\n\ntype ComponentType<R, P> =\n React.ComponentClass<P> |\n React.FunctionComponent<P> |\n React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<R>>;\n\nexport class ReactRenderer<R = unknown, P = unknown> {\n id: string\n\n editor: ExtendedEditor\n\n component: any\n\n element: Element\n\n props: Record<string, any>\n\n reactElement: React.ReactNode\n\n ref: R | null = null\n\n constructor(component: ComponentType<R, P>, {\n editor,\n props = {},\n as = 'div',\n className = '',\n }: ReactRendererOptions) {\n this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString()\n this.component = component\n this.editor = editor as ExtendedEditor\n this.props = props\n this.element = document.createElement(as)\n this.element.classList.add('react-renderer')\n\n if (className) {\n this.element.classList.add(...className.split(' '))\n }\n\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: R) => {\n this.ref = ref\n }\n }\n\n this.reactElement = <Component {...props } />\n\n queueMicrotask(() => {\n flushSync(() => {\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 }\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 queueMicrotask(() => {\n flushSync(() => {\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 }\n}\n","import {\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererOptions,\n NodeViewRendererProps,\n} from '@tiptap/core'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view'\nimport React from 'react'\n\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView'\n\nexport interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {\n update:\n | ((props: {\n oldNode: ProseMirrorNode;\n oldDecorations: Decoration[];\n newNode: ProseMirrorNode;\n newDecorations: Decoration[];\n updateProps: () => void;\n }) => boolean)\n | null;\n as?: string;\n className?: string;\n}\n\nclass ReactNodeView extends NodeView<\n React.FunctionComponent,\n Editor,\n 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 Component = this.component\n const onDragStart = this.onDragStart.bind(this)\n const nodeViewContentRef: ReactNodeViewContextProps['nodeViewContentRef'] = element => {\n if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {\n element.appendChild(this.contentDOMElement)\n }\n }\n\n return (\n <ReactNodeViewContext.Provider value={{ onDragStart, nodeViewContentRef }}>\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 let as = this.node.isInline ? 'span' : 'div'\n\n if (this.options.as) {\n as = this.options.as\n }\n\n const { className = '' } = this.options\n\n this.renderer = new ReactRenderer(ReactNodeViewProvider, {\n editor: this.editor,\n props,\n as,\n className: `node-${this.node.type.name} ${className}`.trim(),\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 as HTMLElement\n }\n\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.contentDOMElement\n }\n\n update(node: ProseMirrorNode, decorations: Decoration[]) {\n const updateProps = (props?: Record<string, any>) => {\n this.renderer.updateProps(props)\n }\n\n if (node.type !== this.node.type) {\n return false\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 === 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(\n component: any,\n options?: Partial<ReactNodeViewRendererOptions>,\n): 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 unknown as ProseMirrorNodeView\n }\n}\n","import { EditorOptions } from '@tiptap/core'\nimport { DependencyList, useEffect, useState } from 'react'\n\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 let isMounted = true\n\n const instance = new Editor(options)\n\n setEditor(instance)\n\n instance.on('transaction', () => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (isMounted) {\n forceUpdate()\n }\n })\n })\n })\n\n return () => {\n instance.destroy()\n isMounted = false\n }\n }, deps)\n\n return editor\n}\n"],"names":["useState","useEffect","BubbleMenuPlugin","React","CoreEditor","ReactDOM","FloatingMenuPlugin","createContext","useContext","flushSync","NodeView"],"mappings":";;;;;;;;;;;AAYa,QAAA,UAAU,GAAG,CAAC,KAAsB,KAAI;MACnD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAwB,IAAI,CAAC,CAAA;MAEnEC,eAAS,CAAC,MAAK;UACb,IAAI,CAAC,OAAO,EAAE;cACZ,OAAM;EACP,SAAA;EAED,QAAA,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;cAC5B,OAAM;EACP,SAAA;EAED,QAAA,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,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,qBAAqB,CAAC,MAAK;EACzB,oBAAA,IAAI,SAAS,EAAE;EACb,wBAAA,WAAW,EAAE,CAAA;EACd,qBAAA;EACH,iBAAC,CAAC,CAAA;EACJ,aAAC,CAAC,CAAA;EACJ,SAAC,CAAC,CAAA;EAEF,QAAA,OAAO,MAAK;cACV,QAAQ,CAAC,OAAO,EAAE,CAAA;cAClB,SAAS,GAAG,KAAK,CAAA;EACnB,SAAC,CAAA;OACF,EAAE,IAAI,CAAC,CAAA;EAER,IAAA,OAAO,MAAM,CAAA;EACf;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
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.200",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,22 +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": "^18.0.1",
|
|
25
|
+
"@types/react-dom": "^18.0.0",
|
|
26
|
+
"react": "^18.0.0",
|
|
27
|
+
"react-dom": "^18.0.0"
|
|
28
|
+
},
|
|
24
29
|
"peerDependencies": {
|
|
25
|
-
"@tiptap/core": "^2.0.0-beta.
|
|
26
|
-
"react": "^17.0.
|
|
27
|
-
"react-dom": "^17.0.
|
|
30
|
+
"@tiptap/core": "^2.0.0-beta.193",
|
|
31
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
32
|
+
"react-dom": "^17.0.0 || ^18.0.0"
|
|
28
33
|
},
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"
|
|
35
|
+
"@tiptap/extension-bubble-menu": "^2.0.0-beta.200",
|
|
36
|
+
"@tiptap/extension-floating-menu": "^2.0.0-beta.200",
|
|
37
|
+
"prosemirror-view": "^1.28.2"
|
|
31
38
|
},
|
|
32
|
-
"
|
|
33
|
-
"
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/ueberdosis/tiptap",
|
|
42
|
+
"directory": "packages/react"
|
|
34
43
|
},
|
|
35
|
-
"
|
|
44
|
+
"sideEffects": false
|
|
36
45
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
|
|
2
|
+
import React, {
|
|
3
|
+
useEffect, useState,
|
|
4
|
+
} from 'react'
|
|
5
|
+
|
|
6
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
|
7
|
+
|
|
8
|
+
export type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {
|
|
9
|
+
className?: string,
|
|
10
|
+
children: React.ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const BubbleMenu = (props: BubbleMenuProps) => {
|
|
14
|
+
const [element, setElement] = useState<HTMLDivElement | null>(null)
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!element) {
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (props.editor.isDestroyed) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
pluginKey = 'bubbleMenu',
|
|
27
|
+
editor,
|
|
28
|
+
tippyOptions = {},
|
|
29
|
+
shouldShow = null,
|
|
30
|
+
} = props
|
|
31
|
+
|
|
32
|
+
const plugin = BubbleMenuPlugin({
|
|
33
|
+
pluginKey,
|
|
34
|
+
editor,
|
|
35
|
+
element,
|
|
36
|
+
tippyOptions,
|
|
37
|
+
shouldShow,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
editor.registerPlugin(plugin)
|
|
41
|
+
return () => editor.unregisterPlugin(pluginKey)
|
|
42
|
+
}, [
|
|
43
|
+
props.editor,
|
|
44
|
+
element,
|
|
45
|
+
])
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>
|
|
49
|
+
{props.children}
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
package/src/Editor.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import { Editor as CoreEditor } from '@tiptap/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { EditorContentProps, EditorContentState } from './EditorContent'
|
|
3
5
|
|
|
4
6
|
export class Editor extends CoreEditor {
|
|
5
|
-
public contentComponent: React.Component | null = null
|
|
7
|
+
public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null
|
|
6
8
|
}
|