fix emoji insertion
This commit is contained in:
parent
cd9365cddb
commit
5424242b0f
|
@ -19,9 +19,9 @@ export async function updateCustomEmojiForInstance (instanceName) {
|
||||||
|
|
||||||
export function insertEmoji (emoji) {
|
export function insertEmoji (emoji) {
|
||||||
let idx = store.get('composeSelectionStart') || 0
|
let idx = store.get('composeSelectionStart') || 0
|
||||||
let oldText = store.get('rawComposeText')
|
let oldText = store.get('rawComposeText') || ''
|
||||||
let pre = substring(oldText, 0, idx)
|
let pre = oldText ? substring(oldText, 0, idx) : ''
|
||||||
let post = substring(oldText, idx)
|
let post = oldText ? substring(oldText, idx) : ''
|
||||||
let newText = `${pre}:${emoji.shortcode}: ${post}`
|
let newText = `${pre}:${emoji.shortcode}: ${post}`
|
||||||
store.set({
|
store.set({
|
||||||
rawComposeText: newText
|
rawComposeText: newText
|
||||||
|
|
|
@ -81,3 +81,13 @@ test('inserts custom emoji correctly', async t => {
|
||||||
.click($('button img[title=":blobpeek:"]'))
|
.click($('button img[title=":blobpeek:"]'))
|
||||||
.expect(composeInput.value).eql(':blobnom: hello :blobpats: world foobar :blobpeek: ')
|
.expect(composeInput.value).eql(':blobnom: hello :blobpats: world foobar :blobpeek: ')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('inserts emoji without typing anything', async t => {
|
||||||
|
await t.useRole(foobarRole)
|
||||||
|
.click(emojiButton)
|
||||||
|
.click($('button img[title=":blobpats:"]'))
|
||||||
|
.expect(composeInput.value).eql(':blobpats: ')
|
||||||
|
.click(emojiButton)
|
||||||
|
.click($('button img[title=":blobpeek:"]'))
|
||||||
|
.expect(composeInput.value).eql(':blobpeek: :blobpats: ')
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue