On Saturday 03 June 2017 09:51:12 Ryne Everett wrote:
> > 2) Implement the approach to RichTextField and global editor
> > configuration from django- ckeditor, but leave TinyMCE as default.
> > Introducing as little incompatibilities as possible would be the
> > hard part.
> 
> Sounds like #2 is the approach for improving the core project, though
> creating a third-party mezzanine-ckeditor project would also be
> useful.

Drawbacks of third-party outlined in answer to Ken.

> Could you expand (perhaps with a code sample) on how django-ckeditor
> makes inline RichTextField configuration easier than Mezzanine?

So, benefits for the core project, as I see them now:

settings.py:

RICHTEXT_EDITOR_CONFIGS = {
    'default': {
        'toolbar_Standard': [
            ['Styles', 'Format', 'NumberedList', 'BulletedList', '-',
             'Outdent', 'Indent', '-', 'Bold', 'Italic', 'Underline', 'Strike',
             'SpellChecker', 'Undo', 'Redo', '-', 'RemoveFormat'],
            ['Link', 'Unlink', 'Anchor'],
            ['Image', 'Table', 'HorizontalRule'],
            ['TextColor', 'BGColor'],
            ['Smiley', 'SpecialChar'], ['Source'],
        ],
        'toolbar': 'Standard',
        'height': '20em',
        'width': '100%',
        'skin': 'moono-lisa',
    },
    '*inline*': {
        'toolbar_Inline': [
            ['Bold', 'Italic', 'Underline', 'Strike'],
            ['Undo', 'Redo', '-', 'RemoveFormat'],
            ['TextColor', 'BGColor'],
            ['Link', 'Unlink'],
            ['Smiley', 'SpecialChar'], ['Source'],
        ],
        'toolbar': 'Inline',
        'forcePasteAsPlainText': True,
        'skin': 'moono-lisa',
        'height': '10em',
        'width': '100%',
    }
}

Options here are specific to chosen editor, but the idea is that there's one 
central place to 
define different configurations that maps to the editor's configuration. This 
could be expanded 
by adding an extra outer dict layer that maps to the editor name - allowing 
different 
configurations to exist for different editors.In theory (but I think also in 
practice) that would 
allow request.user to pick it's favorite editor.

So something like:

RICHTEXT_EDITOR_CONFIGS = {
    'tinymce': {
        'enabled': True,  # Admin control
        'configs': {
            # config dicts here
        },
        'default': True,  # Site-wide default
    },
    'ckeditor': {
        # etc.
    }
}

Then one chooses the configuration by name from RichTextField:

class FaqEntry(models.Model):
    question = models.CharField(
        max_length=127, verbose_name=_('question'), db_index=True,
    )
    answer = RichTextField(
        verbose_name=_('answer'), config_name=*'inline*',
    )

P.S. Once you've built such a config dict, you typically copy it from project 
to project, adding 
configs as needed, so it really isn't as daunting to create as it looks.

-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to