Fixes #3717 - Spaces in front of mentions can cause partly content removal.

This commit is contained in:
Rolf Schmidt 2021-09-02 08:55:30 +02:00 committed by Thorsten Eckel
parent fa4577d463
commit 60c9c45c96
2 changed files with 23 additions and 12 deletions

View file

@ -391,14 +391,10 @@
start = 0
}
// for chrome, remove also leading space, add it later - otherwice space will be tropped
if (start) {
clone.setStart(range.startContainer, start-1)
clone.setEnd(range.startContainer, start)
var spacerChar = clone.toString()
if (spacerChar === ' ') {
start = start - 1
}
// for chrome, check if space is before trigger if so, add it later - otherwise space will be dropped
var addSpacer = false
if ( $(range.startContainer.parentNode).html().includes(' ' + string) ) {
addSpacer = true
}
//this.log('CUT FOR', string, "-"+clone.toString()+"-", start, range.startOffset)
clone.setStart(range.startContainer, start)
@ -406,10 +402,8 @@
clone.deleteContents()
// for chrome, insert space again
if (start) {
if (spacerChar === ' ') {
this.paste(' ')
}
if (addSpacer) {
range.pasteHtml(' ')
}
}

View file

@ -89,6 +89,23 @@ RSpec.shared_examples 'text modules' do |path:|
end
end
it 'does not delete parts of the text on multiple mentions (issue #3717)' do
visit path
within(:active_content) do
find('select[name="group_id"]').select('Users')
find(:richtext).send_keys('Testing Testy')
find(:richtext).send_keys('@@FFFF1')
find(:richtext).send_keys(:enter)
find(:richtext).send_keys(:enter)
find(:richtext).send_keys('Testing Testy ')
find(:richtext).send_keys('@@FFFF1')
find(:richtext).send_keys(:enter)
expect(find(:richtext).text).to include('Testing TestyFFFF1 GGGG1')
expect(find(:richtext).text).to include('Testing Testy FFFF1 GGGG1')
end
end
it 'supports group-dependent text modules' do
# give user access to all groups including those created