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
25b19bcc
Commit
25b19bcc
authored
Jan 04, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Jan 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conditionally render tags in text exported annotations
parent
b43097e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
18 deletions
+37
-18
annotations-exporter.ts
src/sidebar/services/annotations-exporter.ts
+12
-6
annotations-exporter-test.js
src/sidebar/services/test/annotations-exporter-test.js
+25
-12
No files found.
src/sidebar/services/annotations-exporter.ts
View file @
25b19bcc
...
...
@@ -83,14 +83,20 @@ export class AnnotationsExporter {
const
annotationsText
=
annotations
.
map
((
annotation
,
index
)
=>
{
const
page
=
pageLabel
(
annotation
);
const
lines
=
[
annotation
.
created
,
annotation
.
text
,
extractUsername
(
annotation
),
`"
${
quote
(
annotation
)}
"`
,
annotation
.
tags
.
length
>
0
?
`Tags:
${
annotation
.
tags
.
join
(
', '
)}
`
:
undefined
,
page
?
`Page:
${
page
}
`
:
undefined
,
].
filter
(
Boolean
);
return
trimAndDedent
`
Annotation
${
index
+
1
}
:
${
annotation
.
created
}
${
annotation
.
text
}
${
extractUsername
(
annotation
)}
"
${
quote
(
annotation
)}
"
Tags:
${
annotation
.
tags
.
join
(
', '
)}
${
page
?
`Page:
${
page
}
`
:
''
}
`
;
${
lines
.
join
(
'
\
n'
)}
`
;
})
.
join
(
'
\
n
\
n'
);
...
...
src/sidebar/services/test/annotations-exporter-test.js
View file @
25b19bcc
...
...
@@ -65,6 +65,16 @@ describe('AnnotationsExporter', () => {
it
(
'generates text content with provided annotations'
,
()
=>
{
const
isoDate
=
baseAnnotation
.
created
;
const
targetWithPageSelector
=
page
=>
[
{
selector
:
[
{
type
:
'PageSelector'
,
label
:
`
${
page
}
`
,
},
],
},
];
const
annotations
=
[
baseAnnotation
,
baseAnnotation
,
...
...
@@ -76,16 +86,12 @@ describe('AnnotationsExporter', () => {
{
...
baseAnnotation
,
...
newReply
(),
target
:
[
{
selector
:
[
{
type
:
'PageSelector'
,
label
:
'23'
,
},
],
},
],
target
:
targetWithPageSelector
(
23
),
},
{
...
baseAnnotation
,
tags
:
[],
target
:
targetWithPageSelector
(
'iii'
),
},
];
const
groupName
=
'My group'
;
...
...
@@ -103,7 +109,7 @@ http://example.com
Group:
${
groupName
}
Total users: 2
Users: bill, jane
Total annotations:
4
Total annotations:
5
Total replies: 1
Annotation 1:
...
...
@@ -133,7 +139,14 @@ Annotation text
bill
"null"
Tags: tag_1, tag_2
Page: 23`
,
Page: 23
Annotation 5:
${
isoDate
}
Annotation text
bill
"null"
Page: iii`
,
);
});
...
...
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