Page MenuHomePhabricator

Can't reliably gather list of annotation views from a DM offset
Open, Needs TriagePublic

Description

In ve.ce.Surface.prototype.annotationsAtModelSelection we move the cursor one to the right, and use getNodeAndOffset to find the inner annotation, then traverse the DOM to find all surrounding annotations.

The technique fails when the annotation is one character wide, and is generally quite hacky.

We can easily gather annotation models just by looking at the linear data, so there should be a way to do this for the view.

Event Timeline

A side effect of this is if you cursor onto a link from the right, the preview doesn't render:

image.png (199×415 px, 14 KB)

I recall poking around for this in the past, and we've been fairly good at avoiding the model knowing about its views. Which is sensible design, but inconvenient at times like this.

That's correct, but the pattern for nodes is view.getNodeFromOffset( modelOffset ) which doesn't violate that rule, so we should have something similar for annotations.

Esanders updated the task description. (Show Details)

@dchan Perhaps we need a new data structure to keep track of annotations and their offsets?

A side effect of this is if you cursor onto a link from the right, the preview doesn't render:

image.png (199×415 px, 14 KB)

With the hacks from T226708 and T225541, this is now only apparent for single-character links.