add number of connected users
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<editor-content :editor="editor" />
|
<div>
|
||||||
|
<editor-content :editor="editor" />
|
||||||
|
|
||||||
|
<div class="collaboration-status">
|
||||||
|
{{ numberOfConnectedUsers }} user{{ numberOfConnectedUsers === 1 ? '' : 's' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -22,6 +28,7 @@ export default {
|
|||||||
ydoc: null,
|
ydoc: null,
|
||||||
provider: null,
|
provider: null,
|
||||||
type: null,
|
type: null,
|
||||||
|
numberOfConnectedUsers: 0,
|
||||||
editor: null,
|
editor: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -30,6 +37,9 @@ export default {
|
|||||||
this.ydoc = new Y.Doc()
|
this.ydoc = new Y.Doc()
|
||||||
this.provider = new WebrtcProvider('example', this.ydoc)
|
this.provider = new WebrtcProvider('example', this.ydoc)
|
||||||
this.type = this.ydoc.getXmlFragment('prosemirror')
|
this.type = this.ydoc.getXmlFragment('prosemirror')
|
||||||
|
this.provider.on('peers', ({ bcPeers, webrtcPeers }) => {
|
||||||
|
this.numberOfConnectedUsers = bcPeers.length + webrtcPeers.length
|
||||||
|
})
|
||||||
|
|
||||||
this.editor = new Editor({
|
this.editor = new Editor({
|
||||||
// TODO: This is added by every new user.
|
// TODO: This is added by every new user.
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
.collaboration-status {
|
||||||
|
background: #eee;
|
||||||
|
color: #666;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
margin-top: 1rem;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: ' ';
|
||||||
|
display: inline-block;
|
||||||
|
width: 0.5rem;
|
||||||
|
height: 0.5rem;
|
||||||
|
background: green;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* this is a rough fix for the first cursor position when the first paragraph is empty */
|
/* this is a rough fix for the first cursor position when the first paragraph is empty */
|
||||||
.ProseMirror > .collaboration-cursor:first-child {
|
.ProseMirror > .collaboration-cursor:first-child {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# Collaboration
|
# Collaboration
|
||||||
|
|
||||||
|
The content of this editor is shared with every users that opens that example.
|
||||||
|
|
||||||
<!-- <demo name="Examples/Collaboration" :show-source="false"/> -->
|
<!-- <demo name="Examples/Collaboration" :show-source="false"/> -->
|
||||||
|
|
||||||
<demo name="Examples/Collaboration" />
|
<demo name="Examples/Collaboration" />
|
||||||
|
|||||||
Reference in New Issue
Block a user