quill-table-up 3.1.2 → 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/README.md +7 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +168 -146
- package/dist/index.js +47 -47
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +52 -52
- package/dist/index.umd.js.map +1 -1
- package/package.json +22 -24
- package/src/__tests__/e2e/custom-creator.test.ts +44 -44
- package/src/__tests__/e2e/editor-page.ts +77 -77
- package/src/__tests__/e2e/table-align.test.ts +104 -104
- package/src/__tests__/e2e/table-blots.test.ts +169 -169
- package/src/__tests__/e2e/table-caption.test.ts +134 -134
- package/src/__tests__/e2e/table-clipboard.test.ts +20 -20
- package/src/__tests__/e2e/table-hack.test.ts +151 -151
- package/src/__tests__/e2e/table-keyboard-handler.test.ts +12 -3
- package/src/__tests__/e2e/table-menu.test.ts +172 -172
- package/src/__tests__/e2e/table-resize.test.ts +654 -9
- package/src/__tests__/e2e/table-scrollbar.test.ts +144 -144
- package/src/__tests__/e2e/table-selection.test.ts +563 -563
- package/src/__tests__/e2e/types.d.ts +7 -7
- package/src/__tests__/e2e/utils.ts +52 -52
- package/src/__tests__/unit/table-blots.test.ts +720 -720
- package/src/__tests__/unit/table-caption.test.ts +234 -234
- package/src/__tests__/unit/table-cell-merge.test.ts +724 -724
- package/src/__tests__/unit/table-clipboard.test.ts +2176 -2176
- package/src/__tests__/unit/table-hack.test.ts +1014 -1014
- package/src/__tests__/unit/table-insert.test.ts +926 -926
- package/src/__tests__/unit/table-redo-undo.test.ts +2429 -2429
- package/src/__tests__/unit/table-remove.test.ts +343 -343
- package/src/__tests__/unit/utils.test-d.ts +49 -49
- package/src/__tests__/unit/utils.test.ts +711 -711
- package/src/__tests__/unit/utils.ts +307 -307
- package/src/__tests__/unit/vitest.d.ts +14 -14
- package/src/formats/container-format.ts +107 -107
- package/src/formats/overrides/block-embed.ts +72 -72
- package/src/formats/overrides/block.ts +95 -95
- package/src/formats/overrides/index.ts +3 -3
- package/src/formats/overrides/scroll.ts +70 -70
- package/src/formats/table-body-format.ts +52 -52
- package/src/formats/table-caption-format.ts +116 -116
- package/src/formats/table-cell-format.ts +304 -304
- package/src/formats/table-cell-inner-format.ts +403 -398
- package/src/formats/table-colgroup-format.ts +136 -136
- package/src/formats/table-foot-format.ts +7 -7
- package/src/formats/table-head-format.ts +7 -7
- package/src/formats/table-main-format.ts +1 -1
- package/src/formats/table-row-format.ts +218 -210
- package/src/formats/utils.ts +6 -6
- package/src/index.ts +19 -19
- package/src/modules/index.ts +7 -7
- package/src/modules/table-align.ts +131 -131
- package/src/modules/table-clipboard/table-clipboard.ts +6 -8
- package/src/modules/table-dom-selector.ts +33 -33
- package/src/modules/table-menu/constants.ts +223 -223
- package/src/modules/table-menu/index.ts +4 -4
- package/src/modules/table-menu/table-menu-common.ts +330 -329
- package/src/modules/table-menu/table-menu-contextmenu.ts +111 -118
- package/src/modules/table-menu/table-menu-select.ts +96 -94
- package/src/modules/table-resize/index.ts +5 -5
- package/src/modules/table-resize/table-resize-box.ts +714 -363
- package/src/modules/table-resize/table-resize-common.ts +246 -382
- package/src/modules/table-resize/table-resize-drag.ts +241 -0
- package/src/modules/table-resize/table-resize-line.ts +244 -182
- package/src/modules/table-resize/table-resize-scale.ts +174 -173
- package/src/modules/table-resize/utils.ts +84 -3
- package/src/modules/table-scrollbar.ts +292 -292
- package/src/modules/table-selection.ts +613 -669
- package/src/style/button.less +45 -45
- package/src/style/color-picker.less +136 -136
- package/src/style/dialog.less +53 -53
- package/src/style/functions.less +9 -9
- package/src/style/index.less +120 -120
- package/src/style/input.less +64 -64
- package/src/style/select-box.less +52 -52
- package/src/style/table-creator.less +56 -56
- package/src/style/table-menu.less +125 -125
- package/src/style/table-resize-scale.less +31 -31
- package/src/style/table-resize.less +249 -202
- package/src/style/table-scrollbar.less +49 -49
- package/src/style/table-selection.less +23 -23
- package/src/style/tooltip.less +19 -19
- package/src/style/variables.less +1 -1
- package/src/svg/arrow-up-down.svg +11 -11
- package/src/svg/convert-cell.svg +7 -7
- package/src/table-up.ts +1360 -1360
- package/src/types.d.ts +4 -4
- package/src/utils/bem.ts +23 -23
- package/src/utils/blot-helper.ts +101 -105
- package/src/utils/color.ts +109 -109
- package/src/utils/components/button.ts +22 -22
- package/src/utils/components/color-picker.ts +236 -236
- package/src/utils/components/dialog.ts +83 -41
- package/src/utils/components/index.ts +6 -6
- package/src/utils/components/input.ts +74 -74
- package/src/utils/components/table/creator.ts +89 -89
- package/src/utils/components/table/index.ts +2 -2
- package/src/utils/components/table/select-box.ts +78 -78
- package/src/utils/components/tooltip.ts +179 -189
- package/src/utils/constants.ts +125 -124
- package/src/utils/drag-helper.ts +112 -0
- package/src/utils/index.ts +15 -14
- package/src/utils/is.ts +9 -9
- package/src/utils/position.ts +60 -60
- package/src/utils/resize-observer-helper.ts +47 -47
- package/src/utils/scroll.ts +145 -47
- package/src/utils/style-helper.ts +47 -47
- package/src/utils/transformer.ts +10 -10
- package/src/utils/transition-event-helper.ts +8 -8
- package/src/utils/types.ts +156 -157
- package/src/utils/utils.ts +12 -12
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
import type { TableCellInnerFormat, TableMainFormat } from '../../formats';
|
|
2
|
-
import type { TableUp } from '../../table-up';
|
|
3
|
-
import type { Tool } from '../../utils';
|
|
4
|
-
import Quill from 'quill';
|
|
5
|
-
import AutoFull from '../../svg/auto-full.svg';
|
|
6
|
-
import Background from '../../svg/background.svg';
|
|
7
|
-
import Border from '../../svg/border.svg';
|
|
8
|
-
import ConvertCell from '../../svg/convert-cell.svg';
|
|
9
|
-
import Copy from '../../svg/copy.svg';
|
|
10
|
-
import Cut from '../../svg/cut.svg';
|
|
11
|
-
import InsertBottom from '../../svg/insert-bottom.svg';
|
|
12
|
-
import InsertLeft from '../../svg/insert-left.svg';
|
|
13
|
-
import InsertRight from '../../svg/insert-right.svg';
|
|
14
|
-
import InsertTop from '../../svg/insert-top.svg';
|
|
15
|
-
import MergeCell from '../../svg/merge-cell.svg';
|
|
16
|
-
import RemoveColumn from '../../svg/remove-column.svg';
|
|
17
|
-
import RemoveRow from '../../svg/remove-row.svg';
|
|
18
|
-
import RemoveTable from '../../svg/remove-table.svg';
|
|
19
|
-
import SplitCell from '../../svg/split-cell.svg';
|
|
20
|
-
import TableHead from '../../svg/table-head.svg';
|
|
21
|
-
import { blotName, createBEM } from '../../utils';
|
|
22
|
-
|
|
23
|
-
export const menuColorSelectClassName = 'color-selector';
|
|
24
|
-
export async function copyCell(tableModule: TableUp, selectedTds: TableCellInnerFormat[], isCut: boolean = false) {
|
|
25
|
-
const text = tableModule.getTextByCell(selectedTds);
|
|
26
|
-
const html = tableModule.getHTMLByCell(selectedTds, isCut);
|
|
27
|
-
|
|
28
|
-
const clipboardItem = new ClipboardItem({
|
|
29
|
-
'text/plain': new Blob([text], { type: 'text/plain' }),
|
|
30
|
-
'text/html': new Blob([html], { type: 'text/html' }),
|
|
31
|
-
});
|
|
32
|
-
await navigator.clipboard.write([clipboardItem]);
|
|
33
|
-
}
|
|
34
|
-
export const tableMenuTools: Record<string, Tool> = {
|
|
35
|
-
Break: {
|
|
36
|
-
name: 'break',
|
|
37
|
-
},
|
|
38
|
-
CopyCell: {
|
|
39
|
-
name: 'CopyCell',
|
|
40
|
-
tip: 'Copy cell',
|
|
41
|
-
icon: Copy,
|
|
42
|
-
handle(tableModule, selectedTds) {
|
|
43
|
-
copyCell.call(this, tableModule, selectedTds, false);
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
CutCell: {
|
|
47
|
-
name: 'CutCell',
|
|
48
|
-
tip: 'Cut cell',
|
|
49
|
-
icon: Cut,
|
|
50
|
-
handle(tableModule, selectedTds) {
|
|
51
|
-
copyCell.call(this, tableModule, selectedTds, true);
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
InsertTop: {
|
|
55
|
-
name: 'InsertTop',
|
|
56
|
-
icon: InsertTop,
|
|
57
|
-
tip: 'Insert row above',
|
|
58
|
-
handle(tableModule, selectedTds) {
|
|
59
|
-
tableModule.appendRow(selectedTds, false);
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
InsertRight: {
|
|
63
|
-
name: 'InsertRight',
|
|
64
|
-
icon: InsertRight,
|
|
65
|
-
tip: 'Insert column right',
|
|
66
|
-
handle(tableModule, selectedTds) {
|
|
67
|
-
tableModule.appendCol(selectedTds, true);
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
InsertBottom: {
|
|
71
|
-
name: 'InsertBottom',
|
|
72
|
-
icon: InsertBottom,
|
|
73
|
-
tip: 'Insert row below',
|
|
74
|
-
handle(tableModule, selectedTds) {
|
|
75
|
-
tableModule.appendRow(selectedTds, true);
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
InsertLeft: {
|
|
79
|
-
name: 'InsertLeft',
|
|
80
|
-
icon: InsertLeft,
|
|
81
|
-
tip: 'Insert column Left',
|
|
82
|
-
handle(tableModule, selectedTds) {
|
|
83
|
-
tableModule.appendCol(selectedTds, false);
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
MergeCell: {
|
|
87
|
-
name: 'MergeCell',
|
|
88
|
-
icon: MergeCell,
|
|
89
|
-
tip: 'Merge Cell',
|
|
90
|
-
handle(tableModule, selectedTds) {
|
|
91
|
-
tableModule.mergeCells(selectedTds);
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
SplitCell: {
|
|
95
|
-
name: 'SplitCell',
|
|
96
|
-
icon: SplitCell,
|
|
97
|
-
tip: 'Split Cell',
|
|
98
|
-
handle(tableModule, selectedTds) {
|
|
99
|
-
tableModule.splitCell(selectedTds);
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
DeleteRow: {
|
|
103
|
-
name: 'DeleteRow',
|
|
104
|
-
icon: RemoveRow,
|
|
105
|
-
tip: 'Delete Row',
|
|
106
|
-
handle(tableModule, selectedTds) {
|
|
107
|
-
tableModule.removeRow(selectedTds);
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
DeleteColumn: {
|
|
111
|
-
name: 'DeleteColumn',
|
|
112
|
-
icon: RemoveColumn,
|
|
113
|
-
tip: 'Delete Column',
|
|
114
|
-
handle(tableModule, selectedTds) {
|
|
115
|
-
tableModule.removeCol(selectedTds);
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
DeleteTable: {
|
|
119
|
-
name: 'DeleteTable',
|
|
120
|
-
icon: RemoveTable,
|
|
121
|
-
tip: 'Delete table',
|
|
122
|
-
handle(tableModule, selectedTds) {
|
|
123
|
-
tableModule.deleteTable(selectedTds);
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
BackgroundColor: {
|
|
127
|
-
name: 'BackgroundColor',
|
|
128
|
-
icon: Background,
|
|
129
|
-
isColorChoose: true,
|
|
130
|
-
tip: 'Set background color',
|
|
131
|
-
key: 'background-color',
|
|
132
|
-
handle(tableModule, selectedTds, color) {
|
|
133
|
-
tableModule.setCellAttrs(selectedTds, 'background-color', color, true);
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
BorderColor: {
|
|
137
|
-
name: 'BorderColor',
|
|
138
|
-
icon: Border,
|
|
139
|
-
isColorChoose: true,
|
|
140
|
-
tip: 'Set border color',
|
|
141
|
-
key: 'border-color',
|
|
142
|
-
handle(tableModule, selectedTds, color) {
|
|
143
|
-
tableModule.setCellAttrs(selectedTds, 'border-color', color, true);
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
SwitchWidth: {
|
|
147
|
-
name: 'SwitchWidth',
|
|
148
|
-
icon: AutoFull,
|
|
149
|
-
tip: 'Switch table width',
|
|
150
|
-
handle() {
|
|
151
|
-
if (!this.table) return;
|
|
152
|
-
const tableMainBlot = Quill.find(this.table) as TableMainFormat;
|
|
153
|
-
if (!tableMainBlot) return;
|
|
154
|
-
|
|
155
|
-
if (tableMainBlot.full) {
|
|
156
|
-
tableMainBlot.cancelFull();
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
tableMainBlot.setFull();
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
InsertCaption: {
|
|
164
|
-
name: 'InsertCaption',
|
|
165
|
-
icon: TableHead,
|
|
166
|
-
tip: 'Insert table caption',
|
|
167
|
-
handle() {
|
|
168
|
-
if (!this.table) return;
|
|
169
|
-
const tableMainBlot = Quill.find(this.table) as TableMainFormat;
|
|
170
|
-
if (!tableMainBlot) return;
|
|
171
|
-
|
|
172
|
-
const tableCaption = this.quill.scroll.create('text', 'Table Caption').wrap(blotName.tableCaption, {
|
|
173
|
-
tableId: tableMainBlot.tableId,
|
|
174
|
-
});
|
|
175
|
-
tableMainBlot.insertBefore(tableCaption, tableMainBlot.children.head);
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
ToggleTdBetweenTh: {
|
|
179
|
-
name: 'ToggleTdBetweenTh',
|
|
180
|
-
icon: ConvertCell,
|
|
181
|
-
tip: 'Toggle td between th',
|
|
182
|
-
handle(tableModule, selectedTds) {
|
|
183
|
-
for (const td of selectedTds) {
|
|
184
|
-
td.convertTableCell();
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
ConvertTothead: {
|
|
189
|
-
name: 'ConvertTothead',
|
|
190
|
-
icon: ConvertCell,
|
|
191
|
-
tip: 'Convert to thead',
|
|
192
|
-
handle(tableModule, selectedTds) {
|
|
193
|
-
if (!this.table) return;
|
|
194
|
-
const tableMainBlot = Quill.find(this.table) as TableMainFormat;
|
|
195
|
-
if (!tableMainBlot) return;
|
|
196
|
-
|
|
197
|
-
tableModule.convertTableBodyByCells(tableMainBlot, selectedTds, 'thead');
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
ConvertTotfoot: {
|
|
201
|
-
name: 'ConvertTotfoot',
|
|
202
|
-
icon: ConvertCell,
|
|
203
|
-
tip: 'Convert to tfoot',
|
|
204
|
-
handle(tableModule, selectedTds) {
|
|
205
|
-
if (!this.table) return;
|
|
206
|
-
const tableMainBlot = Quill.find(this.table) as TableMainFormat;
|
|
207
|
-
if (!tableMainBlot) return;
|
|
208
|
-
|
|
209
|
-
tableModule.convertTableBodyByCells(tableMainBlot, selectedTds, 'tfoot');
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export const maxSaveColorCount = 10;
|
|
215
|
-
const bem = createBEM('color-map');
|
|
216
|
-
export const colorClassName = {
|
|
217
|
-
selectWrapper: bem.b(),
|
|
218
|
-
used: bem.bm('used'),
|
|
219
|
-
item: bem.be('item'),
|
|
220
|
-
btn: bem.be('btn'),
|
|
221
|
-
map: bem.be('content'),
|
|
222
|
-
mapRow: bem.be('content-row'),
|
|
223
|
-
};
|
|
1
|
+
import type { TableCellInnerFormat, TableMainFormat } from '../../formats';
|
|
2
|
+
import type { TableUp } from '../../table-up';
|
|
3
|
+
import type { Tool } from '../../utils';
|
|
4
|
+
import Quill from 'quill';
|
|
5
|
+
import AutoFull from '../../svg/auto-full.svg';
|
|
6
|
+
import Background from '../../svg/background.svg';
|
|
7
|
+
import Border from '../../svg/border.svg';
|
|
8
|
+
import ConvertCell from '../../svg/convert-cell.svg';
|
|
9
|
+
import Copy from '../../svg/copy.svg';
|
|
10
|
+
import Cut from '../../svg/cut.svg';
|
|
11
|
+
import InsertBottom from '../../svg/insert-bottom.svg';
|
|
12
|
+
import InsertLeft from '../../svg/insert-left.svg';
|
|
13
|
+
import InsertRight from '../../svg/insert-right.svg';
|
|
14
|
+
import InsertTop from '../../svg/insert-top.svg';
|
|
15
|
+
import MergeCell from '../../svg/merge-cell.svg';
|
|
16
|
+
import RemoveColumn from '../../svg/remove-column.svg';
|
|
17
|
+
import RemoveRow from '../../svg/remove-row.svg';
|
|
18
|
+
import RemoveTable from '../../svg/remove-table.svg';
|
|
19
|
+
import SplitCell from '../../svg/split-cell.svg';
|
|
20
|
+
import TableHead from '../../svg/table-head.svg';
|
|
21
|
+
import { blotName, createBEM } from '../../utils';
|
|
22
|
+
|
|
23
|
+
export const menuColorSelectClassName = 'color-selector';
|
|
24
|
+
export async function copyCell(tableModule: TableUp, selectedTds: TableCellInnerFormat[], isCut: boolean = false) {
|
|
25
|
+
const text = tableModule.getTextByCell(selectedTds);
|
|
26
|
+
const html = tableModule.getHTMLByCell(selectedTds, isCut);
|
|
27
|
+
|
|
28
|
+
const clipboardItem = new ClipboardItem({
|
|
29
|
+
'text/plain': new Blob([text], { type: 'text/plain' }),
|
|
30
|
+
'text/html': new Blob([html], { type: 'text/html' }),
|
|
31
|
+
});
|
|
32
|
+
await navigator.clipboard.write([clipboardItem]);
|
|
33
|
+
}
|
|
34
|
+
export const tableMenuTools: Record<string, Tool> = {
|
|
35
|
+
Break: {
|
|
36
|
+
name: 'break',
|
|
37
|
+
},
|
|
38
|
+
CopyCell: {
|
|
39
|
+
name: 'CopyCell',
|
|
40
|
+
tip: 'Copy cell',
|
|
41
|
+
icon: Copy,
|
|
42
|
+
handle(tableModule, selectedTds) {
|
|
43
|
+
copyCell.call(this, tableModule, selectedTds, false);
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
CutCell: {
|
|
47
|
+
name: 'CutCell',
|
|
48
|
+
tip: 'Cut cell',
|
|
49
|
+
icon: Cut,
|
|
50
|
+
handle(tableModule, selectedTds) {
|
|
51
|
+
copyCell.call(this, tableModule, selectedTds, true);
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
InsertTop: {
|
|
55
|
+
name: 'InsertTop',
|
|
56
|
+
icon: InsertTop,
|
|
57
|
+
tip: 'Insert row above',
|
|
58
|
+
handle(tableModule, selectedTds) {
|
|
59
|
+
tableModule.appendRow(selectedTds, false);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
InsertRight: {
|
|
63
|
+
name: 'InsertRight',
|
|
64
|
+
icon: InsertRight,
|
|
65
|
+
tip: 'Insert column right',
|
|
66
|
+
handle(tableModule, selectedTds) {
|
|
67
|
+
tableModule.appendCol(selectedTds, true);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
InsertBottom: {
|
|
71
|
+
name: 'InsertBottom',
|
|
72
|
+
icon: InsertBottom,
|
|
73
|
+
tip: 'Insert row below',
|
|
74
|
+
handle(tableModule, selectedTds) {
|
|
75
|
+
tableModule.appendRow(selectedTds, true);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
InsertLeft: {
|
|
79
|
+
name: 'InsertLeft',
|
|
80
|
+
icon: InsertLeft,
|
|
81
|
+
tip: 'Insert column Left',
|
|
82
|
+
handle(tableModule, selectedTds) {
|
|
83
|
+
tableModule.appendCol(selectedTds, false);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
MergeCell: {
|
|
87
|
+
name: 'MergeCell',
|
|
88
|
+
icon: MergeCell,
|
|
89
|
+
tip: 'Merge Cell',
|
|
90
|
+
handle(tableModule, selectedTds) {
|
|
91
|
+
tableModule.mergeCells(selectedTds);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
SplitCell: {
|
|
95
|
+
name: 'SplitCell',
|
|
96
|
+
icon: SplitCell,
|
|
97
|
+
tip: 'Split Cell',
|
|
98
|
+
handle(tableModule, selectedTds) {
|
|
99
|
+
tableModule.splitCell(selectedTds);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
DeleteRow: {
|
|
103
|
+
name: 'DeleteRow',
|
|
104
|
+
icon: RemoveRow,
|
|
105
|
+
tip: 'Delete Row',
|
|
106
|
+
handle(tableModule, selectedTds) {
|
|
107
|
+
tableModule.removeRow(selectedTds);
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
DeleteColumn: {
|
|
111
|
+
name: 'DeleteColumn',
|
|
112
|
+
icon: RemoveColumn,
|
|
113
|
+
tip: 'Delete Column',
|
|
114
|
+
handle(tableModule, selectedTds) {
|
|
115
|
+
tableModule.removeCol(selectedTds);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
DeleteTable: {
|
|
119
|
+
name: 'DeleteTable',
|
|
120
|
+
icon: RemoveTable,
|
|
121
|
+
tip: 'Delete table',
|
|
122
|
+
handle(tableModule, selectedTds) {
|
|
123
|
+
tableModule.deleteTable(selectedTds);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
BackgroundColor: {
|
|
127
|
+
name: 'BackgroundColor',
|
|
128
|
+
icon: Background,
|
|
129
|
+
isColorChoose: true,
|
|
130
|
+
tip: 'Set background color',
|
|
131
|
+
key: 'background-color',
|
|
132
|
+
handle(tableModule, selectedTds, color) {
|
|
133
|
+
tableModule.setCellAttrs(selectedTds, 'background-color', color, true);
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
BorderColor: {
|
|
137
|
+
name: 'BorderColor',
|
|
138
|
+
icon: Border,
|
|
139
|
+
isColorChoose: true,
|
|
140
|
+
tip: 'Set border color',
|
|
141
|
+
key: 'border-color',
|
|
142
|
+
handle(tableModule, selectedTds, color) {
|
|
143
|
+
tableModule.setCellAttrs(selectedTds, 'border-color', color, true);
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
SwitchWidth: {
|
|
147
|
+
name: 'SwitchWidth',
|
|
148
|
+
icon: AutoFull,
|
|
149
|
+
tip: 'Switch table width',
|
|
150
|
+
handle() {
|
|
151
|
+
if (!this.table) return;
|
|
152
|
+
const tableMainBlot = Quill.find(this.table) as TableMainFormat;
|
|
153
|
+
if (!tableMainBlot) return;
|
|
154
|
+
|
|
155
|
+
if (tableMainBlot.full) {
|
|
156
|
+
tableMainBlot.cancelFull();
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
tableMainBlot.setFull();
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
InsertCaption: {
|
|
164
|
+
name: 'InsertCaption',
|
|
165
|
+
icon: TableHead,
|
|
166
|
+
tip: 'Insert table caption',
|
|
167
|
+
handle() {
|
|
168
|
+
if (!this.table) return;
|
|
169
|
+
const tableMainBlot = Quill.find(this.table) as TableMainFormat;
|
|
170
|
+
if (!tableMainBlot) return;
|
|
171
|
+
|
|
172
|
+
const tableCaption = this.quill.scroll.create('text', 'Table Caption').wrap(blotName.tableCaption, {
|
|
173
|
+
tableId: tableMainBlot.tableId,
|
|
174
|
+
});
|
|
175
|
+
tableMainBlot.insertBefore(tableCaption, tableMainBlot.children.head);
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
ToggleTdBetweenTh: {
|
|
179
|
+
name: 'ToggleTdBetweenTh',
|
|
180
|
+
icon: ConvertCell,
|
|
181
|
+
tip: 'Toggle td between th',
|
|
182
|
+
handle(tableModule, selectedTds) {
|
|
183
|
+
for (const td of selectedTds) {
|
|
184
|
+
td.convertTableCell();
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
ConvertTothead: {
|
|
189
|
+
name: 'ConvertTothead',
|
|
190
|
+
icon: ConvertCell,
|
|
191
|
+
tip: 'Convert to thead',
|
|
192
|
+
handle(tableModule, selectedTds) {
|
|
193
|
+
if (!this.table) return;
|
|
194
|
+
const tableMainBlot = Quill.find(this.table) as TableMainFormat;
|
|
195
|
+
if (!tableMainBlot) return;
|
|
196
|
+
|
|
197
|
+
tableModule.convertTableBodyByCells(tableMainBlot, selectedTds, 'thead');
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
ConvertTotfoot: {
|
|
201
|
+
name: 'ConvertTotfoot',
|
|
202
|
+
icon: ConvertCell,
|
|
203
|
+
tip: 'Convert to tfoot',
|
|
204
|
+
handle(tableModule, selectedTds) {
|
|
205
|
+
if (!this.table) return;
|
|
206
|
+
const tableMainBlot = Quill.find(this.table) as TableMainFormat;
|
|
207
|
+
if (!tableMainBlot) return;
|
|
208
|
+
|
|
209
|
+
tableModule.convertTableBodyByCells(tableMainBlot, selectedTds, 'tfoot');
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export const maxSaveColorCount = 10;
|
|
215
|
+
const bem = createBEM('color-map');
|
|
216
|
+
export const colorClassName = {
|
|
217
|
+
selectWrapper: bem.b(),
|
|
218
|
+
used: bem.bm('used'),
|
|
219
|
+
item: bem.be('item'),
|
|
220
|
+
btn: bem.be('btn'),
|
|
221
|
+
map: bem.be('content'),
|
|
222
|
+
mapRow: bem.be('content-row'),
|
|
223
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { tableMenuTools } from './constants';
|
|
2
|
-
export * from './table-menu-common';
|
|
3
|
-
export * from './table-menu-contextmenu';
|
|
4
|
-
export * from './table-menu-select';
|
|
1
|
+
export { tableMenuTools } from './constants';
|
|
2
|
+
export * from './table-menu-common';
|
|
3
|
+
export * from './table-menu-contextmenu';
|
|
4
|
+
export * from './table-menu-select';
|