I have a plugin that adds a node decoration when the node is selected.
I am now trying to modify the markup of the node based on whether this decoration is present, so I’m using a node view for this.
I’m aware that the update
method of a NodeView receives an array of decorations.
I’d like to check whether it contains the specific decoration I’m looking for. Is it possible to access the decoration attributes?
The Decoration
type only has from
, to,
and spec
properties - is this correct?
This is what I have so far:
update(node: Node, decorations: readonly Decoration[]) {
// const hasSelectedDecoration = ???
if (hasSelectedDecoration) {
this.dom.appendChild(this.selectedIcon);
} else {
this.selectedIcon.remove();
}
return true;
}