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
94b4b245
Commit
94b4b245
authored
May 10, 2021
by
Eduardo Sanz García
Committed by
Eduardo
May 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change some formatting to pass prettier v2.3.0
parent
6479546d
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
144 additions
and
145 deletions
+144
-145
pdf.js
src/annotator/anchoring/pdf.js
+8
-9
pdf-test.js
src/annotator/anchoring/test/pdf-test.js
+2
-2
text-range.js
src/annotator/anchoring/text-range.js
+6
-7
NotebookModal.js
src/annotator/components/NotebookModal.js
+8
-7
settings-test.js
src/annotator/config/test/settings-test.js
+3
-6
guest.js
src/annotator/guest.js
+3
-3
highlighter.js
src/annotator/highlighter.js
+3
-1
index.js
src/annotator/index.js
+5
-3
pdf.js
src/annotator/integrations/pdf.js
+6
-6
range-util.js
src/annotator/range-util.js
+3
-4
sidebar.js
src/annotator/sidebar.js
+10
-8
multi-frame-test.js
src/annotator/test/integration/multi-frame-test.js
+4
-6
shadow-root.js
src/annotator/util/shadow-root.js
+5
-3
url-template.js
src/boot/url-template.js
+3
-1
Dialog.js
src/shared/components/Dialog.js
+3
-1
AnnotationTimestamps.js
src/sidebar/components/Annotation/AnnotationTimestamps.js
+4
-3
Excerpt.js
src/sidebar/components/Excerpt.js
+2
-3
GroupList.js
src/sidebar/components/GroupList/GroupList.js
+4
-3
HelpPanel.js
src/sidebar/components/HelpPanel.js
+2
-2
MarkdownView.js
src/sidebar/components/MarkdownView.js
+4
-3
NotebookView.js
src/sidebar/components/NotebookView.js
+2
-3
ThreadList.js
src/sidebar/components/ThreadList.js
+14
-17
ShareAnnotationsPanel-test.js
src/sidebar/components/test/ShareAnnotationsPanel-test.js
+6
-3
UserMenu-test.js
src/sidebar/components/test/UserMenu-test.js
+4
-8
index.js
src/sidebar/index.js
+6
-6
annotations-test.js
src/sidebar/services/test/annotations-test.js
+4
-4
index.js
src/sidebar/store/index.js
+3
-5
activity.js
src/sidebar/store/modules/activity.js
+2
-3
activity-test.js
src/sidebar/store/modules/test/activity-test.js
+12
-12
sentry-test.js
src/sidebar/util/test/sentry-test.js
+1
-2
unicode.js
src/sidebar/util/unicode.js
+2
-1
No files found.
src/annotator/anchoring/pdf.js
View file @
94b4b245
...
...
@@ -426,12 +426,12 @@ function prioritizePages(position) {
* @return {Promise<Range>}
*/
export
function
anchor
(
root
,
selectors
)
{
const
position
=
/** @type {TextPositionSelector|undefined} */
(
selectors
.
find
(
s
=>
s
.
type
===
'TextPositionSelector'
)
)
;
const
quote
=
/** @type {TextQuoteSelector|undefined} */
(
selectors
.
find
(
s
=>
s
.
type
===
'TextQuoteSelector'
)
)
;
const
position
=
/** @type {TextPositionSelector|undefined} */
(
s
electors
.
find
(
s
=>
s
.
type
===
'TextPositionSelector'
)
);
const
quote
=
/** @type {TextQuoteSelector|undefined} */
(
s
electors
.
find
(
s
=>
s
.
type
===
'TextQuoteSelector'
)
);
/** @type {Promise<Range>} */
let
result
=
Promise
.
reject
(
'unable to anchor'
);
...
...
@@ -464,9 +464,8 @@ export function anchor(root, selectors) {
quotePositionCache
[
quote
.
exact
]
&&
quotePositionCache
[
quote
.
exact
][
position
.
start
]
)
{
const
{
pageIndex
,
anchor
}
=
quotePositionCache
[
quote
.
exact
][
position
.
start
];
const
{
pageIndex
,
anchor
}
=
quotePositionCache
[
quote
.
exact
][
position
.
start
];
return
anchorByPosition
(
pageIndex
,
anchor
.
start
,
anchor
.
end
);
}
...
...
src/annotator/anchoring/test/pdf-test.js
View file @
94b4b245
...
...
@@ -139,8 +139,8 @@ describe('annotator/anchoring/pdf', function () {
const
quote
=
'NODE B'
;
// this selects NODE A text node
const
textNodeSelected
=
container
.
querySelector
(
'.textLayer div'
)
.
firstChild
;
const
textNodeSelected
=
container
.
querySelector
(
'.textLayer div'
)
.
firstChild
;
const
staticRange
=
findText
(
container
,
quote
);
const
range
=
{
...
...
src/annotator/anchoring/text-range.js
View file @
94b4b245
...
...
@@ -41,10 +41,9 @@ function previousSiblingsTextLength(node) {
*/
function
resolveOffsets
(
element
,
...
offsets
)
{
let
nextOffset
=
offsets
.
shift
();
const
nodeIter
=
/** @type {Document} */
(
element
.
ownerDocument
).
createNodeIterator
(
element
,
NodeFilter
.
SHOW_TEXT
);
const
nodeIter
=
/** @type {Document} */
(
element
.
ownerDocument
).
createNodeIterator
(
element
,
NodeFilter
.
SHOW_TEXT
);
const
results
=
[];
let
currentNode
=
nodeIter
.
nextNode
();
...
...
@@ -157,9 +156,9 @@ export class TextPosition {
);
tw
.
currentNode
=
this
.
element
;
const
forwards
=
options
.
direction
===
RESOLVE_FORWARDS
;
const
text
=
/** @type {Text|null} */
(
forwards
?
tw
.
next
Node
()
:
tw
.
previousNode
()
);
const
text
=
/** @type {Text|null} */
(
forwards
?
tw
.
nextNode
()
:
tw
.
previous
Node
()
);
if
(
!
text
)
{
throw
err
;
}
...
...
src/annotator/components/NotebookModal.js
View file @
94b4b245
...
...
@@ -79,13 +79,14 @@ export default function NotebookModal({ eventBus, config }) {
useEffect
(()
=>
{
emitter
.
current
=
eventBus
.
createEmitter
();
emitter
.
current
.
subscribe
(
'openNotebook'
,
(
/** @type {string} */
groupId
)
=>
{
setIsHidden
(
false
);
setIframeKey
(
iframeKey
=>
iframeKey
+
1
);
setGroupId
(
groupId
);
});
emitter
.
current
.
subscribe
(
'openNotebook'
,
(
/** @type {string} */
groupId
)
=>
{
setIsHidden
(
false
);
setIframeKey
(
iframeKey
=>
iframeKey
+
1
);
setGroupId
(
groupId
);
}
);
return
()
=>
{
emitter
.
current
.
destroy
();
...
...
src/annotator/config/test/settings-test.js
View file @
94b4b245
...
...
@@ -627,8 +627,7 @@ describe('annotator/config/settingsFrom', () => {
expected
:
null
,
},
{
when
:
'the client is in a browser extension and allowInBrowserExt: true is given'
,
when
:
'the client is in a browser extension and allowInBrowserExt: true is given'
,
specify
:
'it returns settings from window.hypothesisConfig()'
,
isBrowserExtension
:
true
,
allowInBrowserExt
:
true
,
...
...
@@ -637,8 +636,7 @@ describe('annotator/config/settingsFrom', () => {
expected
:
'configFuncValue'
,
},
{
when
:
'the client is in a browser extension and allowInBrowserExt: true is given'
,
when
:
'the client is in a browser extension and allowInBrowserExt: true is given'
,
specify
:
'it returns settings from js-hypothesis-configs'
,
isBrowserExtension
:
true
,
allowInBrowserExt
:
true
,
...
...
@@ -677,8 +675,7 @@ describe('annotator/config/settingsFrom', () => {
expected
:
'not the default value'
,
},
{
when
:
'the client is in a browser extension and a default value is provided'
,
when
:
'the client is in a browser extension and a default value is provided'
,
specify
:
'it returns the default value'
,
isBrowserExtension
:
true
,
allowInBrowserExt
:
false
,
...
...
src/annotator/guest.js
View file @
94b4b245
...
...
@@ -414,9 +414,9 @@ export default class Guest {
return
;
}
const
highlights
=
/** @type {AnnotationHighlight[]} */
(
highlightRange
(
range
)
)
;
const
highlights
=
/** @type {AnnotationHighlight[]} */
(
highlightRange
(
range
)
);
highlights
.
forEach
(
h
=>
{
h
.
_annotation
=
anchor
.
annotation
;
});
...
...
src/annotator/highlighter.js
View file @
94b4b245
...
...
@@ -168,7 +168,9 @@ function wholeTextNodesInRange(range) {
}
const
textNodes
=
[];
const
nodeIter
=
/** @type {Document} */
(
root
.
ownerDocument
).
createNodeIterator
(
const
nodeIter
=
/** @type {Document} */
(
root
.
ownerDocument
).
createNodeIterator
(
root
,
NodeFilter
.
SHOW_TEXT
// Only return `Text` nodes.
);
...
...
src/annotator/index.js
View file @
94b4b245
...
...
@@ -27,9 +27,11 @@ const window_ = /** @type {HypothesisWindow} */ (window);
// Look up the URL of the sidebar. This element is added to the page by the
// boot script before the "annotator" bundle loads.
const
appLinkEl
=
/** @type {Element} */
(
document
.
querySelector
(
'link[type="application/annotator+html"][rel="sidebar"]'
));
const
appLinkEl
=
/** @type {Element} */
(
document
.
querySelector
(
'link[type="application/annotator+html"][rel="sidebar"]'
)
);
const
config
=
configFrom
(
window
);
...
...
src/annotator/integrations/pdf.js
View file @
94b4b245
...
...
@@ -201,9 +201,9 @@ export class PDFIntegration {
_toggleNoSelectableTextWarning
(
showWarning
)
{
// Get a reference to the top-level DOM element associated with the PDF.js
// viewer.
const
outerContainer
=
/** @type {HTMLElement} */
(
document
.
querySelector
(
'#outerContainer'
)
)
;
const
outerContainer
=
/** @type {HTMLElement} */
(
document
.
querySelector
(
'#outerContainer'
)
);
if
(
!
showWarning
)
{
this
.
_warningBanner
?.
remove
();
...
...
@@ -294,9 +294,9 @@ export class PDFIntegration {
* @return {HTMLElement}
*/
contentContainer
()
{
return
/** @type {HTMLElement} */
(
document
.
querySelector
(
'#viewerContainer'
)
)
;
return
/** @type {HTMLElement} */
(
document
.
querySelector
(
'#viewerContainer'
)
);
}
/**
...
...
src/annotator/range-util.js
View file @
94b4b245
...
...
@@ -46,10 +46,9 @@ export function isNodeInRange(range, node) {
*/
export
function
forEachNodeInRange
(
range
,
callback
)
{
const
root
=
range
.
commonAncestorContainer
;
const
nodeIter
=
/** @type {Document} */
(
root
.
ownerDocument
).
createNodeIterator
(
root
,
NodeFilter
.
SHOW_ALL
);
const
nodeIter
=
/** @type {Document} */
(
root
.
ownerDocument
).
createNodeIterator
(
root
,
NodeFilter
.
SHOW_ALL
);
let
currentNode
;
while
((
currentNode
=
nodeIter
.
nextNode
()))
{
...
...
src/annotator/sidebar.js
View file @
94b4b245
...
...
@@ -210,12 +210,13 @@ export default class Sidebar {
// Sidebar listens to the `openNotebook` event coming from the sidebar's
// iframe and re-publishes it via the emitter to the Notebook
this
.
guest
.
crossframe
.
on
(
'openNotebook'
,
(
/** @type {string} */
groupId
)
=>
{
this
.
hide
();
this
.
_emitter
.
publish
(
'openNotebook'
,
groupId
);
});
this
.
guest
.
crossframe
.
on
(
'openNotebook'
,
(
/** @type {string} */
groupId
)
=>
{
this
.
hide
();
this
.
_emitter
.
publish
(
'openNotebook'
,
groupId
);
}
);
this
.
_emitter
.
subscribe
(
'closeNotebook'
,
()
=>
{
this
.
show
();
});
...
...
@@ -296,8 +297,9 @@ export default class Sidebar {
// its container.
const
toolbarWidth
=
(
this
.
iframeContainer
&&
this
.
toolbar
.
getWidth
())
||
0
;
const
frame
=
/** @type {HTMLElement} */
(
this
.
iframeContainer
??
this
.
externalFrame
);
const
frame
=
/** @type {HTMLElement} */
(
this
.
iframeContainer
??
this
.
externalFrame
);
const
rect
=
frame
.
getBoundingClientRect
();
const
computedStyle
=
window
.
getComputedStyle
(
frame
);
const
width
=
parseInt
(
computedStyle
.
width
);
...
...
src/annotator/test/integration/multi-frame-test.js
View file @
94b4b245
...
...
@@ -120,9 +120,8 @@ describe('CrossFrame multi-frame scenario', function () {
return
new
Promise
(
function
(
resolve
)
{
isLoaded
(
frame
,
function
()
{
const
scriptElement
=
frame
.
contentDocument
.
querySelector
(
'script[src]'
);
const
scriptElement
=
frame
.
contentDocument
.
querySelector
(
'script[src]'
);
assert
(
scriptElement
,
'expected embed script to be injected'
);
assert
.
equal
(
scriptElement
.
src
,
...
...
@@ -144,9 +143,8 @@ describe('CrossFrame multi-frame scenario', function () {
return
new
Promise
(
function
(
resolve
)
{
isLoaded
(
frame
,
function
()
{
const
scriptElement
=
frame
.
contentDocument
.
querySelector
(
'script[src]'
);
const
scriptElement
=
frame
.
contentDocument
.
querySelector
(
'script[src]'
);
assert
.
isNull
(
scriptElement
,
'expected embed script to not be injected'
...
...
src/annotator/util/shadow-root.js
View file @
94b4b245
...
...
@@ -2,9 +2,11 @@
* Load stylesheets for annotator UI components into the shadow DOM root.
*/
function
loadStyles
(
shadowRoot
)
{
const
url
=
/** @type {HTMLLinkElement|undefined} */
(
document
.
querySelector
(
'link[rel="stylesheet"][href*="/build/styles/annotator.css"]'
))?.
href
;
const
url
=
/** @type {HTMLLinkElement|undefined} */
(
document
.
querySelector
(
'link[rel="stylesheet"][href*="/build/styles/annotator.css"]'
)
)?.
href
;
if
(
!
url
)
{
return
;
...
...
src/boot/url-template.js
View file @
94b4b245
...
...
@@ -14,7 +14,9 @@ function extractOrigin(url) {
}
function
currentScriptOrigin
(
document_
=
document
)
{
const
scriptEl
=
/** @type {HTMLScriptElement|null} */
(
document_
.
currentScript
);
const
scriptEl
=
/** @type {HTMLScriptElement|null} */
(
document_
.
currentScript
);
if
(
!
scriptEl
)
{
// Function was called outside of initial script execution.
return
null
;
...
...
src/shared/components/Dialog.js
View file @
94b4b245
...
...
@@ -88,7 +88,9 @@ export default function Dialog({
});
useEffect
(()
=>
{
const
focusEl
=
/** @type {InputElement|undefined} */
(
initialFocus
?.
current
);
const
focusEl
=
/** @type {InputElement|undefined} */
(
initialFocus
?.
current
);
if
(
focusEl
&&
!
focusEl
.
disabled
)
{
focusEl
.
focus
();
}
else
{
...
...
src/sidebar/components/Annotation/AnnotationTimestamps.js
View file @
94b4b245
...
...
@@ -37,9 +37,10 @@ export default function AnnotationTimestamps({
})
{
// "Current" time, used when calculating the relative age of `timestamp`.
const
[
now
,
setNow
]
=
useState
(()
=>
new
Date
());
const
createdDate
=
useMemo
(()
=>
new
Date
(
annotationCreated
),
[
annotationCreated
,
]);
const
createdDate
=
useMemo
(
()
=>
new
Date
(
annotationCreated
),
[
annotationCreated
]
);
const
updatedDate
=
useMemo
(
()
=>
withEditedTimestamp
&&
new
Date
(
annotationUpdated
),
[
annotationUpdated
,
withEditedTimestamp
]
...
...
src/sidebar/components/Excerpt.js
View file @
94b4b245
...
...
@@ -83,9 +83,8 @@ function Excerpt({
overflowThreshold
=
0
,
settings
=
{},
})
{
const
[
collapsedByInlineControls
,
setCollapsedByInlineControls
]
=
useState
(
true
);
const
[
collapsedByInlineControls
,
setCollapsedByInlineControls
]
=
useState
(
true
);
// Container for the excerpt's content.
const
contentElement
=
useRef
(
/** @type {HTMLDivElement|null} */
(
null
));
...
...
src/sidebar/components/GroupList/GroupList.js
View file @
94b4b245
...
...
@@ -46,9 +46,10 @@ function GroupList({ settings }) {
const
focusedGroup
=
store
.
focusedGroup
();
const
userid
=
store
.
profile
().
userid
;
const
myGroupsSorted
=
useMemo
(()
=>
groupsByOrganization
(
myGroups
),
[
myGroups
,
]);
const
myGroupsSorted
=
useMemo
(
()
=>
groupsByOrganization
(
myGroups
),
[
myGroups
]
);
const
featuredGroupsSorted
=
useMemo
(
()
=>
groupsByOrganization
(
featuredGroups
),
...
...
src/sidebar/components/HelpPanel.js
View file @
94b4b245
...
...
@@ -59,8 +59,8 @@ function HelpPanel({ auth, session }) {
// auto-open triggering of this panel is owned by the `HypothesisApp` component.
// This reference is such that we know whether we should "dismiss" the tutorial
// (permanently for this user) when it is closed.
const
hasAutoDisplayPreference
=
!!
store
.
profile
().
preferences
.
show_sidebar_tutorial
;
const
hasAutoDisplayPreference
=
!!
store
.
profile
().
preferences
.
show_sidebar_tutorial
;
// The "Tutorial" (getting started) subpanel is the default panel shown
const
[
activeSubPanel
,
setActiveSubPanel
]
=
useState
(
'tutorial'
);
...
...
src/sidebar/components/MarkdownView.js
View file @
94b4b245
...
...
@@ -24,9 +24,10 @@ export default function MarkdownView({
textClass
=
{},
textStyle
=
{},
})
{
const
html
=
useMemo
(()
=>
(
markdown
?
renderMarkdown
(
markdown
)
:
''
),
[
markdown
,
]);
const
html
=
useMemo
(
()
=>
(
markdown
?
renderMarkdown
(
markdown
)
:
''
),
[
markdown
]
);
const
content
=
useRef
(
/** @type {HTMLDivElement|null} */
(
null
));
useEffect
(()
=>
{
...
...
src/sidebar/components/NotebookView.js
View file @
94b4b245
...
...
@@ -50,9 +50,8 @@ function NotebookView({ loadAnnotationsService, streamer }) {
const
lastPaginationPage
=
useRef
(
1
);
const
[
paginationPage
,
setPaginationPage
]
=
useState
(
1
);
const
[
hasTooManyAnnotationsError
,
setHasTooManyAnnotationsError
]
=
useState
(
false
);
const
[
hasTooManyAnnotationsError
,
setHasTooManyAnnotationsError
]
=
useState
(
false
);
// Load all annotations in the group, unless there are more than 5000
// of them: this is a performance safety valve.
...
...
src/sidebar/components/ThreadList.js
View file @
94b4b245
...
...
@@ -76,20 +76,17 @@ function ThreadList({ threads }) {
const
topLevelThreads
=
threads
;
const
{
offscreenLowerHeight
,
offscreenUpperHeight
,
visibleThreads
,
}
=
useMemo
(
()
=>
calculateVisibleThreads
(
topLevelThreads
,
threadHeights
,
scrollPosition
,
scrollContainerHeight
),
[
topLevelThreads
,
threadHeights
,
scrollPosition
,
scrollContainerHeight
]
);
const
{
offscreenLowerHeight
,
offscreenUpperHeight
,
visibleThreads
}
=
useMemo
(
()
=>
calculateVisibleThreads
(
topLevelThreads
,
threadHeights
,
scrollPosition
,
scrollContainerHeight
),
[
topLevelThreads
,
threadHeights
,
scrollPosition
,
scrollContainerHeight
]
);
const
store
=
useStoreProxy
();
...
...
@@ -176,9 +173,9 @@ function ThreadList({ threads }) {
setThreadHeights
(
prevHeights
=>
{
const
changedHeights
=
{};
for
(
let
{
id
}
of
visibleThreads
)
{
const
threadElement
=
/** @type {HTMLElement} */
(
document
.
getElementById
(
id
)
)
;
const
threadElement
=
/** @type {HTMLElement} */
(
document
.
getElementById
(
id
)
);
const
height
=
getElementHeightWithMargins
(
threadElement
);
if
(
height
!==
prevHeights
[
id
])
{
changedHeights
[
id
]
=
height
;
...
...
src/sidebar/components/test/ShareAnnotationsPanel-test.js
View file @
94b4b245
...
...
@@ -104,17 +104,20 @@ describe('ShareAnnotationsPanel', () => {
{
groupType
:
'private'
,
introPattern
:
/Use this link.*with other group members/
,
visibilityPattern
:
/Annotations in the private group.*are only visible to group members/
,
visibilityPattern
:
/Annotations in the private group.*are only visible to group members/
,
},
{
groupType
:
'restricted'
,
introPattern
:
/Use this link to share these annotations with anyone/
,
visibilityPattern
:
/Anyone using this link may view the annotations in the group/
,
visibilityPattern
:
/Anyone using this link may view the annotations in the group/
,
},
{
groupType
:
'open'
,
introPattern
:
/Use this link to share these annotations with anyone/
,
visibilityPattern
:
/Anyone using this link may view the annotations in the group/
,
visibilityPattern
:
/Anyone using this link may view the annotations in the group/
,
},
].
forEach
(
testCase
=>
{
it
(
'it displays appropriate help text depending on group type'
,
()
=>
{
...
...
src/sidebar/components/test/UserMenu-test.js
View file @
94b4b245
...
...
@@ -242,15 +242,13 @@ describe('UserMenu', () => {
expected
:
true
,
},
{
it
:
'should be present for first-party user if service supports `onLogoutRequest`'
,
it
:
'should be present for first-party user if service supports `onLogoutRequest`'
,
isThirdParty
:
false
,
serviceConfigReturns
:
{
onLogoutRequestProvided
:
true
},
expected
:
true
,
},
{
it
:
'should be present for first-party user if service does not support `onLogoutRequest`'
,
it
:
'should be present for first-party user if service does not support `onLogoutRequest`'
,
isThirdParty
:
false
,
serviceConfigReturns
:
{
onLogoutRequestProvided
:
false
},
expected
:
true
,
...
...
@@ -262,15 +260,13 @@ describe('UserMenu', () => {
expected
:
false
,
},
{
it
:
'should be present for third-party user if service supports `onLogoutRequest`'
,
it
:
'should be present for third-party user if service supports `onLogoutRequest`'
,
isThirdParty
:
true
,
serviceConfigReturns
:
{
onLogoutRequestProvided
:
true
},
expected
:
true
,
},
{
it
:
'should be absent for third-party user if `onLogoutRequest` not supported'
,
it
:
'should be absent for third-party user if `onLogoutRequest` not supported'
,
isThirdParty
:
true
,
serviceConfigReturns
:
{
onLogoutRequestProvided
:
false
},
expected
:
false
,
...
...
src/sidebar/index.js
View file @
94b4b245
...
...
@@ -12,9 +12,9 @@ import { fetchConfig } from './config/fetch-config';
import
*
as
sentry
from
'./util/sentry'
;
// Read settings rendered into sidebar app HTML by service/extension.
const
appConfig
=
/** @type {import('../types/config').SidebarConfig} */
(
parseJsonConfig
(
document
)
)
;
const
appConfig
=
/** @type {import('../types/config').SidebarConfig} */
(
parseJsonConfig
(
document
)
);
if
(
appConfig
.
sentry
)
{
// Initialize Sentry. This is required at the top of this file
...
...
@@ -189,9 +189,9 @@ function startApp(config, appEl) {
);
}
const
appEl
=
/** @type {HTMLElement} */
(
document
.
querySelector
(
'hypothesis-app'
)
)
;
const
appEl
=
/** @type {HTMLElement} */
(
document
.
querySelector
(
'hypothesis-app'
)
);
// Start capturing RPC requests before we start the RPC server (startRPCServer)
preStartRPCServer
();
...
...
src/sidebar/services/test/annotations-test.js
View file @
94b4b245
...
...
@@ -410,8 +410,8 @@ describe('AnnotationsService', () => {
});
return
svc
.
save
(
fixtures
.
defaultAnnotation
()).
then
(()
=>
{
const
annotationWithChanges
=
fakeApi
.
annotation
.
create
.
getCall
(
0
)
.
args
[
1
];
const
annotationWithChanges
=
fakeApi
.
annotation
.
create
.
getCall
(
0
)
.
args
[
1
];
assert
.
equal
(
annotationWithChanges
.
text
,
'my text'
);
assert
.
sameMembers
(
annotationWithChanges
.
tags
,
[
'one'
,
'two'
]);
// Permissions converted to "private"
...
...
@@ -433,8 +433,8 @@ describe('AnnotationsService', () => {
fakeApi
.
annotation
.
update
.
resolves
(
fixtures
.
defaultAnnotation
());
return
svc
.
save
(
annotation
).
then
(()
=>
{
const
savedAnnotation
=
fakeStore
.
addAnnotations
.
getCall
(
0
)
.
args
[
0
][
0
];
const
savedAnnotation
=
fakeStore
.
addAnnotations
.
getCall
(
0
)
.
args
[
0
][
0
];
assert
.
equal
(
savedAnnotation
.
$tag
,
'mytag'
);
assert
.
equal
(
savedAnnotation
.
$foo
,
'bar'
);
});
...
...
src/sidebar/store/index.js
View file @
94b4b245
...
...
@@ -106,9 +106,7 @@ export default function store(settings) {
toastMessages
,
viewer
,
];
return
/** @type {SidebarStore} */
(
createStore
(
modules
,
[
settings
],
middleware
));
return
/** @type {SidebarStore} */
(
createStore
(
modules
,
[
settings
],
middleware
)
);
}
src/sidebar/store/modules/activity.js
View file @
94b4b245
...
...
@@ -61,9 +61,8 @@ const update = {
)
{
addToStarted
.
push
(
action
.
annotation
.
$tag
);
}
const
updatedSaves
=
state
.
activeAnnotationSaveRequests
.
concat
(
addToStarted
);
const
updatedSaves
=
state
.
activeAnnotationSaveRequests
.
concat
(
addToStarted
);
return
{
...
state
,
activeAnnotationSaveRequests
:
updatedSaves
,
...
...
src/sidebar/store/modules/test/activity-test.js
View file @
94b4b245
...
...
@@ -143,8 +143,8 @@ describe('sidebar/store/modules/activity', () => {
store
.
annotationSaveFinished
({
$tag
:
'seven'
});
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
assert
.
lengthOf
(
annotationsBeingSaved
,
1
);
assert
.
deepEqual
(
annotationsBeingSaved
,
[
'nine'
]);
...
...
@@ -155,8 +155,8 @@ describe('sidebar/store/modules/activity', () => {
store
.
annotationSaveFinished
({});
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
assert
.
lengthOf
(
annotationsBeingSaved
,
1
);
assert
.
deepEqual
(
annotationsBeingSaved
,
[
'nine'
]);
...
...
@@ -168,8 +168,8 @@ describe('sidebar/store/modules/activity', () => {
store
.
annotationSaveFinished
({
$tag
:
'four'
});
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
assert
.
lengthOf
(
annotationsBeingSaved
,
1
);
assert
.
deepEqual
(
annotationsBeingSaved
,
[
'nine'
]);
...
...
@@ -180,8 +180,8 @@ describe('sidebar/store/modules/activity', () => {
it
(
'adds annotation `$tag` to list of saving annotations'
,
()
=>
{
store
.
annotationSaveStarted
({
$tag
:
'five'
});
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
assert
.
lengthOf
(
annotationsBeingSaved
,
1
);
assert
.
deepEqual
(
annotationsBeingSaved
,
[
'five'
]);
...
...
@@ -191,8 +191,8 @@ describe('sidebar/store/modules/activity', () => {
store
.
annotationSaveStarted
({
$tag
:
'five'
});
store
.
annotationSaveStarted
({
$tag
:
'five'
});
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
assert
.
lengthOf
(
annotationsBeingSaved
,
1
);
assert
.
deepEqual
(
annotationsBeingSaved
,
[
'five'
]);
...
...
@@ -201,8 +201,8 @@ describe('sidebar/store/modules/activity', () => {
it
(
'does not add the annotation if it does not have a `$tag`'
,
()
=>
{
store
.
annotationSaveStarted
({});
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
const
annotationsBeingSaved
=
store
.
getState
().
activity
.
activeAnnotationSaveRequests
;
assert
.
lengthOf
(
annotationsBeingSaved
,
0
);
});
...
...
src/sidebar/util/test/sentry-test.js
View file @
94b4b245
...
...
@@ -32,8 +32,7 @@ describe('sidebar/util/sentry', () => {
fakeDocumentCurrentScript
=
sinon
.
stub
(
document
,
'currentScript'
);
fakeDocumentCurrentScript
.
get
(()
=>
({
src
:
'https://cdn.hypothes.is/hypothesis/1.123.0/build/scripts/sidebar.bundle.js'
,
src
:
'https://cdn.hypothes.is/hypothesis/1.123.0/build/scripts/sidebar.bundle.js'
,
}));
// Reset rate limiting counters.
...
...
src/sidebar/util/unicode.js
View file @
94b4b245
...
...
@@ -7,7 +7,8 @@
// be valid.
//
// eslint-disable-next-line no-misleading-character-class
const
COMBINING_MARKS
=
/
[\u
0300-
\u
036F
\u
0483-
\u
0489
\u
0591-
\u
05BD
\u
05BF
\u
05C1
\u
05C2
\u
05C4
\u
05C5
\u
05C7
\u
0610-
\u
061A
\u
064B-
\u
065F
\u
0670
\u
06D6-
\u
06DC
\u
06DF-
\u
06E4
\u
06E7
\u
06E8
\u
06EA-
\u
06ED
\u
0711
\u
0730-
\u
074A
\u
07A6-
\u
07B0
\u
07EB-
\u
07F3
\u
0816-
\u
0819
\u
081B-
\u
0823
\u
0825-
\u
0827
\u
0829-
\u
082D
\u
0859-
\u
085B
\u
08E4-
\u
08FE
\u
0900-
\u
0903
\u
093A-
\u
093C
\u
093E-
\u
094F
\u
0951-
\u
0957
\u
0962
\u
0963
\u
0981-
\u
0983
\u
09BC
\u
09BE-
\u
09C4
\u
09C7
\u
09C8
\u
09CB-
\u
09CD
\u
09D7
\u
09E2
\u
09E3
\u
0A01-
\u
0A03
\u
0A3C
\u
0A3E-
\u
0A42
\u
0A47
\u
0A48
\u
0A4B-
\u
0A4D
\u
0A51
\u
0A70
\u
0A71
\u
0A75
\u
0A81-
\u
0A83
\u
0ABC
\u
0ABE-
\u
0AC5
\u
0AC7-
\u
0AC9
\u
0ACB-
\u
0ACD
\u
0AE2
\u
0AE3
\u
0B01-
\u
0B03
\u
0B3C
\u
0B3E-
\u
0B44
\u
0B47
\u
0B48
\u
0B4B-
\u
0B4D
\u
0B56
\u
0B57
\u
0B62
\u
0B63
\u
0B82
\u
0BBE-
\u
0BC2
\u
0BC6-
\u
0BC8
\u
0BCA-
\u
0BCD
\u
0BD7
\u
0C01-
\u
0C03
\u
0C3E-
\u
0C44
\u
0C46-
\u
0C48
\u
0C4A-
\u
0C4D
\u
0C55
\u
0C56
\u
0C62
\u
0C63
\u
0C82
\u
0C83
\u
0CBC
\u
0CBE-
\u
0CC4
\u
0CC6-
\u
0CC8
\u
0CCA-
\u
0CCD
\u
0CD5
\u
0CD6
\u
0CE2
\u
0CE3
\u
0D02
\u
0D03
\u
0D3E-
\u
0D44
\u
0D46-
\u
0D48
\u
0D4A-
\u
0D4D
\u
0D57
\u
0D62
\u
0D63
\u
0D82
\u
0D83
\u
0DCA
\u
0DCF-
\u
0DD4
\u
0DD6
\u
0DD8-
\u
0DDF
\u
0DF2
\u
0DF3
\u
0E31
\u
0E34-
\u
0E3A
\u
0E47-
\u
0E4E
\u
0EB1
\u
0EB4-
\u
0EB9
\u
0EBB
\u
0EBC
\u
0EC8-
\u
0ECD
\u
0F18
\u
0F19
\u
0F35
\u
0F37
\u
0F39
\u
0F3E
\u
0F3F
\u
0F71-
\u
0F84
\u
0F86
\u
0F87
\u
0F8D-
\u
0F97
\u
0F99-
\u
0FBC
\u
0FC6
\u
102B-
\u
103E
\u
1056-
\u
1059
\u
105E-
\u
1060
\u
1062-
\u
1064
\u
1067-
\u
106D
\u
1071-
\u
1074
\u
1082-
\u
108D
\u
108F
\u
109A-
\u
109D
\u
135D-
\u
135F
\u
1712-
\u
1714
\u
1732-
\u
1734
\u
1752
\u
1753
\u
1772
\u
1773
\u
17B4-
\u
17D3
\u
17DD
\u
180B-
\u
180D
\u
18A9
\u
1920-
\u
192B
\u
1930-
\u
193B
\u
19B0-
\u
19C0
\u
19C8
\u
19C9
\u
1A17-
\u
1A1B
\u
1A55-
\u
1A5E
\u
1A60-
\u
1A7C
\u
1A7F
\u
1B00-
\u
1B04
\u
1B34-
\u
1B44
\u
1B6B-
\u
1B73
\u
1B80-
\u
1B82
\u
1BA1-
\u
1BAD
\u
1BE6-
\u
1BF3
\u
1C24-
\u
1C37
\u
1CD0-
\u
1CD2
\u
1CD4-
\u
1CE8
\u
1CED
\u
1CF2-
\u
1CF4
\u
1DC0-
\u
1DE6
\u
1DFC-
\u
1DFF
\u
20D0-
\u
20F0
\u
2CEF-
\u
2CF1
\u
2D7F
\u
2DE0-
\u
2DFF
\u
302A-
\u
302F
\u
3099
\u
309A
\u
A66F-
\u
A672
\u
A674-
\u
A67D
\u
A69F
\u
A6F0
\u
A6F1
\u
A802
\u
A806
\u
A80B
\u
A823-
\u
A827
\u
A880
\u
A881
\u
A8B4-
\u
A8C4
\u
A8E0-
\u
A8F1
\u
A926-
\u
A92D
\u
A947-
\u
A953
\u
A980-
\u
A983
\u
A9B3-
\u
A9C0
\u
AA29-
\u
AA36
\u
AA43
\u
AA4C
\u
AA4D
\u
AA7B
\u
AAB0
\u
AAB2-
\u
AAB4
\u
AAB7
\u
AAB8
\u
AABE
\u
AABF
\u
AAC1
\u
AAEB-
\u
AAEF
\u
AAF5
\u
AAF6
\u
ABE3-
\u
ABEA
\u
ABEC
\u
ABED
\u
FB1E
\u
FE00-
\u
FE0F
\u
FE20-
\u
FE26
]
/g
;
const
COMBINING_MARKS
=
/
[\u
0300-
\u
036F
\u
0483-
\u
0489
\u
0591-
\u
05BD
\u
05BF
\u
05C1
\u
05C2
\u
05C4
\u
05C5
\u
05C7
\u
0610-
\u
061A
\u
064B-
\u
065F
\u
0670
\u
06D6-
\u
06DC
\u
06DF-
\u
06E4
\u
06E7
\u
06E8
\u
06EA-
\u
06ED
\u
0711
\u
0730-
\u
074A
\u
07A6-
\u
07B0
\u
07EB-
\u
07F3
\u
0816-
\u
0819
\u
081B-
\u
0823
\u
0825-
\u
0827
\u
0829-
\u
082D
\u
0859-
\u
085B
\u
08E4-
\u
08FE
\u
0900-
\u
0903
\u
093A-
\u
093C
\u
093E-
\u
094F
\u
0951-
\u
0957
\u
0962
\u
0963
\u
0981-
\u
0983
\u
09BC
\u
09BE-
\u
09C4
\u
09C7
\u
09C8
\u
09CB-
\u
09CD
\u
09D7
\u
09E2
\u
09E3
\u
0A01-
\u
0A03
\u
0A3C
\u
0A3E-
\u
0A42
\u
0A47
\u
0A48
\u
0A4B-
\u
0A4D
\u
0A51
\u
0A70
\u
0A71
\u
0A75
\u
0A81-
\u
0A83
\u
0ABC
\u
0ABE-
\u
0AC5
\u
0AC7-
\u
0AC9
\u
0ACB-
\u
0ACD
\u
0AE2
\u
0AE3
\u
0B01-
\u
0B03
\u
0B3C
\u
0B3E-
\u
0B44
\u
0B47
\u
0B48
\u
0B4B-
\u
0B4D
\u
0B56
\u
0B57
\u
0B62
\u
0B63
\u
0B82
\u
0BBE-
\u
0BC2
\u
0BC6-
\u
0BC8
\u
0BCA-
\u
0BCD
\u
0BD7
\u
0C01-
\u
0C03
\u
0C3E-
\u
0C44
\u
0C46-
\u
0C48
\u
0C4A-
\u
0C4D
\u
0C55
\u
0C56
\u
0C62
\u
0C63
\u
0C82
\u
0C83
\u
0CBC
\u
0CBE-
\u
0CC4
\u
0CC6-
\u
0CC8
\u
0CCA-
\u
0CCD
\u
0CD5
\u
0CD6
\u
0CE2
\u
0CE3
\u
0D02
\u
0D03
\u
0D3E-
\u
0D44
\u
0D46-
\u
0D48
\u
0D4A-
\u
0D4D
\u
0D57
\u
0D62
\u
0D63
\u
0D82
\u
0D83
\u
0DCA
\u
0DCF-
\u
0DD4
\u
0DD6
\u
0DD8-
\u
0DDF
\u
0DF2
\u
0DF3
\u
0E31
\u
0E34-
\u
0E3A
\u
0E47-
\u
0E4E
\u
0EB1
\u
0EB4-
\u
0EB9
\u
0EBB
\u
0EBC
\u
0EC8-
\u
0ECD
\u
0F18
\u
0F19
\u
0F35
\u
0F37
\u
0F39
\u
0F3E
\u
0F3F
\u
0F71-
\u
0F84
\u
0F86
\u
0F87
\u
0F8D-
\u
0F97
\u
0F99-
\u
0FBC
\u
0FC6
\u
102B-
\u
103E
\u
1056-
\u
1059
\u
105E-
\u
1060
\u
1062-
\u
1064
\u
1067-
\u
106D
\u
1071-
\u
1074
\u
1082-
\u
108D
\u
108F
\u
109A-
\u
109D
\u
135D-
\u
135F
\u
1712-
\u
1714
\u
1732-
\u
1734
\u
1752
\u
1753
\u
1772
\u
1773
\u
17B4-
\u
17D3
\u
17DD
\u
180B-
\u
180D
\u
18A9
\u
1920-
\u
192B
\u
1930-
\u
193B
\u
19B0-
\u
19C0
\u
19C8
\u
19C9
\u
1A17-
\u
1A1B
\u
1A55-
\u
1A5E
\u
1A60-
\u
1A7C
\u
1A7F
\u
1B00-
\u
1B04
\u
1B34-
\u
1B44
\u
1B6B-
\u
1B73
\u
1B80-
\u
1B82
\u
1BA1-
\u
1BAD
\u
1BE6-
\u
1BF3
\u
1C24-
\u
1C37
\u
1CD0-
\u
1CD2
\u
1CD4-
\u
1CE8
\u
1CED
\u
1CF2-
\u
1CF4
\u
1DC0-
\u
1DE6
\u
1DFC-
\u
1DFF
\u
20D0-
\u
20F0
\u
2CEF-
\u
2CF1
\u
2D7F
\u
2DE0-
\u
2DFF
\u
302A-
\u
302F
\u
3099
\u
309A
\u
A66F-
\u
A672
\u
A674-
\u
A67D
\u
A69F
\u
A6F0
\u
A6F1
\u
A802
\u
A806
\u
A80B
\u
A823-
\u
A827
\u
A880
\u
A881
\u
A8B4-
\u
A8C4
\u
A8E0-
\u
A8F1
\u
A926-
\u
A92D
\u
A947-
\u
A953
\u
A980-
\u
A983
\u
A9B3-
\u
A9C0
\u
AA29-
\u
AA36
\u
AA43
\u
AA4C
\u
AA4D
\u
AA7B
\u
AAB0
\u
AAB2-
\u
AAB4
\u
AAB7
\u
AAB8
\u
AABE
\u
AABF
\u
AAC1
\u
AAEB-
\u
AAEF
\u
AAF5
\u
AAF6
\u
ABE3-
\u
ABEA
\u
ABEC
\u
ABED
\u
FB1E
\u
FE00-
\u
FE0F
\u
FE20-
\u
FE26
]
/g
;
/**
* @param {string} str
...
...
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