FEATURE: site setting enable_mentions to turn on/off mentions

This commit is contained in:
Joffrey JAFFEUX
2017-12-07 16:27:58 -05:00
committed by Robin Ward
parent 3e4f02a180
commit fd99e1ef56
6 changed files with 38 additions and 20 deletions
@@ -77,16 +77,18 @@ export default Ember.Component.extend({
const $input = this.$('.d-editor-input');
const $preview = this.$('.d-editor-preview-wrapper');
$input.autocomplete({
template: findRawTemplate('user-selector-autocomplete'),
dataSource: term => userSearch({
term,
topicId,
includeMentionableGroups: true
}),
key: "@",
transformComplete: v => v.username || v.name
});
if (this.siteSettings.enable_mentions) {
$input.autocomplete({
template: findRawTemplate('user-selector-autocomplete'),
dataSource: term => userSearch({
term,
topicId,
includeMentionableGroups: true
}),
key: "@",
transformComplete: v => v.username || v.name
});
}
if (this._enableAdvancedEditorPreviewSync()) {
this._initInputPreviewSync($input, $preview);
@@ -154,13 +154,15 @@ export function applySearchAutocomplete($input, siteSettings, appEvents, options
afterComplete
}, options));
$input.autocomplete(_.merge({
template: findRawTemplate('user-selector-autocomplete'),
key: "@",
width: '100%',
treatAsTextarea: true,
transformComplete: v => v.username || v.name,
dataSource: term => userSearch({ term, includeGroups: true }),
afterComplete
}, options));
if (Discourse.SiteSettings.enable_mentions) {
$input.autocomplete(_.merge({
template: findRawTemplate('user-selector-autocomplete'),
key: "@",
width: '100%',
treatAsTextarea: true,
transformComplete: v => v.username || v.name,
dataSource: term => userSearch({ term, includeGroups: true }),
afterComplete
}, options));
}
};
@@ -38,6 +38,10 @@ function addMention(buffer, matches, state) {
}
export function setup(helper) {
helper.registerOptions((opts, siteSettings) => {
opts.features.mentions = !!siteSettings.enable_mentions;
});
helper.registerPlugin(md => {
const rule = {