[NEW] Setting to disable MarkDown and enable AutoLinker

pull/8459/head
Rodrigo Nascimento 8 years ago
parent f221962040
commit 88eb1d5c2d
No known key found for this signature in database
GPG Key ID: CFCE33B7B01AC335
  1. 4
      packages/rocketchat-autolinker/client/client.js
  2. 21
      packages/rocketchat-autolinker/server/settings.js
  3. 5
      packages/rocketchat-markdown/markdown.js
  4. 3
      packages/rocketchat-markdown/settings.js
  5. 6
      packages/rocketchat-ui-message/client/messageBox.js

@ -6,6 +6,10 @@
import Autolinker from 'autolinker';
function AutoLinker(message) {
if (RocketChat.settings.get('AutoLinker') !== true) {
return message;
}
if (_.trim(message.html)) {
const regUrls = new RegExp(RocketChat.settings.get('AutoLinker_UrlsRegExp'));

@ -1,9 +1,16 @@
Meteor.startup(function() {
RocketChat.settings.add('AutoLinker_StripPrefix', false, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nDescription: 'AutoLinker_StripPrefix_Description'});
RocketChat.settings.add('AutoLinker_Urls_Scheme', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true});
RocketChat.settings.add('AutoLinker_Urls_www', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true});
RocketChat.settings.add('AutoLinker_Urls_TLD', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true});
RocketChat.settings.add('AutoLinker_UrlsRegExp', '(://|www\\.).+', {type: 'string', group: 'Message', section: 'AutoLinker', public: true});
RocketChat.settings.add('AutoLinker_Email', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true});
RocketChat.settings.add('AutoLinker_Phone', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nDescription: 'AutoLinker_Phone_Description'});
const enableQuery = {
_id: 'AutoLinker',
value: true
};
RocketChat.settings.add('AutoLinker', false, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nLabel: 'Enabled'});
RocketChat.settings.add('AutoLinker_StripPrefix', false, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nDescription: 'AutoLinker_StripPrefix_Description', enableQuery});
RocketChat.settings.add('AutoLinker_Urls_Scheme', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery});
RocketChat.settings.add('AutoLinker_Urls_www', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery});
RocketChat.settings.add('AutoLinker_Urls_TLD', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery});
RocketChat.settings.add('AutoLinker_UrlsRegExp', '(://|www\\.).+', {type: 'string', group: 'Message', section: 'AutoLinker', public: true, enableQuery});
RocketChat.settings.add('AutoLinker_Email', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery});
RocketChat.settings.add('AutoLinker_Phone', true, {type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nDescription: 'AutoLinker_Phone_Description', enableQuery});
});

@ -31,6 +31,11 @@ class MarkdownClass {
parseMessageNotEscaped(message) {
const parser = RocketChat.settings.get('Markdown_Parser');
if (parser === 'disabled') {
return message;
}
if (typeof parsers[parser] === 'function') {
return parsers[parser](message);
}

@ -5,6 +5,9 @@ Meteor.startup(() => {
RocketChat.settings.add('Markdown_Parser', 'original', {
type: 'select',
values: [{
key: 'disabled',
i18nLabel: 'Disabled'
}, {
key: 'original',
i18nLabel: 'Original'
}, {

@ -97,7 +97,7 @@ const markdownButtons = [
icon: 'italic',
pattern: '_{{text}}_',
command: 'i',
condition: () => RocketChat.Markdown
condition: () => RocketChat.Markdown && RocketChat.settings.get('Markdown_Parser') !== 'disabled'
},
{
label: 'strike',
@ -115,13 +115,13 @@ const markdownButtons = [
label: 'inline_code',
icon: 'code',
pattern: '`{{text}}`',
condition: () => RocketChat.Markdown
condition: () => RocketChat.Markdown && RocketChat.settings.get('Markdown_Parser') !== 'disabled'
},
{
label: 'multi_line',
icon: 'multi-line',
pattern: '```\n{{text}}\n``` ',
condition: () => RocketChat.Markdown
condition: () => RocketChat.Markdown && RocketChat.settings.get('Markdown_Parser') !== 'disabled'
},
{
label: katexSyntax,

Loading…
Cancel
Save