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.
Files changed (111) hide show
  1. package/README.md +7 -0
  2. package/dist/index.css +1 -1
  3. package/dist/index.d.ts +168 -146
  4. package/dist/index.js +47 -47
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.umd.js +52 -52
  7. package/dist/index.umd.js.map +1 -1
  8. package/package.json +22 -24
  9. package/src/__tests__/e2e/custom-creator.test.ts +44 -44
  10. package/src/__tests__/e2e/editor-page.ts +77 -77
  11. package/src/__tests__/e2e/table-align.test.ts +104 -104
  12. package/src/__tests__/e2e/table-blots.test.ts +169 -169
  13. package/src/__tests__/e2e/table-caption.test.ts +134 -134
  14. package/src/__tests__/e2e/table-clipboard.test.ts +20 -20
  15. package/src/__tests__/e2e/table-hack.test.ts +151 -151
  16. package/src/__tests__/e2e/table-keyboard-handler.test.ts +12 -3
  17. package/src/__tests__/e2e/table-menu.test.ts +172 -172
  18. package/src/__tests__/e2e/table-resize.test.ts +654 -9
  19. package/src/__tests__/e2e/table-scrollbar.test.ts +144 -144
  20. package/src/__tests__/e2e/table-selection.test.ts +563 -563
  21. package/src/__tests__/e2e/types.d.ts +7 -7
  22. package/src/__tests__/e2e/utils.ts +52 -52
  23. package/src/__tests__/unit/table-blots.test.ts +720 -720
  24. package/src/__tests__/unit/table-caption.test.ts +234 -234
  25. package/src/__tests__/unit/table-cell-merge.test.ts +724 -724
  26. package/src/__tests__/unit/table-clipboard.test.ts +2176 -2176
  27. package/src/__tests__/unit/table-hack.test.ts +1014 -1014
  28. package/src/__tests__/unit/table-insert.test.ts +926 -926
  29. package/src/__tests__/unit/table-redo-undo.test.ts +2429 -2429
  30. package/src/__tests__/unit/table-remove.test.ts +343 -343
  31. package/src/__tests__/unit/utils.test-d.ts +49 -49
  32. package/src/__tests__/unit/utils.test.ts +711 -711
  33. package/src/__tests__/unit/utils.ts +307 -307
  34. package/src/__tests__/unit/vitest.d.ts +14 -14
  35. package/src/formats/container-format.ts +107 -107
  36. package/src/formats/overrides/block-embed.ts +72 -72
  37. package/src/formats/overrides/block.ts +95 -95
  38. package/src/formats/overrides/index.ts +3 -3
  39. package/src/formats/overrides/scroll.ts +70 -70
  40. package/src/formats/table-body-format.ts +52 -52
  41. package/src/formats/table-caption-format.ts +116 -116
  42. package/src/formats/table-cell-format.ts +304 -304
  43. package/src/formats/table-cell-inner-format.ts +403 -398
  44. package/src/formats/table-colgroup-format.ts +136 -136
  45. package/src/formats/table-foot-format.ts +7 -7
  46. package/src/formats/table-head-format.ts +7 -7
  47. package/src/formats/table-main-format.ts +1 -1
  48. package/src/formats/table-row-format.ts +218 -210
  49. package/src/formats/utils.ts +6 -6
  50. package/src/index.ts +19 -19
  51. package/src/modules/index.ts +7 -7
  52. package/src/modules/table-align.ts +131 -131
  53. package/src/modules/table-clipboard/table-clipboard.ts +6 -8
  54. package/src/modules/table-dom-selector.ts +33 -33
  55. package/src/modules/table-menu/constants.ts +223 -223
  56. package/src/modules/table-menu/index.ts +4 -4
  57. package/src/modules/table-menu/table-menu-common.ts +330 -329
  58. package/src/modules/table-menu/table-menu-contextmenu.ts +111 -118
  59. package/src/modules/table-menu/table-menu-select.ts +96 -94
  60. package/src/modules/table-resize/index.ts +5 -5
  61. package/src/modules/table-resize/table-resize-box.ts +714 -363
  62. package/src/modules/table-resize/table-resize-common.ts +246 -382
  63. package/src/modules/table-resize/table-resize-drag.ts +241 -0
  64. package/src/modules/table-resize/table-resize-line.ts +244 -182
  65. package/src/modules/table-resize/table-resize-scale.ts +174 -173
  66. package/src/modules/table-resize/utils.ts +84 -3
  67. package/src/modules/table-scrollbar.ts +292 -292
  68. package/src/modules/table-selection.ts +613 -669
  69. package/src/style/button.less +45 -45
  70. package/src/style/color-picker.less +136 -136
  71. package/src/style/dialog.less +53 -53
  72. package/src/style/functions.less +9 -9
  73. package/src/style/index.less +120 -120
  74. package/src/style/input.less +64 -64
  75. package/src/style/select-box.less +52 -52
  76. package/src/style/table-creator.less +56 -56
  77. package/src/style/table-menu.less +125 -125
  78. package/src/style/table-resize-scale.less +31 -31
  79. package/src/style/table-resize.less +249 -202
  80. package/src/style/table-scrollbar.less +49 -49
  81. package/src/style/table-selection.less +23 -23
  82. package/src/style/tooltip.less +19 -19
  83. package/src/style/variables.less +1 -1
  84. package/src/svg/arrow-up-down.svg +11 -11
  85. package/src/svg/convert-cell.svg +7 -7
  86. package/src/table-up.ts +1360 -1360
  87. package/src/types.d.ts +4 -4
  88. package/src/utils/bem.ts +23 -23
  89. package/src/utils/blot-helper.ts +101 -105
  90. package/src/utils/color.ts +109 -109
  91. package/src/utils/components/button.ts +22 -22
  92. package/src/utils/components/color-picker.ts +236 -236
  93. package/src/utils/components/dialog.ts +83 -41
  94. package/src/utils/components/index.ts +6 -6
  95. package/src/utils/components/input.ts +74 -74
  96. package/src/utils/components/table/creator.ts +89 -89
  97. package/src/utils/components/table/index.ts +2 -2
  98. package/src/utils/components/table/select-box.ts +78 -78
  99. package/src/utils/components/tooltip.ts +179 -189
  100. package/src/utils/constants.ts +125 -124
  101. package/src/utils/drag-helper.ts +112 -0
  102. package/src/utils/index.ts +15 -14
  103. package/src/utils/is.ts +9 -9
  104. package/src/utils/position.ts +60 -60
  105. package/src/utils/resize-observer-helper.ts +47 -47
  106. package/src/utils/scroll.ts +145 -47
  107. package/src/utils/style-helper.ts +47 -47
  108. package/src/utils/transformer.ts +10 -10
  109. package/src/utils/transition-event-helper.ts +8 -8
  110. package/src/utils/types.ts +156 -157
  111. 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
