Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
fac2a28d
Commit
fac2a28d
authored
Jan 15, 2020
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert src/annotator/anchoring to ES modules
parent
f2d13a01
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
33 deletions
+23
-33
pdf.js
src/annotator/anchoring/pdf.js
+9
-14
fake-pdf-viewer-application.js
src/annotator/anchoring/test/fake-pdf-viewer-application.js
+2
-4
index.js
src/annotator/anchoring/test/html-baselines/index.js
+1
-1
html-test.js
src/annotator/anchoring/test/html-test.js
+4
-4
pdf-test.js
src/annotator/anchoring/test/pdf-test.js
+4
-3
text-position-test.js
src/annotator/anchoring/test/text-position-test.js
+1
-1
types-test.js
src/annotator/anchoring/test/types-test.js
+1
-1
text-position.js
src/annotator/anchoring/text-position.js
+1
-5
No files found.
src/annotator/anchoring/pdf.js
View file @
fac2a28d
/* global PDFViewerApplication */
const
seek
=
require
(
'dom-seek'
)
;
import
seek
from
'dom-seek'
;
// `dom-node-iterator` polyfills optional arguments of `createNodeIterator`
// and properties of the returned `NodeIterator` for IE 11 compatibility.
const
createNodeIterator
=
require
(
'dom-node-iterator/polyfill'
)();
const
xpathRange
=
require
(
'./range'
);
const
RenderingStates
=
require
(
'../pdfjs-rendering-states'
);
const
{
TextPositionAnchor
,
TextQuoteAnchor
}
=
require
(
'./types'
);
const
{
toRange
:
textPositionToRange
}
=
require
(
'./text-position'
);
import
RenderingStates
from
'../pdfjs-rendering-states'
;
import
xpathRange
from
'./range'
;
import
{
toRange
as
textPositionToRange
}
from
'./text-position'
;
import
{
TextPositionAnchor
,
TextQuoteAnchor
}
from
'./types'
;
// Caches for performance.
...
...
@@ -342,7 +343,7 @@ function prioritizePages(position) {
* @param {Array} selectors - Selector objects to anchor
* @return {Promise<Range>}
*/
function
anchor
(
root
,
selectors
)
{
export
function
anchor
(
root
,
selectors
)
{
const
position
=
selectors
.
find
(
s
=>
s
.
type
===
'TextPositionSelector'
);
const
quote
=
selectors
.
find
(
s
=>
s
.
type
===
'TextQuoteSelector'
);
...
...
@@ -406,7 +407,7 @@ function anchor(root, selectors) {
* `toSelector` methods.
* @return {Promise<[TextPositionSelector, TextQuoteSelector]>}
*/
function
describe
(
root
,
range
,
options
=
{})
{
export
function
describe
(
root
,
range
,
options
=
{})
{
const
normalizedRange
=
new
xpathRange
.
BrowserRange
(
range
).
normalize
();
const
startTextLayer
=
getNodeTextLayer
(
normalizedRange
.
start
);
...
...
@@ -461,13 +462,7 @@ function describe(root, range, options = {}) {
*
* This exists mainly as a helper for use in tests.
*/
function
purgeCache
()
{
export
function
purgeCache
()
{
pageTextCache
=
{};
quotePositionCache
=
{};
}
module
.
exports
=
{
anchor
,
describe
,
purgeCache
,
};
src/annotator/anchoring/test/fake-pdf-viewer-application.js
View file @
fac2a28d
...
...
@@ -9,7 +9,7 @@
* each of the relevant classes in PDF.js.
*/
const
RenderingStates
=
require
(
'../../pdfjs-rendering-states'
)
;
import
RenderingStates
from
'../../pdfjs-rendering-states'
;
/**
* Create the DOM structure for a page which matches the structure produced by
...
...
@@ -197,7 +197,7 @@ class FakePDFViewer {
*
* The original is defined at https://github.com/mozilla/pdf.js/blob/master/web/app.js
*/
class
FakePDFViewerApplication
{
export
default
class
FakePDFViewerApplication
{
/**
* @param {Options} options
*/
...
...
@@ -215,5 +215,3 @@ class FakePDFViewerApplication {
this
.
pdfViewer
.
dispose
();
}
}
module
.
exports
=
FakePDFViewerApplication
;
src/annotator/anchoring/test/html-baselines/index.js
View file @
fac2a28d
...
...
@@ -21,7 +21,7 @@
// them as `<fixture name>.json` in this directory
// 4. Add an entry to the fixture list below.
module
.
exports
=
[
export
default
[
{
name
:
'Minimal Document'
,
html
:
require
(
'./minimal.html'
),
...
...
src/annotator/anchoring/test/html-test.js
View file @
fac2a28d
const
html
=
require
(
'../html'
);
import
{
toResult
}
from
'../../../shared/test/promise-util'
;
import
*
as
html
from
'../html'
;
const
{
toResult
}
=
require
(
'../../../shared/test/promise-util'
);
const
fixture
=
require
(
'./html-anchoring-fixture.html'
);
const
htmlBaselines
=
require
(
'./html-baselines'
);
import
fixture
from
'./html-anchoring-fixture.html'
;
import
htmlBaselines
from
'./html-baselines'
;
/** Return all text node children of `container`. */
function
textNodes
(
container
)
{
...
...
src/annotator/anchoring/test/pdf-test.js
View file @
fac2a28d
const
domAnchorTextQuote
=
require
(
'dom-anchor-text-quote'
)
;
import
*
as
domAnchorTextQuote
from
'dom-anchor-text-quote'
;
const
FakePDFViewerApplication
=
require
(
'./fake-pdf-viewer-application'
);
const
pdfAnchoring
=
require
(
'../pdf'
);
import
*
as
pdfAnchoring
from
'../pdf'
;
import
FakePDFViewerApplication
from
'./fake-pdf-viewer-application'
;
/**
* Return a DOM Range which refers to the specified `text` in `container`.
...
...
src/annotator/anchoring/test/text-position-test.js
View file @
fac2a28d
const
{
toRange
}
=
require
(
'../text-position'
)
;
import
{
toRange
}
from
'../text-position'
;
describe
(
'text-position'
,
()
=>
{
let
container
;
...
...
src/annotator/anchoring/test/types-test.js
View file @
fac2a28d
const
types
=
require
(
'../types'
)
;
import
*
as
types
from
'../types'
;
const
TextQuoteAnchor
=
types
.
TextQuoteAnchor
;
const
TextPositionAnchor
=
types
.
TextPositionAnchor
;
...
...
src/annotator/anchoring/text-position.js
View file @
fac2a28d
...
...
@@ -21,7 +21,7 @@
* @param {number} end - Character offset within `root.textContent`
* @return {Range} Range spanning text from `start` to `end`
*/
function
toRange
(
root
,
start
,
end
)
{
export
function
toRange
(
root
,
start
,
end
)
{
// The `filter` and `expandEntityReferences` arguments are mandatory in IE
// although optional according to the spec.
const
nodeIter
=
root
.
ownerDocument
.
createNodeIterator
(
...
...
@@ -76,7 +76,3 @@ function toRange(root, start, end) {
return
range
;
}
module
.
exports
=
{
toRange
,
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment