diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6 index 29e2d313aa9..75a152eaa0f 100644 --- a/app/assets/javascripts/discourse/components/composer-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6 @@ -434,9 +434,14 @@ export default Ember.Component.extend({ }); $element.on('fileuploadpaste', (e) => { - const { types } = clipboardData(e); this._pasted = true; + if (!this.siteSettings.enable_rich_text_paste || !$(".d-editor-input").is(":focus")) { + return; + } + + const { types } = clipboardData(e); + if (types.includes("text/plain") || types.includes("text/html")) { e.preventDefault(); } diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index ef0c6d8047a..9f23f952987 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -640,7 +640,7 @@ export default Ember.Component.extend({ }, paste(e) { - if (!$(".d-editor-input").is(":focus")) { + if (!this.siteSettings.enable_rich_text_paste || !$(".d-editor-input").is(":focus")) { return; } diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 7bb5823f9e5..614f59ce59b 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1088,6 +1088,7 @@ en: top_page_default_timeframe: "Default timeframe for the top view page." show_email_on_profile: "Show a user's email on their profile (only visible to themselves and staff)" prioritize_username_in_ux: "Show username first on user page, user card and posts (when disabled name is shown first)" + enable_rich_text_paste: "Enable automatic HTML to Markdown conversion" email_token_valid_hours: "Forgot password / activate account tokens are valid for (n) hours." diff --git a/config/site_settings.yml b/config/site_settings.yml index 3d004c32674..59c4f8dd161 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -525,6 +525,9 @@ posting: enable_markdown_typographer: client: true default: true + enable_rich_text_paste: + client: true + default: false suppress_reply_directly_below: client: true default: true