@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.
Files changed (74) hide show
  1. package/dist/packages/core/src/Editor.d.ts +5 -0
  2. package/dist/packages/core/src/Extension.d.ts +56 -23
  3. package/dist/packages/core/src/Mark.d.ts +72 -31
  4. package/dist/packages/core/src/Node.d.ts +86 -38
  5. package/dist/packages/core/src/commands/insertContent.d.ts +2 -2
  6. package/dist/packages/core/src/commands/insertContentAt.d.ts +2 -2
  7. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +1 -1
  8. package/dist/packages/core/src/extensions/commands.d.ts +1 -1
  9. package/dist/packages/core/src/extensions/editable.d.ts +1 -1
  10. package/dist/packages/core/src/extensions/focusEvents.d.ts +1 -1
  11. package/dist/packages/core/src/extensions/keymap.d.ts +1 -1
  12. package/dist/packages/core/src/extensions/tabindex.d.ts +1 -1
  13. package/dist/packages/core/src/helpers/getExtensionField.d.ts +2 -2
  14. package/dist/packages/core/src/helpers/splitExtensions.d.ts +3 -3
  15. package/dist/packages/core/src/index.d.ts +3 -3
  16. package/dist/packages/core/src/style.d.ts +1 -1
  17. package/dist/packages/core/src/types.d.ts +2 -0
  18. package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
  19. package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
  20. package/dist/packages/extension-blockquote/src/blockquote.d.ts +1 -1
  21. package/dist/packages/extension-bold/src/bold.d.ts +1 -1
  22. package/dist/packages/extension-bubble-menu/src/bubble-menu.d.ts +1 -1
  23. package/dist/packages/extension-bullet-list/src/bullet-list.d.ts +1 -1
  24. package/dist/packages/extension-character-count/src/character-count.d.ts +1 -1
  25. package/dist/packages/extension-code/src/code.d.ts +1 -1
  26. package/dist/packages/extension-code-block/src/code-block.d.ts +1 -1
  27. package/dist/packages/extension-code-block-lowlight/src/code-block-lowlight.d.ts +1 -1
  28. package/dist/packages/extension-collaboration/src/collaboration.d.ts +1 -1
  29. package/dist/packages/extension-collaboration-cursor/src/collaboration-cursor.d.ts +1 -1
  30. package/dist/packages/extension-color/src/color.d.ts +1 -1
  31. package/dist/packages/extension-document/src/document.d.ts +1 -1
  32. package/dist/packages/extension-dropcursor/src/dropcursor.d.ts +1 -1
  33. package/dist/packages/extension-floating-menu/src/floating-menu.d.ts +1 -1
  34. package/dist/packages/extension-focus/src/focus.d.ts +1 -1
  35. package/dist/packages/extension-font-family/src/font-family.d.ts +1 -1
  36. package/dist/packages/extension-gapcursor/src/gapcursor.d.ts +3 -2
  37. package/dist/packages/extension-hard-break/src/hard-break.d.ts +1 -1
  38. package/dist/packages/extension-heading/src/heading.d.ts +1 -1
  39. package/dist/packages/extension-highlight/src/highlight.d.ts +1 -1
  40. package/dist/packages/extension-history/src/history.d.ts +1 -1
  41. package/dist/packages/extension-horizontal-rule/src/horizontal-rule.d.ts +1 -1
  42. package/dist/packages/extension-image/src/image.d.ts +1 -1
  43. package/dist/packages/extension-italic/src/italic.d.ts +1 -1
  44. package/dist/packages/extension-link/src/link.d.ts +1 -1
  45. package/dist/packages/extension-list-item/src/list-item.d.ts +1 -1
  46. package/dist/packages/extension-mention/src/mention.d.ts +1 -1
  47. package/dist/packages/extension-ordered-list/src/ordered-list.d.ts +1 -1
  48. package/dist/packages/extension-paragraph/src/paragraph.d.ts +1 -1
  49. package/dist/packages/extension-placeholder/src/placeholder.d.ts +1 -1
  50. package/dist/packages/extension-strike/src/strike.d.ts +1 -1
  51. package/dist/packages/extension-subscript/src/subscript.d.ts +1 -1
  52. package/dist/packages/extension-superscript/src/superscript.d.ts +1 -1
  53. package/dist/packages/extension-table/src/table.d.ts +3 -2
  54. package/dist/packages/extension-table-cell/src/table-cell.d.ts +1 -1
  55. package/dist/packages/extension-table-header/src/table-header.d.ts +1 -1
  56. package/dist/packages/extension-table-row/src/table-row.d.ts +1 -1
  57. package/dist/packages/extension-task-item/src/task-item.d.ts +1 -1
  58. package/dist/packages/extension-task-list/src/task-list.d.ts +1 -1
  59. package/dist/packages/extension-text/src/text.d.ts +1 -1
  60. package/dist/packages/extension-text-align/src/text-align.d.ts +1 -1
  61. package/dist/packages/extension-text-style/src/text-style.d.ts +1 -1
  62. package/dist/packages/extension-typography/src/typography.d.ts +1 -1
  63. package/dist/packages/extension-underline/src/underline.d.ts +1 -1
  64. package/dist/packages/starter-kit/src/starter-kit.d.ts +1 -1
  65. package/dist/packages/suggestion/src/suggestion.d.ts +4 -1
  66. package/dist/tiptap-react.cjs.js +10 -4
  67. package/dist/tiptap-react.cjs.js.map +1 -1
  68. package/dist/tiptap-react.esm.js +10 -4
  69. package/dist/tiptap-react.esm.js.map +1 -1
  70. package/dist/tiptap-react.umd.js +10 -4
  71. package/dist/tiptap-react.umd.js.map +1 -1
  72. package/package.json +6 -6
  73. package/src/ReactNodeViewRenderer.tsx +4 -4
  74. package/src/useEditor.ts +7 -1
