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
c5063edf
Unverified
Commit
c5063edf
authored
May 06, 2020
by
Robert Knight
Committed by
GitHub
May 06, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2129 from hypothesis/fix-new-note-label
Fix "New annotation"/"New page note" label
parents
ff015542
801a9ee3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
12 deletions
+31
-12
guest.coffee
src/annotator/guest.coffee
+2
-2
guest-test.coffee
src/annotator/test/guest-test.coffee
+29
-10
No files found.
src/annotator/guest.coffee
View file @
c5063edf
...
...
@@ -425,7 +425,7 @@ module.exports = class Guest extends Delegator
return
@
selectedRanges
=
[
range
]
@
toolbar
?
.
newAnnotationType
=
'
note
'
@
toolbar
?
.
newAnnotationType
=
'
annotation
'
{
left
,
top
,
arrowDirection
}
=
this
.
adderCtrl
.
target
(
focusRect
,
isBackwards
)
this
.
adderCtrl
.
annotationsForSelection
=
annotationsForSelection
()
...
...
@@ -434,7 +434,7 @@ module.exports = class Guest extends Delegator
_onClearSelection
:
()
->
this
.
adderCtrl
.
hide
()
@
selectedRanges
=
[]
@
toolbar
?
.
newAnnotationType
=
'
annotation
'
@
toolbar
?
.
newAnnotationType
=
'
note
'
selectAnnotations
:
(
annotations
,
toggle
)
->
if
toggle
...
...
src/annotator/test/guest-test.coffee
View file @
c5063edf
...
...
@@ -348,35 +348,38 @@ describe 'Guest', ->
afterEach
->
container
.
remove
()
it
'shows the adder if the selection contains text'
,
->
guest
=
createGuest
()
simulateSelectionWithText
=
->
rangeUtil
.
selectionFocusRect
.
returns
({
left
:
0
,
top
:
0
,
width
:
5
,
height
:
5
})
FakeAdder
::
instance
.
target
.
returns
({
left
:
0
,
top
:
0
,
arrowDirection
:
adder
.
ARROW_POINTING_UP
})
selections
.
next
({})
simulateSelectionWithoutText
=
->
rangeUtil
.
selectionFocusRect
.
returns
(
null
)
selections
.
next
({})
it
'shows the adder if the selection contains text'
,
->
guest
=
createGuest
()
simulateSelectionWithText
()
assert
.
called
FakeAdder
::
instance
.
showAt
it
'sets the annotations associated with the selection'
,
->
guest
=
createGuest
()
ann
=
{}
$
(
container
).
data
(
'annotation'
,
ann
)
rangeUtil
.
selectionFocusRect
.
returns
({
left
:
0
,
top
:
0
,
width
:
5
,
height
:
5
})
FakeAdder
::
instance
.
target
.
returns
({
left
:
0
,
top
:
0
,
arrowDirection
:
adder
.
ARROW_POINTING_UP
})
rangeUtil
.
itemsForRange
.
callsFake
((
range
,
callback
)
->
[
callback
(
range
.
startContainer
)]
)
selections
.
next
({})
simulateSelectionWithText
()
assert
.
deepEqual
FakeAdder
::
instance
.
annotationsForSelection
,
[
ann
]
it
'hides the adder if the selection does not contain text'
,
->
guest
=
createGuest
()
rangeUtil
.
selectionFocusRect
.
returns
(
null
)
selections
.
next
({})
simulateSelectionWithoutText
()
assert
.
called
FakeAdder
::
instance
.
hide
assert
.
notCalled
FakeAdder
::
instance
.
showAt
...
...
@@ -385,6 +388,22 @@ describe 'Guest', ->
selections
.
next
(
null
)
assert
.
called
FakeAdder
::
instance
.
hide
it
"sets the toolbar's `newAnnotationType` to 'annotation' if there is a selection"
,
->
guest
=
createGuest
()
guest
.
toolbar
=
{}
simulateSelectionWithText
()
assert
.
equal
guest
.
toolbar
.
newAnnotationType
,
'annotation'
it
"sets the toolbar's `newAnnotationType` to 'note' if the selection is empty"
,
->
guest
=
createGuest
()
guest
.
toolbar
=
{}
simulateSelectionWithoutText
()
assert
.
equal
guest
.
toolbar
.
newAnnotationType
,
'note'
describe
'when adder toolbar buttons are clicked'
,
->
# TODO - Add tests for "Annotate" and "Highlight" buttons.
...
...
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