No regular expressions were active.
|
|
1 |
|
/**
|
|
|
2 |
|
* $Id: ed
itor_plugi
n_src.js 2
64 2007-04
-26 20:53:
09Z 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 |
|
var Ev
ent = tiny
mce.dom.Ev
ent, grep
= tinymce.
grep, each
= tinymce
.each, inA
rray = tin
ymce.inArr
ay, isOldW
ebKit = ti
nymce.isOl
dWebKit;
|
|
|
10 |
|
|
|
|
11 |
|
tinymc
e.create('
tinymce.pl
ugins.Safa
ri', {
|
|
|
12 |
|
in
it : funct
ion(ed) {
|
|
|
13 |
|
var t =
this, dom;
|
|
|
14 |
|
|
|
|
15 |
|
// Ignor
e on non w
ebkit
|
|
|
16 |
|
if (!tin
ymce.isWeb
Kit)
|
|
|
17 |
|
retu
rn;
|
|
|
18 |
|
|
|
|
19 |
|
t.editor
= ed;
|
|
|
20 |
|
t.webKit
FontSizes
= ['x-smal
l', 'small
', 'medium
', 'large'
, 'x-large
', 'xx-lar
ge', '-web
kit-xxx-la
rge'];
|
|
|
21 |
|
t.namedF
ontSizes =
['xx-smal
l', 'x-sma
ll','small
','medium'
,'large','
x-large',
'xx-large'
];
|
|
|
22 |
|
|
|
|
23 |
|
// Safar
i will cra
sh if the
build in c
reatelink
command is
used
|
|
|
24 |
|
/*
ed.addCo
mmand('Cre
ateLink',
function(u
, v) {
|
|
|
25 |
|
ed.e
xecCommand
("mceInser
tContent",
false, '<
a href="'
+ dom.enco
de(v) + '"
>' + ed.se
lection.ge
tContent()
+ '</a>')
;
|
|
|
26 |
|
});*/
|
|
|
27 |
|
|
|
|
28 |
|
ed.onKey
Up.add(fun
ction(ed,
e) {
|
|
|
29 |
|
var
h;
|
|
|
30 |
|
|
|
|
31 |
|
// I
f backspac
e or delet
e key
|
|
|
32 |
|
if (
e.keyCode
== 46 || e
.keyCode =
= 8) {
|
|
|
33 |
|
h = ed.get
Body().inn
erHTML;
|
|
|
34 |
|
|
|
|
35 |
|
// If ther
e is no te
xt content
or images
or hr ele
ments then
remove ev
erything
|
|
|
36 |
|
if (!/<(im
g|hr)/.tes
t(h) && ti
nymce.trim
(h.replace
(/<[^>]+>/
g, '')).le
ngth == 0)
|
|
|
37 |
|
ed.set
Content(''
, {format
: 'raw'});
|
|
|
38 |
|
}
|
|
|
39 |
|
});
|
|
|
40 |
|
|
|
|
41 |
|
// Worka
round for
FormatBloc
k bug, htt
p://bugs.w
ebkit.org/
show_bug.c
gi?id=1600
4
|
|
|
42 |
|
ed.addCo
mmand('For
matBlock',
function(
u, v) {
|
|
|
43 |
|
var
dom = ed.d
om, e = do
m.getParen
t(ed.selec
tion.getNo
de(), dom.
isBlock);
|
|
|
44 |
|
|
|
|
45 |
|
if (
e)
|
|
|
46 |
|
dom.replac
e(dom.crea
te(v), e,
1);
|
|
|
47 |
|
else
|
|
|
48 |
|
ed.getDoc(
).execComm
and("Forma
tBlock", f
alse, v);
|
|
|
49 |
|
});
|
|
|
50 |
|
|
|
|
51 |
|
// Worka
round for
InsertHTML
bug, http
://bugs.we
bkit.org/s
how_bug.cg
i?id=16382
|
|
|
52 |
|
ed.addCo
mmand('mce
InsertCont
ent', func
tion(u, v)
{
|
|
|
53 |
|
ed.g
etDoc().ex
ecCommand(
"InsertTex
t", false,
'mce_mark
er');
|
|
|
54 |
|
ed.g
etBody().i
nnerHTML =
ed.getBod
y().innerH
TML.replac
e(/mce_mar
ker/g, v +
'<span id
="_mce_tmp
">XX</span
>');
|
|
|
55 |
|
ed.s
election.s
elect(ed.d
om.get('_m
ce_tmp'));
|
|
|
56 |
|
ed.g
etDoc().ex
ecCommand(
"Delete",
false, ' '
);
|
|
|
57 |
|
});
|
|
|
58 |
|
|
|
|
59 |
|
// Worka
round for
missing sh
ift+enter
support, h
ttp://bugs
.webkit.or
g/show_bug
.cgi?id=16
973
|
|
|
60 |
|
ed.onKey
Press.add(
function(e
d, e) {
|
|
|
61 |
|
if (
e.keyCode
== 13 && (
e.shiftKey
|| ed.set
tings.forc
e_br_newli
nes && ed.
selection.
getNode().
nodeName !
= 'LI')) {
|
|
|
62 |
|
t._insertB
R(ed);
|
|
|
63 |
|
Event.canc
el(e);
|
|
|
64 |
|
}
|
|
|
65 |
|
});
|
|
|
66 |
|
|
|
|
67 |
|
// Safar
i returns
incorrect
values
|
|
|
68 |
|
ed.addQu
eryValueHa
ndler('Fon
tSize', fu
nction(u,
v) {
|
|
|
69 |
|
var
e, v;
|
|
|
70 |
|
|
|
|
71 |
|
// C
heck for t
he real fo
nt size at
the start
of select
ion
|
|
|
72 |
|
if (
(e = ed.do
m.getParen
t(ed.selec
tion.getSt
art(), 'sp
an')) && (
v = e.styl
e.fontSize
))
|
|
|
73 |
|
return tin
ymce.inArr
ay(t.named
FontSizes,
v) + 1;
|
|
|
74 |
|
|
|
|
75 |
|
// C
heck for t
he real fo
nt size at
the end o
f selectio
n
|
|
|
76 |
|
if (
(e = ed.do
m.getParen
t(ed.selec
tion.getEn
d(), 'span
')) && (v
= e.style.
fontSize))
|
|
|
77 |
|
return tin
ymce.inArr
ay(t.named
FontSizes,
v) + 1;
|
|
|
78 |
|
|
|
|
79 |
|
// R
eturn defa
ult value
it's bette
r than not
hing right
!
|
|
|
80 |
|
retu
rn ed.getD
oc().query
CommandVal
ue('FontSi
ze');
|
|
|
81 |
|
});
|
|
|
82 |
|
|
|
|
83 |
|
// Safar
i returns
incorrect
values
|
|
|
84 |
|
ed.addQu
eryValueHa
ndler('Fon
tName', fu
nction(u,
v) {
|
|
|
85 |
|
var
e, v;
|
|
|
86 |
|
|
|
|
87 |
|
// C
heck for t
he real fo
nt name at
the start
of select
ion
|
|
|
88 |
|
if (
(e = ed.do
m.getParen
t(ed.selec
tion.getSt
art(), 'sp
an')) && (
v = e.styl
e.fontFami
ly))
|
|
|
89 |
|
return v.r
eplace(/,
/g, ',');
|
|
|
90 |
|
|
|
|
91 |
|
// C
heck for t
he real fo
nt name at
the end o
f selectio
n
|
|
|
92 |
|
if (
(e = ed.do
m.getParen
t(ed.selec
tion.getEn
d(), 'span
')) && (v
= e.style.
fontFamily
))
|
|
|
93 |
|
return v.r
eplace(/,
/g, ',');
|
|
|
94 |
|
|
|
|
95 |
|
// R
eturn defa
ult value
it's bette
r than not
hing right
!
|
|
|
96 |
|
retu
rn ed.getD
oc().query
CommandVal
ue('FontNa
me');
|
|
|
97 |
|
});
|
|
|
98 |
|
|
|
|
99 |
|
// Worka
round for
bug, http:
//bugs.web
kit.org/sh
ow_bug.cgi
?id=12250
|
|
|
100 |
|
ed.onCli
ck.add(fun
ction(ed,
e) {
|
|
|
101 |
|
e =
e.target;
|
|
|
102 |
|
|
|
|
103 |
|
if (
e.nodeName
== 'IMG')
{
|
|
|
104 |
|
t.selElm =
e;
|
|
|
105 |
|
ed.selecti
on.select(
e);
|
|
|
106 |
|
} el
se
|
|
|
107 |
|
t.selElm =
null;
|
|
|
108 |
|
});
|
|
|
109 |
|
|
|
|
110 |
|
ed.onBef
oreExecCom
mand.add(f
unction(ed
, c, b) {
|
|
|
111 |
|
var
r = t.book
markRng;
|
|
|
112 |
|
|
|
|
113 |
|
// R
estore sel
ection
|
|
|
114 |
|
if (
r) {
|
|
|
115 |
|
ed.selecti
on.setRng(
r);
|
|
|
116 |
|
t.bookmark
Rng = null
;
|
|
|
117 |
|
//console.
debug('res
tore', r.s
tartContai
ner, r.sta
rtOffset,
r.endConta
iner, r.en
dOffset);
|
|
|
118 |
|
}
|
|
|
119 |
|
});
|
|
|
120 |
|
|
|
|
121 |
|
ed.onIni
t.add(func
tion() {
|
|
|
122 |
|
t._f
ixWebKitSp
ans();
|
|
|
123 |
|
|
|
|
124 |
|
ed.w
indowManag
er.onOpen.
add(functi
on() {
|
|
|
125 |
|
var r = ed
.selection
.getRng();
|
|
|
126 |
|
|
|
|
127 |
|
// Store s
election i
f valid
|
|
|
128 |
|
if (r.star
tContainer
!= ed.get
Doc()) {
|
|
|
129 |
|
t.book
markRng =
r.cloneRan
ge();
|
|
|
130 |
|
//cons
ole.debug(
'store', r
.startCont
ainer, r.s
tartOffset
, r.endCon
tainer, r.
endOffset)
;
|
|
|
131 |
|
}
|
|
|
132 |
|
});
|
|
|
133 |
|
|
|
|
134 |
|
ed.w
indowManag
er.onClose
.add(funct
ion() {
|
|
|
135 |
|
t.bookmark
Rng = null
;
|
|
|
136 |
|
});
|
|
|
137 |
|
|
|
|
138 |
|
if (
isOldWebKi
t)
|
|
|
139 |
|
t._patchSa
fari2x(ed)
;
|
|
|
140 |
|
});
|
|
|
141 |
|
|
|
|
142 |
|
ed.onSet
Content.ad
d(function
() {
|
|
|
143 |
|
dom
= ed.dom;
|
|
|
144 |
|
|
|
|
145 |
|
// C
onvert str
ong,b,em,u
,strike to
spans
|
|
|
146 |
|
each
(['strong'
,'b','em',
'u','strik
e','sub','
sup','a'],
function(
v) {
|
|
|
147 |
|
each(grep(
dom.select
(v)).rever
se(), func
tion(n) {
|
|
|
148 |
|
var nn
= n.nodeN
ame.toLowe
rCase(), s
t;
|
|
|
149 |
|
|
|
|
150 |
|
// Con
vert ancho
rs into im
ages
|
|
|
151 |
|
if (nn
== 'a') {
|
|
|
152 |
|
if
(n.name)
|
|
|
153 |
|
dom.repl
ace(dom.cr
eate('img'
, {mce_nam
e : 'a', n
ame : n.na
me, 'class
' : 'mceIt
emAnchor'}
), n);
|
|
|
154 |
|
|
|
|
155 |
|
re
turn;
|
|
|
156 |
|
}
|
|
|
157 |
|
|
|
|
158 |
|
switch
(nn) {
|
|
|
159 |
|
ca
se 'b':
|
|
|
160 |
|
ca
se 'strong
':
|
|
|
161 |
|
if (nn =
= 'b')
|
|
|
162 |
|
nn =
'strong';
|
|
|
163 |
|
|
|
|
164 |
|
st = 'fo
nt-weight:
bold;';
|
|
|
165 |
|
break;
|
|
|
166 |
|
|
|
|
167 |
|
ca
se 'em':
|
|
|
168 |
|
st = 'fo
nt-style:
italic;';
|
|
|
169 |
|
break;
|
|
|
170 |
|
|
|
|
171 |
|
ca
se 'u':
|
|
|
172 |
|
st = 'te
xt-decorat
ion: under
line;';
|
|
|
173 |
|
break;
|
|
|
174 |
|
|
|
|
175 |
|
ca
se 'sub':
|
|
|
176 |
|
st = 've
rtical-ali
gn: sub;';
|
|
|
177 |
|
break;
|
|
|
178 |
|
|
|
|
179 |
|
ca
se 'sup':
|
|
|
180 |
|
st = 've
rtical-ali
gn: super;
';
|
|
|
181 |
|
break;
|
|
|
182 |
|
|
|
|
183 |
|
ca
se 'strike
':
|
|
|
184 |
|
st = 'te
xt-decorat
ion: line-
through;';
|
|
|
185 |
|
break;
|
|
|
186 |
|
}
|
|
|
187 |
|
|
|
|
188 |
|
dom.re
place(dom.
create('sp
an', {mce_
name : nn,
style : s
t, 'class'
: 'Apple-
style-span
'}), n, 1)
;
|
|
|
189 |
|
});
|
|
|
190 |
|
});
|
|
|
191 |
|
});
|
|
|
192 |
|
|
|
|
193 |
|
ed.onPre
Process.ad
d(function
(ed, o) {
|
|
|
194 |
|
dom
= ed.dom;
|
|
|
195 |
|
|
|
|
196 |
|
each
(grep(o.no
de.getElem
entsByTagN
ame('span'
)).reverse
(), functi
on(n) {
|
|
|
197 |
|
var v, bg;
|
|
|
198 |
|
|
|
|
199 |
|
if (o.get)
{
|
|
|
200 |
|
if (do
m.hasClass
(n, 'Apple
-style-spa
n')) {
|
|
|
201 |
|
bg
= n.style
.backgroun
dColor;
|
|
|
202 |
|
|
|
|
203 |
|
sw
itch (dom.
getAttrib(
n, 'mce_na
me')) {
|
|
|
204 |
|
case 'fo
nt':
|
|
|
205 |
|
if (
!ed.settin
gs.convert
_fonts_to_
spans)
|
|
|
206 |
|
dom.setAtt
rib(n, 'st
yle', '');
|
|
|
207 |
|
brea
k;
|
|
|
208 |
|
|
|
|
209 |
|
case 'st
rong':
|
|
|
210 |
|
case 'em
':
|
|
|
211 |
|
case 'su
b':
|
|
|
212 |
|
case 'su
p':
|
|
|
213 |
|
dom.
setAttrib(
n, 'style'
, '');
|
|
|
214 |
|
brea
k;
|
|
|
215 |
|
|
|
|
216 |
|
case 'st
rike':
|
|
|
217 |
|
case 'u'
:
|
|
|
218 |
|
if (
!ed.settin
gs.inline_
styles)
|
|
|
219 |
|
dom.setAtt
rib(n, 'st
yle', '');
|
|
|
220 |
|
else
|
|
|
221 |
|
dom.setAtt
rib(n, 'mc
e_name', '
');
|
|
|
222 |
|
|
|
|
223 |
|
brea
k;
|
|
|
224 |
|
|
|
|
225 |
|
default:
|
|
|
226 |
|
if (
!ed.settin
gs.inline_
styles)
|
|
|
227 |
|
dom.setAtt
rib(n, 'st
yle', '');
|
|
|
228 |
|
}
|
|
|
229 |
|
|
|
|
230 |
|
|
|
|
231 |
|
if
(bg)
|
|
|
232 |
|
n.style.
background
Color = bg
;
|
|
|
233 |
|
}
|
|
|
234 |
|
}
|
|
|
235 |
|
|
|
|
236 |
|
if (dom.ha
sClass(n,
'mceItemRe
moved'))
|
|
|
237 |
|
dom.re
move(n, 1)
;
|
|
|
238 |
|
});
|
|
|
239 |
|
});
|
|
|
240 |
|
|
|
|
241 |
|
ed.onPos
tProcess.a
dd(functio
n(ed, o) {
|
|
|
242 |
|
// S
afari adds
BR at end
of all bl
ock elemen
ts
|
|
|
243 |
|
o.co
ntent = o.
content.re
place(/<br
\/><\/(h[
1-6]|div|p
|address|p
re)>/g, '<
/$1>');
|
|
|
244 |
|
|
|
|
245 |
|
// S
afari adds
id="undef
ined" to H
R elements
|
|
|
246 |
|
o.co
ntent = o.
content.re
place(/ id
=\"undefin
ed\"/g, ''
);
|
|
|
247 |
|
});
|
|
|
248 |
|
},
|
|
|
249 |
|
|
|
|
250 |
|
_f
ixWebKitSp
ans : func
tion() {
|
|
|
251 |
|
var t =
this, ed =
t.editor;
|
|
|
252 |
|
|
|
|
253 |
|
if (!isO
ldWebKit)
{
|
|
|
254 |
|
// U
se mutator
events on
new WebKi
t
|
|
|
255 |
|
Even
t.add(ed.g
etDoc(), '
DOMNodeIns
erted', fu
nction(e)
{
|
|
|
256 |
|
e = e.targ
et;
|
|
|
257 |
|
|
|
|
258 |
|
if (e && e
.nodeType
== 1)
|
|
|
259 |
|
t._fix
AppleSpan(
e);
|
|
|
260 |
|
});
|
|
|
261 |
|
} else {
|
|
|
262 |
|
// D
o post com
mand proce
ssing in o
ld WebKit
since the
browser cr
ashes on M
utator eve
nts :(
|
|
|
263 |
|
ed.o
nExecComma
nd.add(fun
ction() {
|
|
|
264 |
|
each(ed.do
m.select('
span'), fu
nction(n)
{
|
|
|
265 |
|
t._fix
AppleSpan(
n);
|
|
|
266 |
|
});
|
|
|
267 |
|
|
|
|
268 |
|
ed.nodeCha
nged();
|
|
|
269 |
|
});
|
|
|
270 |
|
}
|
|
|
271 |
|
},
|
|
|
272 |
|
|
|
|
273 |
|
_f
ixAppleSpa
n : functi
on(e) {
|
|
|
274 |
|
var ed =
this.edit
or, dom =
ed.dom, fz
= this.we
bKitFontSi
zes, fzn =
this.name
dFontSizes
, s = ed.s
ettings, s
t, p;
|
|
|
275 |
|
|
|
|
276 |
|
if (dom.
getAttrib(
e, 'mce_fi
xed'))
|
|
|
277 |
|
retu
rn;
|
|
|
278 |
|
|
|
|
279 |
|
// Handl
e Apple st
yle spans
|
|
|
280 |
|
if (e.no
deName ==
'SPAN' &&
e.classNam
e == 'Appl
e-style-sp
an') {
|
|
|
281 |
|
st =
e.style;
|
|
|
282 |
|
|
|
|
283 |
|
if (
!s.convert
_fonts_to_
spans) {
|
|
|
284 |
|
if (st.fon
tSize) {
|
|
|
285 |
|
dom.se
tAttrib(e,
'mce_name
', 'font')
;
|
|
|
286 |
|
dom.se
tAttrib(e,
'size', i
nArray(fz,
st.fontSi
ze) + 1);
|
|
|
287 |
|
}
|
|
|
288 |
|
|
|
|
289 |
|
if (st.fon
tFamily) {
|
|
|
290 |
|
dom.se
tAttrib(e,
'mce_name
', 'font')
;
|
|
|
291 |
|
dom.se
tAttrib(e,
'face', s
t.fontFami
ly);
|
|
|
292 |
|
}
|
|
|
293 |
|
|
|
|
294 |
|
if (st.col
or) {
|
|
|
295 |
|
dom.se
tAttrib(e,
'mce_name
', 'font')
;
|
|
|
296 |
|
dom.se
tAttrib(e,
'color',
dom.toHex(
st.color))
;
|
|
|
297 |
|
}
|
|
|
298 |
|
|
|
|
299 |
|
if (st.bac
kgroundCol
or) {
|
|
|
300 |
|
dom.se
tAttrib(e,
'mce_name
', 'font')
;
|
|
|
301 |
|
dom.se
tStyle(e,
'backgroun
d-color',
st.backgro
undColor);
|
|
|
302 |
|
}
|
|
|
303 |
|
} el
se {
|
|
|
304 |
|
if (st.fon
tSize)
|
|
|
305 |
|
dom.se
tStyle(e,
'fontSize'
, fzn[inAr
ray(fz, st
.fontSize)
]);
|
|
|
306 |
|
}
|
|
|
307 |
|
|
|
|
308 |
|
if (
st.fontWei
ght == 'bo
ld')
|
|
|
309 |
|
dom.setAtt
rib(e, 'mc
e_name', '
strong');
|
|
|
310 |
|
|
|
|
311 |
|
if (
st.fontSty
le == 'ita
lic')
|
|
|
312 |
|
dom.setAtt
rib(e, 'mc
e_name', '
em');
|
|
|
313 |
|
|
|
|
314 |
|
if (
st.textDec
oration ==
'underlin
e')
|
|
|
315 |
|
dom.setAtt
rib(e, 'mc
e_name', '
u');
|
|
|
316 |
|
|
|
|
317 |
|
if (
st.textDec
oration ==
'line-thr
ough')
|
|
|
318 |
|
dom.setAtt
rib(e, 'mc
e_name', '
strike');
|
|
|
319 |
|
|
|
|
320 |
|
if (
st.vertica
lAlign ==
'super')
|
|
|
321 |
|
dom.setAtt
rib(e, 'mc
e_name', '
sup');
|
|
|
322 |
|
|
|
|
323 |
|
if (
st.vertica
lAlign ==
'sub')
|
|
|
324 |
|
dom.setAtt
rib(e, 'mc
e_name', '
sub');
|
|
|
325 |
|
|
|
|
326 |
|
dom.
setAttrib(
e, 'mce_fi
xed', '1')
;
|
|
|
327 |
|
}
|
|
|
328 |
|
},
|
|
|
329 |
|
|
|
|
330 |
|
_p
atchSafari
2x : funct
ion(ed) {
|
|
|
331 |
|
var t =
this, setC
ontent, ge
tNode, dom
= ed.dom,
lr;
|
|
|
332 |
|
|
|
|
333 |
|
// Inlin
e dialogs
|
|
|
334 |
|
if (ed.w
indowManag
er.onBefor
eOpen) {
|
|
|
335 |
|
ed.w
indowManag
er.onBefor
eOpen.add(
function()
{
|
|
|
336 |
|
r = ed.sel
ection.get
Rng();
|
|
|
337 |
|
});
|
|
|
338 |
|
}
|
|
|
339 |
|
|
|
|
340 |
|
// Fake
select on
2.x
|
|
|
341 |
|
ed.selec
tion.selec
t = functi
on(n) {
|
|
|
342 |
|
this
.getSel().
setBaseAnd
Extent(n,
0, n, 1);
|
|
|
343 |
|
};
|
|
|
344 |
|
|
|
|
345 |
|
getNode
= ed.selec
tion.getNo
de;
|
|
|
346 |
|
ed.selec
tion.getNo
de = funct
ion() {
|
|
|
347 |
|
retu
rn t.selEl
m || getNo
de.call(th
is);
|
|
|
348 |
|
};
|
|
|
349 |
|
|
|
|
350 |
|
// Fake
range on S
afari 2.x
|
|
|
351 |
|
ed.selec
tion.getRn
g = functi
on() {
|
|
|
352 |
|
var
t = this,
s = t.getS
el(), d =
ed.getDoc(
), r, rb,
ra, di;
|
|
|
353 |
|
|
|
|
354 |
|
// F
ake range
on Safari
2.x
|
|
|
355 |
|
if (
s.anchorNo
de) {
|
|
|
356 |
|
r = d.crea
teRange();
|
|
|
357 |
|
|
|
|
358 |
|
try {
|
|
|
359 |
|
// Set
up before
range
|
|
|
360 |
|
rb = d
.createRan
ge();
|
|
|
361 |
|
rb.set
Start(s.an
chorNode,
s.anchorOf
fset);
|
|
|
362 |
|
rb.col
lapse(1);
|
|
|
363 |
|
|
|
|
364 |
|
// Set
up after r
ange
|
|
|
365 |
|
ra = d
.createRan
ge();
|
|
|
366 |
|
ra.set
Start(s.fo
cusNode, s
.focusOffs
et);
|
|
|
367 |
|
ra.col
lapse(1);
|
|
|
368 |
|
|
|
|
369 |
|
// Set
up start/e
nd points
by compari
ng locatio
ns
|
|
|
370 |
|
di = r
b.compareB
oundaryPoi
nts(rb.STA
RT_TO_END,
ra) < 0;
|
|
|
371 |
|
r.setS
tart(di ?
s.anchorNo
de : s.foc
usNode, di
? s.ancho
rOffset :
s.focusOff
set);
|
|
|
372 |
|
r.setE
nd(di ? s.
focusNode
: s.anchor
Node, di ?
s.focusOf
fset : s.a
nchorOffse
t);
|
|
|
373 |
|
|
|
|
374 |
|
lr = r
;
|
|
|
375 |
|
} catch (e
x) {
|
|
|
376 |
|
// Som
etimes fai
ls, at lea
st we trie
d to do it
by the bo
ok. I hope
Safari 2.
x will go
disappear
soooon!!!
|
|
|
377 |
|
}
|
|
|
378 |
|
}
|
|
|
379 |
|
|
|
|
380 |
|
retu
rn r || lr
;
|
|
|
381 |
|
};
|
|
|
382 |
|
|
|
|
383 |
|
// Fix s
etContent
so it work
s
|
|
|
384 |
|
setConte
nt = ed.se
lection.se
tContent;
|
|
|
385 |
|
ed.selec
tion.setCo
ntent = fu
nction(h,
s) {
|
|
|
386 |
|
var
r = this.g
etRng(), b
;
|
|
|
387 |
|
|
|
|
388 |
|
try
{
|
|
|
389 |
|
setContent
.call(this
, h, s);
|
|
|
390 |
|
} ca
tch (ex) {
|
|
|
391 |
|
// Workaro
und for Sa
fari 2.x
|
|
|
392 |
|
b = dom.cr
eate('body
');
|
|
|
393 |
|
b.innerHTM
L = h;
|
|
|
394 |
|
|
|
|
395 |
|
each(b.chi
ldNodes, f
unction(n)
{
|
|
|
396 |
|
r.inse
rtNode(n.c
loneNode(t
rue));
|
|
|
397 |
|
});
|
|
|
398 |
|
}
|
|
|
399 |
|
};
|
|
|
400 |
|
},
|
|
|
401 |
|
|
|
|
402 |
|
_i
nsertBR :
function(e
d) {
|
|
|
403 |
|
var dom
= ed.dom,
s = ed.sel
ection, r
= s.getRng
(), br;
|
|
|
404 |
|
|
|
|
405 |
|
// Inser
t BR eleme
nt
|
|
|
406 |
|
r.insert
Node(br =
dom.create
('br'));
|
|
|
407 |
|
|
|
|
408 |
|
// Place
caret aft
er BR
|
|
|
409 |
|
r.setSta
rtAfter(br
);
|
|
|
410 |
|
r.setEnd
After(br);
|
|
|
411 |
|
s.setRng
(r);
|
|
|
412 |
|
|
|
|
413 |
|
// Could
not place
caret aft
er BR then
insert an
nbsp enti
ty and mov
e the care
t
|
|
|
414 |
|
if (s.ge
tSel().foc
usNode ==
br.previou
sSibling)
{
|
|
|
415 |
|
s.se
lect(dom.i
nsertAfter
(dom.doc.c
reateTextN
ode('\u00a
0'), br));
|
|
|
416 |
|
s.co
llapse(1);
|
|
|
417 |
|
}
|
|
|
418 |
|
|
|
|
419 |
|
// Scrol
l to new p
osition, s
crollIntoV
iew can't
be used du
e to bug:
http://bug
s.webkit.o
rg/show_bu
g.cgi?id=1
6117
|
|
|
420 |
|
ed.getWi
n().scroll
To(0, dom.
getPos(s.g
etRng().st
artContain
er).y);
|
|
|
421 |
|
}
|
|
|
422 |
|
});
|
|
|
423 |
|
|
|
|
424 |
|
// Reg
ister plug
in
|
|
|
425 |
|
tinymc
e.PluginMa
nager.add(
'safari',
tinymce.pl
ugins.Safa
ri);
|
|
|
426 |
|
})();
|
|
|
427 |
|
|