From 1089a775c36b9f150ef254dbf1af6feda754d82e Mon Sep 17 00:00:00 2001 From: Arunmozhi Date: Thu, 24 Nov 2022 00:25:28 +0530 Subject: [PATCH 1/2] feat: allow overriding TinyMCE config using settings The TinyMCE configuration can be overridden by adding a `TINYMCE_CONFIG_OVERRIDES` dict to the `JS_ENV_EXTRA_CONFIG`. (cherry picked from commit 54507c1e083990ef9d9c8022027332818bd05595) --- cms/envs/common.py | 2 ++ common/lib/xmodule/xmodule/js/src/html/edit.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cms/envs/common.py b/cms/envs/common.py index fad3814acd5e..b0109d7b6a4f 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1177,6 +1177,8 @@ ##### custom vendor plugin variables ##### # JavaScript code can access this data using `process.env.JS_ENV_EXTRA_CONFIG` # One of the current use cases for this is enabling custom TinyMCE plugins +# (TINYMCE_ADDITIONAL_PLUGINS) and overriding the TinyMCE configuration +# (TINYMCE_CONFIG_OVERRIDES). JS_ENV_EXTRA_CONFIG = {} ############################### PIPELINE ####################################### diff --git a/common/lib/xmodule/xmodule/js/src/html/edit.js b/common/lib/xmodule/xmodule/js/src/html/edit.js index bb92d8c848d9..88863d8e2a03 100644 --- a/common/lib/xmodule/xmodule/js/src/html/edit.js +++ b/common/lib/xmodule/xmodule/js/src/html/edit.js @@ -208,6 +208,12 @@ } }); } + + // apply configuration overrides if have been defined + var tinyMceConfigOverrides = process.env.JS_ENV_EXTRA_CONFIG.TINYMCE_CONFIG_OVERRIDES; + if (tinyMceConfigOverrides) { + Object.assign(tinyMceConfig, tinyMceConfigOverrides); + } } this.tiny_mce_textarea = $(".tiny-mce", this.element).tinymce(tinyMceConfig); From 5f5dbf4792191da8c815c52b9930cbb56018e4ee Mon Sep 17 00:00:00 2001 From: Agrendalath Date: Wed, 23 Nov 2022 19:17:08 +0100 Subject: [PATCH 2/2] test: fix quality --- cms/djangoapps/contentstore/views/component.py | 1 - cms/djangoapps/contentstore/views/tests/test_item.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 2d468977a056..2c1f6d639c51 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -486,7 +486,6 @@ def component_handler(request, usage_key_string, handler, suffix=''): """ usage_key = UsageKey.from_string(usage_key_string) - # Addendum: # TNL 101-62 studio write permission is also checked for editing content. diff --git a/cms/djangoapps/contentstore/views/tests/test_item.py b/cms/djangoapps/contentstore/views/tests/test_item.py index ef2374327831..03adcede7d99 100644 --- a/cms/djangoapps/contentstore/views/tests/test_item.py +++ b/cms/djangoapps/contentstore/views/tests/test_item.py @@ -539,7 +539,9 @@ def test_create_nicely(self): # check against the template template = ProblemBlock.get_template(template_id) self.assertEqual(problem.data, template['data']) + # pylint: disable=unsubscriptable-object self.assertEqual(problem.display_name, template['metadata']['display_name']) + # pylint: disable=unsubscriptable-object self.assertEqual(problem.markdown, template['metadata']['markdown']) def test_create_item_negative(self):