Skip to content
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
19 changes: 0 additions & 19 deletions cms/djangoapps/contentstore/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,6 @@ def exam_setting_view_enabled(course_key):
return not LEGACY_STUDIO_EXAM_SETTINGS.is_enabled(course_key)


# .. toggle_name: legacy_studio.text_editor
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Temporarily fall back to the old Text component (a.k.a. html block) editor.
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2025-03-14
# .. toggle_target_removal_date: 2025-09-14
# .. toggle_tickets: https://github.com/openedx/edx-platform/issues/36275
# .. toggle_warning: In Ulmo, this toggle will be removed. Only the new (React-based) experience will be available.
LEGACY_STUDIO_TEXT_EDITOR = CourseWaffleFlag("legacy_studio.text_editor", __name__)


def use_new_text_editor(course_key):
"""
Returns a boolean = true if new text editor is enabled
"""
return not LEGACY_STUDIO_TEXT_EDITOR.is_enabled(course_key)


# .. toggle_name: legacy_studio.video_editor
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
Expand Down
11 changes: 4 additions & 7 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
use_new_home_page,
use_new_import_page,
use_new_schedule_details_page,
use_new_text_editor,
use_new_textbooks_page,
use_new_unit_page,
use_new_updates_page,
use_new_video_editor,
use_new_video_uploads_page,
)
from cms.djangoapps.models.settings.course_grading import CourseGradingModel
Expand Down Expand Up @@ -289,11 +287,10 @@ def get_editor_page_base_url(course_locator) -> str:
Gets course authoring microfrontend URL for links to the new base editors
"""
editor_url = None
if use_new_text_editor(course_locator) or use_new_video_editor(course_locator):
mfe_base_url = get_course_authoring_url(course_locator)
course_mfe_url = f'{mfe_base_url}/course/{course_locator}/editor'
if mfe_base_url:
editor_url = course_mfe_url
mfe_base_url = get_course_authoring_url(course_locator)
course_mfe_url = f'{mfe_base_url}/course/{course_locator}/editor'
if mfe_base_url:
editor_url = course_mfe_url
return editor_url


Expand Down
10 changes: 4 additions & 6 deletions cms/static/js/views/pages/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,11 @@ function($, _, Backbone, gettext, BasePage,
if (!options || options.view !== 'visibility_view') {
const primaryHeader = $(event.target).closest('.xblock-header-primary, .nav-actions');

var useNewTextEditor = primaryHeader.attr('use-new-editor-text'),
useNewVideoEditor = primaryHeader.attr('use-new-editor-video'),
var useNewVideoEditor = primaryHeader.attr('use-new-editor-video'),
useNewProblemEditor = primaryHeader.attr('use-new-editor-problem'),
blockType = primaryHeader.attr('data-block-type');

if((useNewTextEditor === 'True' && blockType === 'html')
if((blockType === 'html')
|| (useNewVideoEditor === 'True' && blockType === 'video')
|| (useNewProblemEditor === 'True' && blockType === 'problem')
) {
Expand Down Expand Up @@ -1170,8 +1169,7 @@ function($, _, Backbone, gettext, BasePage,
},

onNewXBlock: function(xblockElement, scrollOffset, is_duplicate, data) {
var useNewTextEditor = this.$('.xblock-header-primary').attr('use-new-editor-text'),
useNewVideoEditor = this.$('.xblock-header-primary').attr('use-new-editor-video'),
var useNewVideoEditor = this.$('.xblock-header-primary').attr('use-new-editor-video'),
useVideoGalleryFlow = this.$('.xblock-header-primary').attr("use-video-gallery-flow"),
useNewProblemEditor = this.$('.xblock-header-primary').attr('use-new-editor-problem');

Expand All @@ -1181,7 +1179,7 @@ function($, _, Backbone, gettext, BasePage,
var blockType = data.locator.match(matchBlockTypeFromLocator);
}
// open mfe editors for new blocks only and not for content imported from libraries
if(!data.hasOwnProperty('upstreamRef') && ((useNewTextEditor === 'True' && blockType.includes('html'))
if(!data.hasOwnProperty('upstreamRef') && (blockType.includes('html')
|| (useNewVideoEditor === 'True' && blockType.includes('video'))
|| (useNewProblemEditor === 'True' && blockType.includes('problem')))
){
Expand Down
23 changes: 1 addition & 22 deletions cms/templates/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.utils.translation import gettext as _

from cms.djangoapps.contentstore.helpers import xblock_studio_url, xblock_type_display_name
from cms.djangoapps.contentstore.toggles import use_new_text_editor, use_new_problem_editor, use_new_video_editor, use_video_gallery_flow
from cms.djangoapps.contentstore.toggles import use_new_problem_editor, use_new_video_editor, use_video_gallery_flow
from cms.djangoapps.contentstore.utils import get_editor_page_base_url
from openedx.core.djangolib.js_utils import (
dump_js_escaped_json, js_escaped_string
Expand Down Expand Up @@ -115,7 +115,6 @@
<%block name="content">

<%
use_new_editor_text = use_new_text_editor(xblock_locator.course_key)
use_new_editor_video = use_new_video_editor(xblock_locator.course_key)
use_new_editor_problem = use_new_problem_editor(xblock_locator.course_key)
use_new_video_gallery_flow = use_video_gallery_flow()
Expand Down Expand Up @@ -172,7 +171,6 @@ <h1 class="page-header-title xblock-field-value incontext-editor-value"><span cl
</div>

<nav class="nav-actions" aria-label="${_('Page Actions')}"
use-new-editor-text = ${use_new_editor_text}
use-new-editor-video = ${use_new_editor_video}
use-new-editor-problem = ${use_new_editor_problem}
use-video-gallery-flow = ${use_new_video_gallery_flow}
Expand Down Expand Up @@ -276,25 +274,6 @@ <h5 class="title">${_("Location ID")}</h5>
% endif
</aside>
</section>
<div id="edit-image-modal">
<%static:studiofrontend entry="editImageModal">
{
"course": {
"id": "${context_course.id | n, js_escaped_string}",
"name": "${context_course.display_name_with_default | n, js_escaped_string}",
"url_name": "${context_course.location.block_id | n, js_escaped_string}",
"org": "${context_course.location.org | n, js_escaped_string}",
"num": "${context_course.location.course | n, js_escaped_string}",
"display_course_number": "${context_course.display_coursenumber | n, js_escaped_string}",
"revision": "${context_course.location.revision | n, js_escaped_string}"
},
"help_tokens": {
"image_accessibility": "${get_online_help_info('image_accessibility')['doc_url'] | n, js_escaped_string}"
},
"lang": "${language_code | n, js_escaped_string}"
}
</%static:studiofrontend>
</div>
</div>
</div>

Expand Down
4 changes: 1 addition & 3 deletions cms/templates/studio_xblock_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
from openedx.core.djangolib.js_utils import (
dump_js_escaped_json, js_escaped_string
)
from cms.djangoapps.contentstore.toggles import use_new_text_editor, use_new_problem_editor, use_new_video_editor, use_video_gallery_flow
from cms.djangoapps.contentstore.toggles import use_new_problem_editor, use_new_video_editor, use_video_gallery_flow
from cms.lib.xblock.upstream_sync import UpstreamLink
from openedx.core.djangoapps.content_tagging.toggles import is_tagging_feature_disabled
%>
<%
use_new_editor_text = use_new_text_editor(xblock.context_key)
use_new_editor_video = use_new_video_editor(xblock.context_key)
use_new_editor_problem = use_new_problem_editor(xblock.context_key)
use_new_video_gallery_flow = use_video_gallery_flow()
Expand Down Expand Up @@ -83,7 +82,6 @@
is-collapsed
% endif
"
use-new-editor-text = ${use_new_editor_text}
use-new-editor-video = ${use_new_editor_video}
use-new-editor-problem = ${use_new_editor_problem}
use-video-gallery-flow = ${use_new_video_gallery_flow}
Expand Down
13 changes: 0 additions & 13 deletions cms/templates/widgets/html-edit.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ def test_library_blocks_studio_view(self):
# Add a 'html' XBlock to the library:
create_date = datetime(2024, 6, 6, 6, 6, 6, tzinfo=timezone.utc)
with freeze_time(create_date):
block_data = self._add_block_to_library(lib_id, "html", "html1")
block_data = self._add_block_to_library(lib_id, "problem", "problem1")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kdmccormick just want to confirm the approach I took here. The html block was being used to test content libraries. So I just want to make sure, that switching it to use the problem block instead should be fine?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, looks good. We will eventually remove the old problem editor too, so if you wanted to be more future-proof, you could use a block like drag-and-drop-v2 which will probably have a legacy editor for a long time. Consider that optional for the sake of this PR though.

Either way, make sure to update the docstring for this test function.

self.assertDictContainsEntries(block_data, {
"id": "lb:CL-TEST:testlib2:html:html1",
"display_name": "Text",
"block_type": "html",
"id": "lb:CL-TEST:testlib2:problem:problem1",
"display_name": "Blank Problem",
"block_type": "problem",
"has_unpublished_changes": True,
"last_published": None,
"published_by": None,
Expand All @@ -441,14 +441,14 @@ def test_library_blocks_studio_view(self):
block_data["has_unpublished_changes"] = False
block_data["last_published"] = publish_date.isoformat().replace('+00:00', 'Z')
block_data["published_by"] = "Bob"
block_data["published_display_name"] = "Text"
block_data["published_display_name"] = "Blank Problem"
self.assertDictContainsEntries(self._get_library_block(block_id), block_data)
assert self._get_library_blocks(lib_id)['results'] == [block_data]

# Now update the block's OLX:
orig_olx = self._get_library_block_olx(block_id)
assert '<html' in orig_olx
new_olx = "<html><b>Hello world!</b></html>"
assert '<problem' in orig_olx
new_olx = "<problem><b>Hello world!</b></problem>"

update_date = datetime(2024, 8, 8, 8, 8, 8, tzinfo=timezone.utc)
with freeze_time(update_date):
Expand All @@ -457,7 +457,7 @@ def test_library_blocks_studio_view(self):
assert self._get_library_block_olx(block_id) == new_olx
# And the display name and "unpublished changes" status of the block should be updated:
self.assertDictContainsEntries(self._get_library_block(block_id), {
"display_name": "Text",
"display_name": "Blank Problem",
"has_unpublished_changes": True,
"last_draft_created": update_date.isoformat().replace('+00:00', 'Z')
})
Expand Down
10 changes: 3 additions & 7 deletions xmodule/html_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,9 @@ def studio_view(self, _context):
"""
Return the studio view.
"""
fragment = Fragment(
self.runtime.service(self, 'mako').render_cms_template(self.mako_template, self.get_context())
)
add_css_to_fragment(fragment, 'HtmlBlockEditor.css')
add_webpack_js_to_fragment(fragment, 'HtmlBlockEditor')
shim_xmodule_js(fragment, 'HTMLEditingDescriptor')
return fragment
# Only the ReactJS editor is supported for this block.
# See https://github.com/openedx/frontend-app-authoring/tree/master/src/editors/containers/TextEditor
raise NotImplementedError

@classmethod
def get_customizable_fields(cls) -> dict[str, str | None]:
Expand Down
Loading