Skip to content

Commit

Permalink
fix(richEdito): Fix the mixin to allow @ within userids
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jun 15, 2023
1 parent 2acc9a9 commit 23c8ab6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Expand Up @@ -81,9 +81,9 @@ export default {
},
subline: 'Visiting London',
},
'Test 03': {
'Test@User': {
icon: 'icon-user',
id: 'Test 03',
id: 'Test@User',
title: 'Test 03',
source: 'users',
status: {
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/richEditor/index.js
Expand Up @@ -66,8 +66,8 @@ export default {
return Linkify(part)
}

// Extracting the id, nuking the " and @
const id = part.replace(/@|&quot;/gi, '')
// Extracting the id, nuking the leading @ and all "
const id = part.slice(1).replace(/&quot;/gi, '')
// Compiling template and prepend with the space we removed during the split
return ' ' + this.genSelectTemplate(id)
})
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/mixins/richEditor.spec.js
Expand Up @@ -82,5 +82,13 @@ describe('richEditor.js', () => {

expect(output).toMatch(/^hello <span.+role="heading" title="J. Doe"/)
})

it('keep mentions with special characters', () => {
const editor = shallowMount(TestEditor, { propsData: { userData: {} } })
const input = 'hello @foo@bar - hello @"bar @ foo"'
const output = editor.vm.renderContent(input)

expect(output).toEqual('hello @foo@bar - hello @"bar @ foo"')
})
})
})

0 comments on commit 23c8ab6

Please sign in to comment.