Loading gutenberg.module +1 −0 Original line number Diff line number Diff line Loading @@ -667,6 +667,7 @@ function gutenberg_form_media_edit_form_cancel(array $form, FormStateInterface $ $form_state->disableRedirect(); $command = new CloseModalDialogCommand(); $response = new AjaxResponse(); $response->addCommand(new UpdateMediaEntitiesCommand()); $response->addCommand($command); return $response; } Loading js/gutenberg.es6.js +15 −6 Original line number Diff line number Diff line Loading @@ -679,6 +679,20 @@ }, }; async function updateDrupalBlockBasedOnMediaEntity(id) { const { dispatch } = wp.data; const response = await fetch( Drupal.url(`editor/media/render/${id}`), ); if (response.ok) { const mediaEntity = await response.json(); if (mediaEntity && mediaEntity.view_modes) { dispatch('drupal').setMediaEntity(id, mediaEntity); } } } /** * Add new command for reloading the media block after editing.. */ Loading @@ -687,12 +701,7 @@ const selectedBlock = select('core/block-editor').getSelectedBlock(); const { clientId, attributes } = selectedBlock; const { mediaEntityIds } = attributes; (async () => { await dispatch('core/block-editor').updateBlockAttributes(clientId, { mediaEntityIds: [mediaEntityIds], }); })(); updateDrupalBlockBasedOnMediaEntity(mediaEntityIds[0]); }; })(Drupal, DrupalGutenberg, drupalSettings, window.wp, jQuery); js/gutenberg.js +44 −20 Original line number Diff line number Diff line Loading @@ -10,6 +10,49 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } (function (Drupal, DrupalGutenberg, drupalSettings, wp, $) { var updateDrupalBlockBasedOnMediaEntity = function () { var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee5(id) { var dispatch, response, mediaEntity; return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: dispatch = wp.data.dispatch; _context5.next = 3; return fetch(Drupal.url('editor/media/render/' + id)); case 3: response = _context5.sent; if (!response.ok) { _context5.next = 9; break; } _context5.next = 7; return response.json(); case 7: mediaEntity = _context5.sent; if (mediaEntity && mediaEntity.view_modes) { dispatch('drupal').setMediaEntity(id, mediaEntity); } case 9: case 'end': return _context5.stop(); } } }, _callee5, this); })); return function updateDrupalBlockBasedOnMediaEntity(_x3) { return _ref3.apply(this, arguments); }; }(); Drupal.isMediaEnabled = function () { return (drupalSettings.gutenberg || false) && drupalSettings.gutenberg['media-enabled']; }; Loading Loading @@ -541,8 +584,6 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a }; Drupal.AjaxCommands.prototype.gutenbergUpdateMediaEntities = function () { var _this4 = this; var _wp$data2 = wp.data, select = _wp$data2.select, dispatch = _wp$data2.dispatch; Loading @@ -552,23 +593,6 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a attributes = selectedBlock.attributes; var mediaEntityIds = attributes.mediaEntityIds; _asyncToGenerator(regeneratorRuntime.mark(function _callee5() { return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return dispatch('core/block-editor').updateBlockAttributes(clientId, { mediaEntityIds: [mediaEntityIds] }); case 2: case 'end': return _context5.stop(); } } }, _callee5, _this4); }))(); updateDrupalBlockBasedOnMediaEntity(mediaEntityIds[0]); }; })(Drupal, DrupalGutenberg, drupalSettings, window.wp, jQuery); No newline at end of file Loading
gutenberg.module +1 −0 Original line number Diff line number Diff line Loading @@ -667,6 +667,7 @@ function gutenberg_form_media_edit_form_cancel(array $form, FormStateInterface $ $form_state->disableRedirect(); $command = new CloseModalDialogCommand(); $response = new AjaxResponse(); $response->addCommand(new UpdateMediaEntitiesCommand()); $response->addCommand($command); return $response; } Loading
js/gutenberg.es6.js +15 −6 Original line number Diff line number Diff line Loading @@ -679,6 +679,20 @@ }, }; async function updateDrupalBlockBasedOnMediaEntity(id) { const { dispatch } = wp.data; const response = await fetch( Drupal.url(`editor/media/render/${id}`), ); if (response.ok) { const mediaEntity = await response.json(); if (mediaEntity && mediaEntity.view_modes) { dispatch('drupal').setMediaEntity(id, mediaEntity); } } } /** * Add new command for reloading the media block after editing.. */ Loading @@ -687,12 +701,7 @@ const selectedBlock = select('core/block-editor').getSelectedBlock(); const { clientId, attributes } = selectedBlock; const { mediaEntityIds } = attributes; (async () => { await dispatch('core/block-editor').updateBlockAttributes(clientId, { mediaEntityIds: [mediaEntityIds], }); })(); updateDrupalBlockBasedOnMediaEntity(mediaEntityIds[0]); }; })(Drupal, DrupalGutenberg, drupalSettings, window.wp, jQuery);
js/gutenberg.js +44 −20 Original line number Diff line number Diff line Loading @@ -10,6 +10,49 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } (function (Drupal, DrupalGutenberg, drupalSettings, wp, $) { var updateDrupalBlockBasedOnMediaEntity = function () { var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee5(id) { var dispatch, response, mediaEntity; return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: dispatch = wp.data.dispatch; _context5.next = 3; return fetch(Drupal.url('editor/media/render/' + id)); case 3: response = _context5.sent; if (!response.ok) { _context5.next = 9; break; } _context5.next = 7; return response.json(); case 7: mediaEntity = _context5.sent; if (mediaEntity && mediaEntity.view_modes) { dispatch('drupal').setMediaEntity(id, mediaEntity); } case 9: case 'end': return _context5.stop(); } } }, _callee5, this); })); return function updateDrupalBlockBasedOnMediaEntity(_x3) { return _ref3.apply(this, arguments); }; }(); Drupal.isMediaEnabled = function () { return (drupalSettings.gutenberg || false) && drupalSettings.gutenberg['media-enabled']; }; Loading Loading @@ -541,8 +584,6 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a }; Drupal.AjaxCommands.prototype.gutenbergUpdateMediaEntities = function () { var _this4 = this; var _wp$data2 = wp.data, select = _wp$data2.select, dispatch = _wp$data2.dispatch; Loading @@ -552,23 +593,6 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a attributes = selectedBlock.attributes; var mediaEntityIds = attributes.mediaEntityIds; _asyncToGenerator(regeneratorRuntime.mark(function _callee5() { return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return dispatch('core/block-editor').updateBlockAttributes(clientId, { mediaEntityIds: [mediaEntityIds] }); case 2: case 'end': return _context5.stop(); } } }, _callee5, _this4); }))(); updateDrupalBlockBasedOnMediaEntity(mediaEntityIds[0]); }; })(Drupal, DrupalGutenberg, drupalSettings, window.wp, jQuery); No newline at end of file