How to use the martor.widgets.MartorWidget function in martor

To help you get started, we’ve selected a few martor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github agusmakmun / django-markdown-editor / martor / fields.py View on Github external
def __init__(self, *args, **kwargs):

        # to setup the editor without label
        if not MARTOR_ENABLE_LABEL:
            kwargs['label'] = ''

        super(MartorFormField, self).__init__(*args, **kwargs)

        if not issubclass(self.widget.__class__, MartorWidget):
            self.widget = MartorWidget()
github agusmakmun / django-markdown-editor / martor / widgets.py View on Github external
# Make sure that the martor value is in the class attr passed in
        if 'class' in attrs:
            attrs['class'] += ' martor'
        else:
            attrs['class'] = 'martor'

        # Update and overwrite with the attributes passed in
        attributes_to_pass.update(attrs)

        # Update and overwrite with any attributes that are on the widget
        # itself. This is also the only way we can push something in without
        # being part of the render chain.
        attributes_to_pass.update(self.attrs)

        widget = super(MartorWidget, self).render(name,
                                                  value,
                                                  attributes_to_pass)

        template = get_template('martor/editor.html')

        return template.render({
            'martor': widget,
            'field_name': name
        })
github agusmakmun / django-markdown-editor / martor / widgets.py View on Github external
js = (
            'plugins/js/ace.js',
            'plugins/js/semantic.min.js',
            'plugins/js/mode-markdown.js',
            'plugins/js/ext-language_tools.js',
            'plugins/js/theme-github.js',
            'plugins/js/highlight.min.js',
            'plugins/js/resizable.min.js',
            'plugins/js/emojis.min.js',
            'martor/js/martor.min.js',
        )
        if MARTOR_ENABLE_CONFIGS['jquery'] == 'true':
            js = ('plugins/js/jquery.min.js',).__add__(js)


class AdminMartorWidget(MartorWidget, widgets.AdminTextareaWidget):
    pass
github agusmakmun / django-markdown-editor / martor / fields.py View on Github external
def __init__(self, *args, **kwargs):

        # to setup the editor without label
        if not MARTOR_ENABLE_LABEL:
            kwargs['label'] = ''

        super(MartorFormField, self).__init__(*args, **kwargs)

        if not issubclass(self.widget.__class__, MartorWidget):
            self.widget = MartorWidget()