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,189 +1,179 @@
|
|
|
1
|
-
import {
|
|
2
|
-
autoUpdate,
|
|
3
|
-
computePosition,
|
|
4
|
-
flip,
|
|
5
|
-
limitShift,
|
|
6
|
-
offset,
|
|
7
|
-
shift,
|
|
8
|
-
} from '@floating-ui/dom';
|
|
9
|
-
import { createBEM } from '../bem';
|
|
10
|
-
import { handleIfTransitionend } from '../transition-event-helper';
|
|
11
|
-
|
|
12
|
-
export interface ToolTipOptions {
|
|
13
|
-
direction?:
|
|
14
|
-
| 'top'
|
|
15
|
-
| 'top-start'
|
|
16
|
-
| 'top-end'
|
|
17
|
-
| 'bottom'
|
|
18
|
-
| 'bottom-start'
|
|
19
|
-
| 'bottom-end'
|
|
20
|
-
| 'right'
|
|
21
|
-
| 'right-start'
|
|
22
|
-
| 'right-end'
|
|
23
|
-
| 'left'
|
|
24
|
-
| 'left-start'
|
|
25
|
-
| 'left-end';
|
|
26
|
-
msg?: string;
|
|
27
|
-
delay?: number;
|
|
28
|
-
content?: HTMLElement;
|
|
29
|
-
container?: HTMLElement;
|
|
30
|
-
type?: 'hover' | 'click';
|
|
31
|
-
onOpen?: (force?: boolean) => boolean;
|
|
32
|
-
onClose?: (force?: boolean) => boolean;
|
|
33
|
-
closed?: () => void;
|
|
34
|
-
onDestroy?: () => void;
|
|
35
|
-
}
|
|
36
|
-
const DISTANCE = 4;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
tooltip
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
tooltip.remove();
|
|
181
|
-
};
|
|
182
|
-
return {
|
|
183
|
-
show,
|
|
184
|
-
hide,
|
|
185
|
-
destroy,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
autoUpdate,
|
|
3
|
+
computePosition,
|
|
4
|
+
flip,
|
|
5
|
+
limitShift,
|
|
6
|
+
offset,
|
|
7
|
+
shift,
|
|
8
|
+
} from '@floating-ui/dom';
|
|
9
|
+
import { createBEM } from '../bem';
|
|
10
|
+
import { handleIfTransitionend } from '../transition-event-helper';
|
|
11
|
+
|
|
12
|
+
export interface ToolTipOptions {
|
|
13
|
+
direction?:
|
|
14
|
+
| 'top'
|
|
15
|
+
| 'top-start'
|
|
16
|
+
| 'top-end'
|
|
17
|
+
| 'bottom'
|
|
18
|
+
| 'bottom-start'
|
|
19
|
+
| 'bottom-end'
|
|
20
|
+
| 'right'
|
|
21
|
+
| 'right-start'
|
|
22
|
+
| 'right-end'
|
|
23
|
+
| 'left'
|
|
24
|
+
| 'left-start'
|
|
25
|
+
| 'left-end';
|
|
26
|
+
msg?: string;
|
|
27
|
+
delay?: number;
|
|
28
|
+
content?: HTMLElement;
|
|
29
|
+
container?: HTMLElement;
|
|
30
|
+
type?: 'hover' | 'click';
|
|
31
|
+
onOpen?: (force?: boolean) => boolean;
|
|
32
|
+
onClose?: (force?: boolean) => boolean;
|
|
33
|
+
closed?: () => void;
|
|
34
|
+
onDestroy?: () => void;
|
|
35
|
+
}
|
|
36
|
+
const DISTANCE = 4;
|
|
37
|
+
export interface TooltipInstance {
|
|
38
|
+
destroy: () => void;
|
|
39
|
+
show: (force?: boolean) => void;
|
|
40
|
+
hide: (force?: boolean) => void;
|
|
41
|
+
}
|
|
42
|
+
export function createTooltip(target: HTMLElement, options: ToolTipOptions = {}): TooltipInstance | null {
|
|
43
|
+
const { msg = '', delay = 150, content, direction = 'bottom', type = 'hover', container, onOpen, onClose, closed, onDestroy } = options;
|
|
44
|
+
const bem = createBEM('tooltip');
|
|
45
|
+
if (msg || content) {
|
|
46
|
+
const appendTo = container || document.body;
|
|
47
|
+
const tooltip = document.createElement('div');
|
|
48
|
+
tooltip.classList.add(bem.b(), 'hidden', 'transparent');
|
|
49
|
+
if (content) {
|
|
50
|
+
tooltip.appendChild(content);
|
|
51
|
+
}
|
|
52
|
+
else if (msg) {
|
|
53
|
+
tooltip.textContent = msg;
|
|
54
|
+
}
|
|
55
|
+
let showTimer: ReturnType<typeof setTimeout> | undefined;
|
|
56
|
+
let closeTimer: ReturnType<typeof setTimeout> | undefined;
|
|
57
|
+
let cleanup: () => void;
|
|
58
|
+
const update = () => {
|
|
59
|
+
if (cleanup) cleanup();
|
|
60
|
+
computePosition(target, tooltip, {
|
|
61
|
+
placement: direction,
|
|
62
|
+
middleware: [flip(), shift({ limiter: limitShift() }), offset(DISTANCE)],
|
|
63
|
+
}).then(({ x, y }) => {
|
|
64
|
+
Object.assign(tooltip.style, {
|
|
65
|
+
left: `${x}px`,
|
|
66
|
+
top: `${y}px`,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const transitionendHandler = () => {
|
|
71
|
+
tooltip.classList.add('hidden');
|
|
72
|
+
if (appendTo.contains(tooltip)) {
|
|
73
|
+
appendTo.removeChild(tooltip);
|
|
74
|
+
}
|
|
75
|
+
if (cleanup) cleanup();
|
|
76
|
+
if (closed) closed();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const openTooltip = (force: boolean = false) => {
|
|
80
|
+
if (closeTimer) clearTimeout(closeTimer);
|
|
81
|
+
|
|
82
|
+
showTimer = setTimeout(() => {
|
|
83
|
+
if (onOpen) {
|
|
84
|
+
const allow = onOpen(force);
|
|
85
|
+
if (!force && allow) return;
|
|
86
|
+
}
|
|
87
|
+
appendTo.appendChild(tooltip);
|
|
88
|
+
tooltip.removeEventListener('transitionend', transitionendHandler);
|
|
89
|
+
tooltip.classList.remove('hidden');
|
|
90
|
+
|
|
91
|
+
cleanup = autoUpdate(target, tooltip, update);
|
|
92
|
+
|
|
93
|
+
tooltip.classList.remove('transparent');
|
|
94
|
+
}, delay);
|
|
95
|
+
};
|
|
96
|
+
const closeTooltip = (force: boolean = false) => {
|
|
97
|
+
if (showTimer) clearTimeout(showTimer);
|
|
98
|
+
closeTimer = setTimeout(() => {
|
|
99
|
+
if (onClose) {
|
|
100
|
+
const allow = onClose(force);
|
|
101
|
+
if (!force && allow) return;
|
|
102
|
+
}
|
|
103
|
+
handleIfTransitionend(tooltip, 150, transitionendHandler, { once: true });
|
|
104
|
+
tooltip.classList.add('transparent');
|
|
105
|
+
}, delay);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const hoverDisplay = () => {
|
|
109
|
+
const eventListeners = [target, tooltip];
|
|
110
|
+
const close = closeTooltip.bind(undefined, false);
|
|
111
|
+
const open = openTooltip.bind(undefined, false);
|
|
112
|
+
const prepare = () => {
|
|
113
|
+
for (const listener of eventListeners) {
|
|
114
|
+
listener.addEventListener('mouseenter', open);
|
|
115
|
+
listener.addEventListener('mouseleave', close);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
prepare,
|
|
120
|
+
show: openTooltip,
|
|
121
|
+
hide: closeTooltip,
|
|
122
|
+
destroy: () => {
|
|
123
|
+
for (const listener of eventListeners) {
|
|
124
|
+
listener.removeEventListener('mouseenter', open);
|
|
125
|
+
listener.removeEventListener('mouseleave', close);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
const clickDisplay = () => {
|
|
131
|
+
const close = (e: MouseEvent) => {
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
closeTooltip(false);
|
|
134
|
+
};
|
|
135
|
+
const show = (e: MouseEvent) => {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
openTooltip();
|
|
138
|
+
document.removeEventListener('click', close);
|
|
139
|
+
document.addEventListener('click', close, { once: true });
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
prepare: () => {
|
|
143
|
+
tooltip.addEventListener('click', (e: Event) => e.stopPropagation());
|
|
144
|
+
target.addEventListener('click', show);
|
|
145
|
+
},
|
|
146
|
+
show: openTooltip,
|
|
147
|
+
hide: (force: boolean = false) => {
|
|
148
|
+
closeTooltip(force);
|
|
149
|
+
document.removeEventListener('click', close);
|
|
150
|
+
},
|
|
151
|
+
destroy: () => {
|
|
152
|
+
target.removeEventListener('click', show);
|
|
153
|
+
document.removeEventListener('click', close);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
const displayMethods = {
|
|
158
|
+
hover: hoverDisplay,
|
|
159
|
+
click: clickDisplay,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const { prepare, show, hide, destroy: destroyDisplay } = displayMethods[type]();
|
|
163
|
+
prepare();
|
|
164
|
+
|
|
165
|
+
const destroy = () => {
|
|
166
|
+
hide(true);
|
|
167
|
+
if (onDestroy) onDestroy();
|
|
168
|
+
destroyDisplay();
|
|
169
|
+
if (cleanup) cleanup();
|
|
170
|
+
tooltip.remove();
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
show,
|
|
174
|
+
hide,
|
|
175
|
+
destroy,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
package/src/utils/constants.ts
CHANGED
|
@@ -1,124 +1,125 @@
|
|
|
1
|
-
import type { Parchment as TypeParchment } from 'quill';
|
|
2
|
-
|
|
3
|
-
export const blotName = {
|
|
4
|
-
container: 'table-up-container',
|
|
5
|
-
tableCaption: 'table-up-caption',
|
|
6
|
-
tableWrapper: 'table-up',
|
|
7
|
-
tableMain: 'table-up-main',
|
|
8
|
-
tableColgroup: 'table-up-colgroup',
|
|
9
|
-
tableCol: 'table-up-col',
|
|
10
|
-
tableHead: 'table-up-head',
|
|
11
|
-
tableBody: 'table-up-body',
|
|
12
|
-
tableFoot: 'table-up-foot',
|
|
13
|
-
tableRow: 'table-up-row',
|
|
14
|
-
tableCell: 'table-up-cell',
|
|
15
|
-
tableCellInner: 'table-up-cell-inner',
|
|
16
|
-
} as const;
|
|
17
|
-
|
|
18
|
-
export const tableUpSize = {
|
|
19
|
-
colMinWidthPre: 5,
|
|
20
|
-
colMinWidthPx: 40,
|
|
21
|
-
colDefaultWidth: 100,
|
|
22
|
-
rowMinHeightPx: 36,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const tableUpEvent = {
|
|
26
|
-
AFTER_TABLE_RESIZE: 'after-table-resize',
|
|
27
|
-
TABLE_SELECTION_DRAG_START: 'table-selection-drag-start',
|
|
28
|
-
TABLE_SELECTION_DRAG_END: 'table-selection-drag-end',
|
|
29
|
-
TABLE_SELECTION_CHANGE: 'table-selection-change',
|
|
30
|
-
TABLE_SELECTION_DISPLAY_CHANGE: 'table-selection-display-change',
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const tableUpInternal = {
|
|
34
|
-
moduleName: 'table-up',
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'rgb(
|
|
41
|
-
'rgb(
|
|
42
|
-
'rgb(
|
|
43
|
-
'rgb(
|
|
44
|
-
'rgb(
|
|
45
|
-
'rgb(
|
|
46
|
-
'rgb(
|
|
47
|
-
'rgb(
|
|
48
|
-
'rgb(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
'rgb(
|
|
53
|
-
'rgb(
|
|
54
|
-
'rgb(
|
|
55
|
-
'rgb(229,
|
|
56
|
-
'rgb(
|
|
57
|
-
'rgb(
|
|
58
|
-
'rgb(254,
|
|
59
|
-
'rgb(254,
|
|
60
|
-
'rgb(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
'rgb(
|
|
65
|
-
'rgb(
|
|
66
|
-
'rgb(
|
|
67
|
-
'rgb(199,
|
|
68
|
-
'rgb(
|
|
69
|
-
'rgb(
|
|
70
|
-
'rgb(255,
|
|
71
|
-
'rgb(255,
|
|
72
|
-
'rgb(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
'rgb(
|
|
77
|
-
'rgb(
|
|
78
|
-
'rgb(
|
|
79
|
-
'rgb(153,
|
|
80
|
-
'rgb(
|
|
81
|
-
'rgb(
|
|
82
|
-
'rgb(255,
|
|
83
|
-
'rgb(255,
|
|
84
|
-
'rgb(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
'rgb(
|
|
89
|
-
'rgb(
|
|
90
|
-
'rgb(
|
|
91
|
-
'rgb(
|
|
92
|
-
'rgb(
|
|
93
|
-
'rgb(
|
|
94
|
-
'rgb(
|
|
95
|
-
'rgb(
|
|
96
|
-
'rgb(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'rgb(
|
|
101
|
-
'rgb(
|
|
102
|
-
'rgb(
|
|
103
|
-
'rgb(
|
|
104
|
-
'rgb(
|
|
105
|
-
'rgb(
|
|
106
|
-
'rgb(
|
|
107
|
-
'rgb(
|
|
108
|
-
'rgb(
|
|
109
|
-
|
|
110
|
-
]
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
export
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
import type { Parchment as TypeParchment } from 'quill';
|
|
2
|
+
|
|
3
|
+
export const blotName = {
|
|
4
|
+
container: 'table-up-container',
|
|
5
|
+
tableCaption: 'table-up-caption',
|
|
6
|
+
tableWrapper: 'table-up',
|
|
7
|
+
tableMain: 'table-up-main',
|
|
8
|
+
tableColgroup: 'table-up-colgroup',
|
|
9
|
+
tableCol: 'table-up-col',
|
|
10
|
+
tableHead: 'table-up-head',
|
|
11
|
+
tableBody: 'table-up-body',
|
|
12
|
+
tableFoot: 'table-up-foot',
|
|
13
|
+
tableRow: 'table-up-row',
|
|
14
|
+
tableCell: 'table-up-cell',
|
|
15
|
+
tableCellInner: 'table-up-cell-inner',
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
export const tableUpSize = {
|
|
19
|
+
colMinWidthPre: 5,
|
|
20
|
+
colMinWidthPx: 40,
|
|
21
|
+
colDefaultWidth: 100,
|
|
22
|
+
rowMinHeightPx: 36,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const tableUpEvent = {
|
|
26
|
+
AFTER_TABLE_RESIZE: 'after-table-resize',
|
|
27
|
+
TABLE_SELECTION_DRAG_START: 'table-selection-drag-start',
|
|
28
|
+
TABLE_SELECTION_DRAG_END: 'table-selection-drag-end',
|
|
29
|
+
TABLE_SELECTION_CHANGE: 'table-selection-change',
|
|
30
|
+
TABLE_SELECTION_DISPLAY_CHANGE: 'table-selection-display-change',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const tableUpInternal = {
|
|
34
|
+
moduleName: 'table-up',
|
|
35
|
+
tableSelectionName: 'table-selection',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const defaultColorMap = [
|
|
39
|
+
[
|
|
40
|
+
'rgb(255, 255, 255)',
|
|
41
|
+
'rgb(0, 0, 0)',
|
|
42
|
+
'rgb(72, 83, 104)',
|
|
43
|
+
'rgb(41, 114, 244)',
|
|
44
|
+
'rgb(0, 163, 245)',
|
|
45
|
+
'rgb(49, 155, 98)',
|
|
46
|
+
'rgb(222, 60, 54)',
|
|
47
|
+
'rgb(248, 136, 37)',
|
|
48
|
+
'rgb(245, 196, 0)',
|
|
49
|
+
'rgb(153, 56, 215)',
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
'rgb(242, 242, 242)',
|
|
53
|
+
'rgb(127, 127, 127)',
|
|
54
|
+
'rgb(243, 245, 247)',
|
|
55
|
+
'rgb(229, 239, 255)',
|
|
56
|
+
'rgb(229, 246, 255)',
|
|
57
|
+
'rgb(234, 250, 241)',
|
|
58
|
+
'rgb(254, 233, 232)',
|
|
59
|
+
'rgb(254, 243, 235)',
|
|
60
|
+
'rgb(254, 249, 227)',
|
|
61
|
+
'rgb(253, 235, 255)',
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
'rgb(216, 216, 216)',
|
|
65
|
+
'rgb(89, 89, 89)',
|
|
66
|
+
'rgb(197, 202, 211)',
|
|
67
|
+
'rgb(199, 220, 255)',
|
|
68
|
+
'rgb(199, 236, 255)',
|
|
69
|
+
'rgb(195, 234, 213)',
|
|
70
|
+
'rgb(255, 201, 199)',
|
|
71
|
+
'rgb(255, 220, 196)',
|
|
72
|
+
'rgb(255, 238, 173)',
|
|
73
|
+
'rgb(242, 199, 255)',
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
'rgb(191, 191, 191)',
|
|
77
|
+
'rgb(63, 63, 63)',
|
|
78
|
+
'rgb(128, 139, 158)',
|
|
79
|
+
'rgb(153, 190, 255)',
|
|
80
|
+
'rgb(153, 221, 255)',
|
|
81
|
+
'rgb(152, 215, 182)',
|
|
82
|
+
'rgb(255, 156, 153)',
|
|
83
|
+
'rgb(255, 186, 132)',
|
|
84
|
+
'rgb(255, 226, 112)',
|
|
85
|
+
'rgb(213, 142, 255)',
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
'rgb(165, 165, 165)',
|
|
89
|
+
'rgb(38, 38, 38)',
|
|
90
|
+
'rgb(53, 59, 69)',
|
|
91
|
+
'rgb(20, 80, 184)',
|
|
92
|
+
'rgb(18, 116, 165)',
|
|
93
|
+
'rgb(39, 124, 79)',
|
|
94
|
+
'rgb(158, 30, 26)',
|
|
95
|
+
'rgb(184, 96, 20)',
|
|
96
|
+
'rgb(163, 130, 0)',
|
|
97
|
+
'rgb(94, 34, 129)',
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
'rgb(147, 147, 147)',
|
|
101
|
+
'rgb(13, 13, 13)',
|
|
102
|
+
'rgb(36, 39, 46)',
|
|
103
|
+
'rgb(12, 48, 110)',
|
|
104
|
+
'rgb(10, 65, 92)',
|
|
105
|
+
'rgb(24, 78, 50)',
|
|
106
|
+
'rgb(88, 17, 14)',
|
|
107
|
+
'rgb(92, 48, 10)',
|
|
108
|
+
'rgb(102, 82, 0)',
|
|
109
|
+
'rgb(59, 21, 81)',
|
|
110
|
+
],
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
export const cssNamespace = 'table-up';
|
|
114
|
+
|
|
115
|
+
// Blots that cannot be inserted into a table
|
|
116
|
+
export const tableCantInsert: Set<string> = new Set([blotName.tableCellInner]);
|
|
117
|
+
|
|
118
|
+
export const isForbidInTableBlot = (blot: TypeParchment.Blot) => tableCantInsert.has(blot.statics.blotName);
|
|
119
|
+
export function isForbidInTable(current: TypeParchment.Blot): boolean {
|
|
120
|
+
return current?.parent
|
|
121
|
+
? isForbidInTableBlot(current.parent)
|
|
122
|
+
? true
|
|
123
|
+
: isForbidInTable(current.parent)
|
|
124
|
+
: false;
|
|
125
|
+
}
|