@tiptap/react
Advanced tools
+4
-3
@@ -936,6 +936,7 @@ "use strict"; | ||
| const contentTarget = this.dom.querySelector("[data-node-view-content]"); | ||
| if (!contentTarget) { | ||
| return; | ||
| if (contentTarget) { | ||
| contentTarget.appendChild(this.contentDOMElement); | ||
| } else { | ||
| this.dom.appendChild(this.contentDOMElement); | ||
| } | ||
| contentTarget.appendChild(this.contentDOMElement); | ||
| } | ||
@@ -942,0 +943,0 @@ if (this.options.trackNodeViewPosition) { |
+4
-3
@@ -874,6 +874,7 @@ "use client"; | ||
| const contentTarget = this.dom.querySelector("[data-node-view-content]"); | ||
| if (!contentTarget) { | ||
| return; | ||
| if (contentTarget) { | ||
| contentTarget.appendChild(this.contentDOMElement); | ||
| } else { | ||
| this.dom.appendChild(this.contentDOMElement); | ||
| } | ||
| contentTarget.appendChild(this.contentDOMElement); | ||
| } | ||
@@ -880,0 +881,0 @@ if (this.options.trackNodeViewPosition) { |
+7
-7
| { | ||
| "name": "@tiptap/react", | ||
| "version": "3.29.0", | ||
| "version": "3.29.1", | ||
| "description": "React components for tiptap", | ||
@@ -60,4 +60,4 @@ "keywords": [ | ||
| "react-dom": "^19.0.0", | ||
| "@tiptap/core": "^3.29.0", | ||
| "@tiptap/pm": "^3.29.0" | ||
| "@tiptap/core": "^3.29.1", | ||
| "@tiptap/pm": "^3.29.1" | ||
| }, | ||
@@ -69,8 +69,8 @@ "peerDependencies": { | ||
| "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0", | ||
| "@tiptap/core": "3.29.0", | ||
| "@tiptap/pm": "3.29.0" | ||
| "@tiptap/core": "3.29.1", | ||
| "@tiptap/pm": "3.29.1" | ||
| }, | ||
| "optionalDependencies": { | ||
| "@tiptap/extension-bubble-menu": "^3.29.0", | ||
| "@tiptap/extension-floating-menu": "^3.29.0" | ||
| "@tiptap/extension-bubble-menu": "^3.29.1", | ||
| "@tiptap/extension-floating-menu": "^3.29.1" | ||
| }, | ||
@@ -77,0 +77,0 @@ "scripts": { |
@@ -89,2 +89,12 @@ import { act, render } from '@testing-library/react' | ||
| const ReactParagraphComponent = () => { | ||
| return React.createElement(NodeViewWrapper, null, React.createElement(NodeViewContent)) | ||
| } | ||
| const ReactParagraph = Paragraph.extend({ | ||
| addNodeView() { | ||
| return ReactNodeViewRenderer(ReactParagraphComponent) | ||
| }, | ||
| }) | ||
| const Container = Node.create({ | ||
@@ -141,2 +151,9 @@ name: 'container', | ||
| const createEditorWithReactParagraph = () => { | ||
| return new Editor({ | ||
| extensions: [Document, ReactParagraph, Text], | ||
| content: '<p>Hello</p>', | ||
| }) | ||
| } | ||
| const flushMicrotasks = async () => { | ||
@@ -177,2 +194,32 @@ await act(async () => { | ||
| it('keeps new React paragraph content connected while its portal is queued', async () => { | ||
| const editor = createEditorWithReactParagraph() | ||
| const { container } = render(React.createElement(EditorContent, { editor })) | ||
| await flushMicrotasks() | ||
| editor.commands.setTextSelection(6) | ||
| editor.commands.splitBlock() | ||
| const secondParagraphPosition = editor.state.doc.firstChild!.nodeSize | ||
| expect(editor.state.selection.from).toBe(secondParagraphPosition + 1) | ||
| const contentElements = container.querySelectorAll('[data-node-view-content-react]') | ||
| expect(contentElements).toHaveLength(2) | ||
| expect(contentElements[1].isConnected).toBe(true) | ||
| editor.commands.insertContent('Second') | ||
| expect(editor.state.doc.child(0).textContent).toBe('Hello') | ||
| expect(editor.state.doc.child(1).textContent).toBe('Second') | ||
| await flushMicrotasks() | ||
| expect(contentElements[1].parentElement?.hasAttribute('data-node-view-content')).toBe(true) | ||
| editor.destroy() | ||
| }) | ||
| it('resolves getPos to undefined while the view desc is detached mid-update', async () => { | ||
@@ -179,0 +226,0 @@ const editor = createEditorWithContainers() |
@@ -121,7 +121,8 @@ import type { | ||
| if (!contentTarget) { | ||
| return | ||
| if (contentTarget) { | ||
| contentTarget.appendChild(this.contentDOMElement) | ||
| } else { | ||
| // ProseMirror maps the selection before the queued portal render. | ||
| this.dom.appendChild(this.contentDOMElement) | ||
| } | ||
| contentTarget.appendChild(this.contentDOMElement) | ||
| } | ||
@@ -128,0 +129,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
495882
0.4%7114
0.51%