<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var \Magento\PageBuilder\Block\Adminhtml\Stage\Render $block */
?>
<script>
    <?php
    /**
     * Override the text! plugin within the iframe to ensure we can pipe any XHR requests through to the parent window
     * as the same origin policy will not allow us to load the templates within this iframe.
     */
    ?>
    require.config({
        'map': {
            '*': {
                'text': 'Magento_PageBuilder/js/master-format/render/requirejs/text',
                'Magento_PageBuilder/js/events': 'Magento_PageBuilder/js/master-format/render/events'
            }
        }
    });

    <?php
    /**
     * To be able to override the text plugin we need the Magento template engine to be used, as the template engine
     * within lib has a dependency on the text! plugin we need to ensure we set the template engine before the
     * dependency blocks us. If we try to just override using the RequireJS config above our !text plugin will never
     * get overridden as our template engine cannot load.
     */
    ?>
    require([
        'ko',
        'Magento_Ui/js/lib/knockout/template/engine'
    ], function (ko, templateEngine) {
        'use strict';

        ko.uid = 0;
        ko.setTemplateEngine(templateEngine);
    });
</script>
<script>
    require(['Magento_PageBuilder/js/master-format/render/frame'], function (listen) {
        listen(<?= /* @noEscape */ $block->getPageBuilderConfig(); ?>);
    });
</script>
<div>Page Builder Render Frame</div>
