Skip to content

Commit

Permalink
fixup! feat: mail snippets
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Oct 31, 2024
1 parent 11fc522 commit 3f3edc6
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/components/TextEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ export default {
{
marker: '@',
feed: this.getContact,
itemRenderer: this.customContactRenderer,
itemRenderer: this.customRenderer,
},
{
marker: '!',
feed: this.getSnippet,
itemRenderer: this.customRenderer,
},
],
},
Expand Down Expand Up @@ -192,6 +197,12 @@ export default {
let contactResults = await autoCompleteByName(text, true)
contactResults = contactResults.filter(result => result.email.length > 0)
return contactResults
},
getSnippet(text) {
if (text.length === 0) {
return []
}
return this.snippets.filter(snippet => snippet.title.toLowerCase().includes(text.toLowerCase()))
},
customEmojiRenderer(item) {
const itemElement = document.createElement('span')
Expand Down Expand Up @@ -225,15 +236,15 @@ export default {
return itemElement
},
customContactRenderer(item) {
customRenderer(item, type) {
const itemElement = document.createElement('span')
itemElement.classList.add('custom-item')
itemElement.id = `mention-list-item-id-${item.id}`
const usernameElement = document.createElement('p')
const label = type === 'contact' ? item.label : item.title
usernameElement.classList.add('custom-item-username')
usernameElement.textContent = item.label
usernameElement.textContent = label
itemElement.appendChild(usernameElement)
Expand Down Expand Up @@ -348,6 +359,9 @@ export default {
this.editorInstance.execute('insertItem', { email: item.email[0], label: item.label }, '@')
this.$emit('mention', { email: item.email[0], label: item.label })
}
if (eventData.marker === '!') {
this.editorInstance.execute('insertItem', item.content, '!')
}
}, { priority: 'high' })
this.editorInstance = editor
Expand Down

0 comments on commit 3f3edc6

Please sign in to comment.