Sha256: f65f91f30be74d0212daadb3270e019b626f8913527bc029c4ab2c139940f7d4
Contents?: true
Size: 1.33 KB
Versions: 31
Compression:
Stored size: 1.33 KB
Contents
//= require thredded/components/user_textcomplete const ThreddedMentionAutocompletion = { MATCH_RE: /(^@|\s@)"?([\w., \-()]+[\w.,\-()])$/, // the last letter has to not be a space so it doesn't match after replacement DROPDOWN_MAX_COUNT: 6, init(form, textarea) { const editor = new Textcomplete.editors.Textarea(textarea); const textcomplete = new Textcomplete(editor, { dropdown: { className: Thredded.UserTextcomplete.DROPDOWN_CLASS_NAME, maxCount: ThreddedMentionAutocompletion.DROPDOWN_MAX_COUNT }, }); textcomplete.on('rendered', function() { if (textcomplete.dropdown.items.length) { textcomplete.dropdown.items[0].activate(); } }); textcomplete.register([{ match: ThreddedMentionAutocompletion.MATCH_RE, search: Thredded.UserTextcomplete.searchFn({ url: form.getAttribute('data-autocomplete-url'), autocompleteMinLength: parseInt(form.getAttribute('data-autocomplete-min-length'), 10) }), template: Thredded.UserTextcomplete.formatUser, replace ({name, match}) { let prefix = match[1]; if (/[., ()]/.test(name)) { return `${prefix}"${name}" ` } else { return `${prefix}${name} ` } } }]); } }; window.ThreddedMentionAutocompletion = ThreddedMentionAutocompletion;
Version data entries
31 entries across 31 versions & 2 rubygems