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