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
725f2c09
Commit
725f2c09
authored
Apr 20, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Apr 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate shadow-root module to TS
parent
702100ee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
11 deletions
+6
-11
shadow-root.ts
src/annotator/util/shadow-root.ts
+6
-11
No files found.
src/annotator/util/shadow-root.
j
s
→
src/annotator/util/shadow-root.
t
s
View file @
725f2c09
/**
/**
* Load stylesheets for annotator UI components into the shadow DOM root.
* Load stylesheets for annotator UI components into the shadow DOM root.
*
* @param {ShadowRoot} shadowRoot
*/
*/
function
loadStyles
(
shadowRoot
)
{
function
loadStyles
(
shadowRoot
:
ShadowRoot
)
{
// Find the preloaded stylesheet added by the boot script.
// Find the preloaded stylesheet added by the boot script.
const
url
=
/** @type {HTMLLinkElement|undefined} */
(
const
url
=
(
document
.
querySelector
(
document
.
querySelector
(
'link[rel="preload"][href*="/build/styles/annotator.css"]'
'link[rel="preload"][href*="/build/styles/annotator.css"]'
)
)
as
HTMLLinkElement
|
undefined
)?.
href
;
)?.
href
;
if
(
!
url
)
{
if
(
!
url
)
{
...
@@ -25,10 +23,9 @@ function loadStyles(shadowRoot) {
...
@@ -25,10 +23,9 @@ function loadStyles(shadowRoot) {
* Create the shadow root for an annotator UI component and load the annotator
* Create the shadow root for an annotator UI component and load the annotator
* CSS styles into it.
* CSS styles into it.
*
*
* @param {HTMLElement} container - Container element to render the UI into
* @param container - Container element to render the UI into
* @return {ShadowRoot}
*/
*/
export
function
createShadowRoot
(
container
)
{
export
function
createShadowRoot
(
container
:
HTMLElement
):
ShadowRoot
{
const
shadowRoot
=
container
.
attachShadow
({
mode
:
'open'
});
const
shadowRoot
=
container
.
attachShadow
({
mode
:
'open'
});
loadStyles
(
shadowRoot
);
loadStyles
(
shadowRoot
);
...
@@ -53,10 +50,8 @@ export function createShadowRoot(container) {
...
@@ -53,10 +50,8 @@ export function createShadowRoot(container) {
* Another benefit is that click and touchstart typically causes the sidebar to close.
* Another benefit is that click and touchstart typically causes the sidebar to close.
* By preventing the bubble up of these events, we don't have to individually stop
* By preventing the bubble up of these events, we don't have to individually stop
* the propagation.
* the propagation.
*
* @param {HTMLElement|ShadowRoot} element
*/
*/
function
stopEventPropagation
(
element
)
{
function
stopEventPropagation
(
element
:
HTMLElement
|
ShadowRoot
)
{
element
.
addEventListener
(
'mouseup'
,
event
=>
event
.
stopPropagation
());
element
.
addEventListener
(
'mouseup'
,
event
=>
event
.
stopPropagation
());
element
.
addEventListener
(
'mousedown'
,
event
=>
event
.
stopPropagation
());
element
.
addEventListener
(
'mousedown'
,
event
=>
event
.
stopPropagation
());
element
.
addEventListener
(
'touchstart'
,
event
=>
event
.
stopPropagation
(),
{
element
.
addEventListener
(
'touchstart'
,
event
=>
event
.
stopPropagation
(),
{
...
...
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