suneditor 3.0.0-beta.3 → 3.0.0-beta.30
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.
- package/CONTRIBUTING.md +8 -8
- package/README.md +44 -49
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +95 -53
- package/src/assets/design/color.css +2 -2
- package/src/assets/design/size.css +2 -0
- package/src/assets/icons/defaultIcons.js +16 -1
- package/src/assets/suneditor-contents.css +9 -8
- package/src/assets/suneditor.css +29 -26
- package/src/core/{section → base}/actives.js +20 -12
- package/src/core/base/history.js +4 -4
- package/src/core/class/char.js +10 -10
- package/src/core/class/component.js +146 -57
- package/src/core/class/format.js +94 -2458
- package/src/core/class/html.js +187 -129
- package/src/core/class/inline.js +1853 -0
- package/src/core/class/listFormat.js +582 -0
- package/src/core/class/menu.js +14 -3
- package/src/core/class/nodeTransform.js +9 -14
- package/src/core/class/offset.js +162 -197
- package/src/core/class/selection.js +137 -34
- package/src/core/class/toolbar.js +73 -52
- package/src/core/class/ui.js +11 -11
- package/src/core/class/viewer.js +56 -55
- package/src/core/config/context.js +122 -0
- package/src/core/config/frameContext.js +204 -0
- package/src/core/config/options.js +639 -0
- package/src/core/editor.js +181 -108
- package/src/core/event/actions/index.js +229 -0
- package/src/core/event/effects/common.registry.js +60 -0
- package/src/core/event/effects/keydown.registry.js +551 -0
- package/src/core/event/effects/ruleHelpers.js +145 -0
- package/src/core/{base → event}/eventManager.js +119 -201
- package/src/core/event/executor.js +21 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +4 -4
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +2 -2
- package/src/core/event/handlers/handler_ww_input.js +77 -0
- package/src/core/event/handlers/handler_ww_key.js +228 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.js +3 -3
- package/src/core/event/ports.js +211 -0
- package/src/core/event/reducers/keydown.reducer.js +89 -0
- package/src/core/event/rules/keydown.rule.arrow.js +54 -0
- package/src/core/event/rules/keydown.rule.backspace.js +202 -0
- package/src/core/event/rules/keydown.rule.delete.js +126 -0
- package/src/core/event/rules/keydown.rule.enter.js +144 -0
- package/src/core/event/rules/keydown.rule.tab.js +29 -0
- package/src/core/section/constructor.js +79 -388
- package/src/core/section/documentType.js +47 -26
- package/src/core/util/instanceCheck.js +59 -0
- package/src/editorInjector/_classes.js +4 -0
- package/src/editorInjector/_core.js +17 -7
- package/src/editorInjector/index.js +10 -2
- package/src/events.js +6 -0
- package/src/helper/clipboard.js +24 -10
- package/src/helper/converter.js +17 -12
- package/src/helper/dom/domCheck.js +22 -3
- package/src/helper/dom/domQuery.js +91 -45
- package/src/helper/dom/domUtils.js +93 -19
- package/src/helper/dom/index.js +4 -0
- package/src/helper/env.js +11 -7
- package/src/helper/keyCodeMap.js +4 -3
- package/src/langs/ckb.js +1 -1
- package/src/langs/cs.js +1 -1
- package/src/langs/da.js +1 -1
- package/src/langs/de.js +1 -1
- package/src/langs/en.js +1 -1
- package/src/langs/es.js +1 -1
- package/src/langs/fa.js +1 -1
- package/src/langs/fr.js +1 -1
- package/src/langs/he.js +1 -1
- package/src/langs/hu.js +1 -1
- package/src/langs/it.js +1 -1
- package/src/langs/ja.js +1 -1
- package/src/langs/km.js +1 -1
- package/src/langs/ko.js +1 -1
- package/src/langs/lv.js +1 -1
- package/src/langs/nl.js +1 -1
- package/src/langs/pl.js +1 -1
- package/src/langs/pt_br.js +10 -10
- package/src/langs/ro.js +1 -1
- package/src/langs/ru.js +1 -1
- package/src/langs/se.js +1 -1
- package/src/langs/tr.js +1 -1
- package/src/langs/uk.js +1 -1
- package/src/langs/ur.js +1 -1
- package/src/langs/zh_cn.js +1 -1
- package/src/modules/ApiManager.js +25 -18
- package/src/modules/Browser.js +52 -61
- package/src/modules/ColorPicker.js +37 -38
- package/src/modules/Controller.js +85 -79
- package/src/modules/Figure.js +275 -187
- package/src/modules/FileManager.js +86 -92
- package/src/modules/HueSlider.js +67 -35
- package/src/modules/Modal.js +84 -77
- package/src/modules/ModalAnchorEditor.js +62 -79
- package/src/modules/SelectMenu.js +89 -86
- package/src/plugins/browser/audioGallery.js +9 -5
- package/src/plugins/browser/fileBrowser.js +10 -6
- package/src/plugins/browser/fileGallery.js +9 -5
- package/src/plugins/browser/imageGallery.js +9 -5
- package/src/plugins/browser/videoGallery.js +11 -6
- package/src/plugins/command/blockquote.js +1 -0
- package/src/plugins/command/exportPDF.js +11 -8
- package/src/plugins/command/fileUpload.js +41 -29
- package/src/plugins/command/list_bulleted.js +2 -1
- package/src/plugins/command/list_numbered.js +2 -1
- package/src/plugins/dropdown/align.js +8 -2
- package/src/plugins/dropdown/backgroundColor.js +19 -11
- package/src/plugins/dropdown/font.js +15 -9
- package/src/plugins/dropdown/fontColor.js +19 -11
- package/src/plugins/dropdown/formatBlock.js +7 -2
- package/src/plugins/dropdown/hr.js +7 -3
- package/src/plugins/dropdown/layout.js +6 -2
- package/src/plugins/dropdown/lineHeight.js +8 -3
- package/src/plugins/dropdown/list.js +2 -1
- package/src/plugins/dropdown/paragraphStyle.js +15 -11
- package/src/plugins/dropdown/{table.js → table/index.js} +514 -362
- package/src/plugins/dropdown/template.js +6 -2
- package/src/plugins/dropdown/textStyle.js +7 -3
- package/src/plugins/field/mention.js +33 -27
- package/src/plugins/input/fontSize.js +44 -37
- package/src/plugins/input/pageNavigator.js +3 -2
- package/src/plugins/modal/audio.js +90 -85
- package/src/plugins/modal/drawing.js +58 -66
- package/src/plugins/modal/embed.js +193 -180
- package/src/plugins/modal/image.js +441 -439
- package/src/plugins/modal/link.js +31 -8
- package/src/plugins/modal/math.js +23 -22
- package/src/plugins/modal/video.js +233 -230
- package/src/plugins/popup/anchor.js +24 -18
- package/src/suneditor.js +69 -24
- package/src/typedef.js +42 -19
- package/types/assets/icons/defaultIcons.d.ts +8 -0
- package/types/core/class/char.d.ts +1 -1
- package/types/core/class/component.d.ts +29 -7
- package/types/core/class/format.d.ts +4 -354
- package/types/core/class/html.d.ts +13 -4
- package/types/core/class/inline.d.ts +263 -0
- package/types/core/class/listFormat.d.ts +135 -0
- package/types/core/class/menu.d.ts +10 -2
- package/types/core/class/offset.d.ts +24 -26
- package/types/core/class/selection.d.ts +2 -0
- package/types/core/class/toolbar.d.ts +24 -11
- package/types/core/class/ui.d.ts +1 -1
- package/types/core/class/viewer.d.ts +1 -1
- package/types/core/config/context.d.ts +157 -0
- package/types/core/config/frameContext.d.ts +367 -0
- package/types/core/config/options.d.ts +1119 -0
- package/types/core/editor.d.ts +101 -66
- package/types/core/event/actions/index.d.ts +47 -0
- package/types/core/event/effects/common.registry.d.ts +50 -0
- package/types/core/event/effects/keydown.registry.d.ts +73 -0
- package/types/core/event/effects/ruleHelpers.d.ts +31 -0
- package/types/core/{base → event}/eventManager.d.ts +15 -46
- package/types/core/event/executor.d.ts +6 -0
- package/types/core/event/handlers/handler_ww_input.d.ts +41 -0
- package/types/core/{base/eventHandlers/handler_ww_key_input.d.ts → event/handlers/handler_ww_key.d.ts} +4 -6
- package/types/core/event/ports.d.ts +255 -0
- package/types/core/event/reducers/keydown.reducer.d.ts +75 -0
- package/types/core/event/rules/keydown.rule.arrow.d.ts +8 -0
- package/types/core/event/rules/keydown.rule.backspace.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.delete.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.enter.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.tab.d.ts +9 -0
- package/types/core/section/constructor.d.ts +101 -631
- package/types/core/section/documentType.d.ts +14 -4
- package/types/core/util/instanceCheck.d.ts +50 -0
- package/types/editorInjector/_classes.d.ts +4 -0
- package/types/editorInjector/_core.d.ts +17 -7
- package/types/editorInjector/index.d.ts +10 -2
- package/types/events.d.ts +1 -0
- package/types/helper/clipboard.d.ts +2 -2
- package/types/helper/converter.d.ts +6 -9
- package/types/helper/dom/domCheck.d.ts +7 -0
- package/types/helper/dom/domQuery.d.ts +19 -8
- package/types/helper/dom/domUtils.d.ts +24 -2
- package/types/helper/dom/index.d.ts +86 -1
- package/types/helper/env.d.ts +6 -1
- package/types/helper/index.d.ts +7 -1
- package/types/helper/keyCodeMap.d.ts +3 -3
- package/types/index.d.ts +23 -117
- package/types/langs/index.d.ts +2 -2
- package/types/modules/ApiManager.d.ts +1 -8
- package/types/modules/Browser.d.ts +4 -62
- package/types/modules/ColorPicker.d.ts +4 -21
- package/types/modules/Controller.d.ts +8 -64
- package/types/modules/Figure.d.ts +54 -50
- package/types/modules/FileManager.d.ts +1 -13
- package/types/modules/HueSlider.d.ts +13 -3
- package/types/modules/Modal.d.ts +0 -43
- package/types/modules/ModalAnchorEditor.d.ts +0 -73
- package/types/modules/SelectMenu.d.ts +0 -85
- package/types/modules/index.d.ts +3 -3
- package/types/plugins/browser/audioGallery.d.ts +29 -18
- package/types/plugins/browser/fileBrowser.d.ts +38 -27
- package/types/plugins/browser/fileGallery.d.ts +29 -18
- package/types/plugins/browser/imageGallery.d.ts +24 -16
- package/types/plugins/browser/videoGallery.d.ts +29 -18
- package/types/plugins/command/blockquote.d.ts +1 -0
- package/types/plugins/command/exportPDF.d.ts +18 -18
- package/types/plugins/command/fileUpload.d.ts +65 -45
- package/types/plugins/command/list_bulleted.d.ts +1 -0
- package/types/plugins/command/list_numbered.d.ts +1 -0
- package/types/plugins/dropdown/align.d.ts +13 -8
- package/types/plugins/dropdown/backgroundColor.d.ts +30 -19
- package/types/plugins/dropdown/font.d.ts +13 -12
- package/types/plugins/dropdown/fontColor.d.ts +30 -19
- package/types/plugins/dropdown/formatBlock.d.ts +13 -8
- package/types/plugins/dropdown/hr.d.ts +15 -11
- package/types/plugins/dropdown/layout.d.ts +15 -11
- package/types/plugins/dropdown/lineHeight.d.ts +16 -11
- package/types/plugins/dropdown/list.d.ts +1 -0
- package/types/plugins/dropdown/paragraphStyle.d.ts +31 -27
- package/types/plugins/dropdown/table/index.d.ts +582 -0
- package/types/plugins/dropdown/table.d.ts +41 -86
- package/types/plugins/dropdown/template.d.ts +15 -11
- package/types/plugins/dropdown/textStyle.d.ts +19 -11
- package/types/plugins/field/mention.d.ts +58 -56
- package/types/plugins/index.d.ts +38 -38
- package/types/plugins/input/fontSize.d.ts +46 -50
- package/types/plugins/modal/audio.d.ts +26 -56
- package/types/plugins/modal/drawing.d.ts +0 -85
- package/types/plugins/modal/embed.d.ts +15 -79
- package/types/plugins/modal/image.d.ts +24 -136
- package/types/plugins/modal/link.d.ts +34 -15
- package/types/plugins/modal/math.d.ts +0 -16
- package/types/plugins/modal/video.d.ts +17 -86
- package/types/plugins/popup/anchor.d.ts +1 -8
- package/types/suneditor.d.ts +70 -19
- package/types/typedef.d.ts +60 -46
- package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
- package/src/core/section/context.js +0 -102
- package/types/core/section/context.d.ts +0 -45
- package/types/langs/_Lang.d.ts +0 -194
- /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +0 -0
- /package/types/core/{section → base}/actives.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_toolbar.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.d.ts +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import EditorInjector from '
|
|
2
|
-
import { dom, numbers, converter, env, keyCodeMap } from '
|
|
3
|
-
import { Controller, SelectMenu, ColorPicker, Figure, _DragHandle } from '
|
|
1
|
+
import EditorInjector from '../../../editorInjector';
|
|
2
|
+
import { dom, numbers, converter, env, keyCodeMap } from '../../../helper';
|
|
3
|
+
import { Controller, SelectMenu, ColorPicker, Figure, _DragHandle } from '../../../modules';
|
|
4
4
|
|
|
5
5
|
const { _w, ON_OVER_COMPONENT } = env;
|
|
6
6
|
|
|
7
|
-
const ROW_SELECT_MARGIN =
|
|
8
|
-
const CELL_SELECT_MARGIN =
|
|
7
|
+
const ROW_SELECT_MARGIN = 6;
|
|
8
|
+
const CELL_SELECT_MARGIN = 6;
|
|
9
9
|
const CELL_DECIMAL_END = 0;
|
|
10
10
|
|
|
11
11
|
const RESIZE_CELL_CLASS = '.se-table-resize-line';
|
|
@@ -61,6 +61,14 @@ const DEFAULT_COLOR_LIST = [
|
|
|
61
61
|
'#000000'
|
|
62
62
|
];
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @typedef {Object} TablePluginOptions
|
|
66
|
+
* @property {"x"|"y"|"xy"} [scrollType='x'] - Scroll type ('x', 'y', 'xy')
|
|
67
|
+
* @property {"top"|"bottom"} [captionPosition='bottom'] - Caption position ('top', 'bottom')
|
|
68
|
+
* @property {"cell"|"table"} [cellControllerPosition='cell'] - Cell controller position ('cell', 'table')
|
|
69
|
+
* @property {Array} [colorList] - Color list, used in cell color picker
|
|
70
|
+
*/
|
|
71
|
+
|
|
64
72
|
/**
|
|
65
73
|
* @class
|
|
66
74
|
* @description Table Plugin
|
|
@@ -79,14 +87,51 @@ class Table extends EditorInjector {
|
|
|
79
87
|
return dom.check.isTable(node) ? node : null;
|
|
80
88
|
}
|
|
81
89
|
|
|
90
|
+
/** @type {HTMLElement} */
|
|
91
|
+
#figure;
|
|
92
|
+
/** @type {HTMLTableCellElement} */
|
|
93
|
+
#tdElement;
|
|
94
|
+
/** @type {HTMLTableRowElement} */
|
|
95
|
+
#trElement;
|
|
96
|
+
/** @type {HTMLTableRowElement[]|HTMLCollectionOf<HTMLTableRowElement>} */
|
|
97
|
+
#trElements;
|
|
98
|
+
/** @type {HTMLTableElement} */
|
|
99
|
+
#selectedTable;
|
|
100
|
+
/** @type {HTMLTableCellElement} */
|
|
101
|
+
#fixedCell;
|
|
102
|
+
/** @type {HTMLTableCellElement} */
|
|
103
|
+
#selectedCell;
|
|
104
|
+
/** @type {HTMLTableCellElement[]} */
|
|
105
|
+
#selectedCells;
|
|
106
|
+
#resizing;
|
|
107
|
+
#resizeLine;
|
|
108
|
+
#resizeLinePrev;
|
|
109
|
+
#tableXY;
|
|
110
|
+
#maxWidth;
|
|
111
|
+
#fixedColumn;
|
|
112
|
+
#physical_cellCnt;
|
|
113
|
+
#logical_cellCnt;
|
|
114
|
+
#cellCnt;
|
|
115
|
+
#rowCnt;
|
|
116
|
+
#rowIndex;
|
|
117
|
+
#physical_cellIndex;
|
|
118
|
+
#logical_cellIndex;
|
|
119
|
+
#current_colSpan;
|
|
120
|
+
#current_rowSpan;
|
|
121
|
+
#shift;
|
|
122
|
+
#_s;
|
|
123
|
+
#fixedCellName;
|
|
124
|
+
#ref;
|
|
125
|
+
#bindMultiOn;
|
|
126
|
+
#bindMultiOff;
|
|
127
|
+
#bindShiftOff;
|
|
128
|
+
#bindTouchOff;
|
|
129
|
+
#globalEvents;
|
|
130
|
+
|
|
82
131
|
/**
|
|
83
132
|
* @constructor
|
|
84
133
|
* @param {__se__EditorCore} editor - The root editor instance
|
|
85
|
-
* @param {
|
|
86
|
-
* @param {"x"|"y"|"xy"} [pluginOptions.scrollType='x'] - Scroll type ('x', 'y', 'xy')
|
|
87
|
-
* @param {"top"|"bottom"} [pluginOptions.captionPosition='bottom'] - Caption position ('top', 'bottom')
|
|
88
|
-
* @param {"cell"|"table"} [pluginOptions.cellControllerPosition='cell'] - Cell controller position ('cell', 'table')
|
|
89
|
-
* @param {Array} [pluginOptions.colorList] - Color list, used in cell color picker
|
|
134
|
+
* @param {TablePluginOptions} pluginOptions - Plugin options
|
|
90
135
|
*/
|
|
91
136
|
constructor(editor, pluginOptions) {
|
|
92
137
|
// plugin bisic properties
|
|
@@ -115,12 +160,17 @@ class Table extends EditorInjector {
|
|
|
115
160
|
});
|
|
116
161
|
|
|
117
162
|
// members - Controller
|
|
118
|
-
this.controller_cell = new Controller(this, controller_cell.html, { position: this.cellControllerTop ? 'top' : 'bottom' });
|
|
119
|
-
this.controller_table = new Controller(this, controller_table, { position: 'top' });
|
|
120
163
|
if (this.cellControllerTop) {
|
|
164
|
+
this.controller_cell = new Controller(this, controller_cell.html, { position: 'top' });
|
|
165
|
+
this.controller_table = new Controller(this, controller_table, { position: 'top' });
|
|
121
166
|
this.controller_cell.sibling = this.controller_table.form;
|
|
122
|
-
this.
|
|
167
|
+
this.controller_table.sibling = this.controller_cell.form;
|
|
168
|
+
this.controller_table.siblingMain = true;
|
|
169
|
+
} else {
|
|
170
|
+
this.controller_table = new Controller(this, controller_table, { position: 'top' });
|
|
171
|
+
this.controller_cell = new Controller(this, controller_cell.html, { position: 'bottom' });
|
|
123
172
|
}
|
|
173
|
+
|
|
124
174
|
// props
|
|
125
175
|
const propsTargetForms = [this.controller_table.form, this.controller_cell.form];
|
|
126
176
|
this.controller_props = new Controller(this, controller_props.html, { position: 'bottom', parents: propsTargetForms, isInsideForm: true });
|
|
@@ -239,59 +289,49 @@ class Table extends EditorInjector {
|
|
|
239
289
|
/** @type {HTMLButtonElement} */
|
|
240
290
|
this.unmergeButton = controller_cell.unmergeButton;
|
|
241
291
|
|
|
242
|
-
// members - private
|
|
243
|
-
this._resizing = false;
|
|
244
|
-
this._resizeLine = null;
|
|
245
|
-
this._resizeLinePrev = null;
|
|
246
|
-
|
|
247
|
-
/** @type {HTMLElement} */
|
|
248
|
-
this._figure = null;
|
|
249
292
|
/**
|
|
250
293
|
* @description Same value a "this._selectedTable", but it maintain prev table element
|
|
251
294
|
* @type {HTMLTableElement}
|
|
252
295
|
*/
|
|
253
296
|
this._element = null;
|
|
254
|
-
/** @type {HTMLTableCellElement} */
|
|
255
|
-
this._tdElement = null;
|
|
256
|
-
/** @type {HTMLTableRowElement} */
|
|
257
|
-
this._trElement = null;
|
|
258
|
-
/** @type {HTMLTableRowElement[]|HTMLCollectionOf<HTMLTableRowElement>} */
|
|
259
|
-
this._trElements = null;
|
|
260
|
-
|
|
261
|
-
this._tableXY = [];
|
|
262
|
-
this._maxWidth = true;
|
|
263
|
-
this._fixedColumn = false;
|
|
264
|
-
this._physical_cellCnt = 0;
|
|
265
|
-
this._logical_cellCnt = 0;
|
|
266
|
-
this._cellCnt = 0;
|
|
267
|
-
this._rowCnt = 0;
|
|
268
|
-
this._rowIndex = 0;
|
|
269
|
-
this._physical_cellIndex = 0;
|
|
270
|
-
this._logical_cellIndex = 0;
|
|
271
|
-
this._current_colSpan = 0;
|
|
272
|
-
this._current_rowSpan = 0;
|
|
273
297
|
|
|
274
|
-
//
|
|
275
|
-
|
|
276
|
-
this
|
|
277
|
-
|
|
278
|
-
this
|
|
279
|
-
|
|
280
|
-
this
|
|
281
|
-
|
|
282
|
-
this
|
|
298
|
+
// members - private
|
|
299
|
+
this.#resizing = false;
|
|
300
|
+
this.#resizeLine = null;
|
|
301
|
+
this.#resizeLinePrev = null;
|
|
302
|
+
this.#figure = null;
|
|
303
|
+
this.#tdElement = null;
|
|
304
|
+
this.#trElement = null;
|
|
305
|
+
this.#trElements = null;
|
|
306
|
+
this.#tableXY = [];
|
|
307
|
+
this.#maxWidth = true;
|
|
308
|
+
this.#fixedColumn = false;
|
|
309
|
+
this.#physical_cellCnt = 0;
|
|
310
|
+
this.#logical_cellCnt = 0;
|
|
311
|
+
this.#cellCnt = 0;
|
|
312
|
+
this.#rowCnt = 0;
|
|
313
|
+
this.#rowIndex = 0;
|
|
314
|
+
this.#physical_cellIndex = 0;
|
|
315
|
+
this.#logical_cellIndex = 0;
|
|
316
|
+
this.#current_colSpan = 0;
|
|
317
|
+
this.#current_rowSpan = 0;
|
|
283
318
|
|
|
284
|
-
|
|
285
|
-
this
|
|
286
|
-
this
|
|
287
|
-
this
|
|
319
|
+
// member - multi selecte
|
|
320
|
+
this.#selectedTable = null;
|
|
321
|
+
this.#fixedCell = null;
|
|
322
|
+
this.#selectedCell = null;
|
|
323
|
+
this.#selectedCells = null;
|
|
324
|
+
this.#shift = false;
|
|
325
|
+
this.#_s = false;
|
|
326
|
+
this.#fixedCellName = null;
|
|
327
|
+
this.#ref = null;
|
|
288
328
|
|
|
289
329
|
// member - global events
|
|
290
|
-
this
|
|
291
|
-
this
|
|
292
|
-
this
|
|
293
|
-
this
|
|
294
|
-
this
|
|
330
|
+
this.#bindMultiOn = this.#OnCellMultiSelect.bind(this);
|
|
331
|
+
this.#bindMultiOff = this.#OffCellMultiSelect.bind(this);
|
|
332
|
+
this.#bindShiftOff = this.#OffCellShift.bind(this);
|
|
333
|
+
this.#bindTouchOff = this.#OffCellTouch.bind(this);
|
|
334
|
+
this.#globalEvents = {
|
|
295
335
|
on: null,
|
|
296
336
|
off: null,
|
|
297
337
|
shiftOff: null,
|
|
@@ -314,8 +354,8 @@ class Table extends EditorInjector {
|
|
|
314
354
|
*/
|
|
315
355
|
action() {
|
|
316
356
|
const oTable = dom.utils.createElement('TABLE');
|
|
317
|
-
const x = this
|
|
318
|
-
const y = this
|
|
357
|
+
const x = this.#tableXY[0];
|
|
358
|
+
const y = this.#tableXY[1];
|
|
319
359
|
|
|
320
360
|
const body = `<tbody>${`<tr>${CreateCellsString('td', x)}</tr>`.repeat(y)}</tbody>`;
|
|
321
361
|
const colGroup = `<colgroup>${`<col style="width: ${numbers.get(100 / x, CELL_DECIMAL_END)}%;">`.repeat(x)}</colgroup>`;
|
|
@@ -327,10 +367,11 @@ class Table extends EditorInjector {
|
|
|
327
367
|
scrollTypeClass = ` se-scroll-figure-${this.figureScroll}`;
|
|
328
368
|
}
|
|
329
369
|
|
|
330
|
-
const figure = dom.utils.createElement('FIGURE', { class: 'se-flex-component se-input-component' + scrollTypeClass });
|
|
370
|
+
const figure = dom.utils.createElement('FIGURE', { class: 'se-flex-component se-input-component' + scrollTypeClass, style: 'width: 100%;' });
|
|
331
371
|
figure.appendChild(oTable);
|
|
372
|
+
this.#maxWidth = true;
|
|
332
373
|
|
|
333
|
-
if (this.component.insert(figure, {
|
|
374
|
+
if (this.component.insert(figure, { insertBehavior: 'none' })) {
|
|
334
375
|
this._resetTablePicker();
|
|
335
376
|
const target = oTable.querySelector('td div');
|
|
336
377
|
this.selection.setRange(target, 0, target, 0);
|
|
@@ -344,27 +385,52 @@ class Table extends EditorInjector {
|
|
|
344
385
|
*/
|
|
345
386
|
select(target) {
|
|
346
387
|
this._figureOpen(target);
|
|
347
|
-
if (!this
|
|
388
|
+
if (!this.#figure) this.setTableInfo(target);
|
|
348
389
|
|
|
349
|
-
|
|
350
|
-
this
|
|
351
|
-
this
|
|
352
|
-
this._setTableStyle(this._maxWidth ? 'width|column' : 'width', true);
|
|
390
|
+
this.#maxWidth = this.#figure?.style.width === '100%';
|
|
391
|
+
this.#fixedColumn = dom.utils.hasClass(target, 'se-table-layout-fixed') || target.style.tableLayout === 'fixed';
|
|
392
|
+
this.#setTableStyle(this.#maxWidth ? 'width|column' : 'width', true);
|
|
353
393
|
|
|
354
394
|
if (_DragHandle.get('__overInfo') === ON_OVER_COMPONENT) return;
|
|
355
395
|
|
|
356
|
-
if (!this
|
|
357
|
-
this.setCellInfo(this
|
|
396
|
+
if (!this.#tdElement) return;
|
|
397
|
+
this.setCellInfo(this.#tdElement, true);
|
|
358
398
|
|
|
359
399
|
// controller open
|
|
360
|
-
const btnDisabled = this
|
|
400
|
+
const btnDisabled = this.#selectedCells?.length > 1;
|
|
361
401
|
const figureEl = dom.query.getParentElement(target, dom.check.isFigure);
|
|
362
402
|
this.controller_table.open(figureEl, null, { isWWTarget: false, initMethod: null, addOffset: null, disabled: btnDisabled });
|
|
363
403
|
|
|
364
|
-
if (!this
|
|
404
|
+
if (!this.#fixedCell) return;
|
|
365
405
|
|
|
366
|
-
this
|
|
367
|
-
this.controller_cell.open(this
|
|
406
|
+
this.#setUnMergeButton();
|
|
407
|
+
this.controller_cell.open(this.#tdElement, this.cellControllerTop ? figureEl : null, { isWWTarget: false, initMethod: null, addOffset: null, disabled: btnDisabled });
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* @editorMethod Editor.Component
|
|
412
|
+
* @description Method to delete a component of a plugin, called by the "FileManager", "Controller" module.
|
|
413
|
+
* @param {HTMLElement} target Target element
|
|
414
|
+
* @returns {Promise<void>}
|
|
415
|
+
*/
|
|
416
|
+
destroy(target) {
|
|
417
|
+
if (!target) return;
|
|
418
|
+
|
|
419
|
+
const emptyDiv = target.parentNode;
|
|
420
|
+
dom.utils.removeItem(target);
|
|
421
|
+
|
|
422
|
+
this._closeTableSelectInfo();
|
|
423
|
+
|
|
424
|
+
if (emptyDiv !== this.frameContext.get('wysiwyg'))
|
|
425
|
+
this.nodeTransform.removeAllParents(
|
|
426
|
+
emptyDiv,
|
|
427
|
+
function (current) {
|
|
428
|
+
return current.childNodes.length === 0;
|
|
429
|
+
},
|
|
430
|
+
null
|
|
431
|
+
);
|
|
432
|
+
this.editor.focus();
|
|
433
|
+
this.history.push(false);
|
|
368
434
|
}
|
|
369
435
|
|
|
370
436
|
/**
|
|
@@ -423,14 +489,74 @@ class Table extends EditorInjector {
|
|
|
423
489
|
query: 'table',
|
|
424
490
|
method: (element) => {
|
|
425
491
|
const ColgroupEl = element.querySelector('colgroup');
|
|
426
|
-
let FigureEl = dom.check.isFigure(element.parentNode) ? element.parentNode : null;
|
|
427
|
-
if (ColgroupEl && FigureEl) return;
|
|
492
|
+
let FigureEl = /** @type {HTMLElement} */ (dom.check.isFigure(element.parentNode) ? element.parentNode : null);
|
|
428
493
|
|
|
429
494
|
// create colgroup
|
|
430
495
|
if (!ColgroupEl) {
|
|
431
|
-
const
|
|
432
|
-
const
|
|
496
|
+
const rows = element.rows;
|
|
497
|
+
const maxColumnCount = GetMaxColumns(element);
|
|
498
|
+
const colWidths = new Array(maxColumnCount).fill(null);
|
|
499
|
+
|
|
500
|
+
for (let r = 0, rLen = rows.length, cellsCount; r < rLen; r++) {
|
|
501
|
+
const cellsInRow = rows[r].cells;
|
|
502
|
+
cellsCount = cellsInRow.length;
|
|
503
|
+
let currentLogicalCol = 0;
|
|
504
|
+
const rowColOccupancy = new Array(maxColumnCount).fill(false);
|
|
505
|
+
|
|
506
|
+
for (let c = 0; c < cellsCount; c++) {
|
|
507
|
+
const cell = cellsInRow[c];
|
|
508
|
+
const cellWidth = cell.style.width;
|
|
509
|
+
const colSpan = cell.colSpan || 1;
|
|
510
|
+
|
|
511
|
+
while (currentLogicalCol < maxColumnCount && rowColOccupancy[currentLogicalCol]) {
|
|
512
|
+
currentLogicalCol++;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (currentLogicalCol >= maxColumnCount) break;
|
|
516
|
+
if (cellWidth && !colWidths[currentLogicalCol]) colWidths[currentLogicalCol] = cellWidth;
|
|
517
|
+
|
|
518
|
+
for (let i = 0; i < colSpan; i++) {
|
|
519
|
+
if (currentLogicalCol + i >= maxColumnCount || !cellWidth) continue;
|
|
520
|
+
|
|
521
|
+
rowColOccupancy[currentLogicalCol + i] = true;
|
|
522
|
+
const currentPxWidth = parseFloat(cellWidth);
|
|
523
|
+
|
|
524
|
+
for (let j = 0; j < colSpan; j++) {
|
|
525
|
+
const targetColIndex = currentLogicalCol + j;
|
|
526
|
+
if (targetColIndex >= maxColumnCount) continue;
|
|
527
|
+
|
|
528
|
+
const existingWidth = colWidths[targetColIndex];
|
|
529
|
+
if (existingWidth === null) {
|
|
530
|
+
colWidths[targetColIndex] = `width: ${cellWidth};`;
|
|
531
|
+
} else {
|
|
532
|
+
const existingPxWidth = parseFloat(existingWidth.replace('width: ', '').replace(';', ''));
|
|
533
|
+
if (colSpan === 1 && currentPxWidth !== existingPxWidth) {
|
|
534
|
+
colWidths[targetColIndex] = `width: ${cellWidth};`;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
currentLogicalCol += colSpan;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (cellsCount === maxColumnCount) break;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
const colHTML = [];
|
|
546
|
+
for (let i = 0; i < maxColumnCount; i++) {
|
|
547
|
+
const colStyle = colWidths[i] ? ` style="${colWidths[i]}"` : '';
|
|
548
|
+
colHTML.push(`<col${colStyle}>`);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const colGroup = dom.utils.createElement('colgroup', null, colHTML.join(''));
|
|
433
552
|
element.insertBefore(colGroup, element.firstElementChild);
|
|
553
|
+
|
|
554
|
+
for (let r = 0; r < rows.length; r++) {
|
|
555
|
+
const cellsInRow = rows[r].cells;
|
|
556
|
+
for (let c = 0; c < cellsInRow.length; c++) {
|
|
557
|
+
dom.utils.setStyle(cellsInRow[c], 'width', '');
|
|
558
|
+
}
|
|
559
|
+
}
|
|
434
560
|
}
|
|
435
561
|
|
|
436
562
|
// figure
|
|
@@ -442,6 +568,13 @@ class Table extends EditorInjector {
|
|
|
442
568
|
dom.utils.addClass(FigureEl, 'se-flex-component|se-input-component');
|
|
443
569
|
}
|
|
444
570
|
|
|
571
|
+
// table width
|
|
572
|
+
const tableWidth = element.style.width;
|
|
573
|
+
if (tableWidth) {
|
|
574
|
+
FigureEl.style.width = tableWidth === 'auto' ? 'max-content' : tableWidth;
|
|
575
|
+
dom.utils.setStyle(element, 'width', '');
|
|
576
|
+
}
|
|
577
|
+
|
|
445
578
|
// scroll
|
|
446
579
|
if (!this.figureScroll) {
|
|
447
580
|
dom.utils.removeClass(FigureEl, this.figureScrollList.join('|'));
|
|
@@ -471,11 +604,11 @@ class Table extends EditorInjector {
|
|
|
471
604
|
* @param {__se__PluginMouseEventInfo} params
|
|
472
605
|
*/
|
|
473
606
|
onMouseMove({ event }) {
|
|
474
|
-
if (this
|
|
607
|
+
if (this.#resizing) return;
|
|
475
608
|
|
|
476
609
|
const eventTarget = dom.query.getEventTarget(event);
|
|
477
610
|
const target = dom.query.getParentElement(eventTarget, IsResizeEls);
|
|
478
|
-
if (!target ||
|
|
611
|
+
if (!target || event.buttons === 1) {
|
|
479
612
|
this.__hideResizeLine();
|
|
480
613
|
return;
|
|
481
614
|
}
|
|
@@ -484,10 +617,10 @@ class Table extends EditorInjector {
|
|
|
484
617
|
if (cellEdge.is) {
|
|
485
618
|
if (this._element) this._element.style.cursor = '';
|
|
486
619
|
this.__removeGlobalEvents();
|
|
487
|
-
if (this
|
|
488
|
-
this
|
|
489
|
-
this._setResizeLinePosition(dom.query.getParentElement(target, dom.check.isTable), target, this
|
|
490
|
-
this.
|
|
620
|
+
if (this.#resizeLine?.style.display === 'block') this.#resizeLine.style.display = 'none';
|
|
621
|
+
this.#resizeLine = this.frameContext.get('wrapper').querySelector(RESIZE_CELL_CLASS);
|
|
622
|
+
this._setResizeLinePosition(dom.query.getParentElement(target, dom.check.isTable), target, this.#resizeLine, cellEdge.isLeft);
|
|
623
|
+
this.#resizeLine.style.display = 'block';
|
|
491
624
|
return;
|
|
492
625
|
}
|
|
493
626
|
|
|
@@ -496,10 +629,10 @@ class Table extends EditorInjector {
|
|
|
496
629
|
this.__removeGlobalEvents();
|
|
497
630
|
this._element = dom.query.getParentElement(target, dom.check.isTable);
|
|
498
631
|
this._element.style.cursor = 'ns-resize';
|
|
499
|
-
if (this
|
|
500
|
-
this
|
|
501
|
-
this._setResizeRowPosition(dom.query.getParentElement(target, dom.check.isTable), target, this
|
|
502
|
-
this.
|
|
632
|
+
if (this.#resizeLine?.style.display === 'block') this.#resizeLine.style.display = 'none';
|
|
633
|
+
this.#resizeLine = this.frameContext.get('wrapper').querySelector(RESIZE_ROW_CLASS);
|
|
634
|
+
this._setResizeRowPosition(dom.query.getParentElement(target, dom.check.isTable), target, this.#resizeLine);
|
|
635
|
+
this.#resizeLine.style.display = 'block';
|
|
503
636
|
return;
|
|
504
637
|
}
|
|
505
638
|
|
|
@@ -512,10 +645,10 @@ class Table extends EditorInjector {
|
|
|
512
645
|
* @description Executes the event function of "scroll".
|
|
513
646
|
*/
|
|
514
647
|
onScroll() {
|
|
515
|
-
if (this
|
|
648
|
+
if (this.#resizeLine?.style.display !== 'block') return;
|
|
516
649
|
// delete resize line position
|
|
517
650
|
if (this._element) this._element.style.cursor = '';
|
|
518
|
-
this.
|
|
651
|
+
this.#resizeLine.style.display = 'none';
|
|
519
652
|
}
|
|
520
653
|
|
|
521
654
|
/**
|
|
@@ -524,7 +657,7 @@ class Table extends EditorInjector {
|
|
|
524
657
|
* @param {__se__PluginMouseEventInfo} params
|
|
525
658
|
*/
|
|
526
659
|
onMouseDown({ event }) {
|
|
527
|
-
this
|
|
660
|
+
this.#ref = this.#selectedCell = null;
|
|
528
661
|
const eventTarget = dom.query.getEventTarget(event);
|
|
529
662
|
const target = /** @type {HTMLTableCellElement} */ (dom.query.getParentElement(eventTarget, IsResizeEls));
|
|
530
663
|
if (!target) return;
|
|
@@ -538,15 +671,15 @@ class Table extends EditorInjector {
|
|
|
538
671
|
try {
|
|
539
672
|
this._deleteStyleSelectedCells();
|
|
540
673
|
this.setCellInfo(target, true);
|
|
541
|
-
const colIndex = this
|
|
674
|
+
const colIndex = this.#logical_cellIndex + this.#current_colSpan - (cellEdge.isLeft ? 1 : 0);
|
|
542
675
|
|
|
543
676
|
// ready
|
|
544
677
|
this.ui.enableBackWrapper('ew-resize');
|
|
545
|
-
|
|
546
|
-
this
|
|
678
|
+
this.#resizeLine ||= this.frameContext.get('wrapper').querySelector(RESIZE_CELL_CLASS);
|
|
679
|
+
this.#resizeLinePrev = this.frameContext.get('wrapper').querySelector(RESIZE_CELL_PREV_CLASS);
|
|
547
680
|
|
|
548
681
|
// select figure
|
|
549
|
-
if (colIndex < 0 || colIndex === this
|
|
682
|
+
if (colIndex < 0 || colIndex === this.#logical_cellCnt - 1) {
|
|
550
683
|
this._startFigureResizing(cellEdge.startX, colIndex < 0);
|
|
551
684
|
return;
|
|
552
685
|
}
|
|
@@ -558,7 +691,7 @@ class Table extends EditorInjector {
|
|
|
558
691
|
console.warn('[SUNEDITOR.plugins.table.error]', err);
|
|
559
692
|
this.__removeGlobalEvents();
|
|
560
693
|
} finally {
|
|
561
|
-
this
|
|
694
|
+
this.#fixedCell = this.#selectedCell = null;
|
|
562
695
|
}
|
|
563
696
|
|
|
564
697
|
return;
|
|
@@ -582,8 +715,8 @@ class Table extends EditorInjector {
|
|
|
582
715
|
|
|
583
716
|
// ready
|
|
584
717
|
this.ui.enableBackWrapper('ns-resize');
|
|
585
|
-
|
|
586
|
-
this
|
|
718
|
+
this.#resizeLine ||= this.frameContext.get('wrapper').querySelector(RESIZE_ROW_CLASS);
|
|
719
|
+
this.#resizeLinePrev = this.frameContext.get('wrapper').querySelector(RESIZE_ROW_PREV_CLASS);
|
|
587
720
|
|
|
588
721
|
this._startRowResizing(row, rowEdge.startY, numbers.get(_w.getComputedStyle(row).height, CELL_DECIMAL_END));
|
|
589
722
|
this._toggleEditor(false);
|
|
@@ -591,13 +724,13 @@ class Table extends EditorInjector {
|
|
|
591
724
|
console.warn('[SUNEDITOR.plugins.table.error]', err);
|
|
592
725
|
this.__removeGlobalEvents();
|
|
593
726
|
} finally {
|
|
594
|
-
this
|
|
727
|
+
this.#fixedCell = this.#selectedCell = null;
|
|
595
728
|
}
|
|
596
729
|
|
|
597
730
|
return;
|
|
598
731
|
}
|
|
599
732
|
|
|
600
|
-
if (this
|
|
733
|
+
if (this.#shift && target !== this.#fixedCell) return;
|
|
601
734
|
|
|
602
735
|
this._deleteStyleSelectedCells();
|
|
603
736
|
if (/^TR$/i.test(target.nodeName)) return;
|
|
@@ -610,9 +743,9 @@ class Table extends EditorInjector {
|
|
|
610
743
|
* @description Executes the event function of "mouseup".
|
|
611
744
|
*/
|
|
612
745
|
onMouseUp() {
|
|
613
|
-
this
|
|
614
|
-
if (
|
|
615
|
-
this.controller_cell.resetPosition(this
|
|
746
|
+
this.#shift = false;
|
|
747
|
+
if (this.cellControllerTop && this.controller_cell.isOpen) {
|
|
748
|
+
this.controller_cell.resetPosition(this.#fixedCell);
|
|
616
749
|
}
|
|
617
750
|
}
|
|
618
751
|
|
|
@@ -630,17 +763,17 @@ class Table extends EditorInjector {
|
|
|
630
763
|
* @param {__se__PluginKeyEventInfo} params
|
|
631
764
|
*/
|
|
632
765
|
onKeyDown({ event, range, line }) {
|
|
633
|
-
this
|
|
766
|
+
this.#ref = null;
|
|
634
767
|
|
|
635
768
|
const keyCode = event.code;
|
|
636
769
|
const isTab = keyCodeMap.isTab(keyCode);
|
|
637
|
-
if (this.editor.selectMenuOn || this
|
|
770
|
+
if (this.editor.selectMenuOn || this.#resizing || (!isTab && this.#_s) || keyCodeMap.isCtrl(event)) return;
|
|
638
771
|
|
|
639
772
|
if (!this.cellControllerTop) {
|
|
640
773
|
this.controller_cell.hide();
|
|
641
774
|
}
|
|
642
775
|
|
|
643
|
-
this
|
|
776
|
+
this.#_s = keyCodeMap.isShift(event);
|
|
644
777
|
|
|
645
778
|
// table tabkey
|
|
646
779
|
if (isTab) {
|
|
@@ -649,19 +782,19 @@ class Table extends EditorInjector {
|
|
|
649
782
|
if (tableCell && range.collapsed && dom.check.isEdgePoint(range.startContainer, range.startOffset)) {
|
|
650
783
|
this._closeController();
|
|
651
784
|
|
|
652
|
-
const shift = this
|
|
653
|
-
this
|
|
785
|
+
const shift = this.#_s;
|
|
786
|
+
this.#shift = this.#_s = false;
|
|
654
787
|
|
|
655
788
|
/** @type {HTMLTableElement} */
|
|
656
789
|
const table = dom.query.getParentElement(tableCell, 'table');
|
|
657
790
|
/** @type {HTMLTableCellElement[]} */
|
|
658
|
-
const cells = dom.query.getListChildren(table, dom.check.isTableCell);
|
|
791
|
+
const cells = dom.query.getListChildren(table, dom.check.isTableCell, null);
|
|
659
792
|
const idx = shift ? dom.utils.prevIndex(cells, tableCell) : dom.utils.nextIndex(cells, tableCell);
|
|
660
793
|
|
|
661
794
|
if (idx === cells.length && !shift) {
|
|
662
795
|
if (!dom.query.getParentElement(tableCell, 'thead')) {
|
|
663
796
|
const rows = table.rows;
|
|
664
|
-
const newRow = this.insertBodyRow(table, rows.length, this
|
|
797
|
+
const newRow = this.insertBodyRow(table, rows.length, this.#cellCnt);
|
|
665
798
|
const firstTd = newRow.querySelector('td div');
|
|
666
799
|
this.selection.setRange(firstTd, 0, firstTd, 0);
|
|
667
800
|
}
|
|
@@ -700,12 +833,12 @@ class Table extends EditorInjector {
|
|
|
700
833
|
return;
|
|
701
834
|
}
|
|
702
835
|
|
|
703
|
-
if (this
|
|
836
|
+
if (this.#shift || this.#ref) return;
|
|
704
837
|
|
|
705
|
-
cell
|
|
838
|
+
cell ||= /** @type {HTMLTableCellElement} */ (dom.query.getParentElement(line, dom.check.isTableCell));
|
|
706
839
|
if (cell) {
|
|
707
|
-
this
|
|
708
|
-
this
|
|
840
|
+
this.#_s = false;
|
|
841
|
+
this.#fixedCell = cell;
|
|
709
842
|
this._closeController();
|
|
710
843
|
this.#StyleSelectCells(cell, event.shiftKey);
|
|
711
844
|
return false;
|
|
@@ -718,13 +851,13 @@ class Table extends EditorInjector {
|
|
|
718
851
|
* @param {__se__PluginKeyEventInfo} params
|
|
719
852
|
*/
|
|
720
853
|
onKeyUp({ line }) {
|
|
721
|
-
this
|
|
722
|
-
if (this
|
|
854
|
+
this.#_s = false;
|
|
855
|
+
if (this.#shift && dom.query.getParentElement(line, dom.check.isTableCell) === this.#fixedCell) {
|
|
723
856
|
this._deleteStyleSelectedCells();
|
|
724
857
|
this._toggleEditor(true);
|
|
725
858
|
this.__removeGlobalEvents();
|
|
726
859
|
}
|
|
727
|
-
this
|
|
860
|
+
this.#shift = false;
|
|
728
861
|
}
|
|
729
862
|
|
|
730
863
|
/**
|
|
@@ -766,7 +899,7 @@ class Table extends EditorInjector {
|
|
|
766
899
|
this.selectMenu_column.open();
|
|
767
900
|
break;
|
|
768
901
|
case 'onrow':
|
|
769
|
-
this.selectMenu_row.menus[0].style.display = this.selectMenu_row.menus[1].style.display = /^TH$/i.test(this
|
|
902
|
+
this.selectMenu_row.menus[0].style.display = this.selectMenu_row.menus[1].style.display = /^TH$/i.test(this.#tdElement?.nodeName) ? 'none' : '';
|
|
770
903
|
this.selectMenu_row.open();
|
|
771
904
|
break;
|
|
772
905
|
case 'openTableProperties':
|
|
@@ -814,14 +947,11 @@ class Table extends EditorInjector {
|
|
|
814
947
|
// alignment
|
|
815
948
|
this._setAlignProps(this.propTargets.cell_alignment, this._propsAlignCache, true);
|
|
816
949
|
this._setAlignProps(this.propTargets.cell_alignment_vertical, this._propsVerticalAlignCache, true);
|
|
817
|
-
if (dom.check.isTable(propsCache[0][0]) && this
|
|
818
|
-
this.
|
|
950
|
+
if (dom.check.isTable(propsCache[0][0]) && this.#figure) {
|
|
951
|
+
this.#figure.style.float = this._propsAlignCache;
|
|
819
952
|
}
|
|
820
953
|
break;
|
|
821
954
|
}
|
|
822
|
-
case 'close_props':
|
|
823
|
-
this.controller_props.close();
|
|
824
|
-
break;
|
|
825
955
|
case 'props_align':
|
|
826
956
|
this._setAlignProps(this.propTargets.cell_alignment, target.getAttribute('data-value'), false);
|
|
827
957
|
break;
|
|
@@ -829,52 +959,43 @@ class Table extends EditorInjector {
|
|
|
829
959
|
this._setAlignProps(this.propTargets.cell_alignment_vertical, target.getAttribute('data-value'), false);
|
|
830
960
|
break;
|
|
831
961
|
case 'merge':
|
|
832
|
-
this.mergeCells(this
|
|
962
|
+
this.mergeCells(this.#selectedCells);
|
|
833
963
|
break;
|
|
834
964
|
case 'unmerge':
|
|
835
|
-
this.unmergeCells(this
|
|
965
|
+
this.unmergeCells(this.#selectedCells);
|
|
836
966
|
break;
|
|
837
967
|
case 'resize':
|
|
838
|
-
this
|
|
839
|
-
this
|
|
968
|
+
this.#maxWidth = !this.#maxWidth;
|
|
969
|
+
this.#setTableStyle('width', false);
|
|
840
970
|
this._historyPush();
|
|
841
|
-
|
|
971
|
+
_w.setTimeout(() => {
|
|
972
|
+
this.component.select(this._element, Table.key, { isInput: true });
|
|
973
|
+
}, 0);
|
|
842
974
|
break;
|
|
843
975
|
case 'layout':
|
|
844
|
-
this
|
|
845
|
-
this
|
|
976
|
+
this.#fixedColumn = !this.#fixedColumn;
|
|
977
|
+
this.#setTableStyle('column', false);
|
|
846
978
|
this._historyPush();
|
|
847
|
-
|
|
979
|
+
_w.setTimeout(() => {
|
|
980
|
+
this.component.select(this._element, Table.key, { isInput: true });
|
|
981
|
+
}, 0);
|
|
848
982
|
break;
|
|
849
983
|
case 'copy':
|
|
850
|
-
this.component.copy(this
|
|
984
|
+
this.component.copy(this.#figure);
|
|
851
985
|
break;
|
|
852
986
|
case 'remove': {
|
|
853
|
-
|
|
854
|
-
dom.utils.removeItem(this._figure);
|
|
855
|
-
|
|
856
|
-
this._closeTableSelectInfo();
|
|
857
|
-
|
|
858
|
-
if (emptyDiv !== this.editor.frameContext.get('wysiwyg'))
|
|
859
|
-
this.nodeTransform.removeAllParents(
|
|
860
|
-
emptyDiv,
|
|
861
|
-
function (current) {
|
|
862
|
-
return current.childNodes.length === 0;
|
|
863
|
-
},
|
|
864
|
-
null
|
|
865
|
-
);
|
|
866
|
-
this.editor.focus();
|
|
867
|
-
this.history.push(false);
|
|
987
|
+
this.destroy(this.#figure);
|
|
868
988
|
}
|
|
869
989
|
}
|
|
870
990
|
|
|
991
|
+
// [close_props]
|
|
871
992
|
if (!/(^props_|^revert|Properties$)/.test(command)) {
|
|
872
993
|
this.controller_props.close();
|
|
873
994
|
this.controller_colorPicker.close();
|
|
874
995
|
}
|
|
875
996
|
|
|
876
997
|
if (!/^(remove|props_|on|open|merge)/.test(command)) {
|
|
877
|
-
this._setCellControllerPosition(this
|
|
998
|
+
this._setCellControllerPosition(this.#tdElement, this.#shift);
|
|
878
999
|
}
|
|
879
1000
|
}
|
|
880
1001
|
|
|
@@ -887,30 +1008,30 @@ class Table extends EditorInjector {
|
|
|
887
1008
|
this._deleteStyleSelectedCells();
|
|
888
1009
|
this._toggleEditor(true);
|
|
889
1010
|
|
|
890
|
-
this._figure = null;
|
|
891
1011
|
this._element = null;
|
|
892
|
-
this
|
|
893
|
-
this
|
|
894
|
-
this
|
|
895
|
-
this
|
|
896
|
-
this
|
|
897
|
-
this
|
|
898
|
-
this
|
|
899
|
-
this
|
|
900
|
-
this
|
|
901
|
-
this
|
|
902
|
-
this
|
|
903
|
-
this
|
|
904
|
-
this
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
this
|
|
908
|
-
this
|
|
909
|
-
this
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
this
|
|
913
|
-
this
|
|
1012
|
+
this.#figure = null;
|
|
1013
|
+
this.#trElement = null;
|
|
1014
|
+
this.#trElements = null;
|
|
1015
|
+
this.#tableXY = [];
|
|
1016
|
+
this.#maxWidth = false;
|
|
1017
|
+
this.#fixedColumn = false;
|
|
1018
|
+
this.#physical_cellCnt = 0;
|
|
1019
|
+
this.#logical_cellCnt = 0;
|
|
1020
|
+
this.#rowCnt = 0;
|
|
1021
|
+
this.#rowIndex = 0;
|
|
1022
|
+
this.#physical_cellIndex = 0;
|
|
1023
|
+
this.#logical_cellIndex = 0;
|
|
1024
|
+
this.#current_colSpan = 0;
|
|
1025
|
+
this.#current_rowSpan = 0;
|
|
1026
|
+
|
|
1027
|
+
this.#shift = false;
|
|
1028
|
+
this.#selectedCells = null;
|
|
1029
|
+
this.#selectedTable = null;
|
|
1030
|
+
this.#ref = null;
|
|
1031
|
+
|
|
1032
|
+
this.#fixedCell = null;
|
|
1033
|
+
this.#selectedCell = null;
|
|
1034
|
+
this.#fixedCellName = null;
|
|
914
1035
|
|
|
915
1036
|
const { border_format, border_color, border_style, border_width, back_color, font_color, cell_alignment, cell_alignment_vertical, font_bold, font_underline, font_italic, font_strike } = this.propTargets;
|
|
916
1037
|
dom.utils.removeClass([border_format, border_color, border_style, border_width, back_color, font_color, cell_alignment, cell_alignment_vertical, font_bold, font_underline, font_italic, font_strike], 'on');
|
|
@@ -924,11 +1045,11 @@ class Table extends EditorInjector {
|
|
|
924
1045
|
const firstCell = cells[0];
|
|
925
1046
|
const lastCell = dom.query.findVisualLastCell(cells);
|
|
926
1047
|
|
|
927
|
-
this
|
|
928
|
-
this
|
|
929
|
-
this
|
|
930
|
-
this
|
|
931
|
-
this
|
|
1048
|
+
this.#selectedCells = cells;
|
|
1049
|
+
this.#fixedCell = firstCell;
|
|
1050
|
+
this.#selectedCell = lastCell;
|
|
1051
|
+
this.#fixedCellName = firstCell.nodeName;
|
|
1052
|
+
this.#selectedTable = dom.query.getParentElement(firstCell, 'TABLE');
|
|
932
1053
|
|
|
933
1054
|
this._setMultiCells(firstCell, lastCell);
|
|
934
1055
|
}
|
|
@@ -939,8 +1060,8 @@ class Table extends EditorInjector {
|
|
|
939
1060
|
* @returns {HTMLTableElement} The `<table>` element that is the parent of the provided `element`.
|
|
940
1061
|
*/
|
|
941
1062
|
setTableInfo(element) {
|
|
942
|
-
const table = (this._element = this
|
|
943
|
-
this
|
|
1063
|
+
const table = (this._element = this.#selectedTable = dom.query.getParentElement(element, 'TABLE'));
|
|
1064
|
+
this.#figure = dom.query.getParentElement(table, dom.check.isFigure) || table;
|
|
944
1065
|
return /** @type {HTMLTableElement} */ (table);
|
|
945
1066
|
}
|
|
946
1067
|
|
|
@@ -952,8 +1073,8 @@ class Table extends EditorInjector {
|
|
|
952
1073
|
setCellInfo(tdElement, reset) {
|
|
953
1074
|
const table = this.setTableInfo(tdElement);
|
|
954
1075
|
if (!table) return;
|
|
955
|
-
this
|
|
956
|
-
this
|
|
1076
|
+
this.#fixedCell = tdElement;
|
|
1077
|
+
this.#trElement = /** @type {HTMLTableRowElement} */ (tdElement.parentNode);
|
|
957
1078
|
|
|
958
1079
|
// hedaer
|
|
959
1080
|
if (table.querySelector('thead')) dom.utils.addClass(this.headerButton, 'active');
|
|
@@ -963,15 +1084,15 @@ class Table extends EditorInjector {
|
|
|
963
1084
|
if (table.querySelector('caption')) dom.utils.addClass(this.captionButton, 'active');
|
|
964
1085
|
else dom.utils.removeClass(this.captionButton, 'active');
|
|
965
1086
|
|
|
966
|
-
if (reset || this
|
|
967
|
-
if (this
|
|
968
|
-
this
|
|
969
|
-
this
|
|
1087
|
+
if (reset || this.#physical_cellCnt === 0) {
|
|
1088
|
+
if (this.#tdElement !== tdElement) {
|
|
1089
|
+
this.#tdElement = tdElement;
|
|
1090
|
+
this.#trElement = /** @type {HTMLTableRowElement} */ (tdElement.parentNode);
|
|
970
1091
|
}
|
|
971
1092
|
|
|
972
|
-
if (!this
|
|
1093
|
+
if (!this.#selectedCells?.length) this.#selectedCells = [tdElement];
|
|
973
1094
|
|
|
974
|
-
const rows = (this
|
|
1095
|
+
const rows = (this.#trElements = table.rows);
|
|
975
1096
|
const cellIndex = tdElement.cellIndex;
|
|
976
1097
|
|
|
977
1098
|
let cellCnt = 0;
|
|
@@ -980,17 +1101,17 @@ class Table extends EditorInjector {
|
|
|
980
1101
|
}
|
|
981
1102
|
|
|
982
1103
|
// row cnt, row index
|
|
983
|
-
const rowIndex = (this
|
|
984
|
-
this
|
|
1104
|
+
const rowIndex = (this.#rowIndex = this.#trElement.rowIndex);
|
|
1105
|
+
this.#rowCnt = rows.length;
|
|
985
1106
|
|
|
986
1107
|
// cell cnt, physical cell index
|
|
987
|
-
this
|
|
988
|
-
this
|
|
989
|
-
this
|
|
1108
|
+
this.#physical_cellCnt = this.#trElement.cells.length;
|
|
1109
|
+
this.#logical_cellCnt = this.#cellCnt = cellCnt;
|
|
1110
|
+
this.#physical_cellIndex = cellIndex;
|
|
990
1111
|
|
|
991
1112
|
// span
|
|
992
|
-
this
|
|
993
|
-
this
|
|
1113
|
+
this.#current_colSpan = this.#tdElement.colSpan - 1;
|
|
1114
|
+
this.#current_rowSpan = this.#trElement.cells[cellIndex].rowSpan - 1;
|
|
994
1115
|
|
|
995
1116
|
// find logcal cell index
|
|
996
1117
|
let rowSpanArr = [];
|
|
@@ -1030,7 +1151,7 @@ class Table extends EditorInjector {
|
|
|
1030
1151
|
|
|
1031
1152
|
// logcal cell index
|
|
1032
1153
|
if (i === rowIndex && c === cellIndex) {
|
|
1033
|
-
this
|
|
1154
|
+
this.#logical_cellIndex = logcalIndex;
|
|
1034
1155
|
break;
|
|
1035
1156
|
}
|
|
1036
1157
|
|
|
@@ -1063,9 +1184,9 @@ class Table extends EditorInjector {
|
|
|
1063
1184
|
*/
|
|
1064
1185
|
setRowInfo(trElement) {
|
|
1065
1186
|
const table = this.setTableInfo(trElement);
|
|
1066
|
-
const rows = (this
|
|
1067
|
-
this
|
|
1068
|
-
this
|
|
1187
|
+
const rows = (this.#trElements = table.rows);
|
|
1188
|
+
this.#rowCnt = rows.length;
|
|
1189
|
+
this.#rowIndex = trElement.rowIndex;
|
|
1069
1190
|
}
|
|
1070
1191
|
|
|
1071
1192
|
/**
|
|
@@ -1078,16 +1199,16 @@ class Table extends EditorInjector {
|
|
|
1078
1199
|
const isRow = type === 'row';
|
|
1079
1200
|
|
|
1080
1201
|
if (isRow) {
|
|
1081
|
-
const tableAttr = this.
|
|
1202
|
+
const tableAttr = this.#trElement.parentElement;
|
|
1082
1203
|
if (/^THEAD$/i.test(tableAttr.nodeName)) {
|
|
1083
1204
|
if (option === 'up') {
|
|
1084
1205
|
return;
|
|
1085
1206
|
} else if (!tableAttr.nextElementSibling || !/^TBODY$/i.test(tableAttr.nextElementSibling.nodeName)) {
|
|
1086
1207
|
if (!option) {
|
|
1087
|
-
dom.utils.removeItem(this
|
|
1208
|
+
dom.utils.removeItem(this.#figure);
|
|
1088
1209
|
this._closeTableSelectInfo();
|
|
1089
1210
|
} else {
|
|
1090
|
-
table.innerHTML += '<tbody><tr>' + CreateCellsString('td', this
|
|
1211
|
+
table.innerHTML += '<tbody><tr>' + CreateCellsString('td', this.#logical_cellCnt) + '</tr></tbody>';
|
|
1091
1212
|
}
|
|
1092
1213
|
return;
|
|
1093
1214
|
}
|
|
@@ -1095,9 +1216,9 @@ class Table extends EditorInjector {
|
|
|
1095
1216
|
}
|
|
1096
1217
|
|
|
1097
1218
|
// multi
|
|
1098
|
-
if (this
|
|
1099
|
-
const positionCell = this
|
|
1100
|
-
const selectedCells = this
|
|
1219
|
+
if (this.#ref) {
|
|
1220
|
+
const positionCell = this.#tdElement;
|
|
1221
|
+
const selectedCells = this.#selectedCells;
|
|
1101
1222
|
// multi - row
|
|
1102
1223
|
if (isRow) {
|
|
1103
1224
|
// remove row
|
|
@@ -1119,7 +1240,7 @@ class Table extends EditorInjector {
|
|
|
1119
1240
|
}
|
|
1120
1241
|
} else {
|
|
1121
1242
|
// edit row
|
|
1122
|
-
this.setCellInfo(option === 'up' ? selectedCells[0] : selectedCells
|
|
1243
|
+
this.setCellInfo(option === 'up' ? selectedCells[0] : selectedCells.at(-1), true);
|
|
1123
1244
|
this.editRow(option, null, positionCell);
|
|
1124
1245
|
}
|
|
1125
1246
|
} else {
|
|
@@ -1193,12 +1314,12 @@ class Table extends EditorInjector {
|
|
|
1193
1314
|
|
|
1194
1315
|
const remove = !option;
|
|
1195
1316
|
const up = option === 'up';
|
|
1196
|
-
const originRowIndex = this
|
|
1197
|
-
const rowIndex = remove || up ? originRowIndex : originRowIndex + this
|
|
1317
|
+
const originRowIndex = this.#rowIndex;
|
|
1318
|
+
const rowIndex = remove || up ? originRowIndex : originRowIndex + this.#current_rowSpan + 1;
|
|
1198
1319
|
const sign = remove ? -1 : 1;
|
|
1199
1320
|
|
|
1200
|
-
const rows = this
|
|
1201
|
-
let cellCnt = this
|
|
1321
|
+
const rows = this.#trElements;
|
|
1322
|
+
let cellCnt = this.#logical_cellCnt;
|
|
1202
1323
|
|
|
1203
1324
|
for (let i = 0, len = originRowIndex + (remove ? -1 : 0), cell; i <= len; i++) {
|
|
1204
1325
|
cell = rows[i].cells;
|
|
@@ -1269,7 +1390,7 @@ class Table extends EditorInjector {
|
|
|
1269
1390
|
}
|
|
1270
1391
|
|
|
1271
1392
|
if (!remove) {
|
|
1272
|
-
this._setCellControllerPosition(positionResetElement || this
|
|
1393
|
+
this._setCellControllerPosition(positionResetElement || this.#tdElement, true);
|
|
1273
1394
|
} else {
|
|
1274
1395
|
this._closeController();
|
|
1275
1396
|
}
|
|
@@ -1290,10 +1411,10 @@ class Table extends EditorInjector {
|
|
|
1290
1411
|
|
|
1291
1412
|
const remove = !option;
|
|
1292
1413
|
const left = option === 'left';
|
|
1293
|
-
const colSpan = this
|
|
1294
|
-
const cellIndex = remove || left ? this
|
|
1414
|
+
const colSpan = this.#current_colSpan;
|
|
1415
|
+
const cellIndex = remove || left ? this.#logical_cellIndex : this.#logical_cellIndex + colSpan + 1;
|
|
1295
1416
|
|
|
1296
|
-
const rows = this
|
|
1417
|
+
const rows = this.#trElements;
|
|
1297
1418
|
let rowSpanArr = [];
|
|
1298
1419
|
let spanIndex = [];
|
|
1299
1420
|
let passCell = 0;
|
|
@@ -1301,7 +1422,7 @@ class Table extends EditorInjector {
|
|
|
1301
1422
|
const removeCell = [];
|
|
1302
1423
|
const removeSpanArr = [];
|
|
1303
1424
|
|
|
1304
|
-
for (let i = 0, len = this
|
|
1425
|
+
for (let i = 0, len = this.#rowCnt, row, cells, newCell, applySpan, cellColSpan; i < len; i++) {
|
|
1305
1426
|
row = rows[i];
|
|
1306
1427
|
insertIndex = cellIndex;
|
|
1307
1428
|
applySpan = false;
|
|
@@ -1436,7 +1557,7 @@ class Table extends EditorInjector {
|
|
|
1436
1557
|
row = /** @type {HTMLTableRowElement} */ (removeCell[r].parentNode);
|
|
1437
1558
|
dom.utils.removeItem(removeCell[r]);
|
|
1438
1559
|
if (row.cells.length === 0) {
|
|
1439
|
-
|
|
1560
|
+
removeFirst ||= dom.utils.getArrayIndex(rows, row);
|
|
1440
1561
|
removeEnd = dom.utils.getArrayIndex(rows, row);
|
|
1441
1562
|
dom.utils.removeItem(row);
|
|
1442
1563
|
}
|
|
@@ -1449,10 +1570,10 @@ class Table extends EditorInjector {
|
|
|
1449
1570
|
|
|
1450
1571
|
this._closeController();
|
|
1451
1572
|
} else {
|
|
1452
|
-
this._setCellControllerPosition(positionResetElement || this
|
|
1573
|
+
this._setCellControllerPosition(positionResetElement || this.#tdElement, true);
|
|
1453
1574
|
}
|
|
1454
1575
|
|
|
1455
|
-
return positionResetElement || this
|
|
1576
|
+
return positionResetElement || this.#tdElement;
|
|
1456
1577
|
}
|
|
1457
1578
|
|
|
1458
1579
|
/**
|
|
@@ -1520,14 +1641,14 @@ class Table extends EditorInjector {
|
|
|
1520
1641
|
this.setCellInfo(targetTD, true);
|
|
1521
1642
|
|
|
1522
1643
|
const targetInfo = {
|
|
1523
|
-
physicalCellCnt: this
|
|
1524
|
-
logicalCellCnt: this
|
|
1525
|
-
rowCnt: this
|
|
1526
|
-
rowInex: this
|
|
1527
|
-
physicalCellIndex: this
|
|
1528
|
-
logicalCellIndex: this
|
|
1529
|
-
currentColSpan: this
|
|
1530
|
-
currentRowSpan: this
|
|
1644
|
+
physicalCellCnt: this.#physical_cellCnt,
|
|
1645
|
+
logicalCellCnt: this.#logical_cellCnt,
|
|
1646
|
+
rowCnt: this.#rowCnt,
|
|
1647
|
+
rowInex: this.#rowIndex,
|
|
1648
|
+
physicalCellIndex: this.#physical_cellIndex,
|
|
1649
|
+
logicalCellIndex: this.#logical_cellIndex,
|
|
1650
|
+
currentColSpan: this.#current_colSpan,
|
|
1651
|
+
currentRowSpan: this.#current_rowSpan
|
|
1531
1652
|
};
|
|
1532
1653
|
|
|
1533
1654
|
// --- [expand] target table ---
|
|
@@ -1546,7 +1667,7 @@ class Table extends EditorInjector {
|
|
|
1546
1667
|
for (let i = 0; i < addColCnt; i++) {
|
|
1547
1668
|
this.editCell('right', lastCell);
|
|
1548
1669
|
}
|
|
1549
|
-
targetRows = this
|
|
1670
|
+
targetRows = this.#trElements = targetTable.rows;
|
|
1550
1671
|
}
|
|
1551
1672
|
|
|
1552
1673
|
// --- [Un_merge] cells ---
|
|
@@ -1580,7 +1701,7 @@ class Table extends EditorInjector {
|
|
|
1580
1701
|
if (rs > 1 || cs > 1) {
|
|
1581
1702
|
for (let rsOffset = 1; rsOffset < rs; rsOffset++) {
|
|
1582
1703
|
const rowIndex = r + rsOffset;
|
|
1583
|
-
|
|
1704
|
+
un_mergeRowSpanMap[rowIndex] ||= [];
|
|
1584
1705
|
for (let csOffset = 0; csOffset < cs; csOffset++) {
|
|
1585
1706
|
un_mergeRowSpanMap[rowIndex][logicalIndex + csOffset] = true;
|
|
1586
1707
|
}
|
|
@@ -1598,7 +1719,7 @@ class Table extends EditorInjector {
|
|
|
1598
1719
|
|
|
1599
1720
|
if (unmergeCells.length > 0) {
|
|
1600
1721
|
this.unmergeCells(unmergeCells, true);
|
|
1601
|
-
targetRows = this
|
|
1722
|
+
targetRows = this.#trElements = targetTable.rows;
|
|
1602
1723
|
}
|
|
1603
1724
|
|
|
1604
1725
|
// --- [merge] cells ---
|
|
@@ -1621,7 +1742,7 @@ class Table extends EditorInjector {
|
|
|
1621
1742
|
|
|
1622
1743
|
for (let rsOffset = 1; rsOffset < rs; rsOffset++) {
|
|
1623
1744
|
const rowIndex = r + rsOffset;
|
|
1624
|
-
|
|
1745
|
+
copyCowSpanMap[rowIndex] ||= [];
|
|
1625
1746
|
for (let csOffset = 0; csOffset < cs; csOffset++) {
|
|
1626
1747
|
copyCowSpanMap[rowIndex][copyIndex + csOffset] = true;
|
|
1627
1748
|
}
|
|
@@ -1658,7 +1779,7 @@ class Table extends EditorInjector {
|
|
|
1658
1779
|
if (trs > 1) {
|
|
1659
1780
|
for (let rsOffset = 1; rsOffset < trs; rsOffset++) {
|
|
1660
1781
|
const rIndex = targetR + rsOffset;
|
|
1661
|
-
|
|
1782
|
+
targetRowSpanMap[rIndex] ||= [];
|
|
1662
1783
|
for (let i = 0; i < tcs; i++) {
|
|
1663
1784
|
targetRowSpanMap[rIndex][logicalIndex + i] = true;
|
|
1664
1785
|
}
|
|
@@ -1683,11 +1804,11 @@ class Table extends EditorInjector {
|
|
|
1683
1804
|
|
|
1684
1805
|
if (mergeGroups.length > 0) {
|
|
1685
1806
|
for (const mc of mergeGroups) {
|
|
1686
|
-
this
|
|
1687
|
-
this
|
|
1807
|
+
this.#ref = null;
|
|
1808
|
+
this.#trElements = targetTable.rows;
|
|
1688
1809
|
this.mergeCells(mc, true);
|
|
1689
1810
|
}
|
|
1690
|
-
targetRows = this
|
|
1811
|
+
targetRows = this.#trElements = targetTable.rows;
|
|
1691
1812
|
}
|
|
1692
1813
|
|
|
1693
1814
|
// --- [result] paste cell data ---
|
|
@@ -1721,7 +1842,7 @@ class Table extends EditorInjector {
|
|
|
1721
1842
|
if (trs > 1) {
|
|
1722
1843
|
for (let rs = 1; rs < trs; rs++) {
|
|
1723
1844
|
const rr = r + rs;
|
|
1724
|
-
|
|
1845
|
+
rowSpanMap[rr] ||= [];
|
|
1725
1846
|
for (let cs = 0; cs < tcs; cs++) {
|
|
1726
1847
|
rowSpanMap[rr][tLogicalIndex + cs] = true;
|
|
1727
1848
|
}
|
|
@@ -1745,8 +1866,8 @@ class Table extends EditorInjector {
|
|
|
1745
1866
|
|
|
1746
1867
|
// select cell
|
|
1747
1868
|
this.selectCells(selectedCells);
|
|
1748
|
-
this
|
|
1749
|
-
this
|
|
1869
|
+
this.#setMergeSplitButton();
|
|
1870
|
+
this.#setUnMergeButton();
|
|
1750
1871
|
this.#focusEdge(selectedCells[0]);
|
|
1751
1872
|
|
|
1752
1873
|
// history push
|
|
@@ -1778,10 +1899,10 @@ class Table extends EditorInjector {
|
|
|
1778
1899
|
|
|
1779
1900
|
this.setTableInfo(cloneTable);
|
|
1780
1901
|
selectedCells = clonedSelectedCells;
|
|
1781
|
-
this
|
|
1902
|
+
this.#ref = null;
|
|
1782
1903
|
this._setMultiCells(selectedCells[0], dom.query.findVisualLastCell(selectedCells));
|
|
1783
1904
|
|
|
1784
|
-
const ref = this
|
|
1905
|
+
const ref = this.#ref;
|
|
1785
1906
|
const mergeCell = selectedCells[0];
|
|
1786
1907
|
|
|
1787
1908
|
let emptyRowFirst = null;
|
|
@@ -1813,7 +1934,7 @@ class Table extends EditorInjector {
|
|
|
1813
1934
|
}
|
|
1814
1935
|
|
|
1815
1936
|
if (emptyRowFirst) {
|
|
1816
|
-
const rows = this
|
|
1937
|
+
const rows = this.#trElements;
|
|
1817
1938
|
const rowIndexFirst = dom.utils.getArrayIndex(rows, emptyRowFirst);
|
|
1818
1939
|
const rowIndexLast = dom.utils.getArrayIndex(rows, emptyRowLast || emptyRowFirst);
|
|
1819
1940
|
const removeRows = [];
|
|
@@ -1849,7 +1970,7 @@ class Table extends EditorInjector {
|
|
|
1849
1970
|
originTable.replaceWith(cloneTable);
|
|
1850
1971
|
this._closeTableSelectInfo();
|
|
1851
1972
|
|
|
1852
|
-
this
|
|
1973
|
+
this.#setMergeSplitButton();
|
|
1853
1974
|
this._setController(mergeCell);
|
|
1854
1975
|
|
|
1855
1976
|
this.#focusEdge(mergeCell);
|
|
@@ -1869,7 +1990,7 @@ class Table extends EditorInjector {
|
|
|
1869
1990
|
const originTable = selectedCells[0].closest('table');
|
|
1870
1991
|
const { cloneTable, clonedSelectedCells } = skipPostProcess ? { cloneTable: originTable, clonedSelectedCells: selectedCells } : this.#cloneTable(originTable, selectedCells);
|
|
1871
1992
|
|
|
1872
|
-
this
|
|
1993
|
+
this.#ref = null;
|
|
1873
1994
|
this.setTableInfo(cloneTable);
|
|
1874
1995
|
selectedCells = clonedSelectedCells;
|
|
1875
1996
|
|
|
@@ -1913,7 +2034,7 @@ class Table extends EditorInjector {
|
|
|
1913
2034
|
}
|
|
1914
2035
|
}
|
|
1915
2036
|
|
|
1916
|
-
this
|
|
2037
|
+
this.#selectedCells = null;
|
|
1917
2038
|
|
|
1918
2039
|
if (skipPostProcess) return;
|
|
1919
2040
|
|
|
@@ -1926,16 +2047,16 @@ class Table extends EditorInjector {
|
|
|
1926
2047
|
if (firstCell !== lastCell) {
|
|
1927
2048
|
lastCell = !newLastCell || lastCell.closest('tr').rowIndex > newLastCell.closest('tr').rowIndex || lastCell.cellIndex > newLastCell.cellIndex ? lastCell : newLastCell;
|
|
1928
2049
|
this._setMultiCells(firstCell, lastCell);
|
|
1929
|
-
this
|
|
2050
|
+
this.#selectedCells = Array.from(table.querySelectorAll('.se-selected-table-cell'));
|
|
1930
2051
|
} else {
|
|
1931
2052
|
this.setCellInfo(lastCell, true);
|
|
1932
2053
|
}
|
|
1933
2054
|
|
|
1934
|
-
this
|
|
1935
|
-
this
|
|
2055
|
+
this.#fixedCell = firstCell;
|
|
2056
|
+
this.#selectedCell = lastCell;
|
|
1936
2057
|
dom.utils.addClass(lastCell, 'se-selected-cell-focus');
|
|
1937
2058
|
|
|
1938
|
-
this
|
|
2059
|
+
this.#setUnMergeButton();
|
|
1939
2060
|
this.controller_cell.resetPosition(lastCell);
|
|
1940
2061
|
|
|
1941
2062
|
// history push
|
|
@@ -1966,7 +2087,7 @@ class Table extends EditorInjector {
|
|
|
1966
2087
|
|
|
1967
2088
|
if (!active) {
|
|
1968
2089
|
const header = dom.utils.createElement('THEAD');
|
|
1969
|
-
header.innerHTML = '<tr>' + CreateCellsString('th', this
|
|
2090
|
+
header.innerHTML = '<tr>' + CreateCellsString('th', this.#logical_cellCnt) + '</tr>';
|
|
1970
2091
|
table.insertBefore(header, table.firstElementChild);
|
|
1971
2092
|
} else {
|
|
1972
2093
|
dom.utils.removeItem(table.querySelector('thead'));
|
|
@@ -1974,10 +2095,10 @@ class Table extends EditorInjector {
|
|
|
1974
2095
|
|
|
1975
2096
|
dom.utils.toggleClass(btn, 'active');
|
|
1976
2097
|
|
|
1977
|
-
if (/TH/i.test(this.
|
|
2098
|
+
if (/TH/i.test(this.#tdElement.nodeName)) {
|
|
1978
2099
|
this._closeController();
|
|
1979
2100
|
} else {
|
|
1980
|
-
this._setCellControllerPosition(this
|
|
2101
|
+
this._setCellControllerPosition(this.#tdElement, false);
|
|
1981
2102
|
}
|
|
1982
2103
|
}
|
|
1983
2104
|
|
|
@@ -1998,25 +2119,24 @@ class Table extends EditorInjector {
|
|
|
1998
2119
|
}
|
|
1999
2120
|
|
|
2000
2121
|
dom.utils.toggleClass(btn, 'active');
|
|
2001
|
-
this._setCellControllerPosition(this
|
|
2122
|
+
this._setCellControllerPosition(this.#tdElement, false);
|
|
2002
2123
|
}
|
|
2003
2124
|
|
|
2004
2125
|
/**
|
|
2005
|
-
* @private
|
|
2006
2126
|
* @description Updates table styles.
|
|
2007
2127
|
* @param {string} styles - Styles to update.
|
|
2008
2128
|
* @param {boolean} ondisplay - Whether to update display.
|
|
2009
2129
|
*/
|
|
2010
|
-
|
|
2130
|
+
#setTableStyle(styles, ondisplay) {
|
|
2011
2131
|
if (styles.includes('width')) {
|
|
2012
|
-
const targets = this
|
|
2132
|
+
const targets = this.#figure;
|
|
2013
2133
|
if (!targets) return;
|
|
2014
2134
|
|
|
2015
2135
|
let sizeIcon, text;
|
|
2016
|
-
if (!this
|
|
2136
|
+
if (!this.#maxWidth) {
|
|
2017
2137
|
sizeIcon = this.icons.expansion;
|
|
2018
2138
|
text = this.maxText;
|
|
2019
|
-
if (!ondisplay) targets.style.width = '
|
|
2139
|
+
if (!ondisplay) targets.style.width = 'max-content';
|
|
2020
2140
|
} else {
|
|
2021
2141
|
sizeIcon = this.icons.reduction;
|
|
2022
2142
|
text = this.minText;
|
|
@@ -2028,7 +2148,7 @@ class Table extends EditorInjector {
|
|
|
2028
2148
|
}
|
|
2029
2149
|
|
|
2030
2150
|
if (styles.includes('column')) {
|
|
2031
|
-
if (!this
|
|
2151
|
+
if (!this.#fixedColumn) {
|
|
2032
2152
|
dom.utils.removeClass(this._element, 'se-table-layout-fixed');
|
|
2033
2153
|
dom.utils.addClass(this._element, 'se-table-layout-auto');
|
|
2034
2154
|
dom.utils.removeClass(this.columnFixedButton, 'active');
|
|
@@ -2041,11 +2161,10 @@ class Table extends EditorInjector {
|
|
|
2041
2161
|
}
|
|
2042
2162
|
|
|
2043
2163
|
/**
|
|
2044
|
-
* @private
|
|
2045
2164
|
* @description Sets the merge/split button visibility.
|
|
2046
2165
|
*/
|
|
2047
|
-
|
|
2048
|
-
if (!this
|
|
2166
|
+
#setMergeSplitButton() {
|
|
2167
|
+
if (!this.#ref) {
|
|
2049
2168
|
this.splitButton.style.display = 'block';
|
|
2050
2169
|
this.mergeButton.style.display = 'none';
|
|
2051
2170
|
} else {
|
|
@@ -2055,11 +2174,10 @@ class Table extends EditorInjector {
|
|
|
2055
2174
|
}
|
|
2056
2175
|
|
|
2057
2176
|
/**
|
|
2058
|
-
* @private
|
|
2059
2177
|
* @description Sets the unmerge button visibility.
|
|
2060
2178
|
*/
|
|
2061
|
-
|
|
2062
|
-
if (this.findMergedCells(!this
|
|
2179
|
+
#setUnMergeButton() {
|
|
2180
|
+
if (this.findMergedCells(!this.#selectedCells?.length ? [this.#fixedCell] : this.#selectedCells).length > 0) {
|
|
2063
2181
|
this.unmergeButton.disabled = false;
|
|
2064
2182
|
} else {
|
|
2065
2183
|
this.unmergeButton.disabled = true;
|
|
@@ -2072,17 +2190,17 @@ class Table extends EditorInjector {
|
|
|
2072
2190
|
* @param {HTMLTableCellElement} tdElement - The target table cell.
|
|
2073
2191
|
*/
|
|
2074
2192
|
_setController(tdElement) {
|
|
2075
|
-
if (!this.selection.get().isCollapsed && !this
|
|
2193
|
+
if (!this.selection.get().isCollapsed && !this.#selectedCell) {
|
|
2076
2194
|
this._deleteStyleSelectedCells();
|
|
2077
2195
|
return;
|
|
2078
2196
|
}
|
|
2079
2197
|
|
|
2080
|
-
this
|
|
2198
|
+
this.#setUnMergeButton();
|
|
2081
2199
|
|
|
2082
|
-
this
|
|
2083
|
-
if (this
|
|
2084
|
-
if (!this
|
|
2085
|
-
const tableElement = this
|
|
2200
|
+
this.#tdElement = tdElement;
|
|
2201
|
+
if (this.#fixedCell === tdElement) dom.utils.addClass(tdElement, 'se-selected-cell-focus');
|
|
2202
|
+
if (!this.#selectedCells?.length) this.#selectedCells = [tdElement];
|
|
2203
|
+
const tableElement = this.#selectedTable || this._element || dom.query.getParentElement(tdElement, 'TABLE');
|
|
2086
2204
|
this.component.select(tableElement, Table.key, { isInput: true });
|
|
2087
2205
|
}
|
|
2088
2206
|
|
|
@@ -2094,7 +2212,7 @@ class Table extends EditorInjector {
|
|
|
2094
2212
|
*/
|
|
2095
2213
|
_setCellControllerPosition(tdElement, reset) {
|
|
2096
2214
|
this.setCellInfo(tdElement, reset);
|
|
2097
|
-
|
|
2215
|
+
if (!this.cellControllerTop) this.controller_cell.resetPosition(tdElement);
|
|
2098
2216
|
}
|
|
2099
2217
|
|
|
2100
2218
|
/**
|
|
@@ -2113,7 +2231,27 @@ class Table extends EditorInjector {
|
|
|
2113
2231
|
* @param {Node} target - The target figure element.
|
|
2114
2232
|
*/
|
|
2115
2233
|
_figureOpen(target) {
|
|
2116
|
-
this.figure.open(target, { nonResizing: true, nonSizeInfo: true, nonBorder: true, figureTarget: true,
|
|
2234
|
+
this.figure.open(target, { nonResizing: true, nonSizeInfo: true, nonBorder: true, figureTarget: true, infoOnly: false });
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
/**
|
|
2238
|
+
* @private
|
|
2239
|
+
* @description Converts the width of <col> elements to percentages.
|
|
2240
|
+
* @param {HTMLTableElement} target - The target table element.
|
|
2241
|
+
*/
|
|
2242
|
+
_resizePercentCol(target) {
|
|
2243
|
+
const cols = target.querySelector('colgroup').querySelectorAll('col');
|
|
2244
|
+
const tableTotalWidth = target.offsetWidth;
|
|
2245
|
+
|
|
2246
|
+
cols.forEach((col) => {
|
|
2247
|
+
const colWidthString = col.style.width;
|
|
2248
|
+
|
|
2249
|
+
if (!colWidthString.endsWith('%')) {
|
|
2250
|
+
const pixelWidth = col.offsetWidth || numbers.get(colWidthString, CELL_DECIMAL_END);
|
|
2251
|
+
const percentage = (pixelWidth / tableTotalWidth) * 100;
|
|
2252
|
+
col.style.width = percentage + '%';
|
|
2253
|
+
}
|
|
2254
|
+
});
|
|
2117
2255
|
}
|
|
2118
2256
|
|
|
2119
2257
|
/**
|
|
@@ -2125,12 +2263,13 @@ class Table extends EditorInjector {
|
|
|
2125
2263
|
* @param {boolean} isLeftEdge Whether the resizing is on the left edge.
|
|
2126
2264
|
*/
|
|
2127
2265
|
_startCellResizing(col, startX, startWidth, isLeftEdge) {
|
|
2128
|
-
this.
|
|
2129
|
-
this.
|
|
2266
|
+
this._resizePercentCol(this._element);
|
|
2267
|
+
this._setResizeLinePosition(this.#figure, this.#tdElement, this.#resizeLinePrev, isLeftEdge);
|
|
2268
|
+
this.#resizeLinePrev.style.display = 'block';
|
|
2130
2269
|
const prevValue = col.style.width;
|
|
2131
2270
|
const nextCol = /** @type {HTMLElement} */ (col.nextElementSibling);
|
|
2132
2271
|
const nextColPrevValue = nextCol.style.width;
|
|
2133
|
-
const realWidth = dom.utils.hasClass(this._element, 'se-table-layout-fixed') ? nextColPrevValue : converter.getWidthInPercentage(col);
|
|
2272
|
+
const realWidth = dom.utils.hasClass(this._element, 'se-table-layout-fixed') ? nextColPrevValue : converter.getWidthInPercentage(nextCol || col);
|
|
2134
2273
|
|
|
2135
2274
|
if (_DragHandle.get('__dragHandler')) _DragHandle.get('__dragHandler').style.display = 'none';
|
|
2136
2275
|
this._addResizeGlobalEvents(
|
|
@@ -2138,9 +2277,9 @@ class Table extends EditorInjector {
|
|
|
2138
2277
|
this,
|
|
2139
2278
|
col,
|
|
2140
2279
|
nextCol,
|
|
2141
|
-
this
|
|
2142
|
-
this
|
|
2143
|
-
this
|
|
2280
|
+
this.#figure,
|
|
2281
|
+
this.#tdElement,
|
|
2282
|
+
this.#resizeLine,
|
|
2144
2283
|
isLeftEdge,
|
|
2145
2284
|
startX,
|
|
2146
2285
|
startWidth,
|
|
@@ -2150,6 +2289,7 @@ class Table extends EditorInjector {
|
|
|
2150
2289
|
),
|
|
2151
2290
|
() => {
|
|
2152
2291
|
this.__removeGlobalEvents();
|
|
2292
|
+
this._resizePercentCol(this._element);
|
|
2153
2293
|
this.history.push(true);
|
|
2154
2294
|
this.component.select(this._element, Table.key, { isInput: true });
|
|
2155
2295
|
},
|
|
@@ -2197,12 +2337,12 @@ class Table extends EditorInjector {
|
|
|
2197
2337
|
* @param {number} startHeight The initial height of the row.
|
|
2198
2338
|
*/
|
|
2199
2339
|
_startRowResizing(row, startY, startHeight) {
|
|
2200
|
-
this._setResizeRowPosition(this
|
|
2201
|
-
this.
|
|
2340
|
+
this._setResizeRowPosition(this.#figure, row, this.#resizeLinePrev);
|
|
2341
|
+
this.#resizeLinePrev.style.display = 'block';
|
|
2202
2342
|
const prevValue = row.style.height;
|
|
2203
2343
|
|
|
2204
2344
|
this._addResizeGlobalEvents(
|
|
2205
|
-
this._rowResize.bind(this, row, this
|
|
2345
|
+
this._rowResize.bind(this, row, this.#figure, this.#resizeLine, startY, startHeight),
|
|
2206
2346
|
() => {
|
|
2207
2347
|
this.__removeGlobalEvents();
|
|
2208
2348
|
this.history.push(true);
|
|
@@ -2235,16 +2375,17 @@ class Table extends EditorInjector {
|
|
|
2235
2375
|
* @param {boolean} isLeftEdge Whether the resizing is on the left edge.
|
|
2236
2376
|
*/
|
|
2237
2377
|
_startFigureResizing(startX, isLeftEdge) {
|
|
2238
|
-
const figure = this
|
|
2239
|
-
this._setResizeLinePosition(figure, figure, this
|
|
2240
|
-
this.
|
|
2378
|
+
const figure = this.#figure;
|
|
2379
|
+
this._setResizeLinePosition(figure, figure, this.#resizeLinePrev, isLeftEdge);
|
|
2380
|
+
this.#resizeLinePrev.style.display = 'block';
|
|
2241
2381
|
const realWidth = converter.getWidthInPercentage(figure);
|
|
2242
2382
|
|
|
2243
2383
|
if (_DragHandle.get('__dragHandler')) _DragHandle.get('__dragHandler').style.display = 'none';
|
|
2244
2384
|
this._addResizeGlobalEvents(
|
|
2245
|
-
this._figureResize.bind(this, figure, this
|
|
2385
|
+
this._figureResize.bind(this, figure, this.#resizeLine, isLeftEdge, startX, figure.offsetWidth, numbers.get(realWidth, CELL_DECIMAL_END)),
|
|
2246
2386
|
() => {
|
|
2247
2387
|
this.__removeGlobalEvents();
|
|
2388
|
+
if (numbers.get(figure.style.width, 0) > 100) figure.style.width = '100%';
|
|
2248
2389
|
// figure reopen
|
|
2249
2390
|
this.component.select(this._element, Table.key, { isInput: true });
|
|
2250
2391
|
},
|
|
@@ -2328,8 +2469,8 @@ class Table extends EditorInjector {
|
|
|
2328
2469
|
* @description Deletes styles from selected table cells.
|
|
2329
2470
|
*/
|
|
2330
2471
|
_deleteStyleSelectedCells() {
|
|
2331
|
-
dom.utils.removeClass([this
|
|
2332
|
-
const table = this
|
|
2472
|
+
dom.utils.removeClass([this.#fixedCell, this.#selectedCell], 'se-selected-cell-focus');
|
|
2473
|
+
const table = this.#fixedCell?.closest('table');
|
|
2333
2474
|
if (table) {
|
|
2334
2475
|
const selectedCells = table.querySelectorAll('.se-selected-table-cell');
|
|
2335
2476
|
for (let i = 0, len = selectedCells.length; i < len; i++) {
|
|
@@ -2343,8 +2484,8 @@ class Table extends EditorInjector {
|
|
|
2343
2484
|
* @description Restores styles for selected table cells.
|
|
2344
2485
|
*/
|
|
2345
2486
|
_recallStyleSelectedCells() {
|
|
2346
|
-
if (this
|
|
2347
|
-
const selectedCells = this
|
|
2487
|
+
if (this.#selectedCells) {
|
|
2488
|
+
const selectedCells = this.#selectedCells;
|
|
2348
2489
|
for (let i = 0, len = selectedCells.length; i < len; i++) {
|
|
2349
2490
|
dom.utils.addClass(selectedCells[i], 'se-selected-table-cell');
|
|
2350
2491
|
}
|
|
@@ -2359,10 +2500,10 @@ class Table extends EditorInjector {
|
|
|
2359
2500
|
* @param {(...args: *) => void} keyDownFn The function handling the keydown event.
|
|
2360
2501
|
*/
|
|
2361
2502
|
_addResizeGlobalEvents(resizeFn, stopFn, keyDownFn) {
|
|
2362
|
-
this.
|
|
2363
|
-
this.
|
|
2364
|
-
this.
|
|
2365
|
-
this
|
|
2503
|
+
this.#globalEvents.resize = this.eventManager.addGlobalEvent('mousemove', resizeFn, false);
|
|
2504
|
+
this.#globalEvents.resizeStop = this.eventManager.addGlobalEvent('mouseup', stopFn, false);
|
|
2505
|
+
this.#globalEvents.resizeKeyDown = this.eventManager.addGlobalEvent('keydown', keyDownFn, false);
|
|
2506
|
+
this.#resizing = true;
|
|
2366
2507
|
}
|
|
2367
2508
|
|
|
2368
2509
|
/**
|
|
@@ -2371,7 +2512,7 @@ class Table extends EditorInjector {
|
|
|
2371
2512
|
* @param {boolean} enabled Whether to enable or disable the editor.
|
|
2372
2513
|
*/
|
|
2373
2514
|
_toggleEditor(enabled) {
|
|
2374
|
-
const wysiwyg = this.
|
|
2515
|
+
const wysiwyg = this.frameContext.get('wysiwyg');
|
|
2375
2516
|
wysiwyg.setAttribute('contenteditable', enabled.toString());
|
|
2376
2517
|
if (enabled) dom.utils.removeClass(wysiwyg, 'se-disabled');
|
|
2377
2518
|
else dom.utils.addClass(wysiwyg, 'se-disabled');
|
|
@@ -2385,7 +2526,7 @@ class Table extends EditorInjector {
|
|
|
2385
2526
|
_setCtrlProps(type) {
|
|
2386
2527
|
this._typeCache = type;
|
|
2387
2528
|
const isTable = type === 'table';
|
|
2388
|
-
const targets = isTable ? [this._element] : this
|
|
2529
|
+
const targets = isTable ? [this._element] : this.#selectedCells;
|
|
2389
2530
|
if (!targets || targets.length === 0) return;
|
|
2390
2531
|
|
|
2391
2532
|
const { border_format, border_color, border_style, border_width, back_color, font_color, cell_alignment, cell_alignment_vertical, cell_alignment_table_text, font_bold, font_underline, font_italic, font_strike } = this.propTargets;
|
|
@@ -2406,10 +2547,11 @@ class Table extends EditorInjector {
|
|
|
2406
2547
|
underline = /underline/i.test(textDecoration),
|
|
2407
2548
|
strike = /line-through/i.test(textDecoration),
|
|
2408
2549
|
italic = /italic/i.test(fontStyle),
|
|
2409
|
-
align = isTable ? this
|
|
2550
|
+
align = isTable ? this.#figure?.style.float : textAlign,
|
|
2410
2551
|
align_v = verticalAlign;
|
|
2411
2552
|
this._propsCache = [];
|
|
2412
2553
|
|
|
2554
|
+
const tempColorStyles = _w.getComputedStyle(this.eventManager.__focusTemp);
|
|
2413
2555
|
for (let i = 0, t, isBreak; (t = targets[i]); i++) {
|
|
2414
2556
|
// eslint-disable-next-line no-shadow
|
|
2415
2557
|
const { cssText, border, backgroundColor, color, textAlign, verticalAlign, fontWeight, textDecoration, fontStyle } = t.style;
|
|
@@ -2418,12 +2560,24 @@ class Table extends EditorInjector {
|
|
|
2418
2560
|
|
|
2419
2561
|
const { c, s, w } = this._getBorderStyle(border);
|
|
2420
2562
|
|
|
2563
|
+
// colors
|
|
2564
|
+
let hexBackColor = backgroundColor;
|
|
2565
|
+
let hexColor = color;
|
|
2566
|
+
if (hexBackColor) {
|
|
2567
|
+
this.eventManager.__focusTemp.style.backgroundColor = hexBackColor;
|
|
2568
|
+
hexBackColor = tempColorStyles.backgroundColor;
|
|
2569
|
+
}
|
|
2570
|
+
if (hexColor) {
|
|
2571
|
+
this.eventManager.__focusTemp.style.color = hexColor;
|
|
2572
|
+
hexColor = tempColorStyles.color;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2421
2575
|
if (b_color && cellBorder.c !== c) b_color = '';
|
|
2422
2576
|
if (b_style && cellBorder.s !== s) b_style = '';
|
|
2423
2577
|
if (b_width && cellBorder.w !== w) b_width = '';
|
|
2424
|
-
if (backColor !== converter.rgb2hex(
|
|
2425
|
-
if (fontColor !== converter.rgb2hex(
|
|
2426
|
-
if (align !== (isTable ? this
|
|
2578
|
+
if (backColor !== converter.rgb2hex(hexBackColor)) backColor = '';
|
|
2579
|
+
if (fontColor !== converter.rgb2hex(hexColor)) fontColor = '';
|
|
2580
|
+
if (align !== (isTable ? this.#figure?.style.float : textAlign)) align = '';
|
|
2427
2581
|
if (align_v && align_v !== verticalAlign) align_v = '';
|
|
2428
2582
|
if (bold && bold !== /.+/.test(fontWeight)) bold = false;
|
|
2429
2583
|
if (underline && underline !== /underline/i.test(textDecoration)) underline = false;
|
|
@@ -2440,7 +2594,7 @@ class Table extends EditorInjector {
|
|
|
2440
2594
|
dom.utils.removeClass(border_format, 'active');
|
|
2441
2595
|
|
|
2442
2596
|
// border - styles
|
|
2443
|
-
b_style
|
|
2597
|
+
b_style ||= BORDER_LIST[0];
|
|
2444
2598
|
border_style.textContent = b_style;
|
|
2445
2599
|
border_color.style.borderColor = border_color.value = b_color;
|
|
2446
2600
|
border_width.value = b_width;
|
|
@@ -2548,7 +2702,7 @@ class Table extends EditorInjector {
|
|
|
2548
2702
|
target.disabled = true;
|
|
2549
2703
|
|
|
2550
2704
|
const isTable = this.controller_table.form.contains(this.controller_props.currentTarget);
|
|
2551
|
-
const targets = isTable ? [this._element] : this
|
|
2705
|
+
const targets = isTable ? [this._element] : this.#selectedCells;
|
|
2552
2706
|
const tr = /** @type {HTMLTableCellElement} */ (targets[0]);
|
|
2553
2707
|
const trStyles = _w.getComputedStyle(tr);
|
|
2554
2708
|
const { border_format, border_color, border_style, border_width, back_color, font_color, cell_alignment, cell_alignment_vertical } = this.propTargets;
|
|
@@ -2579,7 +2733,7 @@ class Table extends EditorInjector {
|
|
|
2579
2733
|
if (!isTable) {
|
|
2580
2734
|
const trRow = /** @type {HTMLTableRowElement} */ (tr.parentElement);
|
|
2581
2735
|
// --- target cells roof
|
|
2582
|
-
let { rs, re, cs, ce } = this
|
|
2736
|
+
let { rs, re, cs, ce } = this.#ref || {
|
|
2583
2737
|
rs: trRow.rowIndex || 0,
|
|
2584
2738
|
re: trRow.rowIndex || 0,
|
|
2585
2739
|
cs: tr.cellIndex || 0,
|
|
@@ -2610,7 +2764,6 @@ class Table extends EditorInjector {
|
|
|
2610
2764
|
c++;
|
|
2611
2765
|
}
|
|
2612
2766
|
|
|
2613
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2614
2767
|
try {
|
|
2615
2768
|
if (rowspan > 1) {
|
|
2616
2769
|
const rowspanNum = rowspan - 1;
|
|
@@ -2620,10 +2773,9 @@ class Table extends EditorInjector {
|
|
|
2620
2773
|
} else if (colspan > 1) {
|
|
2621
2774
|
mergeInfo[rowIndex][cellIndex] += colspan - 1;
|
|
2622
2775
|
}
|
|
2623
|
-
} catch
|
|
2776
|
+
} catch {
|
|
2624
2777
|
// ignore error
|
|
2625
2778
|
}
|
|
2626
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2627
2779
|
|
|
2628
2780
|
const isBottom = rowIndex + rowspan - 1 === re;
|
|
2629
2781
|
if (rowIndex === rs) cells.top.push(e);
|
|
@@ -2660,9 +2812,9 @@ class Table extends EditorInjector {
|
|
|
2660
2812
|
// -- table styles
|
|
2661
2813
|
const es = tr.style;
|
|
2662
2814
|
// alignment
|
|
2663
|
-
if (this
|
|
2664
|
-
this.
|
|
2665
|
-
this.
|
|
2815
|
+
if (this.#figure) {
|
|
2816
|
+
this.#figure.style.float = cellAlignment;
|
|
2817
|
+
this.#figure.style.verticalAlign = cellAlignmentVertical;
|
|
2666
2818
|
}
|
|
2667
2819
|
// back
|
|
2668
2820
|
es.backgroundColor = backColor;
|
|
@@ -2694,10 +2846,10 @@ class Table extends EditorInjector {
|
|
|
2694
2846
|
|
|
2695
2847
|
// set cells style
|
|
2696
2848
|
this.controller_props.close();
|
|
2697
|
-
if (this
|
|
2849
|
+
if (this.#tdElement) {
|
|
2698
2850
|
this._recallStyleSelectedCells();
|
|
2699
|
-
this.setCellInfo(this
|
|
2700
|
-
dom.utils.addClass(this
|
|
2851
|
+
this.setCellInfo(this.#tdElement, true);
|
|
2852
|
+
dom.utils.addClass(this.#tdElement, 'se-selected-cell-focus');
|
|
2701
2853
|
}
|
|
2702
2854
|
} catch (err) {
|
|
2703
2855
|
console.warn('[SUNEDITOR.plugins.table.setProps.error]', err);
|
|
@@ -2785,19 +2937,19 @@ class Table extends EditorInjector {
|
|
|
2785
2937
|
* @param {Node} endCell The last cell in the selection.
|
|
2786
2938
|
*/
|
|
2787
2939
|
_setMultiCells(startCell, endCell) {
|
|
2788
|
-
const rows = this.
|
|
2940
|
+
const rows = this.#selectedTable.rows;
|
|
2789
2941
|
this._deleteStyleSelectedCells();
|
|
2790
2942
|
|
|
2791
2943
|
dom.utils.addClass(startCell, 'se-selected-table-cell');
|
|
2792
2944
|
|
|
2793
2945
|
if (startCell === endCell) {
|
|
2794
|
-
if (!this
|
|
2946
|
+
if (!this.#shift) return;
|
|
2795
2947
|
}
|
|
2796
2948
|
|
|
2797
2949
|
let findSelectedCell = true;
|
|
2798
2950
|
let spanIndex = [];
|
|
2799
2951
|
let rowSpanArr = [];
|
|
2800
|
-
const ref = (this
|
|
2952
|
+
const ref = (this.#ref = { _i: 0, cs: null, ce: null, rs: null, re: null });
|
|
2801
2953
|
|
|
2802
2954
|
for (let i = 0, len = rows.length, cells, colSpan; i < len; i++) {
|
|
2803
2955
|
cells = rows[i].cells;
|
|
@@ -2963,9 +3115,9 @@ class Table extends EditorInjector {
|
|
|
2963
3115
|
* @description Hides the resize line if it is visible.
|
|
2964
3116
|
*/
|
|
2965
3117
|
__hideResizeLine() {
|
|
2966
|
-
if (this
|
|
2967
|
-
this.
|
|
2968
|
-
this
|
|
3118
|
+
if (this.#resizeLine) {
|
|
3119
|
+
this.#resizeLine.style.display = 'none';
|
|
3120
|
+
this.#resizeLine = null;
|
|
2969
3121
|
}
|
|
2970
3122
|
}
|
|
2971
3123
|
|
|
@@ -2975,16 +3127,16 @@ class Table extends EditorInjector {
|
|
|
2975
3127
|
*/
|
|
2976
3128
|
__removeGlobalEvents() {
|
|
2977
3129
|
this._toggleEditor(true);
|
|
2978
|
-
this
|
|
3130
|
+
this.#resizing = false;
|
|
2979
3131
|
this.ui.disableBackWrapper();
|
|
2980
3132
|
this.__hideResizeLine();
|
|
2981
|
-
if (this
|
|
2982
|
-
this.
|
|
2983
|
-
this
|
|
3133
|
+
if (this.#resizeLinePrev) {
|
|
3134
|
+
this.#resizeLinePrev.style.display = 'none';
|
|
3135
|
+
this.#resizeLinePrev = null;
|
|
2984
3136
|
}
|
|
2985
|
-
const globalEvents = this
|
|
3137
|
+
const globalEvents = this.#globalEvents;
|
|
2986
3138
|
for (const k in globalEvents) {
|
|
2987
|
-
|
|
3139
|
+
globalEvents[k] &&= this.eventManager.removeGlobalEvent(globalEvents[k]);
|
|
2988
3140
|
}
|
|
2989
3141
|
}
|
|
2990
3142
|
|
|
@@ -3023,27 +3175,27 @@ class Table extends EditorInjector {
|
|
|
3023
3175
|
* If `true`, the selection will extend to include adjacent cells, otherwise it selects only the provided cell.
|
|
3024
3176
|
*/
|
|
3025
3177
|
#StyleSelectCells(tdElement, shift) {
|
|
3026
|
-
this
|
|
3027
|
-
if (!this
|
|
3178
|
+
this.#_s = shift;
|
|
3179
|
+
if (!this.#shift && !this.#ref) this.__removeGlobalEvents();
|
|
3028
3180
|
|
|
3029
|
-
this
|
|
3030
|
-
this
|
|
3031
|
-
if (!this
|
|
3032
|
-
this
|
|
3033
|
-
this
|
|
3181
|
+
this.#shift = shift;
|
|
3182
|
+
this.#fixedCell = tdElement;
|
|
3183
|
+
if (!this.#selectedCells?.length) this.#selectedCells = [tdElement];
|
|
3184
|
+
this.#fixedCellName = tdElement.nodeName;
|
|
3185
|
+
this.#selectedTable = dom.query.getParentElement(tdElement, 'TABLE');
|
|
3034
3186
|
|
|
3035
3187
|
this._deleteStyleSelectedCells();
|
|
3036
3188
|
dom.utils.addClass(tdElement, 'se-selected-cell-focus');
|
|
3037
3189
|
|
|
3038
3190
|
if (!shift) {
|
|
3039
|
-
this.
|
|
3191
|
+
this.#globalEvents.on = this.eventManager.addGlobalEvent('mousemove', this.#bindMultiOn, false);
|
|
3040
3192
|
} else {
|
|
3041
|
-
this.
|
|
3042
|
-
this.
|
|
3193
|
+
this.#globalEvents.shiftOff = this.eventManager.addGlobalEvent('keyup', this.#bindShiftOff, false);
|
|
3194
|
+
this.#globalEvents.on = this.eventManager.addGlobalEvent('mousedown', this.#bindMultiOn, false);
|
|
3043
3195
|
}
|
|
3044
3196
|
|
|
3045
|
-
this.
|
|
3046
|
-
this.
|
|
3197
|
+
this.#globalEvents.off = this.eventManager.addGlobalEvent('mouseup', this.#bindMultiOff, false);
|
|
3198
|
+
this.#globalEvents.touchOff = this.eventManager.addGlobalEvent('touchmove', this.#bindTouchOff, false);
|
|
3047
3199
|
}
|
|
3048
3200
|
|
|
3049
3201
|
/**
|
|
@@ -3052,11 +3204,11 @@ class Table extends EditorInjector {
|
|
|
3052
3204
|
*/
|
|
3053
3205
|
#OnSplitCells(direction) {
|
|
3054
3206
|
const vertical = direction === 'vertical';
|
|
3055
|
-
const currentCell = this
|
|
3056
|
-
const rows = this
|
|
3057
|
-
const currentRow = this
|
|
3058
|
-
const index = this
|
|
3059
|
-
const rowIndex = this
|
|
3207
|
+
const currentCell = this.#tdElement;
|
|
3208
|
+
const rows = this.#trElements;
|
|
3209
|
+
const currentRow = this.#trElement;
|
|
3210
|
+
const index = this.#logical_cellIndex;
|
|
3211
|
+
const rowIndex = this.#rowIndex;
|
|
3060
3212
|
const newCell = CreateCellsHTML(currentCell.nodeName);
|
|
3061
3213
|
|
|
3062
3214
|
// vertical
|
|
@@ -3074,7 +3226,7 @@ class Table extends EditorInjector {
|
|
|
3074
3226
|
let rowSpanArr = [];
|
|
3075
3227
|
let spanIndex = [];
|
|
3076
3228
|
|
|
3077
|
-
for (let i = 0, len = this
|
|
3229
|
+
for (let i = 0, len = this.#rowCnt, cells, colSpan; i < len; i++) {
|
|
3078
3230
|
cells = rows[i].cells;
|
|
3079
3231
|
colSpan = 0;
|
|
3080
3232
|
for (let c = 0, cLen = cells.length, cell, cs, rs, logcalIndex; c < cLen; c++) {
|
|
@@ -3208,7 +3360,7 @@ class Table extends EditorInjector {
|
|
|
3208
3360
|
}
|
|
3209
3361
|
}
|
|
3210
3362
|
|
|
3211
|
-
const physicalIndex = this
|
|
3363
|
+
const physicalIndex = this.#physical_cellIndex;
|
|
3212
3364
|
const cells = currentRow.cells;
|
|
3213
3365
|
|
|
3214
3366
|
for (let c = 0, cLen = cells.length; c < cLen; c++) {
|
|
@@ -3227,8 +3379,8 @@ class Table extends EditorInjector {
|
|
|
3227
3379
|
this.history.push(false);
|
|
3228
3380
|
|
|
3229
3381
|
this._setController(currentCell);
|
|
3230
|
-
this
|
|
3231
|
-
if (!this
|
|
3382
|
+
this.#selectedCell = this.#fixedCell = currentCell;
|
|
3383
|
+
if (!this.#selectedCells?.length) this.#selectedCells = [currentCell];
|
|
3232
3384
|
}
|
|
3233
3385
|
|
|
3234
3386
|
/**
|
|
@@ -3295,7 +3447,7 @@ class Table extends EditorInjector {
|
|
|
3295
3447
|
this.tableUnHighlight.style.height = y_u + 'em';
|
|
3296
3448
|
|
|
3297
3449
|
dom.utils.changeTxt(this.tableDisplay, x + ' x ' + y);
|
|
3298
|
-
this
|
|
3450
|
+
this.#tableXY = [x, y];
|
|
3299
3451
|
}
|
|
3300
3452
|
|
|
3301
3453
|
/**
|
|
@@ -3313,9 +3465,9 @@ class Table extends EditorInjector {
|
|
|
3313
3465
|
this.editor._preventBlur = true;
|
|
3314
3466
|
const target = /** @type {HTMLTableCellElement} */ (dom.query.getParentElement(dom.query.getEventTarget(e), dom.check.isTableCell));
|
|
3315
3467
|
|
|
3316
|
-
if (this
|
|
3317
|
-
if (target === this
|
|
3318
|
-
this
|
|
3468
|
+
if (this.#shift) {
|
|
3469
|
+
if (target === this.#fixedCell) {
|
|
3470
|
+
this.#shift = false;
|
|
3319
3471
|
this._deleteStyleSelectedCells();
|
|
3320
3472
|
this._toggleEditor(true);
|
|
3321
3473
|
this.__removeGlobalEvents();
|
|
@@ -3323,16 +3475,16 @@ class Table extends EditorInjector {
|
|
|
3323
3475
|
} else {
|
|
3324
3476
|
this._toggleEditor(false);
|
|
3325
3477
|
}
|
|
3326
|
-
} else if (!this
|
|
3327
|
-
if (target === this
|
|
3478
|
+
} else if (!this.#ref) {
|
|
3479
|
+
if (target === this.#fixedCell) return;
|
|
3328
3480
|
else this._toggleEditor(false);
|
|
3329
3481
|
}
|
|
3330
3482
|
|
|
3331
|
-
if (!target || target === this
|
|
3483
|
+
if (!target || target === this.#selectedCell || this.#fixedCellName !== target.nodeName || this.#selectedTable !== dom.query.getParentElement(target, 'TABLE')) {
|
|
3332
3484
|
return;
|
|
3333
3485
|
}
|
|
3334
3486
|
|
|
3335
|
-
this._setMultiCells(this
|
|
3487
|
+
this._setMultiCells(this.#fixedCell, (this.#selectedCell = target));
|
|
3336
3488
|
}
|
|
3337
3489
|
|
|
3338
3490
|
/**
|
|
@@ -3342,28 +3494,28 @@ class Table extends EditorInjector {
|
|
|
3342
3494
|
#OffCellMultiSelect(e) {
|
|
3343
3495
|
e.stopPropagation();
|
|
3344
3496
|
|
|
3345
|
-
if (!this
|
|
3497
|
+
if (!this.#shift) {
|
|
3346
3498
|
this._toggleEditor(true);
|
|
3347
3499
|
this.__removeGlobalEvents();
|
|
3348
|
-
} else
|
|
3349
|
-
this.
|
|
3500
|
+
} else {
|
|
3501
|
+
this.#globalEvents.touchOff &&= this.eventManager.removeGlobalEvent(this.#globalEvents.touchOff);
|
|
3350
3502
|
}
|
|
3351
3503
|
|
|
3352
|
-
if (!this
|
|
3504
|
+
if (!this.#fixedCell || !this.#selectedTable) return;
|
|
3353
3505
|
|
|
3354
|
-
this
|
|
3355
|
-
this
|
|
3506
|
+
this.#setMergeSplitButton();
|
|
3507
|
+
this.#selectedCells = Array.from(this.#selectedTable.querySelectorAll('.se-selected-table-cell'));
|
|
3356
3508
|
|
|
3357
|
-
if (this
|
|
3509
|
+
if (this.#shift) return;
|
|
3358
3510
|
|
|
3359
|
-
if (this
|
|
3360
|
-
this.#focusEdge(this
|
|
3361
|
-
if (this
|
|
3362
|
-
dom.utils.removeClass(this
|
|
3511
|
+
if (this.#fixedCell && this.#selectedCell) {
|
|
3512
|
+
this.#focusEdge(this.#fixedCell);
|
|
3513
|
+
if (this.#fixedCell === this.#selectedCell) {
|
|
3514
|
+
dom.utils.removeClass(this.#fixedCell, 'se-selected-table-cell');
|
|
3363
3515
|
}
|
|
3364
3516
|
}
|
|
3365
3517
|
|
|
3366
|
-
const displayCell = this
|
|
3518
|
+
const displayCell = this.#selectedCells?.length > 0 ? this.#selectedCell : this.#fixedCell;
|
|
3367
3519
|
this._setController(displayCell);
|
|
3368
3520
|
}
|
|
3369
3521
|
|
|
@@ -3371,15 +3523,15 @@ class Table extends EditorInjector {
|
|
|
3371
3523
|
* @description Handles the removal of shift-based selection.
|
|
3372
3524
|
*/
|
|
3373
3525
|
#OffCellShift() {
|
|
3374
|
-
if (!this
|
|
3526
|
+
if (!this.#ref) {
|
|
3375
3527
|
this._closeController();
|
|
3376
3528
|
} else {
|
|
3377
3529
|
this.__removeGlobalEvents();
|
|
3378
3530
|
this._toggleEditor(true);
|
|
3379
3531
|
|
|
3380
|
-
this.#focusEdge(this
|
|
3532
|
+
this.#focusEdge(this.#fixedCell);
|
|
3381
3533
|
|
|
3382
|
-
const displayCell = this
|
|
3534
|
+
const displayCell = this.#selectedCells?.length > 0 ? this.#selectedCell : this.#fixedCell;
|
|
3383
3535
|
this._setController(displayCell);
|
|
3384
3536
|
}
|
|
3385
3537
|
}
|