hypothesis / client

The Hypothesis web-based annotation client.
Other
631 stars 195 forks source link

DOM changes to insert highlights around text blocked in Notion #5069

Open dwhly opened 1 year ago

dwhly commented 1 year ago

The selected highlight and the ability to scroll to the highlight by the H annotation client aren't working on Notion web pages-- presumably because our mutations that wrap text nodes in <hypothesis-highlight> elements get stripped out.

We get console warnings like the following:

Screenshot 2022-12-14 at 6 41 37 AM

I noticed a similar issue on another project, which ultimately was resolved... possibly in the new editor launched earlier in the year?: https://github.com/obahareth/notion-rtl/issues/28#issuecomment-1017756589

Given that web annotation and the mechanisms to make it work on the DOM are a larger class of problem I'm curious if there are elegant ways of addressing this, possibly collaboratively between teams.

dwhly commented 1 year ago

@justjake We'd be thankful for any perspective you could share here.

robertknight commented 11 months ago

Given that web annotation and the mechanisms to make it work on the DOM are a larger class of problem I'm curious if there are elegant ways of addressing this, possibly collaboratively between teams.

The CSS Highlight API allows creating highlights without modifying the DOM, so can be used in some cases to avoid creating a conflict with the page's own UI rendering. The current API is missing direct support for interactive highlights. It also faces the theoretical problem that the web application could choose to re-render the UI and "destroy" the highlights at any time.

The other direction is to take some kind of static snapshot of the UI and annotate that.