diff --git a/cms/static/js/views/modals/select_v2_library_content.js b/cms/static/js/views/modals/select_v2_library_content.js index 76fb301540be..e301aeab8d9d 100644 --- a/cms/static/js/views/modals/select_v2_library_content.js +++ b/cms/static/js/views/modals/select_v2_library_content.js @@ -37,6 +37,10 @@ function($, _, gettext, BaseModal) { this.disableActionButton('add'); } } + if (event.data?.type === 'addSelectedComponentsToBank') { + this.selections = event.data.payload.selectedComponents; + this.callback(this.selections); + } }; this.messageListener = window.addEventListener("message", handleMessage); this.cleanupListener = () => { window.removeEventListener("message", handleMessage) }; @@ -70,10 +74,20 @@ function($, _, gettext, BaseModal) { * Show a component picker modal from library. * @param contentPickerUrl Url for component picker * @param callback A function to call with the selected block(s) + * @param isIframeEmbed Boolean indicating if the unit is displayed inside an iframe */ - showComponentPicker: function(contentPickerUrl, callback) { + showComponentPicker: function(contentPickerUrl, callback, isIframeEmbed) { this.contentPickerUrl = contentPickerUrl; this.callback = callback; + if (isIframeEmbed) { + window.parent.postMessage( + { + type: 'showMultipleComponentPicker', + payload: {} + }, document.referrer + ); + return true; + } this.render(); this.show(); diff --git a/cms/static/js/views/pages/container.js b/cms/static/js/views/pages/container.js index 1d57eb92b807..fb8fd2482d4e 100644 --- a/cms/static/js/views/pages/container.js +++ b/cms/static/js/views/pages/container.js @@ -524,7 +524,7 @@ function($, _, Backbone, gettext, BasePage, ViewUtils.runOperationShowingMessage(gettext('Adding'), () => { return lastAdded.done(() => { doneAddingAllBlocks() }); }); - }); + }, this.options.isIframeEmbed); }, /**