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/05/28 13:14:46 UTC
[incubator-annotator] branch dom-tests updated: Simplify demo’s use of describeTextQuote
This is an automated email from the ASF dual-hosted git repository.
gerben pushed a commit to branch dom-tests
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
The following commit(s) were added to refs/heads/dom-tests by this push:
new fdc6b4a Simplify demo’s use of describeTextQuote
fdc6b4a is described below
commit fdc6b4a097de8968b62f13297deb144dddfd2fef
Author: Gerben <ge...@treora.com>
AuthorDate: Thu May 28 15:08:40 2020 +0200
Simplify demo’s use of describeTextQuote
- An element can be directly used as the scope
- No need to abort if the range extends beyond the scope, as it is
trimmed automatically now.
---
web/demo/index.js | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/web/demo/index.js b/web/demo/index.js
index b9e2533..aa2e48b 100644
--- a/web/demo/index.js
+++ b/web/demo/index.js
@@ -127,13 +127,7 @@ async function describeSelection() {
const range = selection.getRangeAt(0);
if (range.collapsed) return;
- const scope = document.createRange();
- scope.selectNodeContents(source);
-
- if (!scope.isPointInRange(range.startContainer, range.startOffset)) return;
- if (!scope.isPointInRange(range.endContainer, range.endOffset)) return;
-
- return describeTextQuote(range, scope);
+ return describeTextQuote(range, source);
}
async function onSelectionChange() {