I want to add an attribute which will be rendered as an HTML attribute to content that was pasted.
I have been trying to implement this using something like the following function:
transformPasted: (slice) => {
let fragment = slice.content
fragment.forEach((node, _, index) => {
fragment = fragment.replaceChild(
index,
schema.node(
node.type,
{
...node.attrs,
pasted: true,
},
node.content,
node.marks,
),
)
})
return new Slice(fragment, slice.openStart, slice.openEnd)
},
This does seem to be setting the attribute correctly however it still always displays pasted="false"
in the HTML. I haven’t managed to successfully change the HTML attribute to pasted="true"
.
Any guidance would be appreciated.