No regular expressions were active.
1 |
|
/**
|
|
1 |
|
/**
|
2 |
|
*
$Id:
editor_plu
gin_src.js
201
200
7
-0
2
-
1
2
15
:
56
:
56
Z
spocke
$
|
|
2 |
|
*
$Id:
editor_plu
gin_src.js
686
200
8
-0
3
-
09
1
8
:
13
:
49
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 |
|
tinyMCE.im
portPlugin
LanguagePa
ck('search
replace');
|
|
8 |
|
(function(
) {
|
|
|
9 |
|
tinymc
e.create('
tinymce.pl
ugins.Sear
chReplaceP
lugin', {
|
|
|
10 |
|
in
it : funct
ion(ed, ur
l) {
|
|
|
11 |
|
function
open(m) {
|
|
|
12 |
|
ed.w
indowManag
er.open({
|
|
|
13 |
|
file : url
+ '/searc
hreplace.h
tm',
|
|
|
14 |
|
width : 42
0 + parseI
nt(ed.getL
ang('searc
hreplace.d
elta_width
', 0)),
|
|
|
15 |
|
height : 1
60 + parse
Int(ed.get
Lang('sear
chreplace.
delta_heig
ht', 0)),
|
|
|
16 |
|
inline : 1
,
|
|
|
17 |
|
auto_focus
: 0
|
|
|
18 |
|
}, {
|
|
|
19 |
|
mode : m,
|
|
|
20 |
|
search_str
ing : ed.s
election.g
etContent(
{format :
'text'}),
|
|
|
21 |
|
plugin_url
: url
|
|
|
22 |
|
});
|
|
|
23 |
|
};
|
|
|
24 |
|
|
|
|
25 |
|
// Regis
ter comman
ds
|
|
|
26 |
|
ed.addCo
mmand('mce
Search', f
unction()
{
|
|
|
27 |
|
open
('search')
;
|
|
|
28 |
|
});
|
|
|
29 |
|
|
|
|
30 |
|
ed.addCo
mmand('mce
Replace',
function()
{
|
|
|
31 |
|
open
('replace'
);
|
|
|
32 |
|
});
|
|
|
33 |
|
|
|
|
34 |
|
// Regis
ter button
s
|
|
|
35 |
|
ed.addBu
tton('sear
ch', {titl
e : 'searc
hreplace.s
earch_desc
', cmd : '
mceSearch'
});
|
|
|
36 |
|
ed.addBu
tton('repl
ace', {tit
le : 'sear
chreplace.
replace_de
sc', cmd :
'mceRepla
ce'});
|
|
|
37 |
|
|
|
|
38 |
|
ed.addSh
ortcut('ct
rl+f', 'se
archreplac
e.search_d
esc', 'mce
Search');
|
|
|
39 |
|
},
|
9 |
|
|
|
40 |
|
|
10 |
|
var TinyMC
E_SearchRe
placePlugi
n = {
|
|
|
11 |
|
getInf
o : functi
on() {
|
|
41 |
|
ge
tInfo : fu
nction() {
|
12 |
|
re
turn {
|
|
42 |
|
return {
|
13 |
|
longname
: 'Search
/Replace',
|
|
43 |
|
long
name : 'Se
arch/Repla
ce',
|
14 |
|
author :
'Moxiecod
e Systems
AB',
|
|
44 |
|
auth
or : 'Moxi
ecode Syst
ems AB',
|
15 |
|
authorur
l : 'http:
//tinymce.
moxiecode.
com',
|
|
45 |
|
auth
orurl : 'h
ttp://tiny
mce.moxiec
ode.com',
|
16 |
|
infourl
: 'http://
wiki.moxie
code.com/i
ndex.php/T
inyMCE:Plu
gins/searc
hreplace',
|
|
46 |
|
info
url : 'htt
p://wiki.m
oxiecode.c
om/index.p
hp/TinyMCE
:Plugins/s
earchrepla
ce',
|
17 |
|
version
:
tiny
MCE
.majorVers
ion
+
"."
+
tiny
MCE
.minorVers
ion
|
|
47 |
|
version
:
tiny
mce
.majorVers
ion
+
"."
+
tiny
mce
.minorVers
ion
|
18 |
|
};
|
|
48 |
|
};
|
19 |
|
},
|
|
|
20 |
|
|
|
|
21 |
|
initIn
stance : f
unction (i
nst) {
|
|
|
22 |
|
in
st.addShor
tcut('ctrl
', 'f', 'l
ang_search
replace_se
arch_desc'
, 'mceSear
ch', true)
;
|
|
|
23 |
|
//
No CTRL+R
for "repl
ace" becau
se browser
s will rel
oad page i
nstead of
executing
plugin
|
|
|
24 |
|
},
|
|
|
25 |
|
|
|
|
26 |
|
getCon
trolHTML :
function
(cn) {
|
|
|
27 |
|
sw
itch (cn)
{
|
|
|
28 |
|
case "se
arch" :
|
|
|
29 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_searc
hreplace_s
earch_desc
', '{$plug
inurl}/ima
ges/search
.gif','mce
Search', t
rue);
|
|
|
30 |
|
|
|
|
31 |
|
case "re
place" :
|
|
|
32 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_searc
hreplace_r
eplace_des
c', '{$plu
ginurl}/im
ages/repla
ce.gif', '
mceSearchR
eplace', t
rue);
|
|
|
33 |
|
}
|
|
|
34 |
|
|
|
|
35 |
|
re
turn "";
|
|
|
36 |
|
},
|
|
|
37 |
|
|
|
|
38 |
|
execCo
mmand : fu
nction (ed
itor_id, e
lement, co
mmand, use
r_interfac
e, value)
{
|
|
|
39 |
|
va
r inst = t
inyMCE.get
InstanceBy
Id(editor_
id), selec
tedText =
inst.selec
tion.getSe
lectedText
(), rng;
|
|
|
40 |
|
|
|
|
41 |
|
fu
nction def
Value(key,
default_v
alue) {
|
|
|
42 |
|
value[ke
y] = typeo
f(value[ke
y]) == "un
defined" ?
default_v
alue : val
ue[key];
|
|
|
43 |
|
}
|
|
|
44 |
|
|
|
|
45 |
|
fu
nction rep
laceSel(se
arch_str,
str, back)
{
|
|
|
46 |
|
if (!ins
t.selectio
n.isCollap
sed()) {
|
|
|
47 |
|
if (
tinyMCE.is
RealIE)
|
|
|
48 |
|
inst.selec
tion.getRn
g().duplic
ate().past
eHTML(str)
; // Needs
to be dup
licated du
e to selec
tion bug i
n IE
|
|
|
49 |
|
else
|
|
|
50 |
|
inst.execC
ommand('mc
eInsertCon
tent', fal
se, str);
|
|
|
51 |
|
}
|
|
|
52 |
|
}
|
|
|
53 |
|
|
|
|
54 |
|
if
(!value)
|
|
|
55 |
|
value =
[];
|
|
|
56 |
|
|
|
|
57 |
|
de
fValue("ed
itor_id",
editor_id)
;
|
|
|
58 |
|
de
fValue("se
archstring
", selecte
dText);
|
|
|
59 |
|
de
fValue("re
placestrin
g", null);
|
|
|
60 |
|
de
fValue("re
placemode"
, "none");
|
|
|
61 |
|
de
fValue("ca
sesensitiv
e", false)
;
|
|
|
62 |
|
de
fValue("ba
ckwards",
false);
|
|
|
63 |
|
de
fValue("wr
ap", false
);
|
|
|
64 |
|
de
fValue("wh
oleword",
false);
|
|
|
65 |
|
de
fValue("in
line", "ye
s");
|
|
|
66 |
|
de
fValue("re
sizable",
"no");
|
|
|
67 |
|
|
|
|
68 |
|
sw
itch (comm
and) {
|
|
|
69 |
|
case "mc
eSearch" :
|
|
|
70 |
|
if (
user_inter
face) {
|
|
|
71 |
|
var templa
te = new A
rray();
|
|
|
72 |
|
|
|
|
73 |
|
template['
file'] = '
../../plug
ins/search
replace/se
archreplac
e.htm';
|
|
|
74 |
|
template['
width'] =
380;
|
|
|
75 |
|
template['
height'] =
155 + (ti
nyMCE.isNS
7 ? 20 : 0
) + (tinyM
CE.isMSIE
? 15 : 0);
|
|
|
76 |
|
template['
width'] +=
tinyMCE.g
etLang('la
ng_searchr
eplace_del
ta_width',
0);
|
|
|
77 |
|
template['
height'] +
= tinyMCE.
getLang('l
ang_search
replace_de
lta_height
', 0);
|
|
|
78 |
|
|
|
|
79 |
|
inst.selec
tion.colla
pse(true);
|
|
|
80 |
|
|
|
|
81 |
|
tinyMCE.op
enWindow(t
emplate, v
alue);
|
|
|
82 |
|
} el
se {
|
|
|
83 |
|
var win =
tinyMCE.ge
tInstanceB
yId(editor
_id).conte
ntWindow;
|
|
|
84 |
|
var doc =
tinyMCE.ge
tInstanceB
yId(editor
_id).conte
ntWindow.d
ocument;
|
|
|
85 |
|
var body =
tinyMCE.g
etInstance
ById(edito
r_id).cont
entWindow.
document.b
ody;
|
|
|
86 |
|
var awin =
value.win
, found;
|
|
|
87 |
|
|
|
|
88 |
|
if (body.i
nnerHTML =
= "") {
|
|
|
89 |
|
awin.a
lert(tinyM
CE.getLang
('lang_sea
rchreplace
_notfound'
));
|
|
|
90 |
|
return
true;
|
|
|
91 |
|
}
|
|
49 |
|
}
|
|
|
50 |
|
});
|
92 |
|
|
|
51 |
|
|
93 |
|
if (value[
'replacemo
de'] == "c
urrent") {
|
|
52 |
|
// Reg
ister plug
in
|
94 |
|
replac
eSel(value
['string']
, value['r
eplacestri
ng'], valu
e['backwar
ds']);
|
|
53 |
|
tinymc
e.PluginMa
nager.add(
'searchrep
lace', tin
ymce.plugi
ns.SearchR
eplacePlug
in);
|
95 |
|
value[
'replacemo
de'] = "no
ne";
|
|
54 |
|
})();
|
96 |
|
//tiny
MCE.execIn
stanceComm
and(editor
_id, 'mceS
earch', us
er_interfa
ce, value)
;
|
|
|
97 |
|
//retu
rn true;
|
|
|
98 |
|
}
|
|
|
99 |
|
|
|
|
100 |
|
inst.selec
tion.colla
pse(value[
'backwards
']);
|
|
|
101 |
|
|
|
|
102 |
|
if (tinyMC
E.isMSIE)
{
|
|
|
103 |
|
var rn
g = inst.s
election.g
etRng();
|
|
|
104 |
|
var fl
ags = 0;
|
|
|
105 |
|
if (va
lue['whole
word'])
|
|
|
106 |
|
fl
ags = flag
s | 2;
|
|
|
107 |
|
|
|
|
108 |
|
if (va
lue['cases
ensitive']
)
|
|
|
109 |
|
fl
ags = flag
s | 4;
|
|
|
110 |
|
|
|
|
111 |
|
if (!r
ng.findTex
t) {
|
|
|
112 |
|
aw
in.alert('
This opera
tion is cu
rrently no
t supporte
d by this
browser.')
;
|
|
|
113 |
|
re
turn true;
|
|
|
114 |
|
}
|
|
|
115 |
|
|
|
|
116 |
|
if (va
lue['repla
cemode'] =
= "all") {
|
|
|
117 |
|
fo
und = fals
e;
|
|
|
118 |
|
|
|
|
119 |
|
wh
ile (rng.f
indText(va
lue['strin
g'], value
['backward
s'] ? -1 :
1, flags)
) {
|
|
|
120 |
|
found =
true;
|
|
|
121 |
|
rng.scro
llIntoView
();
|
|
|
122 |
|
rng.sele
ct();
|
|
|
123 |
|
replaceS
el(value['
string'],
value['rep
lacestring
'], value[
'backwards
']);
|
|
|
124 |
|
}
|
|
|
125 |
|
|
|
|
126 |
|
if
(found)
|
|
|
127 |
|
awin.ale
rt(tinyMCE
.getLang('
lang_searc
hreplace_a
llreplaced
'));
|
|
|
128 |
|
el
se
|
|
|
129 |
|
awin.ale
rt(tinyMCE
.getLang('
lang_searc
hreplace_n
otfound'))
;
|
|
|
130 |
|
|
|
|
131 |
|
re
turn true;
|
|
|
132 |
|
}
|
|
|
133 |
|
|
|
|
134 |
|
if (rn
g.findText
(value['st
ring'], va
lue['backw
ards'] ? -
1 : 1, fla
gs)) {
|
|
|
135 |
|
rn
g.scrollIn
toView();
|
|
|
136 |
|
rn
g.select()
;
|
|
|
137 |
|
} else
|
|
|
138 |
|
aw
in.alert(t
inyMCE.get
Lang('lang
_searchrep
lace_notfo
und'));
|
|
|
139 |
|
} else {
|
|
|
140 |
|
if (va
lue['repla
cemode'] =
= "all") {
|
|
|
141 |
|
fo
und = fals
e;
|
|
|
142 |
|
|
|
|
143 |
|
wh
ile (win.f
ind(value[
'string'],
value['ca
sesensitiv
e'], value
['backward
s'], value
['wrap'],
value['who
leword'],
false, fal
se)) {
|
|
|
144 |
|
found =
true;
|
|
|
145 |
|
replaceS
el(value['
string'],
value['rep
lacestring
'], value[
'backwards
']);
|
|
|
146 |
|
}
|
|
|
147 |
|
|
|
|
148 |
|
if
(found)
|
|
|
149 |
|
awin.ale
rt(tinyMCE
.getLang('
lang_searc
hreplace_a
llreplaced
'));
|
|
|
150 |
|
el
se
|
|
|
151 |
|
awin.ale
rt(tinyMCE
.getLang('
lang_searc
hreplace_n
otfound'))
;
|
|
|
152 |
|
|
|
|
153 |
|
re
turn true;
|
|
|
154 |
|
}
|
|
|
155 |
|
|
|
|
156 |
|
if (!w
in.find(va
lue['strin
g'], value
['casesens
itive'], v
alue['back
wards'], v
alue['wrap
'], value[
'wholeword
'], false,
false))
|
|
|
157 |
|
aw
in.alert(t
inyMCE.get
Lang('lang
_searchrep
lace_notfo
und'));
|
|
|
158 |
|
}
|
|
|
159 |
|
}
|
|
|
160 |
|
|
|
|
161 |
|
retu
rn true;
|
|
|
162 |
|
|
|
|
163 |
|
case "mc
eSearchRep
lace" :
|
|
|
164 |
|
valu
e['replace
string'] =
"";
|
|
|
165 |
|
tiny
MCE.execIn
stanceComm
and(editor
_id, 'mceS
earch', us
er_interfa
ce, value,
false);
|
|
|
166 |
|
retu
rn true;
|
|
|
167 |
|
}
|
|
|
168 |
|
|
|
|
169 |
|
re
turn false
;
|
|
|
170 |
|
}
|
|
|
171 |
|
};
|
|
|
172 |
|
|
|
|
173 |
|
tinyMCE.ad
dPlugin("s
earchrepla
ce", TinyM
CE_SearchR
eplacePlug
in);
|
|
|