There are different ways of accessing properties of the state: memory efficient and via cursors/iterators.
How costly is it (internally) to go over 20-50 widgets every change/update using .iter ?
const rangeSets = view.state.facet(EditorView.atomicRanges).map((f)=>f(view));
for (let i=0; i<rangeSets.length; ++i) {
if (rangeSets[i].size > 0) {
const cursor = rangeSets[i].iter();
let v;
do {
v = cursor.value;
if (!v) break;
//get some properties of v.widget...
cursor.next();
} while(v);
}
};
Or should I bypass facet method and go directly to values of editor view? I believe it is probably considered as a bad practice…
Now I also noticed if I query atomicRanges from another view plugin during update or first creation the list is empty. Only if I trigger the request during viewport change, then there is something.
I though may be atomic ranges are not yet created, so I lowered the priority of my view plugin, which gets all atomic ranges widgets using Prec.lowest, however it did not help.
While I was setting up a minimal example in the playground, I had realized that it was mistake.
I was checking DOMElement of point decorations widgets, while during update/construction, but it is immediately available, since toDOM is delayed.
in the end works perfectly combined with iterating over the existing syntax tree. I just defer the measurements of the DOM element offsetHeight, when they are available.
The result is fantastic!
it all also works nicely for the nested editors as well