@@ -22,5 +22,5 @@ declare module '@tiptap/core' {
22
22
  };
23
23
  }
24
24
  }
25
- export declare const Heading: Node<HeadingOptions>;
25
+ export declare const Heading: Node<HeadingOptions, unknown>;
26
26
  export {};
@@ -27,4 +27,4 @@ declare module '@tiptap/core' {
27
27
  }
28
28
  export declare const inputRegex: RegExp;
29
29
  export declare const pasteRegex: RegExp;
30
- export declare const Highlight: Mark<HighlightOptions>;
30
+ export declare const Highlight: Mark<HighlightOptions, unknown>;
@@ -17,4 +17,4 @@ declare module '@tiptap/core' {
17
17
  };
18
18
  }
19
19
  }
20
- export declare const History: Extension<HistoryOptions>;
20
+ export declare const History: Extension<HistoryOptions, any>;
@@ -12,4 +12,4 @@ declare module '@tiptap/core' {
12
12
  };
13
13
  }
14
14
  }
15
- export declare const HorizontalRule: Node<HorizontalRuleOptions>;
15
+ export declare const HorizontalRule: Node<HorizontalRuleOptions, unknown>;
@@ -18,4 +18,4 @@ declare module '@tiptap/core' {
18
18
  }
19
19
  }
20
20
  export declare const inputRegex: RegExp;
21
- export declare const Image: Node<ImageOptions>;
21
+ export declare const Image: Node<ImageOptions, unknown>;
@@ -24,4 +24,4 @@ export declare const starInputRegex: RegExp;
24
24
  export declare const starPasteRegex: RegExp;
25
25
  export declare const underscoreInputRegex: RegExp;
26
26
  export declare const underscorePasteRegex: RegExp;
27
- export declare const Italic: Mark<ItalicOptions>;
27
+ export declare const Italic: Mark<ItalicOptions, unknown>;
@@ -37,4 +37,4 @@ declare module '@tiptap/core' {
37
37
  };
38
38
  }
39
39
  }
40
- export declare const Link: Mark<LinkOptions>;
40
+ export declare const Link: Mark<LinkOptions, unknown>;
@@ -2,4 +2,4 @@ import { Node } from '@tiptap/core';
2
2
  export interface ListItemOptions {
3
3
  HTMLAttributes: Record<string, any>;
4
4
  }
5
- export declare const ListItem: Node<ListItemOptions>;
5
+ export declare const ListItem: Node<ListItemOptions, any>;
@@ -11,4 +11,4 @@ export declare type MentionOptions = {
11
11
  suggestion: Omit<SuggestionOptions, 'editor'>;
12
12
  };
