Textmarker 的评价
Textmarker 作者: underflyingbirches
underflyingbirches 的回应
开发者回应
发布于 4 年前Hi hmijail, as I tried to explain to you on GitHub: There is nothing strange about restoration failures of saved highlights for pages that change their content. In fact it's expected and I notify users in bold letters about it both on this addon page as well as on the Textmarker pages.
A restoration cannot be successful if:
1) The highlighted text is not on the page anymore (obviously) or
2) The "surrounding content" of the highlight has changed: As explained on GitHub, since DOM elements ceise to exist on page unload there is no way of saving a direct reference, which is why Textmarker has to rely on an indirect description of the highlight's location. This description holds information about the `nodeName` of the ancestor DOM elements as well as the position of those elements (i.e. 3rd child node of its parent element) and the corresp. text node's starting point of the selection. So a verbalized example description could be (a bit simplified):
"Starts at character 4 of the 3rd child node of a p-element, which is the first child of a div-element"
This is necessary, because a highlighted text could occur multiple times on a give page, so it wouldn't be sufficient on page revisit to just search for that text and highlight the first occurrence.
A restoration cannot be successful if:
1) The highlighted text is not on the page anymore (obviously) or
2) The "surrounding content" of the highlight has changed: As explained on GitHub, since DOM elements ceise to exist on page unload there is no way of saving a direct reference, which is why Textmarker has to rely on an indirect description of the highlight's location. This description holds information about the `nodeName` of the ancestor DOM elements as well as the position of those elements (i.e. 3rd child node of its parent element) and the corresp. text node's starting point of the selection. So a verbalized example description could be (a bit simplified):
"Starts at character 4 of the 3rd child node of a p-element, which is the first child of a div-element"
This is necessary, because a highlighted text could occur multiple times on a give page, so it wouldn't be sufficient on page revisit to just search for that text and highlight the first occurrence.