No regular expressions were active.
1 |
|
/**
|
|
1 |
|
/**
|
2 |
|
*
$Id:
editor_plu
gin_src.js
4
2
200
6
-0
8
-
08
1
4:3
2
:
24
Z
spocke
$
|
|
2 |
|
*
$Id:
editor_plu
gin_src.js
2
01
200
7
-0
2
-
1
2
15
:
56:56
Z
spocke
$
|
3 |
|
*
|
|
3 |
|
*
|
4 |
|
* @author
Moxiecode
|
|
4 |
|
* @author
Moxiecode
|
5 |
|
*
@copyright
Copyright
©
2004-200
7
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
|
5 |
|
*
@copyright
Copyright
©
2004-200
8
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
6 |
|
*/
|
|
6 |
|
*/
|
7 |
|
|
|
7 |
|
|
8 |
|
/* Import
plugin spe
cific lang
uage pack
*/
|
|
8 |
|
(function(
) {
|
9 |
|
tinyMCE.im
portPlugin
LanguagePa
ck('visual
chars');
|
|
9 |
|
tinymc
e.create('
tinymce.pl
ugins.Visu
alChars',
{
|
|
|
10 |
|
in
it : funct
ion(ed, ur
l) {
|
|
|
11 |
|
var t =
this;
|
|
|
12 |
|
|
|
|
13 |
|
t.editor
= ed;
|
|
|
14 |
|
|
|
|
15 |
|
// Regis
ter comman
ds
|
|
|
16 |
|
ed.addCo
mmand('mce
VisualChar
s', t._tog
gleVisualC
hars, t);
|
|
|
17 |
|
|
|
|
18 |
|
// Regis
ter button
s
|
|
|
19 |
|
ed.addBu
tton('visu
alchars',
{title : '
visualchar
s.desc', c
md : 'mceV
isualChars
'});
|
|
|
20 |
|
|
|
|
21 |
|
ed.onBef
oreGetCont
ent.add(fu
nction(ed,
o) {
|
|
|
22 |
|
if (
t.state) {
|
|
|
23 |
|
t.state =
true;
|
|
|
24 |
|
t._toggleV
isualChars
();
|
|
|
25 |
|
}
|
|
|
26 |
|
});
|
|
|
27 |
|
},
|
10 |
|
|
|
28 |
|
|
11 |
|
var TinyMC
E_VisualCh
arsPlugin
= {
|
|
|
12 |
|
getInf
o : functi
on() {
|
|
29 |
|
ge
tInfo : fu
nction() {
|
13 |
|
re
turn {
|
|
30 |
|
return {
|
14 |
|
longname
: 'Visual
character
s',
|
|
31 |
|
long
name : 'Vi
sual chara
cters',
|
15 |
|
author :
'Moxiecod
e Systems
AB',
|
|
32 |
|
auth
or : 'Moxi
ecode Syst
ems AB',
|
16 |
|
authorur
l : 'http:
//tinymce.
moxiecode.
com',
|
|
33 |
|
auth
orurl : 'h
ttp://tiny
mce.moxiec
ode.com',
|
17 |
|
infourl
: 'http://
wiki.moxie
code.com/i
ndex.php/T
inyMCE:Plu
gins/visua
lchars',
|
|
34 |
|
info
url : 'htt
p://wiki.m
oxiecode.c
om/index.p
hp/TinyMCE
:Plugins/v
isualchars
',
|
18 |
|
version
:
tiny
MCE
.majorVers
ion
+
"."
+
tiny
MCE
.minorVers
ion
|
|
35 |
|
version
:
tiny
mce
.majorVers
ion
+
"."
+
tiny
mce
.minorVers
ion
|
19 |
|
};
|
|
36 |
|
};
|
20 |
|
},
|
|
37 |
|
},
|
21 |
|
|
|
38 |
|
|
22 |
|
initIn
stance : f
unction(in
st) {
|
|
39 |
|
//
Private m
ethods
|
23 |
|
in
st.visualC
hars = {
|
|
|
24 |
|
state :
false
|
|
|
25 |
|
};
|
|
|
26 |
|
},
|
|
|
27 |
|
|
|
|
28 |
|
getCon
trolHTML :
function(
cn) {
|
|
|
29 |
|
sw
itch (cn)
{
|
|
|
30 |
|
case "vi
sualchars"
:
|
|
|
31 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_visua
lchars_des
c', '{$plu
ginurl}/im
ages/visua
lchars.gif
', 'mceVis
ualChars',
false);
|
|
|
32 |
|
}
|
|
|
33 |
|
|
|
|
34 |
|
re
turn "";
|
|
|
35 |
|
},
|
|
|
36 |
|
|
|
|
37 |
|
execCo
mmand : fu
nction(edi
tor_id, el
ement, com
mand, user
_interface
, value) {
|
|
|
38 |
|
va
r inst = t
inyMCE.get
InstanceBy
Id(editor_
id);
|
|
|
39 |
|
|
|
40 |
|
|
40 |
|
sw
itch (comm
and) {
|
|
41 |
|
_toggleVis
ualChars
:
func
t
i
o
n
(
)
{
|
41 |
|
case "mc
eVisualCha
rs":
|
|
42 |
|
var t =
this, ed =
t.editor,
nl, i, h,
d = ed.ge
tDoc(), b
= ed.getBo
dy(), nv,
s = ed.sel
ection, bo
;
|
42 |
|
this.
_toggleVis
ualChars
(edi
t
or_id,
i
n
st
)
;
|
|
|
43 |
|
retu
rn true;
|
|
|
44 |
|
}
|
|
|
45 |
|
|
|
|
46 |
|
re
turn false
;
|
|
|
47 |
|
},
|
|
|
48 |
|
|
|
|
49 |
|
cleanu
p : functi
on(type, c
ontent, in
st) {
|
|
|
50 |
|
if
(type ==
"insert_to
_editor_do
m" || type
== "get_f
rom_editor
_dom") {
|
|
|
51 |
|
inst.vis
ualChars.s
tate = tru
e;
|
|
|
52 |
|
this._to
ggleVisual
Chars(inst
.editorId,
inst);
|
|
|
53 |
|
}
|
|
|
54 |
|
|
|
|
55 |
|
re
turn conte
nt;
|
|
|
56 |
|
},
|
|
|
57 |
|
|
|
43 |
|
|
58 |
|
// Pri
vate plugi
n internal
methods
|
|
44 |
|
t.state
= !t.state
;
|
|
|
45 |
|
ed.contr
olManager.
setActive(
'visualcha
rs', t.sta
te);
|
59 |
|
|
|
46 |
|
|
60 |
|
_toggl
eVisualCha
rs : funct
ion(editor
_id, inst)
{
|
|
47 |
|
if
(
t.
state)
{
|
61 |
|
va
r nl, i, h
, d = inst
.getDoc(),
b = inst.
getBody(),
nv, s = i
nst.select
ion, bo;
|
|
48 |
|
nl =
[];
|
62 |
|
|
|
49 |
|
tiny
mce.walk(b
, function
(n) {
|
63 |
|
in
st.visualC
hars.state
= !inst.v
isualChars
.state;
|
|
50 |
|
i
f
(n
.nodeType
==
3
&&
n.nodeValu
e
&&
n.nodeValu
e.indexOf(
'\u00a0')
!=
-1
)
|
64 |
|
|
|
51 |
|
nl.pus
h(n);
|
65 |
|
bo
= s.getBo
okmark(tru
e);
|
|
52 |
|
}, '
childNodes
');
|
66 |
|
|
|
|
67 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_visualch
ars', inst
.visualCha
rs.state ?
'mceButto
nSelected'
: 'mceBut
tonNormal'
);
|
|
|
68 |
|
|
|
|
69 |
|
if
(
ins
t.
visualChar
s.
state)
{
|
|
|
70 |
|
nl
=
t
i
nyMCE.sele
ctNodes(b,
f
unction
(n
)
{return
n
.nodeType
==
3
&&
n.nodeValu
e
&&
n.nodeValu
e.indexOf(
'\u00a0')
!=
-1
;}
)
;
|
|
|
71 |
|
|
|
53 |
|
|
72 |
|
for (i=0
; i<nl.len
gth; i++)
{
|
|
54 |
|
for
(i=0; i<nl
.length; i
++) {
|
73 |
|
nv =
nl[i].nod
eValue;
|
|
55 |
|
nv = nl[i]
.nodeValue
;
|
74 |
|
nv
=
nv.replace
(/(\u00a0+
)/g,
'<span
class="mce
ItemHidden
Visual
Char
">$1</span
>');
|
|
56 |
|
nv
=
nv.replace
(/(\u00a0+
)/g,
'<span
class="mce
ItemHidden
mce
Visual
Nbsp
">$1</span
>');
|
75 |
|
nv =
nv.replac
e(/\u00a0/
g, '\u00b7
');
|
|
57 |
|
nv = nv.re
place(/\u0
0a0/g, '\u
00b7');
|
76 |
|
tinyMCE
.setOuterH
TML(nl[i],
nv,
d);
|
|
58 |
|
ed.dom
.setOuterH
TML(nl[i],
nv,
d);
|
77 |
|
}
|
|
59 |
|
}
|
78 |
|
}
else {
|
|
60 |
|
} else {
|
79 |
|
nl = tin
yMCE.selec
tNodes(b,
function(n
) {return
n.nodeType
== 1 && n
.nodeName
== 'SPAN'
&& n.class
Name == 'm
ceItemHidd
enVisualCh
ar';});
|
|
61 |
|
nl =
tinymce.g
rep(ed.dom
.select('s
pan', b),
function(n
) {
|
|
|
62 |
|
return ed.
dom.hasCla
ss(n, 'mce
VisualNbsp
');
|
|
|
63 |
|
});
|
80 |
|
|
|
64 |
|
|
81 |
|
for (i=0
; i<nl.len
gth; i++)
|
|
65 |
|
for
(i=0; i<nl
.length; i
++)
|
82 |
|
tinyMCE
.setOuterH
TML(nl[i],
nl[i].inne
rHTML.repl
ace(/(&mid
dot;|\u00b
7)/g,
' '),
d);
|
|
66 |
|
ed.dom
.setOuterH
TML(nl[i],
nl[i].inne
rHTML.repl
ace(/(&mid
dot;|\u00b
7)/g,
' '),
d);
|
83 |
|
}
|
|
67 |
|
}
|
84 |
|
|
|
|
85 |
|
//
s.moveToBo
okmark(bo)
;
|
|
|
86 |
|
}
|
|
68 |
|
}
|
87 |
|
}
;
|
|
69 |
|
}
)
;
|
88 |
|
|
|
70 |
|
|
89 |
|
tiny
MCE
.
add
Plugin
(
"
visualchar
s
"
,
T
iny
MCE_
VisualChar
s
Plugin
);
|
|
71 |
|
// Reg
ister plug
in
|
|
|
72 |
|
tiny
mce
.
Plugin
Manager.ad
d
(
'
visualchar
s
'
,
t
iny
mce.plugin
s.
VisualChar
s
);
|
|
|
73 |
|
})();
|