This commit is contained in:
Philipp Kühn
2020-12-02 16:29:21 +01:00

View File

@@ -59,7 +59,7 @@ export default {
data() {
return {
currentUser: {
currentUser: JSON.parse(localStorage.getItem('currentUser')) || {
name: this.getRandomName(),
color: this.getRandomColor(),
},
@@ -97,11 +97,15 @@ export default {
}),
],
})
localStorage.setItem('currentUser', JSON.stringify(this.currentUser))
},
methods: {
setName() {
const name = window.prompt('Name')
.trim()
.substring(0, 32)
if (name) {
return this.updateCurrentUser({
@@ -113,6 +117,8 @@ export default {
updateCurrentUser(attributes) {
this.currentUser = { ...this.currentUser, ...attributes }
this.editor.chain().focus().user(this.currentUser).run()
localStorage.setItem('currentUser', JSON.stringify(this.currentUser))
},
getRandomColor() {