1 |
|
tiny
MCE
.
i
m
p
ortP
lugin
L
a
n
g
u
a
g
e
P
a
ck
('
v
isual
c
hars'
);
v
ar
T
i
nyMCE_
VisualChar
s
Pl
u
g
i
n
=
{
getInfo:fu
nction(){r
eturn{long
name:'Visu
al
characters
',author:'
Moxiecode
Systems
AB',author
url:'http:
//tinymce.
moxiecode.
com',infou
rl:'http:/
/wiki.moxi
ecode.com/
index.php/
TinyMCE:Pl
ugins/visu
alchars',v
ersion:tin
y
MCE
.majorVers
ion+"."+ti
ny
MCE
.minorVers
ion}
},
initInstan
ce:functio
n(inst){in
st.visualC
hars={stat
e:false}},
getControl
HTML:funct
ion(cn){sw
itch(cn){c
ase"visual
chars":ret
urn
tinyMCE.ge
tBut
to
nHTML(cn,'
lang_visua
lchars_des
c','{$plu
g
inurl}/ima
g
es/visua
l
chars.gif'
,'mc
eVisualCha
rs
',false)}r
eturn""},e
xecCommand
:function(
editor_id,
element,co
mmand,user
_interface
,value
){var
ins
t=t
inyMCE.get
InstanceBy
Id(editor_
id);switch
(command){
case"mceVi
sualChars"
:this._tog
gleVisualC
h
ars(editor
_
i
d,inst);re
turn
true}retur
n
fal
s
e}
,
cleanup:fu
nction(typ
e,content,
inst){if(t
ype=="inse
rt_to_
ed
itor_dom"|
|type=
=
"get_from_
editor_dom
"){ins
t.
visualChar
s.state=tr
ue;this._t
oggleVisua
lChars(ins
t.editorId
,inst)}ret
urn
content},_
toggleVisu
alChars:fu
nction(
editor
_id
,
inst){var
nl,i,h,d=
inst
.getDoc(),
b=
inst
.getBody()
,nv,s=
inst
.selection
,bo;
ins
t.
visualChar
s.
state=!
ins
t.
visualChar
s.
state;
bo=s.g
e
tBo
o
kmark(
tr
ue);tiny
M
CE
.s
wi
t
c
hClass(edi
t
or_
i
d+
'
_
visualchar
s',
ins
t.
visualChar
s.
state
?'mceButto
nSelected'
:'mceButto
nNormal'
);if(
ins
t.
visualChar
s.
state){nl=
tiny
MCE.sele
c
tNod
e
s
(b,functio
n(n){
return
n.nodeType
==3&&n.nod
eValue&&n.
nodeValue.
indexOf('\
u00a0')!=-
1
}
);for(i=0;
i<nl.lengt
h;i++){nv=
nl[i].node
Value;nv=n
v.replace(
/(\u00a0+)
/g,'<span
class="mce
ItemHidden
Visual
Char
">$1</span
>');nv=nv.
replace(/\
u00a0/g,'\
u00b7');
tinyMCE
.setOuterH
TML(nl[i],
nv,d)
}}else{nl=
tiny
MCE
.select
Nodes
(
b
,function(
n){return
n.nodeTyp
e
==1&&n
.
no
d
eNa
m
e=='SPAN'&
&n
.
c
lass
Name==
'mce
ItemHidden
Visual
Char
'
});for(i=0
;i<nl.leng
th;i++)
tinyMCE
.setOuterH
TML(nl[i],
nl[i].inne
rHTML.repl
ace(/(&mid
dot;|\u00b
7)/g,'&nbs
p;'),d)
}}}
;tiny
MCE
.
add
Plugin
(
"
visualchar
s
"
,
T
iny
MCE_
VisualChar
s
Plugin
);
|
|
1 |
|
(function(
){
tiny
mce
.
create('t
i
ny
m
ce.
p
lugin
s.Visu
a
lChars',{i
n
it:f
u
nction(ed,
url){v
a
r
t=this;t.
e
ditor=ed;e
d.
a
ddCommand
('
mceV
isual
C
hars'
,t._toggle
VisualChar
s,t
);
ed.addButt
on('
v
isualch
ar
s',{t
i
tle:'visua
lchars.des
c',cmd:'mc
e
VisualChar
s
'});ed.onB
eforeGetCo
ntent.add(
f
u
nct
i
o
n
(ed,o){if(
t.state)
{
t.state=tr
ue;t._togg
leVisualCh
ars();}});
},
getInfo:fu
nction(){r
eturn{long
name:'Visu
al
characters
',author:'
Moxiecode
Systems
AB',author
url:'http:
//tinymce.
moxiecode.
com',infou
rl:'http:/
/wiki.moxi
ecode.com/
index.php/
TinyMCE:Pl
ugins/visu
alchars',v
ersion:tin
y
mce
.majorVers
ion+"."+ti
ny
mce
.minorVers
ion}
;
},
_
to
g
g
l
eVisualCha
rs
:function(
){var
t=t
h
i
s
,
ed
=
t.
editor
,
nl,i,h,d=
ed
.getDoc(),
b=
ed
.getBody()
,nv,s=
ed
.selection
,bo;
t.
state=!
t.
state;
e
d.c
o
n
tr
ol
M
anager
.s
e
t
A
c
t
i
ve(
'
visualchar
s',
t.
state
);if(
t.
state){nl=
[];
tiny
m
c
e
.walk
(b,functio
n(n){
if(
n.nodeType
==3&&n.nod
eValue&&n.
nodeValue.
indexOf('\
u00a0')!=-
1
)nl.push(n
);
}
,'childNod
es'
);for(i=0;
i<nl.lengt
h;i++){nv=
nl[i].node
Value;nv=n
v.replace(
/(\u00a0+)
/g,'<span
class="mce
ItemHidden
mce
Visual
Nbsp
">$1</span
>');nv=nv.
replace(/\
u00a0/g,'\
u00b7');
ed.dom
.setOuterH
TML(nl[i],
nv,d)
;
}}else{nl=
tiny
mce.grep(e
d.dom
.select
(
'span',
b
)
,function(
n){return
e
d
.
d
o
m
.
hasC
lass
(n,
'mce
Visual
Nbsp
'
);
});for(i=0
;i<nl.leng
th;i++)
ed.dom
.setOuterH
TML(nl[i],
nl[i].inne
rHTML.repl
ace(/(&mid
dot;|\u00b
7)/g,'&nbs
p;'),d)
;
}}}
)
;tiny
mce
.
Plugin
Manager.ad
d
(
'
visualchar
s
'
,
t
iny
mce.plugin
s.
VisualChar
s
);})(
);
|