You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2020/03/05 23:30:50 UTC
[incubator-annotator] branch use-highlighter-in-demo updated
(7e381e8 -> fc4afdb)
This is an automated email from the ASF dual-hosted git repository.
gerben pushed a change to branch use-highlighter-in-demo
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git.
discard 7e381e8 Remove <mark> border because text nodes remain split.
discard 7f7ea7c Use removeHighlight() instead of replacing innerHTML
new 0774bb2 Use removeHighlight() instead of replacing innerHTML
new fc4afdb Remove <mark> border because text nodes remain split.
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (7e381e8)
\
N -- N -- N refs/heads/use-highlighter-in-demo (fc4afdb)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
[incubator-annotator] 02/02: Remove border because text
nodes remain split.
Posted by ge...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gerben pushed a commit to branch use-highlighter-in-demo
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit fc4afdbd425e75a0cef459cff8679ed085630a7b
Author: Gerben <ge...@treora.com>
AuthorDate: Fri Mar 6 00:10:42 2020 +0100
Remove <mark> border because text nodes remain split.
A motivation to merge split nodes again in the removeHighlight function,
e.g. using Node.normalize().
---
demo/index.html | 1 -
1 file changed, 1 deletion(-)
diff --git a/demo/index.html b/demo/index.html
index facccec..0ae10c1 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -33,7 +33,6 @@ under the License.
}
mark {
background-color: rgba(255, 255, 0, 0.5);
- outline: 0.1px solid rgba(255, 100, 0, 0.8);
}
#parsed {
height: 15rem;
[incubator-annotator] 01/02: Use removeHighlight() instead of
replacing innerHTML
Posted by ge...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gerben pushed a commit to branch use-highlighter-in-demo
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 0774bb27c8775e2d59aec9f910908fd42757275e
Author: Gerben <ge...@treora.com>
AuthorDate: Fri Mar 6 00:08:53 2020 +0100
Use removeHighlight() instead of replacing innerHTML
Note that text nodes that are split by the highlighter will remain split
after a cleanup(). This reveals a bug in our matching functions, as the
“any deeper nesting” example now fails to find any matches (except at a
first try, when the text nodes are not yet split).
---
demo/index.js | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/demo/index.js b/demo/index.js
index 629d489..0506666 100644
--- a/demo/index.js
+++ b/demo/index.js
@@ -32,8 +32,13 @@ import {
} from '@annotator/dom';
import { makeRefinable } from '@annotator/selector';
-function clear() {
- corpus.innerHTML = selectable.innerHTML;
+const cleanupFunctions = [];
+
+function cleanup() {
+ let removeHighlight;
+ while (removeHighlight = cleanupFunctions.shift()) {
+ removeHighlight();
+ }
}
const createSelector = makeRefinable(selector => {
@@ -50,7 +55,7 @@ const createSelector = makeRefinable(selector => {
});
const refresh = async () => {
- clear();
+ cleanup();
const fragment = window.location.hash.slice(1);
if (!fragment) return;
@@ -64,7 +69,8 @@ const refresh = async () => {
}
for (const range of ranges) {
- highlightRange(range);
+ const removeHighlight = highlightRange(range);
+ cleanupFunctions.push(removeHighlight);
}
parsed.innerText = JSON.stringify(selector, null, 2);