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
68b55c2b
Commit
68b55c2b
authored
Nov 22, 2021
by
Eduardo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Rename bridge to contain the frame target"
This reverts commit
520b5c50
.
parent
520b5c50
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
annotation-sync.js
src/annotator/annotation-sync.js
+7
-7
guest.js
src/annotator/guest.js
+13
-13
No files found.
src/annotator/annotation-sync.js
View file @
68b55c2b
...
...
@@ -28,11 +28,11 @@
export
class
AnnotationSync
{
/**
* @param {EventBus} eventBus - Event bus for communicating with the annotator code (eg. the Guest)
* @param {SidebarBridge}
sidebarRPC
- Channel for communicating with the sidebar
* @param {SidebarBridge}
bridge
- Channel for communicating with the sidebar
*/
constructor
(
eventBus
,
sidebarRPC
)
{
constructor
(
eventBus
,
bridge
)
{
this
.
_emitter
=
eventBus
.
createEmitter
();
this
.
_sidebar
RPC
=
sidebarRPC
;
this
.
_sidebar
=
bridge
;
/**
* Mapping from annotation tags to annotation objects for annotations which
...
...
@@ -45,7 +45,7 @@ export class AnnotationSync {
this
.
destroyed
=
false
;
// Relay events from the sidebar to the rest of the annotator.
this
.
_sidebar
RPC
.
on
(
'deleteAnnotation'
,
(
body
,
callback
)
=>
{
this
.
_sidebar
.
on
(
'deleteAnnotation'
,
(
body
,
callback
)
=>
{
if
(
this
.
destroyed
)
{
callback
(
null
);
return
;
...
...
@@ -57,7 +57,7 @@ export class AnnotationSync {
callback
(
null
);
});
this
.
_sidebar
RPC
.
on
(
'loadAnnotations'
,
(
bodies
,
callback
)
=>
{
this
.
_sidebar
.
on
(
'loadAnnotations'
,
(
bodies
,
callback
)
=>
{
if
(
this
.
destroyed
)
{
callback
(
null
);
return
;
...
...
@@ -72,7 +72,7 @@ export class AnnotationSync {
if
(
annotation
.
$tag
)
{
return
;
}
this
.
_sidebar
RPC
.
call
(
'createAnnotation'
,
this
.
_format
(
annotation
));
this
.
_sidebar
.
call
(
'createAnnotation'
,
this
.
_format
(
annotation
));
});
}
...
...
@@ -89,7 +89,7 @@ export class AnnotationSync {
return
;
}
this
.
_sidebar
RPC
.
call
(
this
.
_sidebar
.
call
(
'syncAnchoringStatus'
,
annotations
.
map
(
ann
=>
this
.
_format
(
ann
))
);
...
...
src/annotator/guest.js
View file @
68b55c2b
...
...
@@ -177,12 +177,12 @@ export default class Guest {
*
* @type {Bridge<GuestToSidebarEvent,SidebarToGuestEvent>}
*/
this
.
_
sidebarRPC
=
new
Bridge
();
this
.
_
bridge
=
new
Bridge
();
this
.
_connectSidebarEvents
();
// Set up listeners for when the sidebar asks us to add or remove annotations
// in this frame.
this
.
_annotationSync
=
new
AnnotationSync
(
eventBus
,
this
.
_
sidebarRPC
);
this
.
_annotationSync
=
new
AnnotationSync
(
eventBus
,
this
.
_
bridge
);
this
.
_connectAnnotationSync
();
// Set up automatic and integration-triggered injection of client into
...
...
@@ -229,7 +229,7 @@ export default class Guest {
// Don't hide the sidebar if the event comes from an element that contains a highlight
return
;
}
this
.
_
sidebarRPC
.
call
(
'closeSidebar'
);
this
.
_
bridge
.
call
(
'closeSidebar'
);
};
this
.
_listeners
.
add
(
this
.
element
,
'mouseup'
,
event
=>
{
...
...
@@ -318,7 +318,7 @@ export default class Guest {
async
_connectSidebarEvents
()
{
// Handlers for events sent when user hovers or clicks on an annotation card
// in the sidebar.
this
.
_
sidebarRPC
.
on
(
'focusAnnotations'
,
(
tags
=
[])
=>
{
this
.
_
bridge
.
on
(
'focusAnnotations'
,
(
tags
=
[])
=>
{
this
.
_focusedAnnotations
.
clear
();
tags
.
forEach
(
tag
=>
this
.
_focusedAnnotations
.
add
(
tag
));
...
...
@@ -330,7 +330,7 @@ export default class Guest {
}
});
this
.
_
sidebarRPC
.
on
(
'scrollToAnnotation'
,
tag
=>
{
this
.
_
bridge
.
on
(
'scrollToAnnotation'
,
tag
=>
{
const
anchor
=
this
.
anchors
.
find
(
a
=>
a
.
annotation
.
$tag
===
tag
);
if
(
!
anchor
?.
highlights
)
{
return
;
...
...
@@ -356,21 +356,21 @@ export default class Guest {
});
// Handler for when sidebar requests metadata for the current document
this
.
_
sidebarRPC
.
on
(
'getDocumentInfo'
,
cb
=>
{
this
.
_
bridge
.
on
(
'getDocumentInfo'
,
cb
=>
{
this
.
getDocumentInfo
()
.
then
(
info
=>
cb
(
null
,
info
))
.
catch
(
reason
=>
cb
(
reason
));
});
// Handler for controls on the sidebar
this
.
_
sidebarRPC
.
on
(
'setHighlightsVisible'
,
showHighlights
=>
{
this
.
_
bridge
.
on
(
'setHighlightsVisible'
,
showHighlights
=>
{
this
.
setHighlightsVisible
(
showHighlights
);
});
// Discover and connect to the sidebar frame. All RPC events must be
// registered before creating the channel.
const
sidebarPort
=
await
this
.
_portFinder
.
discover
(
'sidebar'
);
this
.
_
sidebarRPC
.
createChannel
(
sidebarPort
);
this
.
_
bridge
.
createChannel
(
sidebarPort
);
}
destroy
()
{
...
...
@@ -387,7 +387,7 @@ export default class Guest {
this
.
_integration
.
destroy
();
this
.
_emitter
.
destroy
();
this
.
_annotationSync
.
destroy
();
this
.
_
sidebarRPC
.
destroy
();
this
.
_
bridge
.
destroy
();
}
/**
...
...
@@ -585,7 +585,7 @@ export default class Guest {
*/
_focusAnnotations
(
annotations
)
{
const
tags
=
annotations
.
map
(
a
=>
a
.
$tag
);
this
.
_
sidebarRPC
.
call
(
'focusAnnotations'
,
tags
);
this
.
_
bridge
.
call
(
'focusAnnotations'
,
tags
);
}
/**
...
...
@@ -636,11 +636,11 @@ export default class Guest {
selectAnnotations
(
annotations
,
toggle
=
false
)
{
const
tags
=
annotations
.
map
(
a
=>
a
.
$tag
);
if
(
toggle
)
{
this
.
_
sidebarRPC
.
call
(
'toggleAnnotationSelection'
,
tags
);
this
.
_
bridge
.
call
(
'toggleAnnotationSelection'
,
tags
);
}
else
{
this
.
_
sidebarRPC
.
call
(
'showAnnotations'
,
tags
);
this
.
_
bridge
.
call
(
'showAnnotations'
,
tags
);
}
this
.
_
sidebarRPC
.
call
(
'openSidebar'
);
this
.
_
bridge
.
call
(
'openSidebar'
);
}
/**
...
...
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