4 * Copyright 2009, Moxiecode Systems AB
5 * Released under LGPL License.
7 * License: http://tinymce.moxiecode.com/license
8 * Contributing: http://tinymce.moxiecode.com/contributing
12 tinymce.create('tinymce.plugins.VisualChars', {
13 init : function(ed, url) {
19 ed.addCommand('mceVisualChars', t._toggleVisualChars, t);
22 ed.addButton('visualchars', {title : 'visualchars.desc', cmd : 'mceVisualChars'});
24 ed.onBeforeGetContent.add(function(ed, o) {
25 if (t.state && o.format != 'raw' && !o.draft) {
27 t._toggleVisualChars(false);
32 getInfo : function() {
34 longname : 'Visual characters',
35 author : 'Moxiecode Systems AB',
36 authorurl : 'http://tinymce.moxiecode.com',
37 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualchars',
38 version : tinymce.majorVersion + "." + tinymce.minorVersion
44 _toggleVisualChars : function(bookmark) {
45 var t = this, ed = t.editor, nl, i, h, d = ed.getDoc(), b = ed.getBody(), nv, s = ed.selection, bo, div, bm;
48 ed.controlManager.setActive('visualchars', t.state);
55 tinymce.walk(b, function(n) {
56 if (n.nodeType == 3 && n.nodeValue && n.nodeValue.indexOf('\u00a0') != -1)
60 for (i = 0; i < nl.length; i++) {
62 nv = nv.replace(/(\u00a0)/g, '<span data-mce-bogus="1" class="mceItemHidden mceItemNbsp">$1</span>');
64 div = ed.dom.create('div', null, nv);
65 while (node = div.lastChild)
66 ed.dom.insertAfter(node, nl[i]);
71 nl = ed.dom.select('span.mceItemNbsp', b);
73 for (i = nl.length - 1; i >= 0; i--)
74 ed.dom.remove(nl[i], 1);
82 tinymce.PluginManager.add('visualchars', tinymce.plugins.VisualChars);