suneditor 2.46.1 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/.eslintignore +7 -0
  2. package/.eslintrc.json +64 -0
  3. package/CONTRIBUTING.md +36 -0
  4. package/LICENSE.txt +1 -1
  5. package/README.md +174 -805
  6. package/dist/suneditor.min.css +1 -0
  7. package/dist/suneditor.min.js +1 -2
  8. package/package.json +96 -70
  9. package/src/assets/icons/_default.js +194 -0
  10. package/src/assets/suneditor-content.css +646 -0
  11. package/src/assets/suneditor.css +3378 -0
  12. package/src/core/base/eventHandlers/handler_toolbar.js +114 -0
  13. package/src/core/base/eventHandlers/handler_ww_clipboard.js +31 -0
  14. package/src/core/base/eventHandlers/handler_ww_dragDrop.js +69 -0
  15. package/src/core/base/eventHandlers/handler_ww_key_input.js +975 -0
  16. package/src/core/base/eventHandlers/handler_ww_mouse.js +118 -0
  17. package/src/core/base/eventManager.js +1115 -0
  18. package/src/core/base/events.js +320 -0
  19. package/src/core/base/history.js +301 -0
  20. package/src/core/class/char.js +146 -0
  21. package/src/core/class/component.js +627 -0
  22. package/src/core/class/format.js +3255 -0
  23. package/src/core/class/html.js +1621 -0
  24. package/src/core/class/menu.js +260 -0
  25. package/src/core/class/nodeTransform.js +379 -0
  26. package/src/core/class/notice.js +42 -0
  27. package/src/core/class/offset.js +578 -0
  28. package/src/core/class/selection.js +508 -0
  29. package/src/core/class/shortcuts.js +38 -0
  30. package/src/core/class/toolbar.js +440 -0
  31. package/src/core/class/viewer.js +646 -0
  32. package/src/core/editor.js +1593 -0
  33. package/src/core/section/actives.js +107 -0
  34. package/src/core/section/constructor.js +1237 -0
  35. package/src/core/section/context.js +97 -0
  36. package/src/editorInjector/_classes.js +22 -0
  37. package/src/editorInjector/_core.js +28 -0
  38. package/src/editorInjector/index.js +13 -0
  39. package/src/helper/converter.js +313 -0
  40. package/src/helper/domUtils.js +1177 -0
  41. package/src/helper/env.js +250 -0
  42. package/src/helper/index.js +19 -0
  43. package/src/helper/numbers.js +68 -0
  44. package/src/helper/unicode.js +43 -0
  45. package/src/langs/ckb.js +161 -0
  46. package/src/langs/cs.js +161 -0
  47. package/src/langs/da.js +161 -0
  48. package/src/langs/de.js +162 -0
  49. package/src/langs/en.js +199 -0
  50. package/src/langs/es.js +162 -0
  51. package/src/langs/fa.js +159 -0
  52. package/src/langs/fr.js +161 -0
  53. package/src/langs/he.js +162 -0
  54. package/src/{lang → langs}/index.js +0 -2
  55. package/src/langs/it.js +162 -0
  56. package/src/langs/ja.js +162 -0
  57. package/src/langs/ko.js +162 -0
  58. package/src/langs/lv.js +162 -0
  59. package/src/langs/nl.js +162 -0
  60. package/src/langs/pl.js +162 -0
  61. package/src/langs/pt_br.js +162 -0
  62. package/src/langs/ro.js +162 -0
  63. package/src/langs/ru.js +162 -0
  64. package/src/langs/se.js +162 -0
  65. package/src/langs/tr.js +159 -0
  66. package/src/langs/ua.js +162 -0
  67. package/src/langs/ur.js +162 -0
  68. package/src/langs/zh_cn.js +162 -0
  69. package/src/modules/ApiManager.js +168 -0
  70. package/src/modules/ColorPicker.js +302 -0
  71. package/src/modules/Controller.js +315 -0
  72. package/src/modules/Figure.js +1160 -0
  73. package/src/modules/FileBrowser.js +271 -0
  74. package/src/modules/FileManager.js +290 -0
  75. package/src/modules/HueSlider.js +513 -0
  76. package/src/modules/Modal.js +177 -0
  77. package/src/modules/ModalAnchorEditor.js +494 -0
  78. package/src/modules/SelectMenu.js +447 -0
  79. package/src/modules/_DragHandle.js +16 -0
  80. package/src/modules/index.js +14 -0
  81. package/src/plugins/command/blockquote.js +47 -47
  82. package/src/plugins/command/exportPdf.js +168 -0
  83. package/src/plugins/command/fileUpload.js +389 -0
  84. package/src/plugins/command/list_bulleted.js +112 -0
  85. package/src/plugins/command/list_numbered.js +115 -0
  86. package/src/plugins/dropdown/align.js +143 -0
  87. package/src/plugins/dropdown/backgroundColor.js +73 -0
  88. package/src/plugins/dropdown/font.js +113 -0
  89. package/src/plugins/dropdown/fontColor.js +73 -0
  90. package/src/plugins/dropdown/formatBlock.js +141 -0
  91. package/src/plugins/dropdown/hr.js +111 -0
  92. package/src/plugins/dropdown/layout.js +72 -0
  93. package/src/plugins/dropdown/lineHeight.js +114 -0
  94. package/src/plugins/dropdown/list.js +107 -0
  95. package/src/plugins/dropdown/paragraphStyle.js +117 -0
  96. package/src/plugins/dropdown/table.js +2810 -0
  97. package/src/plugins/dropdown/template.js +71 -0
  98. package/src/plugins/dropdown/textStyle.js +137 -0
  99. package/src/plugins/field/mention.js +172 -0
  100. package/src/plugins/fileBrowser/imageGallery.js +76 -59
  101. package/src/plugins/index.js +86 -24
  102. package/src/plugins/input/fontSize.js +357 -0
  103. package/src/plugins/modal/audio.js +510 -0
  104. package/src/plugins/modal/image.js +1062 -0
  105. package/src/plugins/modal/link.js +211 -0
  106. package/src/plugins/modal/math.js +347 -0
  107. package/src/plugins/modal/video.js +870 -0
  108. package/src/suneditor.js +62 -67
  109. package/src/themes/test.css +61 -0
  110. package/typings/CommandPlugin.d.ts +8 -0
  111. package/typings/DialogPlugin.d.ts +20 -0
  112. package/typings/FileBrowserPlugin.d.ts +30 -0
  113. package/typings/Lang.d.ts +124 -0
  114. package/typings/Module.d.ts +15 -0
  115. package/typings/Plugin.d.ts +42 -0
  116. package/typings/SubmenuPlugin.d.ts +8 -0
  117. package/typings/_classes.d.ts +17 -0
  118. package/typings/_colorPicker.d.ts +60 -0
  119. package/typings/_core.d.ts +55 -0
  120. package/typings/align.d.ts +5 -0
  121. package/{src/plugins/dialog → typings}/audio.d.ts +1 -1
  122. package/typings/backgroundColor.d.ts +5 -0
  123. package/{src/plugins/command → typings}/blockquote.d.ts +1 -1
  124. package/typings/char.d.ts +39 -0
  125. package/typings/component.d.ts +38 -0
  126. package/typings/context.d.ts +39 -0
  127. package/typings/converter.d.ts +33 -0
  128. package/typings/dialog.d.ts +28 -0
  129. package/typings/domUtils.d.ts +361 -0
  130. package/typings/editor.d.ts +7 -0
  131. package/typings/editor.ts +542 -0
  132. package/typings/env.d.ts +70 -0
  133. package/typings/eventManager.d.ts +37 -0
  134. package/typings/events.d.ts +262 -0
  135. package/typings/fileBrowser.d.ts +42 -0
  136. package/typings/fileManager.d.ts +67 -0
  137. package/typings/font.d.ts +5 -0
  138. package/typings/fontColor.d.ts +5 -0
  139. package/typings/fontSize.d.ts +5 -0
  140. package/typings/format.d.ts +191 -0
  141. package/typings/formatBlock.d.ts +5 -0
  142. package/typings/history.d.ts +48 -0
  143. package/typings/horizontalRule.d.ts +5 -0
  144. package/{src/plugins/dialog → typings}/image.d.ts +1 -1
  145. package/{src/plugins/fileBrowser → typings}/imageGallery.d.ts +1 -1
  146. package/typings/index.d.ts +21 -0
  147. package/{src/plugins/modules/index.d.ts → typings/index.modules.d.ts} +3 -3
  148. package/typings/index.plugins.d.ts +58 -0
  149. package/typings/lineHeight.d.ts +5 -0
  150. package/{src/plugins/dialog → typings}/link.d.ts +1 -1
  151. package/typings/list.d.ts +5 -0
  152. package/{src/plugins/dialog → typings}/math.d.ts +1 -1
  153. package/typings/mediaContainer.d.ts +25 -0
  154. package/typings/node.d.ts +57 -0
  155. package/typings/notice.d.ts +16 -0
  156. package/typings/numbers.d.ts +29 -0
  157. package/typings/offset.d.ts +24 -0
  158. package/typings/options.d.ts +589 -0
  159. package/typings/paragraphStyle.d.ts +5 -0
  160. package/typings/resizing.d.ts +141 -0
  161. package/typings/selection.d.ts +94 -0
  162. package/typings/shortcuts.d.ts +13 -0
  163. package/typings/suneditor.d.ts +9 -0
  164. package/typings/table.d.ts +5 -0
  165. package/typings/template.d.ts +5 -0
  166. package/typings/textStyle.d.ts +5 -0
  167. package/typings/toolbar.d.ts +32 -0
  168. package/typings/unicode.d.ts +25 -0
  169. package/{src/plugins/dialog → typings}/video.d.ts +1 -1
  170. package/dist/css/suneditor.min.css +0 -1
  171. package/src/assets/css/suneditor-contents.css +0 -562
  172. package/src/assets/css/suneditor.css +0 -566
  173. package/src/assets/defaultIcons.js +0 -103
  174. package/src/lang/Lang.d.ts +0 -144
  175. package/src/lang/ckb.d.ts +0 -5
  176. package/src/lang/ckb.js +0 -188
  177. package/src/lang/cs.d.ts +0 -5
  178. package/src/lang/cs.js +0 -188
  179. package/src/lang/da.d.ts +0 -5
  180. package/src/lang/da.js +0 -191
  181. package/src/lang/de.d.ts +0 -5
  182. package/src/lang/de.js +0 -188
  183. package/src/lang/en.d.ts +0 -5
  184. package/src/lang/en.js +0 -188
  185. package/src/lang/es.d.ts +0 -5
  186. package/src/lang/es.js +0 -188
  187. package/src/lang/fa.d.ts +0 -5
  188. package/src/lang/fa.js +0 -188
  189. package/src/lang/fr.d.ts +0 -5
  190. package/src/lang/fr.js +0 -188
  191. package/src/lang/he.d.ts +0 -5
  192. package/src/lang/he.js +0 -188
  193. package/src/lang/index.d.ts +0 -23
  194. package/src/lang/it.d.ts +0 -5
  195. package/src/lang/it.js +0 -188
  196. package/src/lang/ja.d.ts +0 -5
  197. package/src/lang/ja.js +0 -188
  198. package/src/lang/ko.d.ts +0 -5
  199. package/src/lang/ko.js +0 -188
  200. package/src/lang/lv.d.ts +0 -5
  201. package/src/lang/lv.js +0 -188
  202. package/src/lang/nl.d.ts +0 -5
  203. package/src/lang/nl.js +0 -188
  204. package/src/lang/pl.d.ts +0 -5
  205. package/src/lang/pl.js +0 -188
  206. package/src/lang/pt_br.d.ts +0 -5
  207. package/src/lang/pt_br.js +0 -189
  208. package/src/lang/ro.d.ts +0 -5
  209. package/src/lang/ro.js +0 -188
  210. package/src/lang/ru.d.ts +0 -5
  211. package/src/lang/ru.js +0 -188
  212. package/src/lang/se.d.ts +0 -5
  213. package/src/lang/se.js +0 -191
  214. package/src/lang/tr.d.ts +0 -5
  215. package/src/lang/tr.js +0 -191
  216. package/src/lang/ua.d.ts +0 -5
  217. package/src/lang/ua.js +0 -188
  218. package/src/lang/ur.d.ts +0 -5
  219. package/src/lang/ur.js +0 -188
  220. package/src/lang/zh_cn.d.ts +0 -5
  221. package/src/lang/zh_cn.js +0 -187
  222. package/src/lib/constructor.js +0 -954
  223. package/src/lib/context.d.ts +0 -42
  224. package/src/lib/context.js +0 -71
  225. package/src/lib/core.d.ts +0 -1135
  226. package/src/lib/core.js +0 -9395
  227. package/src/lib/history.d.ts +0 -48
  228. package/src/lib/history.js +0 -219
  229. package/src/lib/util.d.ts +0 -678
  230. package/src/lib/util.js +0 -2131
  231. package/src/options.d.ts +0 -608
  232. package/src/plugins/CommandPlugin.d.ts +0 -8
  233. package/src/plugins/DialogPlugin.d.ts +0 -20
  234. package/src/plugins/FileBrowserPlugin.d.ts +0 -30
  235. package/src/plugins/Module.d.ts +0 -15
  236. package/src/plugins/Plugin.d.ts +0 -42
  237. package/src/plugins/SubmenuPlugin.d.ts +0 -8
  238. package/src/plugins/dialog/audio.js +0 -559
  239. package/src/plugins/dialog/image.js +0 -1126
  240. package/src/plugins/dialog/link.js +0 -223
  241. package/src/plugins/dialog/math.js +0 -295
  242. package/src/plugins/dialog/mention.js +0 -242
  243. package/src/plugins/dialog/video.js +0 -979
  244. package/src/plugins/index.d.ts +0 -79
  245. package/src/plugins/modules/_anchor.js +0 -461
  246. package/src/plugins/modules/_colorPicker.d.ts +0 -60
  247. package/src/plugins/modules/_colorPicker.js +0 -201
  248. package/src/plugins/modules/_notice.d.ts +0 -21
  249. package/src/plugins/modules/_notice.js +0 -72
  250. package/src/plugins/modules/_selectMenu.js +0 -119
  251. package/src/plugins/modules/component.d.ts +0 -25
  252. package/src/plugins/modules/component.js +0 -81
  253. package/src/plugins/modules/dialog.d.ts +0 -28
  254. package/src/plugins/modules/dialog.js +0 -175
  255. package/src/plugins/modules/fileBrowser.d.ts +0 -42
  256. package/src/plugins/modules/fileBrowser.js +0 -374
  257. package/src/plugins/modules/fileManager.d.ts +0 -67
  258. package/src/plugins/modules/fileManager.js +0 -326
  259. package/src/plugins/modules/index.js +0 -9
  260. package/src/plugins/modules/resizing.d.ts +0 -154
  261. package/src/plugins/modules/resizing.js +0 -903
  262. package/src/plugins/submenu/align.d.ts +0 -5
  263. package/src/plugins/submenu/align.js +0 -160
  264. package/src/plugins/submenu/font.d.ts +0 -5
  265. package/src/plugins/submenu/font.js +0 -123
  266. package/src/plugins/submenu/fontColor.d.ts +0 -5
  267. package/src/plugins/submenu/fontColor.js +0 -101
  268. package/src/plugins/submenu/fontSize.d.ts +0 -5
  269. package/src/plugins/submenu/fontSize.js +0 -112
  270. package/src/plugins/submenu/formatBlock.d.ts +0 -5
  271. package/src/plugins/submenu/formatBlock.js +0 -273
  272. package/src/plugins/submenu/hiliteColor.d.ts +0 -5
  273. package/src/plugins/submenu/hiliteColor.js +0 -102
  274. package/src/plugins/submenu/horizontalRule.d.ts +0 -5
  275. package/src/plugins/submenu/horizontalRule.js +0 -98
  276. package/src/plugins/submenu/lineHeight.d.ts +0 -5
  277. package/src/plugins/submenu/lineHeight.js +0 -104
  278. package/src/plugins/submenu/list.d.ts +0 -5
  279. package/src/plugins/submenu/list.js +0 -456
  280. package/src/plugins/submenu/paragraphStyle.d.ts +0 -5
  281. package/src/plugins/submenu/paragraphStyle.js +0 -135
  282. package/src/plugins/submenu/table.d.ts +0 -5
  283. package/src/plugins/submenu/table.js +0 -1431
  284. package/src/plugins/submenu/template.d.ts +0 -5
  285. package/src/plugins/submenu/template.js +0 -72
  286. package/src/plugins/submenu/textStyle.d.ts +0 -5
  287. package/src/plugins/submenu/textStyle.js +0 -167
  288. package/src/suneditor.d.ts +0 -9
  289. package/src/suneditor_build.js +0 -18
  290. /package/{src/plugins/dialog → typings}/mention.d.ts +0 -0
