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
a28acdfc
Commit
a28acdfc
authored
Mar 28, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Mar 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate bucket-bar module to TypeScript
parent
5000c046
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
20 deletions
+18
-20
bucket-bar.tsx
src/annotator/bucket-bar.tsx
+18
-20
No files found.
src/annotator/bucket-bar.
js
→
src/annotator/bucket-bar.
tsx
View file @
a28acdfc
import
{
render
}
from
'preact'
;
import
type
{
AnchorPosition
,
Destroyable
}
from
'../types/annotator'
;
import
Buckets
from
'./components/Buckets'
;
import
{
computeBuckets
}
from
'./util/buckets'
;
/**
* @typedef {import('../types/annotator').AnchorPosition} AnchorPosition
* @typedef {import('../types/annotator').Destroyable} Destroyable
*/
export
type
BucketBarOptions
=
{
onFocusAnnotations
:
(
tags
:
string
[])
=>
void
;
onScrollToClosestOffScreenAnchor
:
(
tags
:
string
[],
direction
:
'down'
|
'up'
)
=>
void
;
onSelectAnnotations
:
(
tags
:
string
[],
toggle
:
boolean
)
=>
void
;
};
/**
* Controller for the "bucket bar" shown alongside the sidebar indicating where
* annotations are in the document.
*
* @implements {Destroyable}
*/
export
class
BucketBar
{
/**
* @param {HTMLElement} container
* @param {object} options
* @param {(tags: string[]) => void} options.onFocusAnnotations
* @param {(tags: string[], direction: 'down'|'up') => void} options.onScrollToClosestOffScreenAnchor
* @param {(tags: string[], toggle: boolean) => void} options.onSelectAnnotations
*/
export
class
BucketBar
implements
Destroyable
{
private
_bucketsContainer
:
HTMLDivElement
;
private
_onFocusAnnotations
:
BucketBarOptions
[
'onFocusAnnotations'
];
private
_onScrollToClosestOffScreenAnchor
:
BucketBarOptions
[
'onScrollToClosestOffScreenAnchor'
];
private
_onSelectAnnotations
:
BucketBarOptions
[
'onSelectAnnotations'
];
constructor
(
container
,
container
:
HTMLElement
,
{
onFocusAnnotations
,
onScrollToClosestOffScreenAnchor
,
onSelectAnnotations
,
}
}
:
BucketBarOptions
)
{
this
.
_bucketsContainer
=
document
.
createElement
(
'div'
);
container
.
appendChild
(
this
.
_bucketsContainer
);
...
...
@@ -46,10 +47,7 @@ export class BucketBar {
this
.
_bucketsContainer
.
remove
();
}
/**
* @param {AnchorPosition[]} positions
*/
update
(
positions
)
{
update
(
positions
:
AnchorPosition
[])
{
const
buckets
=
computeBuckets
(
positions
);
render
(
<
Buckets
...
...
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