{% load i18n %}

<form action="{% url "spirit:comment:publish" topic_id %}" method="post" class="js-reply">
  {% csrf_token %}
  {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}

  {{ form.non_field_errors }}

  {% for field in form %}
    {{ field.errors }}
    {{ field }}
  {% endfor %}

  {% include "spirit/comment/_editor_preview.html" %}

  <div class="comment__reply__actions">
    {% include "spirit/comment/_editor.html" %}

    <input
      class="button comment__reply__actions__publish"
      type="submit"
      value="{% trans "Publish" %}" />
  </div>
</form>

<script>
  document.addEventListener('DOMContentLoaded', function() {

    stModules.store(
      document.querySelector('.js-reply').querySelector('textarea'),
      'comment-thread-{{ topic_id }}'
    );

  });
</script>
