import json

from django.templatetags.static import static

from wagtailtinymce.rich_text import TinyMCERichTextArea


class DigiHelTinyMCERichTextArea(TinyMCERichTextArea):
    plugins = [
        'anchor',
        'autolink',
        'charmap',
        'code',
        'codesample',
        'contextmenu',
        'definitionlist',
        'directionality',
        'emoticons',
        'fullscreen',
        'hr',
        'image',
        'imagetools',
        'insertdatetime',
        'link',
        'lists',
        'media',
        'nonbreaking',
        'pagebreak',
        'paste',
        'preview',
        'print',
        'searchreplace',
        'table',
        'template',
        'textpattern',
        'visualblocks',
        'visualchars',
        'wordcount',
    ]
    style_formats = [
        {
            'title': 'Additional info',
            'block': 'div',
            'classes': 'more-info'
        }
    ]
    default_buttons = [
        [
            ['undo', 'redo'],
            ['styleselect'],
            ['bold', 'italic'],
            ['bullist', 'numlist', 'ToggleDefinitionList', 'ToggleDefinitionItem', 'outdent', 'indent'],
            ['table'],
            ['link', 'unlink'],
            ['wagtaildoclink', 'wagtailimage', 'wagtailembed'],
            ['pastetext', 'fullscreen'],
            ['termlink'],
        ],
    ]
    default_options = {
        'image_advtab': True,
        'browser_spellcheck': True,
        'noneditable_leave_contenteditable': True,
        'language': 'en',
        'language_load': True,
        'content_css': []
    }

    def build_js_init_arguments(self):
        args = super(DigiHelTinyMCERichTextArea, self).build_js_init_arguments()
        args.update(
            plugins=self.plugins,
        )
        args.pop('menubar', None)  # Always enable the menubar
        args['content_css'].append(static('css/tinymce-content.css'))
        args['skin'] = 'wagtail'
        args['height'] = 600
        args['style_formats'] = [
            {'title': 'Additional info','block': 'section','classes': 'more-info', 'wrapper': 'true'},
            {'title': 'Document link','inline': 'span','classes': 'document-link'},
        ]
        args['style_formats_merge'] = True
        args['extended_valid_elements'] = 'div[class]'
        return args

@@ -2325,8 +2325,1597 @@
 rn args%0A
+%0A    @classmethod%0A    def getDefaultArgs(cls):%0A        args = super(DigiHelTinyMCERichTextArea, cls).getDefaultArgs()%0A        args%5B'options'%5D = cls.default_options%0A        args%5B'height'%5D = 600%0A        args%5B'style_formats'%5D = %5B%0A            %7B'title': 'Additional info', 'block': 'section', 'classes': 'more-info', 'wrapper': 'true'%7D,%0A            %7B'title': 'Document link', 'inline': 'span', 'classes': 'document-link'%7D,%0A        %5D%0A        args%5B'style_formats_merge'%5D = True%0A        args%5B'extended_valid_elements'%5D = 'div%5Bclass%5D'%0A        args%5B'plugins'%5D = cls.plugins%0A        return args%0A%0A    def render_js_init(self, id_, name, value):%0A        kwargs = self.kwargs.copy()%0A%0A        if 'buttons' in self.kwargs:%0A            if self.kwargs%5B'buttons'%5D is False:%0A                kwargs%5B'toolbar'%5D = False%0A            else:%0A                kwargs%5B'toolbar'%5D = %5B%0A                    ' %7C '.join(%5B' '.join(groups) for groups in rows%5D)%0A                    for rows in self.kwargs%5B'buttons'%5D%0A                %5D%0A%0A        if 'menus' in self.kwargs:%0A            if self.kwargs%5B'menus'%5D is False:%0A                kwargs%5B'menubar'%5D = False%0A            else:%0A                kwargs%5B'menubar'%5D = ' '.join(self.kwargs%5B'menus'%5D)%0A%0A        if 'passthru_init_keys' in self.kwargs:%0A            kwargs.update(self.kwargs%5B'passthru_init_keys'%5D)%0A%0A        if 'table' in self.kwargs:%0A            for key, values in self.kwargs%5B'table'%5D.items():%0A                kwargs%5Bf'table_%7Bkey%7D'%5D = values%0A%0A        kwargs.pop('menubar', None)%0A%0A        return %22makeTinyMCEEditable(%7B0%7D, %7B1%7D);%22.format(json.dumps(id_), json.dumps(kwargs))

Set old definitions back to TinyMCE