@atlaskit/editor-plugin-table 12.2.6 → 12.2.7
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/CHANGELOG.md +8 -0
- package/package.json +4 -4
- package/afm-cc/tsconfig.json +0 -123
- package/afm-dev-agents/tsconfig.json +0 -123
- package/afm-jira/tsconfig.json +0 -123
- package/afm-passionfruit/tsconfig.json +0 -123
- package/afm-post-office/tsconfig.json +0 -123
- package/afm-rovo-extension/tsconfig.json +0 -123
- package/afm-townsquare/tsconfig.json +0 -123
- package/afm-volt/tsconfig.json +0 -114
- package/build/tsconfig.json +0 -23
- package/docs/0-intro.tsx +0 -57
- package/src/index.ts +0 -21
- package/src/nodeviews/ExternalDropTargets.tsx +0 -91
- package/src/nodeviews/OverflowShadowsObserver.ts +0 -156
- package/src/nodeviews/TableCell.ts +0 -134
- package/src/nodeviews/TableComponent.tsx +0 -1590
- package/src/nodeviews/TableComponentWithSharedState.tsx +0 -278
- package/src/nodeviews/TableContainer.tsx +0 -926
- package/src/nodeviews/TableNodeViewBase.ts +0 -29
- package/src/nodeviews/TableResizer.tsx +0 -884
- package/src/nodeviews/TableRow.ts +0 -830
- package/src/nodeviews/TableStickyScrollbar.ts +0 -211
- package/src/nodeviews/__mocks__/OverflowShadowsObserver.ts +0 -15
- package/src/nodeviews/__mocks__/OverridableMock.ts +0 -26
- package/src/nodeviews/table-container-styles.ts +0 -9
- package/src/nodeviews/table-node-views.ts +0 -76
- package/src/nodeviews/table.tsx +0 -530
- package/src/nodeviews/toDOM.ts +0 -244
- package/src/nodeviews/types.ts +0 -36
- package/src/nodeviews/update-overflow-shadows.ts +0 -11
- package/src/pm-plugins/analytics/actions.ts +0 -21
- package/src/pm-plugins/analytics/commands.ts +0 -47
- package/src/pm-plugins/analytics/plugin-factory.ts +0 -9
- package/src/pm-plugins/analytics/plugin-key.ts +0 -5
- package/src/pm-plugins/analytics/plugin.ts +0 -80
- package/src/pm-plugins/analytics/reducer.ts +0 -27
- package/src/pm-plugins/analytics/types.ts +0 -20
- package/src/pm-plugins/analytics/utils/moved-event.ts +0 -51
- package/src/pm-plugins/commands/clear.ts +0 -43
- package/src/pm-plugins/commands/collapse.ts +0 -17
- package/src/pm-plugins/commands/column-resize.ts +0 -478
- package/src/pm-plugins/commands/commands-with-analytics.ts +0 -715
- package/src/pm-plugins/commands/delete.ts +0 -42
- package/src/pm-plugins/commands/display-mode.ts +0 -18
- package/src/pm-plugins/commands/go-to-next-cell.ts +0 -198
- package/src/pm-plugins/commands/hover.ts +0 -242
- package/src/pm-plugins/commands/index.ts +0 -51
- package/src/pm-plugins/commands/insert.ts +0 -438
- package/src/pm-plugins/commands/misc.ts +0 -811
- package/src/pm-plugins/commands/referentiality.ts +0 -15
- package/src/pm-plugins/commands/selection.ts +0 -537
- package/src/pm-plugins/commands/sort.ts +0 -102
- package/src/pm-plugins/commands/split-cell.ts +0 -28
- package/src/pm-plugins/commands/toggle.ts +0 -109
- package/src/pm-plugins/create-plugin-config.ts +0 -17
- package/src/pm-plugins/decorations/plugin.ts +0 -107
- package/src/pm-plugins/decorations/utils/column-controls.ts +0 -91
- package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -71
- package/src/pm-plugins/decorations/utils/compose-decorations.ts +0 -9
- package/src/pm-plugins/decorations/utils/types.ts +0 -16
- package/src/pm-plugins/default-table-selection.ts +0 -14
- package/src/pm-plugins/drag-and-drop/actions.ts +0 -48
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -222
- package/src/pm-plugins/drag-and-drop/commands.ts +0 -194
- package/src/pm-plugins/drag-and-drop/consts.ts +0 -7
- package/src/pm-plugins/drag-and-drop/plugin-factory.ts +0 -33
- package/src/pm-plugins/drag-and-drop/plugin-key.ts +0 -5
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -398
- package/src/pm-plugins/drag-and-drop/reducer.ts +0 -38
- package/src/pm-plugins/drag-and-drop/types.ts +0 -18
- package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +0 -49
- package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +0 -9
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -73
- package/src/pm-plugins/handlers.ts +0 -161
- package/src/pm-plugins/keymap.ts +0 -436
- package/src/pm-plugins/main.ts +0 -433
- package/src/pm-plugins/plugin-factory.ts +0 -42
- package/src/pm-plugins/plugin-key.ts +0 -8
- package/src/pm-plugins/reducer.ts +0 -145
- package/src/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -102
- package/src/pm-plugins/sticky-headers/commands.ts +0 -8
- package/src/pm-plugins/sticky-headers/plugin-key.ts +0 -5
- package/src/pm-plugins/sticky-headers/plugin-state.ts +0 -52
- package/src/pm-plugins/sticky-headers/plugin.ts +0 -12
- package/src/pm-plugins/sticky-headers/types.ts +0 -20
- package/src/pm-plugins/sticky-headers/util.ts +0 -18
- package/src/pm-plugins/table-analytics.ts +0 -100
- package/src/pm-plugins/table-local-id.ts +0 -213
- package/src/pm-plugins/table-resizing/commands.ts +0 -116
- package/src/pm-plugins/table-resizing/event-handlers.ts +0 -352
- package/src/pm-plugins/table-resizing/plugin-factory.ts +0 -29
- package/src/pm-plugins/table-resizing/plugin-key.ts +0 -5
- package/src/pm-plugins/table-resizing/plugin.ts +0 -94
- package/src/pm-plugins/table-resizing/reducer.ts +0 -37
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -306
- package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -120
- package/src/pm-plugins/table-resizing/utils/consts.ts +0 -11
- package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -118
- package/src/pm-plugins/table-resizing/utils/dom.ts +0 -132
- package/src/pm-plugins/table-resizing/utils/misc.ts +0 -282
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -34
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -289
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -417
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -290
- package/src/pm-plugins/table-resizing/utils/types.ts +0 -25
- package/src/pm-plugins/table-resizing/utils/unit-to-number.ts +0 -1
- package/src/pm-plugins/table-selection-keymap.ts +0 -64
- package/src/pm-plugins/table-size-selector.ts +0 -39
- package/src/pm-plugins/table-width-in-comment-fix.ts +0 -113
- package/src/pm-plugins/table-width.ts +0 -153
- package/src/pm-plugins/transforms/column-width.ts +0 -249
- package/src/pm-plugins/transforms/delete-columns.ts +0 -281
- package/src/pm-plugins/transforms/delete-rows.ts +0 -154
- package/src/pm-plugins/transforms/fix-tables.ts +0 -249
- package/src/pm-plugins/transforms/merge.ts +0 -301
- package/src/pm-plugins/transforms/replace-table.ts +0 -38
- package/src/pm-plugins/transforms/split.ts +0 -90
- package/src/pm-plugins/utils/alignment.ts +0 -33
- package/src/pm-plugins/utils/analytics.ts +0 -238
- package/src/pm-plugins/utils/collapse.ts +0 -93
- package/src/pm-plugins/utils/column-controls.ts +0 -250
- package/src/pm-plugins/utils/create.ts +0 -64
- package/src/pm-plugins/utils/decoration.ts +0 -672
- package/src/pm-plugins/utils/dom.ts +0 -251
- package/src/pm-plugins/utils/drag-menu.tsx +0 -491
- package/src/pm-plugins/utils/get-allow-add-column-custom-step.ts +0 -10
- package/src/pm-plugins/utils/guidelines.ts +0 -30
- package/src/pm-plugins/utils/merged-cells.ts +0 -239
- package/src/pm-plugins/utils/nodes.ts +0 -162
- package/src/pm-plugins/utils/paste.ts +0 -386
- package/src/pm-plugins/utils/row-controls.ts +0 -211
- package/src/pm-plugins/utils/selection.ts +0 -17
- package/src/pm-plugins/utils/snapping.ts +0 -136
- package/src/pm-plugins/utils/table.ts +0 -60
- package/src/pm-plugins/utils/update-plugin-state-decorations.ts +0 -13
- package/src/pm-plugins/view-mode-sort/consts.ts +0 -3
- package/src/pm-plugins/view-mode-sort/index.ts +0 -291
- package/src/pm-plugins/view-mode-sort/plugin-key.ts +0 -7
- package/src/pm-plugins/view-mode-sort/types.ts +0 -23
- package/src/pm-plugins/view-mode-sort/utils.ts +0 -136
- package/src/tablePlugin.tsx +0 -971
- package/src/tablePluginType.ts +0 -102
- package/src/types/index.ts +0 -592
- package/src/ui/ColumnResizeWidget/index.tsx +0 -61
- package/src/ui/ContentComponent.tsx +0 -311
- package/src/ui/DragHandle/HandleIconComponent.tsx +0 -21
- package/src/ui/DragHandle/index.tsx +0 -391
- package/src/ui/DragPreview/index.tsx +0 -51
- package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +0 -59
- package/src/ui/FloatingContextualButton/FixedButton.tsx +0 -203
- package/src/ui/FloatingContextualButton/index.tsx +0 -168
- package/src/ui/FloatingContextualButton/styles.ts +0 -69
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +0 -931
- package/src/ui/FloatingContextualMenu/index.tsx +0 -141
- package/src/ui/FloatingContextualMenu/styles.ts +0 -77
- package/src/ui/FloatingDeleteButton/DeleteButton.tsx +0 -54
- package/src/ui/FloatingDeleteButton/getPopUpOptions.ts +0 -65
- package/src/ui/FloatingDeleteButton/index.tsx +0 -383
- package/src/ui/FloatingDeleteButton/types.ts +0 -3
- package/src/ui/FloatingDragMenu/DragMenu.tsx +0 -668
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +0 -221
- package/src/ui/FloatingDragMenu/index.tsx +0 -136
- package/src/ui/FloatingDragMenu/styles.ts +0 -83
- package/src/ui/FloatingInsertButton/InsertButton.tsx +0 -263
- package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -131
- package/src/ui/FloatingInsertButton/index.tsx +0 -314
- package/src/ui/FloatingToolbarLabel/FloatingToolbarLabel.tsx +0 -31
- package/src/ui/SizeSelector/index.tsx +0 -74
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -397
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +0 -105
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +0 -63
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -151
- package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +0 -106
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +0 -143
- package/src/ui/TableFloatingControls/CornerControls/types.ts +0 -12
- package/src/ui/TableFloatingControls/FloatingControlsWithSelection.tsx +0 -88
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +0 -175
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +0 -131
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -429
- package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +0 -96
- package/src/ui/TableFloatingControls/index.tsx +0 -275
- package/src/ui/TableFullWidthLabel/index.tsx +0 -38
- package/src/ui/common-styles.ts +0 -1218
- package/src/ui/consts.ts +0 -109
- package/src/ui/event-handlers.ts +0 -662
- package/src/ui/global-styles.tsx +0 -55
- package/src/ui/hooks/useInternalTablePluginStateSelector.ts +0 -38
- package/src/ui/icons/AddColLeftIcon.tsx +0 -37
- package/src/ui/icons/AddColRightIcon.tsx +0 -37
- package/src/ui/icons/AddRowAboveIcon.tsx +0 -22
- package/src/ui/icons/AddRowBelowIcon.tsx +0 -39
- package/src/ui/icons/DragHandleDisabledIcon.tsx +0 -25
- package/src/ui/icons/DragHandleIcon.tsx +0 -16
- package/src/ui/icons/DragInMotionIcon.tsx +0 -54
- package/src/ui/icons/MergeCellsIcon.tsx +0 -26
- package/src/ui/icons/MinimisedHandle.tsx +0 -15
- package/src/ui/icons/SortingIconWrapper.tsx +0 -43
- package/src/ui/icons/SplitCellIcon.tsx +0 -34
- package/src/ui/toolbar.tsx +0 -1153
- package/src/ui/ui-styles.ts +0 -960
- package/tsconfig.app.json +0 -135
- package/tsconfig.dev.json +0 -54
- package/tsconfig.json +0 -18
package/src/nodeviews/toDOM.ts
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import kebabCase from 'lodash/kebabCase';
|
|
2
|
-
|
|
3
|
-
import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
|
|
4
|
-
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
5
|
-
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
6
|
-
import type { DOMOutputSpec, NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
-
import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
8
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
generateColgroup,
|
|
12
|
-
generateColgroupFromNode,
|
|
13
|
-
getResizerMinWidth,
|
|
14
|
-
} from '../pm-plugins/table-resizing/utils/colgroup';
|
|
15
|
-
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
|
|
16
|
-
import {
|
|
17
|
-
getTableResizerContainerMaxWidthInCSS,
|
|
18
|
-
getTableResizerContainerForFullPageWidthInCSS,
|
|
19
|
-
getTableResizerItemWidthInCSS,
|
|
20
|
-
} from '../pm-plugins/table-resizing/utils/misc';
|
|
21
|
-
|
|
22
|
-
import { getAlignmentStyle } from './table-container-styles';
|
|
23
|
-
|
|
24
|
-
type Config = {
|
|
25
|
-
allowColumnResizing: boolean;
|
|
26
|
-
tableResizingEnabled: boolean;
|
|
27
|
-
getEditorContainerWidth: GetEditorContainerWidth;
|
|
28
|
-
isNestingSupported?: boolean;
|
|
29
|
-
isTableScalingEnabled?: boolean;
|
|
30
|
-
shouldUseIncreasedScalingPercent?: boolean;
|
|
31
|
-
isCommentEditor?: boolean;
|
|
32
|
-
isChromelessEditor?: boolean;
|
|
33
|
-
isNested?: boolean;
|
|
34
|
-
};
|
|
35
|
-
export const tableNodeSpecWithFixedToDOM = (
|
|
36
|
-
config: Config,
|
|
37
|
-
): NodeSpec & { toDOM: (node: PMNode) => DOMOutputSpec } => {
|
|
38
|
-
const tableNode = config.isNestingSupported ? tableWithNestedTable : table;
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
...tableNode,
|
|
42
|
-
toDOM: (node: PMNode): DOMOutputSpec => {
|
|
43
|
-
const gutterPadding = () => {
|
|
44
|
-
if (expValEquals('platform_editor_preview_panel_responsiveness', 'isEnabled', true)) {
|
|
45
|
-
return 'calc(var(--ak-editor--large-gutter-padding) * 2)';
|
|
46
|
-
} else {
|
|
47
|
-
return `${akEditorGutterPaddingDynamic() * 2}px`;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout))
|
|
52
|
-
.map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`)
|
|
53
|
-
.join(';');
|
|
54
|
-
|
|
55
|
-
const tableMinWidth = getResizerMinWidth(node);
|
|
56
|
-
|
|
57
|
-
const tableWidthAttribute = node.attrs.width ? `${node.attrs.width}px` : `100%`;
|
|
58
|
-
|
|
59
|
-
const isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
|
|
60
|
-
|
|
61
|
-
const attrs = {
|
|
62
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
63
|
-
'data-layout': node.attrs.layout,
|
|
64
|
-
'data-autosize': node.attrs.__autoSize,
|
|
65
|
-
'data-table-local-id': node.attrs.localId,
|
|
66
|
-
'data-table-width': node.attrs.width,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// This would be used for table scaling in colgroup CSS
|
|
70
|
-
// cqw, or px is well supported
|
|
71
|
-
const resizableTableWidth = expValEquals(
|
|
72
|
-
'platform_editor_tables_scaling_css',
|
|
73
|
-
'isEnabled',
|
|
74
|
-
true,
|
|
75
|
-
)
|
|
76
|
-
? isFullPageEditor
|
|
77
|
-
? getTableResizerContainerForFullPageWidthInCSS(node, config.isTableScalingEnabled)
|
|
78
|
-
: `calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2))`
|
|
79
|
-
: `min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2)), ${node.attrs.width ?? '100%'})`;
|
|
80
|
-
|
|
81
|
-
let colgroup: DOMOutputSpec = '';
|
|
82
|
-
|
|
83
|
-
if (config.allowColumnResizing) {
|
|
84
|
-
if (expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)) {
|
|
85
|
-
colgroup = [
|
|
86
|
-
'colgroup',
|
|
87
|
-
{},
|
|
88
|
-
...generateColgroupFromNode(
|
|
89
|
-
node,
|
|
90
|
-
config.isCommentEditor,
|
|
91
|
-
config.isChromelessEditor,
|
|
92
|
-
config.isNested,
|
|
93
|
-
config.isTableScalingEnabled,
|
|
94
|
-
config.shouldUseIncreasedScalingPercent,
|
|
95
|
-
),
|
|
96
|
-
];
|
|
97
|
-
} else {
|
|
98
|
-
colgroup = ['colgroup', {}, ...generateColgroup(node)];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// For Chromeless editor, and nested tables in full page editor
|
|
103
|
-
const tableContainerDiv = [
|
|
104
|
-
'div',
|
|
105
|
-
{
|
|
106
|
-
class: 'pm-table-container',
|
|
107
|
-
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
108
|
-
'data-layout': node.attrs.layout,
|
|
109
|
-
'data-testid': 'table-container',
|
|
110
|
-
},
|
|
111
|
-
[
|
|
112
|
-
'div',
|
|
113
|
-
{
|
|
114
|
-
class: 'pm-table-sticky-sentinel-top',
|
|
115
|
-
'data-testid': 'sticky-sentinel-top',
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
[
|
|
119
|
-
'div',
|
|
120
|
-
{
|
|
121
|
-
class: 'pm-table-row-controls-wrapper',
|
|
122
|
-
},
|
|
123
|
-
['div'],
|
|
124
|
-
],
|
|
125
|
-
[
|
|
126
|
-
'div',
|
|
127
|
-
{
|
|
128
|
-
class: 'pm-table-with-left-shadow',
|
|
129
|
-
style: 'visibility: hidden',
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
[
|
|
133
|
-
'div',
|
|
134
|
-
{
|
|
135
|
-
class: 'pm-table-wrapper',
|
|
136
|
-
},
|
|
137
|
-
[
|
|
138
|
-
'table',
|
|
139
|
-
attrs,
|
|
140
|
-
['span', { class: 'pm-table-shadow-sentinel-right' }],
|
|
141
|
-
['span', { class: 'pm-table-shadow-sentinel-left' }],
|
|
142
|
-
colgroup,
|
|
143
|
-
['tbody', 0],
|
|
144
|
-
],
|
|
145
|
-
],
|
|
146
|
-
[
|
|
147
|
-
'div',
|
|
148
|
-
{
|
|
149
|
-
class: 'pm-table-with-right-shadow',
|
|
150
|
-
style: 'visibility: hidden',
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
[
|
|
154
|
-
'div',
|
|
155
|
-
{
|
|
156
|
-
class: 'pm-table-sticky-sentinel-bottom',
|
|
157
|
-
'data-testid': 'sticky-sentinel-bottom',
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
];
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
!config.tableResizingEnabled ||
|
|
164
|
-
(expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true) && config.isNested)
|
|
165
|
-
) {
|
|
166
|
-
return [
|
|
167
|
-
'div',
|
|
168
|
-
{
|
|
169
|
-
class: 'tableView-content-wrap',
|
|
170
|
-
'data-prosemirror-initial-toDOM-render': 'true',
|
|
171
|
-
},
|
|
172
|
-
tableContainerDiv,
|
|
173
|
-
];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const tableResizingDiv = [
|
|
177
|
-
'div',
|
|
178
|
-
{
|
|
179
|
-
'data-testid': 'table-alignment-container',
|
|
180
|
-
style: alignmentStyle,
|
|
181
|
-
},
|
|
182
|
-
[
|
|
183
|
-
'div',
|
|
184
|
-
{
|
|
185
|
-
class: 'pm-table-resizer-container',
|
|
186
|
-
style: convertToInlineCss({
|
|
187
|
-
'--ak-editor-table-gutter-padding': config.isTableScalingEnabled
|
|
188
|
-
? 'calc(var(--ak-editor--large-gutter-padding) * 2)'
|
|
189
|
-
: 'calc(var(--ak-editor--large-gutter-padding) * 2 - var(--ak-editor-resizer-handle-spacing))',
|
|
190
|
-
'--ak-editor-table-width': resizableTableWidth,
|
|
191
|
-
width: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)
|
|
192
|
-
? `var(--ak-editor-table-width)`
|
|
193
|
-
: `min(calc(100cqw - ${gutterPadding()}), ${tableWidthAttribute})`,
|
|
194
|
-
}),
|
|
195
|
-
},
|
|
196
|
-
[
|
|
197
|
-
'div',
|
|
198
|
-
{
|
|
199
|
-
class: 'resizer-item display-handle',
|
|
200
|
-
style: convertToInlineCss({
|
|
201
|
-
position: 'relative',
|
|
202
|
-
userSelect: 'auto',
|
|
203
|
-
boxSizing: 'border-box',
|
|
204
|
-
'--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
|
|
205
|
-
'--ak-editor-table-min-width': `${tableMinWidth}px`,
|
|
206
|
-
minWidth: 'var(--ak-editor-table-min-width)',
|
|
207
|
-
maxWidth: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)
|
|
208
|
-
? getTableResizerContainerMaxWidthInCSS(
|
|
209
|
-
config.isCommentEditor,
|
|
210
|
-
config.isChromelessEditor,
|
|
211
|
-
config.isTableScalingEnabled,
|
|
212
|
-
)
|
|
213
|
-
: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
|
|
214
|
-
width: expValEquals('platform_editor_tables_scaling_css', 'isEnabled', true)
|
|
215
|
-
? getTableResizerItemWidthInCSS(
|
|
216
|
-
node,
|
|
217
|
-
config.isCommentEditor,
|
|
218
|
-
config.isChromelessEditor,
|
|
219
|
-
)
|
|
220
|
-
: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${tableWidthAttribute})`,
|
|
221
|
-
}),
|
|
222
|
-
},
|
|
223
|
-
[
|
|
224
|
-
'span',
|
|
225
|
-
{
|
|
226
|
-
class: 'resizer-hover-zone',
|
|
227
|
-
},
|
|
228
|
-
tableContainerDiv,
|
|
229
|
-
],
|
|
230
|
-
],
|
|
231
|
-
],
|
|
232
|
-
];
|
|
233
|
-
|
|
234
|
-
return [
|
|
235
|
-
'div',
|
|
236
|
-
{
|
|
237
|
-
class: 'tableView-content-wrap',
|
|
238
|
-
'data-prosemirror-initial-toDOM-render': 'true',
|
|
239
|
-
},
|
|
240
|
-
tableResizingDiv,
|
|
241
|
-
];
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
|
-
};
|
package/src/nodeviews/types.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
-
import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
|
|
4
|
-
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
5
|
-
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
-
|
|
8
|
-
import type { PluginInjectionAPI } from '../types';
|
|
9
|
-
|
|
10
|
-
export type TableOptions = {
|
|
11
|
-
isFullWidthModeEnabled?: boolean;
|
|
12
|
-
wasFullWidthModeEnabled?: boolean;
|
|
13
|
-
isDragAndDropEnabled?: boolean;
|
|
14
|
-
isTableScalingEnabled?: boolean;
|
|
15
|
-
isCommentEditor?: boolean;
|
|
16
|
-
isChromelessEditor?: boolean;
|
|
17
|
-
shouldUseIncreasedScalingPercent?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export interface Props {
|
|
21
|
-
node: PmNode;
|
|
22
|
-
view: EditorView;
|
|
23
|
-
allowColumnResizing?: boolean;
|
|
24
|
-
allowTableResizing?: boolean;
|
|
25
|
-
allowTableAlignment?: boolean;
|
|
26
|
-
allowControls?: boolean;
|
|
27
|
-
cellMinWidth?: number;
|
|
28
|
-
portalProviderAPI: PortalProviderAPI;
|
|
29
|
-
eventDispatcher: EventDispatcher;
|
|
30
|
-
getPos: () => number | undefined;
|
|
31
|
-
options?: TableOptions;
|
|
32
|
-
getEditorContainerWidth: GetEditorContainerWidth;
|
|
33
|
-
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
34
|
-
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
35
|
-
pluginInjectionApi?: PluginInjectionAPI;
|
|
36
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TableCssClassName as ClassName } from '../types';
|
|
2
|
-
|
|
3
|
-
export const updateShadowListForStickyStyles = (heightStyle: string, shadows: HTMLCollection) => {
|
|
4
|
-
Array.from(shadows).forEach((shadow) => {
|
|
5
|
-
if (shadow.classList.contains(ClassName.TABLE_STICKY_SHADOW)) {
|
|
6
|
-
if (shadow instanceof HTMLElement && shadow.style.height !== heightStyle) {
|
|
7
|
-
shadow.style.height = heightStyle;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { RowOrColumnMovedState } from './types';
|
|
2
|
-
|
|
3
|
-
export enum AnalyticPluginTypes {
|
|
4
|
-
UpdateOverflowTriggerNameAction,
|
|
5
|
-
UpdateRowOrColumnMovedAction,
|
|
6
|
-
RemoveRowOrColumnMovedAction,
|
|
7
|
-
RemoveOverFlowTriggerNameAction,
|
|
8
|
-
UpdateRowOrColumnMovedAndOverflowTrigger,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type UpdateRowOrColumnMovedAction = {
|
|
12
|
-
type: AnalyticPluginTypes.UpdateRowOrColumnMovedAction;
|
|
13
|
-
data: RowOrColumnMovedState;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type RemoveRowOrColumnMovedAction = {
|
|
17
|
-
type: AnalyticPluginTypes.RemoveRowOrColumnMovedAction;
|
|
18
|
-
data: undefined;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type AnalyticPluginAction = UpdateRowOrColumnMovedAction | RemoveRowOrColumnMovedAction;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
|
|
3
|
-
import { AnalyticPluginTypes } from './actions';
|
|
4
|
-
import { createCommand, getPluginState } from './plugin-factory';
|
|
5
|
-
import { pluginKey } from './plugin-key';
|
|
6
|
-
import type { ActionType, RowOrColumnMovedState } from './types';
|
|
7
|
-
import { getMovedPayload } from './utils/moved-event';
|
|
8
|
-
|
|
9
|
-
export const updateRowOrColumnMoved = (
|
|
10
|
-
nextState: Omit<RowOrColumnMovedState, 'currentActions'>,
|
|
11
|
-
nextAction: ActionType,
|
|
12
|
-
) =>
|
|
13
|
-
createCommand(
|
|
14
|
-
(state) => {
|
|
15
|
-
const { rowOrColumnMoved } = getPluginState(state);
|
|
16
|
-
const data = getMovedPayload(nextState, nextAction, rowOrColumnMoved);
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
type: AnalyticPluginTypes.UpdateRowOrColumnMovedAction,
|
|
20
|
-
data,
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
(tr) => tr.setMeta('addToHistory', false),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
// --- transforms, prefer these over commands to avoid an extra 'dispatch'
|
|
27
|
-
export const resetRowOrColumnMovedTransform = () => (tr: Transaction) => {
|
|
28
|
-
const payload = {
|
|
29
|
-
type: AnalyticPluginTypes.RemoveRowOrColumnMovedAction,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return tr.setMeta(pluginKey, payload);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const updateRowOrColumnMovedTransform =
|
|
36
|
-
(nextState: Omit<RowOrColumnMovedState, 'currentActions'>, nextAction: ActionType) =>
|
|
37
|
-
(state: EditorState, tr: Transaction) => {
|
|
38
|
-
const { rowOrColumnMoved } = getPluginState(state);
|
|
39
|
-
const data = getMovedPayload(nextState, nextAction, rowOrColumnMoved);
|
|
40
|
-
|
|
41
|
-
const payload = {
|
|
42
|
-
type: AnalyticPluginTypes.UpdateRowOrColumnMovedAction,
|
|
43
|
-
data,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return tr.setMeta(pluginKey, payload);
|
|
47
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
4
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
countCellsInSlice,
|
|
8
|
-
getTableElementMoveTypeBySlice,
|
|
9
|
-
getTableSelectionType,
|
|
10
|
-
isInsideFirstCellOfRowOrColumn,
|
|
11
|
-
} from '../commands/misc';
|
|
12
|
-
|
|
13
|
-
import { resetRowOrColumnMovedTransform, updateRowOrColumnMoved } from './commands';
|
|
14
|
-
import { createPluginState } from './plugin-factory';
|
|
15
|
-
import { pluginKey } from './plugin-key';
|
|
16
|
-
import { defaultState } from './types';
|
|
17
|
-
|
|
18
|
-
export const createPlugin = (dispatch: Dispatch, dispatchAnalyticsEvent: DispatchAnalyticsEvent) =>
|
|
19
|
-
new SafePlugin({
|
|
20
|
-
key: pluginKey,
|
|
21
|
-
state: createPluginState(dispatch, defaultState),
|
|
22
|
-
appendTransaction: (transactions, oldState, newState) => {
|
|
23
|
-
const tr = transactions.find((tr) =>
|
|
24
|
-
tr.getMeta(pluginKey)?.data?.currentActions?.includes('pasted'),
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
if (tr) {
|
|
28
|
-
const newTr = newState.tr;
|
|
29
|
-
dispatchAnalyticsEvent({
|
|
30
|
-
action: TABLE_ACTION.ROW_OR_COLUMN_MOVED,
|
|
31
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
32
|
-
actionSubjectId: null,
|
|
33
|
-
eventType: EVENT_TYPE.TRACK,
|
|
34
|
-
attributes: {
|
|
35
|
-
type: tr.getMeta(pluginKey)?.data?.type,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
return resetRowOrColumnMovedTransform()(newTr);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return undefined;
|
|
42
|
-
},
|
|
43
|
-
props: {
|
|
44
|
-
handlePaste: ({ state, dispatch }, event, slice) => {
|
|
45
|
-
const { schema } = state;
|
|
46
|
-
const type = getTableElementMoveTypeBySlice(slice, state);
|
|
47
|
-
|
|
48
|
-
// if the selection wasn't in the first cell of a row or column, don't count it
|
|
49
|
-
if (!type || !isInsideFirstCellOfRowOrColumn(state.selection, type)) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const count = countCellsInSlice(slice, schema, type);
|
|
54
|
-
|
|
55
|
-
updateRowOrColumnMoved(
|
|
56
|
-
{
|
|
57
|
-
numberOfCells: count,
|
|
58
|
-
type,
|
|
59
|
-
},
|
|
60
|
-
'pasted',
|
|
61
|
-
)(state, dispatch);
|
|
62
|
-
},
|
|
63
|
-
transformCopied: (slice, { state, dispatch }) => {
|
|
64
|
-
const { schema } = state;
|
|
65
|
-
|
|
66
|
-
const type = getTableSelectionType(state.selection);
|
|
67
|
-
const count = countCellsInSlice(slice, schema, type);
|
|
68
|
-
|
|
69
|
-
updateRowOrColumnMoved(
|
|
70
|
-
{
|
|
71
|
-
numberOfCells: count,
|
|
72
|
-
type,
|
|
73
|
-
},
|
|
74
|
-
'copyOrCut',
|
|
75
|
-
)(state, dispatch);
|
|
76
|
-
|
|
77
|
-
return slice;
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AnalyticPluginTypes } from './actions';
|
|
2
|
-
import type { AnalyticPluginAction } from './actions';
|
|
3
|
-
import type { AnalyticPluginState } from './types';
|
|
4
|
-
import { defaultState } from './types';
|
|
5
|
-
|
|
6
|
-
export const reducer = (
|
|
7
|
-
state: AnalyticPluginState,
|
|
8
|
-
action: AnalyticPluginAction,
|
|
9
|
-
): AnalyticPluginState => {
|
|
10
|
-
switch (action.type) {
|
|
11
|
-
case AnalyticPluginTypes.UpdateRowOrColumnMovedAction:
|
|
12
|
-
return {
|
|
13
|
-
...state,
|
|
14
|
-
rowOrColumnMoved: {
|
|
15
|
-
...state.rowOrColumnMoved,
|
|
16
|
-
...action.data,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
case AnalyticPluginTypes.RemoveRowOrColumnMovedAction:
|
|
20
|
-
return {
|
|
21
|
-
...state,
|
|
22
|
-
rowOrColumnMoved: defaultState.rowOrColumnMoved,
|
|
23
|
-
};
|
|
24
|
-
default:
|
|
25
|
-
return state;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type ActionType = 'none' | 'addRowOrColumn' | 'copyOrCut' | 'pasted';
|
|
2
|
-
|
|
3
|
-
export type RowOrColumnMovedState = {
|
|
4
|
-
type?: 'row' | 'column';
|
|
5
|
-
/** used to confirm if same number of cells was copied and pasted */
|
|
6
|
-
numberOfCells?: number;
|
|
7
|
-
currentActions: Array<ActionType>;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type AnalyticPluginState = {
|
|
11
|
-
rowOrColumnMoved: RowOrColumnMovedState;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const defaultState = {
|
|
15
|
-
rowOrColumnMoved: {
|
|
16
|
-
type: undefined,
|
|
17
|
-
numberOfCells: undefined,
|
|
18
|
-
currentActions: [],
|
|
19
|
-
},
|
|
20
|
-
} as AnalyticPluginState;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { ActionType, RowOrColumnMovedState } from '../types';
|
|
2
|
-
import { defaultState } from '../types';
|
|
3
|
-
|
|
4
|
-
const getNextActionType = (
|
|
5
|
-
nextState: Omit<RowOrColumnMovedState, 'currentActions'>,
|
|
6
|
-
nextAction: ActionType,
|
|
7
|
-
prevState?: RowOrColumnMovedState,
|
|
8
|
-
) => {
|
|
9
|
-
if (nextAction === 'pasted') {
|
|
10
|
-
if (
|
|
11
|
-
prevState &&
|
|
12
|
-
prevState.currentActions.includes('copyOrCut') &&
|
|
13
|
-
prevState.currentActions.includes('addRowOrColumn') &&
|
|
14
|
-
prevState.numberOfCells === nextState.numberOfCells &&
|
|
15
|
-
prevState.type === nextState.type
|
|
16
|
-
) {
|
|
17
|
-
return 'pasted';
|
|
18
|
-
}
|
|
19
|
-
return 'none';
|
|
20
|
-
}
|
|
21
|
-
return nextAction;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const getMovedPayload = (
|
|
25
|
-
nextState: Omit<RowOrColumnMovedState, 'currentActions'>,
|
|
26
|
-
nextAction: ActionType,
|
|
27
|
-
prevState: RowOrColumnMovedState,
|
|
28
|
-
) => {
|
|
29
|
-
const nextActionType = getNextActionType(nextState, nextAction, prevState);
|
|
30
|
-
|
|
31
|
-
if (nextActionType === 'none') {
|
|
32
|
-
return defaultState.rowOrColumnMoved;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// a new workflow has started in the opposite axis (e.g. inserted a row, but copied a column) remove old state
|
|
36
|
-
if (prevState.type !== nextState.type) {
|
|
37
|
-
return {
|
|
38
|
-
currentActions: [nextActionType],
|
|
39
|
-
numberOfCells: nextState?.numberOfCells,
|
|
40
|
-
type: nextState.type,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
currentActions: prevState.currentActions.includes(nextActionType)
|
|
46
|
-
? prevState.currentActions
|
|
47
|
-
: [...prevState.currentActions, nextActionType],
|
|
48
|
-
numberOfCells: nextState?.numberOfCells || prevState.numberOfCells,
|
|
49
|
-
type: nextState?.type,
|
|
50
|
-
};
|
|
51
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Command } from '@atlaskit/editor-common/types';
|
|
2
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
|
-
import { emptyCell, findCellClosestToPos, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
5
|
-
|
|
6
|
-
export const clearMultipleCells =
|
|
7
|
-
(targetCellPosition?: number): Command =>
|
|
8
|
-
(state, dispatch) => {
|
|
9
|
-
let cursorPos: number | undefined;
|
|
10
|
-
let { tr } = state;
|
|
11
|
-
|
|
12
|
-
if (isSelectionType(tr.selection, 'cell')) {
|
|
13
|
-
// Ignored via go/ees005
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const selection = tr.selection as any as CellSelection;
|
|
16
|
-
selection.forEachCell((_node, pos) => {
|
|
17
|
-
const $pos = tr.doc.resolve(tr.mapping.map(pos + 1));
|
|
18
|
-
// Ignored via go/ees005
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
20
|
-
tr = emptyCell(findCellClosestToPos($pos)!, state.schema)(tr);
|
|
21
|
-
});
|
|
22
|
-
cursorPos = selection.$headCell.pos;
|
|
23
|
-
} else if (targetCellPosition) {
|
|
24
|
-
// Ignored via go/ees005
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
|
-
const cell = findCellClosestToPos(tr.doc.resolve(targetCellPosition + 1))!;
|
|
27
|
-
tr = emptyCell(cell, state.schema)(tr);
|
|
28
|
-
cursorPos = cell.pos;
|
|
29
|
-
}
|
|
30
|
-
if (tr.docChanged && cursorPos) {
|
|
31
|
-
const $pos = tr.doc.resolve(tr.mapping.map(cursorPos));
|
|
32
|
-
const textSelection = Selection.findFrom($pos, 1, true);
|
|
33
|
-
if (textSelection) {
|
|
34
|
-
tr.setSelection(textSelection);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (dispatch) {
|
|
38
|
-
dispatch(tr);
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
43
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Command } from '@atlaskit/editor-common/types';
|
|
2
|
-
|
|
3
|
-
import { collapseSelectedTable } from '../utils/collapse';
|
|
4
|
-
|
|
5
|
-
export const wrapTableInExpand: Command = (state, dispatch) => {
|
|
6
|
-
const collapseTr = collapseSelectedTable(state.tr);
|
|
7
|
-
|
|
8
|
-
if (!collapseTr) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (dispatch) {
|
|
13
|
-
dispatch(collapseTr);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return true;
|
|
17
|
-
};
|