Changing default richtext editor

66 views
Skip to first unread message

marty3d

unread,
Feb 9, 2013, 3:36:51 PM2/9/13
to django-...@googlegroups.com
Sorry if this is a repost, it seems like my previous attempt was deleted/disappeared into cyberspace :(

Anyway, I would like to know if anyone has been successful in switching from TinyMCE to, say Wymeditor in the admin? And if so, how did you do that? I changed the variables FEINCMS_RICHTEXT_INIT_CONTEXT and FEINCMS_RICHTEXT_INIT_TEMPLATE like this:

FEINCMS_RICHTEXT_INIT_CONTEXT = {
   
'WYMEDITOR_JS_URL': STATIC_URL + 'js/lib/wymeditor-0.5/jquery.wymeditor.min.js',
   
}
FEINCMS_RICHTEXT_INIT_TEMPLATE
= os.path.join(SITE_ROOT, 'cms/templates/admin/content/richtext/init_wymeditor.html')



and the template is:

<script type="text/javascript" src="{{ WYMEDITOR_JS_URL }}"></script>

<script type="text/javascript">
    $
(document).ready(function(){
        $
('.item-richtext').wymeditor();
   
});
</script>



This almost work. I get the editor in the admin, but when saving, the newly entered text is not saved. Mind you, I never been a friend with customizing the Django admin...

Thank you!


Martin J. Laubach

unread,
Feb 10, 2013, 3:58:15 AM2/10/13
to django-...@googlegroups.com
I remember there being something similar with the tinymce plugin, ie. changes not being saved. IIRC it had something to do with transforming the richtext fields back to normal textareas before saving or else the django admin would not pick up the changes. Perhaps have a look at the poorify_rich function, that' s the one that gets called just before saving...

mjl

Matthias Kestenholz

unread,
Feb 11, 2013, 11:31:47 AM2/11/13
to FeinCMS
Hi


On Sat, Feb 9, 2013 at 9:36 PM, marty3d <martin.k...@gmail.com> wrote:
Sorry if this is a repost, it seems like my previous attempt was deleted/disappeared into cyberspace :(


I seeing this issue as well, but cannot find the code I used to fix it back then. Anyway, here's some good advice which should help you fix that problem:

http://stackoverflow.com/questions/615203/wymeditor-wont-reflect-contents-into-textarea-value


HTH,
Matthias

marty3d

unread,
Feb 11, 2013, 12:57:26 PM2/11/13
to django-...@googlegroups.com
Thank you Martin and Matthias!

So, here's what I did to make it work (in case anyone else want to try it)

settings.py:
FEINCMS_RICHTEXT_INIT_CONTEXT = {
    'TINYMCE_JS_URL': STATIC_URL + 'js/lib/tiny_mce-3.4.7/tiny_mce.js',
    'WYMEDITOR_JS_URL': STATIC_URL + 'js/lib/wymeditor-0.5/jquery.wymeditor.min.js',
    }
FEINCMS_RICHTEXT_INIT_TEMPLATE = os.path.join(SITE_ROOT, 'cms/templates/admin/content/richtext/init_wymeditor.html')

init_wymeditor.html:
<script src="{{ WYMEDITOR_JS_URL }}"></script>

<script>
    (function($){
        contentblock_init_handlers.push(function(){
            $('{% block selectors %}.order-machine textarea.item-richtext:not(.wym), #frontend_editor textarea.item-richtext:not(.wym){% endblock %}').each(function(){
                    $(this).addClass('wym').wymeditor({
                        updateSelector: ".submit-row input",
                        updateEvent: "click"
                    });
                });        
        });
    })(feincms.jQuery);
</script>

Also, drinking coffee and have enough sleep certainly helps! :)
Reply all
Reply to author
Forward
0 new messages