Are there examples of hideOn for hoverTooltip?

Thanks. for now I think I don’t have to worry about destroy. I may need to comeback that when I add a way to undo deleting an editor from the environment.

As for the StateField. Ok. I am getting to using StateField. My mental model is “Fields can store additional information in an editor state”, and I understand that the custom effects passed in dispatch can be used in the update of the StateField. So my idea is to remove the property from this (of my plugin) to a StateField.

The core of the StateField looks like this:

  let hoverState = window.CodeMirror.state.StateField.define({
    create() {
      return null;
    },
    update(value, tr) {
      for (let effect of tr.effects) {
        if (effect.is(setHover)) {
          // console.log("effect", effect)
          return effect.value;
        }
      }
    }
  })

and the intermediate version I have looks like this:

....
      const tip = this.source(view, pos, 1);
      if (!tip) {return;}
      this.tooltip = tip.create();
      this.tooltip.dom.style.position = "absolute";
      this.tooltip.dom.classList.add("cm-tooltip-hover");
      this.tooltip.dom.classList.add("cm-tooltip-above");
      this.tooltip.dom.style.left = `${(posCoords.left - rect.left) / scaleX}px`;
      this.tooltip.dom.style.top = `${(posCoords.top - rect.top) / scaleY}px`;
      view.dom.appendChild(this.tooltip.dom);
      this.tooltipPos = {pos, posCoords, line};
      view.dispatch({effects: this.setHover.of({tooltip: this.tooltip, tooltipPos: this.tooltipPos})});
    }
  }

  endHover() {
    this.hoverTimeout = -1;
    if (this.tooltip) {
      this.tooltip.dom?.remove();
      this.tooltip = null;
      this.tooltipPos = null;
      this.view.dispatch({effects: this.setHover.of(null)});
    }
  }
...

I think the idea is that I don’t have “this.tooltip” and “this.tooltipPos” but keep them in the state. I see that the value comes to update of the StateField, and I return it from the update function.

In the endHover() I should be able to remove this.tooltipbut access the state object in some way… But I don’t see how to get to the value. The document for StateField does not seem to have it so it’d be somewhere in the view?

(The intermediate code is accessible here: https://yoshikiohshima.github.io/renkon-pad/?file=https://raw.githubusercontent.com/yoshikiohshima/renkon-pad/refs/heads/main/index.renkon