13
13
  export declare const MentionPluginKey: PluginKey<any, any>;
14
- export declare const Mention: Node<MentionOptions>;
14
+ export declare const Mention: Node<MentionOptions, any>;
@@ -13,4 +13,4 @@ declare module '@tiptap/core' {
13
13
  }
14
14
  }
15
15
  export declare const inputRegex: RegExp;
16
- export declare const OrderedList: Node<OrderedListOptions>;
16
+ export declare const OrderedList: Node<OrderedListOptions, unknown>;
@@ -12,4 +12,4 @@ declare module '@tiptap/core' {
12
12
  };
13
13
  }
14
14
  }
15
- export declare const Paragraph: Node<ParagraphOptions>;
15
+ export declare const Paragraph: Node<ParagraphOptions, any>;
@@ -12,4 +12,4 @@ export interface PlaceholderOptions {
12
12
  showOnlyCurrent: boolean;
13
13
  includeChildren: boolean;
14
14
  }
15
- export declare const Placeholder: Extension<PlaceholderOptions>;
15
+ export declare const Placeholder: Extension<PlaceholderOptions, any>;
@@ -22,4 +22,4 @@ declare module '@tiptap/core' {
22
22
  }
23
23
  export declare const inputRegex: RegExp;
24
24
  export declare const pasteRegex: RegExp;
25
- export declare const Strike: Mark<StrikeOptions>;
25
+ export declare const Strike: Mark<StrikeOptions, unknown>;
@@ -20,4 +20,4 @@ declare module '@tiptap/core' {
20
20
  };
21
21
  }
22
22
  }
23
- export declare const Subscript: Mark<SubscriptExtensionOptions>;
23
+ export declare const Subscript: Mark<SubscriptExtensionOptions, any>;
@@ -20,4 +20,4 @@ declare module '@tiptap/core' {
20
20
  };
21
21
  }
22
22
  }
23
- export declare const Superscript: Mark<SuperscriptExtensionOptions>;
23
+ export declare const Superscript: Mark<SuperscriptExtensionOptions, any>;
@@ -40,15 +40,16 @@ declare module '@tiptap/core' {
40
40
  }) => ReturnType;
41
41
  };
42
42
  }
43
- interface NodeConfig<Options> {
43
+ interface NodeConfig<Options, Storage> {
44
44
  /**
45
45
  * Table Role
46
46
  */
47
47
  tableRole?: string | ((this: {
48
48
  name: string;
49
49
  options: Options;
50
+ storage: Storage;
50
51
  parent: ParentConfig<NodeConfig<Options>>['tableRole'];
51
52
  }) => string);
52
53
  }
53
54
  }
54
- export declare const Table: Node<TableOptions>;
55
+ export declare const Table: Node<TableOptions, unknown>;
@@ -2,4 +2,4 @@ import { Node } from '@tiptap/core';
2
2
  export interface TableCellOptions {
3
3
  HTMLAttributes: Record<string, any>;
4
4
  }
5
- export declare const TableCell: Node<TableCellOptions>;
5
+ export declare const TableCell: Node<TableCellOptions, any>;
@@ -2,4 +2,4 @@ import { Node } from '@tiptap/core';
2
2
  export interface TableHeaderOptions {
3
3
  HTMLAttributes: Record<string, any>;
4
4
  }
5
- export declare const TableHeader: Node<TableHeaderOptions>;
5
+ export declare const TableHeader: Node<TableHeaderOptions, any>;
@@ -2,4 +2,4 @@ import { Node } from '@tiptap/core';
2
2
  export interface TableRowOptions {
3
3
  HTMLAttributes: Record<string, any>;
4
4
  }
5
- export declare const TableRow: Node<TableRowOptions>;
5
+ export declare const TableRow: Node<TableRowOptions, any>;
@@ -4,4 +4,4 @@ export interface TaskItemOptions {
4
4
  HTMLAttributes: Record<string, any>;
5
5
  }
6
6
  export declare const inputRegex: RegExp;
