Pass entire user collection to Editor

This commit is contained in:
Robert Schäfer 2019-04-13 00:58:35 +02:00
parent 2529c62137
commit f760f37186
2 changed files with 21 additions and 6 deletions

View File

@ -16,6 +16,7 @@
/> />
<no-ssr> <no-ssr>
<hc-editor <hc-editor
:users="users"
:value="form.content" :value="form.content"
@input="updateEditorContent" @input="updateEditorContent"
/> />
@ -125,6 +126,22 @@ export default {
// this.form.content = value // this.form.content = value
this.$refs.contributionForm.update('content', value) this.$refs.contributionForm.update('content', value)
} }
},
apollo: {
User: {
query() {
return gql(`{
User {
id
name
slug
}
}`)
},
result(result) {
this.users = result.data.User
}
}
} }
} }
</script> </script>

View File

@ -197,6 +197,7 @@ export default {
EditorMenuBubble EditorMenuBubble
}, },
props: { props: {
users: { type: Array, default: () => [] },
value: { type: String, default: '' }, value: { type: String, default: '' },
doc: { type: Object, default: () => {} } doc: { type: Object, default: () => {} }
}, },
@ -227,12 +228,9 @@ export default {
}), }),
new History(), new History(),
new Mention({ new Mention({
items: () => [ items: () => {
{ id: 1, name: 'Philipp Kühn' }, return this.users
{ id: 2, name: 'Hans Pagel' }, },
{ id: 3, name: 'Kris Siepert' },
{ id: 4, name: 'Justin Schueler' }
],
onEnter: ({ items, query, range, command, virtualNode }) => { onEnter: ({ items, query, range, command, virtualNode }) => {
this.query = query this.query = query
this.filteredUsers = items this.filteredUsers = items