ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
26.85k stars 2.24k forks source link

[Bug]: NodePos.setAttribute doesn't re-render NodeView #5671

Open rChaoz opened 3 days ago

rChaoz commented 3 days ago

Affected Packages

core

Version(s)

2.7.3

Bug Description

Using NodePos.setAttribute() to update the attributes of a node doesn't seem to re-render a NodeView (or the attributes aren't changed at all). Changing it for a custom transaction works.

This doesn't work:

editor.$node("image", { loadingId }).setAttribute(someAttributes)

This works:

editor.commands.command(({ tr, state }) => {
    let done = false
    state.doc.descendants((node, pos) => {
        if (node.type.name === "image" && node.attrs.loadingId === loadingId) {
            tr.setNodeMarkup(pos, undefined, someAttributes)
            done = true
        }
        return !done
    })
    return true
}),

Might be caused by #5672. I don't see any errors in the console tho, like index out of bounds (if I manually call tr.setNodeMarkup with NodePos.pos as the position it throws that error, as the image is the last node).

Browser Used

Firefox

Code Example URL

No response

Expected Behavior

-

Dependency Updates