Add space before characters while typing in TinyMCE

I’m trying to achieve a MS-Word-like management for non-breaking spaces before some characters:

While typing, automatically add non-breaking space before ?, !, : etc. (or replace normal space with non-breaking), or add space after «, etc. (which are rules in French, for e.g.).

Read More

I was doing this in PHP before displaying the content, but it should be much better to have it directly in the Wysiwyg.

Cannot find any plugin / ways to achieve that. Suggestions?

Thanks!

Related posts

1 comment

  1. You can add a tinymce event on keydown (just add setup to your tinymce config parameters):

    ....
    plugins : 'popup1, popup2,...',
    setup : function(ed) {
        //register event handler
        ed.onKeyDown.add(function onkeydown(ed, e)
        {
            // example for '!'
            if(e.charCode == 49 && evt.shiftKey)
            {
                ed.execCommand('insertHTML', false, ' ');
            }
        });
    }
    

Comments are closed.