Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Setting to disable MarkDown and enable AutoLinker #8459

Merged
merged 1 commit into from
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/rocketchat-autolinker/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
21 changes: 14 additions & 7 deletions packages/rocketchat-autolinker/server/settings.js
Original file line number Diff line number Diff line change
@@ -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});
});
5 changes: 5 additions & 0 deletions packages/rocketchat-markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-markdown/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Meteor.startup(() => {
RocketChat.settings.add('Markdown_Parser', 'original', {
type: 'select',
values: [{
key: 'disabled',
i18nLabel: 'Disabled'
}, {
key: 'original',
i18nLabel: 'Original'
}, {
Expand Down
6 changes: 3 additions & 3 deletions packages/rocketchat-ui-message/client/messageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down