@atlaskit/editor-plugin-table 10.4.7 → 10.5.1
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 +16 -0
- package/dist/cjs/nodeviews/TableComponent.js +4 -3
- package/dist/cjs/pm-plugins/utils/drag-menu.js +99 -33
- package/dist/cjs/pm-plugins/utils/paste.js +2 -1
- package/dist/cjs/ui/toolbar.js +13 -12
- package/dist/es2019/nodeviews/TableComponent.js +4 -3
- package/dist/es2019/pm-plugins/utils/drag-menu.js +71 -33
- package/dist/es2019/pm-plugins/utils/paste.js +2 -1
- package/dist/es2019/ui/toolbar.js +8 -9
- package/dist/esm/nodeviews/TableComponent.js +4 -3
- package/dist/esm/pm-plugins/utils/drag-menu.js +99 -33
- package/dist/esm/pm-plugins/utils/paste.js +2 -1
- package/dist/esm/ui/toolbar.js +10 -9
- package/dist/types/pm-plugins/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/drag-menu.d.ts +1 -1
- package/package.json +5 -5
- package/src/nodeviews/TableComponent.tsx +3 -4
- package/src/pm-plugins/utils/{drag-menu.ts → drag-menu.tsx} +125 -58
- package/src/pm-plugins/utils/paste.ts +4 -2
- package/src/ui/toolbar.tsx +10 -9
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
2
4
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
5
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
@@ -181,15 +183,25 @@ export const getDragMenuConfig = (
|
|
|
181
183
|
{
|
|
182
184
|
label: 'above',
|
|
183
185
|
offset: 0,
|
|
184
|
-
icon:
|
|
185
|
-
|
|
186
|
+
icon: () => (
|
|
187
|
+
<TableRowAddAboveIcon
|
|
188
|
+
LEGACY_fallbackIcon={AddRowAboveIcon}
|
|
189
|
+
spacing={'spacious'}
|
|
190
|
+
label={''}
|
|
191
|
+
/>
|
|
192
|
+
),
|
|
186
193
|
keymap: addRowBefore,
|
|
187
194
|
},
|
|
188
195
|
{
|
|
189
196
|
label: 'below',
|
|
190
197
|
offset: 1,
|
|
191
|
-
icon:
|
|
192
|
-
|
|
198
|
+
icon: () => (
|
|
199
|
+
<TableRowAddBelowIcon
|
|
200
|
+
LEGACY_fallbackIcon={AddRowBelowIcon}
|
|
201
|
+
spacing={'spacious'}
|
|
202
|
+
label={''}
|
|
203
|
+
/>
|
|
204
|
+
),
|
|
193
205
|
keymap: addRowAfter,
|
|
194
206
|
},
|
|
195
207
|
]
|
|
@@ -197,15 +209,25 @@ export const getDragMenuConfig = (
|
|
|
197
209
|
{
|
|
198
210
|
label: 'left',
|
|
199
211
|
offset: 0,
|
|
200
|
-
icon:
|
|
201
|
-
|
|
212
|
+
icon: () => (
|
|
213
|
+
<TableColumnAddLeftIcon
|
|
214
|
+
LEGACY_fallbackIcon={AddColLeftIcon}
|
|
215
|
+
spacing={'spacious'}
|
|
216
|
+
label={''}
|
|
217
|
+
/>
|
|
218
|
+
),
|
|
202
219
|
keymap: addColumnBefore,
|
|
203
220
|
},
|
|
204
221
|
{
|
|
205
222
|
label: 'right',
|
|
206
223
|
offset: 1,
|
|
207
|
-
icon:
|
|
208
|
-
|
|
224
|
+
icon: () => (
|
|
225
|
+
<TableColumnAddRightIcon
|
|
226
|
+
LEGACY_fallbackIcon={AddColRightIcon}
|
|
227
|
+
spacing={'spacious'}
|
|
228
|
+
label={''}
|
|
229
|
+
/>
|
|
230
|
+
),
|
|
209
231
|
keymap: addColumnAfter,
|
|
210
232
|
},
|
|
211
233
|
];
|
|
@@ -214,8 +236,13 @@ export const getDragMenuConfig = (
|
|
|
214
236
|
? [
|
|
215
237
|
{
|
|
216
238
|
label: 'up',
|
|
217
|
-
icon:
|
|
218
|
-
|
|
239
|
+
icon: () => (
|
|
240
|
+
<TableRowMoveUpIcon
|
|
241
|
+
LEGACY_fallbackIcon={ArrowUpIcon}
|
|
242
|
+
spacing={'spacious'}
|
|
243
|
+
label={''}
|
|
244
|
+
/>
|
|
245
|
+
),
|
|
219
246
|
keymap: moveRowUp,
|
|
220
247
|
canMove: canMove('table-row', -1, tableMap?.height ?? 0, selection, selectionRect),
|
|
221
248
|
getOriginIndexes: getSelectedRowIndexes,
|
|
@@ -223,8 +250,13 @@ export const getDragMenuConfig = (
|
|
|
223
250
|
},
|
|
224
251
|
{
|
|
225
252
|
label: 'down',
|
|
226
|
-
icon:
|
|
227
|
-
|
|
253
|
+
icon: () => (
|
|
254
|
+
<TableRowMoveDownIcon
|
|
255
|
+
LEGACY_fallbackIcon={ArrowDownIcon}
|
|
256
|
+
spacing={'spacious'}
|
|
257
|
+
label={''}
|
|
258
|
+
/>
|
|
259
|
+
),
|
|
228
260
|
keymap: moveRowDown,
|
|
229
261
|
canMove: canMove('table-row', 1, tableMap?.height ?? 0, selection, selectionRect),
|
|
230
262
|
getOriginIndexes: getSelectedRowIndexes,
|
|
@@ -234,8 +266,13 @@ export const getDragMenuConfig = (
|
|
|
234
266
|
: [
|
|
235
267
|
{
|
|
236
268
|
label: 'left',
|
|
237
|
-
icon:
|
|
238
|
-
|
|
269
|
+
icon: () => (
|
|
270
|
+
<TableColumnMoveLeftIcon
|
|
271
|
+
LEGACY_fallbackIcon={ArrowLeftIcon}
|
|
272
|
+
spacing={'spacious'}
|
|
273
|
+
label={''}
|
|
274
|
+
/>
|
|
275
|
+
),
|
|
239
276
|
keymap: moveColumnLeft,
|
|
240
277
|
canMove: canMove('table-column', -1, tableMap?.width ?? 0, selection, selectionRect),
|
|
241
278
|
getOriginIndexes: getSelectedColumnIndexes,
|
|
@@ -243,8 +280,13 @@ export const getDragMenuConfig = (
|
|
|
243
280
|
},
|
|
244
281
|
{
|
|
245
282
|
label: 'right',
|
|
246
|
-
icon:
|
|
247
|
-
|
|
283
|
+
icon: () => (
|
|
284
|
+
<TableColumnMoveRightIcon
|
|
285
|
+
LEGACY_fallbackIcon={ArrowRightIcon}
|
|
286
|
+
spacing={'spacious'}
|
|
287
|
+
label={''}
|
|
288
|
+
/>
|
|
289
|
+
),
|
|
248
290
|
keymap: moveColumnRight,
|
|
249
291
|
canMove: canMove('table-column', 1, tableMap?.width ?? 0, selection, selectionRect),
|
|
250
292
|
getOriginIndexes: getSelectedColumnIndexes,
|
|
@@ -257,24 +299,33 @@ export const getDragMenuConfig = (
|
|
|
257
299
|
{
|
|
258
300
|
label: 'increasing',
|
|
259
301
|
order: SortOrder.ASC,
|
|
260
|
-
icon:
|
|
261
|
-
|
|
302
|
+
icon: () => (
|
|
303
|
+
<SortAscendingIcon
|
|
304
|
+
LEGACY_fallbackIcon={HipchatChevronDoubleUpIcon}
|
|
305
|
+
spacing={'spacious'}
|
|
306
|
+
label={''}
|
|
307
|
+
/>
|
|
308
|
+
),
|
|
262
309
|
},
|
|
263
310
|
{
|
|
264
311
|
label: 'decreasing',
|
|
265
312
|
order: SortOrder.DESC,
|
|
266
|
-
icon:
|
|
267
|
-
|
|
313
|
+
icon: () => (
|
|
314
|
+
<SortDescendingIcon
|
|
315
|
+
LEGACY_fallbackIcon={HipchatChevronDoubleDownIcon}
|
|
316
|
+
spacing={'spacious'}
|
|
317
|
+
label={''}
|
|
318
|
+
/>
|
|
319
|
+
),
|
|
268
320
|
},
|
|
269
321
|
]
|
|
270
322
|
: [];
|
|
271
323
|
const sortConfigs = [
|
|
272
|
-
...sortOptions.map(({ label, order, icon
|
|
324
|
+
...sortOptions.map(({ label, order, icon }) => ({
|
|
273
325
|
id: `sort_column_${order}`,
|
|
274
326
|
title: `Sort ${label}`,
|
|
275
327
|
disabled: hasMergedCellsInTable,
|
|
276
328
|
icon: icon,
|
|
277
|
-
iconFallback: iconFallback,
|
|
278
329
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
279
330
|
sortColumnWithAnalytics(editorAnalyticsAPI)(
|
|
280
331
|
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
@@ -286,11 +337,10 @@ export const getDragMenuConfig = (
|
|
|
286
337
|
})),
|
|
287
338
|
];
|
|
288
339
|
const restConfigs = [
|
|
289
|
-
...addOptions.map(({ label, offset, icon,
|
|
340
|
+
...addOptions.map(({ label, offset, icon, keymap }) => ({
|
|
290
341
|
id: `add_${direction}_${label}`,
|
|
291
342
|
title: `Add ${direction} ${label}`,
|
|
292
343
|
icon: icon,
|
|
293
|
-
iconFallback: iconFallback,
|
|
294
344
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
295
345
|
if (direction === 'row') {
|
|
296
346
|
insertRowWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, {
|
|
@@ -339,8 +389,13 @@ export const getDragMenuConfig = (
|
|
|
339
389
|
}
|
|
340
390
|
return false;
|
|
341
391
|
},
|
|
342
|
-
icon:
|
|
343
|
-
|
|
392
|
+
icon: () => (
|
|
393
|
+
<TableColumnsDistributeIcon
|
|
394
|
+
LEGACY_fallbackIcon={EditorLayoutThreeEqualIcon}
|
|
395
|
+
spacing={'spacious'}
|
|
396
|
+
label={''}
|
|
397
|
+
/>
|
|
398
|
+
),
|
|
344
399
|
}
|
|
345
400
|
: undefined,
|
|
346
401
|
{
|
|
@@ -353,8 +408,9 @@ export const getDragMenuConfig = (
|
|
|
353
408
|
)(state, dispatch);
|
|
354
409
|
return true;
|
|
355
410
|
},
|
|
356
|
-
icon:
|
|
357
|
-
|
|
411
|
+
icon: () => (
|
|
412
|
+
<TableCellClearIcon LEGACY_fallbackIcon={CrossCircleIcon} spacing={'spacious'} label={''} />
|
|
413
|
+
),
|
|
358
414
|
keymap: tooltip(backspace),
|
|
359
415
|
},
|
|
360
416
|
{
|
|
@@ -383,38 +439,49 @@ export const getDragMenuConfig = (
|
|
|
383
439
|
}
|
|
384
440
|
return true;
|
|
385
441
|
},
|
|
386
|
-
icon:
|
|
387
|
-
|
|
442
|
+
icon:
|
|
443
|
+
direction === 'row'
|
|
444
|
+
? () => (
|
|
445
|
+
<TableRowDeleteIcon
|
|
446
|
+
LEGACY_fallbackIcon={RemoveIcon}
|
|
447
|
+
spacing={'spacious'}
|
|
448
|
+
label={''}
|
|
449
|
+
/>
|
|
450
|
+
)
|
|
451
|
+
: () => (
|
|
452
|
+
<TableColumnDeleteIcon
|
|
453
|
+
LEGACY_fallbackIcon={RemoveIcon}
|
|
454
|
+
spacing={'spacious'}
|
|
455
|
+
label={''}
|
|
456
|
+
/>
|
|
457
|
+
),
|
|
388
458
|
keymap: direction === 'row' ? tooltip(deleteRow) : tooltip(deleteColumn),
|
|
389
459
|
},
|
|
390
|
-
...moveOptions.map(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
keymap: keymap && tooltip(keymap),
|
|
416
|
-
}),
|
|
417
|
-
),
|
|
460
|
+
...moveOptions.map(({ label, canMove, icon, keymap, getOriginIndexes, getTargetIndex }) => ({
|
|
461
|
+
id: `move_${direction}_${label}`,
|
|
462
|
+
title: `Move ${direction} ${label}`,
|
|
463
|
+
disabled: !canMove,
|
|
464
|
+
icon: icon,
|
|
465
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
466
|
+
if (canMove) {
|
|
467
|
+
requestAnimationFrame(() => {
|
|
468
|
+
moveSourceWithAnalytics(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(
|
|
469
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
470
|
+
`table-${direction}`,
|
|
471
|
+
// Ignored via go/ees005
|
|
472
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
473
|
+
getOriginIndexes(selectionRect!),
|
|
474
|
+
// Ignored via go/ees005
|
|
475
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
476
|
+
getTargetIndex(selectionRect!),
|
|
477
|
+
)(editorView.state, editorView.dispatch);
|
|
478
|
+
});
|
|
479
|
+
return true;
|
|
480
|
+
}
|
|
481
|
+
return false;
|
|
482
|
+
},
|
|
483
|
+
keymap: keymap && tooltip(keymap),
|
|
484
|
+
})),
|
|
418
485
|
];
|
|
419
486
|
|
|
420
487
|
const allConfigs = [...restConfigs];
|
|
@@ -106,12 +106,14 @@ export const transformSliceToRemoveNestedTables = (
|
|
|
106
106
|
if (isNestingAllowed) {
|
|
107
107
|
const isPasteInTable = hasParentNodeOfType([table, tableCell, tableHeader])(selection);
|
|
108
108
|
const isPasteInNestedTable = getParentOfTypeCount(schema.nodes.table)(selection.$from) > 1;
|
|
109
|
+
const isPasteFullTableInsideEmptyCellEnabled = fg(
|
|
110
|
+
'platform_editor_paste_full_table_inside_empty_cell',
|
|
111
|
+
);
|
|
109
112
|
const isCellPaste =
|
|
110
113
|
isPasteInTable &&
|
|
111
114
|
slice.content.childCount === 1 &&
|
|
112
115
|
slice.content.firstChild?.type === table &&
|
|
113
|
-
slice.openStart !== 0 &&
|
|
114
|
-
slice.openEnd !== 0;
|
|
116
|
+
(!isPasteFullTableInsideEmptyCellEnabled || (slice.openStart !== 0 && slice.openEnd !== 0));
|
|
115
117
|
|
|
116
118
|
// if nesting is allowed we bump up the default nesting allowance to 2 to support
|
|
117
119
|
// two levels of nesting in nodes that support table nesting already such as layoutSection and expands
|
package/src/ui/toolbar.tsx
CHANGED
|
@@ -51,14 +51,12 @@ import {
|
|
|
51
51
|
import AlignImageCenterIcon from '@atlaskit/icon/core/align-image-center';
|
|
52
52
|
import AlignImageLeftIcon from '@atlaskit/icon/core/align-image-left';
|
|
53
53
|
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
54
|
-
import CustomizeIcon from '@atlaskit/icon/core/customize';
|
|
55
|
-
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
54
|
+
import CustomizeIcon from '@atlaskit/icon/core/migration/customize--preferences';
|
|
55
|
+
import DeleteIcon from '@atlaskit/icon/core/migration/delete--editor-remove';
|
|
56
56
|
import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
|
|
57
57
|
import EditorAlignImageCenter from '@atlaskit/icon/glyph/editor/align-image-center';
|
|
58
58
|
import EditorAlignImageLeft from '@atlaskit/icon/glyph/editor/align-image-left';
|
|
59
59
|
import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
60
|
-
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
61
|
-
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
62
60
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
63
61
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
64
62
|
|
|
@@ -175,8 +173,7 @@ export const getToolbarMenuConfig = (
|
|
|
175
173
|
type: 'dropdown',
|
|
176
174
|
testId: 'table_options',
|
|
177
175
|
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
178
|
-
icon: fg('platform-visual-refresh-icons') ? undefined :
|
|
179
|
-
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
176
|
+
icon: fg('platform-visual-refresh-icons') ? undefined : CustomizeIcon,
|
|
180
177
|
iconBefore: fg('platform-visual-refresh-icons') ? CustomizeIcon : undefined,
|
|
181
178
|
title: formatMessage(messages.tableOptions),
|
|
182
179
|
hidden: options.every((option) => option.hidden),
|
|
@@ -607,7 +604,6 @@ export const getToolbarConfig =
|
|
|
607
604
|
type: 'button' as const,
|
|
608
605
|
appearance: 'danger',
|
|
609
606
|
icon: DeleteIcon,
|
|
610
|
-
iconFallback: RemoveIcon,
|
|
611
607
|
onClick: deleteTableWithAnalytics(editorAnalyticsAPI),
|
|
612
608
|
disabled: !!resizeState && !!resizeState.dragging,
|
|
613
609
|
onMouseEnter: hoverTable(true),
|
|
@@ -844,8 +840,13 @@ const getColumnSettingItems = (
|
|
|
844
840
|
id: 'editor.table.distributeColumns',
|
|
845
841
|
type: 'button',
|
|
846
842
|
title: formatMessage(messages.distributeColumns),
|
|
847
|
-
icon:
|
|
848
|
-
|
|
843
|
+
icon: () => (
|
|
844
|
+
<TableColumnsDistributeIcon
|
|
845
|
+
LEGACY_fallbackIcon={DistributeColumnIcon}
|
|
846
|
+
spacing={'spacious'}
|
|
847
|
+
label={''}
|
|
848
|
+
/>
|
|
849
|
+
),
|
|
849
850
|
onClick: (state, dispatch, view) =>
|
|
850
851
|
getDistributeConfig(
|
|
851
852
|
getEditorContainerWidth,
|