rails_kindeditor 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor-min.js +165 -161
  2. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/en.js +210 -210
  3. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_CN.js +214 -214
  4. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_TW.js +212 -212
  5. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/anchor/anchor.js +46 -46
  6. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/clearhtml/clearhtml.js +29 -29
  7. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/filemanager/filemanager.js +189 -185
  8. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/flash/flash.js +145 -145
  9. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/image.js +259 -242
  10. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/insertfile/insertfile.js +109 -109
  11. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/link/link.js +65 -65
  12. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/map/map.js +137 -137
  13. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/media/media.js +153 -153
  14. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/pagebreak/pagebreak.js +26 -26
  15. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/table/table.js +715 -715
  16. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/wordpaste/wordpaste.js +51 -51
  17. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/common/loading.gif +0 -0
  18. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.css +991 -980
  19. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.png +0 -0
  20. data/lib/rails_kindeditor/version.rb +1 -1
  21. metadata +29 -51
  22. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.gif +0 -0
@@ -1,153 +1,153 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
- KindEditor.plugin('media', function(K) {
11
- var self = this, name = 'media', lang = self.lang(name + '.'),
12
- allowMediaUpload = K.undef(self.allowMediaUpload, true),
13
- allowFileManager = K.undef(self.allowFileManager, false),
14
- uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
15
- self.plugin.media = {
16
- edit : function() {
17
- var html = [
18
- '<div style="padding:10px 20px;">',
19
- //url
20
- '<div class="ke-dialog-row">',
21
- '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
22
- '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> &nbsp;',
23
- '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
24
- '<span class="ke-button-common ke-button-outer">',
25
- '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
26
- '</span>',
27
- '</div>',
28
- //width
29
- '<div class="ke-dialog-row">',
30
- '<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
31
- '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" />',
32
- '</div>',
33
- //height
34
- '<div class="ke-dialog-row">',
35
- '<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
36
- '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" />',
37
- '</div>',
38
- //autostart
39
- '<div class="ke-dialog-row">',
40
- '<label for="keAutostart">' + lang.autostart + '</label>',
41
- '<input type="checkbox" id="keAutostart" name="autostart" value="" /> ',
42
- '</div>',
43
- '</div>'
44
- ].join('');
45
- var dialog = self.createDialog({
46
- name : name,
47
- width : 450,
48
- height : 230,
49
- title : self.lang(name),
50
- body : html,
51
- yesBtn : {
52
- name : self.lang('yes'),
53
- click : function(e) {
54
- var url = K.trim(urlBox.val()),
55
- width = widthBox.val(),
56
- height = heightBox.val();
57
- if (url == 'http://' || K.invalidUrl(url)) {
58
- alert(self.lang('invalidUrl'));
59
- urlBox[0].focus();
60
- return;
61
- }
62
- if (!/^\d*$/.test(width)) {
63
- alert(self.lang('invalidWidth'));
64
- widthBox[0].focus();
65
- return;
66
- }
67
- if (!/^\d*$/.test(height)) {
68
- alert(self.lang('invalidHeight'));
69
- heightBox[0].focus();
70
- return;
71
- }
72
- var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
73
- src : url,
74
- type : K.mediaType(url),
75
- width : width,
76
- height : height,
77
- autostart : autostartBox[0].checked ? 'true' : 'false',
78
- loop : 'true'
79
- });
80
- self.insertHtml(html).hideDialog().focus();
81
- }
82
- }
83
- }),
84
- div = dialog.div,
85
- urlBox = K('[name="url"]', div),
86
- viewServerBtn = K('[name="viewServer"]', div),
87
- widthBox = K('[name="width"]', div),
88
- heightBox = K('[name="height"]', div),
89
- autostartBox = K('[name="autostart"]', div);
90
- urlBox.val('http://');
91
-
92
- if (allowMediaUpload) {
93
- var uploadbutton = K.uploadbutton({
94
- button : K('.ke-upload-button', div)[0],
95
- fieldName : 'imgFile',
96
- url : K.addParam(uploadJson, 'dir=media'),
97
- afterUpload : function(data) {
98
- if (data.error === 0) {
99
- var url = K.formatUrl(data.url, 'absolute');
100
- urlBox.val(url);
101
- if (self.afterUpload) {
102
- self.afterUpload.call(self, url);
103
- }
104
- alert(self.lang('uploadSuccess'));
105
- } else {
106
- alert(data.message);
107
- }
108
- }
109
- });
110
- uploadbutton.fileBox.change(function(e) {
111
- uploadbutton.submit();
112
- });
113
- } else {
114
- K('.ke-upload-button', div).hide();
115
- urlBox.width(250);
116
- }
117
-
118
- if (allowFileManager) {
119
- viewServerBtn.click(function(e) {
120
- self.loadPlugin('filemanager', function() {
121
- self.plugin.filemanagerDialog({
122
- viewType : 'LIST',
123
- dirName : 'media',
124
- clickFn : function(url, title) {
125
- if (self.dialogs.length > 1) {
126
- K('[name="url"]', div).val(url);
127
- self.hideDialog();
128
- }
129
- }
130
- });
131
- });
132
- });
133
- } else {
134
- viewServerBtn.hide();
135
- }
136
-
137
- var img = self.plugin.getSelectedMedia();
138
- if (img) {
139
- var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
140
- urlBox.val(attrs.src);
141
- widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
142
- heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
143
- autostartBox[0].checked = (attrs.autostart === 'true');
144
- }
145
- urlBox[0].focus();
146
- urlBox[0].select();
147
- },
148
- 'delete' : function() {
149
- self.plugin.getSelectedMedia().remove();
150
- }
151
- };
152
- self.clickToolbar(name, self.plugin.media.edit);
153
- });
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ KindEditor.plugin('media', function(K) {
11
+ var self = this, name = 'media', lang = self.lang(name + '.'),
12
+ allowMediaUpload = K.undef(self.allowMediaUpload, true),
13
+ allowFileManager = K.undef(self.allowFileManager, false),
14
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
15
+ self.plugin.media = {
16
+ edit : function() {
17
+ var html = [
18
+ '<div style="padding:10px 20px;">',
19
+ //url
20
+ '<div class="ke-dialog-row">',
21
+ '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
22
+ '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> &nbsp;',
23
+ '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
24
+ '<span class="ke-button-common ke-button-outer">',
25
+ '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
26
+ '</span>',
27
+ '</div>',
28
+ //width
29
+ '<div class="ke-dialog-row">',
30
+ '<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
31
+ '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" />',
32
+ '</div>',
33
+ //height
34
+ '<div class="ke-dialog-row">',
35
+ '<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
36
+ '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" />',
37
+ '</div>',
38
+ //autostart
39
+ '<div class="ke-dialog-row">',
40
+ '<label for="keAutostart">' + lang.autostart + '</label>',
41
+ '<input type="checkbox" id="keAutostart" name="autostart" value="" /> ',
42
+ '</div>',
43
+ '</div>'
44
+ ].join('');
45
+ var dialog = self.createDialog({
46
+ name : name,
47
+ width : 450,
48
+ height : 230,
49
+ title : self.lang(name),
50
+ body : html,
51
+ yesBtn : {
52
+ name : self.lang('yes'),
53
+ click : function(e) {
54
+ var url = K.trim(urlBox.val()),
55
+ width = widthBox.val(),
56
+ height = heightBox.val();
57
+ if (url == 'http://' || K.invalidUrl(url)) {
58
+ alert(self.lang('invalidUrl'));
59
+ urlBox[0].focus();
60
+ return;
61
+ }
62
+ if (!/^\d*$/.test(width)) {
63
+ alert(self.lang('invalidWidth'));
64
+ widthBox[0].focus();
65
+ return;
66
+ }
67
+ if (!/^\d*$/.test(height)) {
68
+ alert(self.lang('invalidHeight'));
69
+ heightBox[0].focus();
70
+ return;
71
+ }
72
+ var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
73
+ src : url,
74
+ type : K.mediaType(url),
75
+ width : width,
76
+ height : height,
77
+ autostart : autostartBox[0].checked ? 'true' : 'false',
78
+ loop : 'true'
79
+ });
80
+ self.insertHtml(html).hideDialog().focus();
81
+ }
82
+ }
83
+ }),
84
+ div = dialog.div,
85
+ urlBox = K('[name="url"]', div),
86
+ viewServerBtn = K('[name="viewServer"]', div),
87
+ widthBox = K('[name="width"]', div),
88
+ heightBox = K('[name="height"]', div),
89
+ autostartBox = K('[name="autostart"]', div);
90
+ urlBox.val('http://');
91
+
92
+ if (allowMediaUpload) {
93
+ var uploadbutton = K.uploadbutton({
94
+ button : K('.ke-upload-button', div)[0],
95
+ fieldName : 'imgFile',
96
+ url : K.addParam(uploadJson, 'dir=media'),
97
+ afterUpload : function(data) {
98
+ if (data.error === 0) {
99
+ var url = K.formatUrl(data.url, 'absolute');
100
+ urlBox.val(url);
101
+ if (self.afterUpload) {
102
+ self.afterUpload.call(self, url);
103
+ }
104
+ alert(self.lang('uploadSuccess'));
105
+ } else {
106
+ alert(data.message);
107
+ }
108
+ }
109
+ });
110
+ uploadbutton.fileBox.change(function(e) {
111
+ uploadbutton.submit();
112
+ });
113
+ } else {
114
+ K('.ke-upload-button', div).hide();
115
+ urlBox.width(250);
116
+ }
117
+
118
+ if (allowFileManager) {
119
+ viewServerBtn.click(function(e) {
120
+ self.loadPlugin('filemanager', function() {
121
+ self.plugin.filemanagerDialog({
122
+ viewType : 'LIST',
123
+ dirName : 'media',
124
+ clickFn : function(url, title) {
125
+ if (self.dialogs.length > 1) {
126
+ K('[name="url"]', div).val(url);
127
+ self.hideDialog();
128
+ }
129
+ }
130
+ });
131
+ });
132
+ });
133
+ } else {
134
+ viewServerBtn.hide();
135
+ }
136
+
137
+ var img = self.plugin.getSelectedMedia();
138
+ if (img) {
139
+ var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
140
+ urlBox.val(attrs.src);
141
+ widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
142
+ heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
143
+ autostartBox[0].checked = (attrs.autostart === 'true');
144
+ }
145
+ urlBox[0].focus();
146
+ urlBox[0].select();
147
+ },
148
+ 'delete' : function() {
149
+ self.plugin.getSelectedMedia().remove();
150
+ }
151
+ };
152
+ self.clickToolbar(name, self.plugin.media.edit);
153
+ });
@@ -1,26 +1,26 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
- KindEditor.plugin('pagebreak', function(K) {
11
- var self = this, name = 'pagebreak';
12
- self.clickToolbar(name, function() {
13
- var cmd = self.cmd, range = cmd.range;
14
- self.focus();
15
- range.enlarge(true);
16
- cmd.split(true);
17
- var tail = self.newlineTag == 'br' || K.WEBKIT ? '' : '<p id="__kindeditor_tail_tag__"></p>';
18
- self.insertHtml('<hr class="ke-pagebreak" style="page-break-after: always;" />' + tail);
19
- if (tail !== '') {
20
- var p = K('#__kindeditor_tail_tag__', self.edit.doc);
21
- range.selectNodeContents(p[0]);
22
- p.removeAttr('id');
23
- cmd.select();
24
- }
25
- });
26
- });
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ KindEditor.plugin('pagebreak', function(K) {
11
+ var self = this, name = 'pagebreak';
12
+ self.clickToolbar(name, function() {
13
+ var cmd = self.cmd, range = cmd.range;
14
+ self.focus();
15
+ range.enlarge(true);
16
+ cmd.split(true);
17
+ var tail = self.newlineTag == 'br' || K.WEBKIT ? '' : '<p id="__kindeditor_tail_tag__"></p>';
18
+ self.insertHtml('<hr class="ke-pagebreak" style="page-break-after: always;" />' + tail);
19
+ if (tail !== '') {
20
+ var p = K('#__kindeditor_tail_tag__', self.edit.doc);
21
+ range.selectNodeContents(p[0]);
22
+ p.removeAttr('id');
23
+ cmd.select();
24
+ }
25
+ });
26
+ });
@@ -1,715 +1,715 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
- KindEditor.plugin('table', function(K) {
11
- var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
12
- // 取得下一行cell的index
13
- function _getCellIndex(table, row, cell) {
14
- var rowSpanCount = 0;
15
- for (var i = 0, len = row.cells.length; i < len; i++) {
16
- if (row.cells[i] == cell) {
17
- break;
18
- }
19
- rowSpanCount += row.cells[i].rowSpan - 1;
20
- }
21
- return cell.cellIndex - rowSpanCount;
22
- }
23
- self.plugin.table = {
24
- //insert or modify table
25
- prop : function(isInsert) {
26
- var html = [
27
- '<div style="padding:10px 20px;">',
28
- //rows, cols
29
- '<div class="ke-dialog-row">',
30
- '<label for="keRows" style="width:90px;">' + lang.cells + '</label>',
31
- lang.rows + ' <input type="text" id="keRows" class="ke-input-text ke-input-number" name="rows" value="" maxlength="4" /> &nbsp; ',
32
- lang.cols + ' <input type="text" class="ke-input-text ke-input-number" name="cols" value="" maxlength="4" />',
33
- '</div>',
34
- //width, height
35
- '<div class="ke-dialog-row">',
36
- '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
37
- lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
38
- '<select name="widthType">',
39
- '<option value="%">' + lang.percent + '</option>',
40
- '<option value="px">' + lang.px + '</option>',
41
- '</select> &nbsp; ',
42
- lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
43
- '<select name="heightType">',
44
- '<option value="%">' + lang.percent + '</option>',
45
- '<option value="px">' + lang.px + '</option>',
46
- '</select>',
47
- '</div>',
48
- //space, padding
49
- '<div class="ke-dialog-row">',
50
- '<label for="kePadding" style="width:90px;">' + lang.space + '</label>',
51
- lang.padding + ' <input type="text" id="kePadding" class="ke-input-text ke-input-number" name="padding" value="" maxlength="4" /> &nbsp; ',
52
- lang.spacing + ' <input type="text" class="ke-input-text ke-input-number" name="spacing" value="" maxlength="4" />',
53
- '</div>',
54
- //align
55
- '<div class="ke-dialog-row">',
56
- '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
57
- '<select id="keAlign" name="align">',
58
- '<option value="">' + lang.alignDefault + '</option>',
59
- '<option value="left">' + lang.alignLeft + '</option>',
60
- '<option value="center">' + lang.alignCenter + '</option>',
61
- '<option value="right">' + lang.alignRight + '</option>',
62
- '</select>',
63
- '</div>',
64
- //border
65
- '<div class="ke-dialog-row">',
66
- '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
67
- lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
68
- lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
69
- '</div>',
70
- //background color
71
- '<div class="ke-dialog-row">',
72
- '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
73
- '<span class="ke-inline-block ke-input-color"></span>',
74
- '</div>',
75
- '</div>'
76
- ].join('');
77
- var picker, currentElement;
78
- function removePicker() {
79
- if (picker) {
80
- picker.remove();
81
- picker = null;
82
- currentElement = null;
83
- }
84
- }
85
- var dialog = self.createDialog({
86
- name : name,
87
- width : 500,
88
- height : 300,
89
- title : self.lang(name),
90
- body : html,
91
- beforeDrag : removePicker,
92
- beforeRemove : function() {
93
- removePicker();
94
- colorBox.unbind();
95
- },
96
- yesBtn : {
97
- name : self.lang('yes'),
98
- click : function(e) {
99
- var rows = rowsBox.val(),
100
- cols = colsBox.val(),
101
- width = widthBox.val(),
102
- height = heightBox.val(),
103
- widthType = widthTypeBox.val(),
104
- heightType = heightTypeBox.val(),
105
- padding = paddingBox.val(),
106
- spacing = spacingBox.val(),
107
- align = alignBox.val(),
108
- border = borderBox.val(),
109
- borderColor = K(colorBox[0]).html() || '',
110
- bgColor = K(colorBox[1]).html() || '';
111
- if (rows == 0 || !/^\d+$/.test(rows)) {
112
- alert(self.lang('invalidRows'));
113
- rowsBox[0].focus();
114
- return;
115
- }
116
- if (cols == 0 || !/^\d+$/.test(cols)) {
117
- alert(self.lang('invalidRows'));
118
- colsBox[0].focus();
119
- return;
120
- }
121
- if (!/^\d*$/.test(width)) {
122
- alert(self.lang('invalidWidth'));
123
- widthBox[0].focus();
124
- return;
125
- }
126
- if (!/^\d*$/.test(height)) {
127
- alert(self.lang('invalidHeight'));
128
- heightBox[0].focus();
129
- return;
130
- }
131
- if (!/^\d*$/.test(padding)) {
132
- alert(self.lang('invalidPadding'));
133
- paddingBox[0].focus();
134
- return;
135
- }
136
- if (!/^\d*$/.test(spacing)) {
137
- alert(self.lang('invalidSpacing'));
138
- spacingBox[0].focus();
139
- return;
140
- }
141
- if (!/^\d*$/.test(border)) {
142
- alert(self.lang('invalidBorder'));
143
- borderBox[0].focus();
144
- return;
145
- }
146
- //modify table
147
- if (table) {
148
- if (width !== '') {
149
- table.width(width + widthType);
150
- } else {
151
- table.css('width', '');
152
- }
153
- if (table[0].width !== undefined) {
154
- table.removeAttr('width');
155
- }
156
- if (height !== '') {
157
- table.height(height + heightType);
158
- } else {
159
- table.css('height', '');
160
- }
161
- if (table[0].height !== undefined) {
162
- table.removeAttr('height');
163
- }
164
- table.css('background-color', bgColor);
165
- if (table[0].bgColor !== undefined) {
166
- table.removeAttr('bgColor');
167
- }
168
- if (padding !== '') {
169
- table[0].cellPadding = padding;
170
- } else {
171
- table.removeAttr('cellPadding');
172
- }
173
- if (spacing !== '') {
174
- table[0].cellSpacing = spacing;
175
- } else {
176
- table.removeAttr('cellSpacing');
177
- }
178
- if (align !== '') {
179
- table[0].align = align;
180
- } else {
181
- table.removeAttr('align');
182
- }
183
- if (border !== '') {
184
- table.attr('border', border);
185
- } else {
186
- table.removeAttr('border');
187
- }
188
- if (border === '' || border === '0') {
189
- table.addClass(zeroborder);
190
- } else {
191
- table.removeClass(zeroborder);
192
- }
193
- if (borderColor !== '') {
194
- table.attr('borderColor', borderColor);
195
- } else {
196
- table.removeAttr('borderColor');
197
- }
198
- self.hideDialog().focus();
199
- return;
200
- }
201
- //insert new table
202
- var style = '';
203
- if (width !== '') {
204
- style += 'width:' + width + widthType + ';';
205
- }
206
- if (height !== '') {
207
- style += 'height:' + height + heightType + ';';
208
- }
209
- if (bgColor !== '') {
210
- style += 'background-color:' + bgColor + ';';
211
- }
212
- var html = '<table';
213
- if (style !== '') {
214
- html += ' style="' + style + '"';
215
- }
216
- if (padding !== '') {
217
- html += ' cellpadding="' + padding + '"';
218
- }
219
- if (spacing !== '') {
220
- html += ' cellspacing="' + spacing + '"';
221
- }
222
- if (align !== '') {
223
- html += ' align="' + align + '"';
224
- }
225
- if (border !== '') {
226
- html += ' border="' + border + '"';
227
- }
228
- if (border === '' || border === '0') {
229
- html += ' class="' + zeroborder + '"';
230
- }
231
- if (borderColor !== '') {
232
- html += ' bordercolor="' + borderColor + '"';
233
- }
234
- html += '>';
235
- for (var i = 0; i < rows; i++) {
236
- html += '<tr>';
237
- for (var j = 0; j < cols; j++) {
238
- html += '<td>' + (K.IE ? '' : '<br />') + '</td>';
239
- }
240
- html += '</tr>';
241
- }
242
- html += '</table>';
243
- if (!K.IE) {
244
- html += '<br />';
245
- }
246
- self.insertHtml(html);
247
- self.select().hideDialog().focus();
248
- self.addBookmark();
249
- }
250
- }
251
- }),
252
- div = dialog.div,
253
- rowsBox = K('[name="rows"]', div).val(3),
254
- colsBox = K('[name="cols"]', div).val(2),
255
- widthBox = K('[name="width"]', div).val(100),
256
- heightBox = K('[name="height"]', div),
257
- widthTypeBox = K('[name="widthType"]', div),
258
- heightTypeBox = K('[name="heightType"]', div),
259
- paddingBox = K('[name="padding"]', div).val(2),
260
- spacingBox = K('[name="spacing"]', div).val(0),
261
- alignBox = K('[name="align"]', div),
262
- borderBox = K('[name="border"]', div).val(1),
263
- colorBox = K('.ke-input-color', div);
264
- function setColor(box, color) {
265
- color = color.toUpperCase();
266
- box.css('background-color', color);
267
- box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
268
- box.html(color);
269
- }
270
- setColor(K(colorBox[0]), '#000000');
271
- setColor(K(colorBox[1]), '');
272
- function clickHandler(e) {
273
- removePicker();
274
- if (!picker || this !== currentElement) {
275
- var box = K(this),
276
- pos = box.pos();
277
- picker = K.colorpicker({
278
- x : pos.x,
279
- y : pos.y + box.height(),
280
- z : 811214,
281
- selectedColor : K(this).html(),
282
- colors : self.colorTable,
283
- noColor : self.lang('noColor'),
284
- click : function(color) {
285
- setColor(box, color);
286
- removePicker();
287
- }
288
- });
289
- currentElement = this;
290
- }
291
- }
292
- colorBox.click(clickHandler);
293
- // foucs and select
294
- rowsBox[0].focus();
295
- rowsBox[0].select();
296
- var table;
297
- if (isInsert) {
298
- return;
299
- }
300
- //get selected table node
301
- table = self.plugin.getSelectedTable();
302
- if (table) {
303
- rowsBox.val(table[0].rows.length);
304
- colsBox.val(table[0].rows.length > 0 ? table[0].rows[0].cells.length : 0);
305
- rowsBox.attr('disabled', true);
306
- colsBox.attr('disabled', true);
307
- var match,
308
- tableWidth = table[0].style.width || table[0].width,
309
- tableHeight = table[0].style.height || table[0].height;
310
- if (tableWidth !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableWidth))) {
311
- widthBox.val(match[1]);
312
- widthTypeBox.val(match[2]);
313
- } else {
314
- widthBox.val('');
315
- }
316
- if (tableHeight !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableHeight))) {
317
- heightBox.val(match[1]);
318
- heightTypeBox.val(match[2]);
319
- }
320
- paddingBox.val(table[0].cellPadding || '');
321
- spacingBox.val(table[0].cellSpacing || '');
322
- alignBox.val(table[0].align || '');
323
- borderBox.val(table[0].border === undefined ? '' : table[0].border);
324
- setColor(K(colorBox[0]), K.toHex(table.attr('borderColor') || ''));
325
- setColor(K(colorBox[1]), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
326
- widthBox[0].focus();
327
- widthBox[0].select();
328
- }
329
- },
330
- //modify cell
331
- cellprop : function() {
332
- var html = [
333
- '<div style="padding:10px 20px;">',
334
- //width, height
335
- '<div class="ke-dialog-row">',
336
- '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
337
- lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
338
- '<select name="widthType">',
339
- '<option value="%">' + lang.percent + '</option>',
340
- '<option value="px">' + lang.px + '</option>',
341
- '</select> &nbsp; ',
342
- lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
343
- '<select name="heightType">',
344
- '<option value="%">' + lang.percent + '</option>',
345
- '<option value="px">' + lang.px + '</option>',
346
- '</select>',
347
- '</div>',
348
- //align
349
- '<div class="ke-dialog-row">',
350
- '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
351
- lang.textAlign + ' <select id="keAlign" name="textAlign">',
352
- '<option value="">' + lang.alignDefault + '</option>',
353
- '<option value="left">' + lang.alignLeft + '</option>',
354
- '<option value="center">' + lang.alignCenter + '</option>',
355
- '<option value="right">' + lang.alignRight + '</option>',
356
- '</select> ',
357
- lang.verticalAlign + ' <select name="verticalAlign">',
358
- '<option value="">' + lang.alignDefault + '</option>',
359
- '<option value="top">' + lang.alignTop + '</option>',
360
- '<option value="middle">' + lang.alignMiddle + '</option>',
361
- '<option value="bottom">' + lang.alignBottom + '</option>',
362
- '<option value="baseline">' + lang.alignBaseline + '</option>',
363
- '</select>',
364
- '</div>',
365
- //border
366
- '<div class="ke-dialog-row">',
367
- '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
368
- lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
369
- lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
370
- '</div>',
371
- //background color
372
- '<div class="ke-dialog-row">',
373
- '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
374
- '<span class="ke-inline-block ke-input-color"></span>',
375
- '</div>',
376
- '</div>'
377
- ].join('');
378
- var picker, currentElement;
379
- function removePicker() {
380
- if (picker) {
381
- picker.remove();
382
- picker = null;
383
- currentElement = null;
384
- }
385
- }
386
- var dialog = self.createDialog({
387
- name : name,
388
- width : 500,
389
- height : 220,
390
- title : self.lang('tablecell'),
391
- body : html,
392
- beforeDrag : removePicker,
393
- beforeRemove : function() {
394
- removePicker();
395
- colorBox.unbind();
396
- },
397
- yesBtn : {
398
- name : self.lang('yes'),
399
- click : function(e) {
400
- var width = widthBox.val(),
401
- height = heightBox.val(),
402
- widthType = widthTypeBox.val(),
403
- heightType = heightTypeBox.val(),
404
- padding = paddingBox.val(),
405
- spacing = spacingBox.val(),
406
- textAlign = textAlignBox.val(),
407
- verticalAlign = verticalAlignBox.val(),
408
- border = borderBox.val(),
409
- borderColor = K(colorBox[0]).html() || '',
410
- bgColor = K(colorBox[1]).html() || '';
411
- if (!/^\d*$/.test(width)) {
412
- alert(self.lang('invalidWidth'));
413
- widthBox[0].focus();
414
- return;
415
- }
416
- if (!/^\d*$/.test(height)) {
417
- alert(self.lang('invalidHeight'));
418
- heightBox[0].focus();
419
- return;
420
- }
421
- if (!/^\d*$/.test(border)) {
422
- alert(self.lang('invalidBorder'));
423
- borderBox[0].focus();
424
- return;
425
- }
426
- cell.css({
427
- width : width !== '' ? (width + widthType) : '',
428
- height : height !== '' ? (height + heightType) : '',
429
- 'background-color' : bgColor,
430
- 'text-align' : textAlign,
431
- 'vertical-align' : verticalAlign,
432
- 'border-width' : border,
433
- 'border-style' : border !== '' ? 'solid' : '',
434
- 'border-color' : borderColor
435
- });
436
- self.hideDialog().focus();
437
- self.addBookmark();
438
- }
439
- }
440
- }),
441
- div = dialog.div,
442
- widthBox = K('[name="width"]', div).val(100),
443
- heightBox = K('[name="height"]', div),
444
- widthTypeBox = K('[name="widthType"]', div),
445
- heightTypeBox = K('[name="heightType"]', div),
446
- paddingBox = K('[name="padding"]', div).val(2),
447
- spacingBox = K('[name="spacing"]', div).val(0),
448
- textAlignBox = K('[name="textAlign"]', div),
449
- verticalAlignBox = K('[name="verticalAlign"]', div),
450
- borderBox = K('[name="border"]', div).val(1),
451
- colorBox = K('.ke-input-color', div);
452
- function setColor(box, color) {
453
- color = color.toUpperCase();
454
- box.css('background-color', color);
455
- box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
456
- box.html(color);
457
- }
458
- setColor(K(colorBox[0]), '#000000');
459
- setColor(K(colorBox[1]), '');
460
- function clickHandler(e) {
461
- removePicker();
462
- if (!picker || this !== currentElement) {
463
- var box = K(this),
464
- pos = box.pos();
465
- picker = K.colorpicker({
466
- x : pos.x,
467
- y : pos.y + box.height(),
468
- z : 811214,
469
- selectedColor : K(this).html(),
470
- colors : self.colorTable,
471
- noColor : self.lang('noColor'),
472
- click : function(color) {
473
- setColor(box, color);
474
- removePicker();
475
- }
476
- });
477
- currentElement = this;
478
- }
479
- }
480
- colorBox.click(clickHandler);
481
- // foucs and select
482
- widthBox[0].focus();
483
- widthBox[0].select();
484
- // get selected cell
485
- var cell = self.plugin.getSelectedCell();
486
- var match,
487
- cellWidth = cell[0].style.width || cell[0].width || '',
488
- cellHeight = cell[0].style.height || cell[0].height || '';
489
- if ((match = /^(\d+)((?:px|%)*)$/.exec(cellWidth))) {
490
- widthBox.val(match[1]);
491
- widthTypeBox.val(match[2]);
492
- } else {
493
- widthBox.val('');
494
- }
495
- if ((match = /^(\d+)((?:px|%)*)$/.exec(cellHeight))) {
496
- heightBox.val(match[1]);
497
- heightTypeBox.val(match[2]);
498
- }
499
- textAlignBox.val(cell[0].style.textAlign || '');
500
- verticalAlignBox.val(cell[0].style.verticalAlign || '');
501
- var border = cell[0].style.borderWidth || '';
502
- if (border) {
503
- border = parseInt(border);
504
- }
505
- borderBox.val(border);
506
- setColor(K(colorBox[0]), K.toHex(cell[0].style.borderColor || ''));
507
- setColor(K(colorBox[1]), K.toHex(cell[0].style.backgroundColor || ''));
508
- widthBox[0].focus();
509
- widthBox[0].select();
510
- },
511
- insert : function() {
512
- this.prop(true);
513
- },
514
- 'delete' : function() {
515
- var table = self.plugin.getSelectedTable();
516
- self.cmd.range.setStartBefore(table[0]).collapse(true);
517
- self.cmd.select();
518
- table.remove();
519
- self.addBookmark();
520
- },
521
- colinsert : function(offset) {
522
- var table = self.plugin.getSelectedTable()[0],
523
- row = self.plugin.getSelectedRow()[0],
524
- cell = self.plugin.getSelectedCell()[0],
525
- index = cell.cellIndex + offset;
526
- for (var i = 0, len = table.rows.length; i < len; i++) {
527
- var newRow = table.rows[i],
528
- newCell = newRow.insertCell(index);
529
- newCell.innerHTML = K.IE ? '' : '<br />';
530
- // 调整下一行的单元格index
531
- index = _getCellIndex(table, newRow, newCell);
532
- }
533
- self.cmd.range.selectNodeContents(cell).collapse(true);
534
- self.cmd.select();
535
- self.addBookmark();
536
- },
537
- colinsertleft : function() {
538
- this.colinsert(0);
539
- },
540
- colinsertright : function() {
541
- this.colinsert(1);
542
- },
543
- rowinsert : function(offset) {
544
- var table = self.plugin.getSelectedTable()[0],
545
- row = self.plugin.getSelectedRow()[0],
546
- cell = self.plugin.getSelectedCell()[0],
547
- newRow;
548
- if (offset === 1) {
549
- newRow = table.insertRow(row.rowIndex + (cell.rowSpan - 1) + offset);
550
- } else {
551
- newRow = table.insertRow(row.rowIndex);
552
- }
553
- for (var i = 0, len = row.cells.length; i < len; i++) {
554
- var newCell = newRow.insertCell(i);
555
- // copy colspan
556
- if (offset === 1 && row.cells[i].colSpan > 1) {
557
- newCell.colSpan = row.cells[i].colSpan;
558
- }
559
- newCell.innerHTML = K.IE ? '' : '<br />';
560
- }
561
- self.cmd.range.selectNodeContents(cell).collapse(true);
562
- self.cmd.select();
563
- self.addBookmark();
564
- },
565
- rowinsertabove : function() {
566
- this.rowinsert(0);
567
- },
568
- rowinsertbelow : function() {
569
- this.rowinsert(1);
570
- },
571
- rowmerge : function() {
572
- var table = self.plugin.getSelectedTable()[0],
573
- row = self.plugin.getSelectedRow()[0],
574
- cell = self.plugin.getSelectedCell()[0],
575
- rowIndex = row.rowIndex, // 当前行的index
576
- nextRowIndex = rowIndex + cell.rowSpan, // 下一行的index
577
- nextRow = table.rows[nextRowIndex]; // 下一行
578
- // 最后一行不能合并
579
- if (table.rows.length <= nextRowIndex) {
580
- return;
581
- }
582
- var cellIndex = _getCellIndex(table, row, cell); // 下一行单元格的index
583
- if (nextRow.cells.length <= cellIndex) {
584
- return;
585
- }
586
- var nextCell = nextRow.cells[cellIndex]; // 下一行单元格
587
- // 上下行的colspan不一致时不能合并
588
- if (cell.colSpan !== nextCell.colSpan) {
589
- return;
590
- }
591
- cell.rowSpan += nextCell.rowSpan;
592
- nextRow.deleteCell(cellIndex);
593
- self.cmd.range.selectNodeContents(cell).collapse(true);
594
- self.cmd.select();
595
- self.addBookmark();
596
- },
597
- colmerge : function() {
598
- var table = self.plugin.getSelectedTable()[0],
599
- row = self.plugin.getSelectedRow()[0],
600
- cell = self.plugin.getSelectedCell()[0],
601
- rowIndex = row.rowIndex, // 当前行的index
602
- cellIndex = cell.cellIndex,
603
- nextCellIndex = cellIndex + 1;
604
- // 最后一列不能合并
605
- if (row.cells.length <= nextCellIndex) {
606
- return;
607
- }
608
- var nextCell = row.cells[nextCellIndex];
609
- // 左右列的rowspan不一致时不能合并
610
- if (cell.rowSpan !== nextCell.rowSpan) {
611
- return;
612
- }
613
- cell.colSpan += nextCell.colSpan;
614
- row.deleteCell(nextCellIndex);
615
- self.cmd.range.selectNodeContents(cell).collapse(true);
616
- self.cmd.select();
617
- self.addBookmark();
618
- },
619
- rowsplit : function() {
620
- var table = self.plugin.getSelectedTable()[0],
621
- row = self.plugin.getSelectedRow()[0],
622
- cell = self.plugin.getSelectedCell()[0],
623
- rowIndex = row.rowIndex;
624
- // 不是可分割单元格
625
- if (cell.rowSpan === 1) {
626
- return;
627
- }
628
- var cellIndex = _getCellIndex(table, row, cell);
629
- for (var i = 1, len = cell.rowSpan; i < len; i++) {
630
- var newRow = table.rows[rowIndex + i],
631
- newCell = newRow.insertCell(cellIndex);
632
- if (cell.colSpan > 1) {
633
- newCell.colSpan = cell.colSpan;
634
- }
635
- newCell.innerHTML = K.IE ? '' : '<br />';
636
- // 调整下一行的单元格index
637
- cellIndex = _getCellIndex(table, newRow, newCell);
638
- }
639
- K(cell).removeAttr('rowSpan');
640
- self.cmd.range.selectNodeContents(cell).collapse(true);
641
- self.cmd.select();
642
- self.addBookmark();
643
- },
644
- colsplit : function() {
645
- var table = self.plugin.getSelectedTable()[0],
646
- row = self.plugin.getSelectedRow()[0],
647
- cell = self.plugin.getSelectedCell()[0],
648
- cellIndex = cell.cellIndex;
649
- // 不是可分割单元格
650
- if (cell.colSpan === 1) {
651
- return;
652
- }
653
- for (var i = 1, len = cell.colSpan; i < len; i++) {
654
- var newCell = row.insertCell(cellIndex + i);
655
- if (cell.rowSpan > 1) {
656
- newCell.rowSpan = cell.rowSpan;
657
- }
658
- newCell.innerHTML = K.IE ? '' : '<br />';
659
- }
660
- K(cell).removeAttr('colSpan');
661
- self.cmd.range.selectNodeContents(cell).collapse(true);
662
- self.cmd.select();
663
- self.addBookmark();
664
- },
665
- coldelete : function() {
666
- var table = self.plugin.getSelectedTable()[0],
667
- row = self.plugin.getSelectedRow()[0],
668
- cell = self.plugin.getSelectedCell()[0],
669
- index = cell.cellIndex;
670
- for (var i = 0, len = table.rows.length; i < len; i++) {
671
- var newRow = table.rows[i],
672
- newCell = newRow.cells[index];
673
- if (newCell.colSpan > 1) {
674
- newCell.colSpan -= 1;
675
- if (newCell.colSpan === 1) {
676
- K(newCell).removeAttr('colSpan');
677
- }
678
- } else {
679
- newRow.deleteCell(index);
680
- }
681
- // 跳过不需要删除的行
682
- if (newCell.rowSpan > 1) {
683
- i += newCell.rowSpan - 1;
684
- }
685
- }
686
- if (row.cells.length === 0) {
687
- self.cmd.range.setStartBefore(table).collapse(true);
688
- self.cmd.select();
689
- K(table).remove();
690
- } else {
691
- self.cmd.selection(true);
692
- }
693
- self.addBookmark();
694
- },
695
- rowdelete : function() {
696
- var table = self.plugin.getSelectedTable()[0],
697
- row = self.plugin.getSelectedRow()[0],
698
- cell = self.plugin.getSelectedCell()[0],
699
- rowIndex = row.rowIndex;
700
- // 从下到上删除
701
- for (var i = cell.rowSpan - 1; i >= 0; i--) {
702
- table.deleteRow(rowIndex + i);
703
- }
704
- if (table.rows.length === 0) {
705
- self.cmd.range.setStartBefore(table).collapse(true);
706
- self.cmd.select();
707
- K(table).remove();
708
- } else {
709
- self.cmd.selection(true);
710
- }
711
- self.addBookmark();
712
- }
713
- };
714
- self.clickToolbar(name, self.plugin.table.prop);
715
- });
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ KindEditor.plugin('table', function(K) {
11
+ var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
12
+ // 取得下一行cell的index
13
+ function _getCellIndex(table, row, cell) {
14
+ var rowSpanCount = 0;
15
+ for (var i = 0, len = row.cells.length; i < len; i++) {
16
+ if (row.cells[i] == cell) {
17
+ break;
18
+ }
19
+ rowSpanCount += row.cells[i].rowSpan - 1;
20
+ }
21
+ return cell.cellIndex - rowSpanCount;
22
+ }
23
+ self.plugin.table = {
24
+ //insert or modify table
25
+ prop : function(isInsert) {
26
+ var html = [
27
+ '<div style="padding:10px 20px;">',
28
+ //rows, cols
29
+ '<div class="ke-dialog-row">',
30
+ '<label for="keRows" style="width:90px;">' + lang.cells + '</label>',
31
+ lang.rows + ' <input type="text" id="keRows" class="ke-input-text ke-input-number" name="rows" value="" maxlength="4" /> &nbsp; ',
32
+ lang.cols + ' <input type="text" class="ke-input-text ke-input-number" name="cols" value="" maxlength="4" />',
33
+ '</div>',
34
+ //width, height
35
+ '<div class="ke-dialog-row">',
36
+ '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
37
+ lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
38
+ '<select name="widthType">',
39
+ '<option value="%">' + lang.percent + '</option>',
40
+ '<option value="px">' + lang.px + '</option>',
41
+ '</select> &nbsp; ',
42
+ lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
43
+ '<select name="heightType">',
44
+ '<option value="%">' + lang.percent + '</option>',
45
+ '<option value="px">' + lang.px + '</option>',
46
+ '</select>',
47
+ '</div>',
48
+ //space, padding
49
+ '<div class="ke-dialog-row">',
50
+ '<label for="kePadding" style="width:90px;">' + lang.space + '</label>',
51
+ lang.padding + ' <input type="text" id="kePadding" class="ke-input-text ke-input-number" name="padding" value="" maxlength="4" /> &nbsp; ',
52
+ lang.spacing + ' <input type="text" class="ke-input-text ke-input-number" name="spacing" value="" maxlength="4" />',
53
+ '</div>',
54
+ //align
55
+ '<div class="ke-dialog-row">',
56
+ '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
57
+ '<select id="keAlign" name="align">',
58
+ '<option value="">' + lang.alignDefault + '</option>',
59
+ '<option value="left">' + lang.alignLeft + '</option>',
60
+ '<option value="center">' + lang.alignCenter + '</option>',
61
+ '<option value="right">' + lang.alignRight + '</option>',
62
+ '</select>',
63
+ '</div>',
64
+ //border
65
+ '<div class="ke-dialog-row">',
66
+ '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
67
+ lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
68
+ lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
69
+ '</div>',
70
+ //background color
71
+ '<div class="ke-dialog-row">',
72
+ '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
73
+ '<span class="ke-inline-block ke-input-color"></span>',
74
+ '</div>',
75
+ '</div>'
76
+ ].join('');
77
+ var picker, currentElement;
78
+ function removePicker() {
79
+ if (picker) {
80
+ picker.remove();
81
+ picker = null;
82
+ currentElement = null;
83
+ }
84
+ }
85
+ var dialog = self.createDialog({
86
+ name : name,
87
+ width : 500,
88
+ height : 300,
89
+ title : self.lang(name),
90
+ body : html,
91
+ beforeDrag : removePicker,
92
+ beforeRemove : function() {
93
+ removePicker();
94
+ colorBox.unbind();
95
+ },
96
+ yesBtn : {
97
+ name : self.lang('yes'),
98
+ click : function(e) {
99
+ var rows = rowsBox.val(),
100
+ cols = colsBox.val(),
101
+ width = widthBox.val(),
102
+ height = heightBox.val(),
103
+ widthType = widthTypeBox.val(),
104
+ heightType = heightTypeBox.val(),
105
+ padding = paddingBox.val(),
106
+ spacing = spacingBox.val(),
107
+ align = alignBox.val(),
108
+ border = borderBox.val(),
109
+ borderColor = K(colorBox[0]).html() || '',
110
+ bgColor = K(colorBox[1]).html() || '';
111
+ if (rows == 0 || !/^\d+$/.test(rows)) {
112
+ alert(self.lang('invalidRows'));
113
+ rowsBox[0].focus();
114
+ return;
115
+ }
116
+ if (cols == 0 || !/^\d+$/.test(cols)) {
117
+ alert(self.lang('invalidRows'));
118
+ colsBox[0].focus();
119
+ return;
120
+ }
121
+ if (!/^\d*$/.test(width)) {
122
+ alert(self.lang('invalidWidth'));
123
+ widthBox[0].focus();
124
+ return;
125
+ }
126
+ if (!/^\d*$/.test(height)) {
127
+ alert(self.lang('invalidHeight'));
128
+ heightBox[0].focus();
129
+ return;
130
+ }
131
+ if (!/^\d*$/.test(padding)) {
132
+ alert(self.lang('invalidPadding'));
133
+ paddingBox[0].focus();
134
+ return;
135
+ }
136
+ if (!/^\d*$/.test(spacing)) {
137
+ alert(self.lang('invalidSpacing'));
138
+ spacingBox[0].focus();
139
+ return;
140
+ }
141
+ if (!/^\d*$/.test(border)) {
142
+ alert(self.lang('invalidBorder'));
143
+ borderBox[0].focus();
144
+ return;
145
+ }
146
+ //modify table
147
+ if (table) {
148
+ if (width !== '') {
149
+ table.width(width + widthType);
150
+ } else {
151
+ table.css('width', '');
152
+ }
153
+ if (table[0].width !== undefined) {
154
+ table.removeAttr('width');
155
+ }
156
+ if (height !== '') {
157
+ table.height(height + heightType);
158
+ } else {
159
+ table.css('height', '');
160
+ }
161
+ if (table[0].height !== undefined) {
162
+ table.removeAttr('height');
163
+ }
164
+ table.css('background-color', bgColor);
165
+ if (table[0].bgColor !== undefined) {
166
+ table.removeAttr('bgColor');
167
+ }
168
+ if (padding !== '') {
169
+ table[0].cellPadding = padding;
170
+ } else {
171
+ table.removeAttr('cellPadding');
172
+ }
173
+ if (spacing !== '') {
174
+ table[0].cellSpacing = spacing;
175
+ } else {
176
+ table.removeAttr('cellSpacing');
177
+ }
178
+ if (align !== '') {
179
+ table[0].align = align;
180
+ } else {
181
+ table.removeAttr('align');
182
+ }
183
+ if (border !== '') {
184
+ table.attr('border', border);
185
+ } else {
186
+ table.removeAttr('border');
187
+ }
188
+ if (border === '' || border === '0') {
189
+ table.addClass(zeroborder);
190
+ } else {
191
+ table.removeClass(zeroborder);
192
+ }
193
+ if (borderColor !== '') {
194
+ table.attr('borderColor', borderColor);
195
+ } else {
196
+ table.removeAttr('borderColor');
197
+ }
198
+ self.hideDialog().focus();
199
+ return;
200
+ }
201
+ //insert new table
202
+ var style = '';
203
+ if (width !== '') {
204
+ style += 'width:' + width + widthType + ';';
205
+ }
206
+ if (height !== '') {
207
+ style += 'height:' + height + heightType + ';';
208
+ }
209
+ if (bgColor !== '') {
210
+ style += 'background-color:' + bgColor + ';';
211
+ }
212
+ var html = '<table';
213
+ if (style !== '') {
214
+ html += ' style="' + style + '"';
215
+ }
216
+ if (padding !== '') {
217
+ html += ' cellpadding="' + padding + '"';
218
+ }
219
+ if (spacing !== '') {
220
+ html += ' cellspacing="' + spacing + '"';
221
+ }
222
+ if (align !== '') {
223
+ html += ' align="' + align + '"';
224
+ }
225
+ if (border !== '') {
226
+ html += ' border="' + border + '"';
227
+ }
228
+ if (border === '' || border === '0') {
229
+ html += ' class="' + zeroborder + '"';
230
+ }
231
+ if (borderColor !== '') {
232
+ html += ' bordercolor="' + borderColor + '"';
233
+ }
234
+ html += '>';
235
+ for (var i = 0; i < rows; i++) {
236
+ html += '<tr>';
237
+ for (var j = 0; j < cols; j++) {
238
+ html += '<td>' + (K.IE ? '&nbsp;' : '<br />') + '</td>';
239
+ }
240
+ html += '</tr>';
241
+ }
242
+ html += '</table>';
243
+ if (!K.IE) {
244
+ html += '<br />';
245
+ }
246
+ self.insertHtml(html);
247
+ self.select().hideDialog().focus();
248
+ self.addBookmark();
249
+ }
250
+ }
251
+ }),
252
+ div = dialog.div,
253
+ rowsBox = K('[name="rows"]', div).val(3),
254
+ colsBox = K('[name="cols"]', div).val(2),
255
+ widthBox = K('[name="width"]', div).val(100),
256
+ heightBox = K('[name="height"]', div),
257
+ widthTypeBox = K('[name="widthType"]', div),
258
+ heightTypeBox = K('[name="heightType"]', div),
259
+ paddingBox = K('[name="padding"]', div).val(2),
260
+ spacingBox = K('[name="spacing"]', div).val(0),
261
+ alignBox = K('[name="align"]', div),
262
+ borderBox = K('[name="border"]', div).val(1),
263
+ colorBox = K('.ke-input-color', div);
264
+ function setColor(box, color) {
265
+ color = color.toUpperCase();
266
+ box.css('background-color', color);
267
+ box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
268
+ box.html(color);
269
+ }
270
+ setColor(K(colorBox[0]), '#000000');
271
+ setColor(K(colorBox[1]), '');
272
+ function clickHandler(e) {
273
+ removePicker();
274
+ if (!picker || this !== currentElement) {
275
+ var box = K(this),
276
+ pos = box.pos();
277
+ picker = K.colorpicker({
278
+ x : pos.x,
279
+ y : pos.y + box.height(),
280
+ z : 811214,
281
+ selectedColor : K(this).html(),
282
+ colors : self.colorTable,
283
+ noColor : self.lang('noColor'),
284
+ click : function(color) {
285
+ setColor(box, color);
286
+ removePicker();
287
+ }
288
+ });
289
+ currentElement = this;
290
+ }
291
+ }
292
+ colorBox.click(clickHandler);
293
+ // foucs and select
294
+ rowsBox[0].focus();
295
+ rowsBox[0].select();
296
+ var table;
297
+ if (isInsert) {
298
+ return;
299
+ }
300
+ //get selected table node
301
+ table = self.plugin.getSelectedTable();
302
+ if (table) {
303
+ rowsBox.val(table[0].rows.length);
304
+ colsBox.val(table[0].rows.length > 0 ? table[0].rows[0].cells.length : 0);
305
+ rowsBox.attr('disabled', true);
306
+ colsBox.attr('disabled', true);
307
+ var match,
308
+ tableWidth = table[0].style.width || table[0].width,
309
+ tableHeight = table[0].style.height || table[0].height;
310
+ if (tableWidth !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableWidth))) {
311
+ widthBox.val(match[1]);
312
+ widthTypeBox.val(match[2]);
313
+ } else {
314
+ widthBox.val('');
315
+ }
316
+ if (tableHeight !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableHeight))) {
317
+ heightBox.val(match[1]);
318
+ heightTypeBox.val(match[2]);
319
+ }
320
+ paddingBox.val(table[0].cellPadding || '');
321
+ spacingBox.val(table[0].cellSpacing || '');
322
+ alignBox.val(table[0].align || '');
323
+ borderBox.val(table[0].border === undefined ? '' : table[0].border);
324
+ setColor(K(colorBox[0]), K.toHex(table.attr('borderColor') || ''));
325
+ setColor(K(colorBox[1]), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
326
+ widthBox[0].focus();
327
+ widthBox[0].select();
328
+ }
329
+ },
330
+ //modify cell
331
+ cellprop : function() {
332
+ var html = [
333
+ '<div style="padding:10px 20px;">',
334
+ //width, height
335
+ '<div class="ke-dialog-row">',
336
+ '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
337
+ lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
338
+ '<select name="widthType">',
339
+ '<option value="%">' + lang.percent + '</option>',
340
+ '<option value="px">' + lang.px + '</option>',
341
+ '</select> &nbsp; ',
342
+ lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
343
+ '<select name="heightType">',
344
+ '<option value="%">' + lang.percent + '</option>',
345
+ '<option value="px">' + lang.px + '</option>',
346
+ '</select>',
347
+ '</div>',
348
+ //align
349
+ '<div class="ke-dialog-row">',
350
+ '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
351
+ lang.textAlign + ' <select id="keAlign" name="textAlign">',
352
+ '<option value="">' + lang.alignDefault + '</option>',
353
+ '<option value="left">' + lang.alignLeft + '</option>',
354
+ '<option value="center">' + lang.alignCenter + '</option>',
355
+ '<option value="right">' + lang.alignRight + '</option>',
356
+ '</select> ',
357
+ lang.verticalAlign + ' <select name="verticalAlign">',
358
+ '<option value="">' + lang.alignDefault + '</option>',
359
+ '<option value="top">' + lang.alignTop + '</option>',
360
+ '<option value="middle">' + lang.alignMiddle + '</option>',
361
+ '<option value="bottom">' + lang.alignBottom + '</option>',
362
+ '<option value="baseline">' + lang.alignBaseline + '</option>',
363
+ '</select>',
364
+ '</div>',
365
+ //border
366
+ '<div class="ke-dialog-row">',
367
+ '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
368
+ lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
369
+ lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
370
+ '</div>',
371
+ //background color
372
+ '<div class="ke-dialog-row">',
373
+ '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
374
+ '<span class="ke-inline-block ke-input-color"></span>',
375
+ '</div>',
376
+ '</div>'
377
+ ].join('');
378
+ var picker, currentElement;
379
+ function removePicker() {
380
+ if (picker) {
381
+ picker.remove();
382
+ picker = null;
383
+ currentElement = null;
384
+ }
385
+ }
386
+ var dialog = self.createDialog({
387
+ name : name,
388
+ width : 500,
389
+ height : 220,
390
+ title : self.lang('tablecell'),
391
+ body : html,
392
+ beforeDrag : removePicker,
393
+ beforeRemove : function() {
394
+ removePicker();
395
+ colorBox.unbind();
396
+ },
397
+ yesBtn : {
398
+ name : self.lang('yes'),
399
+ click : function(e) {
400
+ var width = widthBox.val(),
401
+ height = heightBox.val(),
402
+ widthType = widthTypeBox.val(),
403
+ heightType = heightTypeBox.val(),
404
+ padding = paddingBox.val(),
405
+ spacing = spacingBox.val(),
406
+ textAlign = textAlignBox.val(),
407
+ verticalAlign = verticalAlignBox.val(),
408
+ border = borderBox.val(),
409
+ borderColor = K(colorBox[0]).html() || '',
410
+ bgColor = K(colorBox[1]).html() || '';
411
+ if (!/^\d*$/.test(width)) {
412
+ alert(self.lang('invalidWidth'));
413
+ widthBox[0].focus();
414
+ return;
415
+ }
416
+ if (!/^\d*$/.test(height)) {
417
+ alert(self.lang('invalidHeight'));
418
+ heightBox[0].focus();
419
+ return;
420
+ }
421
+ if (!/^\d*$/.test(border)) {
422
+ alert(self.lang('invalidBorder'));
423
+ borderBox[0].focus();
424
+ return;
425
+ }
426
+ cell.css({
427
+ width : width !== '' ? (width + widthType) : '',
428
+ height : height !== '' ? (height + heightType) : '',
429
+ 'background-color' : bgColor,
430
+ 'text-align' : textAlign,
431
+ 'vertical-align' : verticalAlign,
432
+ 'border-width' : border,
433
+ 'border-style' : border !== '' ? 'solid' : '',
434
+ 'border-color' : borderColor
435
+ });
436
+ self.hideDialog().focus();
437
+ self.addBookmark();
438
+ }
439
+ }
440
+ }),
441
+ div = dialog.div,
442
+ widthBox = K('[name="width"]', div).val(100),
443
+ heightBox = K('[name="height"]', div),
444
+ widthTypeBox = K('[name="widthType"]', div),
445
+ heightTypeBox = K('[name="heightType"]', div),
446
+ paddingBox = K('[name="padding"]', div).val(2),
447
+ spacingBox = K('[name="spacing"]', div).val(0),
448
+ textAlignBox = K('[name="textAlign"]', div),
449
+ verticalAlignBox = K('[name="verticalAlign"]', div),
450
+ borderBox = K('[name="border"]', div).val(1),
451
+ colorBox = K('.ke-input-color', div);
452
+ function setColor(box, color) {
453
+ color = color.toUpperCase();
454
+ box.css('background-color', color);
455
+ box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
456
+ box.html(color);
457
+ }
458
+ setColor(K(colorBox[0]), '#000000');
459
+ setColor(K(colorBox[1]), '');
460
+ function clickHandler(e) {
461
+ removePicker();
462
+ if (!picker || this !== currentElement) {
463
+ var box = K(this),
464
+ pos = box.pos();
465
+ picker = K.colorpicker({
466
+ x : pos.x,
467
+ y : pos.y + box.height(),
468
+ z : 811214,
469
+ selectedColor : K(this).html(),
470
+ colors : self.colorTable,
471
+ noColor : self.lang('noColor'),
472
+ click : function(color) {
473
+ setColor(box, color);
474
+ removePicker();
475
+ }
476
+ });
477
+ currentElement = this;
478
+ }
479
+ }
480
+ colorBox.click(clickHandler);
481
+ // foucs and select
482
+ widthBox[0].focus();
483
+ widthBox[0].select();
484
+ // get selected cell
485
+ var cell = self.plugin.getSelectedCell();
486
+ var match,
487
+ cellWidth = cell[0].style.width || cell[0].width || '',
488
+ cellHeight = cell[0].style.height || cell[0].height || '';
489
+ if ((match = /^(\d+)((?:px|%)*)$/.exec(cellWidth))) {
490
+ widthBox.val(match[1]);
491
+ widthTypeBox.val(match[2]);
492
+ } else {
493
+ widthBox.val('');
494
+ }
495
+ if ((match = /^(\d+)((?:px|%)*)$/.exec(cellHeight))) {
496
+ heightBox.val(match[1]);
497
+ heightTypeBox.val(match[2]);
498
+ }
499
+ textAlignBox.val(cell[0].style.textAlign || '');
500
+ verticalAlignBox.val(cell[0].style.verticalAlign || '');
501
+ var border = cell[0].style.borderWidth || '';
502
+ if (border) {
503
+ border = parseInt(border);
504
+ }
505
+ borderBox.val(border);
506
+ setColor(K(colorBox[0]), K.toHex(cell[0].style.borderColor || ''));
507
+ setColor(K(colorBox[1]), K.toHex(cell[0].style.backgroundColor || ''));
508
+ widthBox[0].focus();
509
+ widthBox[0].select();
510
+ },
511
+ insert : function() {
512
+ this.prop(true);
513
+ },
514
+ 'delete' : function() {
515
+ var table = self.plugin.getSelectedTable();
516
+ self.cmd.range.setStartBefore(table[0]).collapse(true);
517
+ self.cmd.select();
518
+ table.remove();
519
+ self.addBookmark();
520
+ },
521
+ colinsert : function(offset) {
522
+ var table = self.plugin.getSelectedTable()[0],
523
+ row = self.plugin.getSelectedRow()[0],
524
+ cell = self.plugin.getSelectedCell()[0],
525
+ index = cell.cellIndex + offset;
526
+ for (var i = 0, len = table.rows.length; i < len; i++) {
527
+ var newRow = table.rows[i],
528
+ newCell = newRow.insertCell(index);
529
+ newCell.innerHTML = K.IE ? '' : '<br />';
530
+ // 调整下一行的单元格index
531
+ index = _getCellIndex(table, newRow, newCell);
532
+ }
533
+ self.cmd.range.selectNodeContents(cell).collapse(true);
534
+ self.cmd.select();
535
+ self.addBookmark();
536
+ },
537
+ colinsertleft : function() {
538
+ this.colinsert(0);
539
+ },
540
+ colinsertright : function() {
541
+ this.colinsert(1);
542
+ },
543
+ rowinsert : function(offset) {
544
+ var table = self.plugin.getSelectedTable()[0],
545
+ row = self.plugin.getSelectedRow()[0],
546
+ cell = self.plugin.getSelectedCell()[0],
547
+ newRow;
548
+ if (offset === 1) {
549
+ newRow = table.insertRow(row.rowIndex + (cell.rowSpan - 1) + offset);
550
+ } else {
551
+ newRow = table.insertRow(row.rowIndex);
552
+ }
553
+ for (var i = 0, len = row.cells.length; i < len; i++) {
554
+ var newCell = newRow.insertCell(i);
555
+ // copy colspan
556
+ if (offset === 1 && row.cells[i].colSpan > 1) {
557
+ newCell.colSpan = row.cells[i].colSpan;
558
+ }
559
+ newCell.innerHTML = K.IE ? '' : '<br />';
560
+ }
561
+ self.cmd.range.selectNodeContents(cell).collapse(true);
562
+ self.cmd.select();
563
+ self.addBookmark();
564
+ },
565
+ rowinsertabove : function() {
566
+ this.rowinsert(0);
567
+ },
568
+ rowinsertbelow : function() {
569
+ this.rowinsert(1);
570
+ },
571
+ rowmerge : function() {
572
+ var table = self.plugin.getSelectedTable()[0],
573
+ row = self.plugin.getSelectedRow()[0],
574
+ cell = self.plugin.getSelectedCell()[0],
575
+ rowIndex = row.rowIndex, // 当前行的index
576
+ nextRowIndex = rowIndex + cell.rowSpan, // 下一行的index
577
+ nextRow = table.rows[nextRowIndex]; // 下一行
578
+ // 最后一行不能合并
579
+ if (table.rows.length <= nextRowIndex) {
580
+ return;
581
+ }
582
+ var cellIndex = _getCellIndex(table, row, cell); // 下一行单元格的index
583
+ if (nextRow.cells.length <= cellIndex) {
584
+ return;
585
+ }
586
+ var nextCell = nextRow.cells[cellIndex]; // 下一行单元格
587
+ // 上下行的colspan不一致时不能合并
588
+ if (cell.colSpan !== nextCell.colSpan) {
589
+ return;
590
+ }
591
+ cell.rowSpan += nextCell.rowSpan;
592
+ nextRow.deleteCell(cellIndex);
593
+ self.cmd.range.selectNodeContents(cell).collapse(true);
594
+ self.cmd.select();
595
+ self.addBookmark();
596
+ },
597
+ colmerge : function() {
598
+ var table = self.plugin.getSelectedTable()[0],
599
+ row = self.plugin.getSelectedRow()[0],
600
+ cell = self.plugin.getSelectedCell()[0],
601
+ rowIndex = row.rowIndex, // 当前行的index
602
+ cellIndex = cell.cellIndex,
603
+ nextCellIndex = cellIndex + 1;
604
+ // 最后一列不能合并
605
+ if (row.cells.length <= nextCellIndex) {
606
+ return;
607
+ }
608
+ var nextCell = row.cells[nextCellIndex];
609
+ // 左右列的rowspan不一致时不能合并
610
+ if (cell.rowSpan !== nextCell.rowSpan) {
611
+ return;
612
+ }
613
+ cell.colSpan += nextCell.colSpan;
614
+ row.deleteCell(nextCellIndex);
615
+ self.cmd.range.selectNodeContents(cell).collapse(true);
616
+ self.cmd.select();
617
+ self.addBookmark();
618
+ },
619
+ rowsplit : function() {
620
+ var table = self.plugin.getSelectedTable()[0],
621
+ row = self.plugin.getSelectedRow()[0],
622
+ cell = self.plugin.getSelectedCell()[0],
623
+ rowIndex = row.rowIndex;
624
+ // 不是可分割单元格
625
+ if (cell.rowSpan === 1) {
626
+ return;
627
+ }
628
+ var cellIndex = _getCellIndex(table, row, cell);
629
+ for (var i = 1, len = cell.rowSpan; i < len; i++) {
630
+ var newRow = table.rows[rowIndex + i],
631
+ newCell = newRow.insertCell(cellIndex);
632
+ if (cell.colSpan > 1) {
633
+ newCell.colSpan = cell.colSpan;
634
+ }
635
+ newCell.innerHTML = K.IE ? '' : '<br />';
636
+ // 调整下一行的单元格index
637
+ cellIndex = _getCellIndex(table, newRow, newCell);
638
+ }
639
+ K(cell).removeAttr('rowSpan');
640
+ self.cmd.range.selectNodeContents(cell).collapse(true);
641
+ self.cmd.select();
642
+ self.addBookmark();
643
+ },
644
+ colsplit : function() {
645
+ var table = self.plugin.getSelectedTable()[0],
646
+ row = self.plugin.getSelectedRow()[0],
647
+ cell = self.plugin.getSelectedCell()[0],
648
+ cellIndex = cell.cellIndex;
649
+ // 不是可分割单元格
650
+ if (cell.colSpan === 1) {
651
+ return;
652
+ }
653
+ for (var i = 1, len = cell.colSpan; i < len; i++) {
654
+ var newCell = row.insertCell(cellIndex + i);
655
+ if (cell.rowSpan > 1) {
656
+ newCell.rowSpan = cell.rowSpan;
657
+ }
658
+ newCell.innerHTML = K.IE ? '' : '<br />';
659
+ }
660
+ K(cell).removeAttr('colSpan');
661
+ self.cmd.range.selectNodeContents(cell).collapse(true);
662
+ self.cmd.select();
663
+ self.addBookmark();
664
+ },
665
+ coldelete : function() {
666
+ var table = self.plugin.getSelectedTable()[0],
667
+ row = self.plugin.getSelectedRow()[0],
668
+ cell = self.plugin.getSelectedCell()[0],
669
+ index = cell.cellIndex;
670
+ for (var i = 0, len = table.rows.length; i < len; i++) {
671
+ var newRow = table.rows[i],
672
+ newCell = newRow.cells[index];
673
+ if (newCell.colSpan > 1) {
674
+ newCell.colSpan -= 1;
675
+ if (newCell.colSpan === 1) {
676
+ K(newCell).removeAttr('colSpan');
677
+ }
678
+ } else {
679
+ newRow.deleteCell(index);
680
+ }
681
+ // 跳过不需要删除的行
682
+ if (newCell.rowSpan > 1) {
683
+ i += newCell.rowSpan - 1;
684
+ }
685
+ }
686
+ if (row.cells.length === 0) {
687
+ self.cmd.range.setStartBefore(table).collapse(true);
688
+ self.cmd.select();
689
+ K(table).remove();
690
+ } else {
691
+ self.cmd.selection(true);
692
+ }
693
+ self.addBookmark();
694
+ },
695
+ rowdelete : function() {
696
+ var table = self.plugin.getSelectedTable()[0],
697
+ row = self.plugin.getSelectedRow()[0],
698
+ cell = self.plugin.getSelectedCell()[0],
699
+ rowIndex = row.rowIndex;
700
+ // 从下到上删除
701
+ for (var i = cell.rowSpan - 1; i >= 0; i--) {
702
+ table.deleteRow(rowIndex + i);
703
+ }
704
+ if (table.rows.length === 0) {
705
+ self.cmd.range.setStartBefore(table).collapse(true);
706
+ self.cmd.select();
707
+ K(table).remove();
708
+ } else {
709
+ self.cmd.selection(true);
710
+ }
711
+ self.addBookmark();
712
+ }
713
+ };
714
+ self.clickToolbar(name, self.plugin.table.prop);
715
+ });