|
31 | 31 | from xblock.utils.resources import ResourceLoader |
32 | 32 | from xblock.utils.studio_editable import StudioEditableXBlockMixin |
33 | 33 |
|
34 | | -from xblocks_contrib.common.xml_utils import LegacyXmlMixin, is_pointer_tag, name_to_pathname |
| 34 | +from xblocks_contrib.common.xml_utils import EdxJSONEncoder, LegacyXmlMixin, is_pointer_tag, name_to_pathname |
35 | 35 | from xblocks_contrib.video.ajax_handler_mixin import AjaxHandlerMixin |
36 | 36 | from xblocks_contrib.video.bumper_utils import bumperize |
37 | 37 | from xblocks_contrib.video.cache_utils import request_cached |
|
104 | 104 | @XBlock.needs('i18n', 'user') |
105 | 105 | class VideoBlock( |
106 | 106 | VideoFields, VideoTranscriptsMixin, VideoStudioViewHandlers, VideoStudentViewHandlers, |
107 | | - StudioEditableXBlockMixin, LegacyXmlMixin, XBlock, |
| 107 | + LegacyXmlMixin, XBlock, |
108 | 108 | AjaxHandlerMixin, StudioMetadataMixin, |
109 | 109 | LicenseMixin): |
110 | 110 | """ |
@@ -279,6 +279,21 @@ def prioritize_hls(self, youtube_streams, html5_sources): |
279 | 279 |
|
280 | 280 | return False |
281 | 281 |
|
| 282 | + def studio_view(self, context): # pylint: disable=unused-argument |
| 283 | + """ |
| 284 | + Returns a fragment having ``data-metadata`` attribute containing |
| 285 | + ``editable_metadata_fields`` as JSON. The authoring MFE (frontend-app-authoring) |
| 286 | + reads this attribute from the block's HTML to power the video editor UI |
| 287 | + (e.g. transcript parsing via ``parseTranscripts``and related thunk actions). |
| 288 | + See: https://github.com/openedx/frontend-app-authoring/blob/master/src/editors/data/redux/thunkActions/video.js#L163 |
| 289 | +
|
| 290 | + This matches the contract of the built-in video block: |
| 291 | + edx-platform's ``mako_block.studio_view`` (xmodule/mako_block.py) uses |
| 292 | + cms/templates/widgets/metadata-edit.html, which also serializes |
| 293 | + ``editable_metadata_fields`` to JSON in a ``data-metadata`` attribute. |
| 294 | + """ |
| 295 | + return Fragment(f'<div data-metadata="{json.dumps(self.editable_metadata_fields, cls=EdxJSONEncoder)}"></div>') |
| 296 | + |
282 | 297 | def student_view(self, context=None): |
283 | 298 | """ |
284 | 299 | Return the student view. |
|
0 commit comments