You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ra...@apache.org on 2019/06/30 17:27:41 UTC

[incubator-annotator] branch master updated (c859733 -> 447ef4e)

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

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


    from c859733  Refactor @annotator/dom to be DOM-centric
     new b10dd76  Move range selector into @annotator/dom
     new 447ef4e  Move @annotator/dom scope utils to module

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:
 demo/search.js                                    |  6 ++++--
 packages/dom/package.json                         |  1 +
 packages/{range => dom}/src/cartesian.js          |  0
 packages/dom/src/index.js                         |  1 +
 packages/{range/src/index.js => dom/src/range.js} |  9 +-------
 demo/mark.js => packages/dom/src/scope.js         | 24 +++++++++++++++-------
 packages/dom/src/text-quote.js                    | 23 ++-------------------
 packages/{range => dom}/test/cartesian.js         |  0
 packages/{range => dom}/test/index.js             |  0
 packages/range/.npmignore                         |  2 --
 packages/range/package.json                       | 25 -----------------------
 yarn.lock                                         |  1 +
 12 files changed, 27 insertions(+), 65 deletions(-)
 rename packages/{range => dom}/src/cartesian.js (100%)
 rename packages/{range/src/index.js => dom/src/range.js} (89%)
 copy demo/mark.js => packages/dom/src/scope.js (58%)
 rename packages/{range => dom}/test/cartesian.js (100%)
 rename packages/{range => dom}/test/index.js (100%)
 delete mode 100644 packages/range/.npmignore
 delete mode 100644 packages/range/package.json


[incubator-annotator] 02/02: Move @annotator/dom scope utils to module

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 447ef4e2c7a10c33a37a1d6549d615b95565ce5e
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Sun Jun 30 10:24:08 2019 -0700

    Move @annotator/dom scope utils to module
---
 packages/dom/src/range.js      |  9 +--------
 packages/dom/src/scope.js      | 35 +++++++++++++++++++++++++++++++++++
 packages/dom/src/text-quote.js | 23 ++---------------------
 3 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/packages/dom/src/range.js b/packages/dom/src/range.js
index 2adb680..29c0708 100644
--- a/packages/dom/src/range.js
+++ b/packages/dom/src/range.js
@@ -13,16 +13,9 @@
  * the License.
  */
 
+import { ownerDocument } from './scope.js';
 import { product } from './cartesian.js';
 
