Skip to content

Commit 84ba167

Browse files
committed
Current user indicators
1 parent 13623d6 commit 84ba167

3 files changed

Lines changed: 63 additions & 11 deletions

File tree

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
2121
<link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
22-
<title>Graphite Writer BETA v0.3.3 | Create Text Documents Online For Free</title>
22+
<title>Graphite Writer BETA v0.4.0 | Create Text Documents Online For Free</title>
2323
</head>
2424

2525
<body>

src/assets/editor.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
.ql-editor {
66
min-height: 100vh;
77
}
8+
.ql-font-roboto {
9+
font-family: "Roboto", sans-serif;
10+
}
811
#editor {
912
margin-bottom: 5%;
1013
}
@@ -62,7 +65,7 @@
6265
}
6366

6467
.input {
65-
margin-bottom: .5em;
68+
margin-bottom: 0.5em;
6669
}
6770

6871
.share-row {
@@ -76,7 +79,7 @@
7679
margin-bottom: 0;
7780
}
7881
.share-item {
79-
margin-top: .5em;
82+
margin-top: 0.5em;
8083
}
8184

8285
.ql-toolbar {
@@ -85,7 +88,7 @@
8588
border-top-left: 0.5px solid $gray-accent;
8689
border-top-left-radius: 3px;
8790
}
88-
91+
8992
.ql-container {
9093
border-bottom-right: 0.5px solid $gray-accent;
9194
border-bottom-right-radius: 3px;

src/components/editor.vue

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<div class="share-row">
1414

1515
<div class="share-col">
16-
<span class="user" v-for="user in users" :key="user.uid">
17-
<img :src="user.profile_picture" :alt="user.name" class="round-profile share-item" :tooltip="user.name">
16+
<span class="user" v-for="user in currentUsers" :key="user.uid">
17+
<img :src="user.image" :alt="user.name" class="round-profile share-item" :tooltip="user.name">
1818
</span>
1919
&nbsp;
2020
<button v-if="!opts.readOnly" @click="share" class="button dark input"><i class="fas fa-user-plus"></i></button>
@@ -68,14 +68,15 @@ import { encode } from "punycode";
6868
import { log } from "util";
6969
7070
Quill.register("modules/magicUrl", MagicUrl);
71-
71+
const FontAttributor = Quill.import("attributors/class/font");
7272
const Hashids = require("hashids");
7373
let hashids = new Hashids();
7474
let typingTimer; //timer identifier
7575
let doneTypingInterval = 5000;
7676
let updates = [];
77-
var Clipboard = Quill.import("modules/clipboard");
78-
77+
const Clipboard = Quill.import("modules/clipboard");
78+
FontAttributor.whitelist = ["roboto", "Serif", "Sans Serif"];
79+
Quill.register(FontAttributor, true);
7980
class MyClipboard extends Clipboard {
8081
onPaste(e) {
8182
var wrapper = document.querySelector("#editor-wrapper");
@@ -234,7 +235,8 @@ export default {
234235
shareUrl: null,
235236
realTimeId: null,
236237
personToShareWith: null,
237-
shareError: null
238+
shareError: null,
239+
currentUsers: []
238240
}),
239241
created() {
240242
const startLoad = performance.now();
@@ -296,6 +298,33 @@ export default {
296298
time: endLoad - startLoad,
297299
page: "documents"
298300
});
301+
firebase
302+
.database()
303+
.ref(
304+
`/documentMeta/${this.docUser}/${this.docId}/currentUsers/${
305+
this.uid
306+
}`
307+
)
308+
.set({
309+
uid: this.uid,
310+
image: firebase.auth().currentUser.photoURL,
311+
name: firebase.auth().currentUser.displayName
312+
});
313+
firebase
314+
.database()
315+
.ref(
316+
`/documentMeta/${this.docUser}/${this.docId}/currentUsers/${
317+
this.uid
318+
}`
319+
)
320+
.onDisconnect()
321+
.remove();
322+
firebase
323+
.database()
324+
.ref(`/documentMeta/${this.docUser}/${this.docId}/currentUsers`)
325+
.on("value", data => {
326+
this.currentUsers = data.val();
327+
});
299328
console.log(endLoad - startLoad + " loaded");
300329
});
301330
firebase
@@ -345,7 +374,27 @@ export default {
345374
}
346375
});
347376
},
348-
377+
beforeRouteLeave: function(to, from, next) {
378+
firebase
379+
.database()
380+
.ref(
381+
`/documentMeta/${this.docUser}/${this.docId}/currentUsers/${this.uid}`
382+
)
383+
.remove();
384+
firebase
385+
.database()
386+
.ref(`/documents/${this.docUser}/${this.docId}/changes`)
387+
.off();
388+
firebase
389+
.database()
390+
.ref(`/documentMeta/${this.docUser}/${this.docId}/info`)
391+
.off();
392+
firebase
393+
.database()
394+
.ref(`/documentMeta/${this.docUser}/${this.docId}/currentUsers`)
395+
.off();
396+
next();
397+
},
349398
methods: {
350399
shareWithPerson() {
351400
if (validateEmail(this.personToShareWith)) {

0 commit comments

Comments
 (0)