7
- export declare const TaskItem: Node<TaskItemOptions>;
7
+ export declare const TaskItem: Node<TaskItemOptions, unknown>;
@@ -12,4 +12,4 @@ declare module '@tiptap/core' {
12
12
  };
13
13
  }
14
14
  }
15
- export declare const TaskList: Node<TaskListOptions>;
15
+ export declare const TaskList: Node<TaskListOptions, any>;
@@ -1,2 +1,2 @@
1
1
  import { Node } from '@tiptap/core';
2
- export declare const Text: Node<unknown>;
2
+ export declare const Text: Node<any, any>;
@@ -18,4 +18,4 @@ declare module '@tiptap/core' {
18
18
  };
19
19
  }
20
20
  }
21
- export declare const TextAlign: Extension<TextAlignOptions>;
21
+ export declare const TextAlign: Extension<TextAlignOptions, any>;
@@ -12,4 +12,4 @@ declare module '@tiptap/core' {
12
12
  };
13
13
  }
14
14
  }
15
- export declare const TextStyle: Mark<TextStyleOptions>;
15
+ export declare const TextStyle: Mark<TextStyleOptions, any>;
@@ -20,4 +20,4 @@ export declare const superscriptTwo: import("@tiptap/core").InputRule;
20
20
  export declare const superscriptThree: import("@tiptap/core").InputRule;
21
21
  export declare const oneQuarter: import("@tiptap/core").InputRule;
22
22
  export declare const threeQuarters: import("@tiptap/core").InputRule;
23
- export declare const Typography: Extension<unknown>;
23
+ export declare const Typography: Extension<any, any>;
@@ -20,4 +20,4 @@ declare module '@tiptap/core' {
20
20
  };
21
21
  }
22
22
  }
23
- export declare const Underline: Mark<UnderlineOptions>;
23
+ export declare const Underline: Mark<UnderlineOptions, any>;
@@ -34,4 +34,4 @@ export interface StarterKitOptions {
34
34
  strike: Partial<StrikeOptions> | false;
35
35
  text: false;
36
36
  }
37
- export declare const StarterKit: Extension<StarterKitOptions>;
37
+ export declare const StarterKit: Extension<StarterKitOptions, any>;
@@ -15,7 +15,10 @@ export interface SuggestionOptions {
15
15
  range: Range;
16
16
  props: any;
17
17
  }) => void;
