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
591c2338
Commit
591c2338
authored
Jan 08, 2020
by
Lyza Danger Gardner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update `AnnotationQuote` to use util for `isOrphan`, `quote`
parent
0d93b3a0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
55 deletions
+29
-55
annotation-quote.js
src/sidebar/components/annotation-quote.js
+9
-14
annotation.js
src/sidebar/components/annotation.js
+0
-7
annotation-quote-test.js
src/sidebar/components/test/annotation-quote-test.js
+18
-1
annotation-test.js
src/sidebar/components/test/annotation-test.js
+1
-29
annotation.html
src/sidebar/templates/annotation.html
+1
-4
No files found.
src/sidebar/components/annotation-quote.js
View file @
591c2338
...
@@ -2,17 +2,22 @@ const classnames = require('classnames');
...
@@ -2,17 +2,22 @@ const classnames = require('classnames');
const
{
createElement
}
=
require
(
'preact'
);
const
{
createElement
}
=
require
(
'preact'
);
const
propTypes
=
require
(
'prop-types'
);
const
propTypes
=
require
(
'prop-types'
);
const
{
isOrphan
,
quote
}
=
require
(
'../util/annotation-metadata'
);
const
{
withServices
}
=
require
(
'../util/service-context'
);
const
{
withServices
}
=
require
(
'../util/service-context'
);
const
{
applyTheme
}
=
require
(
'../util/theme'
);
const
{
applyTheme
}
=
require
(
'../util/theme'
);
const
Excerpt
=
require
(
'./excerpt'
);
const
Excerpt
=
require
(
'./excerpt'
);
/**
/**
* Display the selected text from the document associated with an annotation.
* Display the selected text from the document associated with an annotation.
*/
*/
function
AnnotationQuote
({
isOrphan
,
quote
,
settings
=
{}
})
{
function
AnnotationQuote
({
annotation
,
settings
=
{}
})
{
return
(
return
(
<
section
<
section
className
=
{
classnames
(
'annotation-quote'
,
isOrphan
&&
'is-orphan'
)}
className
=
{
classnames
(
'annotation-quote'
,
isOrphan
(
annotation
)
&&
'is-orphan'
)}
>
>
<
Excerpt
<
Excerpt
collapsedHeight
=
{
35
}
collapsedHeight
=
{
35
}
...
@@ -23,7 +28,7 @@ function AnnotationQuote({ isOrphan, quote, settings = {} }) {
...
@@ -23,7 +28,7 @@ function AnnotationQuote({ isOrphan, quote, settings = {} }) {
className
=
"annotation-quote__quote"
className
=
"annotation-quote__quote"
style
=
{
applyTheme
([
'selectionFontFamily'
],
settings
)}
style
=
{
applyTheme
([
'selectionFontFamily'
],
settings
)}
>
>
{
quote
}
{
quote
(
annotation
)
}
<
/blockquote
>
<
/blockquote
>
<
/Excerpt
>
<
/Excerpt
>
<
/section
>
<
/section
>
...
@@ -31,17 +36,7 @@ function AnnotationQuote({ isOrphan, quote, settings = {} }) {
...
@@ -31,17 +36,7 @@ function AnnotationQuote({ isOrphan, quote, settings = {} }) {
}
}
AnnotationQuote
.
propTypes
=
{
AnnotationQuote
.
propTypes
=
{
/**
annotation
:
propTypes
.
object
.
isRequired
,
* If `true`, display an indicator that the annotated text was not found in
* the current version of the document.
*/
isOrphan
:
propTypes
.
bool
,
/**
* The text that the annotation refers to. This is rendered as plain text
* (ie. HTML tags are rendered literally).
*/
quote
:
propTypes
.
string
,
// Used for theming.
// Used for theming.
settings
:
propTypes
.
object
,
settings
:
propTypes
.
object
,
...
...
src/sidebar/components/annotation.js
View file @
591c2338
...
@@ -377,13 +377,6 @@ function AnnotationController(
...
@@ -377,13 +377,6 @@ function AnnotationController(
});
});
};
};
this
.
isOrphan
=
function
()
{
if
(
typeof
self
.
annotation
.
$orphan
===
'undefined'
)
{
return
self
.
annotation
.
$anchorTimeout
;
}
return
self
.
annotation
.
$orphan
;
};
this
.
user
=
function
()
{
this
.
user
=
function
()
{
return
self
.
annotation
.
user
;
return
self
.
annotation
.
user
;
};
};
...
...
src/sidebar/components/test/annotation-quote-test.js
View file @
591c2338
...
@@ -6,14 +6,31 @@ const { $imports } = require('../annotation-quote');
...
@@ -6,14 +6,31 @@ const { $imports } = require('../annotation-quote');
const
mockImportedComponents
=
require
(
'./mock-imported-components'
);
const
mockImportedComponents
=
require
(
'./mock-imported-components'
);
describe
(
'AnnotationQuote'
,
()
=>
{
describe
(
'AnnotationQuote'
,
()
=>
{
let
fakeAnnotation
;
let
fakeIsOrphan
;
let
fakeQuote
;
function
createQuote
(
props
)
{
function
createQuote
(
props
)
{
return
mount
(
return
mount
(
<
AnnotationQuote
quote
=
"test quote"
settings
=
{{}}
{...
props
}
/
>
<
AnnotationQuote
annotation
=
{
fakeAnnotation
}
settings
=
{{}}
{...
props
}
/
>
);
);
}
}
beforeEach
(()
=>
{
beforeEach
(()
=>
{
fakeAnnotation
=
{
target
:
[],
};
fakeQuote
=
sinon
.
stub
().
returns
(
'test quote'
);
fakeIsOrphan
=
sinon
.
stub
();
$imports
.
$mock
(
mockImportedComponents
());
$imports
.
$mock
(
mockImportedComponents
());
$imports
.
$mock
({
'../util/annotation-metadata'
:
{
quote
:
fakeQuote
,
isOrphan
:
fakeIsOrphan
,
},
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
src/sidebar/components/test/annotation-test.js
View file @
591c2338
...
@@ -137,8 +137,7 @@ describe('annotation', function() {
...
@@ -137,8 +137,7 @@ describe('annotation', function() {
})
})
.
component
(
'annotationQuote'
,
{
.
component
(
'annotationQuote'
,
{
bindings
:
{
bindings
:
{
isOrphan
:
'<'
,
annotation
:
'<'
,
quote
:
'<'
,
},
},
});
});
});
});
...
@@ -682,33 +681,6 @@ describe('annotation', function() {
...
@@ -682,33 +681,6 @@ describe('annotation', function() {
});
});
});
});
describe
(
'#isOrphan'
,
function
()
{
it
(
'returns false if the annotation is not an orphan'
,
function
()
{
const
controller
=
createDirective
().
controller
;
controller
.
annotation
.
$orphan
=
false
;
assert
.
isFalse
(
controller
.
isOrphan
());
});
it
(
'returns true if the annotation is an orphan'
,
function
()
{
const
controller
=
createDirective
().
controller
;
controller
.
annotation
.
$orphan
=
true
;
assert
.
isTrue
(
controller
.
isOrphan
());
});
it
(
'returns true if the anchoring timeout expired'
,
function
()
{
const
controller
=
createDirective
().
controller
;
controller
.
annotation
.
$anchorTimeout
=
true
;
assert
.
isTrue
(
controller
.
isOrphan
());
});
it
(
'returns false if the anchoring timeout expired but anchoring did complete'
,
function
()
{
const
controller
=
createDirective
().
controller
;
controller
.
annotation
.
$orphan
=
false
;
controller
.
annotation
.
$anchorTimeout
=
true
;
assert
.
isFalse
(
controller
.
isOrphan
());
});
});
describe
(
'#shouldShowLicense'
,
function
()
{
describe
(
'#shouldShowLicense'
,
function
()
{
[
[
{
{
...
...
src/sidebar/templates/annotation.html
View file @
591c2338
...
@@ -12,10 +12,7 @@
...
@@ -12,10 +12,7 @@
show-document-info=
"vm.showDocumentInfo"
>
show-document-info=
"vm.showDocumentInfo"
>
</annotation-header>
</annotation-header>
<annotation-quote
<annotation-quote
annotation=
"vm.annotation"
ng-if=
"vm.quote()"
>
quote=
"vm.quote()"
is-orphan=
"vm.isOrphan()"
ng-if=
"vm.quote()"
>
</annotation-quote>
</annotation-quote>
<annotation-body
<annotation-body
...
...
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