@tiptap/react 2.2.5 → 2.3.0

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
@@ -202,7 +202,8 @@ const useEditor = (options = {}, deps = []) => {
202
202
  }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current]);
203
203
  React.useEffect(() => {
204
204
  let isMounted = true;
205
- editorRef.current = new Editor(options);
205
+ const editor = new Editor(options);
206
+ editorRef.current = editor;
206
207
  editorRef.current.on('transaction', () => {
207
208
  requestAnimationFrame(() => {
208
209
  requestAnimationFrame(() => {
@@ -214,14 +215,9 @@ const useEditor = (options = {}, deps = []) => {
214
215
  });
215
216
  return () => {
216
217
  isMounted = false;
218
+ editor.destroy();
217
219
  };
218
220
  }, deps);
219
- React.useEffect(() => {
220
- return () => {
221
- var _a;
222
- return (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
223
- };
224
- }, []);
225
221
  return editorRef.current;
226
222
  };
227
223
 
@@ -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\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,G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,IAAI,CAAA;KACZ;IAED,UAAU,GAAA;AACR,QAAA,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;;;"}
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 const editor = new Editor(options)\n\n editorRef.current = editor\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 editor.destroy()\n }\n }, deps)\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,C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us, onSelectionUpdate, onTransaction, onUpdate, editorRef.current]);
195
195
  useEffect(() => {
196
196
  let isMounted = true;
197
- editorRef.current = new Editor(options);
197
+ const editor = new Editor(options);
198
+ editorRef.current = editor;
198
199
  editorRef.current.on('transaction', () => {
199
200
  requestAnimationFrame(() => {
200
201
  requestAnimationFrame(() => {
@@ -206,14 +207,9 @@ const useEditor = (options = {}, deps = []) => {
206
207
  });
207
208
  return () => {
208
209
  isMounted = false;
210
+ editor.destroy();
209
211
  };
210
212
  }, deps);
211
- useEffect(() => {
212
- return () => {
213
- var _a;
214
- return (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
215
- };
216
- }, []);
217
213
  return editorRef.current;
218
214
  };
219
215
 
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\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,OA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,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;;;;"}
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 const editor = new Editor(options)\n\n editorRef.current = editor\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 editor.destroy()\n }\n }, deps)\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":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AAI,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.umd.js CHANGED
@@ -198,7 +198,8 @@
198
198
  }, [onBeforeCreate, onBlur, onCreate, onDestroy, onFocus, onSelectionUpdate, onTransaction, onUpdate, editorRef.current]);
199
199
  React.useEffect(() => {
200
200
  let isMounted = true;
201
- editorRef.current = new Editor(options);
201
+ const editor = new Editor(options);
202
+ editorRef.current = editor;
202
203
  editorRef.current.on('transaction', () => {
203
204
  requestAnimationFrame(() => {
204
205
  requestAnimationFrame(() => {
@@ -210,14 +211,9 @@
210
211
  });
211
212
  return () => {
212
213
  isMounted = false;
214
+ editor.destroy();
213
215
  };
214
216
  }, deps);
215
- React.useEffect(() => {
216
- return () => {
217
- var _a;
218
- return (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
219
- };
220
- }, []);
221
217
  return editorRef.current;
222
218
  };
223
219
 
@@ -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\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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AAS,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 const editor = new Editor(options)\n\n editorRef.current = editor\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 editor.destroy()\n }\n }, deps)\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,CA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;;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.5",
4
+ "version": "2.3.0",
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.5",
33
- "@tiptap/extension-floating-menu": "^2.2.5"
32
+ "@tiptap/extension-bubble-menu": "^2.3.0",
33
+ "@tiptap/extension-floating-menu": "^2.3.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@tiptap/core": "^2.2.5",
37
- "@tiptap/pm": "^2.2.5",
36
+ "@tiptap/core": "^2.3.0",
37
+ "@tiptap/pm": "^2.3.0",
38
38
  "@types/react": "^18.2.14",
39
39
  "@types/react-dom": "^18.2.6",
40
40
  "react": "^18.0.0",
package/src/index.ts CHANGED
@@ -8,5 +8,5 @@ export * from './NodeViewWrapper.js'
8
8
  export * from './ReactNodeViewRenderer.js'
9
9
  export * from './ReactRenderer.js'
10
10
  export * from './useEditor.js'
11
- export * from './useReactNodeView.js';
11
+ export * from './useReactNodeView.js'
12
12
  export * from '@tiptap/core'
package/src/useEditor.ts CHANGED
@@ -99,7 +99,9 @@ export const useEditor = (options: Partial<EditorOptions> = {}, deps: Dependency
99
99
  useEffect(() => {
100
100
  let isMounted = true
101
101
 
102
- editorRef.current = new Editor(options)
102
+ const editor = new Editor(options)
103
+
104
+ editorRef.current = editor
103
105
 
104
106
  editorRef.current.on('transaction', () => {
105
107
  requestAnimationFrame(() => {
@@ -113,14 +115,9 @@ export const useEditor = (options: Partial<EditorOptions> = {}, deps: Dependency
113
115
 
114
116
  return () => {
115
117
  isMounted = false
118
+ editor.destroy()
116
119
  }
117
120
  }, deps)
118
121
 
119
- useEffect(() => {
120
- return () => {
121
- return editorRef.current?.destroy()
122
- }
123
- }, [])
124
-
125
122
  return editorRef.current
126
123
  }