|
13 | 13 | <div class="share-row"> |
14 | 14 |
|
15 | 15 | <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"> |
18 | 18 | </span> |
19 | 19 | |
20 | 20 | <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"; |
68 | 68 | import { log } from "util"; |
69 | 69 |
|
70 | 70 | Quill.register("modules/magicUrl", MagicUrl); |
71 | | -
|
| 71 | +const FontAttributor = Quill.import("attributors/class/font"); |
72 | 72 | const Hashids = require("hashids"); |
73 | 73 | let hashids = new Hashids(); |
74 | 74 | let typingTimer; //timer identifier |
75 | 75 | let doneTypingInterval = 5000; |
76 | 76 | 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); |
79 | 80 | class MyClipboard extends Clipboard { |
80 | 81 | onPaste(e) { |
81 | 82 | var wrapper = document.querySelector("#editor-wrapper"); |
@@ -234,7 +235,8 @@ export default { |
234 | 235 | shareUrl: null, |
235 | 236 | realTimeId: null, |
236 | 237 | personToShareWith: null, |
237 | | - shareError: null |
| 238 | + shareError: null, |
| 239 | + currentUsers: [] |
238 | 240 | }), |
239 | 241 | created() { |
240 | 242 | const startLoad = performance.now(); |
@@ -296,6 +298,33 @@ export default { |
296 | 298 | time: endLoad - startLoad, |
297 | 299 | page: "documents" |
298 | 300 | }); |
| 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 | + }); |
299 | 328 | console.log(endLoad - startLoad + " loaded"); |
300 | 329 | }); |
301 | 330 | firebase |
@@ -345,7 +374,27 @@ export default { |
345 | 374 | } |
346 | 375 | }); |
347 | 376 | }, |
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 | + }, |
349 | 398 | methods: { |
350 | 399 | shareWithPerson() { |
351 | 400 | if (validateEmail(this.personToShareWith)) { |
|
0 commit comments