@tiptap/react 3.0.0-beta.3 → 3.0.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react_jsx_runtime_js from 'react/jsx-runtime.js';
2
- import { EditorOptions, Editor, MarkViewRendererOptions, MarkView, MarkViewProps, MarkViewRenderer, NodeViewRendererOptions, NodeViewProps, NodeView, NodeViewRenderer } from '@tiptap/core';
2
+ import { EditorOptions, Editor, MarkViewRendererOptions, MarkView, MarkViewProps, MarkViewRenderer, NodeViewProps, NodeViewRendererOptions, NodeView, NodeViewRendererProps, NodeViewRenderer } from '@tiptap/core';
3
3
  export * from '@tiptap/core';
4
4
  import * as React from 'react';
5
- import React__default, { DependencyList, ReactNode, HTMLAttributes, HTMLProps, ForwardedRef, ComponentProps, ComponentType as ComponentType$1 } from 'react';
5
+ import React__default, { DependencyList, ReactNode, HTMLAttributes, HTMLProps, ForwardedRef, ComponentProps, ComponentClass, FunctionComponent, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, ComponentType as ComponentType$1 } from 'react';
6
6
  import { Node } from '@tiptap/pm/model';
7
7
  import { Decoration, DecorationSource } from '@tiptap/pm/view';
8
8
 
@@ -121,7 +121,7 @@ interface ReactRendererOptions {
121
121
  */
122
122
  className?: string;
123
123
  }
124
- type ComponentType<R, P> = React__default.ComponentClass<P> | React__default.FunctionComponent<P> | React__default.ForwardRefExoticComponent<React__default.PropsWithoutRef<P> & React__default.RefAttributes<R>>;
124
+ type ComponentType<R, P> = ComponentClass<P> | FunctionComponent<P> | ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<R>>;
125
125
  /**
126
126
  * The ReactRenderer class. It's responsible for rendering React components inside the editor.
127
127
  * @example
@@ -139,7 +139,7 @@ declare class ReactRenderer<R = unknown, P extends Record<string, any> = object>
139
139
  component: any;
140
140
  element: Element;
141
141
  props: P;
142
- reactElement: React__default.ReactNode;
142
+ reactElement: ReactNode;
143
143
  ref: R | null;
144
144
  /**
145
145
  * Immediately creates element and renders the provided React component.
@@ -168,9 +168,9 @@ interface MarkViewContextProps {
168
168
  }
169
169
  declare const ReactMarkViewContext: React__default.Context<MarkViewContextProps>;
170
170
  type MarkViewContentProps<T extends keyof React__default.JSX.IntrinsicElements = 'span'> = {
171
- as?: NoInfer<T>;
172
- } & React__default.ComponentProps<T>;
173
- declare const MarkViewContent: React__default.FC<MarkViewContentProps>;
171
+ as?: T;
172
+ } & Omit<React__default.ComponentProps<T>, 'as'>;
173
+ declare const MarkViewContent: <T extends keyof React__default.JSX.IntrinsicElements = "span">(props: MarkViewContentProps<T>) => react_jsx_runtime_js.JSX.Element;
174
174
  interface ReactMarkViewRendererOptions extends MarkViewRendererOptions {
175
175
  /**
176
176
  * The tag name of the element wrapping the React component.
@@ -191,6 +191,10 @@ declare class ReactMarkView extends MarkView<React__default.ComponentType<MarkVi
191
191
  }
192
192
  declare function ReactMarkViewRenderer(component: React__default.ComponentType<MarkViewProps>, options?: Partial<ReactMarkViewRendererOptions>): MarkViewRenderer;
193
193
 
194
+ type ReactNodeViewProps<T = HTMLElement> = NodeViewProps & {
195
+ ref: React__default.RefObject<T | null>;
196
+ };
197
+
194
198
  interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {
195
199
  /**
196
200
  * This function is called when the node view is updated.
@@ -223,15 +227,16 @@ interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {
223
227
  HTMLAttributes: Record<string, any>;
224
228
  }) => Record<string, string>);
225
229
  }
226
- declare class ReactNodeView<Component extends ComponentType$1<NodeViewProps> = ComponentType$1<NodeViewProps>, NodeEditor extends Editor = Editor, Options extends ReactNodeViewRendererOptions = ReactNodeViewRendererOptions> extends NodeView<Component, NodeEditor, Options> {
230
+ declare class ReactNodeView<T = HTMLElement, Component extends ComponentType$1<ReactNodeViewProps<T>> = ComponentType$1<ReactNodeViewProps<T>>, NodeEditor extends Editor = Editor, Options extends ReactNodeViewRendererOptions = ReactNodeViewRendererOptions> extends NodeView<Component, NodeEditor, Options> {
227
231
  /**
228
232
  * The renderer instance.
229
233
  */