18
- items?: (query: string) => any[] | Promise<any[]>;
18
+ items?: (props: {
19
+ query: string;
20
+ editor: Editor;
21
+ }) => any[] | Promise<any[]>;
19
22
  render?: () => {
20
23
  onStart?: (props: SuggestionProps) => void;
21
24
  onUpdate?: (props: SuggestionProps) => void;
@@ -78,7 +78,13 @@ const useEditor = (options = {}, deps = []) => {
78
78
  React.useEffect(() => {
79
79
  const instance = new Editor(options);
80
80
  setEditor(instance);
81
- instance.on('transaction', forceUpdate);
81
+ instance.on('transaction', () => {
82
+ requestAnimationFrame(() => {
83
+ requestAnimationFrame(() => {
84
+ forceUpdate();
85
+ });
86
+ });
87
+ });
82
88
  return () => {
83
89
  instance.destroy();
84
90
  };
@@ -214,6 +220,9 @@ class ReactNodeView extends core.NodeView {
214
220
  const updateProps = (props) => {
215
221
  this.renderer.updateProps(props);
216
222
  };
223
+ if (node.type !== this.node.type) {
224
+ return false;
225
+ }
217
226
  if (typeof this.options.update === 'function') {
218
227
  const oldNode = this.node;
219
228
  const oldDecorations = this.decorations;
@@ -227,9 +236,6 @@ class ReactNodeView extends core.NodeView {
227
236
  updateProps: () => updateProps({ node, decorations }),
228
237
  });
229
238
  }
230
- if (node.type !== this.node.type) {
231
- return false;
232
- }
233
239
  if (node === this.node && this.decorations === decorations) {
234
240
  return true;
235
241
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-react.cjs.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":";;;;;;;;;;;;;;;MASa,UAAU,GAA8B,KAAK;IACxD,MAAM,OAAO,GAAGA,YAAM,CAAiB,IAAI,CAAC,CAAA;IAE5CC,eAAS,CAAC;QACR,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAM;SACP;QAED,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,GAClB,GAAG,KAAK,CAAA;QAET,MAAM,CAAC,cAAc,CAACC,oCAAgB,CAAC;YACrC,SAAS;YACT,MAAM;YACN,OAAO,EAAE,OAAO,C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CAAC,SAAS,GAAI,CAC3C,EACJ;KACF;CACF;MAEY,aAAa,GAAGA,yBAAK,CAAC,IAAI,CAAC,iBAAiB;;MCrG5C,eAAe,GAAmCA,yBAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG;IACzF,MAAM,EAAE,WAAW,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;IAE7B,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,GAAG,4BACe,EAAE,EACzB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE;YACL,GAAG,KAAK,CAAC,KAAK;YACd,UAAU,EAAE,QAAQ;SACrB,GACD,EACH;AACH,CAAC;;MChBY,eAAe,GAAmC,KAAK;IAClE,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;IAC7B,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAEjD,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,kBAAkB,4BACA,EAAE,EACzB,KAAK,EAAE;YACL,GAAG,KAAK,CAAC,KAAK;YACd,UAAU,EAAE,UAAU;SACvB,GACD,EACH;AACH;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"tiptap-react.cjs.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":";;;;;;;;;;;;;;;MASa,UAAU,GAA8B,KAAK;IACxD,MAAM,OAAO,GAAGA,YAAM,CAAiB,IAAI,CAAC,CAAA;IAE5CC,eAAS,CAAC;QACR,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAM;SACP;QAED,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,GAClB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,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAEtC,QACEA;YACEA,iDAAK,GAAG,EAAE,IAAI,CAAC,gBAAgB,KAAM,IAAI,GAAI;YAC7CA,wCAAC,OAAO,IAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAI,CAC3C,EACJ;KACF;CACF;MAEY,aAAa,GAAGA,yBAAK,CAAC,IAAI,CAAC,iBAAiB;;MCrG5C,eAAe,GAAmCA,yBAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG;IACzF,MAAM,EAAE,WAAW,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;IAE7B,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,GAAG,4BACe,EAAE,EACzB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE;YACL,GAAG,KAAK,CAAC,KAAK;YACd,UAAU,EAAE,QAAQ;SACrB,GACD,EACH;AACH,CAAC;;MChBY,eAAe,GAAmC,KAAK;IAClE,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;IAC7B,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAEjD,QACEA,wCAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,kBAAkB,4BACA,EAAE,EACzB,KAAK,EAAE;YACL,GAAG,KAAK,CAAC,KAAK;YACd,UAAU,EAAE,UAAU;SACvB,GACD,EACH;AACH;;;;;;;;;;;;;;;;;;;"}
@@ -70,7 +70,13 @@ const useEditor = (options = {}, deps = []) => {
70
70
  useEffect(() => {
71
71
  const instance = new Editor(options);
72
72
  setEditor(instance);
73
- instance.on('transaction', forceUpdate);
73
+ instance.on('transaction', () => {
74
+ requestAnimationFrame(() => {
75
+ requestAnimationFrame(() => {
76
+ forceUpdate();
77
+ });
78
+ });
79
+ });
74
80
  return () => {
75
81
  instance.destroy();
76
82
  };
@@ -206,6 +212,9 @@ class ReactNodeView extends NodeView {
206
212
  const updateProps = (props) => {
207
213
  this.renderer.updateProps(props);
208
214
  };
215
+ if (node.type !== this.node.type) {
216
+ return false;
217
+ }
209
218
  if (typeof this.options.update === 'function') {
210
219
  const oldNode = this.node;
211
220
  const oldDecorations = this.decorations;
@@ -219,9 +228,6 @@ class ReactNodeView extends NodeView {
219
228
  updateProps: () => updateProps({ node, decorations }),
220
229
  });
221
230
  }
222
- if (node.type !== this.node.type) {
223
- return false;
224
- }
225
231
  if (node === this.node && this.decorations === decorations) {
226
232
  return true;
227
233
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-react.esm.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":["CoreEditor"],"mappings":";;;;;;;MASa,UAAU,GAA8B,KAAK;IACxD,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAE5C,SAAS,CAAC;QACR,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAM;SACP;QAED,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,GAClB,GAAG,KAAK,CAAA;QAET,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;YACrC,SAAS;YACT,MAAM;YACN,OAAO,EAAE,OAAO,CAAC,OAAsB;YACvC,YAAY;YACZ,UAAU;SACX,CAAC,CAAC,CAAA;QAEH,OAAO;YACL,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;SACnC,CAAA;KACF,EAAE;QACD,KAAK,CAAC,MAAM;QACZ,OAAO,CAAC,OAAO;KAChB,CAAC,CAAA;IAEF,QACE,6BAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,IAC3E,KAAK,CAAC,QAAQ,CACX,EACP;AACH;;MCzCa,MAAO,SAAQA,QAAU;IAAtC;;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AE,QAAQ;SACrB,GACD,EACH;AACH,CAAC;;MChBY,eAAe,GAAmC,KAAK;IAClE,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;IAC7B,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAEjD,QACE,oBAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,kBAAkB,4BACA,EAAE,EACzB,KAAK,EAAE;YACL,GAAG,KAAK,CAAC,KAAK;YACd,UAAU,EAAE,UAAU;SACvB,GACD,EACH;AACH;;;;"}
1
+ {"version":3,"file":"tiptap-react.esm.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":["CoreEditor"],"mappings":";;;;;;;MASa,UAAU,GAA8B,KAAK;IACxD,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAE5C,SAAS,CAAC;QACR,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAM;SACP;QAED,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,UAAU,GAAG,IAAI,GAClB,GAAG,KAAK,CAAA;QAET,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;YACrC,SAAS;YACT,MAAM;YACN,OAAO,EAAE,OAAO,CAAC,OAAsB;YACvC,YAAY;YACZ,UAAU;SACX,CAAC,CAAC,CAAA;QAEH,OAAO;YACL,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;SACnC,CAAA;KACF,EAAE;QACD,KAAK,CAAC,MAAM;QACZ,OAAO,CAAC,OAAO;KAChB,CAAC,CAAA;IAEF,QACE,6BAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,IAC3E,KAAK,CAAC,QAAQ,CACX,EACP;AACH;;MCzCa,MAAO,SAAQA,QAAU;IAAtC;;QACS,qBAAgB,GAAmE,IAAI,C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EAAE,WAAW,EACxB,KAAK,EAAE;YACL,GAAG,KAAK,CAAC,KAAK;YACd,UAAU,EAAE,QAAQ;SACrB,GACD,EACH;AACH,CAAC;;MChBY,eAAe,GAAmC,KAAK;IAClE,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAA;IAC7B,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAEjD,QACE,oBAAC,GAAG,OACE,KAAK,EACT,GAAG,EAAE,kBAAkB,4BACA,EAAE,EACzB,KAAK,EAAE;YACL,GAAG,KAAK,CAAC,KAAK;YACd,UAAU,EAAE,UAAU;SACvB,GACD,EACH;AACH;;;;"}
@@ -74,7 +74,13 @@
74
74
  React.useEffect(() => {
75
75
  const instance = new Editor(options);
76
76
  setEditor(instance);
77
- instance.on('transaction', forceUpdate);
77
+ instance.on('transaction', () => {
78
+ requestAnimationFrame(() => {
79
+ requestAnimationFrame(() => {
80
+ forceUpdate();
81
+ });
82
+ });
83
+ });
78
84
  return () => {
79
85
  instance.destroy();
80
86
  };
@@ -210,6 +216,9 @@
210
216
  const updateProps = (props) => {
211
217
  this.renderer.updateProps(props);
212
218
  };
219
+ if (node.type !== this.node.type) {
220
+ return false;
221
+ }
213
222
  if (typeof this.options.update === 'function') {
214
223
  const oldNode = this.node;
215
224
  const oldDecorations = this.decorations;
@@ -223,9 +232,6 @@
223
232
  updateProps: () => updateProps({ node, decorations }),
224
233
  });
225
234
  }
226
- if (node.type !== this.node.type) {
227
- return false;
228
- }
229
235
  if (node === this.node && this.decorations === decorations) {
230
236
  return true;
231
237
  }