No regular expressions were active.
1 |
|
/**
|
|
1 |
|
/**
|
2 |
|
*
$Id:
editor_plu
gin_src.js
20
1
200
7
-0
2
-
1
2
15
:5
6
:
56
Z
spocke
$
|
|
2 |
|
*
$Id:
editor_plu
gin_src.js
69
1
200
8
-0
3
-
09
1
9
:5
8
:
20
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('table'
);
|
|
9 |
|
var ea
ch = tinym
ce.each;
|
10 |
|
|
|
10 |
|
|
11 |
|
var TinyMC
E_TablePlu
gin = {
|
|
11 |
|
tinymc
e.create('
tinymce.pl
ugins.Tabl
ePlugin',
{
|
12 |
|
getI
n
fo
:
function(
)
{
|
|
12 |
|
i
n
it
:
function(
ed,
url
)
{
|
13 |
|
re
turn {
|
|
13 |
|
var t =
this;
|
14 |
|
longname
: 'Tables
',
|
|
|
15 |
|
author :
'Moxiecod
e Systems
AB',
|
|
|
16 |
|
authorur
l : 'http:
//tinymce.
moxiecode.
com',
|
|
|
17 |
|
infourl
: 'http://
wiki.moxie
code.com/i
ndex.php/T
inyMCE:Plu
gins/table
',
|
|
|
18 |
|
version
: tinyMCE.
majorVersi
on + "." +
tinyMCE.m
inorVersio
n
|
|
|
19 |
|
};
|
|
|
20 |
|
},
|
|
|
21 |
|
|
|
14 |
|
|
22 |
|
initIn
stance : f
unction(in
st) {
|
|
15 |
|
t.editor
= ed;
|
23 |
|
if
(tinyMCE.
isGecko) {
|
|
16 |
|
t.url =
url;
|
24 |
|
var doc
= inst.get
Doc();
|
|
|
25 |
|
tinyMCE.
addEvent(d
oc, "mouse
up", TinyM
CE_TablePl
ugin._mous
eDownHandl
er);
|
|
|
26 |
|
}
|
|
|
27 |
|
|
|
17 |
|
|
28 |
|
in
st.tableRo
wClipboard
= null;
|
|
18 |
|
// Regis
ter button
s
|
29 |
|
}
,
|
|
19 |
|
each([
|
|
|
20 |
|
['ta
ble', 'tab
le.desc',
'mceInsert
Table', tr
ue],
|
|
|
21 |
|
['de
lete_table
', 'table.
del', 'mce
TableDelet
e'],
|
|
|
22 |
|
['de
lete_col',
'table.de
lete_col_d
esc', 'mce
TableDelet
eCol'],
|
|
|
23 |
|
['de
lete_row',
'table.de
lete_row_d
esc', 'mce
TableDelet
eRow'],
|
|
|
24 |
|
['co
l_after',
'table.col
_after_des
c', 'mceTa
bleInsertC
olAfter'],
|
|
|
25 |
|
['co
l_before',
'table.co
l_before_d
esc', 'mce
TableInser
tColBefore
'],
|
|
|
26 |
|
['ro
w_after',
'table.row
_after_des
c', 'mceTa
bleInsertR
owAfter'],
|
|
|
27 |
|
['ro
w_before',
'table.ro
w_before_d
esc', 'mce
TableInser
tRowBefore
'],
|
|
|
28 |
|
['ro
w_props',
'table.row
_desc', 'm
ceTableRow
Props', tr
ue],
|
|
|
29 |
|
['ce
ll_props',
'table.ce
ll_desc',
'mceTableC
ellProps',
true],
|
|
|
30 |
|
['sp
lit_cells'
, 'table.s
plit_cells
_desc', 'm
ceTableSpl
itCells',
true],
|
|
|
31 |
|
['me
rge_cells'
, 'table.m
erge_cells
_desc', 'm
ceTableMer
geCells',
true]
|
|
|
32 |
|
], funct
ion(c) {
|
|
|
33 |
|
ed.a
ddButton(c
[0], {titl
e : c[1],
cmd : c[2]
, ui : c[3
]});
|
|
|
34 |
|
}
);
|
30 |
|
|
|
35 |
|
|
31 |
|
/**
|
|
36 |
|
ed.onIni
t.add(func
tion() {
|
32 |
|
* Ret
urns the H
TML conten
ts of the
table cont
rol.
|
|
37 |
|
if (
ed && ed.p
lugins.con
textmenu)
{
|
33 |
|
*/
|
|
38 |
|
ed.plugins
.contextme
nu.onConte
xtMenu.add
(function(
th, m, e)
{
|
34 |
|
getCon
trolHTML :
function(
control_na
me) {
|
|
39 |
|
var sm
;
|
35 |
|
va
r controls
= new Arr
ay(
|
|
|
36 |
|
['table'
, 'table.g
if', 'lang
_table_des
c', 'mceIn
sertTable'
, true],
|
|
|
37 |
|
['delete
_table', '
table_dele
te.gif', '
lang_table
_del', 'mc
eTableDele
te'],
|
|
|
38 |
|
['delete
_col', 'ta
ble_delete
_col.gif',
'lang_tab
le_delete_
col_desc',
'mceTable
DeleteCol'
],
|
|
|
39 |
|
['delete
_row', 'ta
ble_delete
_row.gif',
'lang_tab
le_delete_
row_desc',
'mceTable
DeleteRow'
],
|
|
|
40 |
|
['col_af
ter', 'tab
le_insert_
col_after.
gif', 'lan
g_table_co
l_after_de
sc', 'mceT
ableInsert
ColAfter']
,
|
|
|
41 |
|
['col_be
fore', 'ta
ble_insert
_col_befor
e.gif', 'l
ang_table_
col_before
_desc', 'm
ceTableIns
ertColBefo
re'],
|
|
|
42 |
|
['row_af
ter', 'tab
le_insert_
row_after.
gif', 'lan
g_table_ro
w_after_de
sc', 'mceT
ableInsert
RowAfter']
,
|
|
|
43 |
|
['row_be
fore', 'ta
ble_insert
_row_befor
e.gif', 'l
ang_table_
row_before
_desc', 'm
ceTableIns
ertRowBefo
re'],
|
|
|
44 |
|
['row_pr
ops', 'tab
le_row_pro
ps.gif', '
lang_table
_row_desc'
, 'mceTabl
eRowProps'
, true],
|
|
|
45 |
|
['cell_p
rops', 'ta
ble_cell_p
rops.gif',
'lang_tab
le_cell_de
sc', 'mceT
ableCellPr
ops', true
],
|
|
|
46 |
|
['split_
cells', 't
able_split
_cells.gif
', 'lang_t
able_split
_cells_des
c', 'mceTa
bleSplitCe
lls', true
],
|
|
|
47 |
|
['merge_
cells', 't
able_merge
_cells.gif
', 'lang_t
able_merge
_cells_des
c', 'mceTa
bleMergeCe
lls', true
]);
|
|
|
48 |
|
|
|
40 |
|
|
49 |
|
//
Render ta
ble contro
l
|
|
41 |
|
if (ed
.dom.getPa
rent(e, 't
d') || ed.
dom.getPar
ent(e, 'th
')) {
|
50 |
|
fo
r (var i=0
; i<contro
ls.length;
i++) {
|
|
42 |
|
m.
removeAll(
);
|
51 |
|
var but
= controls
[i];
|
|
43 |
|
m.
add({title
: 'table.
desc', ico
n : 'table
', cmd : '
mceInsertT
able', ui
: true, va
lue : {act
ion : 'ins
ert'}});
|
52 |
|
var cmd
= 'tinyMCE
.execInsta
nceCommand
(\'{$edito
r_id}\',\'
' + but[3]
+ '\', '
+ (but.len
gth > 4 ?
but[4] : f
alse) + (b
ut.length
> 5 ? ', \
'' + but[5
] + '\'' :
'') + ');
return fal
se;';
|
|
44 |
|
m.
add({title
: 'table.
props_desc
', icon :
'table_pro
ps', cmd :
'mceInser
tTable', u
i : true})
;
|
|
|
45 |
|
m.
add({title
: 'table.
del', icon
: 'delete
_table', c
md : 'mceT
ableDelete
', ui : tr
ue});
|
|
|
46 |
|
m.
addSeparat
or();
|
53 |
|
|
|
47 |
|
|
54 |
|
if (but[
0] == cont
rol_name)
|
|
48 |
|
//
Cell menu
|
55 |
|
retu
rn tinyMCE
.getButton
HTML(contr
ol_name, b
ut[2], '{$
pluginurl}
/images/'+
but[1], b
ut[3], (bu
t.length >
4 ? but[4
] : false)
);
|
|
49 |
|
sm
= m.addMe
nu({title
: 'table.c
ell'});
|
56 |
|
}
|
|
50 |
|
sm
.add({titl
e : 'table
.cell_desc
', icon :
'cell_prop
s', cmd :
'mceTableC
ellProps',
ui : true
});
|
|
|
51 |
|
sm
.add({titl
e : 'table
.split_cel
ls_desc',
icon : 'sp
lit_cells'
, cmd : 'm
ceTableSpl
itCells',
ui : true}
);
|
|
|
52 |
|
sm
.add({titl
e : 'table
.merge_cel
ls_desc',
icon : 'me
rge_cells'
, cmd : 'm
ceTableMer
geCells',
ui : true}
);
|
|
|
53 |
|
|
|
|
54 |
|
//
Row menu
|
|
|
55 |
|
sm
= m.addMe
nu({title
: 'table.r
ow'});
|
|
|
56 |
|
sm
.add({titl
e : 'table
.row_desc'
, icon : '
row_props'
, cmd : 'm
ceTableRow
Props', ui
: true});
|
|
|
57 |
|
sm
.add({titl
e : 'table
.row_befor
e_desc', i
con : 'row
_before',
cmd : 'mce
TableInser
tRowBefore
'});
|
|
|
58 |
|
sm
.add({titl
e : 'table
.row_after
_desc', ic
on : 'row_
after', cm
d : 'mceTa
bleInsertR
owAfter'})
;
|
|
|
59 |
|
sm
.add({titl
e : 'table
.delete_ro
w_desc', i
con : 'del
ete_row',
cmd : 'mce
TableDelet
eRow'});
|
|
|
60 |
|
sm
.addSepara
tor();
|
|
|
61 |
|
sm
.add({titl
e : 'table
.cut_row_d
esc', icon
: 'cut',
cmd : 'mce
TableCutRo
w'});
|
|
|
62 |
|
sm
.add({titl
e : 'table
.copy_row_
desc', ico
n : 'copy'
, cmd : 'm
ceTableCop
yRow'});
|
|
|
63 |
|
sm
.add({titl
e : 'table
.paste_row
_before_de
sc', icon
: 'paste',
cmd : 'mc
eTablePast
eRowBefore
'});
|
|
|
64 |
|
sm
.add({titl
e : 'table
.paste_row
_after_des
c', icon :
'paste',
cmd : 'mce
TablePaste
RowAfter'}
);
|
57 |
|
|
|
65 |
|
|
58 |
|
//
Special t
ablecontro
ls
|
|
66 |
|
//
Column me
nu
|
59 |
|
if
(control_
name == "t
ablecontro
ls") {
|
|
67 |
|
sm
= m.addMe
nu({title
: 'table.c
ol'});
|
60 |
|
var html
= "";
|
|
68 |
|
sm
.add({titl
e : 'table
.col_befor
e_desc', i
con : 'col
_before',
cmd : 'mce
TableInser
tColBefore
'});
|
|
|
69 |
|
sm
.add({titl
e : 'table
.col_after
_desc', ic
on : 'col_
after', cm
d : 'mceTa
bleInsertC
olAfter'})
;
|
|
|
70 |
|
sm
.add({titl
e : 'table
.delete_co
l_desc', i
con : 'del
ete_col',
cmd : 'mce
TableDelet
eCol'});
|
|
|
71 |
|
} else
|
|
|
72 |
|
m.
add({title
: 'table.
desc', ico
n : 'table
', cmd : '
mceInsertT
able', ui
: true});
|
|
|
73 |
|
});
|
|
|
74 |
|
}
|
|
|
75 |
|
});
|
61 |
|
|
|
76 |
|
|
62 |
|
html +=
tinyMCE.ge
tControlHT
ML("table"
);
|
|
77 |
|
// Block
delete on
gecko ins
ide TD:s.
Gecko is r
emoving ta
ble elemen
ts and the
n produces
incorrect
tables
|
63 |
|
html +=
tinyMCE.ge
tControlHT
ML("separa
tor");
|
|
78 |
|
// The b
ackspace k
ey also re
moved TD:s
but this
one can no
t be block
ed
|
64 |
|
html +=
tinyMCE.ge
tControlHT
ML("row_pr
ops");
|
|
79 |
|
if (tiny
mce.isGeck
o) {
|
65 |
|
html +=
tinyMCE.ge
tControlHT
ML("cell_p
rops");
|
|
80 |
|
ed.o
nKeyPress.
add(functi
on(ed, e)
{
|
66 |
|
html +=
tinyMCE.ge
tControlHT
ML("separa
tor");
|
|
81 |
|
var n;
|
67 |
|
html +=
tinyMCE.ge
tControlHT
ML("row_be
fore");
|
|
|
68 |
|
html +=
tinyMCE.ge
tControlHT
ML("row_af
ter");
|
|
|
69 |
|
html +=
tinyMCE.ge
tControlHT
ML("delete
_row");
|
|
|
70 |
|
html +=
tinyMCE.ge
tControlHT
ML("separa
tor");
|
|
|
71 |
|
html +=
tinyMCE.ge
tControlHT
ML("col_be
fore");
|
|
|
72 |
|
html +=
tinyMCE.ge
tControlHT
ML("col_af
ter");
|
|
|
73 |
|
html +=
tinyMCE.ge
tControlHT
ML("delete
_col");
|
|
|
74 |
|
html +=
tinyMCE.ge
tControlHT
ML("separa
tor");
|
|
|
75 |
|
html +=
tinyMCE.ge
tControlHT
ML("split_
cells");
|
|
|
76 |
|
html +=
tinyMCE.ge
tControlHT
ML("merge_
cells");
|
|
|
77 |
|
|
|
82 |
|
|
78 |
|
return h
tml;
|
|
83 |
|
if (e.keyC
ode == 46)
{
|
|
|
84 |
|
n = ed
.dom.getPa
rent(ed.se
lection.ge
tNode(), '
TD,TH');
|
|
|
85 |
|
if (n
&& (!n.has
ChildNodes
() || (n.c
hildNodes.
length ==
1 && n.fir
stChild.no
deName ==
'BR')))
|
|
|
86 |
|
ti
nymce.dom.
Event.canc
el(e);
|
|
|
87 |
|
}
|
|
|
88 |
|
});
|
79 |
|
}
|
|
89 |
|
}
|
80 |
|
|
|
90 |
|
|
81 |
|
re
turn "";
|
|
91 |
|
// Add u
ndo level
when new r
ows are cr
eated usin
g the tab
key
|
|
|
92 |
|
ed.onKey
Down.add(f
unction(ed
, e) {
|
|
|
93 |
|
if (
e.keyCode
== 9 && ed
.dom.getPa
rent(ed.se
lection.ge
tNode(), '
TABLE'))
|
|
|
94 |
|
ed.undoMan
ager.add()
;
|
|
|
95 |
|
});
|
|
|
96 |
|
|
|
|
97 |
|
ed.onNod
eChange.ad
d(function
(ed, cm, n
) {
|
|
|
98 |
|
var
p = ed.dom
.getParent
(n, 'td,th
,caption')
;
|
|
|
99 |
|
|
|
|
100 |
|
cm.s
etActive('
table', !!
p);
|
|
|
101 |
|
if (
p && p.nod
eName ===
'CAPTION')
|
|
|
102 |
|
p = null;
|
|
|
103 |
|
|
|
|
104 |
|
cm.s
etDisabled
('delete_t
able', !p)
;
|
|
|
105 |
|
cm.s
etDisabled
('delete_c
ol', !p);
|
|
|
106 |
|
cm.s
etDisabled
('delete_t
able', !p)
;
|
|
|
107 |
|
cm.s
etDisabled
('delete_r
ow', !p);
|
|
|
108 |
|
cm.s
etDisabled
('col_afte
r', !p);
|
|
|
109 |
|
cm.s
etDisabled
('col_befo
re', !p);
|
|
|
110 |
|
cm.s
etDisabled
('row_afte
r', !p);
|
|
|
111 |
|
cm.s
etDisabled
('row_befo
re', !p);
|
|
|
112 |
|
cm.s
etDisabled
('row_prop
s', !p);
|
|
|
113 |
|
cm.s
etDisabled
('cell_pro
ps', !p);
|
|
|
114 |
|
cm.s
etDisabled
('split_ce
lls', !p |
| (parseIn
t(ed.dom.g
etAttrib(p
, 'colspan
', '1')) <
2 && pars
eInt(ed.do
m.getAttri
b(p, 'rows
pan', '1')
) < 2));
|
|
|
115 |
|
cm.s
etDisabled
('merge_ce
lls', !p);
|
|
|
116 |
|
});
|
82 |
|
},
|
|
117 |
|
},
|
83 |
|
|
|
118 |
|
|
84 |
|
/**
|
|
119 |
|
execComman
d
:
function(
c
m
d,
u
i
,
val
)
{
|
85 |
|
* Exe
cutes the
table comm
ands.
|
|
120 |
|
var ed =
this.edit
or, b;
|
86 |
|
*/
|
|
121 |
|
|
87 |
|
execComman
d
:
function(
editor_id,
element,
c
om
m
an
d,
u
ser_
i
nterface
,
val
ue
)
{
|
|
|
88 |
|
//
Is table
command
|
|
122 |
|
// Is ta
ble comman
d
|
89 |
|
switch
(c
om
m
an
d)
{
|
|
123 |
|
switch
(c
m
d)
{
|
90 |
|
case "mc
eInsertTab
le":
|
|
124 |
|
case
"mceInser
tTable":
|
91 |
|
case "mc
eTableRowP
rops":
|
|
125 |
|
case
"mceTable
RowProps":
|
92 |
|
case "mc
eTableCell
Props":
|
|
126 |
|
case
"mceTable
CellProps"
:
|
93 |
|
case "mc
eTableSpli
tCells":
|
|
127 |
|
case
"mceTable
SplitCells
":
|
94 |
|
case "mc
eTableMerg
eCells":
|
|
128 |
|
case
"mceTable
MergeCells
":
|
95 |
|
case "mc
eTableInse
rtRowBefor
e":
|
|
129 |
|
case
"mceTable
InsertRowB
efore":
|
96 |
|
case "mc
eTableInse
rtRowAfter
":
|
|
130 |
|
case
"mceTable
InsertRowA
fter":
|
97 |
|
case "mc
eTableDele
teRow":
|
|
131 |
|
case
"mceTable
DeleteRow"
:
|
98 |
|
case "mc
eTableInse
rtColBefor
e":
|
|
132 |
|
case
"mceTable
InsertColB
efore":
|
99 |
|
case "mc
eTableInse
rtColAfter
":
|
|
133 |
|
case
"mceTable
InsertColA
fter":
|
100 |
|
case "mc
eTableDele
teCol":
|
|
134 |
|
case
"mceTable
DeleteCol"
:
|
101 |
|
case "mc
eTableCutR
ow":
|
|
135 |
|
case
"mceTable
CutRow":
|
102 |
|
case "mc
eTableCopy
Row":
|
|
136 |
|
case
"mceTable
CopyRow":
|
103 |
|
case "mc
eTablePast
eRowBefore
":
|
|
137 |
|
case
"mceTable
PasteRowBe
fore":
|
104 |
|
case "mc
eTablePast
eRowAfter"
:
|
|
138 |
|
case
"mceTable
PasteRowAf
ter":
|
105 |
|
case "mc
eTableDele
te":
|
|
139 |
|
case
"mceTable
Delete":
|
106 |
|
var
inst = tin
yMCE.getIn
stanceById
(editor_id
);
|
|
140 |
|
ed
.execComma
nd('mceBeg
inUndoLeve
l');
|
107 |
|
|
|
141 |
|
th
i
s
._doExecCo
mmand(
c
m
d,
u
i
,
val
);
|
108 |
|
inst
.execComma
nd('mceBeg
inUndoLeve
l');
|
|
142 |
|
ed
.execComma
nd('mceEnd
UndoLevel'
);
|
109 |
|
TinyMCE_Ta
blePlug
i
n
._doExecCo
mmand(
editor_id,
element,
c
o
m
man
d,
u
ser_
i
nterface
,
val
ue
);
|
|
|
110 |
|
inst
.execComma
nd('mceEnd
UndoLevel'
);
|
|
|
111 |
|
|
|
143 |
|
|
112 |
|
retu
rn true;
|
|
144 |
|
return tru
e;
|
113 |
|
}
|
|
145 |
|
}
|
114 |
|
|
|
146 |
|
|
115 |
|
//
Pass to n
ext handle
r in chain
|
|
147 |
|
// Pass
to next ha
ndler in c
hain
|
116 |
|
re
turn false
;
|
|
148 |
|
return f
alse;
|
117 |
|
},
|
|
149 |
|
},
|
118 |
|
|
|
150 |
|
|
119 |
|
handle
NodeChange
: functio
n(editor_i
d, node, u
ndo_index,
undo_leve
ls, visual
_aid, any_
selection)
{
|
|
151 |
|
ge
tInfo : fu
nction() {
|
120 |
|
va
r colspan
= "1", row
span = "1"
, tdElm;
|
|
152 |
|
return {
|
121 |
|
|
|
153 |
|
long
name : 'Ta
bles',
|
122 |
|
va
r inst = t
inyMCE.get
InstanceBy
Id(editor_
id);
|
|
154 |
|
auth
or : 'Moxi
ecode Syst
ems AB',
|
123 |
|
|
|
155 |
|
auth
orurl : 'h
ttp://tiny
mce.moxiec
ode.com',
|
124 |
|
//
Reset tab
le control
s
|
|
156 |
|
info
url : 'htt
p://wiki.m
oxiecode.c
om/index.p
hp/TinyMCE
:Plugins/t
able',
|
125 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_table',
'mceButton
Normal');
|
|
157 |
|
vers
ion : tiny
mce.majorV
ersion + "
." + tinym
ce.minorVe
rsion
|
126 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_delete_t
able', 'mc
eButtonDis
abled');
|
|
158 |
|
}
;
|
127 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_row_prop
s', 'mceBu
ttonDisabl
ed');
|
|
|
128 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_cell_pro
ps', 'mceB
uttonDisab
led');
|
|
|
129 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_row_befo
re', 'mceB
uttonDisab
led');
|
|
|
130 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_row_afte
r', 'mceBu
ttonDisabl
ed');
|
|
|
131 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_delete_r
ow', 'mceB
uttonDisab
led');
|
|
|
132 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_col_befo
re', 'mceB
uttonDisab
led');
|
|
|
133 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_col_afte
r', 'mceBu
ttonDisabl
ed');
|
|
|
134 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_delete_c
ol', 'mceB
uttonDisab
led');
|
|
|
135 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_split_ce
lls', 'mce
ButtonDisa
bled');
|
|
|
136 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_merge_ce
lls', 'mce
ButtonDisa
bled');
|
|
|
137 |
|
|
|
|
138 |
|
//
Within a
td element
|
|
|
139 |
|
if
(tdElm =
tinyMCE.ge
tParentEle
ment(node,
"td,th"))
{
|
|
|
140 |
|
tinyMCE.
switchClas
s(editor_i
d + '_cell
_props', '
mceButtonS
elected');
|
|
|
141 |
|
tinyMCE.
switchClas
s(editor_i
d + '_dele
te_table',
'mceButto
nNormal');
|
|
|
142 |
|
tinyMCE.
switchClas
s(editor_i
d + '_row_
before', '
mceButtonN
ormal');
|
|
|
143 |
|
tinyMCE.
switchClas
s(editor_i
d + '_row_
after', 'm
ceButtonNo
rmal');
|
|
|
144 |
|
tinyMCE.
switchClas
s(editor_i
d + '_dele
te_row', '
mceButtonN
ormal');
|
|
|
145 |
|
tinyMCE.
switchClas
s(editor_i
d + '_col_
before', '
mceButtonN
ormal');
|
|
|
146 |
|
tinyMCE.
switchClas
s(editor_i
d + '_col_
after', 'm
ceButtonNo
rmal');
|
|
|
147 |
|
tinyMCE.
switchClas
s(editor_i
d + '_dele
te_col', '
mceButtonN
ormal');
|
|
|
148 |
|
|
|
|
149 |
|
colspan
= tinyMCE.
getAttrib(
tdElm, "co
lspan");
|
|
|
150 |
|
rowspan
= tinyMCE.
getAttrib(
tdElm, "ro
wspan");
|
|
|
151 |
|
|
|
|
152 |
|
colspan
= colspan
== "" ? "1
" : colspa
n;
|
|
|
153 |
|
rowspan
= rowspan
== "" ? "1
" : rowspa
n;
|
|
|
154 |
|
|
|
|
155 |
|
if (cols
pan != "1"
|| rowspa
n != "1")
|
|
|
156 |
|
tiny
MCE.switch
Class(edit
or_id + '_
split_cell
s', 'mceBu
ttonNormal
');
|
|
|
157 |
|
}
|
|
|
158 |
|
|
|
|
159 |
|
//
Within a
tr element
|
|
|
160 |
|
if
(tinyMCE.
getParentE
lement(nod
e, "tr"))
|
|
|
161 |
|
tinyMCE.
switchClas
s(editor_i
d + '_row_
props', 'm
ceButtonSe
lected');
|
|
|
162 |
|
|
|
|
163 |
|
//
Within ta
ble
|
|
|
164 |
|
if
(tinyMCE.
getParentE
lement(nod
e, "table"
)) {
|
|
|
165 |
|
tinyMCE.
switchClas
s(editor_i
d + '_tabl
e', 'mceBu
ttonSelect
ed');
|
|
|
166 |
|
tinyMCE.
switchClas
s(editor_i
d + '_merg
e_cells',
'mceButton
Normal');
|
|
|
167 |
|
}
|
|
|
168 |
|
},
|
|
159 |
|
},
|
169 |
|
|
|
160 |
|
|
170 |
|
// Pri
vate plugi
n internal
methods
|
|
161 |
|
//
Private p
lugin inte
rnal metho
ds
|
171 |
|
|
|
162 |
|
|
172 |
|
_mouse
DownHandle
r : functi
on(e) {
|
|
|
173 |
|
va
r elm = ti
nyMCE.isMS
IE ? event
.srcElemen
t : e.targ
et;
|
|
|
174 |
|
va
r focusElm
= tinyMCE
.selectedI
nstance.ge
tFocusElem
ent();
|
|
|
175 |
|
|
|
|
176 |
|
//
If press
on special
Mozilla c
reate TD/T
R thingie
|
|
|
177 |
|
if
(elm.node
Name == "B
ODY" && (f
ocusElm.no
deName ==
"TD" || fo
cusElm.nod
eName == "
TH" || (fo
cusElm.par
entNode &&
focusElm.
parentNode
.nodeName
== "TD") |
|(focusElm
.parentNod
e && focus
Elm.parent
Node.nodeN
ame == "TH
") )) {
|
|
|
178 |
|
window.s
etTimeout(
function()
{
|
|
|
179 |
|
var
tableElm =
tinyMCE.g
etParentEl
ement(focu
sElm, "tab
le");
|
|
|
180 |
|
tiny
MCE.handle
VisualAid(
tableElm,
true, tiny
MCE.settin
gs['visual
'], tinyMC
E.selected
Instance);
|
|
|
181 |
|
}, 10);
|
|
|
182 |
|
}
|
|
|
183 |
|
},
|
|
|
184 |
|
|
|
|
185 |
|
/**
|
|
163 |
|
/*
*
|
186 |
|
* Exe
cutes the
table comm
ands.
|
|
164 |
|
*
Executes
the table
commands.
|
187 |
|
*/
|
|
165 |
|
*
/
|
188 |
|
_doExecCom
mand
:
function(
editor_id,
element,
command,
user_inter
face,
value)
{
|
|
166 |
|
_doExecCom
mand
:
function(
command,
user_inter
face,
value)
{
|
189 |
|
va
r inst = t
inyMCE.get
InstanceBy
Id(editor_
id);
|
|
167 |
|
var inst
= this.ed
itor, ed =
inst, url
= this.ur
l;
|
190 |
|
var
focusElm
=
inst.
getFocu
s
El
e
m
e
n
t
();
|
|
168 |
|
var
focusElm
=
inst.
s
e
l
e
ctio
n
.ge
t
Node
();
|
191 |
|
var
trElm
=
t
in
yMCE
.getParent
Element
(focusElm,
"tr");
|
|
169 |
|
var
trElm
=
in
st.dom
.getParent
(focusElm,
"tr");
|
192 |
|
var
tdElm
=
t
in
yMCE
.getParent
Element
(focusElm,
"td,th");
|
|
170 |
|
var
tdElm
=
in
st.dom
.getParent
(focusElm,
"td,th");
|
193 |
|
var
tableElm
=
t
in
yMCE
.getParent
Element
(focusElm,
"table");
|
|
171 |
|
var
tableElm
=
in
st.dom
.getParent
(focusElm,
"table");
|
194 |
|
va
r doc = in
st.content
Window.doc
ument;
|
|
172 |
|
var doc
= inst.con
tentWindow
.document;
|
195 |
|
va
r tableBor
der = tabl
eElm ? tab
leElm.getA
ttribute("
border") :
"";
|
|
173 |
|
var tabl
eBorder =
tableElm ?
tableElm.
getAttribu
te("border
") : "";
|
196 |
|
|
|
174 |
|
|
197 |
|
//
Get first
TD if no
TD found
|
|
175 |
|
// Get f
irst TD if
no TD fou
nd
|
198 |
|
if
(trElm &&
tdElm ==
null)
|
|
176 |
|
if (trEl
m && tdElm
== null)
|
199 |
|
tdElm =
trElm.cell
s[0];
|
|
177 |
|
tdEl
m = trElm.
cells[0];
|
200 |
|
|
|
178 |
|
|
201 |
|
//
------- I
nner funct
ions -----
----
|
|
|
202 |
|
fu
nction inA
rray(ar, v
) {
|
|
179 |
|
function
inArray(a
r, v) {
|
203 |
|
for (var
i=0; i<ar
.length; i
++) {
|
|
180 |
|
for
(var i=0;
i<ar.lengt
h; i++) {
|
204 |
|
// I
s array
|
|
181 |
|
// Is arra
y
|
205 |
|
if (
ar[i].leng
th > 0 &&
inArray(ar
[i], v))
|
|
182 |
|
if (ar[i].
length > 0
&& inArra
y(ar[i], v
))
|
206 |
|
return tru
e;
|
|
183 |
|
return
true;
|
207 |
|
|
|
184 |
|
|
208 |
|
// F
ound value
|
|
185 |
|
// Found v
alue
|
209 |
|
if (
ar[i] == v
)
|
|
186 |
|
if (ar[i]
== v)
|
210 |
|
return tru
e;
|
|
187 |
|
return
true;
|
211 |
|
}
|
|
188 |
|
}
|
212 |
|
|
|
189 |
|
|
213 |
|
return f
alse;
|
|
190 |
|
retu
rn false;
|
214 |
|
}
|
|
191 |
|
}
|
215 |
|
|
|
192 |
|
|
|
|
193 |
|
function
select(dx
, dy) {
|
|
|
194 |
|
var
td;
|
|
|
195 |
|
|
|
|
196 |
|
grid
= getTabl
eGrid(tabl
eElm);
|
|
|
197 |
|
dx =
dx || 0;
|
|
|
198 |
|
dy =
dy || 0;
|
|
|
199 |
|
dx =
Math.max(
cpos.celli
ndex + dx,
0);
|
|
|
200 |
|
dy =
Math.max(
cpos.rowin
dex + dy,
0);
|
|
|
201 |
|
|
|
|
202 |
|
// R
ecalculate
grid and
select
|
|
|
203 |
|
inst
.execComma
nd('mceRep
aint');
|
|
|
204 |
|
td =
getCell(g
rid, dy, d
x);
|
|
|
205 |
|
|
|
|
206 |
|
if (
td) {
|
|
|
207 |
|
inst.selec
tion.selec
t(td.first
Child || t
d);
|
|
|
208 |
|
inst.selec
tion.colla
pse(1);
|
|
|
209 |
|
}
|
|
|
210 |
|
};
|
|
|
211 |
|
|
216 |
|
fu
nction mak
eTD() {
|
|
212 |
|
function
makeTD()
{
|
217 |
|
var newT
D = doc.cr
eateElemen
t("td");
|
|
213 |
|
var
newTD = do
c.createEl
ement("td"
);
|
218 |
|
newTD.inne
rHTML
=
"&n
b
s
p;
"
;
|
|
214 |
|
|
|
|
215 |
|
if (
!tinymce.i
sIE)
|
|
|
216 |
|
newTD.inne
rHTML
=
'<br
mce_
b
ogu
s
=
"
1"/>'
;
|
219 |
|
}
|
|
217 |
|
}
|
220 |
|
|
|
218 |
|
|
221 |
|
fu
nction get
ColRowSpan
(td) {
|
|
219 |
|
function
getColRow
Span(td) {
|
222 |
|
var
colspan
=
t
in
yMCE
.getAttrib
(td,
"colspan")
;
|
|
220 |
|
var
colspan
=
in
st.dom
.getAttrib
(td,
"colspan")
;
|
223 |
|
var
rowspan
=
t
in
yMCE
.getAttrib
(td,
"rowspan")
;
|
|
221 |
|
var
rowspan
=
in
st.dom
.getAttrib
(td,
"rowspan")
;
|
224 |
|
|
|
222 |
|
|
225 |
|
colspan
= colspan
== "" ? 1
: parseInt
(colspan);
|
|
223 |
|
cols
pan = cols
pan == ""
? 1 : pars
eInt(colsp
an);
|
226 |
|
rowspan
= rowspan
== "" ? 1
: parseInt
(rowspan);
|
|
224 |
|
rows
pan = rows
pan == ""
? 1 : pars
eInt(rowsp
an);
|
227 |
|
|
|
225 |
|
|
228 |
|
return {
colspan :
colspan, r
owspan : r
owspan};
|
|
226 |
|
retu
rn {colspa
n : colspa
n, rowspan
: rowspan
};
|
229 |
|
}
|
|
227 |
|
}
|
230 |
|
|
|
228 |
|
|
231 |
|
fu
nction get
CellPos(gr
id, td) {
|
|
229 |
|
function
getCellPo
s(grid, td
) {
|
232 |
|
var x, y
;
|
|
230 |
|
var
x, y;
|
233 |
|
|
|
231 |
|
|
234 |
|
for (y=0
; y<grid.l
ength; y++
) {
|
|
232 |
|
for
(y=0; y<gr
id.length;
y++) {
|
235 |
|
for
(x=0; x<gr
id[y].leng
th; x++) {
|
|
233 |
|
for (x=0;
x<grid[y].
length; x+
+) {
|
236 |
|
if (grid[y
][x] == td
)
|
|
234 |
|
if (gr
id[y][x] =
= td)
|
237 |
|
return
{cellinde
x : x, row
index : y}
;
|
|
235 |
|
re
turn {cell
index : x,
rowindex
: y};
|
238 |
|
}
|
|
236 |
|
}
|
239 |
|
}
|
|
237 |
|
}
|
240 |
|
|
|
238 |
|
|
241 |
|
return n
ull;
|
|
239 |
|
retu
rn null;
|
242 |
|
}
|
|
240 |
|
}
|
243 |
|
|
|
241 |
|
|
244 |
|
fu
nction get
Cell(grid,
row, col)
{
|
|
242 |
|
function
getCell(g
rid, row,
col) {
|
245 |
|
if (grid
[row] && g
rid[row][c
ol])
|
|
243 |
|
if (
grid[row]
&& grid[ro
w][col])
|
246 |
|
retu
rn grid[ro
w][col];
|
|
244 |
|
return gri
d[row][col
];
|
247 |
|
|
|
245 |
|
|
248 |
|
return n
ull;
|
|
246 |
|
retu
rn null;
|
249 |
|
}
|
|
247 |
|
}
|
250 |
|
|
|
248 |
|
|
251 |
|
fu
nction get
TableGrid(
table) {
|
|
249 |
|
function
getTableG
rid(table)
{
|
252 |
|
var
grid
=
new
Array()
,
rows
=
table.rows
,
x,
y,
td,
sd,
xstart,
x2,
y2;
|
|
250 |
|
var
grid
=
[]
,
rows
=
table.rows
,
x,
y,
td,
sd,
xstart,
x2,
y2;
|
253 |
|
|
|
251 |
|
|
254 |
|
for (y=0
; y<rows.l
ength; y++
) {
|
|
252 |
|
for
(y=0; y<ro
ws.length;
y++) {
|
255 |
|
for
(x=0; x<ro
ws[y].cell
s.length;
x++) {
|
|
253 |
|
for (x=0;
x<rows[y].
cells.leng
th; x++) {
|
256 |
|
td = rows[
y].cells[x
];
|
|
254 |
|
td = r
ows[y].cel
ls[x];
|
257 |
|
sd = getCo
lRowSpan(t
d);
|
|
255 |
|
sd = g
etColRowSp
an(td);
|
258 |
|
|
|
256 |
|
|
259 |
|
// All rea
dy filled
|
|
257 |
|
// All
ready fil
led
|
260 |
|
for (xstar
t = x; gri
d[y] && gr
id[y][xsta
rt]; xstar
t++) ;
|
|
258 |
|
for (x
start = x;
grid[y] &
& grid[y][
xstart]; x
start++) ;
|
261 |
|
|
|
259 |
|
|
262 |
|
// Fill bo
x
|
|
260 |
|
// Fil
l box
|
263 |
|
for (y2=y;
y2<y+sd['
rowspan'];
y2++) {
|
|
261 |
|
for (y
2=y; y2<y+
sd['rowspa
n']; y2++)
{
|
264 |
|
if (!g
rid[y2])
|
|
262 |
|
if
(!grid[y2
])
|
265 |
|
grid[y2]
=
new
Array()
;
|
|
263 |
|
grid[y2]
=
[]
;
|
266 |
|
|
|
264 |
|
|
267 |
|
for (x
2=xstart;
x2<xstart+
sd['colspa
n']; x2++)
|
|
265 |
|
fo
r (x2=xsta
rt; x2<xst
art+sd['co
lspan']; x
2++)
|
268 |
|
gr
id[y2][x2]
= td;
|
|
266 |
|
grid[y2]
[x2] = td;
|
269 |
|
}
|
|
267 |
|
}
|
270 |
|
}
|
|
268 |
|
}
|
271 |
|
}
|
|
269 |
|
}
|
272 |
|
|
|
270 |
|
|
273 |
|
return g
rid;
|
|
271 |
|
retu
rn grid;
|
274 |
|
}
|
|
272 |
|
}
|
275 |
|
|
|
273 |
|
|
276 |
|
fu
nction tri
mRow(table
, tr, td,
new_tr) {
|
|
274 |
|
function
trimRow(t
able, tr,
td, new_tr
) {
|
277 |
|
var grid
= getTabl
eGrid(tabl
e), cpos =
getCellPo
s(grid, td
);
|
|
275 |
|
var
grid = get
TableGrid(
table), cp
os = getCe
llPos(grid
, td);
|
278 |
|
var cell
s, lastElm
;
|
|
276 |
|
var
cells, las
tElm;
|
279 |
|
|
|
277 |
|
|
280 |
|
// Time
to crop aw
ay some
|
|
278 |
|
// T
ime to cro
p away som
e
|
281 |
|
if (new_
tr.cells.l
ength != t
r.childNod
es.length)
{
|
|
279 |
|
if (
new_tr.cel
ls.length
!= tr.chil
dNodes.len
gth) {
|
282 |
|
cell
s = tr.chi
ldNodes;
|
|
280 |
|
cells = tr
.childNode
s;
|
283 |
|
last
Elm = null
;
|
|
281 |
|
lastElm =
null;
|
284 |
|
|
|
282 |
|
|
285 |
|
for
(var x=0;
td = getCe
ll(grid, c
pos.rowind
ex, x); x+
+) {
|
|
283 |
|
for (var x
=0; td = g
etCell(gri
d, cpos.ro
windex, x)
; x++) {
|
286 |
|
var remove
= true;
|
|
284 |
|
var re
move = tru
e;
|
287 |
|
var sd = g
etColRowSp
an(td);
|
|
285 |
|
var sd
= getColR
owSpan(td)
;
|
288 |
|
|
|
286 |
|
|
289 |
|
// Remove
due to row
span
|
|
287 |
|
// Rem
ove due to
rowspan
|
290 |
|
if (inArra
y(cells, t
d)) {
|
|
288 |
|
if (in
Array(cell
s, td)) {
|
291 |
|
new_tr
.childNode
s[x]._dele
te = true;
|
|
289 |
|
ne
w_tr.child
Nodes[x]._
delete = t
rue;
|
292 |
|
} else if
((lastElm
== null ||
td != las
tElm) && s
d.colspan
> 1) { //
Remove due
to colspa
n
|
|
290 |
|
} else
if ((last
Elm == nul
l || td !=
lastElm)
&& sd.cols
pan > 1) {
// Remove
due to co
lspan
|
293 |
|
for (v
ar i=x; i<
x+td.colSp
an; i++)
|
|
291 |
|
fo
r (var i=x
; i<x+td.c
olSpan; i+
+)
|
294 |
|
ne
w_tr.child
Nodes[i]._
delete = t
rue;
|
|
292 |
|
new_tr.c
hildNodes[
i]._delete
= true;
|
295 |
|
}
|
|
293 |
|
}
|
296 |
|
|
|
294 |
|
|
297 |
|
if ((lastE
lm == null
|| td !=
lastElm) &
& sd.rowsp
an > 1)
|
|
295 |
|
if ((l
astElm ==
null || td
!= lastEl
m) && sd.r
owspan > 1
)
|
298 |
|
td.row
Span = sd.
rowspan +
1;
|
|
296 |
|
td
.rowSpan =
sd.rowspa
n + 1;
|
299 |
|
|
|
297 |
|
|
300 |
|
lastElm =
td;
|
|
298 |
|
lastEl
m = td;
|
301 |
|
}
|
|
299 |
|
}
|
302 |
|
|
|
300 |
|
|
303 |
|
dele
teMarked(t
ableElm);
|
|
301 |
|
deleteMark
ed(tableEl
m);
|
304 |
|
}
|
|
302 |
|
}
|
305 |
|
}
|
|
303 |
|
}
|
306 |
|
|
|
304 |
|
|
307 |
|
fu
nction pre
vElm(node,
name) {
|
|
305 |
|
function
prevElm(n
ode, name)
{
|
308 |
|
while ((
node = nod
e.previous
Sibling) !
= null) {
|
|
306 |
|
whil
e ((node =
node.prev
iousSiblin
g) != null
) {
|
309 |
|
if (
node.nodeN
ame == nam
e)
|
|
307 |
|
if (node.n
odeName ==
name)
|
310 |
|
return nod
e;
|
|
308 |
|
return
node;
|
311 |
|
}
|
|
309 |
|
}
|
312 |
|
|
|
310 |
|
|
313 |
|
return n
ull;
|
|
311 |
|
retu
rn null;
|
314 |
|
}
|
|
312 |
|
}
|
315 |
|
|
|
313 |
|
|
316 |
|
fu
nction nex
tElm(node,
names) {
|
|
314 |
|
function
nextElm(n
ode, names
) {
|
317 |
|
var name
sAr = name
s.split(',
');
|
|
315 |
|
var
namesAr =
names.spli
t(',');
|
318 |
|
|
|
316 |
|
|
319 |
|
while ((
node = nod
e.nextSibl
ing) != nu
ll) {
|
|
317 |
|
whil
e ((node =
node.next
Sibling) !
= null) {
|
320 |
|
for
(var i=0;
i<namesAr.
length; i+
+) {
|
|
318 |
|
for (var i
=0; i<name
sAr.length
; i++) {
|
321 |
|
if (node.n
odeName.to
LowerCase(
) == names
Ar[i].toLo
werCase()
)
|
|
319 |
|
if (no
de.nodeNam
e.toLowerC
ase() == n
amesAr[i].
toLowerCas
e() )
|
322 |
|
return
node;
|
|
320 |
|
re
turn node;
|
323 |
|
}
|
|
321 |
|
}
|
324 |
|
}
|
|
322 |
|
}
|
325 |
|
|
|
323 |
|
|
326 |
|
return n
ull;
|
|
324 |
|
retu
rn null;
|
327 |
|
}
|
|
325 |
|
}
|
328 |
|
|
|
326 |
|
|
329 |
|
fu
nction del
eteMarked(
tbl) {
|
|
327 |
|
function
deleteMar
ked(tbl) {
|
330 |
|
if (tbl.
rows == 0)
|
|
328 |
|
if (
tbl.rows =
= 0)
|
331 |
|
retu
rn;
|
|
329 |
|
return;
|
332 |
|
|
|
330 |
|
|
333 |
|
var tr =
tbl.rows[
0];
|
|
331 |
|
var
tr = tbl.r
ows[0];
|
334 |
|
do {
|
|
332 |
|
do {
|
335 |
|
var
next = nex
tElm(tr, "
TR");
|
|
333 |
|
var next =
nextElm(t
r, "TR");
|
336 |
|
|
|
334 |
|
|
337 |
|
// D
elete row
|
|
335 |
|
// Delete
row
|
338 |
|
if (
tr._delete
) {
|
|
336 |
|
if (tr._de
lete) {
|
339 |
|
tr.parentN
ode.remove
Child(tr);
|
|
337 |
|
tr.par
entNode.re
moveChild(
tr);
|
340 |
|
continue;
|
|
338 |
|
contin
ue;
|
341 |
|
}
|
|
339 |
|
}
|
342 |
|
|
|
340 |
|
|
343 |
|
// D
elete cell
s
|
|
341 |
|
// Delete
cells
|
344 |
|
var
td = tr.ce
lls[0];
|
|
342 |
|
var td = t
r.cells[0]
;
|
345 |
|
if (
td.cells >
1) {
|
|
343 |
|
if (td.cel
ls > 1) {
|
346 |
|
do {
|
|
344 |
|
do {
|
347 |
|
var ne
xttd = nex
tElm(td, "
TD,TH");
|
|
345 |
|
va
r nexttd =
nextElm(t
d, "TD,TH"
);
|
348 |
|
|
|
346 |
|
|
349 |
|
if (td
._delete)
|
|
347 |
|
if
(td._dele
te)
|
350 |
|
td
.parentNod
e.removeCh
ild(td);
|
|
348 |
|
td.paren
tNode.remo
veChild(td
);
|
351 |
|
} while ((
td = nextt
d) != null
);
|
|
349 |
|
} whil
e ((td = n
exttd) !=
null);
|
352 |
|
}
|
|
350 |
|
}
|
353 |
|
} while
((tr = nex
t) != null
);
|
|
351 |
|
} wh
ile ((tr =
next) !=
null);
|
354 |
|
}
|
|
352 |
|
}
|
355 |
|
|
|
353 |
|
|
356 |
|
fu
nction add
Rows(td_el
m, tr_elm,
rowspan)
{
|
|
354 |
|
function
addRows(t
d_elm, tr_
elm, rowsp
an) {
|
357 |
|
// Add r
ows
|
|
355 |
|
// A
dd rows
|
358 |
|
td_elm.r
owSpan = 1
;
|
|
356 |
|
td_e
lm.rowSpan
= 1;
|
359 |
|
var trNe
xt = nextE
lm(tr_elm,
"TR");
|
|
357 |
|
var
trNext = n
extElm(tr_
elm, "TR")
;
|
360 |
|
for (var
i=1; i<ro
wspan && t
rNext; i++
) {
|
|
358 |
|
for
(var i=1;
i<rowspan
&& trNext;
i++) {
|
361 |
|
var
newTD = do
c.createEl
ement("td"
);
|
|
359 |
|
var newTD
= doc.crea
teElement(
"td");
|
362 |
|
newT
D.innerHTM
L = " 
;";
|
|
|
363 |
|
|
|
360 |
|
|
364 |
|
if
(
tiny
MCE
.is
MS
IE)
|
|
361 |
|
if
(
!
tiny
mce
.is
IE)
|
|
|
362 |
|
newTD.
innerHTML
= '<br mce
_bogus="1"
/>';
|
|
|
363 |
|
|
|
|
364 |
|
if (tinymc
e.isIE)
|
365 |
|
trNext.ins
ertBefore(
newTD, trN
ext.cells(
td_elm.cel
lIndex));
|
|
365 |
|
trNext
.insertBef
ore(newTD,
trNext.ce
lls(td_elm
.cellIndex
));
|
366 |
|
else
|
|
366 |
|
else
|
367 |
|
trNext.ins
ertBefore(
newTD, trN
ext.cells[
td_elm.cel
lIndex]);
|
|
367 |
|
trNext
.insertBef
ore(newTD,
trNext.ce
lls[td_elm
.cellIndex
]);
|
368 |
|
|
|
368 |
|
|
369 |
|
trNe
xt = nextE
lm(trNext,
"TR");
|
|
369 |
|
trNext = n
extElm(trN
ext, "TR")
;
|
370 |
|
}
|
|
370 |
|
}
|
371 |
|
}
|
|
371 |
|
}
|
372 |
|
|
|
372 |
|
|
373 |
|
fu
nction cop
yRow(doc,
table, tr)
{
|
|
373 |
|
function
copyRow(d
oc, table,
tr) {
|
374 |
|
var grid
= getTabl
eGrid(tabl
e);
|
|
374 |
|
var
grid = get
TableGrid(
table);
|
375 |
|
var newT
R = tr.clo
neNode(fal
se);
|
|
375 |
|
var
newTR = tr
.cloneNode
(false);
|
376 |
|
var cpos
= getCell
Pos(grid,
tr.cells[0
]);
|
|
376 |
|
var
cpos = get
CellPos(gr
id, tr.cel
ls[0]);
|
377 |
|
var last
Cell = nul
l;
|
|
377 |
|
var
lastCell =
null;
|
378 |
|
var
tableBorde
r
=
t
in
yMCE
.getAttrib
(table,
"border");
|
|
378 |
|
var
tableBorde
r
=
in
st.dom
.getAttrib
(table,
"border");
|
379 |
|
var tdEl
m = null;
|
|
379 |
|
var
tdElm = nu
ll;
|
380 |
|
|
|
380 |
|
|
381 |
|
for (var
x=0; tdEl
m = getCel
l(grid, cp
os.rowinde
x, x); x++
) {
|
|
381 |
|
for
(var x=0;
tdElm = ge
tCell(grid
, cpos.row
index, x);
x++) {
|
382 |
|
var
newTD = nu
ll;
|
|
382 |
|
var newTD
= null;
|
383 |
|
|
|
383 |
|
|
384 |
|
if (
lastCell !
= tdElm) {
|
|
384 |
|
if (lastCe
ll != tdEl
m) {
|
385 |
|
for (var i
=0; i<tr.c
ells.lengt
h; i++) {
|
|
385 |
|
for (v
ar i=0; i<
tr.cells.l
ength; i++
) {
|
386 |
|
if (td
Elm == tr.
cells[i])
{
|
|
386 |
|
if
(tdElm ==
tr.cells[
i]) {
|
387 |
|
ne
wTD = tdEl
m.cloneNod
e(true);
|
|
387 |
|
newTD =
tdElm.clon
eNode(true
);
|
388 |
|
br
eak;
|
|
388 |
|
break;
|
389 |
|
}
|
|
389 |
|
}
|
390 |
|
}
|
|
390 |
|
}
|
391 |
|
}
|
|
391 |
|
}
|
392 |
|
|
|
392 |
|
|
393 |
|
if (
newTD == n
ull) {
|
|
393 |
|
if (newTD
== null) {
|
394 |
|
newTD = do
c.createEl
ement("td"
);
|
|
394 |
|
newTD
= doc.crea
teElement(
"td");
|
395 |
|
newTD.inne
rHTML
=
"&n
b
s
p;
"
;
|
|
395 |
|
|
|
|
396 |
|
if (!t
inymce.isI
E)
|
|
|
397 |
|
newTD.inne
rHTML
=
'<br
mce_
b
ogu
s
=
"
1"/>'
;
|
396 |
|
}
|
|
398 |
|
}
|
397 |
|
|
|
399 |
|
|
398 |
|
// R
eset col/r
ow span
|
|
400 |
|
// Reset c
ol/row spa
n
|
399 |
|
newT
D.colSpan
= 1;
|
|
401 |
|
newTD.colS
pan = 1;
|
400 |
|
newT
D.rowSpan
= 1;
|
|
402 |
|
newTD.rowS
pan = 1;
|
401 |
|
|
|
403 |
|
|
402 |
|
newT
R.appendCh
ild(newTD)
;
|
|
404 |
|
newTR.appe
ndChild(ne
wTD);
|
403 |
|
|
|
405 |
|
|
404 |
|
last
Cell = tdE
lm;
|
|
406 |
|
lastCell =
tdElm;
|
405 |
|
}
|
|
407 |
|
}
|
406 |
|
|
|
408 |
|
|
407 |
|
return n
ewTR;
|
|
409 |
|
retu
rn newTR;
|
408 |
|
}
|
|
410 |
|
}
|
409 |
|
|
|
411 |
|
|
410 |
|
//
---- Comm
ands -----
|
|
412 |
|
// ----
Commands -
----
|
411 |
|
|
|
413 |
|
|
412 |
|
//
Handle co
mmands
|
|
414 |
|
// Handl
e commands
|
413 |
|
sw
itch (comm
and) {
|
|
415 |
|
switch (
command) {
|
414 |
|
case "mc
eTableRowP
rops":
|
|
416 |
|
case
"mceTable
RowProps":
|
415 |
|
if (
trElm == n
ull)
|
|
417 |
|
if (trElm
== null)
|
416 |
|
return tru
e;
|
|
418 |
|
return
true;
|
417 |
|
|
|
419 |
|
|
418 |
|
if (
user_inter
face) {
|
|
420 |
|
if (user_i
nterface)
{
|
419 |
|
// Setup t
emplate
|
|
421 |
|
inst.w
indowManag
er.open({
|
420 |
|
var templa
te = new A
rray();
|
|
422 |
|
ur
l : url +
'/row.htm'
,
|
421 |
|
|
|
423 |
|
width
:
400
+
parseIn
t
(
in
st
.getLang('
table
.
rowprops_d
elta_width
',
0)
),
|
422 |
|
template['
file'] = '
../../plug
ins/table/
row.htm';
|
|
424 |
|
height
:
295
+
parseIn
t
(
in
st
.getLang('
table
.
rowprops_d
elta_heigh
t',
0)
),
|
423 |
|
template['
width'] =
380;
|
|
425 |
|
in
line : 1
|
424 |
|
template['
height'] =
295;
|
|
426 |
|
}, {
|
425 |
|
|
|
427 |
|
pl
ugin_url :
url
|
426 |
|
// Languag
e specific
width and
height ad
dons
|
|
428 |
|
});
|
427 |
|
template['
width
']
+
=
t
in
yMCE
.getLang('
lang_
table
_
rowprops_d
elta_width
',
0)
;
|
|
|
428 |
|
template['
height
']
+
=
t
in
yMCE
.getLang('
lang_
table
_
rowprops_d
elta_heigh
t',
0)
;
|
|
|
429 |
|
|
|
|
430 |
|
// Open wi
ndow
|
|
|
431 |
|
tinyMCE.op
enWindow(t
emplate, {
editor_id
: inst.edi
torId, inl
ine : "yes
"});
|
|
|
432 |
|
}
|
|
429 |
|
}
|
433 |
|
|
|
430 |
|
|
434 |
|
retu
rn true;
|
|
431 |
|
return tru
e;
|
435 |
|
|
|
432 |
|
|
436 |
|
case "mc
eTableCell
Props":
|
|
433 |
|
case
"mceTable
CellProps"
:
|
437 |
|
if (
tdElm == n
ull)
|
|
434 |
|
if (tdElm
== null)
|
438 |
|
return tru
e;
|
|
435 |
|
return
true;
|
439 |
|
|
|
436 |
|
|
440 |
|
if (
user_inter
face) {
|
|
437 |
|
if (user_i
nterface)
{
|
441 |
|
// Setup t
emplate
|
|
438 |
|
inst.w
indowManag
er.open({
|
442 |
|
var templa
te = new A
rray();
|
|
439 |
|
ur
l : url +
'/cell.htm
',
|
443 |
|
|
|
440 |
|
width
:
400
+
parseIn
t
(
in
st
.getLang('
table
.
cellprops_
delta_widt
h',
0)
),
|
444 |
|
template['
file'] = '
../../plug
ins/table/
cell.htm';
|
|
441 |
|
height
:
295
+
parseIn
t
(
in
st
.getLang('
table
.
cellprops_
delta_heig
ht',
0)
),
|
445 |
|
template['
width'] =
380;
|
|
442 |
|
in
line : 1
|
446 |
|
template['
height'] =
295;
|
|
443 |
|
}, {
|
447 |
|
|
|
444 |
|
pl
ugin_url :
url
|
448 |
|
// Languag
e specific
width and
height ad
dons
|
|
445 |
|
});
|
449 |
|
template['
width
']
+
=
t
in
yMCE
.getLang('
lang_
table
_
cellprops_
delta_widt
h',
0)
;
|
|
|
450 |
|
template['
height
']
+
=
t
in
yMCE
.getLang('
lang_
table
_
cellprops_
delta_heig
ht',
0)
;
|
|
|
451 |
|
|
|
|
452 |
|
// Open wi
ndow
|
|
|
453 |
|
tinyMCE.op
enWindow(t
emplate, {
editor_id
: inst.edi
torId, inl
ine : "yes
"});
|
|
|
454 |
|
}
|
|
446 |
|
}
|
455 |
|
|
|
447 |
|
|
456 |
|
retu
rn true;
|
|
448 |
|
return tru
e;
|
457 |
|
|
|
449 |
|
|
458 |
|
case "mc
eInsertTab
le":
|
|
450 |
|
case
"mceInser
tTable":
|
459 |
|
if (
user_inter
face) {
|
|
451 |
|
if (user_i
nterface)
{
|
460 |
|
// Setup t
emplate
|
|
452 |
|
inst.w
indowManag
er.open({
|
461 |
|
var templa
te = new A
rray();
|
|
453 |
|
ur
l : url +
'/table.ht
m',
|
462 |
|
|
|
454 |
|
width
:
400
+
parseIn
t
(
in
st
.getLang('
table
.
table_delt
a_width',
0)
),
|
463 |
|
template['
file'] = '
../../plug
ins/table/
table.htm'
;
|
|
455 |
|
height
:
320
+
parseIn
t
(
in
st
.getLang('
table
.
table_delt
a_height',
0)
),
|
464 |
|
template['
width'] =
380;
|
|
456 |
|
in
line : 1
|
465 |
|
template['
height'] =
295;
|
|
457 |
|
}, {
|
466 |
|
|
|
458 |
|
pl
ugin_url :
url,
|
467 |
|
// Languag
e specific
width and
height ad
dons
|
|
459 |
|
ac
tion : val
ue ? value
.action :
0
|
468 |
|
template['
width
']
+
=
t
in
yMCE
.getLang('
lang_
table
_
table_delt
a_width',
0)
;
|
|
460 |
|
});
|
469 |
|
template['
height
']
+
=
t
in
yMCE
.getLang('
lang_
table
_
table_delt
a_height',
0)
;
|
|
|
470 |
|
|
|
|
471 |
|
// Open wi
ndow
|
|
|
472 |
|
tinyMCE.op
enWindow(t
emplate, {
editor_id
: inst.edi
torId, inl
ine : "yes
", action
: value});
|
|
|
473 |
|
}
|
|
461 |
|
}
|
474 |
|
|
|
462 |
|
|
475 |
|
retu
rn true;
|
|
463 |
|
return tru
e;
|
476 |
|
|
|
464 |
|
|
477 |
|
case "mc
eTableDele
te":
|
|
465 |
|
case
"mceTable
Delete":
|
478 |
|
var
table
=
t
in
yMCE
.getParent
Element
(inst.
getFocu
s
El
e
m
e
n
t
(),
"table");
|
|
466 |
|
var
table
=
in
st.dom
.getParent
(inst.
s
e
l
e
ctio
n
.ge
t
Node
(),
"table");
|
479 |
|
if (
table) {
|
|
467 |
|
if (table)
{
|
480 |
|
table.pare
ntNode.rem
oveChild(t
able);
|
|
468 |
|
table.
parentNode
.removeChi
ld(table);
|
481 |
|
inst.
r
epaint
(
);
|
|
469 |
|
inst.
execComman
d('mceR
epaint
'
);
|
482 |
|
}
|
|
470 |
|
}
|
483 |
|
retu
rn true;
|
|
471 |
|
return tru
e;
|
484 |
|
|
|
472 |
|
|
485 |
|
case "mc
eTableSpli
tCells":
|
|
473 |
|
case
"mceTable
SplitCells
":
|
486 |
|
case "mc
eTableMerg
eCells":
|
|
474 |
|
case
"mceTable
MergeCells
":
|
487 |
|
case "mc
eTableInse
rtRowBefor
e":
|
|
475 |
|
case
"mceTable
InsertRowB
efore":
|
488 |
|
case "mc
eTableInse
rtRowAfter
":
|
|
476 |
|
case
"mceTable
InsertRowA
fter":
|
489 |
|
case "mc
eTableDele
teRow":
|
|
477 |
|
case
"mceTable
DeleteRow"
:
|
490 |
|
case "mc
eTableInse
rtColBefor
e":
|
|
478 |
|
case
"mceTable
InsertColB
efore":
|
491 |
|
case "mc
eTableInse
rtColAfter
":
|
|
479 |
|
case
"mceTable
InsertColA
fter":
|
492 |
|
case "mc
eTableDele
teCol":
|
|
480 |
|
case
"mceTable
DeleteCol"
:
|
493 |
|
case "mc
eTableCutR
ow":
|
|
481 |
|
case
"mceTable
CutRow":
|
494 |
|
case "mc
eTableCopy
Row":
|
|
482 |
|
case
"mceTable
CopyRow":
|
495 |
|
case "mc
eTablePast
eRowBefore
":
|
|
483 |
|
case
"mceTable
PasteRowBe
fore":
|
496 |
|
case "mc
eTablePast
eRowAfter"
:
|
|
484 |
|
case
"mceTable
PasteRowAf
ter":
|
497 |
|
// N
o table ju
st return
(invalid c
ommand)
|
|
485 |
|
// No tabl
e just ret
urn (inval
id command
)
|
498 |
|
if (
!tableElm)
|
|
486 |
|
if (!table
Elm)
|
499 |
|
return tru
e;
|
|
487 |
|
return
true;
|
500 |
|
|
|
488 |
|
|
501 |
|
// T
able has a
tbody use
that refe
rence
|
|
489 |
|
// Table h
as a tbody
use that
reference
|
502 |
|
// C
hanged log
ic by ApTe
st 2005.07
.12 (www.a
ptest.com)
|
|
490 |
|
// Changed
logic by
ApTest 200
5.07.12 (w
ww.aptest.
com)
|
503 |
|
// N
ow lookk a
t the focu
sed elemen
t and take
its paren
tNode. Th
at will be
a tbody o
r a table.
|
|
491 |
|
// Now loo
kk at the
focused el
ement and
take its p
arentNode.
That wil
l be a tbo
dy or a ta
ble.
|
504 |
|
if (
trElm && t
ableElm !=
trElm.par
entNode)
|
|
492 |
|
if (trElm
&& tableEl
m != trElm
.parentNod
e)
|
505 |
|
tableElm =
trElm.par
entNode;
|
|
493 |
|
tableE
lm = trElm
.parentNod
e;
|
506 |
|
|
|
494 |
|
|
507 |
|
if (
tableElm &
& trElm) {
|
|
495 |
|
if (tableE
lm && trEl
m) {
|
508 |
|
switch (co
mmand) {
|
|
496 |
|
switch
(command)
{
|
509 |
|
case "
mceTableCu
tRow":
|
|
497 |
|
ca
se "mceTab
leCutRow":
|
510 |
|
if
(!trElm |
| !tdElm)
|
|
498 |
|
if (!trE
lm || !tdE
lm)
|
511 |
|
return t
rue;
|
|
499 |
|
retu
rn true;
|
512 |
|
|
|
500 |
|
|
513 |
|
in
st.tableRo
wClipboard
= copyRow
(doc, tabl
eElm, trEl
m);
|
|
501 |
|
inst.tab
leRowClipb
oard = cop
yRow(doc,
tableElm,
trElm);
|
514 |
|
in
st.execCom
mand("mceT
ableDelete
Row");
|
|
502 |
|
inst.exe
cCommand("
mceTableDe
leteRow");
|
515 |
|
br
eak;
|
|
503 |
|
break;
|
516 |
|
|
|
504 |
|
|
517 |
|
case "
mceTableCo
pyRow":
|
|
505 |
|
ca
se "mceTab
leCopyRow"
:
|
518 |
|
if
(!trElm |
| !tdElm)
|
|
506 |
|
if (!trE
lm || !tdE
lm)
|
519 |
|
return t
rue;
|
|
507 |
|
retu
rn true;
|
520 |
|
|
|
508 |
|
|
521 |
|
in
st.tableRo
wClipboard
= copyRow
(doc, tabl
eElm, trEl
m);
|
|
509 |
|
inst.tab
leRowClipb
oard = cop
yRow(doc,
tableElm,
trElm);
|
522 |
|
br
eak;
|
|
510 |
|
break;
|
523 |
|
|
|
511 |
|
|
524 |
|
case "
mceTablePa
steRowBefo
re":
|
|
512 |
|
ca
se "mceTab
lePasteRow
Before":
|
525 |
|
if
(!trElm |
| !tdElm)
|
|
513 |
|
if (!trE
lm || !tdE
lm)
|
526 |
|
return t
rue;
|
|
514 |
|
retu
rn true;
|
527 |
|
|
|
515 |
|
|
528 |
|
va
r newTR =
inst.table
RowClipboa
rd.cloneNo
de(true);
|
|
516 |
|
var newT
R = inst.t
ableRowCli
pboard.clo
neNode(tru
e);
|
529 |
|
|
|
517 |
|
|
530 |
|
va
r prevTR =
prevElm(t
rElm, "TR"
);
|
|
518 |
|
var prev
TR = prevE
lm(trElm,
"TR");
|
531 |
|
if
(prevTR !
= null)
|
|
519 |
|
if (prev
TR != null
)
|
532 |
|
trimRow(
tableElm,
prevTR, pr
evTR.cells
[0], newTR
);
|
|
520 |
|
trim
Row(tableE
lm, prevTR
, prevTR.c
ells[0], n
ewTR);
|
533 |
|
|
|
521 |
|
|
534 |
|
tr
Elm.parent
Node.inser
tBefore(ne
wTR, trElm
);
|
|
522 |
|
trElm.pa
rentNode.i
nsertBefor
e(newTR, t
rElm);
|
535 |
|
br
eak;
|
|
523 |
|
break;
|
536 |
|
|
|
524 |
|
|
537 |
|
case "
mceTablePa
steRowAfte
r":
|
|
525 |
|
ca
se "mceTab
lePasteRow
After":
|
538 |
|
if
(!trElm |
| !tdElm)
|
|
526 |
|
if (!trE
lm || !tdE
lm)
|
539 |
|
return t
rue;
|
|
527 |
|
retu
rn true;
|
540 |
|
|
|
528 |
|
|
541 |
|
va
r nextTR =
nextElm(t
rElm, "TR"
);
|
|
529 |
|
var next
TR = nextE
lm(trElm,
"TR");
|
542 |
|
va
r newTR =
inst.table
RowClipboa
rd.cloneNo
de(true);
|
|
530 |
|
var newT
R = inst.t
ableRowCli
pboard.clo
neNode(tru
e);
|
543 |
|
|
|
531 |
|
|
544 |
|
tr
imRow(tabl
eElm, trEl
m, tdElm,
newTR);
|
|
532 |
|
trimRow(
tableElm,
trElm, tdE
lm, newTR)
;
|
545 |
|
|
|
533 |
|
|
546 |
|
if
(nextTR =
= null)
|
|
534 |
|
if (next
TR == null
)
|
547 |
|
trElm.pa
rentNode.a
ppendChild
(newTR);
|
|
535 |
|
trEl
m.parentNo
de.appendC
hild(newTR
);
|
548 |
|
el
se
|
|
536 |
|
else
|
549 |
|
nextTR.p
arentNode.
insertBefo
re(newTR,
nextTR);
|
|
537 |
|
next
TR.parentN
ode.insert
Before(new
TR, nextTR
);
|
550 |
|
|
|
538 |
|
|
551 |
|
br
eak;
|
|
539 |
|
break;
|
552 |
|
|
|
540 |
|
|
553 |
|
case "
mceTableIn
sertRowBef
ore":
|
|
541 |
|
ca
se "mceTab
leInsertRo
wBefore":
|
554 |
|
if
(!trElm |
| !tdElm)
|
|
542 |
|
if (!trE
lm || !tdE
lm)
|
555 |
|
return t
rue;
|
|
543 |
|
retu
rn true;
|
556 |
|
|
|
544 |
|
|
557 |
|
va
r grid = g
etTableGri
d(tableElm
);
|
|
545 |
|
var grid
= getTabl
eGrid(tabl
eElm);
|
558 |
|
va
r cpos = g
etCellPos(
grid, tdEl
m);
|
|
546 |
|
var cpos
= getCell
Pos(grid,
tdElm);
|
559 |
|
va
r newTR =
doc.create
Element("t
r");
|
|
547 |
|
var newT
R = doc.cr
eateElemen
t("tr");
|
560 |
|
va
r lastTDEl
m = null;
|
|
548 |
|
var last
TDElm = nu
ll;
|
561 |
|
|
|
549 |
|
|
562 |
|
cp
os.rowinde
x--;
|
|
550 |
|
cpos.row
index--;
|
563 |
|
if
(cpos.row
index < 0)
|
|
551 |
|
if (cpos
.rowindex
< 0)
|
564 |
|
cpos.row
index = 0;
|
|
552 |
|
cpos
.rowindex
= 0;
|
565 |
|
|
|
553 |
|
|
566 |
|
//
Create ce
lls
|
|
554 |
|
// Creat
e cells
|
567 |
|
fo
r (var x=0
; tdElm =
getCell(gr
id, cpos.r
owindex, x
); x++) {
|
|
555 |
|
for (var
x=0; tdEl
m = getCel
l(grid, cp
os.rowinde
x, x); x++
) {
|
568 |
|
if (tdEl
m != lastT
DElm) {
|
|
556 |
|
if (
tdElm != l
astTDElm)
{
|
569 |
|
var
sd = getCo
lRowSpan(t
dElm);
|
|
557 |
|
var sd = g
etColRowSp
an(tdElm);
|
570 |
|
|
|
558 |
|
|
571 |
|
if (
sd['rowspa
n'] == 1)
{
|
|
559 |
|
if (sd['ro
wspan'] ==
1) {
|
572 |
|
var newTD
= doc.crea
teElement(
"td");
|
|
560 |
|
var ne
wTD = doc.
createElem
ent("td");
|
573 |
|
|
|
561 |
|
|
574 |
|
newTD.inne
rHTML
=
"&n
b
s
p;
"
;
|
|
562 |
|
if (!t
inymce.isI
E)
|
|
|
563 |
|
newTD.inne
rHTML
=
'<br
mce_
b
ogu
s
=
"
1"/>'
;
|
|
|
564 |
|
|
575 |
|
newTD.colS
pan = tdEl
m.colSpan;
|
|
565 |
|
newTD.
colSpan =
tdElm.colS
pan;
|
576 |
|
|
|
566 |
|
|
577 |
|
newTR.appe
ndChild(ne
wTD);
|
|
567 |
|
newTR.
appendChil
d(newTD);
|
578 |
|
} el
se
|
|
568 |
|
} else
|
579 |
|
tdElm.rowS
pan = sd['
rowspan']
+ 1;
|
|
569 |
|
tdElm.
rowSpan =
sd['rowspa
n'] + 1;
|
580 |
|
|
|
570 |
|
|
581 |
|
last
TDElm = td
Elm;
|
|
571 |
|
lastTDElm
= tdElm;
|
582 |
|
}
|
|
572 |
|
}
|
583 |
|
}
|
|
573 |
|
}
|
584 |
|
|
|
574 |
|
|
585 |
|
tr
Elm.parent
Node.inser
tBefore(ne
wTR, trElm
);
|
|
575 |
|
trElm.pa
rentNode.i
nsertBefor
e(newTR, t
rElm);
|
586 |
|
|
|
576 |
|
select(0
, 1);
|
587 |
|
gr
id = getTa
bleGrid(ta
bleElm);
|
|
|
588 |
|
in
st.selecti
on.selectN
ode(getCel
l(grid, cp
os.rowinde
x + 1, cpo
s.cellinde
x), tinyMC
E.isGecko,
true); //
Only coll
ape on gec
ko
|
|
|
589 |
|
break;
|
|
577 |
|
br
eak;
|
590 |
|
|
|
578 |
|
|
591 |
|
case "
mceTableIn
sertRowAft
er":
|
|
579 |
|
ca
se "mceTab
leInsertRo
wAfter":
|
592 |
|
if
(!trElm |
| !tdElm)
|
|
580 |
|
if (!trE
lm || !tdE
lm)
|
593 |
|
return t
rue;
|
|
581 |
|
retu
rn true;
|
594 |
|
|
|
582 |
|
|
595 |
|
va
r grid = g
etTableGri
d(tableElm
);
|
|
583 |
|
var grid
= getTabl
eGrid(tabl
eElm);
|
596 |
|
va
r cpos = g
etCellPos(
grid, tdEl
m);
|
|
584 |
|
var cpos
= getCell
Pos(grid,
tdElm);
|
597 |
|
va
r newTR =
doc.create
Element("t
r");
|
|
585 |
|
var newT
R = doc.cr
eateElemen
t("tr");
|
598 |
|
va
r lastTDEl
m = null;
|
|
586 |
|
var last
TDElm = nu
ll;
|
599 |
|
|
|
587 |
|
|
600 |
|
//
Create ce
lls
|
|
588 |
|
// Creat
e cells
|
601 |
|
fo
r (var x=0
; tdElm =
getCell(gr
id, cpos.r
owindex, x
); x++) {
|
|
589 |
|
for (var
x=0; tdEl
m = getCel
l(grid, cp
os.rowinde
x, x); x++
) {
|
602 |
|
if (tdEl
m != lastT
DElm) {
|
|
590 |
|
if (
tdElm != l
astTDElm)
{
|
603 |
|
var
sd = getCo
lRowSpan(t
dElm);
|
|
591 |
|
var sd = g
etColRowSp
an(tdElm);
|
604 |
|
|
|
592 |
|
|
605 |
|
if (
sd['rowspa
n'] == 1)
{
|
|
593 |
|
if (sd['ro
wspan'] ==
1) {
|
606 |
|
var newTD
= doc.crea
teElement(
"td");
|
|
594 |
|
var ne
wTD = doc.
createElem
ent("td");
|
607 |
|
|
|
595 |
|
|
608 |
|
newTD.inne
rHTML
=
"&n
b
s
p;
"
;
|
|
596 |
|
if (!t
inymce.isI
E)
|
|
|
597 |
|
newTD.inne
rHTML
=
'<br
mce_
b
ogu
s
=
"
1"/>'
;
|
|
|
598 |
|
|
609 |
|
newTD.colS
pan = tdEl
m.colSpan;
|
|
599 |
|
newTD.
colSpan =
tdElm.colS
pan;
|
610 |
|
|
|
600 |
|
|
611 |
|
newTR.appe
ndChild(ne
wTD);
|
|
601 |
|
newTR.
appendChil
d(newTD);
|
612 |
|
} el
se
|
|
602 |
|
} else
|
613 |
|
tdElm.rowS
pan = sd['
rowspan']
+ 1;
|
|
603 |
|
tdElm.
rowSpan =
sd['rowspa
n'] + 1;
|
614 |
|
|
|
604 |
|
|
615 |
|
last
TDElm = td
Elm;
|
|
605 |
|
lastTDElm
= tdElm;
|
616 |
|
}
|
|
606 |
|
}
|
617 |
|
}
|
|
607 |
|
}
|
618 |
|
|
|
608 |
|
|
619 |
|
if
(newTR.ha
sChildNode
s()) {
|
|
609 |
|
if (newT
R.hasChild
Nodes()) {
|
620 |
|
var next
TR = nextE
lm(trElm,
"TR");
|
|
610 |
|
var
nextTR = n
extElm(trE
lm, "TR");
|
621 |
|
if (next
TR)
|
|
611 |
|
if (
nextTR)
|
622 |
|
next
TR.parentN
ode.insert
Before(new
TR, nextTR
);
|
|
612 |
|
nextTR.par
entNode.in
sertBefore
(newTR, ne
xtTR);
|
623 |
|
else
|
|
613 |
|
else
|
624 |
|
tabl
eElm.appen
dChild(new
TR);
|
|
614 |
|
tableElm.a
ppendChild
(newTR);
|
625 |
|
}
|
|
615 |
|
}
|
626 |
|
|
|
616 |
|
|
627 |
|
gr
id = getTa
bleGrid(ta
bleElm);
|
|
617 |
|
select(0
, 1);
|
628 |
|
in
st.selecti
on.selectN
ode(getCel
l(grid, cp
os.rowinde
x, cpos.ce
llindex),
tinyMCE.is
Gecko, tru
e); // Onl
y collape
on gecko
|
|
|
629 |
|
break;
|
|
618 |
|
br
eak;
|
630 |
|
|
|
619 |
|
|
631 |
|
case "
mceTableDe
leteRow":
|
|
620 |
|
ca
se "mceTab
leDeleteRo
w":
|
632 |
|
if
(!trElm |
| !tdElm)
|
|
621 |
|
if (!trE
lm || !tdE
lm)
|
633 |
|
return t
rue;
|
|
622 |
|
retu
rn true;
|
634 |
|
|
|
623 |
|
|
635 |
|
va
r grid = g
etTableGri
d(tableElm
);
|
|
624 |
|
var grid
= getTabl
eGrid(tabl
eElm);
|
636 |
|
va
r cpos = g
etCellPos(
grid, tdEl
m);
|
|
625 |
|
var cpos
= getCell
Pos(grid,
tdElm);
|
637 |
|
|
|
626 |
|
|
638 |
|
//
Only one
row, remov
e whole ta
ble
|
|
627 |
|
// Only
one row, r
emove whol
e table
|
639 |
|
if
(grid.len
gth == 1)
{
|
|
628 |
|
if (grid
.length ==
1) {
|
640 |
|
t
abl
e
El
m
=
t
in
yMCE
.getParent
Element
(tableElm,
"table")
;
//
Look
for
table
instead
of
tbody
|
|
629 |
|
ins
t
.dom.r
e
m
ove(
in
st.dom
.getParent
(tableElm,
"table")
)
;
|
641 |
|
tableElm
.parentNod
e.removeCh
ild(tableE
lm);
|
|
|
642 |
|
return t
rue;
|
|
630 |
|
retu
rn true;
|
643 |
|
}
|
|
631 |
|
}
|
644 |
|
|
|
632 |
|
|
645 |
|
//
Move down
row spann
ed cells
|
|
633 |
|
// Move
down row s
panned cel
ls
|
646 |
|
va
r cells =
trElm.cell
s;
|
|
634 |
|
var cell
s = trElm.
cells;
|
647 |
|
va
r nextTR =
nextElm(t
rElm, "TR"
);
|
|
635 |
|
var next
TR = nextE
lm(trElm,
"TR");
|
648 |
|
fo
r (var x=0
; x<cells.
length; x+
+) {
|
|
636 |
|
for (var
x=0; x<ce
lls.length
; x++) {
|
649 |
|
if (cell
s[x].rowSp
an > 1) {
|
|
637 |
|
if (
cells[x].r
owSpan > 1
) {
|
650 |
|
var
newTD = ce
lls[x].clo
neNode(tru
e);
|
|
638 |
|
var newTD
= cells[x]
.cloneNode
(true);
|
651 |
|
var
sd = getCo
lRowSpan(c
ells[x]);
|
|
639 |
|
var sd = g
etColRowSp
an(cells[x
]);
|
652 |
|
|
|
640 |
|
|
653 |
|
newT
D.rowSpan
= sd.rowsp
an - 1;
|
|
641 |
|
newTD.rowS
pan = sd.r
owspan - 1
;
|
654 |
|
|
|
642 |
|
|
655 |
|
var
nextTD = n
extTR.cell
s[x];
|
|
643 |
|
var nextTD
= nextTR.
cells[x];
|
656 |
|
|
|
644 |
|
|
657 |
|
if (
nextTD ==
null)
|
|
645 |
|
if (nextTD
== null)
|
658 |
|
nextTR.app
endChild(n
ewTD);
|
|
646 |
|
nextTR
.appendChi
ld(newTD);
|
659 |
|
else
|
|
647 |
|
else
|
660 |
|
nextTR.ins
ertBefore(
newTD, nex
tTD);
|
|
648 |
|
nextTR
.insertBef
ore(newTD,
nextTD);
|
661 |
|
}
|
|
649 |
|
}
|
662 |
|
}
|
|
650 |
|
}
|
663 |
|
|
|
651 |
|
|
664 |
|
//
Delete ce
lls
|
|
652 |
|
// Delet
e cells
|
665 |
|
va
r lastTDEl
m = null;
|
|
653 |
|
var last
TDElm = nu
ll;
|
666 |
|
fo
r (var x=0
; tdElm =
getCell(gr
id, cpos.r
owindex, x
); x++) {
|
|
654 |
|
for (var
x=0; tdEl
m = getCel
l(grid, cp
os.rowinde
x, x); x++
) {
|
667 |
|
if (tdEl
m != lastT
DElm) {
|
|
655 |
|
if (
tdElm != l
astTDElm)
{
|
668 |
|
var
sd = getCo
lRowSpan(t
dElm);
|
|
656 |
|
var sd = g
etColRowSp
an(tdElm);
|
669 |
|
|
|
657 |
|
|
670 |
|
if (
sd.rowspan
> 1) {
|
|
658 |
|
if (sd.row
span > 1)
{
|
671 |
|
tdElm.rowS
pan = sd.r
owspan - 1
;
|
|
659 |
|
tdElm.
rowSpan =
sd.rowspan
- 1;
|
672 |
|
} el
se {
|
|
660 |
|
} else {
|
673 |
|
trElm = td
Elm.parent
Node;
|
|
661 |
|
trElm
= tdElm.pa
rentNode;
|
674 |
|
|
|
662 |
|
|
675 |
|
if (trElm.
parentNode
)
|
|
663 |
|
if (tr
Elm.parent
Node)
|
676 |
|
trElm.
_delete =
true;
|
|
664 |
|
tr
Elm._delet
e = true;
|
677 |
|
}
|
|
665 |
|
}
|
678 |
|
|
|
666 |
|
|
679 |
|
last
TDElm = td
Elm;
|
|
667 |
|
lastTDElm
= tdElm;
|
680 |
|
}
|
|
668 |
|
}
|
681 |
|
}
|
|
669 |
|
}
|
682 |
|
|
|
670 |
|
|
683 |
|
de
leteMarked
(tableElm)
;
|
|
671 |
|
deleteMa
rked(table
Elm);
|
684 |
|
|
|
672 |
|
|
685 |
|
cp
os.rowinde
x--;
|
|
673 |
|
select(0
, -1);
|
686 |
|
if
(cpos.row
index < 0)
|
|
|
687 |
|
cpos.row
index = 0;
|
|
|
688 |
|
|
|
|
689 |
|
//
Recalcula
te grid an
d select
|
|
|
690 |
|
gr
id = getTa
bleGrid(ta
bleElm);
|
|
|
691 |
|
in
st.selecti
on.selectN
ode(getCel
l(grid, cp
os.rowinde
x, 0), tin
yMCE.isGec
ko, true);
// Only c
ollape on
gecko
|
|
|
692 |
|
break;
|
|
674 |
|
br
eak;
|
693 |
|
|
|
675 |
|
|
694 |
|
case "
mceTableIn
sertColBef
ore":
|
|
676 |
|
ca
se "mceTab
leInsertCo
lBefore":
|
695 |
|
if
(!trElm |
| !tdElm)
|
|
677 |
|
if (!trE
lm || !tdE
lm)
|
696 |
|
return t
rue;
|
|
678 |
|
retu
rn true;
|
697 |
|
|
|
679 |
|
|
698 |
|
va
r grid = g
etTableGri
d(tableElm
);
|
|
680 |
|
var grid
= getTabl
eGrid(tabl
eElm);
|
699 |
|
va
r cpos = g
etCellPos(
grid, tdEl
m);
|
|
681 |
|
var cpos
= getCell
Pos(grid,
tdElm);
|
700 |
|
va
r lastTDEl
m = null;
|
|
682 |
|
var last
TDElm = nu
ll;
|
701 |
|
|
|
683 |
|
|
702 |
|
fo
r (var y=0
; tdElm =
getCell(gr
id, y, cpo
s.cellinde
x); y++) {
|
|
684 |
|
for (var
y=0; tdEl
m = getCel
l(grid, y,
cpos.cell
index); y+
+) {
|
703 |
|
if (tdEl
m != lastT
DElm) {
|
|
685 |
|
if (
tdElm != l
astTDElm)
{
|
704 |
|
var
sd = getCo
lRowSpan(t
dElm);
|
|
686 |
|
var sd = g
etColRowSp
an(tdElm);
|
705 |
|
|
|
687 |
|
|
706 |
|
if (
sd['colspa
n'] == 1)
{
|
|
688 |
|
if (sd['co
lspan'] ==
1) {
|
707 |
|
var newTD
= doc.crea
teElement(
tdElm.node
Name);
|
|
689 |
|
var ne
wTD = doc.
createElem
ent(tdElm.
nodeName);
|
708 |
|
|
|
690 |
|
|
709 |
|
newTD.inne
rHTML
=
"&n
b
s
p;
"
;
|
|
691 |
|
if (!t
inymce.isI
E)
|
|
|
692 |
|
newTD.inne
rHTML
=
'<br
mce_
b
ogu
s
=
"
1"/>'
;
|
|
|
693 |
|
|
710 |
|
newTD.rowS
pan = tdEl
m.rowSpan;
|
|
694 |
|
newTD.
rowSpan =
tdElm.rowS
pan;
|
711 |
|
|
|
695 |
|
|
712 |
|
tdElm.pare
ntNode.ins
ertBefore(
newTD, tdE
lm);
|
|
696 |
|
tdElm.
parentNode
.insertBef
ore(newTD,
tdElm);
|
713 |
|
} el
se
|
|
697 |
|
} else
|
714 |
|
tdElm.colS
pan++;
|
|
698 |
|
tdElm.
colSpan++;
|
715 |
|
|
|
699 |
|
|
716 |
|
last
TDElm = td
Elm;
|
|
700 |
|
lastTDElm
= tdElm;
|
717 |
|
}
|
|
701 |
|
}
|
718 |
|
}
|
|
702 |
|
}
|
719 |
|
|
|
703 |
|
|
720 |
|
gr
id = getTa
bleGrid(ta
bleElm);
|
|
704 |
|
select()
;
|
721 |
|
in
st.selecti
on.selectN
ode(getCel
l(grid, cp
os.rowinde
x, cpos.ce
llindex +
1), tinyMC
E.isGecko,
true); //
Only coll
ape on gec
ko
|
|
|
722 |
|
break;
|
|
705 |
|
br
eak;
|
723 |
|
|
|
706 |
|
|
724 |
|
case "
mceTableIn
sertColAft
er":
|
|
707 |
|
ca
se "mceTab
leInsertCo
lAfter":
|
725 |
|
if
(!trElm |
| !tdElm)
|
|
708 |
|
if (!trE
lm || !tdE
lm)
|
726 |
|
return t
rue;
|
|
709 |
|
retu
rn true;
|
727 |
|
|
|
710 |
|
|
728 |
|
va
r grid = g
etTableGri
d(tableElm
);
|
|
711 |
|
var grid
= getTabl
eGrid(tabl
eElm);
|
729 |
|
va
r cpos = g
etCellPos(
grid, tdEl
m);
|
|
712 |
|
var cpos
= getCell
Pos(grid,
tdElm);
|
730 |
|
va
r lastTDEl
m = null;
|
|
713 |
|
var last
TDElm = nu
ll;
|
731 |
|
|
|
714 |
|
|
732 |
|
fo
r (var y=0
; tdElm =
getCell(gr
id, y, cpo
s.cellinde
x); y++) {
|
|
715 |
|
for (var
y=0; tdEl
m = getCel
l(grid, y,
cpos.cell
index); y+
+) {
|
733 |
|
if (tdEl
m != lastT
DElm) {
|
|
716 |
|
if (
tdElm != l
astTDElm)
{
|
734 |
|
var
sd = getCo
lRowSpan(t
dElm);
|
|
717 |
|
var sd = g
etColRowSp
an(tdElm);
|
735 |
|
|
|
718 |
|
|
736 |
|
if (
sd['colspa
n'] == 1)
{
|
|
719 |
|
if (sd['co
lspan'] ==
1) {
|
737 |
|
var newTD
= doc.crea
teElement(
tdElm.node
Name);
|
|
720 |
|
var ne
wTD = doc.
createElem
ent(tdElm.
nodeName);
|
738 |
|
|
|
721 |
|
|
739 |
|
newTD.inne
rHTML
=
"&n
b
s
p;
"
;
|
|
722 |
|
if (!t
inymce.isI
E)
|
|
|
723 |
|
newTD.inne
rHTML
=
'<br
mce_
b
ogu
s
=
"
1"/>'
;
|
|
|
724 |
|
|
740 |
|
newTD.rowS
pan = tdEl
m.rowSpan;
|
|
725 |
|
newTD.
rowSpan =
tdElm.rowS
pan;
|
741 |
|
|
|
726 |
|
|
742 |
|
var nextTD
= nextElm
(tdElm, "T
D,TH");
|
|
727 |
|
var ne
xtTD = nex
tElm(tdElm
, "TD,TH")
;
|
743 |
|
if (nextTD
== null)
|
|
728 |
|
if (ne
xtTD == nu
ll)
|
744 |
|
tdElm.
parentNode
.appendChi
ld(newTD);
|
|
729 |
|
td
Elm.parent
Node.appen
dChild(new
TD);
|
745 |
|
else
|
|
730 |
|
else
|
746 |
|
nextTD
.parentNod
e.insertBe
fore(newTD
, nextTD);
|
|
731 |
|
ne
xtTD.paren
tNode.inse
rtBefore(n
ewTD, next
TD);
|
747 |
|
} el
se
|
|
732 |
|
} else
|
748 |
|
tdElm.colS
pan++;
|
|
733 |
|
tdElm.
colSpan++;
|
749 |
|
|
|
734 |
|
|
750 |
|
last
TDElm = td
Elm;
|
|
735 |
|
lastTDElm
= tdElm;
|
751 |
|
}
|
|
736 |
|
}
|
752 |
|
}
|
|
737 |
|
}
|
753 |
|
|
|
738 |
|
|
754 |
|
gr
id = getTa
bleGrid(ta
bleElm);
|
|
739 |
|
select(1
);
|
755 |
|
in
st.selecti
on.selectN
ode(getCel
l(grid, cp
os.rowinde
x, cpos.ce
llindex),
tinyMCE.is
Gecko, tru
e); // Onl
y collape
on gecko
|
|
|
756 |
|
break;
|
|
740 |
|
br
eak;
|
757 |
|
|
|
741 |
|
|
758 |
|
case "
mceTableDe
leteCol":
|
|
742 |
|
ca
se "mceTab
leDeleteCo
l":
|
759 |
|
if
(!trElm |
| !tdElm)
|
|
743 |
|
if (!trE
lm || !tdE
lm)
|
760 |
|
return t
rue;
|
|
744 |
|
retu
rn true;
|
761 |
|
|
|
745 |
|
|
762 |
|
va
r grid = g
etTableGri
d(tableElm
);
|
|
746 |
|
var grid
= getTabl
eGrid(tabl
eElm);
|
763 |
|
va
r cpos = g
etCellPos(
grid, tdEl
m);
|
|
747 |
|
var cpos
= getCell
Pos(grid,
tdElm);
|
764 |
|
va
r lastTDEl
m = null;
|
|
748 |
|
var last
TDElm = nu
ll;
|
765 |
|
|
|
749 |
|
|
766 |
|
//
Only one
col, remov
e whole ta
ble
|
|
750 |
|
// Only
one col, r
emove whol
e table
|
767 |
|
if
(grid.len
gth > 1 &&
grid[0].l
ength <= 1
) {
|
|
751 |
|
if (grid
.length >
1 && grid[
0].length
<= 1) {
|
768 |
|
t
abl
e
El
m
=
t
in
yMCE
.getParent
Element
(tableElm,
"table")
;
//
Look
for
table
instead
of
tbody
|
|
752 |
|
ins
t
.dom.r
e
m
ove(
in
st.dom
.getParent
(tableElm,
"table")
)
;
|
769 |
|
tableElm
.parentNod
e.removeCh
ild(tableE
lm);
|
|
|
770 |
|
return t
rue;
|
|
753 |
|
retu
rn true;
|
771 |
|
}
|
|
754 |
|
}
|
772 |
|
|
|
755 |
|
|
773 |
|
//
Delete ce
lls
|
|
756 |
|
// Delet
e cells
|
774 |
|
fo
r (var y=0
; tdElm =
getCell(gr
id, y, cpo
s.cellinde
x); y++) {
|
|
757 |
|
for (var
y=0; tdEl
m = getCel
l(grid, y,
cpos.cell
index); y+
+) {
|
775 |
|
if (tdEl
m != lastT
DElm) {
|
|
758 |
|
if (
tdElm != l
astTDElm)
{
|
776 |
|
var
sd = getCo
lRowSpan(t
dElm);
|
|
759 |
|
var sd = g
etColRowSp
an(tdElm);
|
777 |
|
|
|
760 |
|
|
778 |
|
if (
sd['colspa
n'] > 1)
|
|
761 |
|
if (sd['co
lspan'] >
1)
|
779 |
|
tdElm.colS
pan = sd['
colspan']
- 1;
|
|
762 |
|
tdElm.
colSpan =
sd['colspa
n'] - 1;
|
780 |
|
else
{
|
|
763 |
|
else {
|
781 |
|
if (tdElm.
parentNode
)
|
|
764 |
|
if (td
Elm.parent
Node)
|
782 |
|
tdElm.
parentNode
.removeChi
ld(tdElm);
|
|
765 |
|
td
Elm.parent
Node.remov
eChild(tdE
lm);
|
783 |
|
}
|
|
766 |
|
}
|
784 |
|
|
|
767 |
|
|
785 |
|
last
TDElm = td
Elm;
|
|
768 |
|
lastTDElm
= tdElm;
|
786 |
|
}
|
|
769 |
|
}
|
787 |
|
}
|
|
770 |
|
}
|
788 |
|
|
|
771 |
|
|
789 |
|
cp
os.cellind
ex--;
|
|
772 |
|
select(-
1);
|
790 |
|
if
(cpos.cel
lindex < 0
)
|
|
|
791 |
|
cpos.cel
lindex = 0
;
|
|
|
792 |
|
|
|
|
793 |
|
//
Recalcula
te grid an
d select
|
|
|
794 |
|
gr
id = getTa
bleGrid(ta
bleElm);
|
|
|
795 |
|
in
st.selecti
on.selectN
ode(getCel
l(grid, cp
os.rowinde
x, 0), tin
yMCE.isGec
ko, true);
// Only c
ollape on
gecko
|
|
|
796 |
|
break;
|
|
773 |
|
br
eak;
|
797 |
|
|
|
774 |
|
|
798 |
|
case "mceT
ableSplitC
ells":
|
|
775 |
|
case "
mceTableSp
litCells":
|
799 |
|
if (!t
rElm || !t
dElm)
|
|
776 |
|
if
(!trElm |
| !tdElm)
|
800 |
|
re
turn true;
|
|
777 |
|
return t
rue;
|
801 |
|
|
|
778 |
|
|
802 |
|
var sp
andata = g
etColRowSp
an(tdElm);
|
|
779 |
|
va
r spandata
= getColR
owSpan(tdE
lm);
|
803 |
|
|
|
780 |
|
|
804 |
|
var co
lspan = sp
andata["co
lspan"];
|
|
781 |
|
va
r colspan
= spandata
["colspan"
];
|
805 |
|
var ro
wspan = sp
andata["ro
wspan"];
|
|
782 |
|
va
r rowspan
= spandata
["rowspan"
];
|
806 |
|
|
|
783 |
|
|
807 |
|
// Nee
ds splitti
ng
|
|
784 |
|
//
Needs spl
itting
|
808 |
|
if (co
lspan > 1
|| rowspan
> 1) {
|
|
785 |
|
if
(colspan
> 1 || row
span > 1)
{
|
809 |
|
//
Generate
cols
|
|
786 |
|
// Gener
ate cols
|
810 |
|
td
Elm.colSpa
n = 1;
|
|
787 |
|
tdElm.co
lSpan = 1;
|
811 |
|
fo
r (var i=1
; i<colspa
n; i++) {
|
|
788 |
|
for (var
i=1; i<co
lspan; i++
) {
|
812 |
|
var newT
D = doc.cr
eateElemen
t("td");
|
|
789 |
|
var
newTD = do
c.createEl
ement("td"
);
|
813 |
|
|
|
790 |
|
|
814 |
|
newTD.inne
rHTML
=
"&n
b
s
p;
"
;
|
|
791 |
|
if (
!tinymce.i
sIE)
|
|
|
792 |
|
newTD.inne
rHTML
=
'<br
mce_
b
ogu
s
=
"
1"/>'
;
|
815 |
|
|
|
793 |
|
|
816 |
|
trElm.in
sertBefore
(newTD, ne
xtElm(tdEl
m, "TD,TH"
));
|
|
794 |
|
trEl
m.insertBe
fore(newTD
, nextElm(
tdElm, "TD
,TH"));
|
817 |
|
|
|
795 |
|
|
818 |
|
if (rows
pan > 1)
|
|
796 |
|
if (
rowspan >
1)
|
819 |
|
addR
ows(newTD,
trElm, ro
wspan);
|
|
797 |
|
addRows(ne
wTD, trElm
, rowspan)
;
|
820 |
|
}
|
|
798 |
|
}
|
821 |
|
|
|
799 |
|
|
822 |
|
ad
dRows(tdEl
m, trElm,
rowspan);
|
|
800 |
|
addRows(
tdElm, trE
lm, rowspa
n);
|
823 |
|
}
|
|
801 |
|
}
|
824 |
|
|
|
802 |
|
|
825 |
|
// App
ly visual
aids
|
|
803 |
|
//
Apply vis
ual aids
|
826 |
|
tableElm
=
t
in
yMCE
.getParent
Element
(inst.
getFocu
s
El
e
m
e
n
t
(),
"table");
|
|
804 |
|
tableElm
=
in
st.dom
.getParent
(inst.
s
e
l
e
ctio
n
.ge
t
Node
(),
"table");
|
827 |
|
break;
|
|
805 |
|
br
eak;
|
828 |
|
|
|
806 |
|
|
829 |
|
case "mceT
ableMergeC
ells":
|
|
807 |
|
case "
mceTableMe
rgeCells":
|
830 |
|
var
rows
=
new
Array()
;
|
|
808 |
|
var
rows
=
[]
;
|
831 |
|
var
sel
=
inst.
getSel();
|
|
809 |
|
var
sel
=
inst.
selection.
getSel();
|
832 |
|
var gr
id = getTa
bleGrid(ta
bleElm);
|
|
810 |
|
va
r grid = g
etTableGri
d(tableElm
);
|
833 |
|
|
|
811 |
|
|
834 |
|
if
(tiny
MCE
.is
MS
IE
||
sel.rangeC
ount
==
1)
{
|
|
812 |
|
if
(tiny
mce
.is
IE
||
sel.rangeC
ount
==
1)
{
|
835 |
|
if
(user_int
erface) {
|
|
813 |
|
if (user
_interface
) {
|
836 |
|
// Setup
template
|
|
814 |
|
// S
etup templ
ate
|
837 |
|
var temp
late = new
Array();
|
|
|
838 |
|
var sp =
getColRow
Span(tdElm
);
|
|
815 |
|
var
sp = getCo
lRowSpan(t
dElm);
|
839 |
|
|
|
816 |
|
|
840 |
|
template
['file'] =
'../../pl
ugins/tabl
e/merge_ce
lls.htm';
|
|
817 |
|
inst
.windowMan
ager.open(
{
|
841 |
|
template
['width']
= 250;
|
|
818 |
|
url : url
+ '/merge_
cells.htm'
,
|
842 |
|
template
['height']
= 105 + (
tinyMCE.is
NS7 ? 25 :
0);
|
|
819 |
|
width
:
240
+
parseIn
t
(
in
st
.getLang('
table
.
merge_cell
s_delta_wi
dth',
0)
),
|
843 |
|
|
|
820 |
|
height
:
110
+
parseIn
t
(
in
st
.getLang('
table
.
merge_cell
s_delta_he
ight',
0)
),
|
844 |
|
// Langu
age specif
ic width a
nd height
addons
|
|
821 |
|
inline : 1
|
845 |
|
template['
width
']
+
=
t
in
yMCE
.getLang('
lang_
table
_
merge_cell
s_delta_wi
dth',
0)
;
|
|
822 |
|
}, {
|
846 |
|
template['
height
']
+
=
t
in
yMCE
.getLang('
lang_
table
_
merge_cell
s_delta_he
ight',
0)
;
|
|
823 |
|
action : "
update",
|
847 |
|
|
|
824 |
|
numcols :
sp.colspan
,
|
848 |
|
// Open wi
ndow
|
|
825 |
|
numrows :
sp.rowspan
,
|
849 |
|
tinyMCE.
openWindow
(template,
{editor_i
d : inst.e
ditorId, i
nline : "y
es", actio
n : "updat
e", numcol
s : sp.col
span, numr
ows : sp.r
owspan});
|
|
826 |
|
plugin_url
: url
|
|
|
827 |
|
});
|
850 |
|
|
|
828 |
|
|
851 |
|
return t
rue;
|
|
829 |
|
retu
rn true;
|
852 |
|
}
else {
|
|
830 |
|
} else {
|
853 |
|
var numR
ows = pars
eInt(value
['numrows'
]);
|
|
831 |
|
var
numRows =
parseInt(v
alue['numr
ows']);
|
854 |
|
var numC
ols = pars
eInt(value
['numcols'
]);
|
|
832 |
|
var
numCols =
parseInt(v
alue['numc
ols']);
|
855 |
|
var cpos
= getCell
Pos(grid,
tdElm);
|
|
833 |
|
var
cpos = get
CellPos(gr
id, tdElm)
;
|
856 |
|
|
|
834 |
|
|
857 |
|
if ((""
+ numRows)
== "NaN")
|
|
835 |
|
if (
("" + numR
ows) == "N
aN")
|
858 |
|
numR
ows = 1;
|
|
836 |
|
numRows =
1;
|
859 |
|
|
|
837 |
|
|
860 |
|
if ((""
+ numCols)
== "NaN")
|
|
838 |
|
if (
("" + numC
ols) == "N
aN")
|
861 |
|
numC
ols = 1;
|
|
839 |
|
numCols =
1;
|
862 |
|
|
|
840 |
|
|
863 |
|
// Get r
ows and ce
lls
|
|
841 |
|
// G
et rows an
d cells
|
864 |
|
var tRow
s = tableE
lm.rows;
|
|
842 |
|
var
tRows = ta
bleElm.row
s;
|
865 |
|
for (var
y=cpos.ro
windex; y<
grid.lengt
h; y++) {
|
|
843 |
|
for
(var y=cpo
s.rowindex
; y<grid.l
ength; y++
) {
|
866 |
|
var
rowCells
=
new
Array()
;
|
|
844 |
|
var
rowCells
=
[]
;
|
867 |
|
|
|
845 |
|
|
868 |
|
for
(var x=cpo
s.cellinde
x; x<grid[
y].length;
x++) {
|
|
846 |
|
for (var x
=cpos.cell
index; x<g
rid[y].len
gth; x++)
{
|
869 |
|
var td = g
etCell(gri
d, y, x);
|
|
847 |
|
var td
= getCell
(grid, y,
x);
|
870 |
|
|
|
848 |
|
|
871 |
|
if (td &&
!inArray(r
ows, td) &
& !inArray
(rowCells,
td)) {
|
|
849 |
|
if (td
&& !inArr
ay(rows, t
d) && !inA
rray(rowCe
lls, td))
{
|
872 |
|
var cp
= getCell
Pos(grid,
td);
|
|
850 |
|
va
r cp = get
CellPos(gr
id, td);
|
873 |
|
|
|
851 |
|
|
874 |
|
// Wit
hin range
|
|
852 |
|
//
Within ra
nge
|
875 |
|
if (cp
.cellindex
< cpos.ce
llindex+nu
mCols && c
p.rowindex
< cpos.ro
windex+num
Rows)
|
|
853 |
|
if
(cp.celli
ndex < cpo
s.cellinde
x+numCols
&& cp.rowi
ndex < cpo
s.rowindex
+numRows)
|
876 |
|
ro
wCells[row
Cells.leng
th] = td;
|
|
854 |
|
rowCells
[rowCells.
length] =
td;
|
877 |
|
}
|
|
855 |
|
}
|
878 |
|
}
|
|
856 |
|
}
|
879 |
|
|
|
857 |
|
|
880 |
|
if (
rowCells.l
ength > 0)
|
|
858 |
|
if (rowCel
ls.length
> 0)
|
881 |
|
rows[rows.
length] =
rowCells;
|
|
859 |
|
rows[r
ows.length
] = rowCel
ls;
|
|
|
860 |
|
|
|
|
861 |
|
var td = g
etCell(gri
d, cpos.ro
windex, cp
os.cellind
ex);
|
|
|
862 |
|
each(ed.do
m.select('
br', td),
function(e
, i) {
|
|
|
863 |
|
if (i
> 0 && ed.
dom.getAtt
rib('mce_b
ogus'))
|
|
|
864 |
|
ed
.dom.remov
e(e);
|
|
|
865 |
|
});
|
882 |
|
}
|
|
866 |
|
}
|
883 |
|
|
|
867 |
|
|
884 |
|
//return
true;
|
|
868 |
|
//re
turn true;
|
885 |
|
}
|
|
869 |
|
}
|
886 |
|
} else
{
|
|
870 |
|
}
else {
|
887 |
|
var
cells
=
new
Array()
;
|
|
871 |
|
var
cells
=
[]
;
|
888 |
|
var
sel
=
inst.
getSel();
|
|
872 |
|
var
sel
=
inst.
selection.
getSel();
|
889 |
|
va
r lastTR =
null;
|
|
873 |
|
var last
TR = null;
|
890 |
|
va
r curRow =
null;
|
|
874 |
|
var curR
ow = null;
|
891 |
|
va
r x1 = -1,
y1 = -1,
x2, y2;
|
|
875 |
|
var x1 =
-1, y1 =
-1, x2, y2
;
|
892 |
|
|
|
876 |
|
|
893 |
|
//
Only one
cell selec
ted, whats
the point
?
|
|
877 |
|
// Only
one cell s
elected, w
hats the p
oint?
|
894 |
|
if
(sel.rang
eCount < 2
)
|
|
878 |
|
if (sel.
rangeCount
< 2)
|
895 |
|
return t
rue;
|
|
879 |
|
retu
rn true;
|
896 |
|
|
|
880 |
|
|
897 |
|
//
Get all s
elected ce
lls
|
|
881 |
|
// Get a
ll selecte
d cells
|
898 |
|
fo
r (var i=0
; i<sel.ra
ngeCount;
i++) {
|
|
882 |
|
for (var
i=0; i<se
l.rangeCou
nt; i++) {
|
899 |
|
var rng
= sel.getR
angeAt(i);
|
|
883 |
|
var
rng = sel.
getRangeAt
(i);
|
900 |
|
var tdEl
m = rng.st
artContain
er.childNo
des[rng.st
artOffset]
;
|
|
884 |
|
var
tdElm = rn
g.startCon
tainer.chi
ldNodes[rn
g.startOff
set];
|
901 |
|
|
|
885 |
|
|
902 |
|
if (!tdE
lm)
|
|
886 |
|
if (
!tdElm)
|
903 |
|
brea
k;
|
|
887 |
|
break;
|
904 |
|
|
|
888 |
|
|
905 |
|
if (tdEl
m.nodeName
== "TD")
|
|
889 |
|
if (
tdElm.node
Name == "T
D")
|
906 |
|
cell
s[cells.le
ngth] = td
Elm;
|
|
890 |
|
cells[cell
s.length]
= tdElm;
|
907 |
|
}
|
|
891 |
|
}
|
908 |
|
|
|
892 |
|
|
909 |
|
//
Get rows
and cells
|
|
893 |
|
// Get r
ows and ce
lls
|
910 |
|
va
r tRows =
tableElm.r
ows;
|
|
894 |
|
var tRow
s = tableE
lm.rows;
|
911 |
|
fo
r (var y=0
; y<tRows.
length; y+
+) {
|
|
895 |
|
for (var
y=0; y<tR
ows.length
; y++) {
|
912 |
|
var
rowCells
=
new
Array()
;
|
|
896 |
|
var
rowCells
=
[]
;
|
913 |
|
|
|
897 |
|
|
914 |
|
for (var
x=0; x<tR
ows[y].cel
ls.length;
x++) {
|
|
898 |
|
for
(var x=0;
x<tRows[y]
.cells.len
gth; x++)
{
|
915 |
|
var
td = tRows
[y].cells[
x];
|
|
899 |
|
var td = t
Rows[y].ce
lls[x];
|
916 |
|
|
|
900 |
|
|
917 |
|
for
(var i=0;
i<cells.le
ngth; i++)
{
|
|
901 |
|
for (var i
=0; i<cell
s.length;
i++) {
|
918 |
|
if (td ==
cells[i])
{
|
|
902 |
|
if (td
== cells[
i]) {
|
919 |
|
rowCel
ls[rowCell
s.length]
= td;
|
|
903 |
|
ro
wCells[row
Cells.leng
th] = td;
|
920 |
|
}
|
|
904 |
|
}
|
921 |
|
}
|
|
905 |
|
}
|
922 |
|
}
|
|
906 |
|
}
|
923 |
|
|
|
907 |
|
|
924 |
|
if (rowC
ells.lengt
h > 0)
|
|
908 |
|
if (
rowCells.l
ength > 0)
|
925 |
|
rows
[rows.leng
th] = rowC
ells;
|
|
909 |
|
rows[rows.
length] =
rowCells;
|
926 |
|
}
|
|
910 |
|
}
|
927 |
|
|
|
911 |
|
|
928 |
|
//
Find sele
cted cells
in grid a
nd box
|
|
912 |
|
// Find
selected c
ells in gr
id and box
|
929 |
|
var
curRow
=
new
Array()
;
|
|
913 |
|
var
curRow
=
[]
;
|
930 |
|
va
r lastTR =
null;
|
|
914 |
|
var last
TR = null;
|
931 |
|
fo
r (var y=0
; y<grid.l
ength; y++
) {
|
|
915 |
|
for (var
y=0; y<gr
id.length;
y++) {
|
932 |
|
for (var
x=0; x<gr
id[y].leng
th; x++) {
|
|
916 |
|
for
(var x=0;
x<grid[y].
length; x+
+) {
|
933 |
|
grid
[y][x]._se
lected = f
alse;
|
|
917 |
|
grid[y][x]
._selected
= false;
|
934 |
|
|
|
918 |
|
|
935 |
|
for
(var i=0;
i<cells.le
ngth; i++)
{
|
|
919 |
|
for (var i
=0; i<cell
s.length;
i++) {
|
936 |
|
if (grid[y
][x] == ce
lls[i]) {
|
|
920 |
|
if (gr
id[y][x] =
= cells[i]
) {
|
937 |
|
// Get
start pos
|
|
921 |
|
//
Get start
pos
|
938 |
|
if (x1
== -1) {
|
|
922 |
|
if
(x1 == -1
) {
|
939 |
|
x1
= x;
|
|
923 |
|
x1 = x;
|
940 |
|
y1
= y;
|
|
924 |
|
y1 = y;
|
941 |
|
}
|
|
925 |
|
}
|
942 |
|
|
|
926 |
|
|
943 |
|
// Get
end pos
|
|
927 |
|
//
Get end p
os
|
944 |
|
x2 = x
;
|
|
928 |
|
x2
= x;
|
945 |
|
y2 = y
;
|
|
929 |
|
y2
= y;
|
946 |
|
|
|
930 |
|
|
947 |
|
grid[y
][x]._sele
cted = tru
e;
|
|
931 |
|
gr
id[y][x]._
selected =
true;
|
948 |
|
}
|
|
932 |
|
}
|
949 |
|
}
|
|
933 |
|
}
|
950 |
|
}
|
|
934 |
|
}
|
951 |
|
}
|
|
935 |
|
}
|
952 |
|
|
|
936 |
|
|
953 |
|
//
Is there
gaps, if s
o deny
|
|
937 |
|
// Is th
ere gaps,
if so deny
|
954 |
|
fo
r (var y=y
1; y<=y2;
y++) {
|
|
938 |
|
for (var
y=y1; y<=
y2; y++) {
|
955 |
|
for (var
x=x1; x<=
x2; x++) {
|
|
939 |
|
for
(var x=x1;
x<=x2; x+
+) {
|
956 |
|
if (
!grid[y][x
]._selecte
d) {
|
|
940 |
|
if (!grid[
y][x]._sel
ected) {
|
957 |
|
alert("Inv
alid selec
tion for m
erge.");
|
|
941 |
|
alert(
"Invalid s
election f
or merge."
);
|
958 |
|
return tru
e;
|
|
942 |
|
return
true;
|
959 |
|
}
|
|
943 |
|
}
|
960 |
|
}
|
|
944 |
|
}
|
961 |
|
}
|
|
945 |
|
}
|
962 |
|
}
|
|
946 |
|
}
|
963 |
|
|
|
947 |
|
|
964 |
|
// Val
idate sele
ction and
get total
rowspan an
d colspan
|
|
948 |
|
//
Validate
selection
and get to
tal rowspa
n and cols
pan
|
965 |
|
var ro
wSpan = 1,
colSpan =
1;
|
|
949 |
|
va
r rowSpan
= 1, colSp
an = 1;
|
966 |
|
|
|
950 |
|
|
967 |
|
// Val
idate hori
zontal and
get total
colspan
|
|
951 |
|
//
Validate
horizontal
and get t
otal colsp
an
|
968 |
|
var la
stRowSpan
= -1;
|
|
952 |
|
va
r lastRowS
pan = -1;
|
969 |
|
for (v
ar y=0; y<
rows.lengt
h; y++) {
|
|
953 |
|
fo
r (var y=0
; y<rows.l
ength; y++
) {
|
970 |
|
va
r rowColSp
an = 0;
|
|
954 |
|
var rowC
olSpan = 0
;
|
971 |
|
|
|
955 |
|
|
972 |
|
fo
r (var x=0
; x<rows[y
].length;
x++) {
|
|
956 |
|
for (var
x=0; x<ro
ws[y].leng
th; x++) {
|
973 |
|
var sd =
getColRow
Span(rows[
y][x]);
|
|
957 |
|
var
sd = getCo
lRowSpan(r
ows[y][x])
;
|
974 |
|
|
|
958 |
|
|
975 |
|
rowColSp
an += sd['
colspan'];
|
|
959 |
|
rowC
olSpan +=
sd['colspa
n'];
|
976 |
|
|
|
960 |
|
|
977 |
|
if (last
RowSpan !=
-1 && sd[
'rowspan']
!= lastRo
wSpan) {
|
|
961 |
|
if (
lastRowSpa
n != -1 &&
sd['rowsp
an'] != la
stRowSpan)
{
|
978 |
|
aler
t("Invalid
selection
for merge
.");
|
|
962 |
|
alert("Inv
alid selec
tion for m
erge.");
|
979 |
|
retu
rn true;
|
|
963 |
|
return tru
e;
|
980 |
|
}
|
|
964 |
|
}
|
981 |
|
|
|
965 |
|
|
982 |
|
lastRowS
pan = sd['
rowspan'];
|
|
966 |
|
last
RowSpan =
sd['rowspa
n'];
|
983 |
|
}
|
|
967 |
|
}
|
984 |
|
|
|
968 |
|
|
985 |
|
if
(rowColSp
an > colSp
an)
|
|
969 |
|
if (rowC
olSpan > c
olSpan)
|
986 |
|
colSpan
= rowColSp
an;
|
|
970 |
|
colS
pan = rowC
olSpan;
|
987 |
|
|
|
971 |
|
|
988 |
|
la
stRowSpan
= -1;
|
|
972 |
|
lastRowS
pan = -1;
|
989 |
|
}
|
|
973 |
|
}
|
990 |
|
|
|
974 |
|
|
991 |
|
// Val
idate vert
ical and g
et total r
owspan
|
|
975 |
|
//
Validate
vertical a
nd get tot
al rowspan
|
992 |
|
var la
stColSpan
= -1;
|
|
976 |
|
va
r lastColS
pan = -1;
|
993 |
|
for (v
ar x=0; x<
rows[0].le
ngth; x++)
{
|
|
977 |
|
fo
r (var x=0
; x<rows[0
].length;
x++) {
|
994 |
|
va
r colRowSp
an = 0;
|
|
978 |
|
var colR
owSpan = 0
;
|
995 |
|
|
|
979 |
|
|
996 |
|
fo
r (var y=0
; y<rows.l
ength; y++
) {
|
|
980 |
|
for (var
y=0; y<ro
ws.length;
y++) {
|
997 |
|
var sd =
getColRow
Span(rows[
y][x]);
|
|
981 |
|
var
sd = getCo
lRowSpan(r
ows[y][x])
;
|
998 |
|
|
|
982 |
|
|
999 |
|
colRowSp
an += sd['
rowspan'];
|
|
983 |
|
colR
owSpan +=
sd['rowspa
n'];
|
1000 |
|
|
|
984 |
|
|
1001 |
|
if (last
ColSpan !=
-1 && sd[
'colspan']
!= lastCo
lSpan) {
|
|
985 |
|
if (
lastColSpa
n != -1 &&
sd['colsp
an'] != la
stColSpan)
{
|
1002 |
|
aler
t("Invalid
selection
for merge
.");
|
|
986 |
|
alert("Inv
alid selec
tion for m
erge.");
|
1003 |
|
retu
rn true;
|
|
987 |
|
return tru
e;
|
1004 |
|
}
|
|
988 |
|
}
|
1005 |
|
|
|
989 |
|
|
1006 |
|
lastColS
pan = sd['
colspan'];
|
|
990 |
|
last
ColSpan =
sd['colspa
n'];
|
1007 |
|
}
|
|
991 |
|
}
|
1008 |
|
|
|
992 |
|
|
1009 |
|
if
(colRowSp
an > rowSp
an)
|
|
993 |
|
if (colR
owSpan > r
owSpan)
|
1010 |
|
rowSpan
= colRowSp
an;
|
|
994 |
|
rowS
pan = colR
owSpan;
|
1011 |
|
|
|
995 |
|
|
1012 |
|
la
stColSpan
= -1;
|
|
996 |
|
lastColS
pan = -1;
|
1013 |
|
}
|
|
997 |
|
}
|
1014 |
|
|
|
998 |
|
|
1015 |
|
// Set
up td
|
|
999 |
|
//
Setup td
|
1016 |
|
tdElm
= rows[0][
0];
|
|
1000 |
|
td
Elm = rows
[0][0];
|
1017 |
|
tdElm.
rowSpan =
rowSpan;
|
|
1001 |
|
td
Elm.rowSpa
n = rowSpa
n;
|
1018 |
|
tdElm.
colSpan =
colSpan;
|
|
1002 |
|
td
Elm.colSpa
n = colSpa
n;
|
1019 |
|
|
|
1003 |
|
|
1020 |
|
// Mer
ge cells
|
|
1004 |
|
//
Merge cel
ls
|
1021 |
|
for (v
ar y=0; y<
rows.lengt
h; y++) {
|
|
1005 |
|
fo
r (var y=0
; y<rows.l
ength; y++
) {
|
1022 |
|
fo
r (var x=0
; x<rows[y
].length;
x++) {
|
|
1006 |
|
for (var
x=0; x<ro
ws[y].leng
th; x++) {
|
1023 |
|
var html
= rows[y]
[x].innerH
TML;
|
|
1007 |
|
var
html = row
s[y][x].in
nerHTML;
|
1024 |
|
var
chk
=
t
inyMCE
.re
gexpRe
place(
html,
"
[
\t\r\n]
"
,
"");
|
|
1008 |
|
var
chk
=
h
t
ml
.re
place(
/
[
\t\r\n]
/g
,
"");
|
1025 |
|
|
|
1009 |
|
|
1026 |
|
if
(chk
!=
"<br/>"
&&
chk
!=
"<br>"
&&
chk
!=
"&n
b
s
p;
"
&&
(x+y
>
0))
|
|
1010 |
|
if
(chk
!=
"<br/>"
&&
chk
!=
"<br>"
&&
chk
!=
'<br
mce_
b
ogu
s
=
"
1"/>'
&&
(x+y
>
0))
|
1027 |
|
tdEl
m.innerHTM
L += html;
|
|
1011 |
|
tdElm.inne
rHTML += h
tml;
|
1028 |
|
|
|
1012 |
|
|
1029 |
|
// Not c
urrent cel
l
|
|
1013 |
|
// N
ot current
cell
|
1030 |
|
if (rows
[y][x] !=
tdElm && !
rows[y][x]
._deleted)
{
|
|
1014 |
|
if (
rows[y][x]
!= tdElm
&& !rows[y
][x]._dele
ted) {
|
1031 |
|
var
cpos = get
CellPos(gr
id, rows[y
][x]);
|
|
1015 |
|
var cpos =
getCellPo
s(grid, ro
ws[y][x]);
|
1032 |
|
var
tr = rows[
y][x].pare
ntNode;
|
|
1016 |
|
var tr = r
ows[y][x].
parentNode
;
|
1033 |
|
|
|
1017 |
|
|
1034 |
|
tr.r
emoveChild
(rows[y][x
]);
|
|
1018 |
|
tr.removeC
hild(rows[
y][x]);
|
1035 |
|
rows
[y][x]._de
leted = tr
ue;
|
|
1019 |
|
rows[y][x]
._deleted
= true;
|
1036 |
|
|
|
1020 |
|
|
1037 |
|
// E
mpty TR, r
emove it
|
|
1021 |
|
// Empty T
R, remove
it
|
1038 |
|
if (
!tr.hasChi
ldNodes())
{
|
|
1022 |
|
if (!tr.ha
sChildNode
s()) {
|
1039 |
|
tr.parentN
ode.remove
Child(tr);
|
|
1023 |
|
tr.par
entNode.re
moveChild(
tr);
|
1040 |
|
|
|
1024 |
|
|
1041 |
|
var lastCe
ll = null;
|
|
1025 |
|
var la
stCell = n
ull;
|
1042 |
|
for (var x
=0; cellEl
m = getCel
l(grid, cp
os.rowinde
x, x); x++
) {
|
|
1026 |
|
for (v
ar x=0; ce
llElm = ge
tCell(grid
, cpos.row
index, x);
x++) {
|
1043 |
|
if (ce
llElm != l
astCell &&
cellElm.r
owSpan > 1
)
|
|
1027 |
|
if
(cellElm
!= lastCel
l && cellE
lm.rowSpan
> 1)
|
1044 |
|
ce
llElm.rowS
pan--;
|
|
1028 |
|
cellElm.
rowSpan--;
|
1045 |
|
|
|
1029 |
|
|
1046 |
|
lastCe
ll = cellE
lm;
|
|
1030 |
|
la
stCell = c
ellElm;
|
1047 |
|
}
|
|
1031 |
|
}
|
1048 |
|
|
|
1032 |
|
|
1049 |
|
if (tdElm.
rowSpan >
1)
|
|
1033 |
|
if (td
Elm.rowSpa
n > 1)
|
1050 |
|
tdElm.
rowSpan--;
|
|
1034 |
|
td
Elm.rowSpa
n--;
|
1051 |
|
}
|
|
1035 |
|
}
|
1052 |
|
}
|
|
1036 |
|
}
|
1053 |
|
}
|
|
1037 |
|
}
|
1054 |
|
}
|
|
1038 |
|
}
|
1055 |
|
|
|
1039 |
|
|
|
|
1040 |
|
//
Remove al
l but one
bogus br
|
|
|
1041 |
|
ea
ch(ed.dom.
select('br
', tdElm),
function(
e, i) {
|
|
|
1042 |
|
if (i >
0 && ed.do
m.getAttri
b(e, 'mce_
bogus'))
|
|
|
1043 |
|
ed.d
om.remove(
e);
|
|
|
1044 |
|
})
;
|
|
|
1045 |
|
|
1056 |
|
break;
|
|
1046 |
|
br
eak;
|
1057 |
|
}
|
|
1047 |
|
}
|
1058 |
|
|
|
1048 |
|
|
1059 |
|
tableElm
=
t
in
yMCE
.getParent
Element
(inst.
getFocu
s
El
e
m
e
n
t
(),
"table");
|
|
1049 |
|
tableElm
=
in
st.dom
.getParent
(inst.
s
e
l
e
ctio
n
.ge
t
Node
(),
"table");
|
1060 |
|
tinyMCE.ha
ndleVisual
Aid(tableE
lm, true,
tinyMCE.se
ttings['vi
sual'], ti
nyMCE.sele
ctedInstan
ce);
|
|
1050 |
|
inst.a
ddVisual(t
ableElm);
|
1061 |
|
tinyMCE.tr
iggerNodeC
hange();
|
|
1051 |
|
inst.
nod
e
Ch
a
n
ged
();
|
1062 |
|
inst.
r
e
p
a
i
n
t
();
|
|
|
1063 |
|
}
|
|
1052 |
|
}
|
1064 |
|
|
|
1053 |
|
|
1065 |
|
return t
rue;
|
|
1054 |
|
retu
rn true;
|
1066 |
|
}
|
|
1055 |
|
}
|
1067 |
|
|
|
1056 |
|
|
1068 |
|
//
Pass to n
ext handle
r in chain
|
|
1057 |
|
// Pass
to next ha
ndler in c
hain
|
1069 |
|
re
turn false
;
|
|
1058 |
|
return f
alse;
|
1070 |
|
}
|
|
1059 |
|
}
|
1071 |
|
}
;
|
|
1060 |
|
}
)
;
|
1072 |
|
|
|
1061 |
|
|
1073 |
|
tiny
MCE
.
add
Plugin
(
"
table
"
,
T
iny
MCE_
TablePlugi
n);
|
|
1062 |
|
// Reg
ister plug
in
|
|
|
1063 |
|
tiny
mce
.
Plugin
Manager.ad
d
(
'
table
'
,
t
iny
mce.plugin
s.
TablePlugi
n);
|
|
|
1064 |
|
})();
|