-function ownerDocument(scope) {
-  if ('commonAncestorContainer' in scope) {
-    return scope.commonAncestorContainer.ownerDocument;
-  }
-
-  return scope.ownerDocument;
-}
-
 export function createRangeSelectorCreator(createSelector) {
   return function createRangeSelector(selector) {
     const startSelector = createSelector(selector.startSelector);
diff --git a/packages/dom/src/scope.js b/packages/dom/src/scope.js
new file mode 100644
index 0000000..49c6637
--- /dev/null
+++ b/packages/dom/src/scope.js
@@ -0,0 +1,35 @@
+/**
+ * @license
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+export function ownerDocument(scope) {
+  if ('commonAncestorContainer' in scope) {
+    return scope.commonAncestorContainer.ownerDocument;
+  }
+
+  return scope.ownerDocument;
+}
+
+export function rangeFromScope(scope) {
+  if ('commonAncestorContainer' in scope) {
+    return scope;
+  }
+
+  const document = scope.ownerDocument;
+  const range = document.createRange();
+
+  range.selectNodeContents(scope);
+
+  return range;
+}
diff --git a/packages/dom/src/text-quote.js b/packages/dom/src/text-quote.js
index 12e5a4a..ddebfbc 100644
--- a/packages/dom/src/text-quote.js
+++ b/packages/dom/src/text-quote.js
@@ -16,6 +16,8 @@
 import createNodeIterator from 'dom-node-iterator';
 import seek from 'dom-seek';
 
+import { ownerDocument, rangeFromScope } from './scope.js';
+
 // Node constants
 const TEXT_NODE = 3;
 
@@ -32,27 +34,6 @@ function firstTextNodeInRange(range) {
   return iter.nextNode();
 }
 
-function ownerDocument(scope) {
-  if ('commonAncestorContainer' in scope) {
-    return scope.commonAncestorContainer.ownerDocument;
-  }
-
-  return scope.ownerDocument;
-}
-
-function rangeFromScope(scope) {
-  if ('commonAncestorContainer' in scope) {
-    return scope;
-  }
-
-  const document = scope.ownerDocument;
-  const range = document.createRange();
-
-  range.selectNodeContents(scope);
-
-  return range;
-}
-
 export function createTextQuoteSelector(selector) {
   return async function* matchAll(scope) {
     const document = ownerDocument(scope);


[incubator-annotator] 01/02: Move range selector into @annotator/dom

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b10dd76c96186606fd4ad0714725663e0944a513
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Sun Jun 30 10:14:12 2019 -0700

    Move range selector into @annotator/dom
    
    The implementation of a range selector is specific to the types of scope
    and match. With the new implementation of the Text Quote selector for
    the DOM returning a DOM Range, the current range selector belongs inside
    the @annotator/dom package.
---
 demo/search.js                                    |  6 ++++--
 packages/dom/package.json                         |  1 +
 packages/{range => dom}/src/cartesian.js          |  0
 packages/dom/src/index.js                         |  1 +
 packages/{range/src/index.js => dom/src/range.js} |  0
 packages/{range => dom}/test/cartesian.js         |  0
 packages/{range => dom}/test/index.js             |  0
 packages/range/.npmignore                         |  2 --
 packages/range/package.json                       | 25 -----------------------
 yarn.lock                                         |  1 +
 10 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/demo/search.js b/demo/search.js
index 7760088..e5145a3 100644
--- a/demo/search.js
+++ b/demo/search.js
@@ -14,8 +14,10 @@
  */
 
 import { makeRefinable } from '@annotator/selector';
-import { createRangeSelectorCreator } from '@annotator/range';
-import { createTextQuoteSelector } from '@annotator/dom';
+import {
+  createRangeSelectorCreator,
+  createTextQuoteSelector,
+} from '@annotator/dom';
 
 const createSelector = makeRefinable(selector => {
   const selectorCreator = {
diff --git a/packages/dom/package.json b/packages/dom/package.json
index 27dc65a..4e12ee6 100644
--- a/packages/dom/package.json
+++ b/packages/dom/package.json
@@ -13,6 +13,7 @@
   "module": "esm/index.js",
   "dependencies": {
     "@babel/runtime-corejs3": "^7.4.0",
+    "cartesian": "^1.0.1",
     "core-js": "3",
     "dom-node-iterator": "^3.5.3",
     "dom-seek": "^4.0.3"
diff --git a/packages/range/src/cartesian.js b/packages/dom/src/cartesian.js
similarity index 100%
rename from packages/range/src/cartesian.js
rename to packages/dom/src/cartesian.js
diff --git a/packages/dom/src/index.js b/packages/dom/src/index.js
index 1d4a9b3..9caac1b 100644
--- a/packages/dom/src/index.js
+++ b/packages/dom/src/index.js
@@ -14,4 +14,5 @@
  */
 
 export * from './css';
+export * from './range';
 export * from './text-quote';
diff --git a/packages/range/src/index.js b/packages/dom/src/range.js
similarity index 100%
rename from packages/range/src/index.js
rename to packages/dom/src/range.js
diff --git a/packages/range/test/cartesian.js b/packages/dom/test/cartesian.js
similarity index 100%
rename from packages/range/test/cartesian.js
rename to packages/dom/test/cartesian.js
diff --git a/packages/range/test/index.js b/packages/dom/test/index.js
similarity index 100%
rename from packages/range/test/index.js
rename to packages/dom/test/index.js
diff --git a/packages/range/.npmignore b/packages/range/.npmignore
deleted file mode 100644
index 281df39..0000000
--- a/packages/range/.npmignore
+++ /dev/null
@@ -1,2 +0,0 @@
-src
-test
diff --git a/packages/range/package.json b/packages/range/package.json
deleted file mode 100644
index 06041c4..0000000
--- a/packages/range/package.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-  "name": "@annotator/range",
-  "version": "0.0.0",
-  "description": "Utilities for annotation.",
-  "homepage": "https://annotator.apache.org",
-  "repository": {
-    "type": "git",
-    "url": "https://github.com/apache/incubator-annotator.git"
-  },
-  "license": "Apache-2.0",
-  "author": "Apache Software Foundation",
-  "main": "lib/index.js",
-  "module": "esm/index.js",
-  "dependencies": {
-    "@babel/runtime-corejs3": "^7.4.0",
-    "cartesian": "^1.0.1",
-    "core-js": "3"
-  },
-  "engines": {
-    "node": ">=6.0.0"
-  },
-  "publishConfig": {
-    "access": "public"
-  }
-}
diff --git a/yarn.lock b/yarn.lock
index 28b30d3..ea02686 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2364,6 +2364,7 @@ caniuse-lite@^1.0.30000974:
 cartesian@^1.0.1:
   version "1.0.1"
   resolved "https://registry.yarnpkg.com/cartesian/-/cartesian-1.0.1.tgz#ae3fc8a63e2ba7e2c4989ce696207457bcae65af"
+  integrity sha1-rj/Ipj4rp+LEmJzmliB0V7yuZa8=
   dependencies:
     xtend "^4.0.1"