suneditor 3.1.3 → 3.2.0
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/dist/suneditor-contents.min.css +1 -1
- package/dist/suneditor.min.css +28 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +2 -1
- package/src/assets/design/color.css +12 -0
- package/src/assets/design/size.css +9 -2
- package/src/assets/icons/defaultIcons.js +96 -47
- package/src/assets/suneditor-contents.css +3 -2
- package/src/assets/suneditor.css +480 -31
- package/src/core/config/contextProvider.js +2 -1
- package/src/core/config/eventManager.js +41 -2
- package/src/core/config/optionProvider.js +23 -2
- package/src/core/editor.js +32 -14
- package/src/core/event/actions/index.js +76 -9
- package/src/core/event/effects/common.registry.js +2 -1
- package/src/core/event/effects/keydown.registry.js +169 -33
- package/src/core/event/effects/ruleHelpers.js +20 -6
- package/src/core/event/eventOrchestrator.js +136 -23
- package/src/core/event/handlers/handler_toolbar.js +4 -2
- package/src/core/event/handlers/handler_ww_dragDrop.js +10 -0
- package/src/core/event/handlers/handler_ww_input.js +9 -2
- package/src/core/event/handlers/handler_ww_key.js +86 -17
- package/src/core/event/handlers/handler_ww_mouse.js +45 -8
- package/src/core/event/ports.js +23 -5
- package/src/core/event/reducers/keydown.reducer.js +15 -2
- package/src/core/event/rules/keydown.rule.arrow.js +12 -2
- package/src/core/event/rules/keydown.rule.backspace.js +110 -15
- package/src/core/event/rules/keydown.rule.delete.js +62 -7
- package/src/core/event/rules/keydown.rule.enter.js +62 -31
- package/src/core/event/support/defaultLineManager.js +9 -2
- package/src/core/event/support/selectionState.js +13 -3
- package/src/core/kernel/coreKernel.js +1 -0
- package/src/core/logic/dom/char.js +13 -3
- package/src/core/logic/dom/format.js +171 -39
- package/src/core/logic/dom/html.js +357 -87
- package/src/core/logic/dom/inline.js +229 -34
- package/src/core/logic/dom/listFormat.js +111 -20
- package/src/core/logic/dom/nodeTransform.js +36 -11
- package/src/core/logic/dom/offset.js +116 -31
- package/src/core/logic/dom/selection.js +147 -29
- package/src/core/logic/panel/blockHandle.js +785 -0
- package/src/core/logic/panel/blockResolver.js +278 -0
- package/src/core/logic/panel/finder.js +16 -6
- package/src/core/logic/panel/menu.js +119 -18
- package/src/core/logic/panel/toolbar.js +75 -19
- package/src/core/logic/panel/viewer.js +76 -20
- package/src/core/logic/shell/_commandExecutor.js +44 -9
- package/src/core/logic/shell/commandDispatcher.js +46 -4
- package/src/core/logic/shell/component.js +102 -25
- package/src/core/logic/shell/focusManager.js +13 -3
- package/src/core/logic/shell/history.js +21 -6
- package/src/core/logic/shell/pluginManager.js +21 -13
- package/src/core/logic/shell/shortcuts.js +9 -1
- package/src/core/logic/shell/ui.js +139 -37
- package/src/core/schema/frameContext.js +34 -3
- package/src/core/schema/options.js +61 -19
- package/src/core/section/constructor.js +537 -103
- package/src/core/section/documentType.js +35 -6
- package/src/helper/converter.js +24 -7
- package/src/helper/dom/domCheck.js +25 -5
- package/src/helper/dom/domQuery.js +2 -1
- package/src/helper/dom/domUtils.js +17 -4
- package/src/helper/env.js +11 -2
- package/src/helper/keyCodeMap.js +6 -2
- package/src/helper/markdown.js +24 -5
- package/src/helper/msOffice.js +9 -2
- package/src/interfaces/plugins.js +1 -1
- package/src/langs/ckb.js +0 -1
- package/src/langs/cs.js +0 -1
- package/src/langs/da.js +0 -1
- package/src/langs/de.js +0 -1
- package/src/langs/en.js +0 -1
- package/src/langs/es.js +0 -1
- package/src/langs/fa.js +0 -1
- package/src/langs/fr.js +0 -1
- package/src/langs/he.js +0 -1
- package/src/langs/hu.js +0 -1
- package/src/langs/index.js +27 -1
- package/src/langs/it.js +0 -1
- package/src/langs/ja.js +0 -1
- package/src/langs/km.js +0 -1
- package/src/langs/ko.js +0 -1
- package/src/langs/lv.js +0 -1
- package/src/langs/nl.js +0 -1
- package/src/langs/pl.js +0 -1
- package/src/langs/pt_br.js +0 -1
- package/src/langs/ro.js +0 -1
- package/src/langs/ru.js +0 -1
- package/src/langs/se.js +0 -1
- package/src/langs/tr.js +0 -1
- package/src/langs/uk.js +0 -1
- package/src/langs/ur.js +0 -1
- package/src/langs/zh_cn.js +0 -1
- package/src/modules/contract/Browser.js +68 -23
- package/src/modules/contract/ColorPicker.js +12 -4
- package/src/modules/contract/Controller.js +37 -7
- package/src/modules/contract/Figure.js +159 -36
- package/src/modules/contract/HueSlider.js +27 -4
- package/src/modules/contract/Modal.js +62 -11
- package/src/modules/manager/FileManager.js +50 -8
- package/src/modules/ui/CommandMenu.js +597 -0
- package/src/modules/ui/ModalAnchorEditor.js +41 -9
- package/src/modules/ui/SelectMenu.js +481 -36
- package/src/modules/ui/index.js +1 -0
- package/src/plugins/browser/audioGallery.js +8 -1
- package/src/plugins/browser/fileBrowser.js +15 -2
- package/src/plugins/browser/fileGallery.js +8 -1
- package/src/plugins/browser/imageGallery.js +24 -3
- package/src/plugins/browser/videoGallery.js +19 -4
- package/src/plugins/command/blockquote.js +6 -1
- package/src/plugins/command/codeBlock.js +43 -5
- package/src/plugins/command/exportPDF.js +20 -4
- package/src/plugins/command/fileUpload.js +46 -11
- package/src/plugins/command/list_bulleted.js +6 -1
- package/src/plugins/command/list_numbered.js +6 -1
- package/src/plugins/dropdown/align.js +21 -33
- package/src/plugins/dropdown/backgroundColor.js +10 -2
- package/src/plugins/dropdown/blockStyle.js +17 -22
- package/src/plugins/dropdown/font.js +34 -34
- package/src/plugins/dropdown/hr.js +15 -43
- package/src/plugins/dropdown/layout.js +10 -27
- package/src/plugins/dropdown/lineHeight.js +10 -33
- package/src/plugins/dropdown/list.js +19 -25
- package/src/plugins/dropdown/paragraphStyle.js +16 -24
- package/src/plugins/dropdown/table/index.js +72 -17
- package/src/plugins/dropdown/table/render/table.html.js +3 -1
- package/src/plugins/dropdown/table/services/table.cell.js +33 -7
- package/src/plugins/dropdown/table/services/table.clipboard.js +5 -1
- package/src/plugins/dropdown/table/services/table.grid.js +40 -9
- package/src/plugins/dropdown/table/services/table.resize.js +55 -11
- package/src/plugins/dropdown/table/services/table.selection.js +27 -7
- package/src/plugins/dropdown/table/services/table.style.js +120 -20
- package/src/plugins/dropdown/template.js +13 -29
- package/src/plugins/dropdown/textStyle.js +22 -35
- package/src/plugins/field/autocomplete.js +8 -4
- package/src/plugins/field/slashCommand.js +297 -0
- package/src/plugins/index.js +3 -0
- package/src/plugins/input/fontSize.js +37 -8
- package/src/plugins/input/pageNavigator.js +7 -1
- package/src/plugins/modal/audio.js +71 -17
- package/src/plugins/modal/drawing.js +41 -11
- package/src/plugins/modal/embed.js +132 -22
- package/src/plugins/modal/image/index.js +115 -28
- package/src/plugins/modal/image/services/image.size.js +9 -2
- package/src/plugins/modal/image/services/image.upload.js +38 -4
- package/src/plugins/modal/link.js +9 -2
- package/src/plugins/modal/math.js +10 -2
- package/src/plugins/modal/video/index.js +112 -26
- package/src/plugins/modal/video/render/video.html.js +4 -1
- package/src/plugins/modal/video/services/video.size.js +15 -4
- package/src/plugins/modal/video/services/video.upload.js +10 -2
- package/src/plugins/popup/anchor.js +14 -2
- package/src/suneditor.js +8 -2
- package/src/themes/cobalt.css +12 -0
- package/src/themes/cream.css +12 -0
- package/src/themes/dark.css +12 -0
- package/src/themes/midnight.css +12 -0
- package/src/typedef.js +32 -21
- package/types/assets/icons/defaultIcons.d.ts +1 -0
- package/types/core/config/contextProvider.d.ts +7 -1
- package/types/core/config/eventManager.d.ts +37 -4
- package/types/core/config/optionProvider.d.ts +5 -1
- package/types/core/event/actions/index.d.ts +44 -6
- package/types/core/event/effects/keydown.registry.d.ts +37 -7
- package/types/core/event/effects/ruleHelpers.d.ts +6 -1
- package/types/core/event/eventOrchestrator.d.ts +6 -1
- package/types/core/event/handlers/handler_ww_clipboard.d.ts +15 -3
- package/types/core/event/handlers/handler_ww_dragDrop.d.ts +14 -2
- package/types/core/event/handlers/handler_ww_input.d.ts +10 -2
- package/types/core/event/handlers/handler_ww_key.d.ts +10 -2
- package/types/core/event/handlers/handler_ww_mouse.d.ts +25 -5
- package/types/core/event/ports.d.ts +7 -2
- package/types/core/event/rules/keydown.rule.backspace.d.ts +6 -1
- package/types/core/kernel/store.d.ts +4 -1
- package/types/core/logic/dom/format.d.ts +32 -14
- package/types/core/logic/dom/html.d.ts +11 -3
- package/types/core/logic/dom/nodeTransform.d.ts +6 -6
- package/types/core/logic/panel/blockHandle.d.ts +64 -0
- package/types/core/logic/panel/blockResolver.d.ts +50 -0
- package/types/core/logic/panel/menu.d.ts +72 -3
- package/types/core/logic/shell/commandDispatcher.d.ts +8 -0
- package/types/core/logic/shell/component.d.ts +5 -3
- package/types/core/logic/shell/shortcuts.d.ts +10 -1
- package/types/core/logic/shell/ui.d.ts +7 -1
- package/types/core/schema/context.d.ts +7 -1
- package/types/core/schema/frameContext.d.ts +36 -4
- package/types/core/schema/options.d.ts +110 -37
- package/types/core/section/constructor.d.ts +38 -1
- package/types/events.d.ts +208 -32
- package/types/helper/converter.d.ts +4 -2
- package/types/helper/dom/domCheck.d.ts +12 -2
- package/types/helper/dom/domQuery.d.ts +35 -7
- package/types/helper/dom/domUtils.d.ts +4 -1
- package/types/interfaces/plugins.d.ts +2 -2
- package/types/langs/_Lang.d.ts +0 -1
- package/types/modules/contract/Browser.d.ts +7 -7
- package/types/modules/contract/ColorPicker.d.ts +2 -2
- package/types/modules/contract/Controller.d.ts +7 -0
- package/types/modules/contract/Figure.d.ts +31 -4
- package/types/modules/ui/CommandMenu.d.ts +262 -0
- package/types/modules/ui/ModalAnchorEditor.d.ts +6 -1
- package/types/modules/ui/SelectMenu.d.ts +56 -3
- package/types/modules/ui/index.d.ts +1 -0
- package/types/plugins/browser/audioGallery.d.ts +17 -1
- package/types/plugins/browser/fileBrowser.d.ts +17 -1
- package/types/plugins/browser/fileGallery.d.ts +17 -1
- package/types/plugins/browser/imageGallery.d.ts +17 -1
- package/types/plugins/browser/videoGallery.d.ts +17 -1
- package/types/plugins/dropdown/align.d.ts +1 -1
- package/types/plugins/dropdown/blockStyle.d.ts +3 -1
- package/types/plugins/dropdown/table/index.d.ts +4 -1
- package/types/plugins/dropdown/table/services/table.clipboard.d.ts +5 -1
- package/types/plugins/dropdown/table/services/table.grid.d.ts +10 -2
- package/types/plugins/field/autocomplete.d.ts +0 -1
- package/types/plugins/field/slashCommand.d.ts +165 -0
- package/types/plugins/index.d.ts +3 -0
- package/types/plugins/modal/embed.d.ts +34 -0
- package/types/plugins/modal/link.d.ts +4 -1
- package/types/typedef.d.ts +48 -23
|
@@ -4,7 +4,13 @@ import { Controller, Figure } from '../../../modules/contract';
|
|
|
4
4
|
import { _DragHandle } from '../../../modules/ui';
|
|
5
5
|
|
|
6
6
|
import * as Constants from './shared/table.constants';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
CreateCellsString,
|
|
9
|
+
GetMaxColumns,
|
|
10
|
+
IsResizeEls,
|
|
11
|
+
IsTableCaption,
|
|
12
|
+
GetLogicalCellIndex,
|
|
13
|
+
} from './shared/table.utils';
|
|
8
14
|
import { CreateHTML, CreateHTML_controller_table, CreateHTML_controller_cell } from './render/table.html';
|
|
9
15
|
|
|
10
16
|
import TableCellService from './services/table.cell';
|
|
@@ -89,10 +95,18 @@ class Table extends PluginDropdownFree {
|
|
|
89
95
|
const controller_cell = CreateHTML_controller_cell(this.$, this.cellControllerTop);
|
|
90
96
|
|
|
91
97
|
this.$.contextProvider.applyToRoots((e) => {
|
|
92
|
-
e.get('wrapper').appendChild(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
e.get('wrapper').appendChild(
|
|
98
|
+
e.get('wrapper').appendChild(
|
|
99
|
+
dom.utils.createElement('DIV', { class: Constants.RESIZE_CELL_CLASS.replace(/^\./, '') }),
|
|
100
|
+
);
|
|
101
|
+
e.get('wrapper').appendChild(
|
|
102
|
+
dom.utils.createElement('DIV', { class: Constants.RESIZE_CELL_PREV_CLASS.replace(/^\./, '') }),
|
|
103
|
+
);
|
|
104
|
+
e.get('wrapper').appendChild(
|
|
105
|
+
dom.utils.createElement('DIV', { class: Constants.RESIZE_ROW_CLASS.replace(/^\./, '') }),
|
|
106
|
+
);
|
|
107
|
+
e.get('wrapper').appendChild(
|
|
108
|
+
dom.utils.createElement('DIV', { class: Constants.RESIZE_ROW_PREV_CLASS.replace(/^\./, '') }),
|
|
109
|
+
);
|
|
96
110
|
});
|
|
97
111
|
|
|
98
112
|
// members - Controller
|
|
@@ -175,7 +189,12 @@ class Table extends PluginDropdownFree {
|
|
|
175
189
|
|
|
176
190
|
this.#maxWidth = this.state.figureElement?.style.width === '100%';
|
|
177
191
|
this.#fixedColumn = dom.utils.hasClass(target, 'se-table-layout-fixed') || target.style.tableLayout === 'fixed';
|
|
178
|
-
this.styleService.setTableLayout(
|
|
192
|
+
this.styleService.setTableLayout(
|
|
193
|
+
this.#maxWidth ? 'width|column' : 'width',
|
|
194
|
+
this.#maxWidth,
|
|
195
|
+
this.#fixedColumn,
|
|
196
|
+
true,
|
|
197
|
+
);
|
|
179
198
|
|
|
180
199
|
if (_DragHandle.get('__overInfo') === ON_OVER_COMPONENT) return;
|
|
181
200
|
|
|
@@ -185,12 +204,22 @@ class Table extends PluginDropdownFree {
|
|
|
185
204
|
// controller open
|
|
186
205
|
const btnDisabled = this.state.selectedCells?.length > 1;
|
|
187
206
|
const figureEl = dom.query.getParentElement(target, dom.check.isFigure);
|
|
188
|
-
this.controller_table.open(figureEl, null, {
|
|
207
|
+
this.controller_table.open(figureEl, null, {
|
|
208
|
+
isWWTarget: false,
|
|
209
|
+
initMethod: null,
|
|
210
|
+
addOffset: null,
|
|
211
|
+
disabled: btnDisabled,
|
|
212
|
+
});
|
|
189
213
|
|
|
190
214
|
if (!this.state.fixedCell) return;
|
|
191
215
|
|
|
192
216
|
this.cellService.setUnMergeButton();
|
|
193
|
-
this.controller_cell.open(this.state.tdElement, this.cellControllerTop ? figureEl : null, {
|
|
217
|
+
this.controller_cell.open(this.state.tdElement, this.cellControllerTop ? figureEl : null, {
|
|
218
|
+
isWWTarget: false,
|
|
219
|
+
initMethod: null,
|
|
220
|
+
addOffset: null,
|
|
221
|
+
disabled: btnDisabled,
|
|
222
|
+
});
|
|
194
223
|
}
|
|
195
224
|
|
|
196
225
|
/**
|
|
@@ -253,7 +282,7 @@ class Table extends PluginDropdownFree {
|
|
|
253
282
|
if (domParserBody.childElementCount !== 1) return;
|
|
254
283
|
|
|
255
284
|
const componentInfo = this.$.component.get(domParserBody.firstElementChild);
|
|
256
|
-
if (componentInfo
|
|
285
|
+
if (componentInfo?.pluginName !== Table.key) return;
|
|
257
286
|
|
|
258
287
|
const copyTable = /** @type {HTMLTableElement} */ (componentInfo.target);
|
|
259
288
|
const selectedCells = this.clipboardService.pasteTableCellMatrix(copyTable, targetCell);
|
|
@@ -278,7 +307,9 @@ class Table extends PluginDropdownFree {
|
|
|
278
307
|
/** @param {HTMLTableElement} element */
|
|
279
308
|
method: (element) => {
|
|
280
309
|
const ColgroupEl = element.querySelector('colgroup');
|
|
281
|
-
let FigureEl = /** @type {HTMLElement} */ (
|
|
310
|
+
let FigureEl = /** @type {HTMLElement} */ (
|
|
311
|
+
dom.check.isFigure(element.parentNode) ? element.parentNode : null
|
|
312
|
+
);
|
|
282
313
|
|
|
283
314
|
// create colgroup
|
|
284
315
|
if (!ColgroupEl) {
|
|
@@ -318,7 +349,9 @@ class Table extends PluginDropdownFree {
|
|
|
318
349
|
if (existingWidth === null) {
|
|
319
350
|
colWidths[targetColIndex] = `width: ${cellWidth};`;
|
|
320
351
|
} else {
|
|
321
|
-
const existingPxWidth = parseFloat(
|
|
352
|
+
const existingPxWidth = parseFloat(
|
|
353
|
+
existingWidth.replace('width: ', '').replace(';', ''),
|
|
354
|
+
);
|
|
322
355
|
if (colSpan === 1 && currentPxWidth !== existingPxWidth) {
|
|
323
356
|
colWidths[targetColIndex] = `width: ${cellWidth};`;
|
|
324
357
|
}
|
|
@@ -370,7 +403,10 @@ class Table extends PluginDropdownFree {
|
|
|
370
403
|
} else {
|
|
371
404
|
const scrollTypeClass = `se-scroll-figure-${this.figureScroll}`;
|
|
372
405
|
dom.utils.addClass(FigureEl, scrollTypeClass);
|
|
373
|
-
dom.utils.removeClass(
|
|
406
|
+
dom.utils.removeClass(
|
|
407
|
+
FigureEl,
|
|
408
|
+
this.figureScrollList.filter((v) => v !== scrollTypeClass).join('|'),
|
|
409
|
+
);
|
|
374
410
|
}
|
|
375
411
|
},
|
|
376
412
|
};
|
|
@@ -463,7 +499,13 @@ class Table extends PluginDropdownFree {
|
|
|
463
499
|
|
|
464
500
|
const keyCode = event.code;
|
|
465
501
|
const isTab = keyCodeMap.isTab(keyCode);
|
|
466
|
-
if (
|
|
502
|
+
if (
|
|
503
|
+
this.$.ui.selectMenuOn ||
|
|
504
|
+
this.resizeService.isResizing() ||
|
|
505
|
+
(!isTab && this.#_s) ||
|
|
506
|
+
keyCodeMap.isCtrl(event)
|
|
507
|
+
)
|
|
508
|
+
return;
|
|
467
509
|
|
|
468
510
|
if (!this.cellControllerTop) {
|
|
469
511
|
this.controller_cell.hide();
|
|
@@ -547,7 +589,10 @@ class Table extends PluginDropdownFree {
|
|
|
547
589
|
*/
|
|
548
590
|
onKeyUp({ line }) {
|
|
549
591
|
this.#_s = false;
|
|
550
|
-
if (
|
|
592
|
+
if (
|
|
593
|
+
this.state.isShiftPressed &&
|
|
594
|
+
dom.query.getParentElement(line, dom.check.isTableCell) === this.state.fixedCell
|
|
595
|
+
) {
|
|
551
596
|
this.selectionService.deleteStyleSelectedCells();
|
|
552
597
|
this._editorEnable(true);
|
|
553
598
|
this.#initService();
|
|
@@ -760,7 +805,8 @@ class Table extends PluginDropdownFree {
|
|
|
760
805
|
this.setState('tdElement', tdElement);
|
|
761
806
|
if (this.state.fixedCell === tdElement) dom.utils.addClass(tdElement, 'se-selected-cell-focus');
|
|
762
807
|
if (!this.state.selectedCells?.length) this.setState('selectedCells', [tdElement]);
|
|
763
|
-
const tableElement =
|
|
808
|
+
const tableElement =
|
|
809
|
+
this.state.selectedTable || this._element || dom.query.getParentElement(tdElement, 'TABLE');
|
|
764
810
|
this.$.component.select(tableElement, Table.key, { isInput: true });
|
|
765
811
|
}
|
|
766
812
|
|
|
@@ -807,7 +853,13 @@ class Table extends PluginDropdownFree {
|
|
|
807
853
|
* @param {Node} target - The target figure element.
|
|
808
854
|
*/
|
|
809
855
|
#figureOpen(target) {
|
|
810
|
-
this.figure.open(target, {
|
|
856
|
+
this.figure.open(target, {
|
|
857
|
+
nonResizing: true,
|
|
858
|
+
nonSizeInfo: true,
|
|
859
|
+
nonBorder: true,
|
|
860
|
+
figureTarget: true,
|
|
861
|
+
infoOnly: false,
|
|
862
|
+
});
|
|
811
863
|
}
|
|
812
864
|
|
|
813
865
|
/**
|
|
@@ -885,7 +937,10 @@ class Table extends PluginDropdownFree {
|
|
|
885
937
|
scrollTypeClass = ` se-scroll-figure-${this.figureScroll}`;
|
|
886
938
|
}
|
|
887
939
|
|
|
888
|
-
const figure = dom.utils.createElement('FIGURE', {
|
|
940
|
+
const figure = dom.utils.createElement('FIGURE', {
|
|
941
|
+
class: 'se-flex-component se-input-component' + scrollTypeClass,
|
|
942
|
+
style: 'width: 100%;',
|
|
943
|
+
});
|
|
889
944
|
figure.appendChild(oTable);
|
|
890
945
|
this.#maxWidth = true;
|
|
891
946
|
|
|
@@ -158,7 +158,9 @@ export function CreateHTML_controller_cell({ lang, icons }, cellControllerTop) {
|
|
|
158
158
|
* @returns {TableCtrlProps}
|
|
159
159
|
*/
|
|
160
160
|
export function CreateHTML_controller_properties({ lang, icons, options }) {
|
|
161
|
-
const alignItems = options.get('_rtl')
|
|
161
|
+
const alignItems = options.get('_rtl')
|
|
162
|
+
? ['right', 'center', 'left', 'justify']
|
|
163
|
+
: ['left', 'center', 'right', 'justify'];
|
|
162
164
|
let alignHtml = '';
|
|
163
165
|
for (let i = 0, item, text; i < alignItems.length; i++) {
|
|
164
166
|
item = alignItems[i];
|
|
@@ -34,7 +34,12 @@ export class TableCellService {
|
|
|
34
34
|
|
|
35
35
|
// members - SelectMenu - split
|
|
36
36
|
const splitMenu = CreateSplitMenu(this.#$.lang);
|
|
37
|
-
this.selectMenu_split = new SelectMenu(this.#$, {
|
|
37
|
+
this.selectMenu_split = new SelectMenu(this.#$, {
|
|
38
|
+
checkList: false,
|
|
39
|
+
position: 'bottom-center',
|
|
40
|
+
openMethod: openCellMenuFunc,
|
|
41
|
+
closeMethod: closeCellMenuFunc,
|
|
42
|
+
});
|
|
38
43
|
this.selectMenu_split.on(this.splitButton, this._OnSplitCells.bind(this));
|
|
39
44
|
this.selectMenu_split.create(splitMenu.items, splitMenu.menus);
|
|
40
45
|
}
|
|
@@ -59,7 +64,9 @@ export class TableCellService {
|
|
|
59
64
|
mergeCells(selectedCells, skipPostProcess = false) {
|
|
60
65
|
const originTable = selectedCells[0].closest('table');
|
|
61
66
|
InvalidateTableCache(originTable);
|
|
62
|
-
const { clonedTable, clonedSelectedCells } = skipPostProcess
|
|
67
|
+
const { clonedTable, clonedSelectedCells } = skipPostProcess
|
|
68
|
+
? { clonedTable: originTable, clonedSelectedCells: selectedCells }
|
|
69
|
+
: CloneTable(originTable, selectedCells);
|
|
63
70
|
|
|
64
71
|
this.#main.setTableInfo(clonedTable);
|
|
65
72
|
selectedCells = clonedSelectedCells;
|
|
@@ -160,7 +167,9 @@ export class TableCellService {
|
|
|
160
167
|
|
|
161
168
|
const originTable = selectedCells[0].closest('table');
|
|
162
169
|
InvalidateTableCache(originTable);
|
|
163
|
-
const { clonedTable, clonedSelectedCells } = skipPostProcess
|
|
170
|
+
const { clonedTable, clonedSelectedCells } = skipPostProcess
|
|
171
|
+
? { clonedTable: originTable, clonedSelectedCells: selectedCells }
|
|
172
|
+
: CloneTable(originTable, selectedCells);
|
|
164
173
|
|
|
165
174
|
this.#main.setState('ref', null);
|
|
166
175
|
this.#main.setTableInfo(clonedTable);
|
|
@@ -217,7 +226,12 @@ export class TableCellService {
|
|
|
217
226
|
|
|
218
227
|
// set info
|
|
219
228
|
if (firstCell !== lastCell) {
|
|
220
|
-
lastCell =
|
|
229
|
+
lastCell =
|
|
230
|
+
!newLastCell ||
|
|
231
|
+
lastCell.closest('tr').rowIndex > newLastCell.closest('tr').rowIndex ||
|
|
232
|
+
lastCell.cellIndex > newLastCell.cellIndex
|
|
233
|
+
? lastCell
|
|
234
|
+
: newLastCell;
|
|
221
235
|
this.#selectionService.setMultiCells(firstCell, lastCell);
|
|
222
236
|
this.#main.setState('selectedCells', Array.from(table.querySelectorAll('.se-selected-table-cell')));
|
|
223
237
|
} else {
|
|
@@ -265,7 +279,11 @@ export class TableCellService {
|
|
|
265
279
|
* @description Sets the unmerge button visibility.
|
|
266
280
|
*/
|
|
267
281
|
setUnMergeButton() {
|
|
268
|
-
if (
|
|
282
|
+
if (
|
|
283
|
+
this.findMergedCells(
|
|
284
|
+
!this.#state.selectedCells?.length ? [this.#state.fixedCell] : this.#state.selectedCells,
|
|
285
|
+
).length > 0
|
|
286
|
+
) {
|
|
269
287
|
this.unmergeButton.disabled = false;
|
|
270
288
|
} else {
|
|
271
289
|
this.unmergeButton.disabled = true;
|
|
@@ -345,7 +363,11 @@ export class TableCellService {
|
|
|
345
363
|
});
|
|
346
364
|
}
|
|
347
365
|
|
|
348
|
-
if (
|
|
366
|
+
if (
|
|
367
|
+
cell !== currentCell &&
|
|
368
|
+
logcalIndex <= index &&
|
|
369
|
+
logcalIndex + cs >= index + currentColSpan - 1
|
|
370
|
+
) {
|
|
349
371
|
cell.colSpan += 1;
|
|
350
372
|
break;
|
|
351
373
|
}
|
|
@@ -399,7 +421,11 @@ export class TableCellService {
|
|
|
399
421
|
const nextCells = nextRow.cells;
|
|
400
422
|
let rs = rowSpanArr.shift();
|
|
401
423
|
|
|
402
|
-
for (
|
|
424
|
+
for (
|
|
425
|
+
let c = 0, cLen = nextCells.length, colSpan = 0, cell, cs, logcalIndex, insertIndex;
|
|
426
|
+
c < cLen;
|
|
427
|
+
c++
|
|
428
|
+
) {
|
|
403
429
|
logcalIndex = c + colSpan;
|
|
404
430
|
cell = nextCells[c];
|
|
405
431
|
cs = cell.colSpan - 1;
|
|
@@ -292,7 +292,11 @@ export class TableClipboardService {
|
|
|
292
292
|
const cEnd = cStart + cs - 1;
|
|
293
293
|
const mergeCells = [];
|
|
294
294
|
|
|
295
|
-
for (
|
|
295
|
+
for (
|
|
296
|
+
let targetR = targetInfo.rowIndex + r, tRowCnt = targetR + rs, rowOffset = 0;
|
|
297
|
+
targetR < tRowCnt;
|
|
298
|
+
targetR++, rowOffset++
|
|
299
|
+
) {
|
|
296
300
|
const targetRow = targetRows[targetR];
|
|
297
301
|
const targetCells = targetRow.cells;
|
|
298
302
|
|
|
@@ -28,13 +28,23 @@ export class TableGridService {
|
|
|
28
28
|
|
|
29
29
|
// members - SelectMenu - column
|
|
30
30
|
const columnMenu = CreateColumnMenu(this.#$.lang, this.#$.icons);
|
|
31
|
-
this.selectMenu_column = new SelectMenu(this.#$, {
|
|
31
|
+
this.selectMenu_column = new SelectMenu(this.#$, {
|
|
32
|
+
checkList: false,
|
|
33
|
+
position: 'bottom-center',
|
|
34
|
+
openMethod: openCellMenuFunc,
|
|
35
|
+
closeMethod: closeCellMenuFunc,
|
|
36
|
+
});
|
|
32
37
|
this.selectMenu_column.on(columnButton, this.#OnColumnEdit.bind(this));
|
|
33
38
|
this.selectMenu_column.create(columnMenu.items, columnMenu.menus);
|
|
34
39
|
|
|
35
40
|
// members - SelectMenu - row
|
|
36
41
|
const rownMenu = CreateRowMenu(this.#$.lang, this.#$.icons);
|
|
37
|
-
this.selectMenu_row = new SelectMenu(this.#$, {
|
|
42
|
+
this.selectMenu_row = new SelectMenu(this.#$, {
|
|
43
|
+
checkList: false,
|
|
44
|
+
position: 'bottom-center',
|
|
45
|
+
openMethod: openCellMenuFunc,
|
|
46
|
+
closeMethod: closeCellMenuFunc,
|
|
47
|
+
});
|
|
38
48
|
this.selectMenu_row.on(rowButton, this.#OnRowEdit.bind(this));
|
|
39
49
|
this.selectMenu_row.create(rownMenu.items, rownMenu.menus);
|
|
40
50
|
}
|
|
@@ -54,7 +64,11 @@ export class TableGridService {
|
|
|
54
64
|
* @description Opens the row menu.
|
|
55
65
|
*/
|
|
56
66
|
openRowMenu() {
|
|
57
|
-
this.selectMenu_row.menus[0].style.display = this.selectMenu_row.menus[1].style.display = /^TH$/i.test(
|
|
67
|
+
this.selectMenu_row.menus[0].style.display = this.selectMenu_row.menus[1].style.display = /^TH$/i.test(
|
|
68
|
+
this.#state.tdElement?.nodeName,
|
|
69
|
+
)
|
|
70
|
+
? 'none'
|
|
71
|
+
: '';
|
|
58
72
|
this.selectMenu_row.open();
|
|
59
73
|
}
|
|
60
74
|
|
|
@@ -77,7 +91,8 @@ export class TableGridService {
|
|
|
77
91
|
dom.utils.removeItem(this.#state.figureElement);
|
|
78
92
|
this.#main._closeTableSelectInfo();
|
|
79
93
|
} else {
|
|
80
|
-
table.innerHTML +=
|
|
94
|
+
table.innerHTML +=
|
|
95
|
+
'<tbody><tr>' + CreateCellsString('td', this.#state.logical_cellCnt) + '</tr></tbody>';
|
|
81
96
|
}
|
|
82
97
|
return;
|
|
83
98
|
}
|
|
@@ -274,7 +289,12 @@ export class TableGridService {
|
|
|
274
289
|
if (removeIndex >= insertIndex && removeIndex + cs <= insertIndex + colSpan) {
|
|
275
290
|
removeCell.push(cell);
|
|
276
291
|
} else if (removeIndex <= insertIndex + colSpan && removeIndex + cs >= insertIndex) {
|
|
277
|
-
cell.colSpan -= numbers.getOverlapRangeAtIndex(
|
|
292
|
+
cell.colSpan -= numbers.getOverlapRangeAtIndex(
|
|
293
|
+
cellIndex,
|
|
294
|
+
cellIndex + colSpan,
|
|
295
|
+
removeIndex,
|
|
296
|
+
removeIndex + cs,
|
|
297
|
+
);
|
|
278
298
|
} else if (rs > 0 && (removeIndex < insertIndex || removeIndex + cs > insertIndex + colSpan)) {
|
|
279
299
|
removeSpanArr.push({
|
|
280
300
|
cell: cell,
|
|
@@ -311,8 +331,11 @@ export class TableGridService {
|
|
|
311
331
|
if (remove) {
|
|
312
332
|
dom.utils.removeItem(cols[insertIndex]);
|
|
313
333
|
} else {
|
|
314
|
-
const isAutoLayout =
|
|
315
|
-
|
|
334
|
+
const isAutoLayout =
|
|
335
|
+
!dom.utils.hasClass(this.#main._element, 'se-table-layout-fixed') &&
|
|
336
|
+
this.#main._element.style.tableLayout !== 'fixed';
|
|
337
|
+
const hasWidth =
|
|
338
|
+
!isAutoLayout && Array.prototype.some.call(cols, (col) => numbers.get(col.style.width) > 0);
|
|
316
339
|
|
|
317
340
|
if (hasWidth) {
|
|
318
341
|
let totalW = 0;
|
|
@@ -345,7 +368,12 @@ export class TableGridService {
|
|
|
345
368
|
|
|
346
369
|
for (let c = 0, cLen = removeSpanArr.length, rowSpanCell; c < cLen; c++) {
|
|
347
370
|
rowSpanCell = removeSpanArr[c];
|
|
348
|
-
rowSpanCell.cell.rowSpan = numbers.getOverlapRangeAtIndex(
|
|
371
|
+
rowSpanCell.cell.rowSpan = numbers.getOverlapRangeAtIndex(
|
|
372
|
+
removeFirst,
|
|
373
|
+
removeEnd,
|
|
374
|
+
rowSpanCell.i,
|
|
375
|
+
rowSpanCell.rs,
|
|
376
|
+
);
|
|
349
377
|
}
|
|
350
378
|
|
|
351
379
|
this.#main._closeController();
|
|
@@ -408,7 +436,10 @@ export class TableGridService {
|
|
|
408
436
|
|
|
409
437
|
if (cell.rowSpan > 1) {
|
|
410
438
|
cell.rowSpan -= 1;
|
|
411
|
-
spanCells.push({
|
|
439
|
+
spanCells.push({
|
|
440
|
+
cell: /** @type {HTMLTableCellElement} */ (cell.cloneNode(true)),
|
|
441
|
+
index: logcalIndex,
|
|
442
|
+
});
|
|
412
443
|
}
|
|
413
444
|
}
|
|
414
445
|
|
|
@@ -61,7 +61,12 @@ export class TableResizeService {
|
|
|
61
61
|
this.#removeGlobalEvents();
|
|
62
62
|
if (this.#resizeLine?.style.display === 'block') this.#resizeLine.style.display = 'none';
|
|
63
63
|
this.#resizeLine = this.#$.frameContext.get('wrapper').querySelector(Constants.RESIZE_CELL_CLASS);
|
|
64
|
-
this.#setResizeLinePosition(
|
|
64
|
+
this.#setResizeLinePosition(
|
|
65
|
+
dom.query.getParentElement(target, dom.check.isTable),
|
|
66
|
+
target,
|
|
67
|
+
this.#resizeLine,
|
|
68
|
+
cellEdge.isLeft,
|
|
69
|
+
);
|
|
65
70
|
this.#resizeLine.style.display = 'block';
|
|
66
71
|
return false;
|
|
67
72
|
}
|
|
@@ -98,12 +103,15 @@ export class TableResizeService {
|
|
|
98
103
|
try {
|
|
99
104
|
this.#selectionService.deleteStyleSelectedCells();
|
|
100
105
|
this.#main.setCellInfo(target, true);
|
|
101
|
-
const colIndex =
|
|
106
|
+
const colIndex =
|
|
107
|
+
this.#state.logical_cellIndex + this.#state.current_colSpan - (cellEdge.isLeft ? 1 : 0);
|
|
102
108
|
|
|
103
109
|
// ready
|
|
104
110
|
this.#$.ui.enableBackWrapper('ew-resize');
|
|
105
111
|
this.#resizeLine ||= this.#$.frameContext.get('wrapper').querySelector(Constants.RESIZE_CELL_CLASS);
|
|
106
|
-
this.#resizeLinePrev = this.#$.frameContext
|
|
112
|
+
this.#resizeLinePrev = this.#$.frameContext
|
|
113
|
+
.get('wrapper')
|
|
114
|
+
.querySelector(Constants.RESIZE_CELL_PREV_CLASS);
|
|
107
115
|
|
|
108
116
|
// select figure
|
|
109
117
|
if (colIndex < 0 || colIndex === this.#state.logical_cellCnt - 1) {
|
|
@@ -112,8 +120,15 @@ export class TableResizeService {
|
|
|
112
120
|
return false;
|
|
113
121
|
}
|
|
114
122
|
|
|
115
|
-
const col = this.#main._element.querySelector('colgroup').querySelectorAll('col')[
|
|
116
|
-
|
|
123
|
+
const col = this.#main._element.querySelector('colgroup').querySelectorAll('col')[
|
|
124
|
+
colIndex < 0 ? 0 : colIndex
|
|
125
|
+
];
|
|
126
|
+
this._startCellResizing(
|
|
127
|
+
col,
|
|
128
|
+
cellEdge.startX,
|
|
129
|
+
numbers.get(_w.getComputedStyle(col).width, Constants.CELL_DECIMAL_END),
|
|
130
|
+
cellEdge.isLeft,
|
|
131
|
+
);
|
|
117
132
|
this.#main._editorEnable(false);
|
|
118
133
|
} catch (err) {
|
|
119
134
|
console.warn('[SUNEDITOR.plugins.table.error]', err);
|
|
@@ -148,9 +163,15 @@ export class TableResizeService {
|
|
|
148
163
|
// ready
|
|
149
164
|
this.#$.ui.enableBackWrapper('ns-resize');
|
|
150
165
|
this.#resizeLine ||= this.#$.frameContext.get('wrapper').querySelector(Constants.RESIZE_ROW_CLASS);
|
|
151
|
-
this.#resizeLinePrev = this.#$.frameContext
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
this.#resizeLinePrev = this.#$.frameContext
|
|
167
|
+
.get('wrapper')
|
|
168
|
+
.querySelector(Constants.RESIZE_ROW_PREV_CLASS);
|
|
169
|
+
|
|
170
|
+
this._startRowResizing(
|
|
171
|
+
row,
|
|
172
|
+
rowEdge.startY,
|
|
173
|
+
numbers.get(_w.getComputedStyle(row).height, Constants.CELL_DECIMAL_END),
|
|
174
|
+
);
|
|
154
175
|
this.#main._editorEnable(false);
|
|
155
176
|
} catch (err) {
|
|
156
177
|
console.warn('[SUNEDITOR.plugins.table.error]', err);
|
|
@@ -204,7 +225,9 @@ export class TableResizeService {
|
|
|
204
225
|
const prevValue = col.style.width;
|
|
205
226
|
const nextCol = /** @type {HTMLElement} */ (col.nextElementSibling);
|
|
206
227
|
const nextColPrevValue = nextCol.style.width;
|
|
207
|
-
const realWidth = dom.utils.hasClass(this.#main._element, 'se-table-layout-fixed')
|
|
228
|
+
const realWidth = dom.utils.hasClass(this.#main._element, 'se-table-layout-fixed')
|
|
229
|
+
? nextColPrevValue
|
|
230
|
+
: converter.getWidthInPercentage(nextCol || col);
|
|
208
231
|
|
|
209
232
|
if (_DragHandle.get('__dragHandler')) _DragHandle.get('__dragHandler').style.display = 'none';
|
|
210
233
|
this.#addResizeGlobalEvents(
|
|
@@ -251,7 +274,20 @@ export class TableResizeService {
|
|
|
251
274
|
* @param {number} tableWidth The total width of the table.
|
|
252
275
|
* @param {MouseEvent} e The mouse event.
|
|
253
276
|
*/
|
|
254
|
-
#cellResize(
|
|
277
|
+
#cellResize(
|
|
278
|
+
col,
|
|
279
|
+
nextCol,
|
|
280
|
+
figure,
|
|
281
|
+
tdEl,
|
|
282
|
+
resizeLine,
|
|
283
|
+
isLeftEdge,
|
|
284
|
+
startX,
|
|
285
|
+
startWidth,
|
|
286
|
+
prevWidthPercent,
|
|
287
|
+
nextColWidthPercent,
|
|
288
|
+
tableWidth,
|
|
289
|
+
e,
|
|
290
|
+
) {
|
|
255
291
|
const deltaX = e.clientX - startX;
|
|
256
292
|
const newWidthPx = startWidth + deltaX;
|
|
257
293
|
const newWidthPercent = (newWidthPx / tableWidth) * 100;
|
|
@@ -324,7 +360,15 @@ export class TableResizeService {
|
|
|
324
360
|
|
|
325
361
|
if (_DragHandle.get('__dragHandler')) _DragHandle.get('__dragHandler').style.display = 'none';
|
|
326
362
|
this.#addResizeGlobalEvents(
|
|
327
|
-
this.#figureResize.bind(
|
|
363
|
+
this.#figureResize.bind(
|
|
364
|
+
this,
|
|
365
|
+
figure,
|
|
366
|
+
this.#resizeLine,
|
|
367
|
+
isLeftEdge,
|
|
368
|
+
startX,
|
|
369
|
+
figure.offsetWidth,
|
|
370
|
+
numbers.get(realWidth, Constants.CELL_DECIMAL_END),
|
|
371
|
+
),
|
|
328
372
|
() => {
|
|
329
373
|
this.#removeGlobalEvents();
|
|
330
374
|
if (numbers.get(figure.style.width, 0) > 100) figure.style.width = '100%';
|
|
@@ -93,7 +93,10 @@ export class TableSelectionService {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// try cache
|
|
96
|
-
const cacheKey = getCacheKey(
|
|
96
|
+
const cacheKey = getCacheKey(
|
|
97
|
+
/** @type {HTMLTableCellElement} */ (startCell),
|
|
98
|
+
/** @type {HTMLTableCellElement} */ (endCell),
|
|
99
|
+
);
|
|
97
100
|
let tableCache = refCache.get(table);
|
|
98
101
|
const cachedRef = tableCache?.get(cacheKey);
|
|
99
102
|
|
|
@@ -186,7 +189,10 @@ export class TableSelectionService {
|
|
|
186
189
|
const newRs = ref.rs < i ? ref.rs : i;
|
|
187
190
|
const newRe = ref.re > i + rs ? ref.re : i + rs;
|
|
188
191
|
|
|
189
|
-
if (
|
|
192
|
+
if (
|
|
193
|
+
numbers.getOverlapRangeAtIndex(ref.cs, ref.ce, logcalIndex, logcalIndex + cs) &&
|
|
194
|
+
numbers.getOverlapRangeAtIndex(ref.rs, ref.re, i, i + rs)
|
|
195
|
+
) {
|
|
190
196
|
if (ref.cs !== newCs || ref.ce !== newCe || ref.rs !== newRs || ref.re !== newRe) {
|
|
191
197
|
ref.cs = newCs;
|
|
192
198
|
ref.ce = newCe;
|
|
@@ -262,7 +268,10 @@ export class TableSelectionService {
|
|
|
262
268
|
}
|
|
263
269
|
}
|
|
264
270
|
|
|
265
|
-
if (
|
|
271
|
+
if (
|
|
272
|
+
numbers.getOverlapRangeAtIndex(ref.cs, ref.ce, logcalIndex, logcalIndex + cs) &&
|
|
273
|
+
numbers.getOverlapRangeAtIndex(ref.rs, ref.re, i, i + rs)
|
|
274
|
+
) {
|
|
266
275
|
dom.utils.addClass(cell, 'se-selected-table-cell');
|
|
267
276
|
}
|
|
268
277
|
|
|
@@ -362,7 +371,9 @@ export class TableSelectionService {
|
|
|
362
371
|
*/
|
|
363
372
|
#OnCellMultiSelect(e) {
|
|
364
373
|
this.#$.store.set('_preventBlur', true);
|
|
365
|
-
const target = /** @type {HTMLTableCellElement} */ (
|
|
374
|
+
const target = /** @type {HTMLTableCellElement} */ (
|
|
375
|
+
dom.query.getParentElement(dom.query.getEventTarget(e), dom.check.isTableCell)
|
|
376
|
+
);
|
|
366
377
|
|
|
367
378
|
if (this.#state.isShiftPressed) {
|
|
368
379
|
if (target === this.#state.fixedCell) {
|
|
@@ -379,7 +390,12 @@ export class TableSelectionService {
|
|
|
379
390
|
else this.#main._editorEnable(false);
|
|
380
391
|
}
|
|
381
392
|
|
|
382
|
-
if (
|
|
393
|
+
if (
|
|
394
|
+
!target ||
|
|
395
|
+
target === this.#state.selectedCell ||
|
|
396
|
+
this.#fixedCellName !== target.nodeName ||
|
|
397
|
+
this.#state.selectedTable !== dom.query.getParentElement(target, 'TABLE')
|
|
398
|
+
) {
|
|
383
399
|
return;
|
|
384
400
|
}
|
|
385
401
|
|
|
@@ -405,7 +421,10 @@ export class TableSelectionService {
|
|
|
405
421
|
if (!fixedCell || !this.#state.selectedTable) return;
|
|
406
422
|
|
|
407
423
|
this.#cellService.setMergeSplitButton();
|
|
408
|
-
this.#main.setState(
|
|
424
|
+
this.#main.setState(
|
|
425
|
+
'selectedCells',
|
|
426
|
+
Array.from(this.#state.selectedTable.querySelectorAll('.se-selected-table-cell')),
|
|
427
|
+
);
|
|
409
428
|
|
|
410
429
|
if (this.#state.isShiftPressed) return;
|
|
411
430
|
|
|
@@ -432,7 +451,8 @@ export class TableSelectionService {
|
|
|
432
451
|
|
|
433
452
|
this.focusCellEdge(this.#state.fixedCell);
|
|
434
453
|
|
|
435
|
-
const displayCell =
|
|
454
|
+
const displayCell =
|
|
455
|
+
this.#state.selectedCells?.length > 0 ? this.#state.selectedCell : this.#state.fixedCell;
|
|
436
456
|
this.#main._setController(displayCell);
|
|
437
457
|
}
|
|
438
458
|
}
|