Detect cursor motion into atomicRanges widget

In the docs on atomicRanges there is facet extension used to skip atoms. I was wondering, is it possible to detect the cursor movement into the replacement atomic decoration and send an event to the corresponding WidgetType?

I guess I need to apply a custom transaction filter to stop the cursor movement and fire an event on a widget. So I check the source code of atomicRanges to have an idea how to do it

function skipAtoms(view, oldPos, pos) {
    let atoms = view.state.facet(atomicRanges).map(f => f(view));
    for (;;) {
        let moved = false;
        for (let set of atoms) {
            set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
                if (pos.from > from && pos.from < to) {
                    pos = oldPos.head > pos.from ? EditorSelection.cursor(from, 1) : EditorSelection.cursor(to, -1);
                    moved = true;
        if (!moved)
            return pos;

It looks like that an atom object contains only ranges of symbols, which cover atoms, but they have no direct references to the instances of a WidgetType placed on the corresponding range. Or where should I look for that?


No, atomicRanges can’t do that, but instead of using that you could define a transaction filter that, when the selection ends up inside one of your ranges, moves it as appropriate and adds some effect that makes your extension update the appropriate widget (widgets are stateless, so you don’t really send events to them, but rather you replace them with a different instance).