@tiptap/react 2.0.0-beta.22 → 2.0.0-beta.220

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