ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
27.73k stars 2.3k forks source link

[React][TS] Node conditional creation from FloatingMenu not working. #2167

Closed Iipal closed 3 years ago

Iipal commented 3 years ago

What’s the bug you are facing?

Can't create a CustomNode from FloatingMenu image

How can we reproduce the bug on our side?

call editor.commands.setNode("CustomNodeName") from FloatingMenu component with CustomNodeExtenstion created with useEditor

Can you provide a CodeSandbox?

https://codesandbox.io/s/thirsty-stonebraker-jmhoi?file=/src/App.tsx

What did you expect to happen?

Expect to see the custom component in Editor just as shown in documentation: https://tiptap.dev/guide/node-views/react

Anything to add? (optional)

Or any other solution for my problem ? To being abble create custom component even between text and draggable as well.

Did you update your dependencies?

Are you sponsoring us?

hanspagel commented 3 years ago

Your extension is an atom node (without text content) and it’s not clear how a paragraph (potentially with text) should be transformed to an atom node. Try insertContent instead!

https://tiptap.dev/api/commands/insert-content

Iipal commented 3 years ago

@hanspagel Thanks, removing atom: true and using insertContent like this:

editor.commands.insertContent(`<${AttachmentComponentExtensionName} />`);

fixes my issue.