Hey there!
I wonder if there is a possibility to iterate through all decorations on click event.
Please take a look at the example below and the comments in the code
const DecoPlugin = ViewPlugin.fromClass(
class {
decorations: DecorationSet;
constructor(view: EditorView) {
this.decorations = deco(view);
}
update(update: ViewUpdate) {
if (update.docChanged || update.viewportChanged) {
this.decorations = deco(update.view);
}
}
},
{
decorations: (v) => v.decorations,
eventHandlers: {
click: (e, view) => {
const target = e.target as HTMLElement;
// here I would like to check if the clicked element is a decorator
// if YES, I want to take its coords (from, to)
}
}
}
);
const deco = (view: EditorView) => {
const widgets: Range<Decoration>[] = [];
// here I add lots of decorators
// widget.push(Decoration.replace(...)
return Decoration.set(widgets, true);
};
Though in package-lock.json I have these dependencies from basic-setup… But I dont use it, basic-setup is an option in uiw/react-codemirror component, which I disabled