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/09/10 20:03:52 UTC

[incubator-annotator] branch master updated (267bbcb -> 871e51d)

This is an automated email from the ASF dual-hosted git repository.

gerben pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git.


    from 267bbcb  Merge pull request #88 from apache/range-as-dom-scope
     new 9e36aaf  Fix forgotten scope→Range change
     new 934746a  Fix describeTextQuote’s clipping range to scope
     new 83e00f8  Fix spec mismatch: RangeSelector’s start is inclusive.
     new 871e51d  Support multi-selection in demo

The 4 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:
 packages/dom/src/range/match.ts         |  2 +-
 packages/dom/src/text-quote/describe.ts |  4 ++--
 web/demo/index.js                       | 13 +++++++++----
 3 files changed, 12 insertions(+), 7 deletions(-)


[incubator-annotator] 01/04: Fix forgotten scope→Range change

Posted by ge...@apache.org.
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

commit 9e36aafa1f4bb5199b42cfdf6cf77630ae99aa8f
Author: Gerben <ge...@treora.com>
AuthorDate: Thu Sep 10 21:53:42 2020 +0200

    Fix forgotten scope→Range change
---
 web/demo/index.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/web/demo/index.js b/web/demo/index.js
index 25fa5b4..a821b89 100644
--- a/web/demo/index.js
+++ b/web/demo/index.js
@@ -127,7 +127,9 @@ async function onSelectionChange() {
   cleanup();
   const selection = document.getSelection();
   const range = selection.getRangeAt(0);
-  const selector = await describeTextQuote(range, source);
+  const scope = document.createRange();
+  scope.selectNodeContents(source);
+  const selector = await describeTextQuote(range, scope);
   anchor(selector);
 }
 


[incubator-annotator] 03/04: Fix spec mismatch: RangeSelector’s start is inclusive.

Posted by ge...@apache.org.
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

commit 83e00f82efcd5df331fb95f2ec98b57cd1f1af2a
Author: Gerben <ge...@treora.com>
AuthorDate: Tue Sep 8 19:47:21 2020 +0200

    Fix spec mismatch: RangeSelector’s start is inclusive.
---
 packages/dom/src/range/match.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/dom/src/range/match.ts b/packages/dom/src/range/match.ts
index b5bbe05..c7e138a 100644
--- a/packages/dom/src/range/match.ts
+++ b/packages/dom/src/range/match.ts
@@ -40,7 +40,7 @@ export function makeCreateRangeSelectorMatcher(
       for await (const [start, end] of pairs) {
         const result = ownerDocument(scope).createRange();
 
-        result.setStart(start.endContainer, start.endOffset);
+        result.setStart(start.startContainer, start.startOffset);
         result.setEnd(end.startContainer, end.startOffset);
 
         if (!result.collapsed) yield result;


[incubator-annotator] 04/04: Support multi-selection in demo

Posted by ge...@apache.org.
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

commit 871e51d777b6ebe11f193855e88e25cfed56cd71
Author: Gerben <ge...@treora.com>
AuthorDate: Tue Sep 8 19:13:21 2020 +0200

    Support multi-selection in demo
    
    A hard-coded selection.getRangeAt(0) just looks sad.
---
 web/demo/index.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/web/demo/index.js b/web/demo/index.js
index a821b89..cb96a40 100644
--- a/web/demo/index.js
+++ b/web/demo/index.js
@@ -89,6 +89,7 @@ function cleanup() {
     removeHighlight();
   }
   target.normalize();
+  info.innerText = '';
 }
 
 const createMatcher = makeRefinable((selector) => {
@@ -120,17 +121,19 @@ async function anchor(selector) {
     cleanupFunctions.push(removeHighlight);
   }
 
-  info.innerText = JSON.stringify(selector, null, 2);
+  info.innerText += JSON.stringify(selector, null, 2) + '\n\n';
 }
 
 async function onSelectionChange() {
   cleanup();
-  const selection = document.getSelection();
-  const range = selection.getRangeAt(0);
   const scope = document.createRange();
   scope.selectNodeContents(source);
-  const selector = await describeTextQuote(range, scope);
-  anchor(selector);
+  const selection = document.getSelection();
+  for (let i = 0; i < selection.rangeCount; i++) {
+    const range = selection.getRangeAt(i);
+    const selector = await describeTextQuote(range, scope);
+    await anchor(selector);
+  }
 }
 
 function onSelectorExampleClick(event) {


[incubator-annotator] 02/04: Fix describeTextQuote’s clipping range to scope

Posted by ge...@apache.org.
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

commit 934746adb09c29c421aa3131b80ef6c2042d8715
Author: Gerben <ge...@treora.com>
AuthorDate: Tue Sep 8 19:34:44 2020 +0200

    Fix describeTextQuote’s clipping range to scope
---
 packages/dom/src/text-quote/describe.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/dom/src/text-quote/describe.ts b/packages/dom/src/text-quote/describe.ts
index 7db2bc3..dca21c8 100644
--- a/packages/dom/src/text-quote/describe.ts
+++ b/packages/dom/src/text-quote/describe.ts
@@ -36,9 +36,9 @@ export async function describeTextQuote(
   range = range.cloneRange();
 
   // Take the part of the range that falls within the scope.
-  if (!scope.isPointInRange(range.startContainer, range.startOffset))
+  if (range.compareBoundaryPoints(Range.START_TO_START, scope) === -1)
     range.setStart(scope.startContainer, scope.startOffset);
-  if (!scope.isPointInRange(range.endContainer, range.endOffset))
+  if (range.compareBoundaryPoints(Range.END_TO_END, scope) === 1)
     range.setEnd(scope.endContainer, scope.endOffset);
 
   return {