@tiptap/react 2.0.0-beta.9 → 2.0.0-beta.91

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.
@@ -1,298 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@tiptap/core');
6
- var React = require('react');
7
- var extensionBubbleMenu = require('@tiptap/extension-bubble-menu');
8
- var ReactDOM = require('react-dom');
9
-
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
- var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
14
-
15
- const BubbleMenu = props => {
16
- const element = React.useRef(null);
17
- React.useEffect(() => {
18
- const { editor, keepInBounds = true } = props;
19
- editor.registerPlugin(extensionBubbleMenu.BubbleMenuPlugin({
20
- editor,
21
- element: element.current,
22
- keepInBounds,
23
- }));
24
- return () => {
25
- editor.unregisterPlugin(extensionBubbleMenu.BubbleMenuPluginKey);
26
- };
27
- }, []);
28
- return (React__default['default'].createElement("div", { ref: element, className: props.className }, props.children));
29
- };
30
-
31
- class Editor extends core.Editor {
32
- constructor() {
33
- super(...arguments);
34
- this.contentComponent = null;
35
- }
36
- }
37
-
38
- function useForceUpdate() {
39
- const [, setValue] = React.useState(0);
40
- return () => setValue(value => value + 1);
41
- }
42
- const useEditor = (options = {}) => {
43
- const [editor, setEditor] = React.useState(null);
44
- const forceUpdate = useForceUpdate();
45
- React.useEffect(() => {
46
- const instance = new Editor(options);
47
- setEditor(instance);
48
- instance.on('transaction', forceUpdate);
49
- return () => {
50
- instance.destroy();
51
- };
52
- }, []);
53
- return editor;
54
- };
55
-
56
- function isClassComponent(Component) {
57
- return !!(typeof Component === 'function'
58
- && Component.prototype
59
- && Component.prototype.isReactComponent);
60
- }
61
- class ReactRenderer {
62
- constructor(component, { props = {}, editor }) {
63
- this.ref = null;
64
- this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString();
65
- this.component = component;
66
- this.editor = editor;
67
- this.props = props;
68
- this.element = document.createElement('div');
69
- this.element.classList.add('react-renderer');
70
- this.render();
71
- }
72
- render() {
73
- var _a;
74
- const Component = this.component;
75
- const props = this.props;
76
- if (isClassComponent(Component)) {
77
- props.ref = (ref) => {
78
- this.ref = ref;
79
- };
80
- }
81
- this.reactElement = React__default['default'].createElement(Component, Object.assign({}, props));
82
- if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
83
- this.editor.contentComponent.setState({
84
- renderers: this.editor.contentComponent.state.renderers.set(this.id, this),
85
- });
86
- }
87
- }
88
- updateProps(props = {}) {
89
- this.props = {
90
- ...this.props,
91
- ...props,
92
- };
93
- this.render();
94
- }
95
- destroy() {
96
- var _a;
97
- if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
98
- const { renderers } = this.editor.contentComponent.state;
99
- renderers.delete(this.id);
100
- this.editor.contentComponent.setState({
101
- renderers,
102
- });
103
- }
104
- }
105
- }
106
-
107
- const ReactNodeViewContext = React.createContext({
108
- isEditable: undefined,
109
- onDragStart: undefined,
110
- });
111
- const useReactNodeView = () => React.useContext(ReactNodeViewContext);
112
-
113
- class ReactNodeView extends core.NodeView {
114
- mount() {
115
- const props = {
116
- editor: this.editor,
117
- node: this.node,
118
- decorations: this.decorations,
119
- selected: false,
120
- extension: this.extension,
121
- getPos: () => this.getPos(),
122
- updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
123
- };
124
- if (!this.component.displayName) {
125
- const capitalizeFirstChar = (string) => {
126
- return string.charAt(0).toUpperCase() + string.substring(1);
127
- };
128
- // @ts-ignore
129
- this.component.displayName = capitalizeFirstChar(this.extension.config.name);
130
- }
131
- const ReactNodeViewProvider = componentProps => {
132
- const [isEditable, setIsEditable] = React.useState(this.editor.isEditable);
133
- const onDragStart = this.onDragStart.bind(this);
134
- const onViewUpdate = () => setIsEditable(this.editor.isEditable);
135
- const Component = this.component;
136
- React.useEffect(() => {
137
- this.editor.on('viewUpdate', onViewUpdate);
138
- return () => {
139
- this.editor.off('viewUpdate', onViewUpdate);
140
- };
141
- }, []);
142
- return (React__default['default'].createElement(ReactNodeViewContext.Provider, { value: { onDragStart, isEditable } },
143
- React__default['default'].createElement(Component, Object.assign({}, componentProps))));
144
- };
145
- ReactNodeViewProvider.displayName = 'ReactNodeView';
146
- this.renderer = new ReactRenderer(ReactNodeViewProvider, {
147
- editor: this.editor,
148
- props,
149
- });
150
- }
151
- get dom() {
152
- var _a;
153
- if (!((_a = this.renderer.element.firstElementChild) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-node-view-wrapper'))) {
154
- throw Error('Please use the ReactViewWrapper component for your node view.');
155
- }
156
- return this.renderer.element;
157
- }
158
- get contentDOM() {
159
- if (this.node.isLeaf) {
160
- return null;
161
- }
162
- const contentElement = this.dom.querySelector('[data-node-view-content]');
163
- return contentElement || this.dom;
164
- }
165
- update(node, decorations) {
166
- if (typeof this.options.update === 'function') {
167
- return this.options.update(node, decorations);
168
- }
169
- if (node.type !== this.node.type) {
170
- return false;
171
- }
172
- if (node === this.node && this.decorations === decorations) {
173
- return true;
174
- }
175
- this.node = node;
176
- this.decorations = decorations;
177
- this.renderer.updateProps({ node, decorations });
178
- return true;
179
- }
180
- selectNode() {
181
- this.renderer.updateProps({
182
- selected: true,
183
- });
184
- }
185
- deselectNode() {
186
- this.renderer.updateProps({
187
- selected: false,
188
- });
189
- }
190
- destroy() {
191
- this.renderer.destroy();
192
- }
193
- }
194
- function ReactNodeViewRenderer(component, options) {
195
- return (props) => {
196
- // try to get the parent component
197
- // this is important for vue devtools to show the component hierarchy correctly
198
- // maybe it’s `undefined` because <editor-content> isn’t rendered yet
199
- if (!props.editor.contentComponent) {
200
- return {};
201
- }
202
- return new ReactNodeView(component, props, options);
203
- };
204
- }
205
-
206
- const Portals = ({ renderers }) => {
207
- return (React__default['default'].createElement(React__default['default'].Fragment, null, Array.from(renderers).map(([key, renderer]) => {
208
- return ReactDOM__default['default'].createPortal(renderer.reactElement, renderer.element, key);
209
- })));
210
- };
211
- class PureEditorContent extends React__default['default'].Component {
212
- constructor(props) {
213
- super(props);
214
- this.editorContentRef = React__default['default'].createRef();
215
- this.state = {
216
- renderers: new Map(),
217
- };
218
- }
219
- componentDidMount() {
220
- this.init();
221
- }
222
- componentDidUpdate() {
223
- this.init();
224
- }
225
- init() {
226
- const { editor } = this.props;
227
- if (editor && editor.options.element) {
228
- if (editor.contentComponent) {
229
- return;
230
- }
231
- const element = this.editorContentRef.current;
232
- element.appendChild(editor.options.element.firstChild);
233
- editor.setOptions({
234
- element,
235
- });
236
- editor.contentComponent = this;
237
- // TODO: alternative to setTimeout?
238
- setTimeout(() => editor.createNodeViews(), 0);
239
- }
240
- }
241
- componentWillUnmount() {
242
- const { editor } = this.props;
243
- if (!editor) {
244
- return;
245
- }
246
- if (!editor.isDestroyed) {
247
- editor.view.setProps({
248
- nodeViews: {},
249
- });
250
- }
251
- editor.contentComponent = null;
252
- if (!editor.options.element.firstChild) {
253
- return;
254
- }
255
- const newElement = document.createElement('div');
256
- newElement.appendChild(editor.options.element.firstChild);
257
- editor.setOptions({
258
- element: newElement,
259
- });
260
- }
261
- render() {
262
- return (React__default['default'].createElement(React__default['default'].Fragment, null,
263
- React__default['default'].createElement("div", { ref: this.editorContentRef }),
264
- React__default['default'].createElement(Portals, { renderers: this.state.renderers })));
265
- }
266
- }
267
- const EditorContent = React__default['default'].memo(PureEditorContent);
268
-
269
- const NodeViewWrapper = props => {
270
- const { onDragStart } = useReactNodeView();
271
- const Tag = props.as || 'div';
272
- return (React__default['default'].createElement(Tag, { className: props.className, "data-node-view-wrapper": "", onDragStart: onDragStart, style: { whiteSpace: 'normal' } }, props.children));
273
- };
274
-
275
- const NodeViewContent = props => {
276
- const { isEditable } = useReactNodeView();
277
- const Tag = props.as || 'div';
278
- return (React__default['default'].createElement(Tag, { className: props.className, "data-node-view-content": "", contentEditable: isEditable, style: { whiteSpace: 'pre-wrap' } }));
279
- };
280
-
281
- exports.BubbleMenu = BubbleMenu;
282
- exports.Editor = Editor;
283
- exports.EditorContent = EditorContent;
284
- exports.NodeViewContent = NodeViewContent;
285
- exports.NodeViewWrapper = NodeViewWrapper;
286
- exports.PureEditorContent = PureEditorContent;
287
- exports.ReactNodeViewRenderer = ReactNodeViewRenderer;
288
- exports.ReactRenderer = ReactRenderer;
289
- exports.useEditor = useEditor;
290
- Object.keys(core).forEach(function (k) {
291
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
292
- enumerable: true,
293
- get: function () {
294
- return core[k];
295
- }
296
- });
297
- });
298
- //# sourceMappingURL=tiptap-react.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-react.cjs.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":";;;;;;;;;;;;;;MAOa,UAAU,GAA8B,KAAK;IACxD,MAAM,OAAO,GAAGA,YAAM,CAAiB,IAAI,CAAC,CAAA;IAE5CC,eAAS,CAAC;QACR,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,GAAG,KAAK,CAAA;QAE7C,MAAM,CAAC,cAAc,CAACC,oCAAgB,CAAC;YACrC,MAAM;YACN,OAAO,EAAE,OAAO,CAAC,OAAsB;YACvC,YAAY;SACb,CAAC,CAAC,CAAA;QAEH,OAAO;YACL,MAAM,CAAC,gBAAgB,CAACC,uCAAmB,CAAC,CAAA;SAC7C,CAAA;KACF,EAAE,EAAE,CAAC,CAAA;IAEN,QACEC,iDAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,IAC1C,KAAK,CAAC,QAAQ,CACX,EACP;AACH;;MCzBa,MAAO,SAAQC,WAAU;IAAtC;;QACS,qBAAgB,GAAmE,IAAI,CAAA;KAC/F;;;ACFD,SAAS,cAAc;IACrB,MAAM,GAAG,QAAQ,CAAC,GAAGC,cAAQ,CAAC,CAAC,CAAC,CAAA;IAEhC,OAAO,MAAM,QAAQ,CAAC,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC;MAEY,SAAS,GAAG,CAAC,UAAkC,EAAE;IAC5D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAgB,IAAI,CAAC,CAAA;IACzD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpCL,eAAS,CAAC;QACR,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAA;QAEpC,SAAS,CAAC,QAAQ,CAAC,CA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AAC,iBAAiB;;MCpG5C,eAAe,GAAmC,KAAK;IAClE,MAAM,EAAE,WAAW,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;IAE7B,QACEA,wCAAC,GAAG,IACF,SAAS,EAAE,KAAK,CAAC,SAAS,4BACH,EAAE,EACzB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,IAE/B,KAAK,CAAC,QAAQ,CACV,EACP;AACH;;MCda,eAAe,GAAmC,KAAK;IAClE,MAAM,EAAE,UAAU,EAAE,GAAG,gBAAgB,EAAE,CAAA;IACzC,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;IAE7B,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;AACH;;;;;;;;;;;;;;;;;;;;"}
@@ -1,274 +0,0 @@
1
- import { Editor as Editor$1, NodeView } from '@tiptap/core';
2
- export * from '@tiptap/core';
3
- import React, { useRef, useEffect, useState, createContext, useContext } from 'react';
4
- import { BubbleMenuPlugin, BubbleMenuPluginKey } from '@tiptap/extension-bubble-menu';
5
- import ReactDOM from 'react-dom';
6
-
7
- const BubbleMenu = props => {
8
- const element = useRef(null);
9
- useEffect(() => {
10
- const { editor, keepInBounds = true } = props;
11
- editor.registerPlugin(BubbleMenuPlugin({
12
- editor,
13
- element: element.current,
14
- keepInBounds,
15
- }));
16
- return () => {
17
- editor.unregisterPlugin(BubbleMenuPluginKey);
18
- };
19
- }, []);
20
- return (React.createElement("div", { ref: element, className: props.className }, props.children));
21
- };
22
-
23
- class Editor extends Editor$1 {
24
- constructor() {
25
- super(...arguments);
26
- this.contentComponent = null;
27
- }
28
- }
29
-
30
- function useForceUpdate() {
31
- const [, setValue] = useState(0);
32
- return () => setValue(value => value + 1);
33
- }
34
- const useEditor = (options = {}) => {
35
- const [editor, setEditor] = useState(null);
36
- const forceUpdate = useForceUpdate();
37
- useEffect(() => {
38
- const instance = new Editor(options);
39
- setEditor(instance);
40
- instance.on('transaction', forceUpdate);
41
- return () => {
42
- instance.destroy();
43
- };
44
- }, []);
45
- return editor;
46
- };
47
-
48
- function isClassComponent(Component) {
49
- return !!(typeof Component === 'function'
50
- && Component.prototype
51
- && Component.prototype.isReactComponent);
52
- }
53
- class ReactRenderer {
54
- constructor(component, { props = {}, editor }) {
55
- this.ref = null;
56
- this.id = Math.floor(Math.random() * 0xFFFFFFFF).toString();
57
- this.component = component;
58
- this.editor = editor;
59
- this.props = props;
60
- this.element = document.createElement('div');
61
- this.element.classList.add('react-renderer');
62
- this.render();
63
- }
64
- render() {
65
- var _a;
66
- const Component = this.component;
67
- const props = this.props;
68
- if (isClassComponent(Component)) {
69
- props.ref = (ref) => {
70
- this.ref = ref;
71
- };
72
- }
73
- this.reactElement = React.createElement(Component, Object.assign({}, props));
74
- if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
75
- this.editor.contentComponent.setState({
76
- renderers: this.editor.contentComponent.state.renderers.set(this.id, this),
77
- });
78
- }
79
- }
80
- updateProps(props = {}) {
81
- this.props = {
82
- ...this.props,
83
- ...props,
84
- };
85
- this.render();
86
- }
87
- destroy() {
88
- var _a;
89
- if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.contentComponent) {
90
- const { renderers } = this.editor.contentComponent.state;
91
- renderers.delete(this.id);
92
- this.editor.contentComponent.setState({
93
- renderers,
94
- });
95
- }
96
- }
97
- }
98
-
99
- const ReactNodeViewContext = createContext({
100
- isEditable: undefined,
101
- onDragStart: undefined,
102
- });
103
- const useReactNodeView = () => useContext(ReactNodeViewContext);
104
-
105
- class ReactNodeView extends NodeView {
106
- mount() {
107
- const props = {
108
- editor: this.editor,
109
- node: this.node,
110
- decorations: this.decorations,
111
- selected: false,
112
- extension: this.extension,
113
- getPos: () => this.getPos(),
114
- updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
115
- };
116
- if (!this.component.displayName) {
117
- const capitalizeFirstChar = (string) => {
118
- return string.charAt(0).toUpperCase() + string.substring(1);
119
- };
120
- // @ts-ignore
121
- this.component.displayName = capitalizeFirstChar(this.extension.config.name);
122
- }
123
- const ReactNodeViewProvider = componentProps => {
124
- const [isEditable, setIsEditable] = useState(this.editor.isEditable);
125
- const onDragStart = this.onDragStart.bind(this);
126
- const onViewUpdate = () => setIsEditable(this.editor.isEditable);
127
- const Component = this.component;
128
- useEffect(() => {
129
- this.editor.on('viewUpdate', onViewUpdate);
130
- return () => {
131
- this.editor.off('viewUpdate', onViewUpdate);
132
- };
133
- }, []);
134
- return (React.createElement(ReactNodeViewContext.Provider, { value: { onDragStart, isEditable } },
135
- React.createElement(Component, Object.assign({}, componentProps))));
136
- };
137
- ReactNodeViewProvider.displayName = 'ReactNodeView';
138
- this.renderer = new ReactRenderer(ReactNodeViewProvider, {
139
- editor: this.editor,
140
- props,
141
- });
142
- }
143
- get dom() {
144
- var _a;
145
- if (!((_a = this.renderer.element.firstElementChild) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-node-view-wrapper'))) {
146
- throw Error('Please use the ReactViewWrapper component for your node view.');
147
- }
148
- return this.renderer.element;
149
- }
150
- get contentDOM() {
151
- if (this.node.isLeaf) {
152
- return null;
153
- }
154
- const contentElement = this.dom.querySelector('[data-node-view-content]');
155
- return contentElement || this.dom;
156
- }
157
- update(node, decorations) {
158
- if (typeof this.options.update === 'function') {
159
- return this.options.update(node, decorations);
160
- }
161
- if (node.type !== this.node.type) {
162
- return false;
163
- }
164
- if (node === this.node && this.decorations === decorations) {
165
- return true;
166
- }
167
- this.node = node;
168
- this.decorations = decorations;
169
- this.renderer.updateProps({ node, decorations });
170
- return true;
171
- }
172
- selectNode() {
173
- this.renderer.updateProps({
174
- selected: true,
175
- });
176
- }
177
- deselectNode() {
178
- this.renderer.updateProps({
179
- selected: false,
180
- });
181
- }
182
- destroy() {
183
- this.renderer.destroy();
184
- }
185
- }
186
- function ReactNodeViewRenderer(component, options) {
187
- return (props) => {
188
- // try to get the parent component
189
- // this is important for vue devtools to show the component hierarchy correctly
190
- // maybe it’s `undefined` because <editor-content> isn’t rendered yet
191
- if (!props.editor.contentComponent) {
192
- return {};
193
- }
194
- return new ReactNodeView(component, props, options);
195
- };
196
- }
197
-
198
- const Portals = ({ renderers }) => {
199
- return (React.createElement(React.Fragment, null, Array.from(renderers).map(([key, renderer]) => {
200
- return ReactDOM.createPortal(renderer.reactElement, renderer.element, key);
201
- })));
202
- };
203
- class PureEditorContent extends React.Component {
204
- constructor(props) {
205
- super(props);
206
- this.editorContentRef = React.createRef();
207
- this.state = {
208
- renderers: new Map(),
209
- };
210
- }
211
- componentDidMount() {
212
- this.init();
213
- }
214
- componentDidUpdate() {
215
- this.init();
216
- }
217
- init() {
218
- const { editor } = this.props;
219
- if (editor && editor.options.element) {
220
- if (editor.contentComponent) {
221
- return;
222
- }
223
- const element = this.editorContentRef.current;
224
- element.appendChild(editor.options.element.firstChild);
225
- editor.setOptions({
226
- element,
227
- });
228
- editor.contentComponent = this;
229
- // TODO: alternative to setTimeout?
230
- setTimeout(() => editor.createNodeViews(), 0);
231
- }
232
- }
233
- componentWillUnmount() {
234
- const { editor } = this.props;
235
- if (!editor) {
236
- return;
237
- }
238
- if (!editor.isDestroyed) {
239
- editor.view.setProps({
240
- nodeViews: {},
241
- });
242
- }
243
- editor.contentComponent = null;
244
- if (!editor.options.element.firstChild) {
245
- return;
246
- }
247
- const newElement = document.createElement('div');
248
- newElement.appendChild(editor.options.element.firstChild);
249
- editor.setOptions({
250
- element: newElement,
251
- });
252
- }
253
- render() {
254
- return (React.createElement(React.Fragment, null,
255
- React.createElement("div", { ref: this.editorContentRef }),
256
- React.createElement(Portals, { renderers: this.state.renderers })));
257
- }
258
- }
259
- const EditorContent = React.memo(PureEditorContent);
260
-
261
- const NodeViewWrapper = props => {
262
- const { onDragStart } = useReactNodeView();
263
- const Tag = props.as || 'div';
264
- return (React.createElement(Tag, { className: props.className, "data-node-view-wrapper": "", onDragStart: onDragStart, style: { whiteSpace: 'normal' } }, props.children));
265
- };
266
-
267
- const NodeViewContent = props => {
268
- const { isEditable } = useReactNodeView();
269
- const Tag = props.as || 'div';
270
- return (React.createElement(Tag, { className: props.className, "data-node-view-content": "", contentEditable: isEditable, style: { whiteSpace: 'pre-wrap' } }));
271
- };
272
-
273
- export { BubbleMenu, Editor, EditorContent, NodeViewContent, NodeViewWrapper, PureEditorContent, ReactNodeViewRenderer, ReactRenderer, useEditor };
274
- //# sourceMappingURL=tiptap-react.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-react.esm.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 cont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