@tiptap/react 2.2.0 → 2.2.2

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/dist/index.cjs CHANGED
@@ -141,13 +141,9 @@ class Editor extends core.Editor {
141
141
  }
142
142
  }
143
143
 
144
- function useForceUpdate() {
145
- const [, setValue] = React.useState(0);
146
- return () => setValue(value => value + 1);
147
- }
148
144
  const useEditor = (options = {}, deps = []) => {
149
- const [editor, setEditor] = React.useState(null);
150
- const forceUpdate = useForceUpdate();
145
+ const editorRef = React.useRef(null);
146
+ const [, forceUpdate] = React.useState({});
151
147
  const { onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, } = options;
152
148
  const onBeforeCreateRef = React.useRef(onBeforeCreate);
153
149
  const onBlurRef = React.useRef(onBlur);
@@ -160,59 +156,58 @@ const useEditor = (options = {}, deps = []) => {
160
156
  // This effect will handle updating the editor instance
161
157
  // when the event handlers change.
162
158
  React.useEffect(() => {
163
- if (!editor) {
159
+ if (!editorRef.current) {
164
160
  return;
165
161
  }
166
162
  if (onBeforeCreate) {
167
- editor.off('beforeCreate', onBeforeCreateRef.current);
168
- editor.on('beforeCreate', onBeforeCreate);
163
+ editorRef.current.off('beforeCreate', onBeforeCreateRef.current);
164
+ editorRef.current.on('beforeCreate', onBeforeCreate);
169
165
  onBeforeCreateRef.current = onBeforeCreate;
170
166
  }
171
167
  if (onBlur) {
172
- editor.off('blur', onBlurRef.current);
173
- editor.on('blur', onBlur);
168
+ editorRef.current.off('blur', onBlurRef.current);
169
+ editorRef.current.on('blur', onBlur);
174
170
  onBlurRef.current = onBlur;
175
171
  }
176
172
  if (onCreate) {
177
- editor.off('create', onCreateRef.current);
178
- editor.on('create', onCreate);
173
+ editorRef.current.off('create', onCreateRef.current);
174
+ editorRef.current.on('create', onCreate);
179
175
  onCreateRef.current = onCreate;
180
176
  }
181
177
  if (onDestroy) {
182
- editor.off('destroy', onDestroyRef.current);
183
- editor.on('destroy', onDestroy);
178
+ editorRef.current.off('destroy', onDestroyRef.current);
179
+ editorRef.current.on('destroy', onDestroy);
184
180
  onDestroyRef.current = onDestroy;
185
181
  }
186
182
  if (onFocus) {
187
- editor.off('focus', onFocusRef.current);
188
- editor.on('focus', onFocus);
183
+ editorRef.current.off('focus', onFocusRef.current);
184
+ editorRef.current.on('focus', onFocus);
189
185
  onFocusRef.current = onFocus;
190
186
  }
191
187
  if (onSelectionUpdate) {
192
- editor.off('selectionUpdate', onSelectionUpdateRef.current);
193
- editor.on('selectionUpdate', onSelectionUpdate);
188
+ editorRef.current.off('selectionUpdate', onSelectionUpdateRef.current);
189
+ editorRef.current.on('selectionUpdate', onSelectionUpdate);
194
190
  onSelectionUpdateRef.current = onSelectionUpdate;
195
191
  }
196
192
  if (onTransaction) {
197
- editor.off('transaction', onTransactionRef.current);
198
- editor.on('transaction', onTransaction);
193
+ editorRef.current.off('transaction', onTransactionRef.current);
194
+ editorRef.current.on('transaction', onTransaction);
199
195
  onTransactionRef.current = onTransaction;
200
196
  }
201
197
  if (onUpdate) {
202
- editor.off('update', onUpdateRef.current);
203
- editor.on('update', onUpdate);
198
+ editorRef.current.off('update', onUpdateRef.current);
199
+ editorRef.current.on('update', onUpdate);
204
200
  onUpdateRef.current = onUpdate;
205
201
  }
206
- }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editor]);
202
+ }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current]);
207
203
  React.useEffect(() => {
208
204
  let isMounted = true;
209
- const instance = new Editor(options);
210
- setEditor(instance);
211
- instance.on('transaction', () => {
205
+ editorRef.current = new Editor(options);
206
+ editorRef.current.on('transaction', () => {
212
207
  requestAnimationFrame(() => {
213
208
  requestAnimationFrame(() => {
214
209
  if (isMounted) {
215
- forceUpdate();
210
+ forceUpdate({});
216
211
  }
217
212
  });
218
213
  });
@@ -223,10 +218,11 @@ const useEditor = (options = {}, deps = []) => {
223
218
  }, deps);
224
219
  React.useEffect(() => {
225
220
  return () => {
226
- editor === null || editor === void 0 ? void 0 : editor.destroy();
221
+ var _a;
222
+ return (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
227
223
  };
228
- }, [editor]);
229
- return editor;
224
+ }, []);
225
+ return editorRef.current;
230
226
  };
231
227
 
232
228
  const EditorContext = React.createContext({
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/EditorContent.tsx","../src/Editor.ts","../src/useEditor.ts","../src/Context.tsx","../src/BubbleMenu.tsx","../src/FloatingMenu.tsx","../src/useReactNodeView.ts","../src/NodeViewContent.tsx","../src/NodeViewWrapper.tsx","../src/ReactRenderer.tsx","../src/ReactNodeViewRenderer.tsx"],"sourcesContent":["import React, {\n ForwardedRef, forwardRef, HTMLProps, LegacyRef, MutableRefObject,\n} from 'react'\nimport ReactDOM, { flushSync } from 'react-dom'\n\nimport { Editor } from './Editor.js'\nimport { ReactRenderer } from './ReactRenderer.js'\n\nconst mergeRefs = <T extends HTMLDivElement>(\n ...refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined>\n) => {\n return (node: T) => {\n refs.forEach(ref => {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = node\n }\n })\n }\n}\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 innerRef?: ForwardedRef<HTMLDivElement | 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 flushSync(fn)\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, innerRef, ...rest } = this.props\n\n return (\n <>\n <div ref={mergeRefs(innerRef, this.editorContentRef)} {...rest} />\n {/* @ts-ignore */}\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\n// EditorContent should be re-created whenever the Editor instance changes\nconst EditorContentWithKey = forwardRef<HTMLDivElement, EditorContentProps>(\n (props: Omit<EditorContentProps, 'innerRef'>, ref) => {\n const key = React.useMemo(() => {\n return Math.floor(Math.random() * 0xFFFFFFFF).toString()\n }, [props.editor])\n\n // Can't use JSX here because it conflicts with the type definition of Vue's JSX, so use createElement\n return React.createElement(PureEditorContent, {\n key,\n innerRef: ref,\n ...props,\n })\n },\n)\n\nexport const EditorContent = React.memo(EditorContentWithKey)\n","import { Editor as CoreEditor } from '@tiptap/core'\nimport React from 'react'\n\nimport { EditorContentProps, EditorContentState } from './EditorContent.js'\nimport { ReactRenderer } from './ReactRenderer.js'\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 { EditorOptions } from '@tiptap/core'\nimport {\n DependencyList,\n useEffect,\n useRef,\n useState,\n} from 'react'\n\nimport { Editor } from './Editor.js'\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\n const forceUpdate = useForceUpdate()\n\n const {\n onBeforeCreate,\n onBlur,\n onCreate,\n onDestroy,\n onFocus,\n onSelectionUpdate,\n onTransaction,\n onUpdate,\n } = options\n\n const onBeforeCreateRef = useRef(onBeforeCreate)\n const onBlurRef = useRef(onBlur)\n const onCreateRef = useRef(onCreate)\n const onDestroyRef = useRef(onDestroy)\n const onFocusRef = useRef(onFocus)\n const onSelectionUpdateRef = useRef(onSelectionUpdate)\n const onTransactionRef = useRef(onTransaction)\n const onUpdateRef = useRef(onUpdate)\n\n // This effect will handle updating the editor instance\n // when the event handlers change.\n useEffect(() => {\n if (!editor) {\n return\n }\n\n if (onBeforeCreate) {\n editor.off('beforeCreate', onBeforeCreateRef.current)\n editor.on('beforeCreate', onBeforeCreate)\n onBeforeCreateRef.current = onBeforeCreate\n }\n\n if (onBlur) {\n editor.off('blur', onBlurRef.current)\n editor.on('blur', onBlur)\n onBlurRef.current = onBlur\n }\n\n if (onCreate) {\n editor.off('create', onCreateRef.current)\n editor.on('create', onCreate)\n onCreateRef.current = onCreate\n }\n\n if (onDestroy) {\n editor.off('destroy', onDestroyRef.current)\n editor.on('destroy', onDestroy)\n onDestroyRef.current = onDestroy\n }\n\n if (onFocus) {\n editor.off('focus', onFocusRef.current)\n editor.on('focus', onFocus)\n onFocusRef.current = onFocus\n }\n\n if (onSelectionUpdate) {\n editor.off('selectionUpdate', onSelectionUpdateRef.current)\n editor.on('selectionUpdate', onSelectionUpdate)\n onSelectionUpdateRef.current = onSelectionUpdate\n }\n\n if (onTransaction) {\n editor.off('transaction', onTransactionRef.current)\n editor.on('transaction', onTransaction)\n onTransactionRef.current = onTransaction\n }\n\n if (onUpdate) {\n editor.off('update', onUpdateRef.current)\n editor.on('update', onUpdate)\n onUpdateRef.current = onUpdate\n }\n }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editor])\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 isMounted = false\n }\n }, deps)\n\n useEffect(() => {\n return () => {\n editor?.destroy()\n }\n }, [editor])\n\n return editor\n}\n","import { EditorOptions } from '@tiptap/core'\nimport React, { createContext, ReactNode, useContext } from 'react'\n\nimport { Editor } from './Editor.js'\nimport { EditorContent } from './EditorContent.js'\nimport { useEditor } from './useEditor.js'\n\nexport type EditorContextValue = {\n editor: Editor | null;\n}\n\nexport const EditorContext = createContext<EditorContextValue>({\n editor: null,\n})\n\nexport const EditorConsumer = EditorContext.Consumer\n\nexport const useCurrentEditor = () => useContext(EditorContext)\n\nexport type EditorProviderProps = {\n children: ReactNode;\n slotBefore?: ReactNode;\n slotAfter?: ReactNode;\n} & Partial<EditorOptions>\n\nexport const EditorProvider = ({\n children, slotAfter, slotBefore, ...editorOptions\n}: EditorProviderProps) => {\n const editor = useEditor(editorOptions)\n\n if (!editor) {\n return null\n }\n\n return (\n <EditorContext.Provider value={{ editor }}>\n {slotBefore}\n <EditorConsumer>\n {({ editor: currentEditor }) => (\n <EditorContent editor={currentEditor} />\n )}\n </EditorConsumer>\n {children}\n {slotAfter}\n </EditorContext.Provider>\n )\n}\n","import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport React, { useEffect, useState } from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey' | 'editor'>, '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 const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu', editor, tippyOptions = {}, updateDelay, shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = BubbleMenuPlugin({\n updateDelay,\n editor: menuEditor,\n element,\n pluginKey,\n shouldShow,\n tippyOptions,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [props.editor, currentEditor, element])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport React, {\n useEffect, useState,\n} from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey' | 'editor'>, 'element'> & {\n className?: string,\n children: React.ReactNode\n}\n\nexport const FloatingMenu = (props: FloatingMenuProps) => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('FloatingMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = FloatingMenuPlugin({\n pluginKey,\n editor: menuEditor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n currentEditor,\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.js'\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.js'\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.js'\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 attrs?: Record<string, 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 attrs,\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 if (attrs) {\n Object.keys(attrs).forEach(key => {\n this.element.setAttribute(key, attrs[key])\n })\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.js'\nimport { ReactRenderer } from './ReactRenderer.js'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView.js'\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 attrs?: Record<string, 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 if (this.node.isLeaf) {\n this.contentDOMElement = null\n } else if (this.options.contentDOMElementTag) {\n this.contentDOMElement = document.createElement(this.options.contentDOMElementTag)\n } else {\n this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div')\n }\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.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\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 attrs: this.options.attrs,\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 handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n\n if (from <= this.getPos() && to >= this.getPos() + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\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 this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\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"],"names":["React","ReactDOM","flushSync","forwardRef","CoreEditor","useState","useRef","useEffect","createContext","useContext","BubbleMenuPlugin","FloatingMenuPlugin","NodeView"],"mappings":";;;;;;;;;;;;;;;AAQA,MAAM,SAAS,GAAG,CAChB,GAAG,IAA2D,KAC5D;IACF,OAAO,CAAC,IAAO,KAAI;AACjB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,IAAG;AACjB,YAAA,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;gBAC7B,GAAG,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AAC,MAAM,CAAC,0BAA0B,CAAC,CAAA;KACnE;IAED,OAAO,GAAA;AACL,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;AAC9D,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAA;KAC9B;AACF,CAAA;AAEe,SAAA,qBAAqB,CACnC,SAAc,EACd,OAA+C,EAAA;IAE/C,OAAO,CAAC,KAA4B,KAAI;;;;AAItC,QAAA,IAAI,CAAE,KAAK,CAAC,MAAiB,CAAC,gBAAgB,EAAE;AAC9C,YAAA,OAAO,EAAE,CAAA;AACV,SAAA;QAED,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAmC,CAAA;AACvF,KAAC,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/EditorContent.tsx","../src/Editor.ts","../src/useEditor.ts","../src/Context.tsx","../src/BubbleMenu.tsx","../src/FloatingMenu.tsx","../src/useReactNodeView.ts","../src/NodeViewContent.tsx","../src/NodeViewWrapper.tsx","../src/ReactRenderer.tsx","../src/ReactNodeViewRenderer.tsx"],"sourcesContent":["import React, {\n ForwardedRef, forwardRef, HTMLProps, LegacyRef, MutableRefObject,\n} from 'react'\nimport ReactDOM, { flushSync } from 'react-dom'\n\nimport { Editor } from './Editor.js'\nimport { ReactRenderer } from './ReactRenderer.js'\n\nconst mergeRefs = <T extends HTMLDivElement>(\n ...refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined>\n) => {\n return (node: T) => {\n refs.forEach(ref => {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = node\n }\n })\n }\n}\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 innerRef?: ForwardedRef<HTMLDivElement | 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 flushSync(fn)\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, innerRef, ...rest } = this.props\n\n return (\n <>\n <div ref={mergeRefs(innerRef, this.editorContentRef)} {...rest} />\n {/* @ts-ignore */}\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\n// EditorContent should be re-created whenever the Editor instance changes\nconst EditorContentWithKey = forwardRef<HTMLDivElement, EditorContentProps>(\n (props: Omit<EditorContentProps, 'innerRef'>, ref) => {\n const key = React.useMemo(() => {\n return Math.floor(Math.random() * 0xFFFFFFFF).toString()\n }, [props.editor])\n\n // Can't use JSX here because it conflicts with the type definition of Vue's JSX, so use createElement\n return React.createElement(PureEditorContent, {\n key,\n innerRef: ref,\n ...props,\n })\n },\n)\n\nexport const EditorContent = React.memo(EditorContentWithKey)\n","import { Editor as CoreEditor } from '@tiptap/core'\nimport React from 'react'\n\nimport { EditorContentProps, EditorContentState } from './EditorContent.js'\nimport { ReactRenderer } from './ReactRenderer.js'\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 { EditorOptions } from '@tiptap/core'\nimport {\n DependencyList,\n useEffect,\n useRef,\n useState,\n} from 'react'\n\nimport { Editor } from './Editor.js'\n\nexport const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {\n const editorRef = useRef<Editor | null>(null)\n const [, forceUpdate] = useState({})\n\n const {\n onBeforeCreate,\n onBlur,\n onCreate,\n onDestroy,\n onFocus,\n onSelectionUpdate,\n onTransaction,\n onUpdate,\n } = options\n\n const onBeforeCreateRef = useRef(onBeforeCreate)\n const onBlurRef = useRef(onBlur)\n const onCreateRef = useRef(onCreate)\n const onDestroyRef = useRef(onDestroy)\n const onFocusRef = useRef(onFocus)\n const onSelectionUpdateRef = useRef(onSelectionUpdate)\n const onTransactionRef = useRef(onTransaction)\n const onUpdateRef = useRef(onUpdate)\n\n // This effect will handle updating the editor instance\n // when the event handlers change.\n useEffect(() => {\n if (!editorRef.current) {\n return\n }\n\n if (onBeforeCreate) {\n editorRef.current.off('beforeCreate', onBeforeCreateRef.current)\n editorRef.current.on('beforeCreate', onBeforeCreate)\n\n onBeforeCreateRef.current = onBeforeCreate\n }\n\n if (onBlur) {\n editorRef.current.off('blur', onBlurRef.current)\n editorRef.current.on('blur', onBlur)\n\n onBlurRef.current = onBlur\n }\n\n if (onCreate) {\n editorRef.current.off('create', onCreateRef.current)\n editorRef.current.on('create', onCreate)\n\n onCreateRef.current = onCreate\n }\n\n if (onDestroy) {\n editorRef.current.off('destroy', onDestroyRef.current)\n editorRef.current.on('destroy', onDestroy)\n\n onDestroyRef.current = onDestroy\n }\n\n if (onFocus) {\n editorRef.current.off('focus', onFocusRef.current)\n editorRef.current.on('focus', onFocus)\n\n onFocusRef.current = onFocus\n }\n\n if (onSelectionUpdate) {\n editorRef.current.off('selectionUpdate', onSelectionUpdateRef.current)\n editorRef.current.on('selectionUpdate', onSelectionUpdate)\n\n onSelectionUpdateRef.current = onSelectionUpdate\n }\n\n if (onTransaction) {\n editorRef.current.off('transaction', onTransactionRef.current)\n editorRef.current.on('transaction', onTransaction)\n\n onTransactionRef.current = onTransaction\n }\n\n if (onUpdate) {\n editorRef.current.off('update', onUpdateRef.current)\n editorRef.current.on('update', onUpdate)\n\n onUpdateRef.current = onUpdate\n }\n }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current])\n\n useEffect(() => {\n let isMounted = true\n\n editorRef.current = new Editor(options)\n\n editorRef.current.on('transaction', () => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (isMounted) {\n forceUpdate({})\n }\n })\n })\n })\n\n return () => {\n isMounted = false\n }\n }, deps)\n\n useEffect(() => {\n return () => {\n return editorRef.current?.destroy()\n }\n }, [])\n\n return editorRef.current\n}\n","import { EditorOptions } from '@tiptap/core'\nimport React, { createContext, ReactNode, useContext } from 'react'\n\nimport { Editor } from './Editor.js'\nimport { EditorContent } from './EditorContent.js'\nimport { useEditor } from './useEditor.js'\n\nexport type EditorContextValue = {\n editor: Editor | null;\n}\n\nexport const EditorContext = createContext<EditorContextValue>({\n editor: null,\n})\n\nexport const EditorConsumer = EditorContext.Consumer\n\nexport const useCurrentEditor = () => useContext(EditorContext)\n\nexport type EditorProviderProps = {\n children: ReactNode;\n slotBefore?: ReactNode;\n slotAfter?: ReactNode;\n} & Partial<EditorOptions>\n\nexport const EditorProvider = ({\n children, slotAfter, slotBefore, ...editorOptions\n}: EditorProviderProps) => {\n const editor = useEditor(editorOptions)\n\n if (!editor) {\n return null\n }\n\n return (\n <EditorContext.Provider value={{ editor }}>\n {slotBefore}\n <EditorConsumer>\n {({ editor: currentEditor }) => (\n <EditorContent editor={currentEditor} />\n )}\n </EditorConsumer>\n {children}\n {slotAfter}\n </EditorContext.Provider>\n )\n}\n","import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport React, { useEffect, useState } from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey' | 'editor'>, '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 const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu', editor, tippyOptions = {}, updateDelay, shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = BubbleMenuPlugin({\n updateDelay,\n editor: menuEditor,\n element,\n pluginKey,\n shouldShow,\n tippyOptions,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [props.editor, currentEditor, element])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport React, {\n useEffect, useState,\n} from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey' | 'editor'>, 'element'> & {\n className?: string,\n children: React.ReactNode\n}\n\nexport const FloatingMenu = (props: FloatingMenuProps) => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('FloatingMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = FloatingMenuPlugin({\n pluginKey,\n editor: menuEditor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n currentEditor,\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.js'\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.js'\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.js'\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 attrs?: Record<string, 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 attrs,\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 if (attrs) {\n Object.keys(attrs).forEach(key => {\n this.element.setAttribute(key, attrs[key])\n })\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.js'\nimport { ReactRenderer } from './ReactRenderer.js'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView.js'\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 attrs?: Record<string, 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 if (this.node.isLeaf) {\n this.contentDOMElement = null\n } else if (this.options.contentDOMElementTag) {\n this.contentDOMElement = document.createElement(this.options.contentDOMElementTag)\n } else {\n this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div')\n }\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.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\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 attrs: this.options.attrs,\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 handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n\n if (from <= this.getPos() && to >= this.getPos() + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\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 this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\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"],"names":["React","ReactDOM","flushSync","forwardRef","CoreEditor","useRef","useState","useEffect","createContext","useContext","BubbleMenuPlugin","FloatingMenuPlugin","NodeView"],"mappings":";;;;;;;;;;;;;;;AAQA,MAAM,SAAS,GAAG,CAChB,GAAG,IAA2D,KAC5D;IACF,OAAO,CAAC,IAAO,KAAI;AACjB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,IAAG;AACjB,YAAA,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;gBAC7B,GAAG,CAAC,IAAI,CAAC,CAAA;AACV,aAAA;AAAM,iBAAA,IAAI,GAAG,EAAE;AACb,gBAAA,GAAkC,CAAC,OAAO,GAAG,IAAI,CAAA;AACnD,aAAA;AACH,SAAC,CAAC,CAAA;AACJ,KAAC,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAA2D,CAAC,EAAE,SAAS,EAAE,KAAI;AACxF,IAAA,QACEA,yBACG,CAAA,aAAA,CAAAA,yBAAA,CAAA,QAAA,EAAA,IAAA,EAAA,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAI;AACjD,QAAA,OAAOC,4BAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;KAC3E,CAAC,CACD,EACJ;AACH,CAAC,CAAA;AAWY,MAAA,iBAAkB,SAAQD,yBAAK,CAAC,SAAiD,CAAA;AAK5F,IAAA,WAAA,CAAY,KAAyB,EAAA;QACnC,KAAK,CAAC,KAAK,CAAC,CAAA;AACZ,QAAA,IAAI,CAAC,gBAAgB,GAAGA,yBAAK,CAAC,SAAS,EAAE,CAAA;AACzC,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;QAExB,IAAI,CAAC,KAAK,GAAG;AACX,YAAA,SAAS,EAAE,EAAE;SACd,CAAA;KACF;I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AC;AACxB,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA,CAAC,CAAA;QACF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;KAChE;IAED,YAAY,GAAA;AACV,QAAA,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;AACxB,YAAA,QAAQ,EAAE,KAAK;AAChB,SAAA,CAAC,CAAA;QACF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAA;KACnE;IAED,OAAO,GAAA;AACL,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;AAC9D,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAA;KAC9B;AACF,CAAA;AAEe,SAAA,qBAAqB,CACnC,SAAc,EACd,OAA+C,EAAA;IAE/C,OAAO,CAAC,KAA4B,KAAI;;;;AAItC,QAAA,IAAI,CAAE,KAAK,CAAC,MAAiB,CAAC,gBAAgB,EAAE;AAC9C,YAAA,OAAO,EAAE,CAAA;AACV,SAAA;QAED,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAmC,CAAA;AACvF,KAAC,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu';
2
- import React, { forwardRef, useState, useRef, useEffect, createContext, useContext } from 'react';
2
+ import React, { forwardRef, useRef, useState, useEffect, createContext, useContext } from 'react';
3
3
  import ReactDOM, { flushSync } from 'react-dom';
4
4
  import { Editor as Editor$1, NodeView } from '@tiptap/core';
5
5
  export * from '@tiptap/core';
@@ -133,13 +133,9 @@ class Editor extends Editor$1 {
133
133
  }
134
134
  }
135
135
 
136
- function useForceUpdate() {
137
- const [, setValue] = useState(0);
138
- return () => setValue(value => value + 1);
139
- }
140
136
  const useEditor = (options = {}, deps = []) => {
141
- const [editor, setEditor] = useState(null);
142
- const forceUpdate = useForceUpdate();
137
+ const editorRef = useRef(null);
138
+ const [, forceUpdate] = useState({});
143
139
  const { onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, } = options;
144
140
  const onBeforeCreateRef = useRef(onBeforeCreate);
145
141
  const onBlurRef = useRef(onBlur);
@@ -152,59 +148,58 @@ const useEditor = (options = {}, deps = []) => {
152
148
  // This effect will handle updating the editor instance
153
149
  // when the event handlers change.
154
150
  useEffect(() => {
155
- if (!editor) {
151
+ if (!editorRef.current) {
156
152
  return;
157
153
  }
158
154
  if (onBeforeCreate) {
159
- editor.off('beforeCreate', onBeforeCreateRef.current);
160
- editor.on('beforeCreate', onBeforeCreate);
155
+ editorRef.current.off('beforeCreate', onBeforeCreateRef.current);
156
+ editorRef.current.on('beforeCreate', onBeforeCreate);
161
157
  onBeforeCreateRef.current = onBeforeCreate;
162
158
  }
163
159
  if (onBlur) {
164
- editor.off('blur', onBlurRef.current);
165
- editor.on('blur', onBlur);
160
+ editorRef.current.off('blur', onBlurRef.current);
161
+ editorRef.current.on('blur', onBlur);
166
162
  onBlurRef.current = onBlur;
167
163
  }
168
164
  if (onCreate) {
169
- editor.off('create', onCreateRef.current);
170
- editor.on('create', onCreate);
165
+ editorRef.current.off('create', onCreateRef.current);
166
+ editorRef.current.on('create', onCreate);
171
167
  onCreateRef.current = onCreate;
172
168
  }
173
169
  if (onDestroy) {
174
- editor.off('destroy', onDestroyRef.current);
175
- editor.on('destroy', onDestroy);
170
+ editorRef.current.off('destroy', onDestroyRef.current);
171
+ editorRef.current.on('destroy', onDestroy);
176
172
  onDestroyRef.current = onDestroy;
177
173
  }
178
174
  if (onFocus) {
179
- editor.off('focus', onFocusRef.current);
180
- editor.on('focus', onFocus);
175
+ editorRef.current.off('focus', onFocusRef.current);
176
+ editorRef.current.on('focus', onFocus);
181
177
  onFocusRef.current = onFocus;
182
178
  }
183
179
  if (onSelectionUpdate) {
184
- editor.off('selectionUpdate', onSelectionUpdateRef.current);
185
- editor.on('selectionUpdate', onSelectionUpdate);
180
+ editorRef.current.off('selectionUpdate', onSelectionUpdateRef.current);
181
+ editorRef.current.on('selectionUpdate', onSelectionUpdate);
186
182
  onSelectionUpdateRef.current = onSelectionUpdate;
187
183
  }
188
184
  if (onTransaction) {
189
- editor.off('transaction', onTransactionRef.current);
190
- editor.on('transaction', onTransaction);
185
+ editorRef.current.off('transaction', onTransactionRef.current);
186
+ editorRef.current.on('transaction', onTransaction);
191
187
  onTransactionRef.current = onTransaction;
192
188
  }
193
189
  if (onUpdate) {
194
- editor.off('update', onUpdateRef.current);
195
- editor.on('update', onUpdate);
190
+ editorRef.current.off('update', onUpdateRef.current);
191
+ editorRef.current.on('update', onUpdate);
196
192
  onUpdateRef.current = onUpdate;
197
193
  }
198
- }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editor]);
194
+ }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current]);
199
195
  useEffect(() => {
200
196
  let isMounted = true;
201
- const instance = new Editor(options);
202
- setEditor(instance);
203
- instance.on('transaction', () => {
197
+ editorRef.current = new Editor(options);
198
+ editorRef.current.on('transaction', () => {
204
199
  requestAnimationFrame(() => {
205
200
  requestAnimationFrame(() => {
206
201
  if (isMounted) {
207
- forceUpdate();
202
+ forceUpdate({});
208
203
  }
209
204
  });
210
205
  });
@@ -215,10 +210,11 @@ const useEditor = (options = {}, deps = []) => {
215
210
  }, deps);
216
211
  useEffect(() => {
217
212
  return () => {
218
- editor === null || editor === void 0 ? void 0 : editor.destroy();
213
+ var _a;
214
+ return (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
219
215
  };
220
- }, [editor]);
221
- return editor;
216
+ }, []);
217
+ return editorRef.current;
222
218
  };
223
219
 
224
220
  const EditorContext = createContext({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/EditorContent.tsx","../src/Editor.ts","../src/useEditor.ts","../src/Context.tsx","../src/BubbleMenu.tsx","../src/FloatingMenu.tsx","../src/useReactNodeView.ts","../src/NodeViewContent.tsx","../src/NodeViewWrapper.tsx","../src/ReactRenderer.tsx","../src/ReactNodeViewRenderer.tsx"],"sourcesContent":["import React, {\n ForwardedRef, forwardRef, HTMLProps, LegacyRef, MutableRefObject,\n} from 'react'\nimport ReactDOM, { flushSync } from 'react-dom'\n\nimport { Editor } from './Editor.js'\nimport { ReactRenderer } from './ReactRenderer.js'\n\nconst mergeRefs = <T extends HTMLDivElement>(\n ...refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined>\n) => {\n return (node: T) => {\n refs.forEach(ref => {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = node\n }\n })\n }\n}\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 innerRef?: ForwardedRef<HTMLDivElement | 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 flushSync(fn)\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, innerRef, ...rest } = this.props\n\n return (\n <>\n <div ref={mergeRefs(innerRef, this.editorContentRef)} {...rest} />\n {/* @ts-ignore */}\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\n// EditorContent should be re-created whenever the Editor instance changes\nconst EditorContentWithKey = forwardRef<HTMLDivElement, EditorContentProps>(\n (props: Omit<EditorContentProps, 'innerRef'>, ref) => {\n const key = React.useMemo(() => {\n return Math.floor(Math.random() * 0xFFFFFFFF).toString()\n }, [props.editor])\n\n // Can't use JSX here because it conflicts with the type definition of Vue's JSX, so use createElement\n return React.createElement(PureEditorContent, {\n key,\n innerRef: ref,\n ...props,\n })\n },\n)\n\nexport const EditorContent = React.memo(EditorContentWithKey)\n","import { Editor as CoreEditor } from '@tiptap/core'\nimport React from 'react'\n\nimport { EditorContentProps, EditorContentState } from './EditorContent.js'\nimport { ReactRenderer } from './ReactRenderer.js'\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 { EditorOptions } from '@tiptap/core'\nimport {\n DependencyList,\n useEffect,\n useRef,\n useState,\n} from 'react'\n\nimport { Editor } from './Editor.js'\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\n const forceUpdate = useForceUpdate()\n\n const {\n onBeforeCreate,\n onBlur,\n onCreate,\n onDestroy,\n onFocus,\n onSelectionUpdate,\n onTransaction,\n onUpdate,\n } = options\n\n const onBeforeCreateRef = useRef(onBeforeCreate)\n const onBlurRef = useRef(onBlur)\n const onCreateRef = useRef(onCreate)\n const onDestroyRef = useRef(onDestroy)\n const onFocusRef = useRef(onFocus)\n const onSelectionUpdateRef = useRef(onSelectionUpdate)\n const onTransactionRef = useRef(onTransaction)\n const onUpdateRef = useRef(onUpdate)\n\n // This effect will handle updating the editor instance\n // when the event handlers change.\n useEffect(() => {\n if (!editor) {\n return\n }\n\n if (onBeforeCreate) {\n editor.off('beforeCreate', onBeforeCreateRef.current)\n editor.on('beforeCreate', onBeforeCreate)\n onBeforeCreateRef.current = onBeforeCreate\n }\n\n if (onBlur) {\n editor.off('blur', onBlurRef.current)\n editor.on('blur', onBlur)\n onBlurRef.current = onBlur\n }\n\n if (onCreate) {\n editor.off('create', onCreateRef.current)\n editor.on('create', onCreate)\n onCreateRef.current = onCreate\n }\n\n if (onDestroy) {\n editor.off('destroy', onDestroyRef.current)\n editor.on('destroy', onDestroy)\n onDestroyRef.current = onDestroy\n }\n\n if (onFocus) {\n editor.off('focus', onFocusRef.current)\n editor.on('focus', onFocus)\n onFocusRef.current = onFocus\n }\n\n if (onSelectionUpdate) {\n editor.off('selectionUpdate', onSelectionUpdateRef.current)\n editor.on('selectionUpdate', onSelectionUpdate)\n onSelectionUpdateRef.current = onSelectionUpdate\n }\n\n if (onTransaction) {\n editor.off('transaction', onTransactionRef.current)\n editor.on('transaction', onTransaction)\n onTransactionRef.current = onTransaction\n }\n\n if (onUpdate) {\n editor.off('update', onUpdateRef.current)\n editor.on('update', onUpdate)\n onUpdateRef.current = onUpdate\n }\n }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editor])\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 isMounted = false\n }\n }, deps)\n\n useEffect(() => {\n return () => {\n editor?.destroy()\n }\n }, [editor])\n\n return editor\n}\n","import { EditorOptions } from '@tiptap/core'\nimport React, { createContext, ReactNode, useContext } from 'react'\n\nimport { Editor } from './Editor.js'\nimport { EditorContent } from './EditorContent.js'\nimport { useEditor } from './useEditor.js'\n\nexport type EditorContextValue = {\n editor: Editor | null;\n}\n\nexport const EditorContext = createContext<EditorContextValue>({\n editor: null,\n})\n\nexport const EditorConsumer = EditorContext.Consumer\n\nexport const useCurrentEditor = () => useContext(EditorContext)\n\nexport type EditorProviderProps = {\n children: ReactNode;\n slotBefore?: ReactNode;\n slotAfter?: ReactNode;\n} & Partial<EditorOptions>\n\nexport const EditorProvider = ({\n children, slotAfter, slotBefore, ...editorOptions\n}: EditorProviderProps) => {\n const editor = useEditor(editorOptions)\n\n if (!editor) {\n return null\n }\n\n return (\n <EditorContext.Provider value={{ editor }}>\n {slotBefore}\n <EditorConsumer>\n {({ editor: currentEditor }) => (\n <EditorContent editor={currentEditor} />\n )}\n </EditorConsumer>\n {children}\n {slotAfter}\n </EditorContext.Provider>\n )\n}\n","import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport React, { useEffect, useState } from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey' | 'editor'>, '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 const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu', editor, tippyOptions = {}, updateDelay, shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = BubbleMenuPlugin({\n updateDelay,\n editor: menuEditor,\n element,\n pluginKey,\n shouldShow,\n tippyOptions,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [props.editor, currentEditor, element])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport React, {\n useEffect, useState,\n} from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey' | 'editor'>, 'element'> & {\n className?: string,\n children: React.ReactNode\n}\n\nexport const FloatingMenu = (props: FloatingMenuProps) => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('FloatingMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = FloatingMenuPlugin({\n pluginKey,\n editor: menuEditor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n currentEditor,\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.js'\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.js'\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.js'\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 attrs?: Record<string, 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 attrs,\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 if (attrs) {\n Object.keys(attrs).forEach(key => {\n this.element.setAttribute(key, attrs[key])\n })\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.js'\nimport { ReactRenderer } from './ReactRenderer.js'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView.js'\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 attrs?: Record<string, 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 if (this.node.isLeaf) {\n this.contentDOMElement = null\n } else if (this.options.contentDOMElementTag) {\n this.contentDOMElement = document.createElement(this.options.contentDOMElementTag)\n } else {\n this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div')\n }\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.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\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 attrs: this.options.attrs,\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 handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n\n if (from <= this.getPos() && to >= this.getPos() + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\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 this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\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"],"names":["CoreEditor"],"mappings":";;;;;;;AAQA,MAAM,SAAS,GAAG,CAChB,GAAG,IAA2D,KAC5D;IACF,OAAO,CAAC,IAAO,KAAI;AACjB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,IAAG;AACjB,YAAA,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;gBAC7B,GAAG,CAAC,IAAI,CAAC,CAAA;AACV,aAAA;AAAM,iBAAA,IAAI,GAAG,EAAE;AACb,gBAAA,GAAkC,CAAC,OAAO,GAAG,IAAI,CAAA;AACnD,aAAA;AACH,SAAC,CAAC,CAAA;AACJ,KAAC,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAA2D,CAAC,EAAE,SAAS,EAAE,KAAI;AACxF,IAAA,QACE,KACG,CAAA,aAAA,CAA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AAI,CAAE,KAAK,CAAC,MAAiB,CAAC,gBAAgB,EAAE;AAC9C,YAAA,OAAO,EAAE,CAAA;AACV,SAAA;QAED,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAmC,CAAA;AACvF,KAAC,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/EditorContent.tsx","../src/Editor.ts","../src/useEditor.ts","../src/Context.tsx","../src/BubbleMenu.tsx","../src/FloatingMenu.tsx","../src/useReactNodeView.ts","../src/NodeViewContent.tsx","../src/NodeViewWrapper.tsx","../src/ReactRenderer.tsx","../src/ReactNodeViewRenderer.tsx"],"sourcesContent":["import React, {\n ForwardedRef, forwardRef, HTMLProps, LegacyRef, MutableRefObject,\n} from 'react'\nimport ReactDOM, { flushSync } from 'react-dom'\n\nimport { Editor } from './Editor.js'\nimport { ReactRenderer } from './ReactRenderer.js'\n\nconst mergeRefs = <T extends HTMLDivElement>(\n ...refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined>\n) => {\n return (node: T) => {\n refs.forEach(ref => {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = node\n }\n })\n }\n}\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 innerRef?: ForwardedRef<HTMLDivElement | 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 flushSync(fn)\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, innerRef, ...rest } = this.props\n\n return (\n <>\n <div ref={mergeRefs(innerRef, this.editorContentRef)} {...rest} />\n {/* @ts-ignore */}\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\n// EditorContent should be re-created whenever the Editor instance changes\nconst EditorContentWithKey = forwardRef<HTMLDivElement, EditorContentProps>(\n (props: Omit<EditorContentProps, 'innerRef'>, ref) => {\n const key = React.useMemo(() => {\n return Math.floor(Math.random() * 0xFFFFFFFF).toString()\n }, [props.editor])\n\n // Can't use JSX here because it conflicts with the type definition of Vue's JSX, so use createElement\n return React.createElement(PureEditorContent, {\n key,\n innerRef: ref,\n ...props,\n })\n },\n)\n\nexport const EditorContent = React.memo(EditorContentWithKey)\n","import { Editor as CoreEditor } from '@tiptap/core'\nimport React from 'react'\n\nimport { EditorContentProps, EditorContentState } from './EditorContent.js'\nimport { ReactRenderer } from './ReactRenderer.js'\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 { EditorOptions } from '@tiptap/core'\nimport {\n DependencyList,\n useEffect,\n useRef,\n useState,\n} from 'react'\n\nimport { Editor } from './Editor.js'\n\nexport const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {\n const editorRef = useRef<Editor | null>(null)\n const [, forceUpdate] = useState({})\n\n const {\n onBeforeCreate,\n onBlur,\n onCreate,\n onDestroy,\n onFocus,\n onSelectionUpdate,\n onTransaction,\n onUpdate,\n } = options\n\n const onBeforeCreateRef = useRef(onBeforeCreate)\n const onBlurRef = useRef(onBlur)\n const onCreateRef = useRef(onCreate)\n const onDestroyRef = useRef(onDestroy)\n const onFocusRef = useRef(onFocus)\n const onSelectionUpdateRef = useRef(onSelectionUpdate)\n const onTransactionRef = useRef(onTransaction)\n const onUpdateRef = useRef(onUpdate)\n\n // This effect will handle updating the editor instance\n // when the event handlers change.\n useEffect(() => {\n if (!editorRef.current) {\n return\n }\n\n if (onBeforeCreate) {\n editorRef.current.off('beforeCreate', onBeforeCreateRef.current)\n editorRef.current.on('beforeCreate', onBeforeCreate)\n\n onBeforeCreateRef.current = onBeforeCreate\n }\n\n if (onBlur) {\n editorRef.current.off('blur', onBlurRef.current)\n editorRef.current.on('blur', onBlur)\n\n onBlurRef.current = onBlur\n }\n\n if (onCreate) {\n editorRef.current.off('create', onCreateRef.current)\n editorRef.current.on('create', onCreate)\n\n onCreateRef.current = onCreate\n }\n\n if (onDestroy) {\n editorRef.current.off('destroy', onDestroyRef.current)\n editorRef.current.on('destroy', onDestroy)\n\n onDestroyRef.current = onDestroy\n }\n\n if (onFocus) {\n editorRef.current.off('focus', onFocusRef.current)\n editorRef.current.on('focus', onFocus)\n\n onFocusRef.current = onFocus\n }\n\n if (onSelectionUpdate) {\n editorRef.current.off('selectionUpdate', onSelectionUpdateRef.current)\n editorRef.current.on('selectionUpdate', onSelectionUpdate)\n\n onSelectionUpdateRef.current = onSelectionUpdate\n }\n\n if (onTransaction) {\n editorRef.current.off('transaction', onTransactionRef.current)\n editorRef.current.on('transaction', onTransaction)\n\n onTransactionRef.current = onTransaction\n }\n\n if (onUpdate) {\n editorRef.current.off('update', onUpdateRef.current)\n editorRef.current.on('update', onUpdate)\n\n onUpdateRef.current = onUpdate\n }\n }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current])\n\n useEffect(() => {\n let isMounted = true\n\n editorRef.current = new Editor(options)\n\n editorRef.current.on('transaction', () => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (isMounted) {\n forceUpdate({})\n }\n })\n })\n })\n\n return () => {\n isMounted = false\n }\n }, deps)\n\n useEffect(() => {\n return () => {\n return editorRef.current?.destroy()\n }\n }, [])\n\n return editorRef.current\n}\n","import { EditorOptions } from '@tiptap/core'\nimport React, { createContext, ReactNode, useContext } from 'react'\n\nimport { Editor } from './Editor.js'\nimport { EditorContent } from './EditorContent.js'\nimport { useEditor } from './useEditor.js'\n\nexport type EditorContextValue = {\n editor: Editor | null;\n}\n\nexport const EditorContext = createContext<EditorContextValue>({\n editor: null,\n})\n\nexport const EditorConsumer = EditorContext.Consumer\n\nexport const useCurrentEditor = () => useContext(EditorContext)\n\nexport type EditorProviderProps = {\n children: ReactNode;\n slotBefore?: ReactNode;\n slotAfter?: ReactNode;\n} & Partial<EditorOptions>\n\nexport const EditorProvider = ({\n children, slotAfter, slotBefore, ...editorOptions\n}: EditorProviderProps) => {\n const editor = useEditor(editorOptions)\n\n if (!editor) {\n return null\n }\n\n return (\n <EditorContext.Provider value={{ editor }}>\n {slotBefore}\n <EditorConsumer>\n {({ editor: currentEditor }) => (\n <EditorContent editor={currentEditor} />\n )}\n </EditorConsumer>\n {children}\n {slotAfter}\n </EditorContext.Provider>\n )\n}\n","import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport React, { useEffect, useState } from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey' | 'editor'>, '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 const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu', editor, tippyOptions = {}, updateDelay, shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = BubbleMenuPlugin({\n updateDelay,\n editor: menuEditor,\n element,\n pluginKey,\n shouldShow,\n tippyOptions,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [props.editor, currentEditor, element])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport React, {\n useEffect, useState,\n} from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey' | 'editor'>, 'element'> & {\n className?: string,\n children: React.ReactNode\n}\n\nexport const FloatingMenu = (props: FloatingMenuProps) => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('FloatingMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = FloatingMenuPlugin({\n pluginKey,\n editor: menuEditor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n currentEditor,\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.js'\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.js'\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.js'\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 attrs?: Record<string, 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 attrs,\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 if (attrs) {\n Object.keys(attrs).forEach(key => {\n this.element.setAttribute(key, attrs[key])\n })\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.js'\nimport { ReactRenderer } from './ReactRenderer.js'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView.js'\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 attrs?: Record<string, 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 if (this.node.isLeaf) {\n this.contentDOMElement = null\n } else if (this.options.contentDOMElementTag) {\n this.contentDOMElement = document.createElement(this.options.contentDOMElementTag)\n } else {\n this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div')\n }\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.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\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 attrs: this.options.attrs,\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 handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n\n if (from <= this.getPos() && to >= this.getPos() + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\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 this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\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"],"names":["CoreEditor"],"mappings":";;;;;;;AAQA,MAAM,SAAS,GAAG,CAChB,GAAG,IAA2D,KAC5D;IACF,OAAO,CAAC,IAAO,KAAI;AACjB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,IAAG;AACjB,YAAA,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;gBAC7B,GAAG,CAAC,IAAI,CAAC,CAAA;AACV,aAAA;AAAM,iBAAA,IAAI,GAAG,EAAE;AACb,gBAAA,GAAkC,CAAC,OAAO,GAAG,IAAI,CAAA;AACnD,aAAA;AACH,SAAC,CAAC,CAAA;AACJ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CAAA;AAEe,SAAA,qBAAqB,CACnC,SAAc,EACd,OAA+C,EAAA;IAE/C,OAAO,CAAC,KAA4B,KAAI;;;;AAItC,QAAA,IAAI,CAAE,KAAK,CAAC,MAAiB,CAAC,gBAAgB,EAAE;AAC9C,YAAA,OAAO,EAAE,CAAA;AACV,SAAA;QAED,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAmC,CAAA;AACvF,KAAC,CAAA;AACH;;;;"}
package/dist/index.umd.js CHANGED
@@ -137,13 +137,9 @@
137
137
  }
138
138
  }
139
139
 
140
- function useForceUpdate() {
141
- const [, setValue] = React.useState(0);
142
- return () => setValue(value => value + 1);
143
- }
144
140
  const useEditor = (options = {}, deps = []) => {
145
- const [editor, setEditor] = React.useState(null);
146
- const forceUpdate = useForceUpdate();
141
+ const editorRef = React.useRef(null);
142
+ const [, forceUpdate] = React.useState({});
147
143
  const { onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, } = options;
148
144
  const onBeforeCreateRef = React.useRef(onBeforeCreate);
149
145
  const onBlurRef = React.useRef(onBlur);
@@ -156,59 +152,58 @@
156
152
  // This effect will handle updating the editor instance
157
153
  // when the event handlers change.
158
154
  React.useEffect(() => {
159
- if (!editor) {
155
+ if (!editorRef.current) {
160
156
  return;
161
157
  }
162
158
  if (onBeforeCreate) {
163
- editor.off('beforeCreate', onBeforeCreateRef.current);
164
- editor.on('beforeCreate', onBeforeCreate);
159
+ editorRef.current.off('beforeCreate', onBeforeCreateRef.current);
160
+ editorRef.current.on('beforeCreate', onBeforeCreate);
165
161
  onBeforeCreateRef.current = onBeforeCreate;
166
162
  }
167
163
  if (onBlur) {
168
- editor.off('blur', onBlurRef.current);
169
- editor.on('blur', onBlur);
164
+ editorRef.current.off('blur', onBlurRef.current);
165
+ editorRef.current.on('blur', onBlur);
170
166
  onBlurRef.current = onBlur;
171
167
  }
172
168
  if (onCreate) {
173
- editor.off('create', onCreateRef.current);
174
- editor.on('create', onCreate);
169
+ editorRef.current.off('create', onCreateRef.current);
170
+ editorRef.current.on('create', onCreate);
175
171
  onCreateRef.current = onCreate;
176
172
  }
177
173
  if (onDestroy) {
178
- editor.off('destroy', onDestroyRef.current);
179
- editor.on('destroy', onDestroy);
174
+ editorRef.current.off('destroy', onDestroyRef.current);
175
+ editorRef.current.on('destroy', onDestroy);
180
176
  onDestroyRef.current = onDestroy;
181
177
  }
182
178
  if (onFocus) {
183
- editor.off('focus', onFocusRef.current);
184
- editor.on('focus', onFocus);
179
+ editorRef.current.off('focus', onFocusRef.current);
180
+ editorRef.current.on('focus', onFocus);
185
181
  onFocusRef.current = onFocus;
186
182
  }
187
183
  if (onSelectionUpdate) {
188
- editor.off('selectionUpdate', onSelectionUpdateRef.current);
189
- editor.on('selectionUpdate', onSelectionUpdate);
184
+ editorRef.current.off('selectionUpdate', onSelectionUpdateRef.current);
185
+ editorRef.current.on('selectionUpdate', onSelectionUpdate);
190
186
  onSelectionUpdateRef.current = onSelectionUpdate;
191
187
  }
192
188
  if (onTransaction) {
193
- editor.off('transaction', onTransactionRef.current);
194
- editor.on('transaction', onTransaction);
189
+ editorRef.current.off('transaction', onTransactionRef.current);
190
+ editorRef.current.on('transaction', onTransaction);
195
191
  onTransactionRef.current = onTransaction;
196
192
  }
197
193
  if (onUpdate) {
198
- editor.off('update', onUpdateRef.current);
199
- editor.on('update', onUpdate);
194
+ editorRef.current.off('update', onUpdateRef.current);
195
+ editorRef.current.on('update', onUpdate);
200
196
  onUpdateRef.current = onUpdate;
201
197
  }
202
- }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editor]);
198
+ }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current]);
203
199
  React.useEffect(() => {
204
200
  let isMounted = true;
205
- const instance = new Editor(options);
206
- setEditor(instance);
207
- instance.on('transaction', () => {
201
+ editorRef.current = new Editor(options);
202
+ editorRef.current.on('transaction', () => {
208
203
  requestAnimationFrame(() => {
209
204
  requestAnimationFrame(() => {
210
205
  if (isMounted) {
211
- forceUpdate();
206
+ forceUpdate({});
212
207
  }
213
208
  });
214
209
  });
@@ -219,10 +214,11 @@
219
214
  }, deps);
220
215
  React.useEffect(() => {
221
216
  return () => {
222
- editor === null || editor === void 0 ? void 0 : editor.destroy();
217
+ var _a;
218
+ return (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
223
219
  };
224
- }, [editor]);
225
- return editor;
220
+ }, []);
221
+ return editorRef.current;
226
222
  };
227
223
 
228
224
  const EditorContext = React.createContext({
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/EditorContent.tsx","../src/Editor.ts","../src/useEditor.ts","../src/Context.tsx","../src/BubbleMenu.tsx","../src/FloatingMenu.tsx","../src/useReactNodeView.ts","../src/NodeViewContent.tsx","../src/NodeViewWrapper.tsx","../src/ReactRenderer.tsx","../src/ReactNodeViewRenderer.tsx"],"sourcesContent":["import React, {\n ForwardedRef, forwardRef, HTMLProps, LegacyRef, MutableRefObject,\n} from 'react'\nimport ReactDOM, { flushSync } from 'react-dom'\n\nimport { Editor } from './Editor.js'\nimport { ReactRenderer } from './ReactRenderer.js'\n\nconst mergeRefs = <T extends HTMLDivElement>(\n ...refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined>\n) => {\n return (node: T) => {\n refs.forEach(ref => {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = node\n }\n })\n }\n}\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 innerRef?: ForwardedRef<HTMLDivElement | 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 flushSync(fn)\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, innerRef, ...rest } = this.props\n\n return (\n <>\n <div ref={mergeRefs(innerRef, this.editorContentRef)} {...rest} />\n {/* @ts-ignore */}\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\n// EditorContent should be re-created whenever the Editor instance changes\nconst EditorContentWithKey = forwardRef<HTMLDivElement, EditorContentProps>(\n (props: Omit<EditorContentProps, 'innerRef'>, ref) => {\n const key = React.useMemo(() => {\n return Math.floor(Math.random() * 0xFFFFFFFF).toString()\n }, [props.editor])\n\n // Can't use JSX here because it conflicts with the type definition of Vue's JSX, so use createElement\n return React.createElement(PureEditorContent, {\n key,\n innerRef: ref,\n ...props,\n })\n },\n)\n\nexport const EditorContent = React.memo(EditorContentWithKey)\n","import { Editor as CoreEditor } from '@tiptap/core'\nimport React from 'react'\n\nimport { EditorContentProps, EditorContentState } from './EditorContent.js'\nimport { ReactRenderer } from './ReactRenderer.js'\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 { EditorOptions } from '@tiptap/core'\nimport {\n DependencyList,\n useEffect,\n useRef,\n useState,\n} from 'react'\n\nimport { Editor } from './Editor.js'\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\n const forceUpdate = useForceUpdate()\n\n const {\n onBeforeCreate,\n onBlur,\n onCreate,\n onDestroy,\n onFocus,\n onSelectionUpdate,\n onTransaction,\n onUpdate,\n } = options\n\n const onBeforeCreateRef = useRef(onBeforeCreate)\n const onBlurRef = useRef(onBlur)\n const onCreateRef = useRef(onCreate)\n const onDestroyRef = useRef(onDestroy)\n const onFocusRef = useRef(onFocus)\n const onSelectionUpdateRef = useRef(onSelectionUpdate)\n const onTransactionRef = useRef(onTransaction)\n const onUpdateRef = useRef(onUpdate)\n\n // This effect will handle updating the editor instance\n // when the event handlers change.\n useEffect(() => {\n if (!editor) {\n return\n }\n\n if (onBeforeCreate) {\n editor.off('beforeCreate', onBeforeCreateRef.current)\n editor.on('beforeCreate', onBeforeCreate)\n onBeforeCreateRef.current = onBeforeCreate\n }\n\n if (onBlur) {\n editor.off('blur', onBlurRef.current)\n editor.on('blur', onBlur)\n onBlurRef.current = onBlur\n }\n\n if (onCreate) {\n editor.off('create', onCreateRef.current)\n editor.on('create', onCreate)\n onCreateRef.current = onCreate\n }\n\n if (onDestroy) {\n editor.off('destroy', onDestroyRef.current)\n editor.on('destroy', onDestroy)\n onDestroyRef.current = onDestroy\n }\n\n if (onFocus) {\n editor.off('focus', onFocusRef.current)\n editor.on('focus', onFocus)\n onFocusRef.current = onFocus\n }\n\n if (onSelectionUpdate) {\n editor.off('selectionUpdate', onSelectionUpdateRef.current)\n editor.on('selectionUpdate', onSelectionUpdate)\n onSelectionUpdateRef.current = onSelectionUpdate\n }\n\n if (onTransaction) {\n editor.off('transaction', onTransactionRef.current)\n editor.on('transaction', onTransaction)\n onTransactionRef.current = onTransaction\n }\n\n if (onUpdate) {\n editor.off('update', onUpdateRef.current)\n editor.on('update', onUpdate)\n onUpdateRef.current = onUpdate\n }\n }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editor])\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 isMounted = false\n }\n }, deps)\n\n useEffect(() => {\n return () => {\n editor?.destroy()\n }\n }, [editor])\n\n return editor\n}\n","import { EditorOptions } from '@tiptap/core'\nimport React, { createContext, ReactNode, useContext } from 'react'\n\nimport { Editor } from './Editor.js'\nimport { EditorContent } from './EditorContent.js'\nimport { useEditor } from './useEditor.js'\n\nexport type EditorContextValue = {\n editor: Editor | null;\n}\n\nexport const EditorContext = createContext<EditorContextValue>({\n editor: null,\n})\n\nexport const EditorConsumer = EditorContext.Consumer\n\nexport const useCurrentEditor = () => useContext(EditorContext)\n\nexport type EditorProviderProps = {\n children: ReactNode;\n slotBefore?: ReactNode;\n slotAfter?: ReactNode;\n} & Partial<EditorOptions>\n\nexport const EditorProvider = ({\n children, slotAfter, slotBefore, ...editorOptions\n}: EditorProviderProps) => {\n const editor = useEditor(editorOptions)\n\n if (!editor) {\n return null\n }\n\n return (\n <EditorContext.Provider value={{ editor }}>\n {slotBefore}\n <EditorConsumer>\n {({ editor: currentEditor }) => (\n <EditorContent editor={currentEditor} />\n )}\n </EditorConsumer>\n {children}\n {slotAfter}\n </EditorContext.Provider>\n )\n}\n","import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport React, { useEffect, useState } from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey' | 'editor'>, '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 const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu', editor, tippyOptions = {}, updateDelay, shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = BubbleMenuPlugin({\n updateDelay,\n editor: menuEditor,\n element,\n pluginKey,\n shouldShow,\n tippyOptions,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [props.editor, currentEditor, element])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport React, {\n useEffect, useState,\n} from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey' | 'editor'>, 'element'> & {\n className?: string,\n children: React.ReactNode\n}\n\nexport const FloatingMenu = (props: FloatingMenuProps) => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('FloatingMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = FloatingMenuPlugin({\n pluginKey,\n editor: menuEditor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n currentEditor,\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.js'\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.js'\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.js'\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 attrs?: Record<string, 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 attrs,\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 if (attrs) {\n Object.keys(attrs).forEach(key => {\n this.element.setAttribute(key, attrs[key])\n })\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.js'\nimport { ReactRenderer } from './ReactRenderer.js'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView.js'\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 attrs?: Record<string, 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 if (this.node.isLeaf) {\n this.contentDOMElement = null\n } else if (this.options.contentDOMElementTag) {\n this.contentDOMElement = document.createElement(this.options.contentDOMElementTag)\n } else {\n this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div')\n }\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.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\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 attrs: this.options.attrs,\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 handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n\n if (from <= this.getPos() && to >= this.getPos() + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\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 this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\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"],"names":["React","ReactDOM","flushSync","forwardRef","CoreEditor","useState","useRef","useEffect","createContext","useContext","BubbleMenuPlugin","FloatingMenuPlugin","NodeView"],"mappings":";;;;;;;;;;;EAQA,MAAM,SAAS,GAAG,CAChB,GAAG,IAA2D,KAC5D;MACF,OAAO,CAA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,CAAC,WAAW,CAAC;EACxB,YAAA,QAAQ,EAAE,KAAK;EAChB,SAAA,CAAC,CAAA;UACF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAA;OACnE;MAED,OAAO,GAAA;EACL,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;UACvB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;EAC9D,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAA;OAC9B;EACF,CAAA;EAEe,SAAA,qBAAqB,CACnC,SAAc,EACd,OAA+C,EAAA;MAE/C,OAAO,CAAC,KAA4B,KAAI;;;;EAItC,QAAA,IAAI,CAAE,KAAK,CAAC,MAAiB,CAAC,gBAAgB,EAAE;EAC9C,YAAA,OAAO,EAAE,CAAA;EACV,SAAA;UAED,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAmC,CAAA;EACvF,KAAC,CAAA;EACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/EditorContent.tsx","../src/Editor.ts","../src/useEditor.ts","../src/Context.tsx","../src/BubbleMenu.tsx","../src/FloatingMenu.tsx","../src/useReactNodeView.ts","../src/NodeViewContent.tsx","../src/NodeViewWrapper.tsx","../src/ReactRenderer.tsx","../src/ReactNodeViewRenderer.tsx"],"sourcesContent":["import React, {\n ForwardedRef, forwardRef, HTMLProps, LegacyRef, MutableRefObject,\n} from 'react'\nimport ReactDOM, { flushSync } from 'react-dom'\n\nimport { Editor } from './Editor.js'\nimport { ReactRenderer } from './ReactRenderer.js'\n\nconst mergeRefs = <T extends HTMLDivElement>(\n ...refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined>\n) => {\n return (node: T) => {\n refs.forEach(ref => {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = node\n }\n })\n }\n}\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 innerRef?: ForwardedRef<HTMLDivElement | 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 flushSync(fn)\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, innerRef, ...rest } = this.props\n\n return (\n <>\n <div ref={mergeRefs(innerRef, this.editorContentRef)} {...rest} />\n {/* @ts-ignore */}\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\n// EditorContent should be re-created whenever the Editor instance changes\nconst EditorContentWithKey = forwardRef<HTMLDivElement, EditorContentProps>(\n (props: Omit<EditorContentProps, 'innerRef'>, ref) => {\n const key = React.useMemo(() => {\n return Math.floor(Math.random() * 0xFFFFFFFF).toString()\n }, [props.editor])\n\n // Can't use JSX here because it conflicts with the type definition of Vue's JSX, so use createElement\n return React.createElement(PureEditorContent, {\n key,\n innerRef: ref,\n ...props,\n })\n },\n)\n\nexport const EditorContent = React.memo(EditorContentWithKey)\n","import { Editor as CoreEditor } from '@tiptap/core'\nimport React from 'react'\n\nimport { EditorContentProps, EditorContentState } from './EditorContent.js'\nimport { ReactRenderer } from './ReactRenderer.js'\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 { EditorOptions } from '@tiptap/core'\nimport {\n DependencyList,\n useEffect,\n useRef,\n useState,\n} from 'react'\n\nimport { Editor } from './Editor.js'\n\nexport const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {\n const editorRef = useRef<Editor | null>(null)\n const [, forceUpdate] = useState({})\n\n const {\n onBeforeCreate,\n onBlur,\n onCreate,\n onDestroy,\n onFocus,\n onSelectionUpdate,\n onTransaction,\n onUpdate,\n } = options\n\n const onBeforeCreateRef = useRef(onBeforeCreate)\n const onBlurRef = useRef(onBlur)\n const onCreateRef = useRef(onCreate)\n const onDestroyRef = useRef(onDestroy)\n const onFocusRef = useRef(onFocus)\n const onSelectionUpdateRef = useRef(onSelectionUpdate)\n const onTransactionRef = useRef(onTransaction)\n const onUpdateRef = useRef(onUpdate)\n\n // This effect will handle updating the editor instance\n // when the event handlers change.\n useEffect(() => {\n if (!editorRef.current) {\n return\n }\n\n if (onBeforeCreate) {\n editorRef.current.off('beforeCreate', onBeforeCreateRef.current)\n editorRef.current.on('beforeCreate', onBeforeCreate)\n\n onBeforeCreateRef.current = onBeforeCreate\n }\n\n if (onBlur) {\n editorRef.current.off('blur', onBlurRef.current)\n editorRef.current.on('blur', onBlur)\n\n onBlurRef.current = onBlur\n }\n\n if (onCreate) {\n editorRef.current.off('create', onCreateRef.current)\n editorRef.current.on('create', onCreate)\n\n onCreateRef.current = onCreate\n }\n\n if (onDestroy) {\n editorRef.current.off('destroy', onDestroyRef.current)\n editorRef.current.on('destroy', onDestroy)\n\n onDestroyRef.current = onDestroy\n }\n\n if (onFocus) {\n editorRef.current.off('focus', onFocusRef.current)\n editorRef.current.on('focus', onFocus)\n\n onFocusRef.current = onFocus\n }\n\n if (onSelectionUpdate) {\n editorRef.current.off('selectionUpdate', onSelectionUpdateRef.current)\n editorRef.current.on('selectionUpdate', onSelectionUpdate)\n\n onSelectionUpdateRef.current = onSelectionUpdate\n }\n\n if (onTransaction) {\n editorRef.current.off('transaction', onTransactionRef.current)\n editorRef.current.on('transaction', onTransaction)\n\n onTransactionRef.current = onTransaction\n }\n\n if (onUpdate) {\n editorRef.current.off('update', onUpdateRef.current)\n editorRef.current.on('update', onUpdate)\n\n onUpdateRef.current = onUpdate\n }\n }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current])\n\n useEffect(() => {\n let isMounted = true\n\n editorRef.current = new Editor(options)\n\n editorRef.current.on('transaction', () => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (isMounted) {\n forceUpdate({})\n }\n })\n })\n })\n\n return () => {\n isMounted = false\n }\n }, deps)\n\n useEffect(() => {\n return () => {\n return editorRef.current?.destroy()\n }\n }, [])\n\n return editorRef.current\n}\n","import { EditorOptions } from '@tiptap/core'\nimport React, { createContext, ReactNode, useContext } from 'react'\n\nimport { Editor } from './Editor.js'\nimport { EditorContent } from './EditorContent.js'\nimport { useEditor } from './useEditor.js'\n\nexport type EditorContextValue = {\n editor: Editor | null;\n}\n\nexport const EditorContext = createContext<EditorContextValue>({\n editor: null,\n})\n\nexport const EditorConsumer = EditorContext.Consumer\n\nexport const useCurrentEditor = () => useContext(EditorContext)\n\nexport type EditorProviderProps = {\n children: ReactNode;\n slotBefore?: ReactNode;\n slotAfter?: ReactNode;\n} & Partial<EditorOptions>\n\nexport const EditorProvider = ({\n children, slotAfter, slotBefore, ...editorOptions\n}: EditorProviderProps) => {\n const editor = useEditor(editorOptions)\n\n if (!editor) {\n return null\n }\n\n return (\n <EditorContext.Provider value={{ editor }}>\n {slotBefore}\n <EditorConsumer>\n {({ editor: currentEditor }) => (\n <EditorContent editor={currentEditor} />\n )}\n </EditorConsumer>\n {children}\n {slotAfter}\n </EditorContext.Provider>\n )\n}\n","import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport React, { useEffect, useState } from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey' | 'editor'>, '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 const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu', editor, tippyOptions = {}, updateDelay, shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = BubbleMenuPlugin({\n updateDelay,\n editor: menuEditor,\n element,\n pluginKey,\n shouldShow,\n tippyOptions,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [props.editor, currentEditor, element])\n\n return (\n <div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport React, {\n useEffect, useState,\n} from 'react'\n\nimport { useCurrentEditor } from './Context.js'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey' | 'editor'>, 'element'> & {\n className?: string,\n children: React.ReactNode\n}\n\nexport const FloatingMenu = (props: FloatingMenuProps) => {\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const { editor: currentEditor } = useCurrentEditor()\n\n useEffect(() => {\n if (!element) {\n return\n }\n\n if (props.editor?.isDestroyed || currentEditor?.isDestroyed) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n const menuEditor = editor || currentEditor\n\n if (!menuEditor) {\n console.warn('FloatingMenu component is not rendered inside of an editor component or does not have editor prop.')\n return\n }\n\n const plugin = FloatingMenuPlugin({\n pluginKey,\n editor: menuEditor,\n element,\n tippyOptions,\n shouldShow,\n })\n\n menuEditor.registerPlugin(plugin)\n return () => menuEditor.unregisterPlugin(pluginKey)\n }, [\n props.editor,\n currentEditor,\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.js'\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.js'\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.js'\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 attrs?: Record<string, 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 attrs,\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 if (attrs) {\n Object.keys(attrs).forEach(key => {\n this.element.setAttribute(key, attrs[key])\n })\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.js'\nimport { ReactRenderer } from './ReactRenderer.js'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView.js'\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 attrs?: Record<string, 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 if (this.node.isLeaf) {\n this.contentDOMElement = null\n } else if (this.options.contentDOMElementTag) {\n this.contentDOMElement = document.createElement(this.options.contentDOMElementTag)\n } else {\n this.contentDOMElement = document.createElement(this.node.isInline ? 'span' : 'div')\n }\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.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\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 attrs: this.options.attrs,\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 handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n\n if (from <= this.getPos() && to >= this.getPos() + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\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 this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\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"],"names":["React","ReactDOM","flushSync","forwardRef","CoreEditor","useRef","useState","useEffect","createContext","useContext","BubbleMenuPlugin","FloatingMenuPlugin","NodeView"],"mappings":";;;;;;;;;;;EAQA,MAAM,SAAS,GAAG,CAChB,GAAG,IAA2D,KAC5D;MACF,OAAO,CAAC,IAAO,KAAI;EACjB,QAAA,IAAI,CAAC,OAAO,CAAC,GAAG,IAAG;EACjB,YAAA,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;kBAC7B,GAAG,CAAC,IAAI,CAAC,CAAA;EACV,aAAA;EAAM,iBAAA,IAAI,GAAG,EAAE;EACb,gBAAA,GAAkC,CAAC,OAAO,GAAG,IAAI,CAAA;EACnD,aAAA;EACH,SAAC,CAAC,CAAA;EACJ,KAAC,CAAA;EACH,CAAC,CAAA;EAED,MAAM,OAAO,GAA2D,CAAC,EAAE,SAAS,EAAE,KAAI;EACxF,IAAA,QACEA,yBACG,CAAA,aAAA,CAAAA,yBAAA,CAAA,QAAA,EAAA,IAAA,EAAA,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAI;EACjD,QAAA,OAAOC,4BAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;OAC3E,CAAC,CACD,EACJ;EACH,CAAC,CAAA;EAWY,MAAA,iBAAkB,SAAQD,yBAAK,CAAC,SAAiD,CAAA;EAK5F,IAAA,WAAA,CAAY,KAAyB,EAAA;UACnC,KAAK,CAAC,KAAK,CAAC,CAAA;EACZ,QAAA,IAAI,CAAC,gBAAgB,GAAGA,yBAAK,CAAC,SAAS,EAAE,C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,EAAE,WAAW,EAAE,CAAC,CAAA;EAElC,QAAA,OAAO,IAAI,CAAA;OACZ;MAED,UAAU,GAAA;EACR,QAAA,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;EACxB,YAAA,QAAQ,EAAE,IAAI;EACf,SAAA,CAAC,CAAA;UACF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;OAChE;MAED,YAAY,GAAA;EACV,QAAA,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;EACxB,YAAA,QAAQ,EAAE,KAAK;EAChB,SAAA,CAAC,CAAA;UACF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAA;OACnE;MAED,OAAO,GAAA;EACL,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;UACvB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;EAC9D,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAA;OAC9B;EACF,CAAA;EAEe,SAAA,qBAAqB,CACnC,SAAc,EACd,OAA+C,EAAA;MAE/C,OAAO,CAAC,KAA4B,KAAI;;;;EAItC,QAAA,IAAI,CAAE,KAAK,CAAC,MAAiB,CAAC,gBAAgB,EAAE;EAC9C,YAAA,OAAO,EAAE,CAAA;EACV,SAAA;UAED,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAmC,CAAA;EACvF,KAAC,CAAA;EACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
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.2.0",
4
+ "version": "2.2.2",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -29,12 +29,12 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@tiptap/extension-bubble-menu": "^2.2.0",
33
- "@tiptap/extension-floating-menu": "^2.2.0"
32
+ "@tiptap/extension-bubble-menu": "^2.2.2",
33
+ "@tiptap/extension-floating-menu": "^2.2.2"
34
34
  },
35
35
  "devDependencies": {
36
- "@tiptap/core": "^2.2.0",
37
- "@tiptap/pm": "^2.2.0",
36
+ "@tiptap/core": "^2.2.2",
37
+ "@tiptap/pm": "^2.2.2",
38
38
  "@types/react": "^18.2.14",
39
39
  "@types/react-dom": "^18.2.6",
40
40
  "react": "^18.0.0",
package/src/useEditor.ts CHANGED
@@ -8,16 +8,9 @@ import {
8
8
 
9
9
  import { Editor } from './Editor.js'
10
10
 
11
- function useForceUpdate() {
12
- const [, setValue] = useState(0)
13
-
14
- return () => setValue(value => value + 1)
15
- }
16
-
17
11
  export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {
18
- const [editor, setEditor] = useState<Editor | null>(null)
19
-
20
- const forceUpdate = useForceUpdate()
12
+ const editorRef = useRef<Editor | null>(null)
13
+ const [, forceUpdate] = useState({})
21
14
 
22
15
  const {
23
16
  onBeforeCreate,
@@ -42,71 +35,77 @@ export const useEditor = (options: Partial<EditorOptions> = {}, deps: Dependency
42
35
  // This effect will handle updating the editor instance
43
36
  // when the event handlers change.
44
37
  useEffect(() => {
45
- if (!editor) {
38
+ if (!editorRef.current) {
46
39
  return
47
40
  }
48
41
 
49
42
  if (onBeforeCreate) {
50
- editor.off('beforeCreate', onBeforeCreateRef.current)
51
- editor.on('beforeCreate', onBeforeCreate)
43
+ editorRef.current.off('beforeCreate', onBeforeCreateRef.current)
44
+ editorRef.current.on('beforeCreate', onBeforeCreate)
45
+
52
46
  onBeforeCreateRef.current = onBeforeCreate
53
47
  }
54
48
 
55
49
  if (onBlur) {
56
- editor.off('blur', onBlurRef.current)
57
- editor.on('blur', onBlur)
50
+ editorRef.current.off('blur', onBlurRef.current)
51
+ editorRef.current.on('blur', onBlur)
52
+
58
53
  onBlurRef.current = onBlur
59
54
  }
60
55
 
61
56
  if (onCreate) {
62
- editor.off('create', onCreateRef.current)
63
- editor.on('create', onCreate)
57
+ editorRef.current.off('create', onCreateRef.current)
58
+ editorRef.current.on('create', onCreate)
59
+
64
60
  onCreateRef.current = onCreate
65
61
  }
66
62
 
67
63
  if (onDestroy) {
68
- editor.off('destroy', onDestroyRef.current)
69
- editor.on('destroy', onDestroy)
64
+ editorRef.current.off('destroy', onDestroyRef.current)
65
+ editorRef.current.on('destroy', onDestroy)
66
+
70
67
  onDestroyRef.current = onDestroy
71
68
  }
72
69
 
73
70
  if (onFocus) {
74
- editor.off('focus', onFocusRef.current)
75
- editor.on('focus', onFocus)
71
+ editorRef.current.off('focus', onFocusRef.current)
72
+ editorRef.current.on('focus', onFocus)
73
+
76
74
  onFocusRef.current = onFocus
77
75
  }
78
76
 
79
77
  if (onSelectionUpdate) {
80
- editor.off('selectionUpdate', onSelectionUpdateRef.current)
81
- editor.on('selectionUpdate', onSelectionUpdate)
78
+ editorRef.current.off('selectionUpdate', onSelectionUpdateRef.current)
79
+ editorRef.current.on('selectionUpdate', onSelectionUpdate)
80
+
82
81
  onSelectionUpdateRef.current = onSelectionUpdate
83
82
  }
84
83
 
85
84
  if (onTransaction) {
86
- editor.off('transaction', onTransactionRef.current)
87
- editor.on('transaction', onTransaction)
85
+ editorRef.current.off('transaction', onTransactionRef.current)
86
+ editorRef.current.on('transaction', onTransaction)
87
+
88
88
  onTransactionRef.current = onTransaction
89
89
  }
90
90
 
91
91
  if (onUpdate) {
92
- editor.off('update', onUpdateRef.current)
93
- editor.on('update', onUpdate)
92
+ editorRef.current.off('update', onUpdateRef.current)
93
+ editorRef.current.on('update', onUpdate)
94
+
94
95
  onUpdateRef.current = onUpdate
95
96
  }
96
- }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editor])
97
+ }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current])
97
98
 
98
99
  useEffect(() => {
99
100
  let isMounted = true
100
101
 
101
- const instance = new Editor(options)
102
-
103
- setEditor(instance)
102
+ editorRef.current = new Editor(options)
104
103
 
105
- instance.on('transaction', () => {
104
+ editorRef.current.on('transaction', () => {
106
105
  requestAnimationFrame(() => {
107
106
  requestAnimationFrame(() => {
108
107
  if (isMounted) {
109
- forceUpdate()
108
+ forceUpdate({})
110
109
  }
111
110
  })
112
111
  })
@@ -119,9 +118,9 @@ export const useEditor = (options: Partial<EditorOptions> = {}, deps: Dependency
119
118
 
120
119
  useEffect(() => {
121
120
  return () => {
122
- editor?.destroy()
121
+ return editorRef.current?.destroy()
123
122
  }
124
- }, [editor])
123
+ }, [])
125
124
 
126
- return editor
125
+ return editorRef.current
127
126
  }