felix
1
Hi, I am trying to use DecorationSet to add some style to node,
like
cost decos = [Decoration.node(from, to, { style:"color: red;"})];
const applyData = { deco: DecorationSet.create(view.state.doc, decos) };
const tr = state.tr.setMeta(plugin, applyData);
dispatch(tr);
...
Then I use DecorationSet.empty
to remove DecorationSet and I find the node style value is still have "color: red;"
Is there any way to bring the style back before set decoration or force the node render again ?
Thanks
marijn
2
How do you do this and what does your plugin do, exactly? Minimal self-contained example code would be useful.
felix
3
Hi, my plugin is very simple
const plugin = new Plugin({
state: {
init(config, instance) {
return { deco: DecorationSet.empty };
},
apply(tr, value, oldState, newState) {
const data = tr.getMeta(this);
if (data) {
return data;
}
return value;
},
},
props: {
decorations(state) {
return this.getState(state).deco;
},
},
});
and I use dispatch(view.state.tr.setMeta(plugin, { deco: DecorationSet.empty }));
to remove the Decoration
marijn
4
That’s probably issue #676, which is fixed in the current master branch.