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

**URL:** <https://discuss.prosemirror.net/t/how-do-i-set-the-contenteditable-property-of-the-prosemirror-widget-to-true/8875>\
**Category:** Uncategorized\
**Created:** [November 26, 2025, 7:05am UTC](https://discuss.prosemirror.net/t/how-do-i-set-the-contenteditable-property-of-the-prosemirror-widget-to-true/8875 "2025-11-26T07:05:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fervor](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/f/a3d4f5/32.png) [@fervor](https://discuss.prosemirror.net/u/fervor)\
**Post date:** [November 26, 2025, 7:05am UTC](https://discuss.prosemirror.net/t/how-do-i-set-the-contenteditable-property-of-the-prosemirror-widget-to-true/8875/1 "2025-11-26T07:05:26Z")

</div>

```javascript
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.

 ![image](https://discuss.prosemirror.net/uploads/secondsite/original/2X/0/0dc72801bc49bab490ee59a5a1a330276bef3692.png)

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [November 26, 2025, 7:17am UTC](https://discuss.prosemirror.net/t/how-do-i-set-the-contenteditable-property-of-the-prosemirror-widget-to-true/8875/2 "2025-11-26T07:17:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fervor](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/f/a3d4f5/32.png) [@fervor](https://discuss.prosemirror.net/u/fervor)\
**Post date:** [November 26, 2025, 7:33am UTC](https://discuss.prosemirror.net/t/how-do-i-set-the-contenteditable-property-of-the-prosemirror-widget-to-true/8875/3 "2025-11-26T07:33:27Z")

</div>

Thank you for your reply. By examining the source code, I discovered the [widget.type.spec.raw](https://github.com/ProseMirror/prosemirror-view/blob/81b640a1d8974eb8a9771061bd7e708e795660f7/src/viewdesc.ts#L545) property. Setting it to `true` allowed me to remove the `contenteditable` attribute.

After removing `contenteditable`, it fixes: [#1520](https://github.com/ProseMirror/prosemirror/issues/1520#issuecomment-2795605280). I’m not sure if other issues exist.

* * *

![PixPin_2025-11-26_15-31-41](https://discuss.prosemirror.net/uploads/secondsite/original/2X/b/b0d6ba3f6be806acaccd0a99cfd412367b00188c.gif)

* * *

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

```
