Hello there, I am currently working on a university project, and ran into the following issue:
I defined a MarkSpec, and I want to set the background color of this mark dynamically. This is my code:
const myMark: MarkSpec = {
attrs: {
originalObject: {default: null}
},
contentEditable : false,
toDOM(mark: Mark): DOMOutputSpec {
return [
'span',
{
class: `testclass ${mark.attrs.originalObject.value.serialize().type as string}`,
contenteditable: 'false',
style: `color: ${mark.attrs.originalObject.value.Color as string}`
},
0,
];
},
};
This initially works like expected and creates for example this HTML:
<span class="testclass myclass" contenteditable="false" style="color: #FFFFFF">shuf1</span>
However, as soon as I try to edit something in the editor, it creates a second span around this:
<span style="color:#FFFFFF;"><span class="testclass myclass" contenteditable="false" style="color: #FFFFFF">shuf1</span></span>
Because I want to reload the color dynamically, I end up with something like this:
<span style="color:#FFFFFF;"><span class="testclass myclass" contenteditable="false" style="color: #123123">shuf1</span></span>
This breaks my formatting. Why is the second span created? Unfortunately, I am kind of new to this editor, but can’t seem to find answers to this problem.
Thank you in advance!