Merge branch 'gfm-autocomplete-char-in-middle' into 'master'
Fixed GFM autocomplete to disallow non-word characters in string ## What does this MR do? Disallows GFM autocomplete working when a non-word character is enter in the middle of the string. ## Screenshots (if relevant) ![Screen_Shot_2016-12-12_at_09.47.46](/uploads/aa6463a57b97c103c69eab6bb1d80540/Screen_Shot_2016-12-12_at_09.47.46.png) ## What are the relevant issue numbers? Closes #25540 See merge request !8035
This commit is contained in:
commit
cd5b06dd51
2 changed files with 11 additions and 2 deletions
|
@ -67,14 +67,15 @@
|
|||
// The below is taken from At.js source
|
||||
// Tweaked to commands to start without a space only if char before is a non-word character
|
||||
// https://github.com/ichord/At.js
|
||||
var _a, _y, regexp, match;
|
||||
var _a, _y, regexp, match, atSymbols;
|
||||
atSymbols = Object.keys(this.app.controllers).join('|');
|
||||
subtext = subtext.split(' ').pop();
|
||||
flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
|
||||
_a = decodeURI("%C3%80");
|
||||
_y = decodeURI("%C3%BF");
|
||||
|
||||
regexp = new RegExp("(?:\\B|\\W|\\s)" + flag + "(?!\\W)([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)|([^\\x00-\\xff]*)$", 'gi');
|
||||
regexp = new RegExp("(?:\\B|\\W|\\s)" + flag + "(?![" + atSymbols + "])([A-Za-z" + _a + "-" + _y + "0-9_\'\.\+\-]*)$", 'gi');
|
||||
|
||||
match = regexp.exec(subtext);
|
||||
|
||||
|
|
|
@ -89,4 +89,12 @@ feature 'GFM autocomplete', feature: true, js: true do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'doesnt open autocomplete after non-word character' do
|
||||
page.within '.timeline-content-form' do
|
||||
find('#note_note').native.send_keys("@#{user.username[0..2]}!")
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector('.atwho-view')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue