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
efcb285a
Commit
efcb285a
authored
Feb 21, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Feb 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate notebook.js module to TypeScript
parent
6de1f58a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
notebook.tsx
src/annotator/notebook.tsx
+40
-0
No files found.
src/annotator/notebook.
js
→
src/annotator/notebook.
tsx
View file @
efcb285a
import
{
render
}
from
'preact'
;
import
type
{
Destroyable
}
from
'../types/annotator'
;
import
NotebookModal
from
'./components/NotebookModal'
;
import
type
{
NotebookConfig
}
from
'./components/NotebookModal'
;
import
type
{
EventBus
}
from
'./util/emitter'
;
import
{
createShadowRoot
}
from
'./util/shadow-root'
;
/**
* @typedef {import('../types/annotator').Destroyable} Destroyable
* @typedef {import('./components/NotebookModal').NotebookConfig} NotebookConfig
*/
export
class
Notebook
implements
Destroyable
{
private
_outerContainer
:
HTMLElement
;
private
_shadowRoot
:
ShadowRoot
;
/** @implements {Destroyable} */
export
class
Notebook
{
/**
* @param {HTMLElement} element
* @param {import('./util/emitter').EventBus} eventBus -
* Enables communication between components sharing the same eventBus
* @param {NotebookConfig} config
* @param eventBus - Enables communication between components sharing the
* same eventBus
*/
constructor
(
element
,
eventBus
,
config
)
{
constructor
(
element
:
HTMLElement
,
eventBus
:
EventBus
,
config
:
NotebookConfig
)
{
/**
* Un-styled shadow host for the notebook content.
* This isolates the notebook from the page's styles.
*/
this
.
_outerContainer
=
document
.
createElement
(
'hypothesis-notebook'
);
element
.
appendChild
(
this
.
_outerContainer
);
this
.
shadowRoot
=
createShadowRoot
(
this
.
_outerContainer
);
this
.
_
shadowRoot
=
createShadowRoot
(
this
.
_outerContainer
);
render
(
<
NotebookModal
eventBus=
{
eventBus
}
config=
{
config
}
/>,
this
.
shadowRoot
this
.
_
shadowRoot
);
}
destroy
()
{
render
(
null
,
this
.
shadowRoot
);
render
(
null
,
this
.
_
shadowRoot
);
this
.
_outerContainer
.
remove
();
}
}
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