{% extends "admin/change_form.html" %}

{% block extrahead %}
    {{ block.super }}
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.2/codemirror.min.css"
          integrity="sha256-I8NyGs4wjbMuBSUE40o55W6k6P7tu/7G28/JGUUYCIs=" crossorigin="anonymous"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.2/theme/mdn-like.min.css"
          integrity="sha256-NOY3wYv+L8FgjrwUjZgi4StO4CvnI8F+NxQwFhhstH8=" crossorigin="anonymous"/>
{% endblock %}

{% block admin_change_form_document_ready %}
    {{ block.super }}

    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.2/codemirror.min.js"
            integrity="sha256-hY4lHTn7c3QSwGpgxj3OAYynw9Etpx530BNJHTmhvYA=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.2/addon/mode/overlay.min.js"
            integrity="sha256-pmk+B8h8zI8asluOrjNTCKvDypYYKOYVmvmhwPDaYl0=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.2/mode/django/django.min.js"
            integrity="sha256-nLr6+psgWgm4BnA7O+W9T0gldFRHCI+H3cByx/TSabE=" crossorigin="anonymous"></script>

    <script>
      (function($) {
        var options = {
            mode: 'django',
            theme: "mdn-like",
            lineWrapping: true
        };

        CodeMirror.fromTextArea($('#id_subject')[0], options);
        CodeMirror.fromTextArea($('#id_content')[0], options);
        CodeMirror.fromTextArea($('#id_html_content')[0], options);

        $('.CodeMirror').css('height', 'auto');
      })(django.jQuery);
    </script>
{% endblock %}

