fix: TinyMCE editor in advanced block editors [FC-0076] (#36754)
* fix: TinyMCE editors in advanced block editors
* Sets baseUrl to avoid an error in: 86eee4b05d/xblock/utils/public/studio_edit.js (L52)
* Uncouple the listener func of the cancel button (see the comment)
* chore: Add `edx_sga` in `LIBRARY_ENABLED_BLOCKS`
This commit is contained in:
@@ -2882,6 +2882,7 @@ LIBRARY_ENABLED_BLOCKS = [
|
||||
'openassessment',
|
||||
'conditional',
|
||||
'done',
|
||||
'edx_sga',
|
||||
'freetextresponse',
|
||||
'google-calendar',
|
||||
'google-document',
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
// The minimal RequireJS configuration required for common LMS and CMS building XBlock types to work:
|
||||
require = require || RequireJS.require;
|
||||
define = define || RequireJS.define;
|
||||
baseUrl = "";
|
||||
(function (require, define) {
|
||||
if ('{{ view_name | safe }}' === 'studio_view') {
|
||||
// Call `require-config.js` of the CMS
|
||||
@@ -47,9 +48,10 @@
|
||||
script.type = 'text/javascript';
|
||||
script.src = "{{ cms_root_url }}/static/studio/cms/js/require-config.js";
|
||||
document.head.appendChild(script);
|
||||
baseUrl = "{{ cms_root_url }}/static/studio";
|
||||
|
||||
require.config({
|
||||
baseUrl: "{{ cms_root_url }}/static/studio",
|
||||
baseUrl,
|
||||
paths: {
|
||||
accessibility: 'js/src/accessibility_tools',
|
||||
draggabilly: 'js/vendor/draggabilly',
|
||||
@@ -64,8 +66,9 @@
|
||||
"{{ lms_root_url }}/static/dist{{ oa_manifest.oa_editor_textarea_js }}",
|
||||
]);
|
||||
} else {
|
||||
baseUrl = "{{ lms_root_url }}/static/";
|
||||
require.config({
|
||||
baseUrl: "{{ lms_root_url }}/static/",
|
||||
baseUrl,
|
||||
paths: {
|
||||
accessibility: 'js/src/accessibility_tools',
|
||||
draggabilly: 'js/vendor/draggabilly',
|
||||
@@ -375,7 +378,6 @@
|
||||
if ('{{ view_name | safe }}' === 'studio_view') {
|
||||
// Used when rendering the `studio_view`, in order to avoid open a new tab on click cancel or save
|
||||
const selectors = [
|
||||
'.cancel-button',
|
||||
'.save-button',
|
||||
'.action-cancel',
|
||||
'.action-save',
|
||||
@@ -391,6 +393,24 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// This button is used in `StudioEditableXBlockMixin` from the `Xblock` app
|
||||
// That app adds a listener that removes any TinyMCE editors on click cancel.
|
||||
// ref: https://github.com/openedx/XBlock/blob/86eee4b05dffa42b009fab2a9050b73766131b9d/xblock/utils/public/studio_edit.js#L169
|
||||
//
|
||||
// Here that is an issue because we show a confirmation modal when clicking cancel,
|
||||
// if the user stays to edit all TinyMCE editors are no longer there.
|
||||
//
|
||||
// We uncouple the listener to avoid remove the TinyMCE editors
|
||||
const extraCancelSelector = '.cancel-button';
|
||||
const elements = $(extraCancelSelector).first();
|
||||
if (elements.length) {
|
||||
elements.first().unbind("click");
|
||||
elements.on('click', function() {
|
||||
event.preventDefault();
|
||||
runtime.notify('cancel', {});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user