@@ -1,1431 +0,0 @@
1
- /*
2
- * wysiwyg web editor
3
- *
4
- * suneditor.js
5
- * Copyright 2017 JiHong Lee.
6
- * MIT license.
7
- */
8
- 'use strict';
9
-
10
- export default {
11
- name: 'table',
12
- display: 'submenu',
13
- add: function (core, targetElement) {
14
- const context = core.context;
15
- let contextTable = context.table = {
16
- _element: null,
17
- _tdElement: null,
18
- _trElement: null,
19
- _trElements: null,
20
- _tableXY: [],
21
- _maxWidth: true,
22
- _fixedColumn: false,
23
- _rtl: core.options.rtl,
24
- cellControllerTop: core.options.tableCellControllerPosition === 'top',
25
- resizeText: null,
26
- headerButton: null,
27
- mergeButton: null,
28
- splitButton: null,
29
- splitMenu: null,
30
- maxText: core.lang.controller.maxSize,
31
- minText: core.lang.controller.minSize,
32
- _physical_cellCnt: 0,
33
- _logical_cellCnt: 0,
34
- _rowCnt: 0,
35
- _rowIndex: 0,
36
- _physical_cellIndex: 0,
37
- _logical_cellIndex: 0,
38
- _current_colSpan: 0,
39
- _current_rowSpan: 0,
40
- icons: {
41
- expansion: core.icons.expansion,
42
- reduction: core.icons.reduction
43
- }
44
- };
45
-
46
- /** set submenu */
47
- let listDiv = this.setSubmenu(core);
48
- let tablePicker = listDiv.querySelector('.se-controller-table-picker');
49
-
50
- contextTable.tableHighlight = listDiv.querySelector('.se-table-size-highlighted');
51
- contextTable.tableUnHighlight = listDiv.querySelector('.se-table-size-unhighlighted');
52
- contextTable.tableDisplay = listDiv.querySelector('.se-table-size-display');
53
- if (core.options.rtl) contextTable.tableHighlight.style.left = (10 * 18 - 13) + 'px';
54
-
55
- /** set table controller */
56
- let tableController = this.setController_table(core);
57
- contextTable.tableController = tableController;
58
- contextTable.resizeButton = tableController.querySelector('._se_table_resize');
59
- contextTable.resizeText = tableController.querySelector('._se_table_resize > span > span');
60
- contextTable.columnFixedButton = tableController.querySelector('._se_table_fixed_column');
61
- contextTable.headerButton = tableController.querySelector('._se_table_header');
62
-
63
- /** set resizing */
64
- let resizeDiv = this.setController_tableEditor(core, contextTable.cellControllerTop);
65
- contextTable.resizeDiv = resizeDiv;
66
- contextTable.splitMenu = resizeDiv.querySelector('.se-btn-group-sub');
67
- contextTable.mergeButton = resizeDiv.querySelector('._se_table_merge_button');
68
- contextTable.splitButton = resizeDiv.querySelector('._se_table_split_button');
69
- contextTable.insertRowAboveButton = resizeDiv.querySelector('._se_table_insert_row_a');
70
- contextTable.insertRowBelowButton = resizeDiv.querySelector('._se_table_insert_row_b');
71
-
72
- /** add event listeners */
73
- tablePicker.addEventListener('mousemove', this.onMouseMove_tablePicker.bind(core, contextTable));
74
- tablePicker.addEventListener('click', this.appendTable.bind(core));
75
- resizeDiv.addEventListener('click', this.onClick_tableController.bind(core));
76
- tableController.addEventListener('click', this.onClick_tableController.bind(core));
77
-
78
- /** append target button menu */
79
- core.initMenuTarget(this.name, targetElement, listDiv);
80
-
81
- /** append controller */
82
- context.element.relative.appendChild(resizeDiv);
83
- context.element.relative.appendChild(tableController);
84
-
85
- /** empty memory */
86
- listDiv = null, tablePicker = null, resizeDiv = null, tableController = null, contextTable = null;
87
- },
88
-
89
- setSubmenu: function (core) {
90
- const listDiv = core.util.createElement('DIV');
91
- listDiv.className = 'se-submenu se-selector-table';
92
- listDiv.innerHTML = '' +
93
- '<div class="se-table-size">' +
94
- '<div class="se-table-size-picker se-controller-table-picker"></div>' +
95
- '<div class="se-table-size-highlighted"></div>' +
96
- '<div class="se-table-size-unhighlighted"></div>' +
97
- '</div>' +
98
- '<div class="se-table-size-display">1 x 1</div>';
99
-
100
- return listDiv;
101
- },
102
-
103
- setController_table: function (core) {
104
- const lang = core.lang;
105
- const icons = core.icons;
106
- const tableResize = core.util.createElement('DIV');
107
-
108
- tableResize.className = 'se-controller se-controller-table';
109
- tableResize.innerHTML = '' +
110
- '<div>' +
111
- '<div class="se-btn-group">' +
112
- '<button type="button" data-command="resize" class="se-btn se-tooltip _se_table_resize">' +
113
- icons.expansion +
114
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.maxSize + '</span></span>' +
115
- '</button>' +
116
- '<button type="button" data-command="layout" class="se-btn se-tooltip _se_table_fixed_column">' +
117
- icons.fixed_column_width +
118
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.fixedColumnWidth + '</span></span>' +
119
- '</button>' +
120
- '<button type="button" data-command="header" class="se-btn se-tooltip _se_table_header">' +
121
- icons.table_header +
122
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.tableHeader + '</span></span>' +
123
- '</button>' +
124
- '<button type="button" data-command="remove" class="se-btn se-tooltip">' +
125
- icons.delete +
126
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.remove + '</span></span>' +
127
- '</button>' +
128
- '</div>' +
129
- '</div>';
130
-
131
- return tableResize;
132
- },
133
-
134
- setController_tableEditor: function (core, cellControllerTop) {
135
- const lang = core.lang;
136
- const icons = core.icons;
137
- const tableResize = core.util.createElement('DIV');
138
-
139
- tableResize.className = 'se-controller se-controller-table-cell';
140
- tableResize.innerHTML = (cellControllerTop ? '' : '<div class="se-arrow se-arrow-up"></div>') +
141
- '<div class="se-btn-group">' +
142
- '<button type="button" data-command="insert" data-value="row" data-option="up" class="se-btn se-tooltip _se_table_insert_row_a">' +
143
- icons.insert_row_above +
144
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.insertRowAbove + '</span></span>' +
145
- '</button>' +
146
- '<button type="button" data-command="insert" data-value="row" data-option="down" class="se-btn se-tooltip _se_table_insert_row_b">' +
147
- icons.insert_row_below +
148
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.insertRowBelow + '</span></span>' +
149
- '</button>' +
150
- '<button type="button" data-command="delete" data-value="row" class="se-btn se-tooltip">' +
151
- icons.delete_row +
152
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.deleteRow + '</span></span>' +
153
- '</button>' +
154
- '<button type="button" data-command="merge" class="_se_table_merge_button se-btn se-tooltip" disabled>' +
155
- icons.merge_cell +
156
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.mergeCells + '</span></span>' +
157
- '</button>' +
158
- '</div>' +
159
- '<div class="se-btn-group" style="padding-top: 0;">' +
160
- '<button type="button" data-command="insert" data-value="cell" data-option="left" class="se-btn se-tooltip">' +
161
- icons.insert_column_left +
162
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.insertColumnBefore + '</span></span>' +
163
- '</button>' +
164
- '<button type="button" data-command="insert" data-value="cell" data-option="right" class="se-btn se-tooltip">' +
165
- icons.insert_column_right +
166
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.insertColumnAfter + '</span></span>' +
167
- '</button>' +
168
- '<button type="button" data-command="delete" data-value="cell" class="se-btn se-tooltip">' +
169
- icons.delete_column +
170
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.deleteColumn + '</span></span>' +
171
- '</button>' +
172
- '<button type="button" data-command="onsplit" class="_se_table_split_button se-btn se-tooltip">' +
173
- icons.split_cell +
174
- '<span class="se-tooltip-inner"><span class="se-tooltip-text">' + lang.controller.splitCells + '</span></span>' +
175
- '</button>' +
176
- '<div class="se-btn-group-sub sun-editor-common se-list-layer se-table-split">' +
177
- '<div class="se-list-inner">' +
178
- '<ul class="se-list-basic">' +
179
- '<li class="se-btn-list" data-command="split" data-value="vertical" style="line-height:32px;" title="' + lang.controller.VerticalSplit + '" aria-label="' + lang.controller.VerticalSplit + '">' +
180
- lang.controller.VerticalSplit + '</li>' +
181
- '<li class="se-btn-list" data-command="split" data-value="horizontal" style="line-height:32px;" title="' + lang.controller.HorizontalSplit + '" aria-label="' + lang.controller.HorizontalSplit + '">' +
182
- lang.controller.HorizontalSplit + '</li>' +
183
- '</ul>' +
184
- '</div>' +
185
- '</div>' +
186
- '</div>';
187
-
188
- return tableResize;
189
- },
190
-
191
- appendTable: function () {
192
- const oTable = this.util.createElement('TABLE');
193
- const createCells = this.plugins.table.createCells;
194
-
195
- const x = this.context.table._tableXY[0];
196
- let y = this.context.table._tableXY[1];
197
- let tableHTML = '<tbody>';
198
- while (y > 0) {
199
- tableHTML += '<tr>' + createCells.call(this, 'td', x) + '</tr>';
200
- --y;
201
- }
202
- tableHTML += '</tbody>';
203
- oTable.innerHTML = tableHTML;
204
-
205
- const changed = this.insertComponent(oTable, false, true, false);
206
-
207
- if (changed) {
208
- const firstTd = oTable.querySelector('td div');
209
- this.setRange(firstTd, 0, firstTd, 0);
210
- this.plugins.table.reset_table_picker.call(this);
211
- }
212
- },
213
-
214
- createCells: function (nodeName, cnt, returnElement) {
215
- nodeName = nodeName.toLowerCase();
216
-
217
- if (!returnElement) {
218
- let cellsHTML = '';
219
- while (cnt > 0) {
220
- cellsHTML += '<' +nodeName + '><div><br></div></' + nodeName + '>';
221
- cnt--;
222
- }
223
- return cellsHTML;
224
- } else {
225
- const cell = this.util.createElement(nodeName);
226
- cell.innerHTML = '<div><br></div>';
227
- return cell;
228
- }
229
- },
230
-
231
- onMouseMove_tablePicker: function (contextTable, e) {
232
- e.stopPropagation();
233
-
234
- let x = this._w.Math.ceil(e.offsetX / 18);
235
- let y = this._w.Math.ceil(e.offsetY / 18);
236
- x = x < 1 ? 1 : x;
237
- y = y < 1 ? 1 : y;
238
-
239
- if (contextTable._rtl) {
240
- contextTable.tableHighlight.style.left = (x * 18 - 13) + 'px';
241
- x = 11 - x;
242
- }
243
-
244
- contextTable.tableHighlight.style.width = x + 'em';
245
- contextTable.tableHighlight.style.height = y + 'em';
246
-
247
- // let x_u = x < 5 ? 5 : (x > 9 ? 10 : x + 1);
248
- // let y_u = y < 5 ? 5 : (y > 9 ? 10 : y + 1);
249
- // contextTable.tableUnHighlight.style.width = x_u + 'em';
250
- // contextTable.tableUnHighlight.style.height = y_u + 'em';
251
-
252
- this.util.changeTxt(contextTable.tableDisplay, x + ' x ' + y);
253
- contextTable._tableXY = [x, y];
254
- },
255
-
256
- reset_table_picker: function () {
257
- if (!this.context.table.tableHighlight) return;
258
-
259
- const highlight = this.context.table.tableHighlight.style;
260
- const unHighlight = this.context.table.tableUnHighlight.style;
261
-
262
- highlight.width = '1em';
263
- highlight.height = '1em';
264
- unHighlight.width = '10em';
265
- unHighlight.height = '10em';
266
-
267
- this.util.changeTxt(this.context.table.tableDisplay, '1 x 1');
268
- this.submenuOff();
269
- },
270
-
271
- init: function () {
272
- const contextTable = this.context.table;
273
- const tablePlugin = this.plugins.table;
274
-
275
- tablePlugin._removeEvents.call(this);
276
-
277
- if (tablePlugin._selectedTable) {
278
- const selectedCells = tablePlugin._selectedTable.querySelectorAll('.se-table-selected-cell');
279
- for (let i = 0, len = selectedCells.length; i < len; i++) {
280
- this.util.removeClass(selectedCells[i], 'se-table-selected-cell');
281
- }
282
- }
283
-
284
- tablePlugin._toggleEditor.call(this, true);
285
-
286
- contextTable._element = null;
287
- contextTable._tdElement = null;
288
- contextTable._trElement = null;
289
- contextTable._trElements = null;
290
- contextTable._tableXY = [];
291
- contextTable._maxWidth = true;
292
- contextTable._fixedColumn = false;
293
- contextTable._physical_cellCnt = 0;
294
- contextTable._logical_cellCnt = 0;
295
- contextTable._rowCnt = 0;
296
- contextTable._rowIndex = 0;
297
- contextTable._physical_cellIndex = 0;
298
- contextTable._logical_cellIndex = 0;
299
- contextTable._current_colSpan = 0;
300
- contextTable._current_rowSpan = 0;
301
-
302
- tablePlugin._shift = false;
303
- tablePlugin._selectedCells = null;
304
- tablePlugin._selectedTable = null;
305
- tablePlugin._ref = null;
306
-
307
- tablePlugin._fixedCell = null;
308
- tablePlugin._selectedCell = null;
309
- tablePlugin._fixedCellName = null;
310
- },
311
-
312
- /** table edit controller */
313
- call_controller_tableEdit: function (tdElement) {
314
- const tablePlugin = this.plugins.table;
315
- const contextTable = this.context.table;
316
-
317
- if (!this.getSelection().isCollapsed && !tablePlugin._selectedCell) {
318
- this.controllersOff();
319
- this.util.removeClass(tdElement, 'se-table-selected-cell');
320
- return;
321
- }
322
-
323
- const tableElement = contextTable._element || this.plugins.table._selectedTable || this.util.getParentElement(tdElement, 'TABLE');
324
- contextTable._maxWidth = this.util.hasClass(tableElement, 'se-table-size-100') || tableElement.style.width === '100%' || (!tableElement.style.width && !this.util.hasClass(tableElement, 'se-table-size-auto'));
325
- contextTable._fixedColumn = this.util.hasClass(tableElement, 'se-table-layout-fixed') || tableElement.style.tableLayout === 'fixed';
326
- tablePlugin.setTableStyle.call(this, contextTable._maxWidth ? 'width|column' : 'width');
327
-
328
- tablePlugin.setPositionControllerTop.call(this, tableElement);
329
- tablePlugin.setPositionControllerDiv.call(this, tdElement, tablePlugin._shift);
330
-
331
- if (!tablePlugin._shift) this.controllersOn(contextTable.resizeDiv, contextTable.tableController, tablePlugin.init.bind(this), tdElement, 'table');
332
- },
333
-
334
- setPositionControllerTop: function (tableElement) {
335
- this.setControllerPosition(this.context.table.tableController, tableElement, 'top', {left: 0, top: 0});
336
- },
337
-
338
- setPositionControllerDiv: function (tdElement, reset) {
339
- const contextTable = this.context.table;
340
- const resizeDiv = contextTable.resizeDiv;
341
-
342
- this.plugins.table.setCellInfo.call(this, tdElement, reset);
343
-
344
- if (contextTable.cellControllerTop) {
345
- this.setControllerPosition(resizeDiv, contextTable._element, 'top', {left: contextTable.tableController.offsetWidth, top: 0});
346
- } else {
347
- this.setControllerPosition(resizeDiv, tdElement, 'bottom', {left: 0, top: 0});
348
- }
349
- },
350
-
351
- setCellInfo: function (tdElement, reset) {
352
- const contextTable = this.context.table;
353
- const table = contextTable._element = this.plugins.table._selectedTable || this.util.getParentElement(tdElement, 'TABLE');
354
-
355
- if (/THEAD/i.test(table.firstElementChild.nodeName)) {
356
- this.util.addClass(contextTable.headerButton, 'active');
357
- } else {
358
- this.util.removeClass(contextTable.headerButton, 'active');
359
- }
360
-
361
- if (reset || contextTable._physical_cellCnt === 0) {
362
- if (contextTable._tdElement !== tdElement) {
363
- contextTable._tdElement = tdElement;
364
- contextTable._trElement = tdElement.parentNode;
365
- }
366
-
367
- const rows = contextTable._trElements = table.rows;
368
- const cellIndex = tdElement.cellIndex;
369
-
370
- let cellCnt = 0;
371
- for (let i = 0, cells = rows[0].cells, len = rows[0].cells.length; i < len; i++) {
372
- cellCnt += cells[i].colSpan;
373
- }
374
-
375
- // row cnt, row index
376
- const rowIndex = contextTable._rowIndex = contextTable._trElement.rowIndex;
377
- contextTable._rowCnt = rows.length;
378
-
379
- // cell cnt, physical cell index
380
- contextTable._physical_cellCnt = contextTable._trElement.cells.length;
381
- contextTable._logical_cellCnt = cellCnt;
382
- contextTable._physical_cellIndex = cellIndex;
383
-
384
- // span
385
- contextTable._current_colSpan = contextTable._tdElement.colSpan - 1;
386
- contextTable._current_rowSpan - contextTable._trElement.cells[cellIndex].rowSpan - 1;
387
-
388
- // find logcal cell index
389
- let rowSpanArr = [];
390
- let spanIndex = [];
391
- for (let i = 0, cells, colSpan; i <= rowIndex; i++) {
392
- cells = rows[i].cells;
393
- colSpan = 0;
394
- for (let c = 0, cLen = cells.length, cell, cs, rs, logcalIndex; c < cLen; c++) {
395
- cell = cells[c];
396
- cs = cell.colSpan - 1;
397
- rs = cell.rowSpan - 1;
398
- logcalIndex = c + colSpan;
399
-
400
- if (spanIndex.length > 0) {
401
- for (let r = 0, arr; r < spanIndex.length; r++) {
402
- arr = spanIndex[r];
403
- if (arr.row > i) continue;
404
- if (logcalIndex >= arr.index) {
405
- colSpan += arr.cs;
406
- logcalIndex += arr.cs;
407
- arr.rs -= 1;
408
- arr.row = i + 1;
409
- if (arr.rs < 1) {
410
- spanIndex.splice(r, 1);
411
- r--;
412
- }
413
- } else if (c === cLen - 1) {
414
- arr.rs -= 1;
415
- arr.row = i + 1;
416
- if (arr.rs < 1) {
417
- spanIndex.splice(r, 1);
418
- r--;
419
- }
420
- }
421
- }
422
- }
423
-
424
- // logcal cell index
425
- if (i === rowIndex && c === cellIndex) {
426
- contextTable._logical_cellIndex = logcalIndex;
427
- break;
428
- }
429
-
430
- if (rs > 0) {
431
- rowSpanArr.push({
432
- index: logcalIndex,
433
- cs: cs + 1,
434
- rs: rs,
435
- row: -1
436
- });
437
- }
438
-
439
- colSpan += cs;
440
- }
441
-
442
- spanIndex = spanIndex.concat(rowSpanArr).sort(function (a, b) {return a.index - b.index;});
443
- rowSpanArr = [];
444
- }
445
-
446
- rowSpanArr = null;
447
- spanIndex = null;
448
- }
449
- },
450
-
451
- editTable: function (type, option) {
452
- const tablePlugin = this.plugins.table;
453
- const contextTable = this.context.table;
454
- const table = contextTable._element;
455
- const isRow = type === 'row';
456
-
457
- if (isRow) {
458
- const tableAttr = contextTable._trElement.parentNode;
459
- if (/^THEAD$/i.test(tableAttr.nodeName)) {
460
- if (option === 'up') {
461
- return;
462
- } else if (!tableAttr.nextElementSibling || !/^TBODY$/i.test(tableAttr.nextElementSibling.nodeName)) {
463
- table.innerHTML += '<tbody><tr>' + tablePlugin.createCells.call(this, 'td', contextTable._logical_cellCnt, false) + '</tr></tbody>';
464
- return;
465
- }
466
- }
467
- }
468
-
469
- // multi
470
- if (tablePlugin._ref) {
471
- const positionCell = contextTable._tdElement;
472
- const selectedCells = tablePlugin._selectedCells;
473
- // multi - row
474
- if (isRow) {
475
- // remove row
476
- if (!option) {
477
- let row = selectedCells[0].parentNode;
478
- const removeCells = [selectedCells[0]];
479
-
480
- for (let i = 1, len = selectedCells.length, cell; i < len; i++) {
481
- cell = selectedCells[i];
482
- if (row !== cell.parentNode) {
483
- removeCells.push(cell);
484
- row = cell.parentNode;
485
- }
486
- }
487
-
488
- for (let i = 0, len = removeCells.length; i < len; i++) {
489
- tablePlugin.setCellInfo.call(this, removeCells[i], true);
490
- tablePlugin.editRow.call(this, option);
491
- }
492
- } else { // edit row
493
- tablePlugin.setCellInfo.call(this, option === 'up' ? selectedCells[0] : selectedCells[selectedCells.length - 1], true);
494
- tablePlugin.editRow.call(this, option, positionCell);
495
- }
496
- } else { // multi - cell
497
- const firstRow = selectedCells[0].parentNode;
498
- // remove cell
499
- if (!option) {
500
- const removeCells = [selectedCells[0]];
501
-
502
- for (let i = 1, len = selectedCells.length, cell; i < len; i++) {
503
- cell = selectedCells[i];
504
- if (firstRow === cell.parentNode) {
505
- removeCells.push(cell);
506
- } else {
507
- break;
508
- }
509
- }
510
-
511
- for (let i = 0, len = removeCells.length; i < len; i++) {
512
- tablePlugin.setCellInfo.call(this, removeCells[i], true);
513
- tablePlugin.editCell.call(this, option);
514
- }
515
- } else { // edit cell
516
- let rightCell = null;
517
-
518
- for (let i = 0, len = selectedCells.length - 1; i < len; i++) {
519
- if (firstRow !== selectedCells[i + 1].parentNode) {
520
- rightCell = selectedCells[i];
521
- break;
522
- }
523
- }
524
-
525
- tablePlugin.setCellInfo.call(this, option === 'left' ? selectedCells[0] : rightCell || selectedCells[0], true);
526
- tablePlugin.editCell.call(this, option, positionCell);
527
- }
528
- }
529
-
530
- if (!option) tablePlugin.init.call(this);
531
- } // one
532
- else {
533
- tablePlugin[isRow ? 'editRow' : 'editCell'].call(this, option);
534
- }
535
-
536
- // after remove
537
- if (!option) {
538
- const children = table.children;
539
- for (let i = 0; i < children.length; i++) {
540
- if (children[i].children.length === 0) {
541
- this.util.removeItem(children[i]);
542
- i--;
543
- }
544
- }
545
-
546
- if (table.children.length === 0) this.util.removeItem(table);
547
- }
548
- },
549
-
550
- editRow: function (option, positionResetElement) {
551
- const contextTable = this.context.table;
552
- const remove = !option;
553
-
554
- const up = option === 'up';
555
- const originRowIndex = contextTable._rowIndex;
556
- const rowIndex = remove || up ? originRowIndex : originRowIndex + contextTable._current_rowSpan + 1;
557
- const sign = remove ? -1 : 1;
558
-
559
- const rows = contextTable._trElements;
560
- let cellCnt = contextTable._logical_cellCnt;
561
-
562
- for (let i = 0, len = originRowIndex + (remove ? -1 : 0), cell; i <= len; i++) {
563
- cell = rows[i].cells;
564
- if (cell.length === 0) return;
565
-
566
- for (let c = 0, cLen = cell.length, rs, cs; c < cLen; c++) {
567
- rs = cell[c].rowSpan;
568
- cs = cell[c].colSpan;
569
- if (rs < 2 && cs < 2) continue;
570
-
571
- if (rs + i > rowIndex && rowIndex > i) {
572
- cell[c].rowSpan = rs + sign;
573
- cellCnt -= cs;
574
- }
575
- }
576
- }
577
-
578
- if (remove) {
579
- const next = rows[originRowIndex + 1];
580
- if (next) {
581
- const spanCells = [];
582
- let cells = rows[originRowIndex].cells;
583
- let colSpan = 0;
584
-
585
- for (let i = 0, len = cells.length, cell, logcalIndex; i < len; i++) {
586
- cell = cells[i];
587
- logcalIndex = i + colSpan;
588
- colSpan += cell.colSpan - 1;
589
-
590
- if (cell.rowSpan > 1) {
591
- cell.rowSpan -= 1;
592
- spanCells.push({cell: cell.cloneNode(false), index: logcalIndex});
593
- }
594
- }
595
-
596
- if (spanCells.length > 0) {
597
- let spanCell = spanCells.shift();
598
- cells = next.cells;
599
- colSpan = 0;
600
-
601
- for (let i = 0, len = cells.length, cell, logcalIndex; i < len; i++) {
602
- cell = cells[i];
603
- logcalIndex = i + colSpan;
604
- colSpan += cell.colSpan - 1;
605
-
606
- if (logcalIndex >= spanCell.index) {
607
- i--, colSpan--;
608
- colSpan += spanCell.cell.colSpan - 1;
609
- next.insertBefore(spanCell.cell, cell);
610
- spanCell = spanCells.shift();
611
- if (!spanCell) break;
612
- }
613
- }
614
-
615
- if (spanCell) {
616
- next.appendChild(spanCell.cell);
617
- for (let i = 0, len = spanCells.length; i < len; i++) {
618
- next.appendChild(spanCells[i].cell);
619
- }
620
- }
621
- }
622
- }
623
-
624
- contextTable._element.deleteRow(rowIndex);
625
- } else {
626
- const newRow = contextTable._element.insertRow(rowIndex);
627
- newRow.innerHTML = this.plugins.table.createCells.call(this, 'td', cellCnt, false);
628
- }
629
-
630
- if (!remove) {
631
- this.plugins.table.setPositionControllerDiv.call(this, positionResetElement || contextTable._tdElement, true);
632
- } else {
633
- this.controllersOff();
634
- }
635
- },
636
-
637
- editCell: function (option, positionResetElement) {
638
- const contextTable = this.context.table;
639
- const util = this.util;
640
- const remove = !option;
641
-
642
- const left = option === 'left';
643
- const colSpan = contextTable._current_colSpan;
644
- const cellIndex = remove || left ? contextTable._logical_cellIndex : contextTable._logical_cellIndex + colSpan + 1;
645
-
646
- const rows = contextTable._trElements;
647
- let rowSpanArr = [];
648
- let spanIndex = [];
649
- let passCell = 0;
650
- const removeCell = [];
651
- const removeSpanArr = [];
652
-
653
- for (let i = 0, len = contextTable._rowCnt, row, insertIndex, cells, newCell, applySpan, cellColSpan; i < len; i++) {
654
- row = rows[i];
655
- insertIndex = cellIndex;
656
- applySpan = false;
657
- cells = row.cells;
658
- cellColSpan = 0;
659
-
660
- for (let c = 0, cell, cLen = cells.length, rs, cs, removeIndex; c < cLen; c++) {
661
- cell = cells[c];
662
- if (!cell) break;
663
-
664
- rs = cell.rowSpan - 1;
665
- cs = cell.colSpan - 1;
666
-
667
- if (!remove) {
668
- if (c >= insertIndex) break;
669
- if (cs > 0) {
670
- if (passCell < 1 && cs + c >= insertIndex) {
671
- cell.colSpan += 1;
672
- insertIndex = null;
673
- passCell = rs + 1;
674
- break;
675
- }
676
-
677
- insertIndex -= cs;
678
- }
679
-
680
- if (!applySpan) {
681
- for (let r = 0, arr; r < spanIndex.length; r++) {
682
- arr = spanIndex[r];
683
- insertIndex -= arr.cs;
684
- arr.rs -= 1;
685
- if (arr.rs < 1) {
686
- spanIndex.splice(r, 1);
687
- r--;
688
- }
689
- }
690
- applySpan = true;
691
- }
692
- } else {
693
- removeIndex = c + cellColSpan;
694
-
695
- if (spanIndex.length > 0) {
696
- const lastCell = !cells[c + 1];
697
- for (let r = 0, arr; r < spanIndex.length; r++) {
698
- arr = spanIndex[r];
699
- if (arr.row > i) continue;
700
-
701
- if (removeIndex >= arr.index) {
702
- cellColSpan += arr.cs;
703
- removeIndex = c + cellColSpan;
704
- arr.rs -= 1;
705
- arr.row = i + 1;
706
- if (arr.rs < 1) {
707
- spanIndex.splice(r, 1);
708
- r--;
709
- }
710
- } else if (lastCell) {
711
- arr.rs -= 1;
712
- arr.row = i + 1;
713
- if (arr.rs < 1) {
714
- spanIndex.splice(r, 1);
715
- r--;
716
- }
717
- }
718
- }
719
- }
720
-
721
- if (rs > 0) {
722
- rowSpanArr.push({
723
- rs: rs,
724
- cs: cs + 1,
725
- index: removeIndex,
726
- row: -1
727
- });
728
- }
729
-
730
- if (removeIndex >= insertIndex && removeIndex + cs <= insertIndex + colSpan) {
731
- removeCell.push(cell);
732
- } else if (removeIndex <= insertIndex + colSpan && removeIndex + cs >= insertIndex) {
733
- cell.colSpan -= util.getOverlapRangeAtIndex(cellIndex, cellIndex + colSpan, removeIndex, removeIndex + cs);
734
- } else if (rs > 0 && (removeIndex < insertIndex || removeIndex + cs > insertIndex + colSpan)) {
735
- removeSpanArr.push({
736
- cell: cell,
737
- i: i,
738
- rs: i + rs
739
- });
740
- }
741
-
742
- cellColSpan += cs;
743
- }
744
- }
745
-
746
- spanIndex = spanIndex.concat(rowSpanArr).sort(function (a, b) {return a.index - b.index;});
747
- rowSpanArr = [];
748
-
749
- if (!remove) {
750
- if (passCell > 0) {
751
- passCell -= 1;
752
- continue;
753
- }
754
-
755
- if (insertIndex !== null && cells.length > 0) {
756
- newCell = this.plugins.table.createCells.call(this, cells[0].nodeName, 0, true);
757
- newCell = row.insertBefore(newCell, cells[insertIndex]);
758
- }
759
- }
760
- }
761
-
762
- if (remove) {
763
- let removeFirst, removeEnd;
764
- for (let r = 0, rLen = removeCell.length, row; r < rLen; r++) {
765
- row = removeCell[r].parentNode;
766
- util.removeItem(removeCell[r]);
767
- if (row.cells.length === 0) {
768
- if (!removeFirst) removeFirst = util.getArrayIndex(rows, row);
769
- removeEnd = util.getArrayIndex(rows, row);
770
- util.removeItem(row);
771
- }
772
- }
773
-
774
- for (let c = 0, cLen = removeSpanArr.length, rowSpanCell; c < cLen; c++) {
775
- rowSpanCell = removeSpanArr[c];
776
- rowSpanCell.cell.rowSpan = util.getOverlapRangeAtIndex(removeFirst, removeEnd, rowSpanCell.i, rowSpanCell.rs);
777
- }
778
-
779
- this.controllersOff();
780
- } else {
781
- this.plugins.table.setPositionControllerDiv.call(this, positionResetElement || contextTable._tdElement, true);
782
- }
783
- },
784
-
785
- _closeSplitMenu: null,
786
- openSplitMenu: function () {
787
- this.util.addClass(this.context.table.splitButton, 'on');
788
- this.context.table.splitMenu.style.display = 'inline-table';
789
-
790
- this.plugins.table._closeSplitMenu = function () {
791
- this.util.removeClass(this.context.table.splitButton, 'on');
792
- this.context.table.splitMenu.style.display = 'none';
793
- this.removeDocEvent('click', this.plugins.table._closeSplitMenu);
794
- this.plugins.table._closeSplitMenu = null;
795
- }.bind(this);
796
-
797
- this.addDocEvent('click', this.plugins.table._closeSplitMenu);
798
- },
799
-
800
- splitCells: function (direction) {
801
- const util = this.util;
802
- const vertical = direction === 'vertical';
803
- const contextTable = this.context.table;
804
- const currentCell = contextTable._tdElement;
805
- const rows = contextTable._trElements;
806
- const currentRow = contextTable._trElement;
807
- const index = contextTable._logical_cellIndex;
808
- const rowIndex = contextTable._rowIndex;
809
- const newCell = this.plugins.table.createCells.call(this, currentCell.nodeName, 0, true);
810
-
811
- // vertical
812
- if (vertical) {
813
- const currentColSpan = currentCell.colSpan;
814
- newCell.rowSpan = currentCell.rowSpan;
815
-
816
- // colspan > 1
817
- if (currentColSpan > 1) {
818
- newCell.colSpan = this._w.Math.floor(currentColSpan/2);
819
- currentCell.colSpan = currentColSpan - newCell.colSpan;
820
- currentRow.insertBefore(newCell, currentCell.nextElementSibling);
821
- } else { // colspan - 1
822
- let rowSpanArr = [];
823
- let spanIndex = [];
824
-
825
- for (let i = 0, len = contextTable._rowCnt, cells, colSpan; i < len; i++) {
826
- cells = rows[i].cells;
827
- colSpan = 0;
828
- for (let c = 0, cLen = cells.length, cell, cs, rs, logcalIndex; c < cLen; c++) {
829
- cell = cells[c];
830
- cs = cell.colSpan - 1;
831
- rs = cell.rowSpan - 1;
832
- logcalIndex = c + colSpan;
833
-
834
- if (spanIndex.length > 0) {
835
- for (let r = 0, arr; r < spanIndex.length; r++) {
836
- arr = spanIndex[r];
837
- if (arr.row > i) continue;
838
- if (logcalIndex >= arr.index) {
839
- colSpan += arr.cs;
840
- logcalIndex += arr.cs;
841
- arr.rs -= 1;
842
- arr.row = i + 1;
843
- if (arr.rs < 1) {
844
- spanIndex.splice(r, 1);
845
- r--;
846
- }
847
- } else if (c === cLen - 1) {
848
- arr.rs -= 1;
849
- arr.row = i + 1;
850
- if (arr.rs < 1) {
851
- spanIndex.splice(r, 1);
852
- r--;
853
- }
854
- }
855
- }
856
- }
857
-
858
- if (logcalIndex <= index && rs > 0) {
859
- rowSpanArr.push({
860
- index: logcalIndex,
861
- cs: cs + 1,
862
- rs: rs,
863
- row: -1
864
- });
865
- }
866
-
867
- if (cell !== currentCell && logcalIndex <= index && logcalIndex + cs >= index + currentColSpan - 1) {
868
- cell.colSpan += 1;
869
- break;
870
- }
871
-
872
- if (logcalIndex > index) break;
873
-
874
- colSpan += cs;
875
- }
876
-
877
- spanIndex = spanIndex.concat(rowSpanArr).sort(function (a, b) {return a.index - b.index;});
878
- rowSpanArr = [];
879
- }
880
-
881
- currentRow.insertBefore(newCell, currentCell.nextElementSibling);
882
- }
883
- } else { // horizontal
884
- const currentRowSpan = currentCell.rowSpan;
885
- newCell.colSpan = currentCell.colSpan;
886
-
887
- // rowspan > 1
888
- if (currentRowSpan > 1) {
889
- newCell.rowSpan = this._w.Math.floor(currentRowSpan/2);
890
- const newRowSpan = currentRowSpan - newCell.rowSpan;
891
-
892
- const rowSpanArr = [];
893
- const nextRowIndex = util.getArrayIndex(rows, currentRow) + newRowSpan;
894
-
895
- for (let i = 0, cells, colSpan; i < nextRowIndex; i++) {
896
- cells = rows[i].cells;
897
- colSpan = 0;
898
- for (let c = 0, cLen = cells.length, cell, cs, logcalIndex; c < cLen; c++) {
899
- logcalIndex = c + colSpan;
900
- if (logcalIndex >= index) break;
901
-
902
- cell = cells[c];
903
- cs = cell.rowSpan - 1;
904
- if (cs > 0 && cs + i >= nextRowIndex && logcalIndex < index) {
905
- rowSpanArr.push({
906
- index: logcalIndex,
907
- cs: cell.colSpan
908
- });
909
- }
910
- colSpan += cell.colSpan - 1;
911
- }
912
- }
913
-
914
- const nextRow = rows[nextRowIndex];
915
- const nextCells = nextRow.cells;
916
- let rs = rowSpanArr.shift();
917
-
918
- for (let c = 0, cLen = nextCells.length, colSpan = 0, cell, cs, logcalIndex, insertIndex; c < cLen; c++) {
919
- logcalIndex = c + colSpan;
920
- cell = nextCells[c];
921
- cs = cell.colSpan - 1;
922
- insertIndex = logcalIndex + cs + 1;
923
-
924
- if (rs && insertIndex >= rs.index) {
925
- colSpan += rs.cs;
926
- insertIndex += rs.cs;
927
- rs = rowSpanArr.shift();
928
- }
929
-
930
- if (insertIndex >= index || c === cLen - 1) {
931
- nextRow.insertBefore(newCell, cell.nextElementSibling);
932
- break;
933
- }
934
-
935
- colSpan += cs;
936
- }
937
-
938
- currentCell.rowSpan = newRowSpan;
939
- } else { // rowspan - 1
940
- newCell.rowSpan = currentCell.rowSpan;
941
- const newRow = util.createElement('TR');
942
- newRow.appendChild(newCell);
943
-
944
- for (let i = 0, cells; i < rowIndex; i++) {
945
- cells = rows[i].cells;
946
- if (cells.length === 0) return;
947
-
948
- for (let c = 0, cLen = cells.length; c < cLen; c++) {
949
- if (i + cells[c].rowSpan - 1 >= rowIndex) {
950
- cells[c].rowSpan += 1;
951
- }
952
- }
953
- }
954
-
955
- const physicalIndex = contextTable._physical_cellIndex;
956
- const cells = currentRow.cells;
957
-
958
- for (let c = 0, cLen = cells.length; c < cLen; c++) {
959
- if (c === physicalIndex) continue;
960
- cells[c].rowSpan += 1;
961
- }
962
-
963
- currentRow.parentNode.insertBefore(newRow, currentRow.nextElementSibling);
964
- }
965
- }
966
-
967
- this.focusEdge(currentCell);
968
- this.plugins.table.setPositionControllerDiv.call(this, currentCell, true);
969
- },
970
-
971
- mergeCells: function () {
972
- const tablePlugin = this.plugins.table;
973
- const contextTable = this.context.table;
974
- const util = this.util;
975
-
976
- const ref = tablePlugin._ref;
977
- const selectedCells = tablePlugin._selectedCells;
978
- const mergeCell = selectedCells[0];
979
-
980
- let emptyRowFirst = null;
981
- let emptyRowLast = null;
982
- let cs = (ref.ce - ref.cs) + 1;
983
- let rs = (ref.re - ref.rs) + 1;
984
- let mergeHTML = '';
985
- let row = null;
986
-
987
- for (let i = 1, len = selectedCells.length, cell, ch; i < len; i++) {
988
- cell = selectedCells[i];
989
- if (row !== cell.parentNode) row = cell.parentNode;
990
-
991
- ch = cell.children;
992
- for (let c = 0, cLen = ch.length; c < cLen; c++) {
993
- if (util.isFormatElement(ch[c]) && util.onlyZeroWidthSpace(ch[c].textContent)) {
994
- util.removeItem(ch[c]);
995
- }
996
- }
997
-
998
- mergeHTML += cell.innerHTML;
999
- util.removeItem(cell);
1000
-
1001
- if (row.cells.length === 0) {
1002
- if (!emptyRowFirst) emptyRowFirst = row;
1003
- else emptyRowLast = row;
1004
- rs -= 1;
1005
- }
1006
- }
1007
-
1008
- if (emptyRowFirst) {
1009
- const rows = contextTable._trElements;
1010
- const rowIndexFirst = util.getArrayIndex(rows, emptyRowFirst);
1011
- const rowIndexLast = util.getArrayIndex(rows, emptyRowLast || emptyRowFirst);
1012
- const removeRows = [];
1013
-
1014
- for (let i = 0, cells; i <= rowIndexLast; i++) {
1015
- cells = rows[i].cells;
1016
- if (cells.length === 0) {
1017
- removeRows.push(rows[i]);
1018
- continue;
1019
- }
1020
-
1021
- for (let c = 0, cLen = cells.length, cell, rs; c < cLen; c++) {
1022
- cell = cells[c];
1023
- rs = cell.rowSpan - 1;
1024
- if (rs > 0 && i + rs >= rowIndexFirst) {
1025
- cell.rowSpan -= util.getOverlapRangeAtIndex(rowIndexFirst, rowIndexLast, i, i + rs);
1026
- }
1027
- }
1028
- }
1029
-
1030
- for (let i = 0, len = removeRows.length; i < len; i++) {
1031
- util.removeItem(removeRows[i]);
1032
- }
1033
- }
1034
-
1035
- mergeCell.innerHTML += mergeHTML;
1036
- mergeCell.colSpan = cs;
1037
- mergeCell.rowSpan = rs;
1038
-
1039
- this.controllersOff();
1040
- tablePlugin.setActiveButton.call(this, true, false);
1041
- tablePlugin.call_controller_tableEdit.call(this, mergeCell);
1042
-
1043
- util.addClass(mergeCell, 'se-table-selected-cell');
1044
- this.focusEdge(mergeCell);
1045
- },
1046
-
1047
- toggleHeader: function () {
1048
- const util = this.util;
1049
- const headerButton = this.context.table.headerButton;
1050
- const active = util.hasClass(headerButton, 'active');
1051
- const table = this.context.table._element;
1052
-
1053
- if (!active) {
1054
- const header = util.createElement('THEAD');
1055
- header.innerHTML = '<tr>' + this.plugins.table.createCells.call(this, 'th', this.context.table._logical_cellCnt, false) + '</tr>';
1056
- table.insertBefore(header, table.firstElementChild);
1057
- } else {
1058
- util.removeItem(table.querySelector('thead'));
1059
- }
1060
-
1061
- util.toggleClass(headerButton, 'active');
1062
-
1063
- if (/TH/i.test(this.context.table._tdElement.nodeName)) {
1064
- this.controllersOff();
1065
- } else {
1066
- this.plugins.table.setPositionControllerDiv.call(this, this.context.table._tdElement, false);
1067
- }
1068
- },
1069
-
1070
- setTableStyle: function (styles) {
1071
- const contextTable = this.context.table;
1072
- const tableElement = contextTable._element;
1073
- let icon, span, sizeIcon, text;
1074
-
1075
- if (styles.indexOf('width') > -1) {
1076
- icon = contextTable.resizeButton.firstElementChild;
1077
- span = contextTable.resizeText;
1078
-
1079
- if (!contextTable._maxWidth) {
1080
- sizeIcon = contextTable.icons.expansion;
1081
- text = contextTable.maxText;
1082
- contextTable.columnFixedButton.style.display = 'none';
1083
- this.util.removeClass(tableElement, 'se-table-size-100');
1084
- this.util.addClass(tableElement, 'se-table-size-auto');
1085
- } else {
1086
- sizeIcon = contextTable.icons.reduction;
1087
- text = contextTable.minText;
1088
- contextTable.columnFixedButton.style.display = 'block';
1089
- this.util.removeClass(tableElement, 'se-table-size-auto');
1090
- this.util.addClass(tableElement, 'se-table-size-100');
1091
- }
1092
-
1093
- this.util.changeElement(icon, sizeIcon);
1094
- this.util.changeTxt(span, text);
1095
- }
1096
-
1097
- if (styles.indexOf('column') > -1) {
1098
- if (!contextTable._fixedColumn) {
1099
- this.util.removeClass(tableElement, 'se-table-layout-fixed');
1100
- this.util.addClass(tableElement, 'se-table-layout-auto');
1101
- this.util.removeClass(contextTable.columnFixedButton, 'active');
1102
- } else {
1103
- this.util.removeClass(tableElement, 'se-table-layout-auto');
1104
- this.util.addClass(tableElement, 'se-table-layout-fixed');
1105
- this.util.addClass(contextTable.columnFixedButton, 'active');
1106
- }
1107
-
1108
- }
1109
- },
1110
-
1111
- setActiveButton: function (fixedCell, selectedCell) {
1112
- const contextTable = this.context.table;
1113
-
1114
- if (/^TH$/i.test(fixedCell.nodeName)) {
1115
- contextTable.insertRowAboveButton.setAttribute('disabled', true);
1116
- contextTable.insertRowBelowButton.setAttribute('disabled', true);
1117
- } else {
1118
- contextTable.insertRowAboveButton.removeAttribute('disabled');
1119
- contextTable.insertRowBelowButton.removeAttribute('disabled');
1120
- }
1121
-
1122
- if (!selectedCell || fixedCell === selectedCell) {
1123
- contextTable.splitButton.removeAttribute('disabled');
1124
- contextTable.mergeButton.setAttribute('disabled', true);
1125
- } else {
1126
- contextTable.splitButton.setAttribute('disabled', true);
1127
- contextTable.mergeButton.removeAttribute('disabled');
1128
- }
1129
- },
1130
-
1131
- // multi selecte
1132
- _bindOnSelect: null,
1133
- _bindOffSelect: null,
1134
- _bindOffShift: null,
1135
- _selectedCells: null,
1136
- _shift: false,
1137
- _fixedCell: null,
1138
- _fixedCellName: null,
1139
- _selectedCell: null,
1140
- _selectedTable: null,
1141
- _ref: null,
1142
- _toggleEditor: function (enabled) {
1143
- this.context.element.wysiwyg.setAttribute('contenteditable', enabled);
1144
- if (enabled) this.util.removeClass(this.context.element.wysiwyg, 'se-disabled');
1145
- else this.util.addClass(this.context.element.wysiwyg, 'se-disabled');
1146
- },
1147
-
1148
- _offCellMultiSelect: function (e) {
1149
- e.stopPropagation();
1150
- const tablePlugin = this.plugins.table;
1151
-
1152
- if (!tablePlugin._shift) {
1153
- tablePlugin._removeEvents.call(this);
1154
- tablePlugin._toggleEditor.call(this, true);
1155
- } else if (tablePlugin._initBind) {
1156
- this._wd.removeEventListener('touchmove', tablePlugin._initBind);
1157
- tablePlugin._initBind = null;
1158
- }
1159
-
1160
- if (!tablePlugin._fixedCell || !tablePlugin._selectedTable) return;
1161
-
1162
- tablePlugin.setActiveButton.call(this, tablePlugin._fixedCell, tablePlugin._selectedCell);
1163
- tablePlugin.call_controller_tableEdit.call(this, tablePlugin._selectedCell || tablePlugin._fixedCell);
1164
-
1165
- tablePlugin._selectedCells = tablePlugin._selectedTable.querySelectorAll('.se-table-selected-cell');
1166
- if (tablePlugin._selectedCell && tablePlugin._fixedCell) this.focusEdge(tablePlugin._selectedCell);
1167
-
1168
- if (!tablePlugin._shift) {
1169
- tablePlugin._fixedCell = null;
1170
- tablePlugin._selectedCell = null;
1171
- tablePlugin._fixedCellName = null;
1172
- }
1173
- },
1174
-
1175
- _onCellMultiSelect: function (e) {
1176
- this._antiBlur = true;
1177
- const tablePlugin = this.plugins.table;
1178
- const target = this.util.getParentElement(e.target, this.util.isCell);
1179
-
1180
- if (tablePlugin._shift) {
1181
- if (target === tablePlugin._fixedCell) tablePlugin._toggleEditor.call(this, true);
1182
- else tablePlugin._toggleEditor.call(this, false);
1183
- } else if (!tablePlugin._ref) {
1184
- if (target === tablePlugin._fixedCell) return;
1185
- else tablePlugin._toggleEditor.call(this, false);
1186
- }
1187
-
1188
- if (!target || target === tablePlugin._selectedCell || tablePlugin._fixedCellName !== target.nodeName ||
1189
- tablePlugin._selectedTable !== this.util.getParentElement(target, 'TABLE')) {
1190
- return;
1191
- }
1192
-
1193
- tablePlugin._selectedCell = target;
1194
- tablePlugin._setMultiCells.call(this, tablePlugin._fixedCell, target);
1195
- },
1196
-
1197
- _setMultiCells: function (startCell, endCell) {
1198
- const tablePlugin = this.plugins.table;
1199
- const rows = tablePlugin._selectedTable.rows;
1200
- const util = this.util;
1201
-
1202
- const selectedCells = tablePlugin._selectedTable.querySelectorAll('.se-table-selected-cell');
1203
- for (let i = 0, len = selectedCells.length; i < len; i++) {
1204
- util.removeClass(selectedCells[i], 'se-table-selected-cell');
1205
- }
1206
-
1207
- if (startCell === endCell) {
1208
- util.addClass(startCell, 'se-table-selected-cell');
1209
- if (!tablePlugin._shift) return;
1210
- }
1211
-
1212
- let findSelectedCell = true;
1213
- let spanIndex = [];
1214
- let rowSpanArr = [];
1215
- const ref = tablePlugin._ref = {_i: 0, cs: null, ce: null, rs: null, re: null};
1216
-
1217
- for (let i = 0, len = rows.length, cells, colSpan; i < len; i++) {
1218
- cells = rows[i].cells;
1219
- colSpan = 0;
1220
-
1221
- for (let c = 0, cLen = cells.length, cell, logcalIndex, cs, rs; c < cLen; c++) {
1222
- cell = cells[c];
1223
- cs = cell.colSpan - 1;
1224
- rs = cell.rowSpan - 1;
1225
- logcalIndex = c + colSpan;
1226
-
1227
- if (spanIndex.length > 0) {
1228
- for (let r = 0, arr; r < spanIndex.length; r++) {
1229
- arr = spanIndex[r];
1230
- if (arr.row > i) continue;
1231
- if (logcalIndex >= arr.index) {
1232
- colSpan += arr.cs;
1233
- logcalIndex += arr.cs;
1234
- arr.rs -= 1;
1235
- arr.row = i + 1;
1236
- if (arr.rs < 1) {
1237
- spanIndex.splice(r, 1);
1238
- r--;
1239
- }
1240
- } else if (c === cLen - 1) {
1241
- arr.rs -= 1;
1242
- arr.row = i + 1;
1243
- if (arr.rs < 1) {
1244
- spanIndex.splice(r, 1);
1245
- r--;
1246
- }
1247
- }
1248
- }
1249
- }
1250
-
1251
- if (findSelectedCell) {
1252
- if (cell === startCell || cell === endCell) {
1253
- ref.cs = ref.cs !== null && ref.cs < logcalIndex ? ref.cs : logcalIndex;
1254
- ref.ce = ref.ce !== null && ref.ce > logcalIndex + cs ? ref.ce : logcalIndex + cs;
1255
- ref.rs = ref.rs !== null && ref.rs < i ? ref.rs : i;
1256
- ref.re = ref.re !== null && ref.re > i + rs ? ref.re : i + rs;
1257
- ref._i += 1;
1258
- }
1259
-
1260
- if (ref._i === 2) {
1261
- findSelectedCell = false;
1262
- spanIndex = [];
1263
- rowSpanArr = [];
1264
- i = -1;
1265
- break;
1266
- }
1267
- } else if (util.getOverlapRangeAtIndex(ref.cs, ref.ce, logcalIndex, logcalIndex + cs) && util.getOverlapRangeAtIndex(ref.rs, ref.re, i, i + rs)) {
1268
- const newCs = ref.cs < logcalIndex ? ref.cs : logcalIndex;
1269
- const newCe = ref.ce > logcalIndex + cs ? ref.ce : logcalIndex + cs;
1270
- const newRs = ref.rs < i ? ref.rs : i;
1271
- const newRe = ref.re > i + rs ? ref.re : i + rs;
1272
-
1273
- if (ref.cs !== newCs || ref.ce !== newCe || ref.rs !== newRs || ref.re !== newRe) {
1274
- ref.cs = newCs;
1275
- ref.ce = newCe;
1276
- ref.rs = newRs;
1277
- ref.re = newRe;
1278
- i = -1;
1279
-
1280
- spanIndex = [];
1281
- rowSpanArr = [];
1282
- break;
1283
- }
1284
-
1285
- util.addClass(cell, 'se-table-selected-cell');
1286
- }
1287
-
1288
- if (rs > 0) {
1289
- rowSpanArr.push({
1290
- index: logcalIndex,
1291
- cs: cs + 1,
1292
- rs: rs,
1293
- row: -1
1294
- });
1295
- }
1296
-
1297
- colSpan += cell.colSpan - 1;
1298
- }
1299
-
1300
- spanIndex = spanIndex.concat(rowSpanArr).sort(function (a, b) {return a.index - b.index;});
1301
- rowSpanArr = [];
1302
- }
1303
- },
1304
-
1305
- _removeEvents: function () {
1306
- const tablePlugin = this.plugins.table;
1307
-
1308
- if (tablePlugin._initBind) {
1309
- this._wd.removeEventListener('touchmove', tablePlugin._initBind);
1310
- tablePlugin._initBind = null;
1311
- }
1312
-
1313
- if (tablePlugin._bindOnSelect) {
1314
- this._wd.removeEventListener('mousedown', tablePlugin._bindOnSelect);
1315
- this._wd.removeEventListener('mousemove', tablePlugin._bindOnSelect);
1316
- tablePlugin._bindOnSelect = null;
1317
- }
1318
-
1319
- if (tablePlugin._bindOffSelect) {
1320
- this._wd.removeEventListener('mouseup', tablePlugin._bindOffSelect);
1321
- tablePlugin._bindOffSelect = null;
1322
- }
1323
-
1324
- if (tablePlugin._bindOffShift) {
1325
- this._wd.removeEventListener('keyup', tablePlugin._bindOffShift);
1326
- tablePlugin._bindOffShift = null;
1327
- }
1328
- },
1329
-
1330
- _initBind: null,
1331
- onTableCellMultiSelect: function (tdElement, shift) {
1332
- const tablePlugin = this.plugins.table;
1333
-
1334
- tablePlugin._removeEvents.call(this);
1335
- this.controllersOff();
1336
-
1337
- tablePlugin._shift = shift;
1338
- tablePlugin._fixedCell = tdElement;
1339
- tablePlugin._fixedCellName = tdElement.nodeName;
1340
- tablePlugin._selectedTable = this.util.getParentElement(tdElement, 'TABLE');
1341
-
1342
- const selectedCells = tablePlugin._selectedTable.querySelectorAll('.se-table-selected-cell');
1343
- for (let i = 0, len = selectedCells.length; i < len; i++) {
1344
- this.util.removeClass(selectedCells[i], 'se-table-selected-cell');
1345
- }
1346
-
1347
- this.util.addClass(tdElement, 'se-table-selected-cell');
1348
-
1349
- tablePlugin._bindOnSelect = tablePlugin._onCellMultiSelect.bind(this);
1350
- tablePlugin._bindOffSelect = tablePlugin._offCellMultiSelect.bind(this);
1351
-
1352
- if (!shift) {
1353
- this._wd.addEventListener('mousemove', tablePlugin._bindOnSelect, false);
1354
- } else {
1355
- tablePlugin._bindOffShift = function () {
1356
- this.controllersOn(this.context.table.resizeDiv, this.context.table.tableController, this.plugins.table.init.bind(this), tdElement, 'table');
1357
- if (!tablePlugin._ref) this.controllersOff();
1358
- }.bind(this);
1359
-
1360
- this._wd.addEventListener('keyup', tablePlugin._bindOffShift, false);
1361
- this._wd.addEventListener('mousedown', tablePlugin._bindOnSelect, false);
1362
- }
1363
-
1364
- this._wd.addEventListener('mouseup', tablePlugin._bindOffSelect, false);
1365
- tablePlugin._initBind = tablePlugin.init.bind(this);
1366
- this._wd.addEventListener('touchmove', tablePlugin._initBind, false);
1367
- },
1368
-
1369
- onClick_tableController: function (e) {
1370
- e.stopPropagation();
1371
- const target = e.target.getAttribute('data-command') ? e.target : e.target.parentNode;
1372
-
1373
- if (target.getAttribute('disabled')) return;
1374
-
1375
- const command = target.getAttribute('data-command');
1376
- const value = target.getAttribute('data-value');
1377
- const option = target.getAttribute('data-option');
1378
- const tablePlugin = this.plugins.table;
1379
-
1380
- if (typeof tablePlugin._closeSplitMenu === 'function') {
1381
- tablePlugin._closeSplitMenu();
1382
- if (command === 'onsplit') return;
1383
- }
1384
-
1385
- if (!command) return;
1386
-
1387
- e.preventDefault();
1388
- const contextTable = this.context.table;
1389
-
1390
- switch (command) {
1391
- case 'insert':
1392
- case 'delete':
1393
- tablePlugin.editTable.call(this, value, option);
1394
- break;
1395
- case 'header':
1396
- tablePlugin.toggleHeader.call(this);
1397
- break;
1398
- case 'onsplit':
1399
- tablePlugin.openSplitMenu.call(this);
1400
- break;
1401
- case 'split':
1402
- tablePlugin.splitCells.call(this, value);
1403
- break;
1404
- case 'merge':
1405
- tablePlugin.mergeCells.call(this);
1406
- break;
1407
- case 'resize':
1408
- contextTable._maxWidth = !contextTable._maxWidth;
1409
- tablePlugin.setTableStyle.call(this, 'width');
1410
- tablePlugin.setPositionControllerTop.call(this, contextTable._element);
1411
- tablePlugin.setPositionControllerDiv.call(this, contextTable._tdElement, tablePlugin._shift);
1412
- break;
1413
- case 'layout':
1414
- contextTable._fixedColumn = !contextTable._fixedColumn;
1415
- tablePlugin.setTableStyle.call(this, 'column');
1416
- tablePlugin.setPositionControllerTop.call(this, contextTable._element);
1417
- tablePlugin.setPositionControllerDiv.call(this, contextTable._tdElement, tablePlugin._shift);
1418
- break;
1419
- case 'remove':
1420
- const emptyDiv = contextTable._element.parentNode;
1421
- this.util.removeItem(contextTable._element);
1422
- this.controllersOff();
1423
-
1424
- if (emptyDiv !== this.context.element.wysiwyg) this.util.removeItemAllParents(emptyDiv, function (current) { return current.childNodes.length === 0; }, null);
1425
- this.focus();
1426
- }
1427
-
1428
- // history stack
1429
- this.history.push(false);
1430
- }
1431
- };