class CKEditor5::Rails::Editor::InlinePluginWindowInitializer

def initialize(plugin)

def initialize(plugin)
  @plugin = plugin
end

def to_html(nonce: nil)

def to_html(nonce: nil)
  code = wrap_with_handlers(@plugin.code)
  tag.script(code.html_safe, nonce: nonce)
end

def wrap_with_handlers(code)

def wrap_with_handlers(code)
  <<~JS
    window.addEventListener('ckeditor:request-cjs-plugin:#{@plugin.name}', () => {
      window['#{@plugin.name}'] = #{code.html_safe};
    }, { once: true });
  JS
end