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
e12b4735
Commit
e12b4735
authored
Nov 14, 2022
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Nov 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `AnnotationBody` to TS
parent
5ce4ac3b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
22 deletions
+21
-22
AnnotationBody.tsx
src/sidebar/components/Annotation/AnnotationBody.tsx
+21
-22
No files found.
src/sidebar/components/Annotation/AnnotationBody.
js
→
src/sidebar/components/Annotation/AnnotationBody.
tsx
View file @
e12b4735
...
...
@@ -6,6 +6,9 @@ import {
import
classnames
from
'classnames'
;
import
{
useMemo
,
useState
}
from
'preact/hooks'
;
import
type
{
Annotation
}
from
'../../../types/api'
;
import
type
{
SidebarSettings
}
from
'../../../types/config'
;
import
{
useSidebarStore
}
from
'../../store'
;
import
{
isThirdPartyUser
}
from
'../../helpers/account-id'
;
import
{
isHidden
}
from
'../../helpers/annotation-metadata'
;
...
...
@@ -17,20 +20,20 @@ import MarkdownView from '../MarkdownView';
import
TagList
from
'../TagList'
;
import
TagListItem
from
'../TagListItem'
;
/**
* @typedef {import("../../../types/api").Annotation} Annotation
* @typedef {import("../../../types/config").SidebarSettings} SidebarSettings
*/
type
ToggleExcerptButtonProps
=
{
classes
?:
string
;
setCollapsed
:
(
collapse
:
boolean
)
=>
void
;
collapsed
:
boolean
;
};
/**
* Button to expand or collapse the annotation excerpt (content)
*
* @param {object} props
* @param {string} [props.classes]
* @param {(collapse:boolean) => void} props.setCollapsed
* @param {boolean} props.collapsed
*/
function
ToggleExcerptButton
({
classes
,
setCollapsed
,
collapsed
})
{
function
ToggleExcerptButton
({
classes
,
setCollapsed
,
collapsed
,
}:
ToggleExcerptButtonProps
)
{
const
toggleText
=
collapsed
?
'More'
:
'Less'
;
return
(
<
Button
...
...
@@ -51,18 +54,17 @@ function ToggleExcerptButton({ classes, setCollapsed, collapsed }) {
);
}
/**
* @typedef AnnotationBodyProps
* @prop {Annotation} annotation - The annotation in question
* @prop {SidebarSettings} settings
*/
export
type
AnnotationBodyProps
=
{
annotation
:
Annotation
;
// injected
settings
:
SidebarSettings
;
};
/**
* Display the rendered content of an annotation.
*
* @param {AnnotationBodyProps} props
*/
function
AnnotationBody
({
annotation
,
settings
})
{
function
AnnotationBody
({
annotation
,
settings
}
:
AnnotationBodyProps
)
{
// Should the text content of `Excerpt` be rendered in a collapsed state,
// assuming it is collapsible (exceeds allotted collapsed space)?
const
[
collapsed
,
setCollapsed
]
=
useState
(
true
);
...
...
@@ -88,10 +90,7 @@ function AnnotationBody({ annotation, settings }) {
[
annotation
,
defaultAuthority
]
);
/**
* @param {string} tag
*/
const
createTagSearchURL
=
tag
=>
{
const
createTagSearchURL
=
(
tag
:
string
)
=>
{
return
store
.
getLink
(
'search.tag'
,
{
tag
});
};
...
...
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