diff --git a/demos/src/Examples/CustomParagraph/React/Paragraph.jsx b/demos/src/Examples/CustomParagraph/React/Paragraph.jsx index cec21f2fd6d..422cab82370 100644 --- a/demos/src/Examples/CustomParagraph/React/Paragraph.jsx +++ b/demos/src/Examples/CustomParagraph/React/Paragraph.jsx @@ -6,6 +6,7 @@ import { } from '@tiptap/react' const ParagraphComponent = ({ node }) => { + console.count('render') return ( = React.FunctionComponent

| React.ForwardRefExoticComponent & React.RefAttributes>; +let first = true + /** * The ReactRenderer class. It's responsible for rendering React components inside the editor. * @example @@ -121,7 +124,20 @@ export class ReactRenderer { }) } - this.render() + if (first) { + // TODO this is totally a hack, on the first render of the editor (parent editor) + // We need to delay the rendering of the ReactRenderer components (because it would render before the editor is ready) + // setTimeout(() => { + this.render() + first = false + // }, 100) + } else { + // On first render, we need to flush the render synchronously + // Renders afterwards can be async, but this fixes a cursor positioning issue + flushSync(() => { + this.render() + }) + } } render(): void {