cancel
Showing results for 
Search instead for 
Did you mean: 

TinyMCE and escape characters

camozzi
Champ in-the-making
Champ in-the-making
I've been having an issue with alfresco and escape characters, but only for on specific instance. In my web forms I have text areas that use the TinyMCE editor. To enter code like the copyright symbol, I have added the option to edit the html so I can put in the escape sequence &copyright; . I have to do it this way, because just putting the symbol on the editor causes some weird results on the pages themselves (i.e. strange symbols).    Most of the escape sequences work, but when I do the escape seq. for registered trade mark (® or even the numeric equivalent), TinyMCE seems to convert the symbol to its actual value - causes a display issue on the page. Has anyone encountered this issue? Can anyone help? Thanks!   -Jeff
1 REPLY 1

camozzi
Champ in-the-making
Champ in-the-making
After contacting support I've learned this is a known issue. So, I made my own solution using javascript. My code may not be the prettiest, but it should get the point across:


<script type="text/javascript">
var escapeCharacters = ['reg;',
                        'trade;',
                        'copy;'
                        ];


window.addEvent('domready', function() {
            parseEscapeSymbols();   
});

function parseEscapeSymbols() {
    var ampString = '&amp;';
    var testSymbol;

    var currentHTML;
   
    for (var i = 0; i < escapeCharacters.length; i++) {
        testSymbol = ampString + escapeCharacters[i];
        currentHTML = document.body.innerHTML;
        document.body.innerHTML = currentHTML.replace(testSymbol, '&' + escapeCharacters[i]);
    }
}

</script>

When you edit the text in tinymce, you can simply type the escape character right in there. (I.e. I type "&reg;" while I'm editing text). TinyMCE converts this to "&amp;reg;". Knowing this, I can grab the body text of the HTML document after it loads, and replace all instances of &amp;<symbol>; with the proper symbol. For my uses I only needed to replace three, but the escapeCharacters array can be expanded to whatever is needed.

-Jeff
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.