230
- renderer: ReactRenderer<unknown, NodeViewProps>;
234
+ renderer: ReactRenderer<unknown, ReactNodeViewProps<T>>;
231
235
  /**
232
236
  * The element that holds the rich-text content of the node.
233
237
  */
234
238
  contentDOMElement: HTMLElement | null;
239
+ constructor(component: Component, props: NodeViewRendererProps, options?: Partial<Options>);
235
240
  /**
236
241
  * Setup the React component.
237
242
  * Called on initialization.
@@ -280,7 +285,7 @@ declare class ReactNodeView<Component extends ComponentType$1<NodeViewProps> = C
280
285
  /**
281
286
  * Create a React node view renderer.
282
287
  */
283
- declare function ReactNodeViewRenderer(component: ComponentType$1<NodeViewProps>, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer;
288
+ declare function ReactNodeViewRenderer<T = HTMLElement>(component: ComponentType$1<ReactNodeViewProps<T>>, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer;
284
289
 
285
290
  type EditorStateSnapshot<TEditor extends Editor | null = Editor | null> = {
286
291
  editor: TEditor;
@@ -342,4 +347,4 @@ declare const ReactNodeViewContentProvider: ({ children, content }: {
342
347
  }) => React.FunctionComponentElement<React.ProviderProps<ReactNodeViewContextProps>>;
343
348
  declare const useReactNodeView: () => ReactNodeViewContextProps;
344
349
 
345
- export { EditorConsumer, EditorContent, type EditorContentProps, EditorContext, type EditorContextValue, EditorProvider, type EditorProviderProps, type EditorStateSnapshot, MarkViewContent, type MarkViewContentProps, type MarkViewContextProps, NodeViewContent, type NodeViewContentProps, NodeViewWrapper, type NodeViewWrapperProps, PureEditorContent, ReactMarkView, ReactMarkViewContext, ReactMarkViewRenderer, type ReactMarkViewRendererOptions, ReactNodeView, ReactNodeViewContentProvider, ReactNodeViewContext, type ReactNodeViewContextProps, ReactNodeViewRenderer, type ReactNodeViewRendererOptions, ReactRenderer, type ReactRendererOptions, type UseEditorOptions, type UseEditorStateOptions, useCurrentEditor, useEditor, useEditorState, useReactNodeView };
350
+ export { EditorConsumer, EditorContent, type EditorContentProps, EditorContext, type EditorContextValue, EditorProvider, type EditorProviderProps, type EditorStateSnapshot, MarkViewContent, type MarkViewContentProps, type MarkViewContextProps, NodeViewContent, type NodeViewContentProps, NodeViewWrapper, type NodeViewWrapperProps, PureEditorContent, ReactMarkView, ReactMarkViewContext, ReactMarkViewRenderer, type ReactMarkViewRendererOptions, ReactNodeView, ReactNodeViewContentProvider, ReactNodeViewContext, type ReactNodeViewContextProps, type ReactNodeViewProps, ReactNodeViewRenderer, type ReactNodeViewRendererOptions, ReactRenderer, type ReactRendererOptions, type UseEditorOptions, type UseEditorStateOptions, useCurrentEditor, useEditor, useEditorState, useReactNodeView };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react_jsx_runtime_js from 'react/jsx-runtime.js';
2
- import { EditorOptions, Editor, MarkViewRendererOptions, MarkView, MarkViewProps, MarkViewRenderer, NodeViewRendererOptions, NodeViewProps, NodeView, NodeViewRenderer } from '@tiptap/core';
2
+ import { EditorOptions, Editor, MarkViewRendererOptions, MarkView, MarkViewProps, MarkViewRenderer, NodeViewProps, NodeViewRendererOptions, NodeView, NodeViewRendererProps, NodeViewRenderer } from '@tiptap/core';
3
3
  export * from '@tiptap/core';
4
4
  import * as React from 'react';
5
- import React__default, { DependencyList, ReactNode, HTMLAttributes, HTMLProps, ForwardedRef, ComponentProps, ComponentType as ComponentType$1 } from 'react';
5
+ import React__default, { DependencyList, ReactNode, HTMLAttributes, HTMLProps, ForwardedRef, ComponentProps, ComponentClass, FunctionComponent, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, ComponentType as ComponentType$1 } from 'react';
6
6
  import { Node } from '@tiptap/pm/model';
7
7
  import { Decoration, DecorationSource } from '@tiptap/pm/view';
8
8
 
@@ -121,7 +121,7 @@ interface ReactRendererOptions {
121
121
  */
122
122
  className?: string;
123
123
  }
124
- type ComponentType<R, P> = React__default.ComponentClass<P> | React__default.FunctionComponent<P> | React__default.ForwardRefExoticComponent<React__default.PropsWithoutRef<P> & React__default.RefAttributes<R>>;
124
+ type ComponentType<R, P> = ComponentClass<P> | FunctionComponent<P> | ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<R>>;
125
125
  /**
126
126
  * The ReactRenderer class. It's responsible for rendering React components inside the editor.
127
127
  * @example
@@ -139,7 +139,7 @@ declare class ReactRenderer<R = unknown, P extends Record<string, any> = object>
139
139
  component: any;
140
140
  element: Element;
141
141
  props: P;
142
- reactElement: React__default.ReactNode;
142
+ reactElement: ReactNode;
143
143
  ref: R | null;
144
144
  /**
145
145
  * Immediately creates element and renders the provided React component.
@@ -168,9 +168,9 @@ interface MarkViewContextProps {
168
168
  }
169
169
  declare const ReactMarkViewContext: React__default.Context<MarkViewContextProps>;
170
170
  type MarkViewContentProps<T extends keyof React__default.JSX.IntrinsicElements = 'span'> = {
171
- as?: NoInfer<T>;
172
- } & React__default.ComponentProps<T>;
173
- declare const MarkViewContent: React__default.FC<MarkViewContentProps>;
171
+ as?: T;
172
+ } & Omit<React__default.ComponentProps<T>, 'as'>;
173
+ declare const MarkViewContent: <T extends keyof React__default.JSX.IntrinsicElements = "span">(props: MarkViewContentProps<T>) => react_jsx_runtime_js.JSX.Element;
174
174
  interface ReactMarkViewRendererOptions extends MarkViewRendererOptions {
175
175
  /**
176
176
  * The tag name of the element wrapping the React component.
@@ -191,6 +191,10 @@ declare class ReactMarkView extends MarkView<React__default.ComponentType<MarkVi
191
191
  }
192
192
  declare function ReactMarkViewRenderer(component: React__default.ComponentType<MarkViewProps>, options?: Partial<ReactMarkViewRendererOptions>): MarkViewRenderer;
193
193
 
194
+ type ReactNodeViewProps<T = HTMLElement> = NodeViewProps & {
195
+ ref: React__default.RefObject<T | null>;
196
+ };
197
+
194
198
  interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {
195
199
  /**
196
200
  * This function is called when the node view is updated.
@@ -223,15 +227,16 @@ interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {
223
227
  HTMLAttributes: Record<string, any>;
224
228
  }) => Record<string, string>);
225
229
  }
226
- declare class ReactNodeView<Component extends ComponentType$1<NodeViewProps> = ComponentType$1<NodeViewProps>, NodeEditor extends Editor = Editor, Options extends ReactNodeViewRendererOptions = ReactNodeViewRendererOptions> extends NodeView<Component, NodeEditor, Options> {
230
+ declare class ReactNodeView<T = HTMLElement, Component extends ComponentType$1<ReactNodeViewProps<T>> = ComponentType$1<ReactNodeViewProps<T>>, NodeEditor extends Editor = Editor, Options extends ReactNodeViewRendererOptions = ReactNodeViewRendererOptions> extends NodeView<Component, NodeEditor, Options> {
227
231
  /**
228
232
  * The renderer instance.
229
233
  */
230
- renderer: ReactRenderer<unknown, NodeViewProps>;
234
+ renderer: ReactRenderer<unknown, ReactNodeViewProps<T>>;
231
235
  /**
232
236
  * The element that holds the rich-text content of the node.
233
237
  */
234
238
  contentDOMElement: HTMLElement | null;
239
+ constructor(component: Component, props: NodeViewRendererProps, options?: Partial<Options>);
235
240
  /**
236
241
  * Setup the React component.
237
242
  * Called on initialization.
@@ -280,7 +285,7 @@ declare class ReactNodeView<Component extends ComponentType$1<NodeViewProps> = C
280
285
  /**
281
286
  * Create a React node view renderer.
282
287
  */
283
- declare function ReactNodeViewRenderer(component: ComponentType$1<NodeViewProps>, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer;
288
+ declare function ReactNodeViewRenderer<T = HTMLElement>(component: ComponentType$1<ReactNodeViewProps<T>>, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer;
284
289
 
285
290
  type EditorStateSnapshot<TEditor extends Editor | null = Editor | null> = {
286
291
  editor: TEditor;
@@ -342,4 +347,4 @@ declare const ReactNodeViewContentProvider: ({ children, content }: {
342
347
  }) => React.FunctionComponentElement<React.ProviderProps<ReactNodeViewContextProps>>;
343
348
  declare const useReactNodeView: () => ReactNodeViewContextProps;
344
349
 
345
- export { EditorConsumer, EditorContent, type EditorContentProps, EditorContext, type EditorContextValue, EditorProvider, type EditorProviderProps, type EditorStateSnapshot, MarkViewContent, type MarkViewContentProps, type MarkViewContextProps, NodeViewContent, type NodeViewContentProps, NodeViewWrapper, type NodeViewWrapperProps, PureEditorContent, ReactMarkView, ReactMarkViewContext, ReactMarkViewRenderer, type ReactMarkViewRendererOptions, ReactNodeView, ReactNodeViewContentProvider, ReactNodeViewContext, type ReactNodeViewContextProps, ReactNodeViewRenderer, type ReactNodeViewRendererOptions, ReactRenderer, type ReactRendererOptions, type UseEditorOptions, type UseEditorStateOptions, useCurrentEditor, useEditor, useEditorState, useReactNodeView };
350
+ export { EditorConsumer, EditorContent, type EditorContentProps, EditorContext, type EditorContextValue, EditorProvider, type EditorProviderProps, type EditorStateSnapshot, MarkViewContent, type MarkViewContentProps, type MarkViewContextProps, NodeViewContent, type NodeViewContentProps, NodeViewWrapper, type NodeViewWrapperProps, PureEditorContent, ReactMarkView, ReactMarkViewContext, ReactMarkViewRenderer, type ReactMarkViewRendererOptions, ReactNodeView, ReactNodeViewContentProvider, ReactNodeViewContext, type ReactNodeViewContextProps, type ReactNodeViewProps, ReactNodeViewRenderer, type ReactNodeViewRendererOptions, ReactRenderer, type ReactRendererOptions, type UseEditorOptions, type UseEditorStateOptions, useCurrentEditor, useEditor, useEditorState, useReactNodeView };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { createContext, useContext, useMemo } from "react";
4
4
  // src/EditorContent.tsx
5
5
  import React, { forwardRef } from "react";
6
6
  import ReactDOM from "react-dom";
7
- import { useSyncExternalStore } from "use-sync-external-store/shim";
7
+ import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  var mergeRefs = (...refs) => {
10
10
  return (node) => {
@@ -120,13 +120,10 @@ var PureEditorContent = class extends React.Component {
120
120
  return;
121
121
  }
122
122
  this.initialized = false;
123
- try {
124
- if (!editor.isDestroyed) {
125
- editor.view.setProps({
126
- nodeViews: {}
127
- });
128
- }
129
- } catch {
123
+ if (!editor.isDestroyed) {
124
+ editor.view.setProps({
125
+ nodeViews: {}
126
+ });
130
127
  }
131
128
  if (this.unsubscribeToContentComponent) {
132
129
  this.unsubscribeToContentComponent();
@@ -166,12 +163,12 @@ var EditorContent = React.memo(EditorContentWithKey);
166
163
  // src/useEditor.ts
167
164
  import { Editor } from "@tiptap/core";
168
165
  import { useDebugValue as useDebugValue2, useEffect as useEffect2, useRef, useState as useState2 } from "react";
169
- import { useSyncExternalStore as useSyncExternalStore2 } from "use-sync-external-store/shim";
166
+ import { useSyncExternalStore as useSyncExternalStore2 } from "use-sync-external-store/shim/index.js";
170
167
 
171
168
  // src/useEditorState.ts
172
- import deepEqual from "fast-deep-equal/es6/react";
169
+ import deepEqual from "fast-deep-equal/es6/react.js";
173
170
  import { useDebugValue, useEffect, useLayoutEffect, useState } from "react";
174
- import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
171
+ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
175
172
  var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
176
173
  var EditorStateManager = class {
177
174
  constructor(initialEditor) {
@@ -618,14 +615,42 @@ import { MarkView } from "@tiptap/core";
618
615
  import React4 from "react";
619
616
 
620
617
  // src/ReactRenderer.tsx
618
+ import { version as reactVersion } from "react";
621
619
  import { flushSync } from "react-dom";
622
620
  import { jsx as jsx5 } from "react/jsx-runtime";
623
621
  function isClassComponent(Component) {
624
622
  return !!(typeof Component === "function" && Component.prototype && Component.prototype.isReactComponent);
625
623
  }
626
624
  function isForwardRefComponent(Component) {
627
- var _a;
628
- return !!(typeof Component === "object" && ((_a = Component.$$typeof) == null ? void 0 : _a.toString()) === "Symbol(react.forward_ref)");
625
+ return !!(typeof Component === "object" && Component.$$typeof && (Component.$$typeof.toString() === "Symbol(react.forward_ref)" || Component.$$typeof.description === "react.forward_ref"));
626
+ }
627
+ function isMemoComponent(Component) {
628
+ return !!(typeof Component === "object" && Component.$$typeof && (Component.$$typeof.toString() === "Symbol(react.memo)" || Component.$$typeof.description === "react.memo"));
629
+ }
630
+ function canReceiveRef(Component) {
631
+ if (isClassComponent(Component)) {
632
+ return true;
633
+ }
634
+ if (isForwardRefComponent(Component)) {
635
+ return true;
636
+ }
637
+ if (isMemoComponent(Component)) {
638
+ const wrappedComponent = Component.type;
639
+ if (wrappedComponent) {
640
+ return isClassComponent(wrappedComponent) || isForwardRefComponent(wrappedComponent);
641
+ }
642
+ }
643
+ return false;
644
+ }
645
+ function isReact19Plus() {
646
+ try {
647
+ if (reactVersion) {
648
+ const majorVersion = parseInt(reactVersion.split(".")[0], 10);
649
+ return majorVersion >= 19;
650
+ }
651
+ } catch {
652
+ }
653
+ return false;
629
654
  }
630
655
  var ReactRenderer = class {
631
656
  /**
@@ -647,7 +672,9 @@ var ReactRenderer = class {
647
672
  this.render();
648
673
  });
649
674
  } else {
650
- this.render();
675
+ queueMicrotask(() => {
676
+ this.render();
677
+ });
651
678
  }
652
679
  }
653
680
  /**
@@ -658,12 +685,18 @@ var ReactRenderer = class {
658
685
  const Component = this.component;
659
686
  const props = this.props;
660
687
  const editor = this.editor;
661
- if (isClassComponent(Component) || isForwardRefComponent(Component)) {
662
- props.ref = (ref) => {
688
+ const isReact19 = isReact19Plus();
689
+ const componentCanReceiveRef = canReceiveRef(Component);
690
+ const elementProps = { ...props };
691
+ if (elementProps.ref && !(isReact19 || componentCanReceiveRef)) {
692
+ delete elementProps.ref;
693
+ }
694
+ if (!elementProps.ref && (isReact19 || componentCanReceiveRef)) {
695
+ elementProps.ref = (ref) => {
663
696
  this.ref = ref;
664
697
  };
665
698
  }
666
- this.reactElement = /* @__PURE__ */ jsx5(Component, { ...props });
699
+ this.reactElement = /* @__PURE__ */ jsx5(Component, { ...elementProps });
667
700
  (_a = editor == null ? void 0 : editor.contentComponent) == null ? void 0 : _a.setRenderer(this.id, this);
668
701
  }
669
702
  /**
@@ -701,11 +734,11 @@ var ReactMarkViewContext = React4.createContext({
701
734
  }
702
735
  });
703
736
  var MarkViewContent = (props) => {
704
- const Tag = props.as || "span";
737
+ const { as: Tag = "span", ...rest } = props;
705
738
  const { markViewContentRef } = React4.useContext(ReactMarkViewContext);
706
739
  return (
707
740
  // @ts-ignore
708
- /* @__PURE__ */ jsx6(Tag, { ...props, ref: markViewContentRef, "data-mark-view-content": "" })
741
+ /* @__PURE__ */ jsx6(Tag, { ...rest, ref: markViewContentRef, "data-mark-view-content": "" })
709
742
  );
710
743
  };
711
744
  var ReactMarkView = class extends MarkView {
@@ -713,7 +746,7 @@ var ReactMarkView = class extends MarkView {
713
746
  super(component, props, options);
714
747
  this.didMountContentDomElement = false;
715
748
  const { as = "span", attrs, className = "" } = options || {};
716
- const componentProps = props;
749
+ const componentProps = { ...props, updateAttributes: this.updateAttributes.bind(this) };
717
750
  this.contentDOMElement = document.createElement("span");
718
751
  const markViewContentRef = (el) => {
719
752
  if (el && this.contentDOMElement && el.firstChild !== this.contentDOMElement) {
@@ -754,9 +787,27 @@ function ReactMarkViewRenderer(component, options = {}) {
754
787
 
755
788
  // src/ReactNodeViewRenderer.tsx
756
789
  import { getRenderedAttributes, NodeView } from "@tiptap/core";
757
- import React5 from "react";
790
+ import { createElement as createElement2, createRef, memo } from "react";
758
791
  import { jsx as jsx7 } from "react/jsx-runtime";
759
792
  var ReactNodeView = class extends NodeView {
793
+ constructor(component, props, options) {
794
+ super(component, props, options);
795
+ if (!this.node.isLeaf) {
796
+ if (this.options.contentDOMElementTag) {
797
+ this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
798
+ } else {
799
+ this.contentDOMElement = document.createElement(this.node.isInline ? "span" : "div");
800
+ }
801
+ this.contentDOMElement.dataset.nodeViewContentReact = "";
802
+ this.contentDOMElement.dataset.nodeViewWrapper = "";
803
+ this.contentDOMElement.style.whiteSpace = "inherit";
804
+ const contentTarget = this.dom.querySelector("[data-node-view-content]");
805
+ if (!contentTarget) {
806
+ return;
807
+ }
808
+ contentTarget.appendChild(this.contentDOMElement);
809
+ }
810
+ }
760
811
  /**
761
812
  * Setup the React component.
762
813
  * Called on initialization.
@@ -773,7 +824,8 @@ var ReactNodeView = class extends NodeView {
773
824
  HTMLAttributes: this.HTMLAttributes,
774
825
  getPos: () => this.getPos(),
775
826
  updateAttributes: (attributes = {}) => this.updateAttributes(attributes),
776
- deleteNode: () => this.deleteNode()
827
+ deleteNode: () => this.deleteNode(),
828
+ ref: createRef()
777
829
  };
778
830
  if (!this.component.displayName) {
779
831
  const capitalizeFirstChar = (string) => {
@@ -784,26 +836,18 @@ var ReactNodeView = class extends NodeView {
784
836
  const onDragStart = this.onDragStart.bind(this);
785
837
  const nodeViewContentRef = (element) => {
786
838
  if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
839
+ if (element.hasAttribute("data-node-view-wrapper")) {
840
+ element.removeAttribute("data-node-view-wrapper");
841
+ }
787
842
  element.appendChild(this.contentDOMElement);
788
843
  }
789
844
  };
790
845
  const context = { onDragStart, nodeViewContentRef };
791
846
  const Component = this.component;
792
- const ReactNodeViewProvider = React5.memo((componentProps) => {
793
- return /* @__PURE__ */ jsx7(ReactNodeViewContext.Provider, { value: context, children: React5.createElement(Component, componentProps) });
847
+ const ReactNodeViewProvider = memo((componentProps) => {
848
+ return /* @__PURE__ */ jsx7(ReactNodeViewContext.Provider, { value: context, children: createElement2(Component, componentProps) });
794
849
  });
795
850
  ReactNodeViewProvider.displayName = "ReactNodeView";
796
- if (this.node.isLeaf) {
797
- this.contentDOMElement = null;
798
- } else if (this.options.contentDOMElementTag) {
799
- this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);
800
- } else {
801
- this.contentDOMElement = document.createElement(this.node.isInline ? "span" : "div");
802
- }
803
- if (this.contentDOMElement) {
804
- this.contentDOMElement.dataset.nodeViewContentReact = "";
805
- this.contentDOMElement.style.whiteSpace = "inherit";
806
- }
807
851
  let as = this.node.isInline ? "span" : "div";
808
852
  if (this.options.as) {
809
853
  as = this.options.as;