How do I set the `contenteditable` property of the ProseMirror widget to true?

const cursor = document.createElement("span");
cursor.classList.add('caret')
cursor.textContent = "";
cursor.contentEditable = "true"

return DecorationSet.create(state.doc, [
    Decoration.widget(from, () => cursor, {
        side: -1, ignoreSelection: true,
    })
]);

I tried setting `cursor.contentEditable = “true”` to true, but it didn’t work.

What is the reason you want to set this element to be editable? ProseMirror cannot really handle the cursor being inside a widget.

Thank you for your reply. By examining the source code, I discovered the widget.type.spec.raw property. Setting it to true allowed me to remove the contenteditable attribute.

After removing contenteditable, it fixes: #1520. I’m not sure if other issues exist.


PixPin_2025-11-26_15-31-41


const cursor = document.createElement("span");
cursor.classList.add('caret')
return DecorationSet.create(state.doc, [
    Decoration.widget(from, () => cursor, {side: -1, ignoreSelection: true, raw: true})
]);