I’m experiencing a wired behavior from setNodeAttribute
. It resets the stored marks. Here is a simplified version of my plugin:
function TextDirectionPlugin() {
return new Plugin({
key: new PluginKey("textDirection"),
appendTransaction: (transactions, oldState, newState) => {
let modified = false;
const tr = newState.tr;
newState.doc.descendants((node, pos) => {
if (node.type.name === "paragraph") {
// Resets marks:
tr.setNodeAttribute(pos, "dir", getTextDirection(node.textContent));
// tr.storedMakrs === null
modified = true;
}
});
return modified ? tr : null;
},
});
}
After tr.setNodeAttribute()
runs, tr.storedMarks
becomes null
.
I’m using this plugin in TipTap, and I’m skeptical this is a TipTap bug. But, I wanted to make sure this is NOT the expected behavior.