This is an automated email from the ASF dual-hosted git repository.
gerben pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
The following commit(s) were added to refs/heads/master by this push:
new adfdd09 Use node as scope in demo
adfdd09 is described below
commit adfdd09fec03a60b9683db7a85001a5a015f5dc7
Author: Gerben <[email protected]>
AuthorDate: Sat Jun 5 19:38:57 2021 +0200
Use node as scope in demo
---
web/index.js | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/web/index.js b/web/index.js
index ca2be03..abb9a8b 100644
--- a/web/index.js
+++ b/web/index.js
@@ -111,13 +111,10 @@ const createMatcher = makeRefinable((selector) => {
});
async function anchor(selector) {
- const scope = document.createRange();
- scope.selectNodeContents(target);
-
const matchAll = createMatcher(selector);
const ranges = [];
- for await (const range of matchAll(scope)) {
+ for await (const range of matchAll(target)) {
ranges.push(range);
}
@@ -132,15 +129,13 @@ async function anchor(selector) {
async function onSelectionChange() {
cleanup();
const describeMode = form.describeMode.value;
- const scope = document.createRange();
- scope.selectNodeContents(source);
const selection = document.getSelection();
for (let i = 0; i < selection.rangeCount; i++) {
const range = selection.getRangeAt(i);
const selector =
describeMode === 'TextPosition'
- ? await describeTextPosition(range, scope)
- : await describeTextQuote(range, scope, { minimumQuoteLength: 10 });
+ ? await describeTextPosition(range, source)
+ : await describeTextQuote(range, source, { minimumQuoteLength: 10 });
await anchor(selector);
}
}