@atlaskit/editor-plugin-table 22.2.17 → 22.2.18
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 +9 -0
- package/dist/cjs/types/index.js +0 -1
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +92 -171
- package/dist/cjs/ui/FloatingContextualMenu/index.js +3 -4
- package/dist/cjs/ui/FloatingContextualMenu/styles.js +3 -3
- package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +7 -17
- package/dist/cjs/ui/FloatingInsertButton/getPopupOptions.js +7 -9
- package/dist/cjs/ui/FloatingInsertButton/index.js +3 -2
- package/dist/cjs/ui/common-styles.js +1 -2
- package/dist/cjs/ui/consts.js +1 -2
- package/dist/cjs/ui/ui-styles.js +14 -19
- package/dist/es2019/types/index.js +0 -1
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +36 -131
- package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -5
- package/dist/es2019/ui/FloatingContextualMenu/styles.js +4 -24
- package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +7 -17
- package/dist/es2019/ui/FloatingInsertButton/getPopupOptions.js +8 -10
- package/dist/es2019/ui/FloatingInsertButton/index.js +3 -2
- package/dist/es2019/ui/common-styles.js +2 -5
- package/dist/es2019/ui/consts.js +0 -1
- package/dist/es2019/ui/ui-styles.js +2 -13
- package/dist/esm/types/index.js +0 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +93 -172
- package/dist/esm/ui/FloatingContextualMenu/index.js +4 -5
- package/dist/esm/ui/FloatingContextualMenu/styles.js +4 -4
- package/dist/esm/ui/FloatingInsertButton/InsertButton.js +7 -17
- package/dist/esm/ui/FloatingInsertButton/getPopupOptions.js +8 -10
- package/dist/esm/ui/FloatingInsertButton/index.js +3 -2
- package/dist/esm/ui/common-styles.js +1 -2
- package/dist/esm/ui/consts.js +0 -1
- package/dist/esm/ui/ui-styles.js +15 -20
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +1 -4
- package/dist/types/ui/FloatingContextualMenu/styles.d.ts +1 -1
- package/dist/types/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types/ui/consts.d.ts +0 -1
- package/dist/types/ui/ui-styles.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +1 -4
- package/dist/types-ts4.5/ui/FloatingContextualMenu/styles.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingInsertButton/getPopupOptions.d.ts +1 -1
- package/dist/types-ts4.5/ui/consts.d.ts +0 -1
- package/dist/types-ts4.5/ui/ui-styles.d.ts +1 -1
- package/package.json +4 -4
|
@@ -42,9 +42,12 @@ import { canMergeCells } from '../../pm-plugins/transforms/merge';
|
|
|
42
42
|
import { getSelectedColumnIndexes, getSelectedRowIndexes } from '../../pm-plugins/utils/selection';
|
|
43
43
|
import { getMergedCellsPositions } from '../../pm-plugins/utils/table';
|
|
44
44
|
import { TableCssClassName as ClassName } from '../../types';
|
|
45
|
-
import { colorPalletteColumns,
|
|
45
|
+
import { colorPalletteColumns, contextualMenuDropdownWidthDnD } from '../consts';
|
|
46
46
|
import { cellColourPreviewStyles } from './styles';
|
|
47
47
|
const arrowsList = new Set(!expValEquals('platform_editor_toolbar_submenu_open_click', 'isEnabled', true) ? ['ArrowRight', 'ArrowLeft'] : ['ArrowRight']);
|
|
48
|
+
const dropdownMenuSection = {
|
|
49
|
+
hasSeparator: true
|
|
50
|
+
};
|
|
48
51
|
const elementBeforeIconStyles = xcss({
|
|
49
52
|
marginRight: 'space.negative.075',
|
|
50
53
|
display: 'flex'
|
|
@@ -108,8 +111,7 @@ export class ContextualMenu extends Component {
|
|
|
108
111
|
isSubmenuOpen
|
|
109
112
|
} = this.state;
|
|
110
113
|
const {
|
|
111
|
-
targetCellPosition
|
|
112
|
-
isDragAndDropEnabled
|
|
114
|
+
targetCellPosition
|
|
113
115
|
} = getPluginState(editorView.state);
|
|
114
116
|
if (allowBackgroundColor) {
|
|
115
117
|
var _node$attrs, _node$attrs2;
|
|
@@ -122,17 +124,17 @@ export class ContextualMenu extends Component {
|
|
|
122
124
|
const selectedRowIndex = selectedRowAndColumnFromPalette.selectedRowIndex;
|
|
123
125
|
const selectedColumnIndex = selectedRowAndColumnFromPalette.selectedColumnIndex;
|
|
124
126
|
return {
|
|
125
|
-
content:
|
|
127
|
+
content: formatMessage(messages.backgroundColor),
|
|
126
128
|
value: {
|
|
127
129
|
name: 'background'
|
|
128
130
|
},
|
|
129
|
-
elemBefore:
|
|
131
|
+
elemBefore: jsx(Box, {
|
|
130
132
|
xcss: elementBeforeIconStyles
|
|
131
133
|
}, jsx(PaintBucketIcon, {
|
|
132
134
|
color: "currentColor",
|
|
133
135
|
spacing: "spacious",
|
|
134
136
|
label: formatMessage(messages.backgroundColor)
|
|
135
|
-
}))
|
|
137
|
+
})),
|
|
136
138
|
elemAfter:
|
|
137
139
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
138
140
|
jsx("div", {
|
|
@@ -142,7 +144,7 @@ export class ContextualMenu extends Component {
|
|
|
142
144
|
css: cellColourPreviewStyles(background)
|
|
143
145
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
144
146
|
,
|
|
145
|
-
className:
|
|
147
|
+
className: ClassName.CONTEXTUAL_MENU_ICON_SMALL
|
|
146
148
|
}), isSubmenuOpen && jsx("div", {
|
|
147
149
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
148
150
|
className: ClassName.CONTEXTUAL_SUBMENU,
|
|
@@ -210,12 +212,8 @@ export class ContextualMenu extends Component {
|
|
|
210
212
|
},
|
|
211
213
|
intl: {
|
|
212
214
|
formatMessage
|
|
213
|
-
}
|
|
214
|
-
editorView
|
|
215
|
+
}
|
|
215
216
|
} = this.props;
|
|
216
|
-
const {
|
|
217
|
-
isDragAndDropEnabled
|
|
218
|
-
} = getPluginState(editorView.state);
|
|
219
217
|
if (allowMergeCells) {
|
|
220
218
|
return [{
|
|
221
219
|
content: formatMessage(messages.mergeCells),
|
|
@@ -223,26 +221,26 @@ export class ContextualMenu extends Component {
|
|
|
223
221
|
name: 'merge'
|
|
224
222
|
},
|
|
225
223
|
isDisabled: !canMergeCells(state.tr),
|
|
226
|
-
elemBefore:
|
|
224
|
+
elemBefore: jsx(Box, {
|
|
227
225
|
xcss: elementBeforeIconStyles
|
|
228
226
|
}, jsx(TableCellMergeIcon, {
|
|
229
227
|
color: "currentColor",
|
|
230
228
|
spacing: "spacious",
|
|
231
229
|
label: formatMessage(messages.mergeCells)
|
|
232
|
-
}))
|
|
230
|
+
}))
|
|
233
231
|
}, {
|
|
234
232
|
content: formatMessage(messages.splitCell),
|
|
235
233
|
value: {
|
|
236
234
|
name: 'split'
|
|
237
235
|
},
|
|
238
236
|
isDisabled: !splitCell(state),
|
|
239
|
-
elemBefore:
|
|
237
|
+
elemBefore: jsx(Box, {
|
|
240
238
|
xcss: elementBeforeIconStyles
|
|
241
239
|
}, jsx(TableCellSplitIcon, {
|
|
242
240
|
color: "currentColor",
|
|
243
241
|
spacing: "spacious",
|
|
244
242
|
label: formatMessage(messages.splitCell)
|
|
245
|
-
}))
|
|
243
|
+
}))
|
|
246
244
|
}];
|
|
247
245
|
}
|
|
248
246
|
return [];
|
|
@@ -251,13 +249,9 @@ export class ContextualMenu extends Component {
|
|
|
251
249
|
const {
|
|
252
250
|
intl: {
|
|
253
251
|
formatMessage
|
|
254
|
-
}
|
|
255
|
-
editorView
|
|
252
|
+
}
|
|
256
253
|
} = this.props;
|
|
257
|
-
const
|
|
258
|
-
isDragAndDropEnabled
|
|
259
|
-
} = getPluginState(editorView.state);
|
|
260
|
-
const content = formatMessage(isDragAndDropEnabled ? messages.addColumnRight : messages.insertColumn);
|
|
254
|
+
const content = formatMessage(messages.addColumnRight);
|
|
261
255
|
return {
|
|
262
256
|
content,
|
|
263
257
|
value: {
|
|
@@ -267,7 +261,7 @@ export class ContextualMenu extends Component {
|
|
|
267
261
|
elemAfter: jsx("div", {
|
|
268
262
|
css: shortcutStyle
|
|
269
263
|
}, tooltip(addColumnAfter)),
|
|
270
|
-
elemBefore:
|
|
264
|
+
elemBefore:
|
|
271
265
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
272
266
|
jsx(Box, {
|
|
273
267
|
xcss: elementBeforeIconStyles
|
|
@@ -275,7 +269,7 @@ export class ContextualMenu extends Component {
|
|
|
275
269
|
color: "currentColor",
|
|
276
270
|
spacing: "spacious",
|
|
277
271
|
label: formatMessage(messages.addColumnRight)
|
|
278
|
-
}))
|
|
272
|
+
})),
|
|
279
273
|
'aria-label': tooltip(addColumnAfter, String(content))
|
|
280
274
|
};
|
|
281
275
|
});
|
|
@@ -283,13 +277,9 @@ export class ContextualMenu extends Component {
|
|
|
283
277
|
const {
|
|
284
278
|
intl: {
|
|
285
279
|
formatMessage
|
|
286
|
-
}
|
|
287
|
-
editorView
|
|
280
|
+
}
|
|
288
281
|
} = this.props;
|
|
289
|
-
const
|
|
290
|
-
isDragAndDropEnabled
|
|
291
|
-
} = getPluginState(editorView.state);
|
|
292
|
-
const content = formatMessage(isDragAndDropEnabled ? messages.addRowBelow : messages.insertRow);
|
|
282
|
+
const content = formatMessage(messages.addRowBelow);
|
|
293
283
|
return {
|
|
294
284
|
content,
|
|
295
285
|
value: {
|
|
@@ -299,13 +289,13 @@ export class ContextualMenu extends Component {
|
|
|
299
289
|
elemAfter: jsx("div", {
|
|
300
290
|
css: shortcutStyle
|
|
301
291
|
}, tooltip(addRowAfter)),
|
|
302
|
-
elemBefore:
|
|
292
|
+
elemBefore: jsx(Box, {
|
|
303
293
|
xcss: elementBeforeIconStyles
|
|
304
294
|
}, jsx(TableRowAddBelowIcon, {
|
|
305
295
|
color: "currentColor",
|
|
306
296
|
spacing: "spacious",
|
|
307
297
|
label: formatMessage(messages.addRowBelow)
|
|
308
|
-
}))
|
|
298
|
+
})),
|
|
309
299
|
'aria-label': tooltip(addRowAfter, String(content))
|
|
310
300
|
};
|
|
311
301
|
});
|
|
@@ -314,12 +304,8 @@ export class ContextualMenu extends Component {
|
|
|
314
304
|
selectionRect,
|
|
315
305
|
intl: {
|
|
316
306
|
formatMessage
|
|
317
|
-
}
|
|
318
|
-
editorView
|
|
307
|
+
}
|
|
319
308
|
} = this.props;
|
|
320
|
-
const {
|
|
321
|
-
isDragAndDropEnabled
|
|
322
|
-
} = getPluginState(editorView.state);
|
|
323
309
|
const {
|
|
324
310
|
top,
|
|
325
311
|
bottom,
|
|
@@ -340,7 +326,7 @@ export class ContextualMenu extends Component {
|
|
|
340
326
|
elemAfter: jsx("div", {
|
|
341
327
|
css: shortcutStyle
|
|
342
328
|
}, tooltip(backspace)),
|
|
343
|
-
elemBefore:
|
|
329
|
+
elemBefore: jsx(Box, {
|
|
344
330
|
xcss: elementBeforeIconStyles
|
|
345
331
|
}, jsx(TableCellClearIcon, {
|
|
346
332
|
color: "currentColor",
|
|
@@ -348,7 +334,7 @@ export class ContextualMenu extends Component {
|
|
|
348
334
|
label: formatMessage(messages.clearCells, {
|
|
349
335
|
0: Math.max(noOfColumns, noOfRows)
|
|
350
336
|
})
|
|
351
|
-
}))
|
|
337
|
+
})),
|
|
352
338
|
'aria-label': tooltip(backspace, String(content))
|
|
353
339
|
};
|
|
354
340
|
});
|
|
@@ -357,12 +343,8 @@ export class ContextualMenu extends Component {
|
|
|
357
343
|
selectionRect,
|
|
358
344
|
intl: {
|
|
359
345
|
formatMessage
|
|
360
|
-
}
|
|
361
|
-
editorView
|
|
346
|
+
}
|
|
362
347
|
} = this.props;
|
|
363
|
-
const {
|
|
364
|
-
isDragAndDropEnabled
|
|
365
|
-
} = getPluginState(editorView.state);
|
|
366
348
|
const {
|
|
367
349
|
right,
|
|
368
350
|
left
|
|
@@ -375,7 +357,7 @@ export class ContextualMenu extends Component {
|
|
|
375
357
|
value: {
|
|
376
358
|
name: 'delete_column'
|
|
377
359
|
},
|
|
378
|
-
elemBefore:
|
|
360
|
+
elemBefore: jsx(Box, {
|
|
379
361
|
xcss: elementBeforeIconStyles
|
|
380
362
|
}, jsx(TableColumnDeleteIcon, {
|
|
381
363
|
color: "currentColor",
|
|
@@ -383,7 +365,7 @@ export class ContextualMenu extends Component {
|
|
|
383
365
|
label: formatMessage(messages.removeColumns, {
|
|
384
366
|
0: noOfColumns
|
|
385
367
|
})
|
|
386
|
-
}))
|
|
368
|
+
}))
|
|
387
369
|
};
|
|
388
370
|
});
|
|
389
371
|
_defineProperty(this, "createDeleteRowItem", () => {
|
|
@@ -391,12 +373,8 @@ export class ContextualMenu extends Component {
|
|
|
391
373
|
selectionRect,
|
|
392
374
|
intl: {
|
|
393
375
|
formatMessage
|
|
394
|
-
}
|
|
395
|
-
editorView
|
|
376
|
+
}
|
|
396
377
|
} = this.props;
|
|
397
|
-
const {
|
|
398
|
-
isDragAndDropEnabled
|
|
399
|
-
} = getPluginState(editorView.state);
|
|
400
378
|
const {
|
|
401
379
|
bottom,
|
|
402
380
|
top
|
|
@@ -409,7 +387,7 @@ export class ContextualMenu extends Component {
|
|
|
409
387
|
value: {
|
|
410
388
|
name: 'delete_row'
|
|
411
389
|
},
|
|
412
|
-
elemBefore:
|
|
390
|
+
elemBefore: jsx(Box, {
|
|
413
391
|
xcss: elementBeforeIconStyles
|
|
414
392
|
}, jsx(TableRowDeleteIcon, {
|
|
415
393
|
color: "currentColor",
|
|
@@ -417,7 +395,7 @@ export class ContextualMenu extends Component {
|
|
|
417
395
|
label: formatMessage(messages.removeRows, {
|
|
418
396
|
0: noOfRows
|
|
419
397
|
})
|
|
420
|
-
}))
|
|
398
|
+
}))
|
|
421
399
|
};
|
|
422
400
|
});
|
|
423
401
|
_defineProperty(this, "createDistributeColumnsItemInternal", partialMenuItem => {
|
|
@@ -448,73 +426,7 @@ export class ContextualMenu extends Component {
|
|
|
448
426
|
...partialMenuItem
|
|
449
427
|
};
|
|
450
428
|
});
|
|
451
|
-
_defineProperty(this, "
|
|
452
|
-
const {
|
|
453
|
-
editorView
|
|
454
|
-
} = this.props;
|
|
455
|
-
const {
|
|
456
|
-
isDragAndDropEnabled,
|
|
457
|
-
pluginConfig: {
|
|
458
|
-
allowDistributeColumns
|
|
459
|
-
}
|
|
460
|
-
} = getPluginState(editorView.state);
|
|
461
|
-
if (allowDistributeColumns && !isDragAndDropEnabled) {
|
|
462
|
-
return this.createDistributeColumnsItemInternal();
|
|
463
|
-
}
|
|
464
|
-
return null;
|
|
465
|
-
});
|
|
466
|
-
_defineProperty(this, "createSortColumnItems", () => {
|
|
467
|
-
const {
|
|
468
|
-
intl: {
|
|
469
|
-
formatMessage
|
|
470
|
-
},
|
|
471
|
-
editorView,
|
|
472
|
-
allowColumnSorting
|
|
473
|
-
} = this.props;
|
|
474
|
-
const {
|
|
475
|
-
isDragAndDropEnabled
|
|
476
|
-
} = getPluginState(editorView.state);
|
|
477
|
-
if (allowColumnSorting && !isDragAndDropEnabled) {
|
|
478
|
-
const hasMergedCellsInTable = getMergedCellsPositions(editorView.state.tr).length > 0;
|
|
479
|
-
const warning = hasMergedCellsInTable ? {
|
|
480
|
-
tooltipDescription: formatMessage(messages.canNotSortTable),
|
|
481
|
-
isDisabled: true
|
|
482
|
-
} : {};
|
|
483
|
-
return [{
|
|
484
|
-
content: formatMessage(messages.sortColumnASC),
|
|
485
|
-
value: {
|
|
486
|
-
name: 'sort_column_asc'
|
|
487
|
-
},
|
|
488
|
-
...warning
|
|
489
|
-
}, {
|
|
490
|
-
content: formatMessage(messages.sortColumnDESC),
|
|
491
|
-
value: {
|
|
492
|
-
name: 'sort_column_desc'
|
|
493
|
-
},
|
|
494
|
-
...warning
|
|
495
|
-
}];
|
|
496
|
-
}
|
|
497
|
-
return null;
|
|
498
|
-
});
|
|
499
|
-
_defineProperty(this, "createOriginalContextMenuItems", () => {
|
|
500
|
-
const items = [];
|
|
501
|
-
const sortColumnItems = this.createSortColumnItems();
|
|
502
|
-
const backgroundColorItem = this.createBackgroundColorItem();
|
|
503
|
-
const distributeColumnsItem = this.createDistributeColumnsItem();
|
|
504
|
-
sortColumnItems && items.push(...sortColumnItems);
|
|
505
|
-
backgroundColorItem && items.push(backgroundColorItem);
|
|
506
|
-
items.push(this.createInsertColumnItem());
|
|
507
|
-
items.push(this.createInsertRowItem());
|
|
508
|
-
items.push(this.createDeleteColumnItem());
|
|
509
|
-
items.push(this.createDeleteRowItem());
|
|
510
|
-
items.push(...this.createMergeSplitCellItems());
|
|
511
|
-
distributeColumnsItem && items.push(distributeColumnsItem);
|
|
512
|
-
items.push(this.createClearCellsItem());
|
|
513
|
-
return [{
|
|
514
|
-
items
|
|
515
|
-
}];
|
|
516
|
-
});
|
|
517
|
-
_defineProperty(this, "createNewContextMenuItems", () => {
|
|
429
|
+
_defineProperty(this, "createContextMenuItems", () => {
|
|
518
430
|
const backgroundColorItem = this.createBackgroundColorItem();
|
|
519
431
|
const mergeSplitCellItems = this.createMergeSplitCellItems();
|
|
520
432
|
const insertColumnItem = this.createInsertColumnItem();
|
|
@@ -815,10 +727,9 @@ export class ContextualMenu extends Component {
|
|
|
815
727
|
}
|
|
816
728
|
componentDidUpdate() {
|
|
817
729
|
const {
|
|
818
|
-
isDragAndDropEnabled,
|
|
819
730
|
isContextualMenuOpen
|
|
820
731
|
} = getPluginState(this.props.editorView.state);
|
|
821
|
-
if (
|
|
732
|
+
if (this.props.isDragMenuOpen && isContextualMenuOpen) {
|
|
822
733
|
toggleContextualMenu()(this.props.editorView.state, this.props.editorView.dispatch);
|
|
823
734
|
}
|
|
824
735
|
}
|
|
@@ -827,14 +738,10 @@ export class ContextualMenu extends Component {
|
|
|
827
738
|
isOpen,
|
|
828
739
|
offset,
|
|
829
740
|
boundariesElement,
|
|
830
|
-
editorView,
|
|
831
741
|
isCellMenuOpenByKeyboard,
|
|
832
742
|
api
|
|
833
743
|
} = this.props;
|
|
834
|
-
const
|
|
835
|
-
isDragAndDropEnabled
|
|
836
|
-
} = getPluginState(editorView.state);
|
|
837
|
-
const items = isDragAndDropEnabled ? this.createNewContextMenuItems() : this.createOriginalContextMenuItems();
|
|
744
|
+
const items = this.createContextMenuItems();
|
|
838
745
|
let isOpenAllowed = false;
|
|
839
746
|
isOpenAllowed = isCellMenuOpenByKeyboard ? this.state.isOpenAllowed : isOpen;
|
|
840
747
|
return jsx(UserIntentPopupWrapper, {
|
|
@@ -860,7 +767,7 @@ export class ContextualMenu extends Component {
|
|
|
860
767
|
onMouseEnter: this.handleItemMouseEnter,
|
|
861
768
|
onMouseLeave: this.handleItemMouseLeave,
|
|
862
769
|
fitHeight: 188,
|
|
863
|
-
fitWidth:
|
|
770
|
+
fitWidth: contextualMenuDropdownWidthDnD
|
|
864
771
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
865
772
|
,
|
|
866
773
|
shouldFocusFirstItem: () => {
|
|
@@ -868,9 +775,7 @@ export class ContextualMenu extends Component {
|
|
|
868
775
|
},
|
|
869
776
|
boundariesElement: boundariesElement,
|
|
870
777
|
offset: offset,
|
|
871
|
-
section:
|
|
872
|
-
hasSeparator: true
|
|
873
|
-
} : undefined,
|
|
778
|
+
section: dropdownMenuSection,
|
|
874
779
|
allowEnterDefaultBehavior: this.state.isSubmenuOpen
|
|
875
780
|
})));
|
|
876
781
|
}
|
|
@@ -9,7 +9,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
9
9
|
import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
10
10
|
import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
11
11
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
12
|
-
import {
|
|
12
|
+
import { contextualMenuDropdownWidthDnD, contextualMenuTriggerSize, tablePopupMenuFitHeight } from '../consts';
|
|
13
13
|
|
|
14
14
|
// Ignored via go/ees005
|
|
15
15
|
// eslint-disable-next-line import/no-named-as-default
|
|
@@ -36,8 +36,7 @@ const FloatingContextualMenu = ({
|
|
|
36
36
|
|
|
37
37
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
38
38
|
const {
|
|
39
|
-
targetCellPosition
|
|
40
|
-
isDragAndDropEnabled
|
|
39
|
+
targetCellPosition
|
|
41
40
|
} = getPluginState(editorView.state);
|
|
42
41
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
43
42
|
return null;
|
|
@@ -69,7 +68,7 @@ const FloatingContextualMenu = ({
|
|
|
69
68
|
boundariesElement: boundariesElement,
|
|
70
69
|
scrollableElement: scrollableElement,
|
|
71
70
|
fitHeight: tablePopupMenuFitHeight,
|
|
72
|
-
fitWidth:
|
|
71
|
+
fitWidth: contextualMenuDropdownWidthDnD
|
|
73
72
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
74
73
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
75
74
|
,
|
|
@@ -80,7 +79,7 @@ const FloatingContextualMenu = ({
|
|
|
80
79
|
offset: [-7, 0],
|
|
81
80
|
stick: true
|
|
82
81
|
}, jsx("div", {
|
|
83
|
-
css: tablePopupStyles(
|
|
82
|
+
css: tablePopupStyles()
|
|
84
83
|
}, jsx(ContextualMenu, {
|
|
85
84
|
editorView: editorView
|
|
86
85
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
3
|
import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
|
|
4
4
|
import { TableCssClassName as ClassName } from '../../types';
|
|
5
|
-
import {
|
|
5
|
+
import { contextualMenuDropdownWidthDnD } from '../consts';
|
|
6
6
|
export const cellColourPreviewStyles = selectedColor => css({
|
|
7
7
|
'&::before': {
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
9
9
|
background: selectedColor
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
export const tablePopupStyles = (
|
|
13
|
-
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
|
|
12
|
+
export const tablePopupStyles = (
|
|
13
|
+
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
|
|
14
14
|
) => css`
|
|
15
15
|
.${ClassName.CONTEXTUAL_SUBMENU} {
|
|
16
16
|
border-radius: ${"var(--ds-radius-small, 3px)"};
|
|
@@ -19,7 +19,7 @@ export const tablePopupStyles = (isDragAndDropEnabled
|
|
|
19
19
|
display: block;
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
|
-
left: ${
|
|
22
|
+
left: ${contextualMenuDropdownWidthDnD}px;
|
|
23
23
|
padding: ${"var(--ds-space-100, 8px)"};
|
|
24
24
|
|
|
25
25
|
> div {
|
|
@@ -27,26 +27,6 @@ export const tablePopupStyles = (isDragAndDropEnabled
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.${ClassName.CONTEXTUAL_MENU_ICON} {
|
|
31
|
-
display: flex;
|
|
32
|
-
|
|
33
|
-
&::before {
|
|
34
|
-
content: '';
|
|
35
|
-
display: block;
|
|
36
|
-
border: 1px solid ${tableBackgroundBorderColor};
|
|
37
|
-
border-radius: ${"var(--ds-radius-small, 3px)"};
|
|
38
|
-
width: 20px;
|
|
39
|
-
height: 20px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&::after {
|
|
43
|
-
content: '›';
|
|
44
|
-
margin-left: ${"var(--ds-space-050, 4px)"};
|
|
45
|
-
line-height: 20px;
|
|
46
|
-
color: ${"var(--ds-icon, #292A2E)"};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
30
|
.${ClassName.CONTEXTUAL_MENU_ICON_SMALL} {
|
|
51
31
|
display: flex;
|
|
52
32
|
|
|
@@ -11,33 +11,25 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
|
11
11
|
import Tooltip from '@atlaskit/tooltip';
|
|
12
12
|
import { TableCssClassName as ClassName } from '../../types';
|
|
13
13
|
import { tableToolbarSize } from '../consts';
|
|
14
|
-
const getInsertLineHeight = (tableRef, hasStickyHeaders
|
|
14
|
+
const getInsertLineHeight = (tableRef, hasStickyHeaders) => {
|
|
15
15
|
// The line gets height 100% from the table,
|
|
16
16
|
// but since we have an overflow on the left,
|
|
17
17
|
// we should add an offset to make up for it.
|
|
18
18
|
const LINE_OFFSET = 3;
|
|
19
|
-
const ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - tableMarginTop *
|
|
19
|
+
const ADDITIONAL_HEIGHT = hasStickyHeaders ? tableRef.getBoundingClientRect().top - tableMarginTop * 3 - LINE_OFFSET : tableToolbarSize + LINE_OFFSET;
|
|
20
20
|
return tableRef.offsetHeight + ADDITIONAL_HEIGHT;
|
|
21
21
|
};
|
|
22
|
-
const
|
|
22
|
+
const getNumberColumnWidth = tableRef => {
|
|
23
23
|
const parent = closestElement(tableRef, `.${ClassName.TABLE_CONTAINER}`);
|
|
24
24
|
if (parent) {
|
|
25
|
-
return parent.querySelector(`.${ClassName.NUMBERED_COLUMN}`) ? tableToolbarSize + akEditorTableNumberColumnWidth - 1 : tableToolbarSize;
|
|
26
|
-
}
|
|
27
|
-
return tableToolbarSize;
|
|
28
|
-
};
|
|
29
|
-
const getNumberColumnWidth = (tableRef, isDragAndDropEnabled) => {
|
|
30
|
-
const parent = closestElement(tableRef, `.${ClassName.TABLE_CONTAINER}`);
|
|
31
|
-
if (parent && isDragAndDropEnabled) {
|
|
32
25
|
return parent.querySelector(`.${ClassName.NUMBERED_COLUMN}`) ? akEditorTableNumberColumnWidth - 1 : 0;
|
|
33
26
|
}
|
|
34
27
|
return 0;
|
|
35
28
|
};
|
|
36
|
-
const getInsertLineWidth = (tableRef,
|
|
29
|
+
const getInsertLineWidth = (tableRef, isChromelessEditor) => {
|
|
37
30
|
// The line gets width 100% from the table,
|
|
38
31
|
// but since we have an overflow on the left,
|
|
39
32
|
// we should add an offset to make up for it.
|
|
40
|
-
const LINE_OFFSET = 4;
|
|
41
33
|
const DRAG_LINE_OFFSET = isChromelessEditor ? 14 : 6;
|
|
42
34
|
const {
|
|
43
35
|
parentElement,
|
|
@@ -52,9 +44,7 @@ const getInsertLineWidth = (tableRef, isDragAndDropEnabled, isChromelessEditor)
|
|
|
52
44
|
scrollLeft
|
|
53
45
|
} = parentElement;
|
|
54
46
|
const diff = offsetWidth - parentOffsetWidth;
|
|
55
|
-
|
|
56
|
-
const lineOffset = isDragAndDropEnabled ? DRAG_LINE_OFFSET : LINE_OFFSET;
|
|
57
|
-
return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + lineOffset + getNumberColumnWidth(tableRef, isDragAndDropEnabled);
|
|
47
|
+
return Math.min(offsetWidth, parentOffsetWidth - Math.max(scrollLeft - diff, 0)) + DRAG_LINE_OFFSET + getNumberColumnWidth(tableRef);
|
|
58
48
|
};
|
|
59
49
|
const tooltipMessageByType = type => {
|
|
60
50
|
return type === 'row' ? messages.insertRow : messages.insertColumn;
|
|
@@ -106,10 +96,10 @@ const InsertButtonForDragAndDrop = ({
|
|
|
106
96
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
107
97
|
,
|
|
108
98
|
style: type === 'row' ? {
|
|
109
|
-
width: getInsertLineWidth(tableRef,
|
|
99
|
+
width: getInsertLineWidth(tableRef, isChromelessEditor),
|
|
110
100
|
left: "var(--ds-space-150, 12px)"
|
|
111
101
|
} : {
|
|
112
|
-
height: getInsertLineHeight(tableRef, hasStickyHeaders
|
|
102
|
+
height: getInsertLineHeight(tableRef, hasStickyHeaders) - 8,
|
|
113
103
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
114
104
|
top: '-3px'
|
|
115
105
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
2
|
-
import { tableInsertColumnButtonOffset, tableInsertColumnButtonSize
|
|
2
|
+
import { tableInsertColumnButtonOffset, tableInsertColumnButtonSize } from '../consts';
|
|
3
3
|
const HORIZONTAL_ALIGN_COLUMN_BUTTON = -(tableInsertColumnButtonSize / 2);
|
|
4
4
|
const HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON = HORIZONTAL_ALIGN_COLUMN_BUTTON + akEditorTableNumberColumnWidth;
|
|
5
|
-
const VERTICAL_ALIGN_COLUMN_BUTTON = tableToolbarSize + tableInsertColumnButtonOffset;
|
|
6
5
|
const VERTICAL_ALIGN_COLUMN_BUTTON_DRAG = tableInsertColumnButtonOffset;
|
|
7
|
-
const HORIZONTAL_ALIGN_ROW_BUTTON = -(tableToolbarSize + tableInsertColumnButtonOffset + tableInsertColumnButtonSize);
|
|
8
6
|
const HORIZONTAL_ALIGN_ROW_BUTTON_DRAG = -18;
|
|
9
7
|
const VERTICAL_ALIGN_ROW_BUTTON = tableInsertColumnButtonSize / 2;
|
|
10
|
-
function getRowOptions(index
|
|
8
|
+
function getRowOptions(index) {
|
|
11
9
|
let defaultOptions = {
|
|
12
10
|
alignX: 'left',
|
|
13
11
|
alignY: 'bottom',
|
|
@@ -27,16 +25,16 @@ function getRowOptions(index, isDragAndDropEnabled) {
|
|
|
27
25
|
return {
|
|
28
26
|
...position,
|
|
29
27
|
// Left position should be always the offset (To place in the correct position even if the table has overflow).
|
|
30
|
-
left:
|
|
28
|
+
left: HORIZONTAL_ALIGN_ROW_BUTTON_DRAG
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
31
|
};
|
|
34
32
|
}
|
|
35
|
-
function getColumnOptions(index, tableContainer, hasNumberedColumns
|
|
33
|
+
function getColumnOptions(index, tableContainer, hasNumberedColumns) {
|
|
36
34
|
const options = {
|
|
37
35
|
alignX: 'end',
|
|
38
36
|
alignY: 'top',
|
|
39
|
-
offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON,
|
|
37
|
+
offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON, VERTICAL_ALIGN_COLUMN_BUTTON_DRAG],
|
|
40
38
|
// :: (position: PopupPosition) -> PopupPosition
|
|
41
39
|
// Limit the InsertButton position to the table container
|
|
42
40
|
// if the left position starts before it
|
|
@@ -77,12 +75,12 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDr
|
|
|
77
75
|
}
|
|
78
76
|
return options;
|
|
79
77
|
}
|
|
80
|
-
function getPopupOptions(direction, index, hasNumberedColumns,
|
|
78
|
+
function getPopupOptions(direction, index, hasNumberedColumns, tableContainer) {
|
|
81
79
|
switch (direction) {
|
|
82
80
|
case 'column':
|
|
83
|
-
return getColumnOptions(index, tableContainer, hasNumberedColumns
|
|
81
|
+
return getColumnOptions(index, tableContainer, hasNumberedColumns);
|
|
84
82
|
case 'row':
|
|
85
|
-
return getRowOptions(index
|
|
83
|
+
return getRowOptions(index);
|
|
86
84
|
default:
|
|
87
85
|
return {};
|
|
88
86
|
}
|
|
@@ -38,7 +38,8 @@ export class FloatingInsertButton extends React.Component {
|
|
|
38
38
|
dispatchAnalyticsEvent,
|
|
39
39
|
isChromelessEditor
|
|
40
40
|
} = this.props;
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
// ED-26961 - disable insert button for first column and row
|
|
42
43
|
if (insertColumnButtonIndex === 0 || insertRowButtonIndex === 0) {
|
|
43
44
|
return null;
|
|
44
45
|
}
|
|
@@ -129,7 +130,7 @@ export class FloatingInsertButton extends React.Component {
|
|
|
129
130
|
allowOutOfBounds: true
|
|
130
131
|
// Ignored via go/ees005
|
|
131
132
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
132
|
-
}, getPopupOptions(type, index, hasNumberedColumns,
|
|
133
|
+
}, getPopupOptions(type, index, hasNumberedColumns, tableContainerWrapper), {
|
|
133
134
|
zIndex: zIndex
|
|
134
135
|
}), /*#__PURE__*/React.createElement(DragAndDropInsertButton, {
|
|
135
136
|
type: type,
|
|
@@ -234,9 +234,7 @@ const activeCellHighlightStyles = () => {
|
|
|
234
234
|
}
|
|
235
235
|
`;
|
|
236
236
|
};
|
|
237
|
-
const baseTableStylesWithoutSharedStyle = props =>
|
|
238
|
-
var _props$featureFlags;
|
|
239
|
-
return css`
|
|
237
|
+
const baseTableStylesWithoutSharedStyle = props => css`
|
|
240
238
|
${columnControlsLineMarker()};
|
|
241
239
|
${hoveredDeleteButton()};
|
|
242
240
|
${hoveredCell()};
|
|
@@ -559,7 +557,7 @@ const baseTableStylesWithoutSharedStyle = props => {
|
|
|
559
557
|
}
|
|
560
558
|
|
|
561
559
|
${sentinelStyles}
|
|
562
|
-
${OverflowShadow(
|
|
560
|
+
${OverflowShadow()}
|
|
563
561
|
${stickyScrollbarStyles}
|
|
564
562
|
|
|
565
563
|
.${ClassName.TABLE_STICKY} .${ClassName.TABLE_STICKY_SHADOW} {
|
|
@@ -1307,7 +1305,6 @@ const baseTableStylesWithoutSharedStyle = props => {
|
|
|
1307
1305
|
overflow: visible;
|
|
1308
1306
|
}
|
|
1309
1307
|
`;
|
|
1310
|
-
};
|
|
1311
1308
|
|
|
1312
1309
|
// re-exporting these styles to use in Gemini test when table node view is rendered outside of PM
|
|
1313
1310
|
export const baseTableStyles = props => css`
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -52,7 +52,6 @@ export const resizeHandlerAreaWidth = RESIZE_HANDLE_AREA_DECORATION_GAP / 3;
|
|
|
52
52
|
export const resizeLineWidth = 2;
|
|
53
53
|
export const resizeHandlerZIndex = columnControlsZIndex + akRichMediaResizeZIndex;
|
|
54
54
|
export const contextualMenuTriggerSize = 16;
|
|
55
|
-
export const contextualMenuDropdownWidth = 180;
|
|
56
55
|
export const contextualMenuDropdownWidthDnD = 250;
|
|
57
56
|
export const stickyRowZIndex = resizeHandlerZIndex + 2;
|
|
58
57
|
export const stickyRowOffsetTop = 8;
|