{% load grapesjs_tags %}

<textarea hidden name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>
{% if widget.value %}{{ widget.value|safe }}{% else %}{{ widget.get_render_html_value|safe }}{% endif %}</textarea>
<div hidden name='get-all-id'>{{ widget.attrs.id }}</div>
<div id="gjs-{{ widget.attrs.id }}"></div>

<script type="text/javascript">
  var editor_{{ widget.attrs.id }} = grapesjs.init({
      container : '#gjs-{{ widget.attrs.id }}',
      style: '.txt-red{color: red}',
      plugins: ['gjs-preset-newsletter'],
      pluginsOpts: {
        'gjs-preset-newsletter': {
          modalTitleImport: 'Import template',
        }
      }
  });

  if ({% get_default_models_data %}) {
      editor_{{ widget.attrs.id }}.setComponents(document.getElementById("{{ widget.attrs.id }}").value);
  }

</script>


