Currently the format is like this:
renderHTML({ HTMLAttributes }) {
return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
},
Now could I do something like this:
renderHTML({ HTMLAttributes }) {
return <div>hello</div>;
},
Updated with addNodeView:
So I have now a CustomImage.js:
const CustomImage = Image.extend({
addNodeView() {
return ReactNodeViewRenderer(NextImage);
},
});
export default CustomImage;
And NextImage is:
const NextImage = () => {
return (
<NodeViewWrapper>
<div>hello</div>
</NodeViewWrapper>
);
};
export default NextImage;
And I use it like this:
html = generateHTML(JSON.parse(text), [
CustomImage
....
The
renderHtml
function is called when you runeditor.getHTML()
To answer your question, from my best knowledge it need to match their format. To achieve what you want you could do something like this:
If you on the other hand want to render that in the editor you should use:
And you can show whatever component you want:
Edit: Assuming that you are using react, you should use useEditor if you want to use the tiptap editor.
https://tiptap.dev/installation/react