@tiptap/react 2.0.0-beta.82 → 2.0.0-beta.86
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/packages/core/src/Editor.d.ts +5 -0
- package/dist/packages/core/src/Extension.d.ts +56 -23
- package/dist/packages/core/src/Mark.d.ts +72 -31
- package/dist/packages/core/src/Node.d.ts +86 -38
- package/dist/packages/core/src/commands/insertContent.d.ts +2 -2
- package/dist/packages/core/src/commands/insertContentAt.d.ts +2 -2
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +1 -1
- package/dist/packages/core/src/extensions/commands.d.ts +1 -1
- package/dist/packages/core/src/extensions/editable.d.ts +1 -1
- package/dist/packages/core/src/extensions/focusEvents.d.ts +1 -1
- package/dist/packages/core/src/extensions/keymap.d.ts +1 -1
- package/dist/packages/core/src/extensions/tabindex.d.ts +1 -1
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +2 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +3 -3
- package/dist/packages/core/src/index.d.ts +3 -3
- package/dist/packages/core/src/style.d.ts +1 -1
- package/dist/packages/core/src/types.d.ts +2 -0
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
- package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
- package/dist/packages/extension-blockquote/src/blockquote.d.ts +1 -1
- package/dist/packages/extension-bold/src/bold.d.ts +1 -1
- package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +1 -1
- package/dist/packages/extension-bullet-list/src/bullet-list.d.ts +1 -1
- package/dist/packages/extension-character-count/src/character-count.d.ts +1 -1
- package/dist/packages/extension-code/src/code.d.ts +1 -1
- package/dist/packages/extension-code-block/src/code-block.d.ts +1 -1
- package/dist/packages/extension-code-block-lowlight/src/code-block-lowlight.d.ts +1 -1
- package/dist/packages/extension-collaboration/src/collaboration.d.ts +1 -1
- package/dist/packages/extension-collaboration-cursor/src/collaboration-cursor.d.ts +1 -1
- package/dist/packages/extension-color/src/color.d.ts +1 -1
- package/dist/packages/extension-document/src/document.d.ts +1 -1
- package/dist/packages/extension-dropcursor/src/dropcursor.d.ts +1 -1
- package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +1 -1
- package/dist/packages/extension-focus/src/focus.d.ts +1 -1
- package/dist/packages/extension-font-family/src/font-family.d.ts +1 -1
- package/dist/packages/extension-gapcursor/src/gapcursor.d.ts +3 -2
- package/dist/packages/extension-hard-break/src/hard-break.d.ts +1 -1
- package/dist/packages/extension-heading/src/heading.d.ts +1 -1
- package/dist/packages/extension-highlight/src/highlight.d.ts +1 -1
- package/dist/packages/extension-history/src/history.d.ts +1 -1
- package/dist/packages/extension-horizontal-rule/src/horizontal-rule.d.ts +1 -1
- package/dist/packages/extension-image/src/image.d.ts +1 -1
- package/dist/packages/extension-italic/src/italic.d.ts +1 -1
- package/dist/packages/extension-link/src/link.d.ts +1 -1
- package/dist/packages/extension-list-item/src/list-item.d.ts +1 -1
- package/dist/packages/extension-mention/src/mention.d.ts +1 -1
- package/dist/packages/extension-ordered-list/src/ordered-list.d.ts +1 -1
- package/dist/packages/extension-paragraph/src/paragraph.d.ts +1 -1
- package/dist/packages/extension-placeholder/src/placeholder.d.ts +1 -1
- package/dist/packages/extension-strike/src/strike.d.ts +1 -1
- package/dist/packages/extension-subscript/src/subscript.d.ts +1 -1
- package/dist/packages/extension-superscript/src/superscript.d.ts +1 -1
- package/dist/packages/extension-table/src/table.d.ts +3 -2
- package/dist/packages/extension-table-cell/src/table-cell.d.ts +1 -1
- package/dist/packages/extension-table-header/src/table-header.d.ts +1 -1
- package/dist/packages/extension-table-row/src/table-row.d.ts +1 -1
- package/dist/packages/extension-task-item/src/task-item.d.ts +1 -1
- package/dist/packages/extension-task-list/src/task-list.d.ts +1 -1
- package/dist/packages/extension-text/src/text.d.ts +1 -1
- package/dist/packages/extension-text-align/src/text-align.d.ts +1 -1
- package/dist/packages/extension-text-style/src/text-style.d.ts +1 -1
- package/dist/packages/extension-typography/src/typography.d.ts +1 -1
- package/dist/packages/extension-underline/src/underline.d.ts +1 -1
- package/dist/packages/starter-kit/src/starter-kit.d.ts +1 -1
- package/dist/packages/suggestion/src/suggestion.d.ts +4 -1
- package/dist/tiptap-react.cjs.js +10 -4
- package/dist/tiptap-react.cjs.js.map +1 -1
- package/dist/tiptap-react.esm.js +10 -4
- package/dist/tiptap-react.esm.js.map +1 -1
- package/dist/tiptap-react.umd.js +10 -4
- package/dist/tiptap-react.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/ReactNodeViewRenderer.tsx +4 -4
- package/src/useEditor.ts +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-react.umd.js","sources":["../src/BubbleMenu.tsx","../src/Editor.ts","../src/FloatingMenu.tsx","../src/useEditor.ts","../src/ReactRenderer.tsx","../src/useReactNodeView.ts","../src/ReactNodeViewRenderer.tsx","../src/EditorContent.tsx","../src/NodeViewWrapper.tsx","../src/NodeViewContent.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const BubbleMenu: React.FC<BubbleMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!element.current) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n editor.registerPlugin(BubbleMenuPlugin({\n pluginKey,\n editor,\n element: element.current as HTMLElement,\n tippyOptions,\n shouldShow,\n }))\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n }\n }, [\n props.editor,\n element.current,\n ])\n\n return (\n <div ref={element} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import React from 'react'\nimport { Editor as CoreEditor } from '@tiptap/core'\nimport { EditorContentProps, EditorContentState } from './EditorContent'\n\nexport class Editor extends CoreEditor {\n public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null\n}\n","import React, { useEffect, useRef } from 'react'\nimport { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!element.current) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n editor.registerPlugin(FloatingMenuPlugin({\n pluginKey,\n editor,\n element: element.current as HTMLElement,\n tippyOptions,\n shouldShow,\n }))\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n }\n }, [\n props.editor,\n element.current,\n ])\n\n return (\n <div ref={element} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { useState, useEffect, DependencyList } from 'react'\nimport { EditorOptions } from '@tiptap/core'\nimport { Editor } from './Editor'\n\nfunction useForceUpdate() {\n const [, setValue] = useState(0)\n\n return () => setValue(value => value + 1)\n}\n\nexport const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {\n const [editor, setEditor] = useState<Editor | null>(null)\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n const instance = new Editor(options)\n\n setEditor(instance)\n\n instance.on('transaction', forceUpdate)\n\n return () => {\n instance.destroy()\n }\n }, deps)\n\n return editor\n}\n","import React from 'react'\nimport { Editor } from '@tiptap/core'\nimport { Editor as ExtendedEditor } from './Editor'\n\nfunction isClassComponent(Component: any) {\n return !!(\n typeof Component === 'function'\n && Component.prototype\n && Component.prototype.isReactComponent\n )\n}\n\nfunction isForwardRefComponent(Component: any) {\n return !!(\n typeof Component === 'object'\n && Component.$$typeof?.toString() === 'Symbol(react.forward_ref)'\n )\n}\n\nexport interface ReactRendererOptions {\n editor: Editor,\n props?: Record<string, any>,\n as?: string,\n}\n\ntype ComponentType<R> =\n | React.ComponentClass\n | React.FunctionComponent\n | React.ForwardRefExoticComponent<{ items: any[], command: any } & React.RefAttributes<R>>\n\nexport class ReactRenderer<R = 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>, { editor, props = {}, as = 'div' }: 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 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 if (this.editor?.contentComponent) {\n this.editor.contentComponent.setState({\n renderers: this.editor.contentComponent.state.renderers.set(\n this.id,\n this,\n ),\n })\n }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n this.props = {\n ...this.props,\n ...props,\n }\n\n this.render()\n }\n\n destroy(): void {\n if (this.editor?.contentComponent) {\n const { renderers } = this.editor.contentComponent.state\n\n renderers.delete(this.id)\n\n this.editor.contentComponent.setState({\n renderers,\n })\n }\n }\n}\n","import { createContext, useContext } from 'react'\n\nexport interface ReactNodeViewContextProps {\n 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'\nimport {\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererProps,\n NodeViewRendererOptions,\n} from '@tiptap/core'\nimport { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView'\n\nexport interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {\n update: ((props: {\n oldNode: ProseMirrorNode,\n oldDecorations: Decoration[],\n newNode: ProseMirrorNode,\n newDecorations: Decoration[],\n updateProps: () => void,\n }) => boolean) | null,\n}\n\nclass ReactNodeView extends NodeView<React.FunctionComponent, Editor, 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 (\n element\n && this.contentDOMElement\n && element.firstChild !== this.contentDOMElement\n ) {\n element.appendChild(this.contentDOMElement)\n }\n }\n\n return (\n <ReactNodeViewContext.Provider value={{ onDragStart, nodeViewContentRef }}>\n <Component {...componentProps} />\n </ReactNodeViewContext.Provider>\n )\n }\n\n ReactNodeViewProvider.displayName = 'ReactNodeView'\n\n this.contentDOMElement = this.node.isLeaf\n ? null\n : document.createElement(this.node.isInline ? 'span' : 'div')\n\n if (this.contentDOMElement) {\n // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari\n // With this fix it seems to work fine\n // See: https://github.com/ueberdosis/tiptap/issues/1197\n this.contentDOMElement.style.whiteSpace = 'inherit'\n }\n\n this.renderer = new ReactRenderer(ReactNodeViewProvider, {\n editor: this.editor,\n props,\n as: this.node.isInline\n ? 'span'\n : 'div',\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\n }\n\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.contentDOMElement\n }\n\n update(node: ProseMirrorNode, decorations: Decoration[]) {\n const updateProps = (props?: Record<string, any>) => {\n this.renderer.updateProps(props)\n }\n\n if (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.type !== this.node.type) {\n return false\n }\n\n if (node === this.node && this.decorations === decorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n\n updateProps({ node, decorations })\n\n return true\n }\n\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n }\n\n destroy() {\n this.renderer.destroy()\n this.contentDOMElement = null\n }\n}\n\nexport function ReactNodeViewRenderer(component: any, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer {\n return (props: NodeViewRendererProps) => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {}\n }\n\n return new ReactNodeView(component, props, options) as ProseMirrorNodeView\n }\n}\n","import React, { HTMLProps } from 'react'\nimport ReactDOM from 'react-dom'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\n\nconst Portals: React.FC<{ renderers: Map<string, ReactRenderer> }> = ({ renderers }) => {\n return (\n <>\n {Array.from(renderers).map(([key, renderer]) => {\n return ReactDOM.createPortal(\n renderer.reactElement,\n renderer.element,\n key,\n )\n })}\n </>\n )\n}\n\nexport interface EditorContentProps extends HTMLProps<HTMLDivElement> {\n editor: Editor | null,\n}\n\nexport interface EditorContentState {\n renderers: Map<string, ReactRenderer>\n}\n\nexport class PureEditorContent extends React.Component<EditorContentProps, EditorContentState> {\n editorContentRef: React.RefObject<any>\n\n constructor(props: EditorContentProps) {\n super(props)\n this.editorContentRef = React.createRef()\n\n this.state = {\n renderers: new Map(),\n }\n }\n\n componentDidMount() {\n this.init()\n }\n\n componentDidUpdate() {\n this.init()\n }\n\n init() {\n const { editor } = this.props\n\n if (editor && editor.options.element) {\n if (editor.contentComponent) {\n return\n }\n\n const element = this.editorContentRef.current\n\n element.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element,\n })\n\n editor.contentComponent = this\n\n editor.createNodeViews()\n }\n }\n\n componentWillUnmount() {\n const { editor } = this.props\n\n if (!editor) {\n return\n }\n\n if (!editor.isDestroyed) {\n editor.view.setProps({\n nodeViews: {},\n })\n }\n\n editor.contentComponent = null\n\n if (!editor.options.element.firstChild) {\n return\n }\n\n const newElement = document.createElement('div')\n\n newElement.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element: newElement,\n })\n }\n\n render() {\n const { editor, ...rest } = this.props\n\n return (\n <>\n <div ref={this.editorContentRef} {...rest} />\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\nexport const EditorContent = React.memo(PureEditorContent)\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewWrapperProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewWrapper: React.FC<NodeViewWrapperProps> = React.forwardRef((props, ref) => {\n const { onDragStart } = useReactNodeView()\n const Tag = props.as || 'div'\n\n return (\n <Tag\n {...props}\n ref={ref}\n data-node-view-wrapper=\"\"\n onDragStart={onDragStart}\n style={{\n ...props.style,\n whiteSpace: 'normal',\n }}\n />\n )\n})\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewContentProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewContent: React.FC<NodeViewContentProps> = props => {\n const Tag = props.as || 'div'\n const { nodeViewContentRef } = useReactNodeView()\n\n return (\n <Tag\n {...props}\n ref={nodeViewContentRef}\n data-node-view-content=\"\"\n style={{\n ...props.style,\n whiteSpace: 'pre-wrap',\n }}\n />\n )\n}\n"],"names":["useRef","useEffect","BubbleMenuPlugin","React","CoreEditor","FloatingMenuPlugin","useState","createContext","useContext","NodeView","ReactDOM"],"mappings":";;;;;;;;;;;QASa,UAAU,GAA8B,KAAK;MACxD,MAAM,OAAO,GAAGA,YAAM,CAAiB,IAAI,CAAC,CAAA;MAE5CC,eAAS,CAAC;UACR,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;cACpB,OAAM;WACP;UAED,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,GAClB,GAAG,KAAK,CAAA;UAET,MAAM,CAAC,cAAc,CAACC,oCAAgB,CAAC;cACrC,SAAS;cACT,MAAM;cACN,OAAO,EAAE,OAAO,CAAC,OAAsB;cACvC,YAAY;cACZ,UAAU;WACX,CAAC,CAAC,CAAA;UAEH,OAAO;cACL,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;WACnC,CAAA;OACF,EAAE;UACD,KAAK,CAAC,MAAM;UACZ,OAAO,CAAC,OAAO;OAChB,CAAC,CAAA;MAEF,QACEC,iDAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,IAC3E,KAAK,CAAC,QAA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,EAAE,EACzB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE;cACL,GAAG,KAAK,CAAC,KAAK;cACd,UAAU,EAAE,QAAQ;WACrB,GACD,EACH;EACH,CAAC;;QChBY,eAAe,GAAmC,KAAK;MAClE,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;MAC7B,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;MAEjD,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,kBAAkB,4BACA,EAAE,EACzB,KAAK,EAAE;cACL,GAAG,KAAK,CAAC,KAAK;cACd,UAAU,EAAE,UAAU;WACvB,GACD,EACH;EACH;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"tiptap-react.umd.js","sources":["../src/BubbleMenu.tsx","../src/Editor.ts","../src/FloatingMenu.tsx","../src/useEditor.ts","../src/ReactRenderer.tsx","../src/useReactNodeView.ts","../src/ReactNodeViewRenderer.tsx","../src/EditorContent.tsx","../src/NodeViewWrapper.tsx","../src/NodeViewContent.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type BubbleMenuProps = Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const BubbleMenu: React.FC<BubbleMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!element.current) {\n return\n }\n\n const {\n pluginKey = 'bubbleMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n editor.registerPlugin(BubbleMenuPlugin({\n pluginKey,\n editor,\n element: element.current as HTMLElement,\n tippyOptions,\n shouldShow,\n }))\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n }\n }, [\n props.editor,\n element.current,\n ])\n\n return (\n <div ref={element} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import React from 'react'\nimport { Editor as CoreEditor } from '@tiptap/core'\nimport { EditorContentProps, EditorContentState } from './EditorContent'\n\nexport class Editor extends CoreEditor {\n public contentComponent: React.Component<EditorContentProps, EditorContentState> | null = null\n}\n","import React, { useEffect, useRef } from 'react'\nimport { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey'>, 'element'> & {\n className?: string,\n}\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = props => {\n const element = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!element.current) {\n return\n }\n\n const {\n pluginKey = 'floatingMenu',\n editor,\n tippyOptions = {},\n shouldShow = null,\n } = props\n\n editor.registerPlugin(FloatingMenuPlugin({\n pluginKey,\n editor,\n element: element.current as HTMLElement,\n tippyOptions,\n shouldShow,\n }))\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n }\n }, [\n props.editor,\n element.current,\n ])\n\n return (\n <div ref={element} className={props.className} style={{ visibility: 'hidden' }}>\n {props.children}\n </div>\n )\n}\n","import { useState, useEffect, DependencyList } from 'react'\nimport { EditorOptions } from '@tiptap/core'\nimport { Editor } from './Editor'\n\nfunction useForceUpdate() {\n const [, setValue] = useState(0)\n\n return () => setValue(value => value + 1)\n}\n\nexport const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {\n const [editor, setEditor] = useState<Editor | null>(null)\n const forceUpdate = useForceUpdate()\n\n useEffect(() => {\n const instance = new Editor(options)\n\n setEditor(instance)\n\n instance.on('transaction', () => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n forceUpdate()\n })\n })\n })\n\n return () => {\n instance.destroy()\n }\n }, deps)\n\n return editor\n}\n","import React from 'react'\nimport { Editor } from '@tiptap/core'\nimport { Editor as ExtendedEditor } from './Editor'\n\nfunction isClassComponent(Component: any) {\n return !!(\n typeof Component === 'function'\n && Component.prototype\n && Component.prototype.isReactComponent\n )\n}\n\nfunction isForwardRefComponent(Component: any) {\n return !!(\n typeof Component === 'object'\n && Component.$$typeof?.toString() === 'Symbol(react.forward_ref)'\n )\n}\n\nexport interface ReactRendererOptions {\n editor: Editor,\n props?: Record<string, any>,\n as?: string,\n}\n\ntype ComponentType<R> =\n | React.ComponentClass\n | React.FunctionComponent\n | React.ForwardRefExoticComponent<{ items: any[], command: any } & React.RefAttributes<R>>\n\nexport class ReactRenderer<R = 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>, { editor, props = {}, as = 'div' }: 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 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 if (this.editor?.contentComponent) {\n this.editor.contentComponent.setState({\n renderers: this.editor.contentComponent.state.renderers.set(\n this.id,\n this,\n ),\n })\n }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n this.props = {\n ...this.props,\n ...props,\n }\n\n this.render()\n }\n\n destroy(): void {\n if (this.editor?.contentComponent) {\n const { renderers } = this.editor.contentComponent.state\n\n renderers.delete(this.id)\n\n this.editor.contentComponent.setState({\n renderers,\n })\n }\n }\n}\n","import { createContext, useContext } from 'react'\n\nexport interface ReactNodeViewContextProps {\n 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'\nimport {\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererProps,\n NodeViewRendererOptions,\n} from '@tiptap/core'\nimport { Decoration, NodeView as ProseMirrorNodeView } from 'prosemirror-view'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\nimport { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView'\n\nexport interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {\n update: ((props: {\n oldNode: ProseMirrorNode,\n oldDecorations: Decoration[],\n newNode: ProseMirrorNode,\n newDecorations: Decoration[],\n updateProps: () => void,\n }) => boolean) | null,\n}\n\nclass ReactNodeView extends NodeView<React.FunctionComponent, Editor, 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 (\n element\n && this.contentDOMElement\n && element.firstChild !== this.contentDOMElement\n ) {\n element.appendChild(this.contentDOMElement)\n }\n }\n\n return (\n <ReactNodeViewContext.Provider value={{ onDragStart, nodeViewContentRef }}>\n <Component {...componentProps} />\n </ReactNodeViewContext.Provider>\n )\n }\n\n ReactNodeViewProvider.displayName = 'ReactNodeView'\n\n this.contentDOMElement = this.node.isLeaf\n ? null\n : document.createElement(this.node.isInline ? 'span' : 'div')\n\n if (this.contentDOMElement) {\n // For some reason the whiteSpace prop is not inherited properly in Chrome and Safari\n // With this fix it seems to work fine\n // See: https://github.com/ueberdosis/tiptap/issues/1197\n this.contentDOMElement.style.whiteSpace = 'inherit'\n }\n\n this.renderer = new ReactRenderer(ReactNodeViewProvider, {\n editor: this.editor,\n props,\n as: this.node.isInline\n ? 'span'\n : 'div',\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\n }\n\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.contentDOMElement\n }\n\n update(node: ProseMirrorNode, decorations: Decoration[]) {\n const updateProps = (props?: Record<string, any>) => {\n this.renderer.updateProps(props)\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (typeof this.options.update === 'function') {\n const oldNode = this.node\n const oldDecorations = this.decorations\n\n this.node = node\n this.decorations = decorations\n\n return this.options.update({\n oldNode,\n oldDecorations,\n newNode: node,\n newDecorations: decorations,\n updateProps: () => updateProps({ node, decorations }),\n })\n }\n\n if (node === this.node && this.decorations === decorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n\n updateProps({ node, decorations })\n\n return true\n }\n\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n }\n\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n }\n\n destroy() {\n this.renderer.destroy()\n this.contentDOMElement = null\n }\n}\n\nexport function ReactNodeViewRenderer(component: any, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer {\n return (props: NodeViewRendererProps) => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {}\n }\n\n return new ReactNodeView(component, props, options) as ProseMirrorNodeView\n }\n}\n","import React, { HTMLProps } from 'react'\nimport ReactDOM from 'react-dom'\nimport { Editor } from './Editor'\nimport { ReactRenderer } from './ReactRenderer'\n\nconst Portals: React.FC<{ renderers: Map<string, ReactRenderer> }> = ({ renderers }) => {\n return (\n <>\n {Array.from(renderers).map(([key, renderer]) => {\n return ReactDOM.createPortal(\n renderer.reactElement,\n renderer.element,\n key,\n )\n })}\n </>\n )\n}\n\nexport interface EditorContentProps extends HTMLProps<HTMLDivElement> {\n editor: Editor | null,\n}\n\nexport interface EditorContentState {\n renderers: Map<string, ReactRenderer>\n}\n\nexport class PureEditorContent extends React.Component<EditorContentProps, EditorContentState> {\n editorContentRef: React.RefObject<any>\n\n constructor(props: EditorContentProps) {\n super(props)\n this.editorContentRef = React.createRef()\n\n this.state = {\n renderers: new Map(),\n }\n }\n\n componentDidMount() {\n this.init()\n }\n\n componentDidUpdate() {\n this.init()\n }\n\n init() {\n const { editor } = this.props\n\n if (editor && editor.options.element) {\n if (editor.contentComponent) {\n return\n }\n\n const element = this.editorContentRef.current\n\n element.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element,\n })\n\n editor.contentComponent = this\n\n editor.createNodeViews()\n }\n }\n\n componentWillUnmount() {\n const { editor } = this.props\n\n if (!editor) {\n return\n }\n\n if (!editor.isDestroyed) {\n editor.view.setProps({\n nodeViews: {},\n })\n }\n\n editor.contentComponent = null\n\n if (!editor.options.element.firstChild) {\n return\n }\n\n const newElement = document.createElement('div')\n\n newElement.append(...editor.options.element.childNodes)\n\n editor.setOptions({\n element: newElement,\n })\n }\n\n render() {\n const { editor, ...rest } = this.props\n\n return (\n <>\n <div ref={this.editorContentRef} {...rest} />\n <Portals renderers={this.state.renderers} />\n </>\n )\n }\n}\n\nexport const EditorContent = React.memo(PureEditorContent)\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewWrapperProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewWrapper: React.FC<NodeViewWrapperProps> = React.forwardRef((props, ref) => {\n const { onDragStart } = useReactNodeView()\n const Tag = props.as || 'div'\n\n return (\n <Tag\n {...props}\n ref={ref}\n data-node-view-wrapper=\"\"\n onDragStart={onDragStart}\n style={{\n ...props.style,\n whiteSpace: 'normal',\n }}\n />\n )\n})\n","import React from 'react'\nimport { useReactNodeView } from './useReactNodeView'\n\nexport interface NodeViewContentProps {\n [key: string]: any,\n as?: React.ElementType,\n}\n\nexport const NodeViewContent: React.FC<NodeViewContentProps> = props => {\n const Tag = props.as || 'div'\n const { nodeViewContentRef } = useReactNodeView()\n\n return (\n <Tag\n {...props}\n ref={nodeViewContentRef}\n data-node-view-content=\"\"\n style={{\n ...props.style,\n whiteSpace: 'pre-wrap',\n }}\n />\n )\n}\n"],"names":["useRef","useEffect","BubbleMenuPlugin","React","CoreEditor","FloatingMenuPlugin","useState","createContext","useContext","NodeView","ReactDOM"],"mappings":";;;;;;;;;;;QASa,UAAU,GAA8B,KAAK;MACxD,MAAM,OAAO,GAAGA,YAAM,CAAiB,IAAI,CAAC,CAAA;MAE5CC,eAAS,CAAC;UACR,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;cACpB,OAAM;WACP;UAED,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,GAClB,GAAG,KAAK,CAAA;UAET,MAAM,CAAC,cAAc,CAACC,oCAAgB,CAAC;cACrC,SAAS;cACT,MAAM;cACN,OAAO,EAAE,OAAO,CAAC,OAAsB;cACvC,YAAY;cACZ,UAAU;WACX,CAAC,CAAC,CAAA;UAEH,OAAO;cACL,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;WACnC,CAAA;OACF,EAAE;UACD,KAAK,CAAC,MAAM;UACZ,OAAO,CAAC,OAAO;OAChB,CAAC,CAAA;MAEF,QACEC,iDAAK,GAAG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C,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG;MACzF,MAAM,EAAE,WAAW,EAAE,GAAG,gBAAgB,EAAE,CAAA;MAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;MAE7B,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,GAAG,4BACe,EAAE,EACzB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE;cACL,GAAG,KAAK,CAAC,KAAK;cACd,UAAU,EAAE,QAAQ;WACrB,GACD,EACH;EACH,CAAC;;QChBY,eAAe,GAAmC,KAAK;MAClE,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;MAC7B,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;MAEjD,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,kBAAkB,4BACA,EAAE,EACzB,KAAK,EAAE;cACL,GAAG,KAAK,CAAC,KAAK;cACd,UAAU,EAAE,UAAU;WACvB,GACD,EACH;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.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.86",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/react": "^17.0.
|
|
25
|
-
"@types/react-dom": "^17.0.
|
|
24
|
+
"@types/react": "^17.0.32",
|
|
25
|
+
"@types/react-dom": "^17.0.10",
|
|
26
26
|
"react": "^17.0.0",
|
|
27
27
|
"react-dom": "^17.0.0"
|
|
28
28
|
},
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"react-dom": "^17.0.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tiptap/extension-bubble-menu": "^2.0.0-beta.
|
|
36
|
-
"@tiptap/extension-floating-menu": "^2.0.0-beta.
|
|
35
|
+
"@tiptap/extension-bubble-menu": "^2.0.0-beta.43",
|
|
36
|
+
"@tiptap/extension-floating-menu": "^2.0.0-beta.37",
|
|
37
37
|
"prosemirror-view": "^1.20.3"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"url": "https://github.com/ueberdosis/tiptap",
|
|
42
42
|
"directory": "packages/react"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "642627ec3635a1d8fa851887d75bee5f193ec63b"
|
|
45
45
|
}
|
|
@@ -114,6 +114,10 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeV
|
|
|
114
114
|
this.renderer.updateProps(props)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
if (node.type !== this.node.type) {
|
|
118
|
+
return false
|
|
119
|
+
}
|
|
120
|
+
|
|
117
121
|
if (typeof this.options.update === 'function') {
|
|
118
122
|
const oldNode = this.node
|
|
119
123
|
const oldDecorations = this.decorations
|
|
@@ -130,10 +134,6 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeV
|
|
|
130
134
|
})
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
if (node.type !== this.node.type) {
|
|
134
|
-
return false
|
|
135
|
-
}
|
|
136
|
-
|
|
137
137
|
if (node === this.node && this.decorations === decorations) {
|
|
138
138
|
return true
|
|
139
139
|
}
|
package/src/useEditor.ts
CHANGED
|
@@ -17,7 +17,13 @@ export const useEditor = (options: Partial<EditorOptions> = {}, deps: Dependency
|
|
|
17
17
|
|
|
18
18
|
setEditor(instance)
|
|
19
19
|
|
|
20
|
-
instance.on('transaction',
|
|
20
|
+
instance.on('transaction', () => {
|
|
21
|
+
requestAnimationFrame(() => {
|
|
22
|
+
requestAnimationFrame(() => {
|
|
23
|
+
forceUpdate()
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
})
|
|
21
27
|
|
|
22
28
|
return () => {
|
|
23
29
|
instance.destroy()
|