- let tooltipContainer: HTMLElement;
38
- export interface TooltipInstance {
39
- destroy: () => void;
40
- show: (force?: boolean) => void;
41
- hide: (force?: boolean) => void;
42
- }
43
- export function createTooltip(target: HTMLElement, options: ToolTipOptions = {}): TooltipInstance | null {
44
- const { msg = '', delay = 150, content, direction = 'bottom', type = 'hover', container, onOpen, onClose, closed, onDestroy } = options;
45
- const bem = createBEM('tooltip');
46
- if (msg || content) {
47
- if (!tooltipContainer) {
48
- tooltipContainer = document.createElement('div');
49
- }
50
- const appendTo = container || tooltipContainer;
51
- const tooltip = document.createElement('div');
52
- tooltip.classList.add(bem.b(), 'hidden', 'transparent');
53
- if (content) {
54
- tooltip.appendChild(content);
55
- }
56
- else if (msg) {
57
- tooltip.textContent = msg;
58
- }
59
- let showTimer: ReturnType<typeof setTimeout> | undefined;
60
- let closeTimer: ReturnType<typeof setTimeout> | undefined;
61
- let cleanup: () => void;
62
- const update = () => {
63
- if (cleanup) cleanup();
64
- computePosition(target, tooltip, {
65
- placement: direction,
66
- middleware: [flip(), shift({ limiter: limitShift() }), offset(DISTANCE)],
67
- }).then(({ x, y }) => {
68
- Object.assign(tooltip.style, {
69
- left: `${x}px`,
70
- top: `${y}px`,
71
- });
72
- });
73
- };
74
- const transitionendHandler = () => {
75
- tooltip.classList.add('hidden');
76
- if (appendTo.contains(tooltip)) {
77
- appendTo.removeChild(tooltip);
78
- if (appendTo === tooltipContainer && !tooltipContainer.hasChildNodes()) {
79
- document.body.removeChild(tooltipContainer);
80
- }
81
- }
82
- if (cleanup) cleanup();
83
- if (closed) closed();
84
- };
85
-
86
- const openTooltip = (force: boolean = false) => {
87
- if (closeTimer) clearTimeout(closeTimer);
88
-
89
- showTimer = setTimeout(() => {
90
- if (onOpen) {
91
- const allow = onOpen(force);
92
- if (!force && allow) return;
93
- }
94
- if (appendTo === tooltipContainer && !tooltipContainer.parentElement) {
95
- document.body.appendChild(tooltipContainer);
96
- }
97
- appendTo.appendChild(tooltip);
98
- tooltip.removeEventListener('transitionend', transitionendHandler);
99
- tooltip.classList.remove('hidden');
100
-
101
- cleanup = autoUpdate(target, tooltip, update);
102
-
103
- tooltip.classList.remove('transparent');
104
- }, delay);
105
- };
106
- const closeTooltip = (force: boolean = false) => {
107
- if (showTimer) clearTimeout(showTimer);
108
- closeTimer = setTimeout(() => {
109
- if (onClose) {
110
- const allow = onClose(force);
111
- if (!force && allow) return;
112
- }
113
- handleIfTransitionend(tooltip, 150, transitionendHandler, { once: true });
114
- tooltip.classList.add('transparent');
115
- }, delay);
116
- };
117
-
118
- const hoverDisplay = () => {
119
- const eventListeners = [target, tooltip];
120
- const close = closeTooltip.bind(undefined, false);
121
- const open = openTooltip.bind(undefined, false);
122
- const prepare = () => {
123
- for (const listener of eventListeners) {
124
- listener.addEventListener('mouseenter', open);
125
- listener.addEventListener('mouseleave', close);
126
- }
127
- };
128
- return {
129
- prepare,
130
- show: openTooltip,
131
- hide: closeTooltip,
132
- destroy: () => {
133
- for (const listener of eventListeners) {
134
- listener.removeEventListener('mouseenter', open);
135
- listener.removeEventListener('mouseleave', close);
136
- }
137
- },
138
- };
139
- };
140
- const clickDisplay = () => {
141
- const close = (e: MouseEvent) => {
142
- e.stopPropagation();
143
- closeTooltip(false);
144
- };
145
- const show = (e: MouseEvent) => {
146
- e.stopPropagation();
147
- openTooltip();
148
- document.removeEventListener('click', close);
149
- document.addEventListener('click', close, { once: true });
150
- };
151
- return {
152
- prepare: () => {
153
- tooltip.addEventListener('click', (e: Event) => e.stopPropagation());
154
- target.addEventListener('click', show);
155
- },
156
- show: openTooltip,
157
- hide: (force: boolean = false) => {
158
- closeTooltip(force);
159
- document.removeEventListener('click', close);
160
- },
161
- destroy: () => {
162
- target.removeEventListener('click', show);
163
- document.removeEventListener('click', close);
164
- },
165
- };
166
- };
167
- const displayMethods = {
168
- hover: hoverDisplay,
169
- click: clickDisplay,
170
- };
171
-
172
- const { prepare, show, hide, destroy: destroyDisplay } = displayMethods[type]();
173
- prepare();
174
-
175
- const destroy = () => {
176
- hide(true);
177
- if (onDestroy) onDestroy();
178
- destroyDisplay();
179
- if (cleanup) cleanup();
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
+ }
@@ -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
- export const defaultColorMap = [
38
- [
39
- 'rgb(255, 255, 255)',
40
- 'rgb(0, 0, 0)',
41
- 'rgb(72, 83, 104)',
42
- 'rgb(41, 114, 244)',
43
- 'rgb(0, 163, 245)',
44
- 'rgb(49, 155, 98)',
45
- 'rgb(222, 60, 54)',
46
- 'rgb(248, 136, 37)',
47
- 'rgb(245, 196, 0)',
48
- 'rgb(153, 56, 215)',
49
- ],
50
- [
51
- 'rgb(242, 242, 242)',
52
- 'rgb(127, 127, 127)',
53
- 'rgb(243, 245, 247)',
54
- 'rgb(229, 239, 255)',
55
- 'rgb(229, 246, 255)',
56
- 'rgb(234, 250, 241)',
57
- 'rgb(254, 233, 232)',
58
- 'rgb(254, 243, 235)',
59
- 'rgb(254, 249, 227)',
60
- 'rgb(253, 235, 255)',
61
- ],
62
- [
63
- 'rgb(216, 216, 216)',
64
- 'rgb(89, 89, 89)',
65
- 'rgb(197, 202, 211)',
66
- 'rgb(199, 220, 255)',
67
- 'rgb(199, 236, 255)',
68
- 'rgb(195, 234, 213)',
69
- 'rgb(255, 201, 199)',
70
- 'rgb(255, 220, 196)',
71
- 'rgb(255, 238, 173)',
72
- 'rgb(242, 199, 255)',
73
- ],
74
- [
75
- 'rgb(191, 191, 191)',
76
- 'rgb(63, 63, 63)',
77
- 'rgb(128, 139, 158)',
78
- 'rgb(153, 190, 255)',
79
- 'rgb(153, 221, 255)',
80
- 'rgb(152, 215, 182)',
81
- 'rgb(255, 156, 153)',
82
- 'rgb(255, 186, 132)',
83
- 'rgb(255, 226, 112)',
84
- 'rgb(213, 142, 255)',
85
- ],
86
- [
87
- 'rgb(165, 165, 165)',
88
- 'rgb(38, 38, 38)',
89
- 'rgb(53, 59, 69)',
90
- 'rgb(20, 80, 184)',
91
- 'rgb(18, 116, 165)',
92
- 'rgb(39, 124, 79)',
93
- 'rgb(158, 30, 26)',
94
- 'rgb(184, 96, 20)',
95
- 'rgb(163, 130, 0)',
96
- 'rgb(94, 34, 129)',
97
- ],
98
- [
99
- 'rgb(147, 147, 147)',
100
- 'rgb(13, 13, 13)',
101
- 'rgb(36, 39, 46)',
102
- 'rgb(12, 48, 110)',
103
- 'rgb(10, 65, 92)',
104
- 'rgb(24, 78, 50)',
105
- 'rgb(88, 17, 14)',
106
- 'rgb(92, 48, 10)',
107
- 'rgb(102, 82, 0)',
108
- 'rgb(59, 21, 81)',
109
- ],
110
- ];
111
-
112
- export const cssNamespace = 'table-up';
113
-
114
- // Blots that cannot be inserted into a table
115
- export const tableCantInsert: Set<string> = new Set([blotName.tableCellInner]);
116
-
117
- export const isForbidInTableBlot = (blot: TypeParchment.Blot) => tableCantInsert.has(blot.statics.blotName);
118
- export function isForbidInTable(current: TypeParchment.Blot): boolean {
119
- return current && current.parent
120
- ? isForbidInTableBlot(current.parent)
121
- ? true
122
- : isForbidInTable(current.parent)
123
- : false;
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
+ }