Hi, I have the following Tiptap extension (node):
export const MathConcept = Node.create({
name: "mathConcept",
inline: true,
group: "inline",
selectable: true,
draggable: true,
addAttributes: () => {
return {
name: {
default: null,
parseHTML: (element) => element.dataset.name,
renderHTML: (attrs) => ({ "data-name": attrs.name }),
},
id: {
default: null,
parseHTML: (element) => element.dataset.id,
renderHTML: (attrs) => ({ "data-id": attrs.id }),
},
description: {
default: null,
rendered: false,
},
"original-name": {
default: null,
rendered: false,
},
"concept-type": {
default: null,
parseHTML: (element) => element.getAttribute("data-concept-type"),
renderHTML: (attrs) => ({ "data-concept-type": attrs["concept-type"] }),
},
};
},
renderHTML({ HTMLAttributes, node }) {
const attrs = mergeAttributes(HTMLAttributes, this.options.HTMLAttributes, {
"data-type": this.name,
});
return ["span", attrs, node.attrs.name];
},
parseHTML() {
return [
{ tag: `span[data-type="${this.name}"]` },
/* Parse RichMention */
{ tag: `div[data-type="${this.name}"]` },
];
},
addNodeView() {
return ReactNodeViewRenderer(MathConceptNodeView, {
attrs: {
"data-copyable": "true",
},
stopEvent() {
return false;
},
});
},
addProseMirrorPlugins() {
return [
suggestion({ editor: this.editor, ...MathConceptSuggestion }),
];
},
});
And the problem is that when I copy it and paste in my tiptap editor then it works and its correctly parsed into that node, but when I copy it to chat gpt, the empty string is pasted instead of node.attrs.name. I checked the clipboard text and html and the result for html is:
<p data-copyable="true" style="margin-left: 0px!important;" data-pm-slice="0 0 []"><span data-name="Postać kanoniczna funkcji kwadratowej" data-id="ffd192bc-b987-4b88-885f-233471f1efd6" data-concept-type="DEFINITION" data-type="mathConcept">Postać kanoniczna funkcji kwadratowej</span> </p>
while as I said, text/plain is an empty string. How can I fix that? Can I somehow override the way this node is serialized when copying it? Without overriding the html part?