No regular expressions were active.
1 |
|
var TinyMC
E_BBCodePl
ugin = {
|
|
1 |
|
/**
|
|
|
2 |
|
* $Id: ed
itor_plugi
n_src.js 2
01 2007-02
-12 15:56:
56Z spocke
$
|
|
|
3 |
|
*
|
|
|
4 |
|
* @author
Moxiecode
|
|
|
5 |
|
* @copyri
ght Copyri
ght © 2004
-2008, Mox
iecode Sys
tems AB, A
ll rights
reserved.
|
|
|
6 |
|
*/
|
|
|
7 |
|
|
|
|
8 |
|
(function(
) {
|
|
|
9 |
|
tinymc
e.create('
tinymce.pl
ugins.BBCo
dePlugin',
{
|
|
|
10 |
|
in
it : funct
ion(ed, ur
l) {
|
|
|
11 |
|
var t =
this, dial
ect = ed.g
etParam('b
bcode_dial
ect', 'pun
bb').toLow
erCase();
|
|
|
12 |
|
|
|
|
13 |
|
ed.onBef
oreSetCont
ent.add(fu
nction(ed,
o) {
|
|
|
14 |
|
o.co
ntent = t[
'_' + dial
ect + '_bb
code2html'
](o.conten
t);
|
|
|
15 |
|
});
|
|
|
16 |
|
|
|
|
17 |
|
ed.onPos
tProcess.a
dd(functio
n(ed, o) {
|
|
|
18 |
|
if (
o.set)
|
|
|
19 |
|
o.content
= t['_' +
dialect +
'_bbcode2h
tml'](o.co
ntent);
|
|
|
20 |
|
|
|
|
21 |
|
if (
o.get)
|
|
|
22 |
|
o.content
= t['_' +
dialect +
'_html2bbc
ode'](o.co
ntent);
|
|
|
23 |
|
});
|
|
|
24 |
|
},
|
|
|
25 |
|
|
2 |
|
getInf
o : functi
on() {
|
|
26 |
|
ge
tInfo : fu
nction() {
|
3 |
|
re
turn {
|
|
27 |
|
return {
|
4 |
|
longname
: 'BBCode
Plugin',
|
|
28 |
|
long
name : 'BB
Code Plugi
n',
|
5 |
|
author :
'Moxiecod
e Systems
AB',
|
|
29 |
|
auth
or : 'Moxi
ecode Syst
ems AB',
|
6 |
|
authorur
l : 'http:
//tinymce.
moxiecode.
com',
|
|
30 |
|
auth
orurl : 'h
ttp://tiny
mce.moxiec
ode.com',
|
7 |
|
infourl
: 'http://
wiki.moxie
code.com/i
ndex.php/T
inyMCE:Plu
gins/bbcod
e',
|
|
31 |
|
info
url : 'htt
p://wiki.m
oxiecode.c
om/index.p
hp/TinyMCE
:Plugins/b
bcode',
|
8 |
|
version
:
tiny
MCE
.majorVers
ion
+
"."
+
tiny
MCE
.minorVers
ion
|
|
32 |
|
version
:
tiny
mce
.majorVers
ion
+
"."
+
tiny
mce
.minorVers
ion
|
9 |
|
};
|
|
33 |
|
};
|
10 |
|
},
|
|
34 |
|
},
|
11 |
|
|
|
35 |
|
|
12 |
|
cleanu
p : functi
on(type, c
ontent) {
|
|
|
13 |
|
va
r dialect
= tinyMCE.
getParam('
bbcode_dia
lect', 'pu
nbb').toLo
werCase();
|
|
|
14 |
|
|
|
|
15 |
|
sw
itch (type
) {
|
|
|
16 |
|
case "in
sert_to_ed
itor":
|
|
|
17 |
|
cont
ent = this
['_' + dia
lect + '_b
bcode2html
'](content
);
|
|
|
18 |
|
brea
k;
|
|
|
19 |
|
|
|
|
20 |
|
case "ge
t_from_edi
tor":
|
|
|
21 |
|
cont
ent = this
['_' + dia
lect + '_h
tml2bbcode
'](content
);
|
|
|
22 |
|
brea
k;
|
|
|
23 |
|
}
|
|
|
24 |
|
|
|
|
25 |
|
re
turn conte
nt;
|
|
|
26 |
|
},
|
|
|
27 |
|
|
|
|
28 |
|
// Pri
vate metho
ds
|
|
36 |
|
//
Private m
ethods
|
29 |
|
|
|
37 |
|
|
30 |
|
// HTM
L -> BBCod
e in PunBB
dialect
|
|
38 |
|
//
HTML -> B
BCode in P
unBB diale
ct
|
31 |
|
_punbb
_html2bbco
de : funct
ion(s) {
|
|
39 |
|
_p
unbb_html2
bbcode : f
unction(s)
{
|
32 |
|
s
=
tiny
MCE
.trim(s);
|
|
40 |
|
s
=
tiny
mce
.trim(s);
|
33 |
|
|
|
41 |
|
|
34 |
|
fu
nction rep
(re, str)
{
|
|
42 |
|
function
rep(re, s
tr) {
|
35 |
|
s = s.re
place(re,
str);
|
|
43 |
|
s =
s.replace(
re, str);
|
36 |
|
};
|
|
44 |
|
};
|
37 |
|
|
|
45 |
|
|
38 |
|
//
example:
<strong> t
o [b]
|
|
46 |
|
// examp
le: <stron
g> to [b]
|
39 |
|
rep(/<a
href=\"(.*
?)\".*?>(.
*?)<\/a>/g
i,"[url
]
$1
[/url]");
|
|
47 |
|
rep(/<a
.*?
href=\"(.*
?)\".*?>(.
*?)<\/a>/g
i,"[url
=
$1
]$2
[/url]");
|
40 |
|
re
p(/<font.*
?color=\"(
.*?)\".*?c
lass=\"cod
eStyle\".*
?>(.*?)<\/
font>/gi,"
[code][col
or=$1]$2[/
color][/co
de]");
|
|
48 |
|
rep(/<fo
nt.*?color
=\"(.*?)\"
.*?class=\
"codeStyle
\".*?>(.*?
)<\/font>/
gi,"[code]
[color=$1]
$2[/color]
[/code]");
|
41 |
|
re
p(/<font.*
?color=\"(
.*?)\".*?c
lass=\"quo
teStyle\".
*?>(.*?)<\
/font>/gi,
"[quote][c
olor=$1]$2
[/color][/
quote]");
|
|
49 |
|
rep(/<fo
nt.*?color
=\"(.*?)\"
.*?class=\
"quoteStyl
e\".*?>(.*
?)<\/font>
/gi,"[quot
e][color=$
1]$2[/colo
r][/quote]
");
|
42 |
|
re
p(/<font.*
?class=\"c
odeStyle\"
.*?color=\
"(.*?)\".*
?>(.*?)<\/
font>/gi,"
[code][col
or=$1]$2[/
color][/co
de]");
|
|
50 |
|
rep(/<fo
nt.*?class
=\"codeSty
le\".*?col
or=\"(.*?)
\".*?>(.*?
)<\/font>/
gi,"[code]
[color=$1]
$2[/color]
[/code]");
|
43 |
|
re
p(/<font.*
?class=\"q
uoteStyle\
".*?color=
\"(.*?)\".
*?>(.*?)<\
/font>/gi,
"[quote][c
olor=$1]$2
[/color][/
quote]");
|
|
51 |
|
rep(/<fo
nt.*?class
=\"quoteSt
yle\".*?co
lor=\"(.*?
)\".*?>(.*
?)<\/font>
/gi,"[quot
e][color=$
1]$2[/colo
r][/quote]
");
|
|
|
52 |
|
rep(/<sp
an style=\
"color: ?(
.*?);\">(.
*?)<\/span
>/gi,"[col
or=$1]$2[/
color]");
|
44 |
|
re
p(/<font.*
?color=\"(
.*?)\".*?>
(.*?)<\/fo
nt>/gi,"[c
olor=$1]$2
[/color]")
;
|
|
53 |
|
rep(/<fo
nt.*?color
=\"(.*?)\"
.*?>(.*?)<
\/font>/gi
,"[color=$
1]$2[/colo
r]");
|
|
|
54 |
|
rep(/<sp
an style=\
"font-size
:(.*?);\">
(.*?)<\/sp
an>/gi,"[s
ize=$1]$2[
/size]");
|
45 |
|
re
p(/<font>(
.*?)<\/fon
t>/gi,"$1"
);
|
|
55 |
|
rep(/<fo
nt>(.*?)<\
/font>/gi,
"$1");
|
46 |
|
re
p(/<img.*?
src=\"(.*?
)\".*?\/>/
gi,"[img]$
1[/img]");
|
|
56 |
|
rep(/<im
g.*?src=\"
(.*?)\".*?
\/>/gi,"[i
mg]$1[/img
]");
|
47 |
|
re
p(/<span c
lass=\"cod
eStyle\">(
.*?)<\/spa
n>/gi,"[co
de]$1[/cod
e]");
|
|
57 |
|
rep(/<sp
an class=\
"codeStyle
\">(.*?)<\
/span>/gi,
"[code]$1[
/code]");
|
48 |
|
re
p(/<span c
lass=\"quo
teStyle\">
(.*?)<\/sp
an>/gi,"[q
uote]$1[/q
uote]");
|
|
58 |
|
rep(/<sp
an class=\
"quoteStyl
e\">(.*?)<
\/span>/gi
,"[quote]$
1[/quote]"
);
|
49 |
|
re
p(/<strong
class=\"c
odeStyle\"
>(.*?)<\/s
trong>/gi,
"[code][b]
$1[/b][/co
de]");
|
|
59 |
|
rep(/<st
rong class
=\"codeSty
le\">(.*?)
<\/strong>
/gi,"[code
][b]$1[/b]
[/code]");
|
50 |
|
re
p(/<strong
class=\"q
uoteStyle\
">(.*?)<\/
strong>/gi
,"[quote][
b]$1[/b][/
quote]");
|
|
60 |
|
rep(/<st
rong class
=\"quoteSt
yle\">(.*?
)<\/strong
>/gi,"[quo
te][b]$1[/
b][/quote]
");
|
51 |
|
re
p(/<em cla
ss=\"codeS
tyle\">(.*
?)<\/em>/g
i,"[code][
i]$1[/i][/
code]");
|
|
61 |
|
rep(/<em
class=\"c
odeStyle\"
>(.*?)<\/e
m>/gi,"[co
de][i]$1[/
i][/code]"
);
|
52 |
|
re
p(/<em cla
ss=\"quote
Style\">(.
*?)<\/em>/
gi,"[quote
][i]$1[/i]
[/quote]")
;
|
|
62 |
|
rep(/<em
class=\"q
uoteStyle\
">(.*?)<\/
em>/gi,"[q
uote][i]$1
[/i][/quot
e]");
|
53 |
|
re
p(/<u clas
s=\"codeSt
yle\">(.*?
)<\/u>/gi,
"[code][u]
$1[/u][/co
de]");
|
|
63 |
|
rep(/<u
class=\"co
deStyle\">
(.*?)<\/u>
/gi,"[code
][u]$1[/u]
[/code]");
|
54 |
|
re
p(/<u clas
s=\"quoteS
tyle\">(.*
?)<\/u>/gi
,"[quote][
u]$1[/u][/
quote]");
|
|
64 |
|
rep(/<u
class=\"qu
oteStyle\"
>(.*?)<\/u
>/gi,"[quo
te][u]$1[/
u][/quote]
");
|
55 |
|
re
p(/<\/(str
ong|b)>/gi
,"[/b]");
|
|
65 |
|
rep(/<\/
(strong|b)
>/gi,"[/b]
");
|
56 |
|
re
p(/<(stron
g|b)>/gi,"
[b]");
|
|
66 |
|
rep(/<(s
trong|b)>/
gi,"[b]");
|
57 |
|
re
p(/<\/(em|
i)>/gi,"[/
i]");
|
|
67 |
|
rep(/<\/
(em|i)>/gi
,"[/i]");
|
58 |
|
re
p(/<(em|i)
>/gi,"[i]"
);
|
|
68 |
|
rep(/<(e
m|i)>/gi,"
[i]");
|
59 |
|
re
p(/<\/u>/g
i,"[/u]");
|
|
69 |
|
rep(/<\/
u>/gi,"[/u
]");
|
|
|
70 |
|
rep(/<sp
an style=\
"text-deco
ration: ?u
nderline;\
">(.*?)<\/
span>/gi,"
[u]$1[/u]"
);
|
60 |
|
re
p(/<u>/gi,
"[u]");
|
|
71 |
|
rep(/<u>
/gi,"[u]")
;
|
61 |
|
re
p(/<br \/>
/gi,"\n");
|
|
72 |
|
rep(/<br
\/>/gi,"\
n");
|
62 |
|
re
p(/<br\/>/
gi,"\n");
|
|
73 |
|
rep(/<br
\/>/gi,"\n
");
|
63 |
|
re
p(/<br>/gi
,"\n");
|
|
74 |
|
rep(/<br
>/gi,"\n")
;
|
64 |
|
re
p(/<p>/gi,
"");
|
|
75 |
|
rep(/<p>
/gi,"");
|
65 |
|
re
p(/<\/p>/g
i,"\n");
|
|
76 |
|
rep(/<\/
p>/gi,"\n"
);
|
66 |
|
re
p(/ /
gi," ");
|
|
77 |
|
rep(/&nb
sp;/gi," "
);
|
67 |
|
re
p(/"/
gi,"\"");
|
|
78 |
|
rep(/&qu
ot;/gi,"\"
");
|
68 |
|
re
p(/</gi
,"<");
|
|
79 |
|
rep(/<
;/gi,"<");
|
69 |
|
re
p(/>/gi
,">");
|
|
80 |
|
rep(/>
;/gi,">");
|
70 |
|
re
p(/&/g
i,"&");
|
|
81 |
|
rep(/&am
p;/gi,"&")
;
|
71 |
|
re
p(/&undefi
ned;/gi,"'
"); // qui
ckfix
|
|
|
72 |
|
|
|
82 |
|
|
73 |
|
re
turn s;
|
|
83 |
|
return s
;
|
74 |
|
},
|
|
84 |
|
},
|
75 |
|
|
|
85 |
|
|
76 |
|
// BBC
ode -> HTM
L from Pun
BB dialect
|
|
86 |
|
//
BBCode ->
HTML from
PunBB dia
lect
|
77 |
|
_punbb
_bbcode2ht
ml : funct
ion(s) {
|
|
87 |
|
_p
unbb_bbcod
e2html : f
unction(s)
{
|
78 |
|
s
=
tiny
MCE
.trim(s);
|
|
88 |
|
s
=
tiny
mce
.trim(s);
|
79 |
|
|
|
89 |
|
|
80 |
|
fu
nction rep
(re, str)
{
|
|
90 |
|
function
rep(re, s
tr) {
|
81 |
|
s = s.re
place(re,
str);
|
|
91 |
|
s =
s.replace(
re, str);
|
82 |
|
};
|
|
92 |
|
};
|
83 |
|
|
|
93 |
|
|
84 |
|
//
example:
[b] to <st
rong>
|
|
94 |
|
// examp
le: [b] to
<strong>
|
85 |
|
re
p(/\n/gi,"
<br />");
|
|
95 |
|
rep(/\n/
gi,"<br />
");
|
86 |
|
re
p(/\[b\]/g
i,"<strong
>");
|
|
96 |
|
rep(/\[b
\]/gi,"<st
rong>");
|
87 |
|
re
p(/\[\/b\]
/gi,"</str
ong>");
|
|
97 |
|
rep(/\[\
/b\]/gi,"<
/strong>")
;
|
88 |
|
re
p(/\[i\]/g
i,"<em>");
|
|
98 |
|
rep(/\[i
\]/gi,"<em
>");
|
89 |
|
re
p(/\[\/i\]
/gi,"</em>
");
|
|
99 |
|
rep(/\[\
/i\]/gi,"<
/em>");
|
90 |
|
re
p(/\[u\]/g
i,"<u>");
|
|
100 |
|
rep(/\[u
\]/gi,"<u>
");
|
91 |
|
re
p(/\[\/u\]
/gi,"</u>"
);
|
|
101 |
|
rep(/\[\
/u\]/gi,"<
/u>");
|
|
|
102 |
|
rep(/\[u
rl=([^\]]+
)\](.*?)\[
\/url\]/gi
,"<a href=
\"$1\">$2<
/a>");
|
92 |
|
re
p(/\[url\]
(.*?)\[\/u
rl\]/gi,"<
a href=\"$
1\">$1</a>
");
|
|
103 |
|
rep(/\[u
rl\](.*?)\
[\/url\]/g
i,"<a href
=\"$1\">$1
</a>");
|
93 |
|
re
p(/\[img\]
(.*?)\[\/i
mg\]/gi,"<
img src=\"
$1\" />");
|
|
104 |
|
rep(/\[i
mg\](.*?)\
[\/img\]/g
i,"<img sr
c=\"$1\" /
>");
|
94 |
|
re
p(/\[color
=(.*?)\](.
*?)\[\/col
or\]/gi,"<
font color
=\"$1\">$2
</font>");
|
|
105 |
|
rep(/\[c
olor=(.*?)
\](.*?)\[\
/color\]/g
i,"<font c
olor=\"$1\
">$2</font
>");
|
95 |
|
re
p(/\[code\
](.*?)\[\/
code\]/gi,
"<span cla
ss=\"codeS
tyle\">$1<
/span>&nbs
p;");
|
|
106 |
|
rep(/\[c
ode\](.*?)
\[\/code\]
/gi,"<span
class=\"c
odeStyle\"
>$1</span>
");
|
96 |
|
re
p(/\[quote
.*?\](.*?)
\[\/quote\
]/gi,"<spa
n class=\"
quoteStyle
\">$1</spa
n> ")
;
|
|
107 |
|
rep(/\[q
uote.*?\](
.*?)\[\/qu
ote\]/gi,"
<span clas
s=\"quoteS
tyle\">$1<
/span>&nbs
p;");
|
97 |
|
|
|
108 |
|
|
98 |
|
re
turn s;
|
|
109 |
|
return s
;
|
99 |
|
}
|
|
110 |
|
}
|
100 |
|
}
;
|
|
111 |
|
}
)
;
|
101 |
|
|
|
112 |
|
|
102 |
|
tiny
MCE
.
add
Plugin
(
"
bbcode
"
,
T
iny
MCE_
BBCodePlug
in);
|
|
113 |
|
// Reg
ister plug
in
|
|
|
114 |
|
tiny
mce
.
Plugin
Manager.ad
d
(
'
bbcode
'
,
t
iny
mce.plugin
s.
BBCodePlug
in);
|
|
|
115 |
|
})();
|