@atlaskit/editor-plugin-table 7.13.3 → 7.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/toolbar.js +72 -4
- package/dist/cjs/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.js +43 -0
- package/dist/es2019/toolbar.js +74 -3
- package/dist/es2019/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.js +37 -0
- package/dist/esm/toolbar.js +71 -3
- package/dist/esm/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.js +36 -0
- package/dist/types/toolbar.d.ts +1 -0
- package/dist/types/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.d.ts +9 -0
- package/dist/types-ts4.5/toolbar.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.d.ts +9 -0
- package/package.json +6 -2
- package/src/toolbar.tsx +99 -1
- package/src/ui/FloatingAlignmentButtons/FloatingAlignmentButtons.tsx +56 -0
- package/tsconfig.app.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#99771](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99771)
|
|
8
|
+
[`3cd9b2d8ae80`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3cd9b2d8ae80) -
|
|
9
|
+
[ux] ED-22923 Tables - Added alignment toolbat button
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 7.13.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#98080](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98080)
|
|
20
|
+
[`23c03580e38c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/23c03580e38c) -
|
|
21
|
+
[ux] [ED-23247] Allow floating toolbar copy buttons in live pages view mode.
|
|
22
|
+
|
|
3
23
|
## 7.13.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/dist/cjs/toolbar.js
CHANGED
|
@@ -5,7 +5,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getLockBtnConfig = exports.getDistributeConfig = exports.getClosestSelectionRect = exports.getClosestSelectionOrTableRect = void 0;
|
|
8
|
+
exports.getToolbarMenuConfig = exports.getToolbarConfig = exports.getToolbarCellOptionsConfig = exports.getLockBtnConfig = exports.getDistributeConfig = exports.getClosestSelectionRect = exports.getClosestSelectionOrTableRect = exports.getAlignmentOptionsConfig = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
11
|
var _react = require("@emotion/react");
|
|
11
12
|
var _customSteps = require("@atlaskit/custom-steps");
|
|
@@ -19,6 +20,8 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
19
20
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
20
21
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
21
22
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
23
|
+
var _alignImageCenter = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/align-image-center"));
|
|
24
|
+
var _alignImageLeft = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/align-image-left"));
|
|
22
25
|
var _layoutThreeEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-three-equal"));
|
|
23
26
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
24
27
|
var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
|
|
@@ -31,6 +34,7 @@ var _resizeState = require("./pm-plugins/table-resizing/utils/resize-state");
|
|
|
31
34
|
var _tableWidth = require("./pm-plugins/table-width");
|
|
32
35
|
var _transforms = require("./transforms");
|
|
33
36
|
var _types = require("./types");
|
|
37
|
+
var _FloatingAlignmentButtons = require("./ui/FloatingAlignmentButtons/FloatingAlignmentButtons");
|
|
34
38
|
var _icons = require("./ui/icons");
|
|
35
39
|
var _utils4 = require("./utils");
|
|
36
40
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -324,6 +328,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
324
328
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
325
329
|
var nodeType = state.schema.nodes.table;
|
|
326
330
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
331
|
+
var alignmentMenu;
|
|
332
|
+
alignmentMenu = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.allow-table-alignment') ? getAlignmentOptionsConfig(pluginState, intl, editorAnalyticsAPI) : [];
|
|
327
333
|
var cellItems;
|
|
328
334
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled);
|
|
329
335
|
var columnSettingsItems;
|
|
@@ -380,11 +386,12 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
380
386
|
},
|
|
381
387
|
zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex + 1,
|
|
382
388
|
// Place the context menu slightly above the others
|
|
383
|
-
items: [menu, separator(menu.hidden)].concat((0, _toConsumableArray2.default)(cellItems), (0, _toConsumableArray2.default)(columnSettingsItems), colorPicker, [{
|
|
389
|
+
items: [menu, separator(menu.hidden)].concat((0, _toConsumableArray2.default)(alignmentMenu), [separator(alignmentMenu.length === 0)], (0, _toConsumableArray2.default)(cellItems), (0, _toConsumableArray2.default)(columnSettingsItems), colorPicker, [{
|
|
384
390
|
type: 'extensions-placeholder',
|
|
385
391
|
separator: 'end'
|
|
386
392
|
}, {
|
|
387
393
|
type: 'copy-button',
|
|
394
|
+
supportsViewMode: true,
|
|
388
395
|
items: [{
|
|
389
396
|
state: state,
|
|
390
397
|
formatMessage: intl.formatMessage,
|
|
@@ -393,9 +400,9 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(getE
|
|
|
393
400
|
onMouseLeave: (0, _commands.clearHoverSelection)(),
|
|
394
401
|
onFocus: (0, _commands.hoverTable)(false, true),
|
|
395
402
|
onBlur: (0, _commands.clearHoverSelection)()
|
|
396
|
-
}, {
|
|
397
|
-
type: 'separator'
|
|
398
403
|
}]
|
|
404
|
+
}, {
|
|
405
|
+
type: 'separator'
|
|
399
406
|
}, {
|
|
400
407
|
id: 'editor.table.delete',
|
|
401
408
|
type: 'button',
|
|
@@ -585,4 +592,65 @@ var highlightColumnsHandler = function highlightColumnsHandler(state, dispatch)
|
|
|
585
592
|
return true;
|
|
586
593
|
}
|
|
587
594
|
return false;
|
|
595
|
+
};
|
|
596
|
+
var getAlignmentOptionsConfig = exports.getAlignmentOptionsConfig = function getAlignmentOptionsConfig(state, _ref6, editorAnalyticsAPI) {
|
|
597
|
+
var formatMessage = _ref6.formatMessage;
|
|
598
|
+
var alignmentIcons = [{
|
|
599
|
+
id: 'editor.table.alignLeft',
|
|
600
|
+
value: 'align-start',
|
|
601
|
+
icon: _alignImageLeft.default
|
|
602
|
+
}, {
|
|
603
|
+
id: 'editor.table.alignCenter',
|
|
604
|
+
value: 'center',
|
|
605
|
+
icon: _alignImageCenter.default
|
|
606
|
+
}];
|
|
607
|
+
|
|
608
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
609
|
+
var layoutToMessages = {
|
|
610
|
+
center: _messages.tableMessages.alignTableCenter,
|
|
611
|
+
'align-start': _messages.tableMessages.alignTableLeft
|
|
612
|
+
};
|
|
613
|
+
var alignmentButtons = alignmentIcons.map(function (alignmentIcon) {
|
|
614
|
+
var id = alignmentIcon.id,
|
|
615
|
+
value = alignmentIcon.value,
|
|
616
|
+
icon = alignmentIcon.icon;
|
|
617
|
+
return {
|
|
618
|
+
id: id,
|
|
619
|
+
type: 'button',
|
|
620
|
+
icon: icon,
|
|
621
|
+
title: formatMessage(layoutToMessages[value]),
|
|
622
|
+
selected: false,
|
|
623
|
+
// TODO - get the correct selected state based on the selected layout attr
|
|
624
|
+
onClick: makeAlignment()
|
|
625
|
+
};
|
|
626
|
+
});
|
|
627
|
+
var alignmentOptions = {
|
|
628
|
+
render: function render(props) {
|
|
629
|
+
return (0, _react.jsx)(_FloatingAlignmentButtons.FloatingAlignmentButtons, (0, _extends2.default)({
|
|
630
|
+
alignmentButtons: alignmentButtons
|
|
631
|
+
}, props));
|
|
632
|
+
},
|
|
633
|
+
width: 60,
|
|
634
|
+
height: 32
|
|
635
|
+
};
|
|
636
|
+
var alignmentToolbarItem = [{
|
|
637
|
+
id: 'table-layout',
|
|
638
|
+
testId: 'table-layout-dropdown',
|
|
639
|
+
type: 'dropdown',
|
|
640
|
+
options: alignmentOptions,
|
|
641
|
+
title: formatMessage(_messages.tableMessages.tableAlignmentOptions),
|
|
642
|
+
// TODO - get the correct title based on the selected layout attr
|
|
643
|
+
icon: _alignImageCenter.default // TODO - get the correct icon based on the selected layout attr
|
|
644
|
+
}];
|
|
645
|
+
return alignmentToolbarItem;
|
|
646
|
+
};
|
|
647
|
+
var makeAlignment = function makeAlignment() {
|
|
648
|
+
return function (state, dispatch) {
|
|
649
|
+
var tableObject = (0, _utils3.findTable)(state.selection);
|
|
650
|
+
if (!tableObject || !dispatch) {
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
// TODO Add alignment logic here
|
|
654
|
+
return true;
|
|
655
|
+
};
|
|
588
656
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FloatingAlignmentButtons = void 0;
|
|
7
|
+
var _react = require("@emotion/react");
|
|
8
|
+
var _button = require("@atlaskit/button");
|
|
9
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
|
+
var _primitives = require("@atlaskit/primitives");
|
|
11
|
+
/** @jsx jsx */
|
|
12
|
+
|
|
13
|
+
var containerStyles = (0, _primitives.xcss)({
|
|
14
|
+
marginLeft: 'space.100'
|
|
15
|
+
});
|
|
16
|
+
var FloatingAlignmentButtons = exports.FloatingAlignmentButtons = function FloatingAlignmentButtons(_ref) {
|
|
17
|
+
var alignmentButtons = _ref.alignmentButtons,
|
|
18
|
+
dispatchCommand = _ref.dispatchCommand;
|
|
19
|
+
return (0, _react.jsx)(_primitives.Box, {
|
|
20
|
+
xcss: containerStyles
|
|
21
|
+
}, (0, _react.jsx)(_button.ButtonGroup, null, alignmentButtons.map(function (item, idx) {
|
|
22
|
+
switch (item.type) {
|
|
23
|
+
case 'separator':
|
|
24
|
+
return (0, _react.jsx)(_ui.FloatingToolbarSeparator, {
|
|
25
|
+
key: idx
|
|
26
|
+
});
|
|
27
|
+
case 'button':
|
|
28
|
+
var ButtonIcon = item.icon;
|
|
29
|
+
return (0, _react.jsx)(_ui.FloatingToolbarButton, {
|
|
30
|
+
key: idx,
|
|
31
|
+
icon: item.icon ? (0, _react.jsx)(ButtonIcon, {
|
|
32
|
+
label: item.title
|
|
33
|
+
}) : undefined,
|
|
34
|
+
title: item.title,
|
|
35
|
+
selected: item.selected,
|
|
36
|
+
disabled: item.disabled,
|
|
37
|
+
onClick: function onClick() {
|
|
38
|
+
dispatchCommand(item.onClick);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
})));
|
|
43
|
+
};
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
/** @jsx jsx */
|
|
2
3
|
import { jsx } from '@emotion/react';
|
|
3
4
|
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
@@ -11,6 +12,8 @@ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
|
11
12
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
12
13
|
import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
13
14
|
import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType, splitCell } from '@atlaskit/editor-tables/utils';
|
|
15
|
+
import EditorAlignImageCenter from '@atlaskit/icon/glyph/editor/align-image-center';
|
|
16
|
+
import EditorAlignImageLeft from '@atlaskit/icon/glyph/editor/align-image-left';
|
|
14
17
|
import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
15
18
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
16
19
|
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
@@ -23,6 +26,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
|
|
|
23
26
|
import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
24
27
|
import { canMergeCells } from './transforms';
|
|
25
28
|
import { TableCssClassName } from './types';
|
|
29
|
+
import { FloatingAlignmentButtons } from './ui/FloatingAlignmentButtons/FloatingAlignmentButtons';
|
|
26
30
|
import { DisplayModeIcon } from './ui/icons';
|
|
27
31
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, isTableNested } from './utils';
|
|
28
32
|
export const getToolbarMenuConfig = (config, state, {
|
|
@@ -310,6 +314,8 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
310
314
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
311
315
|
const nodeType = state.schema.nodes.table;
|
|
312
316
|
const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
317
|
+
let alignmentMenu;
|
|
318
|
+
alignmentMenu = getBooleanFF('platform.editor.table.allow-table-alignment') ? getAlignmentOptionsConfig(pluginState, intl, editorAnalyticsAPI) : [];
|
|
313
319
|
let cellItems;
|
|
314
320
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled);
|
|
315
321
|
let columnSettingsItems;
|
|
@@ -360,11 +366,12 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
360
366
|
},
|
|
361
367
|
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
362
368
|
// Place the context menu slightly above the others
|
|
363
|
-
items: [menu, separator(menu.hidden), ...cellItems, ...columnSettingsItems, ...colorPicker, {
|
|
369
|
+
items: [menu, separator(menu.hidden), ...alignmentMenu, separator(alignmentMenu.length === 0), ...cellItems, ...columnSettingsItems, ...colorPicker, {
|
|
364
370
|
type: 'extensions-placeholder',
|
|
365
371
|
separator: 'end'
|
|
366
372
|
}, {
|
|
367
373
|
type: 'copy-button',
|
|
374
|
+
supportsViewMode: true,
|
|
368
375
|
items: [{
|
|
369
376
|
state,
|
|
370
377
|
formatMessage: intl.formatMessage,
|
|
@@ -373,9 +380,9 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
373
380
|
onMouseLeave: clearHoverSelection(),
|
|
374
381
|
onFocus: hoverTable(false, true),
|
|
375
382
|
onBlur: clearHoverSelection()
|
|
376
|
-
}, {
|
|
377
|
-
type: 'separator'
|
|
378
383
|
}]
|
|
384
|
+
}, {
|
|
385
|
+
type: 'separator'
|
|
379
386
|
}, {
|
|
380
387
|
id: 'editor.table.delete',
|
|
381
388
|
type: 'button',
|
|
@@ -552,4 +559,68 @@ const highlightColumnsHandler = (state, dispatch) => {
|
|
|
552
559
|
return true;
|
|
553
560
|
}
|
|
554
561
|
return false;
|
|
562
|
+
};
|
|
563
|
+
export const getAlignmentOptionsConfig = (state, {
|
|
564
|
+
formatMessage
|
|
565
|
+
}, editorAnalyticsAPI) => {
|
|
566
|
+
const alignmentIcons = [{
|
|
567
|
+
id: 'editor.table.alignLeft',
|
|
568
|
+
value: 'align-start',
|
|
569
|
+
icon: EditorAlignImageLeft
|
|
570
|
+
}, {
|
|
571
|
+
id: 'editor.table.alignCenter',
|
|
572
|
+
value: 'center',
|
|
573
|
+
icon: EditorAlignImageCenter
|
|
574
|
+
}];
|
|
575
|
+
|
|
576
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
577
|
+
const layoutToMessages = {
|
|
578
|
+
center: messages.alignTableCenter,
|
|
579
|
+
'align-start': messages.alignTableLeft
|
|
580
|
+
};
|
|
581
|
+
const alignmentButtons = alignmentIcons.map(alignmentIcon => {
|
|
582
|
+
const {
|
|
583
|
+
id,
|
|
584
|
+
value,
|
|
585
|
+
icon
|
|
586
|
+
} = alignmentIcon;
|
|
587
|
+
return {
|
|
588
|
+
id: id,
|
|
589
|
+
type: 'button',
|
|
590
|
+
icon: icon,
|
|
591
|
+
title: formatMessage(layoutToMessages[value]),
|
|
592
|
+
selected: false,
|
|
593
|
+
// TODO - get the correct selected state based on the selected layout attr
|
|
594
|
+
onClick: makeAlignment()
|
|
595
|
+
};
|
|
596
|
+
});
|
|
597
|
+
const alignmentOptions = {
|
|
598
|
+
render: props => {
|
|
599
|
+
return jsx(FloatingAlignmentButtons, _extends({
|
|
600
|
+
alignmentButtons: alignmentButtons
|
|
601
|
+
}, props));
|
|
602
|
+
},
|
|
603
|
+
width: 60,
|
|
604
|
+
height: 32
|
|
605
|
+
};
|
|
606
|
+
const alignmentToolbarItem = [{
|
|
607
|
+
id: 'table-layout',
|
|
608
|
+
testId: 'table-layout-dropdown',
|
|
609
|
+
type: 'dropdown',
|
|
610
|
+
options: alignmentOptions,
|
|
611
|
+
title: formatMessage(messages.tableAlignmentOptions),
|
|
612
|
+
// TODO - get the correct title based on the selected layout attr
|
|
613
|
+
icon: EditorAlignImageCenter // TODO - get the correct icon based on the selected layout attr
|
|
614
|
+
}];
|
|
615
|
+
return alignmentToolbarItem;
|
|
616
|
+
};
|
|
617
|
+
const makeAlignment = () => {
|
|
618
|
+
return (state, dispatch) => {
|
|
619
|
+
const tableObject = findTable(state.selection);
|
|
620
|
+
if (!tableObject || !dispatch) {
|
|
621
|
+
return false;
|
|
622
|
+
}
|
|
623
|
+
// TODO Add alignment logic here
|
|
624
|
+
return true;
|
|
625
|
+
};
|
|
555
626
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { ButtonGroup } from '@atlaskit/button';
|
|
4
|
+
import { FloatingToolbarButton as Button, FloatingToolbarSeparator } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
6
|
+
const containerStyles = xcss({
|
|
7
|
+
marginLeft: 'space.100'
|
|
8
|
+
});
|
|
9
|
+
export const FloatingAlignmentButtons = ({
|
|
10
|
+
alignmentButtons,
|
|
11
|
+
dispatchCommand
|
|
12
|
+
}) => {
|
|
13
|
+
return jsx(Box, {
|
|
14
|
+
xcss: containerStyles
|
|
15
|
+
}, jsx(ButtonGroup, null, alignmentButtons.map((item, idx) => {
|
|
16
|
+
switch (item.type) {
|
|
17
|
+
case 'separator':
|
|
18
|
+
return jsx(FloatingToolbarSeparator, {
|
|
19
|
+
key: idx
|
|
20
|
+
});
|
|
21
|
+
case 'button':
|
|
22
|
+
const ButtonIcon = item.icon;
|
|
23
|
+
return jsx(Button, {
|
|
24
|
+
key: idx,
|
|
25
|
+
icon: item.icon ? jsx(ButtonIcon, {
|
|
26
|
+
label: item.title
|
|
27
|
+
}) : undefined,
|
|
28
|
+
title: item.title,
|
|
29
|
+
selected: item.selected,
|
|
30
|
+
disabled: item.disabled,
|
|
31
|
+
onClick: () => {
|
|
32
|
+
dispatchCommand(item.onClick);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
})));
|
|
37
|
+
};
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
3
|
/** @jsx jsx */
|
|
3
4
|
import { jsx } from '@emotion/react';
|
|
@@ -12,6 +13,8 @@ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
|
12
13
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
13
14
|
import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
14
15
|
import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType, splitCell } from '@atlaskit/editor-tables/utils';
|
|
16
|
+
import EditorAlignImageCenter from '@atlaskit/icon/glyph/editor/align-image-center';
|
|
17
|
+
import EditorAlignImageLeft from '@atlaskit/icon/glyph/editor/align-image-left';
|
|
15
18
|
import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
16
19
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
17
20
|
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
@@ -24,6 +27,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
|
|
|
24
27
|
import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
25
28
|
import { canMergeCells } from './transforms';
|
|
26
29
|
import { TableCssClassName } from './types';
|
|
30
|
+
import { FloatingAlignmentButtons } from './ui/FloatingAlignmentButtons/FloatingAlignmentButtons';
|
|
27
31
|
import { DisplayModeIcon } from './ui/icons';
|
|
28
32
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, isTableNested } from './utils';
|
|
29
33
|
export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, editorAnalyticsAPI) {
|
|
@@ -313,6 +317,8 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
313
317
|
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
314
318
|
var nodeType = state.schema.nodes.table;
|
|
315
319
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
320
|
+
var alignmentMenu;
|
|
321
|
+
alignmentMenu = getBooleanFF('platform.editor.table.allow-table-alignment') ? getAlignmentOptionsConfig(pluginState, intl, editorAnalyticsAPI) : [];
|
|
316
322
|
var cellItems;
|
|
317
323
|
cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled);
|
|
318
324
|
var columnSettingsItems;
|
|
@@ -369,11 +375,12 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
369
375
|
},
|
|
370
376
|
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
371
377
|
// Place the context menu slightly above the others
|
|
372
|
-
items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), _toConsumableArray(columnSettingsItems), colorPicker, [{
|
|
378
|
+
items: [menu, separator(menu.hidden)].concat(_toConsumableArray(alignmentMenu), [separator(alignmentMenu.length === 0)], _toConsumableArray(cellItems), _toConsumableArray(columnSettingsItems), colorPicker, [{
|
|
373
379
|
type: 'extensions-placeholder',
|
|
374
380
|
separator: 'end'
|
|
375
381
|
}, {
|
|
376
382
|
type: 'copy-button',
|
|
383
|
+
supportsViewMode: true,
|
|
377
384
|
items: [{
|
|
378
385
|
state: state,
|
|
379
386
|
formatMessage: intl.formatMessage,
|
|
@@ -382,9 +389,9 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
382
389
|
onMouseLeave: clearHoverSelection(),
|
|
383
390
|
onFocus: hoverTable(false, true),
|
|
384
391
|
onBlur: clearHoverSelection()
|
|
385
|
-
}, {
|
|
386
|
-
type: 'separator'
|
|
387
392
|
}]
|
|
393
|
+
}, {
|
|
394
|
+
type: 'separator'
|
|
388
395
|
}, {
|
|
389
396
|
id: 'editor.table.delete',
|
|
390
397
|
type: 'button',
|
|
@@ -574,4 +581,65 @@ var highlightColumnsHandler = function highlightColumnsHandler(state, dispatch)
|
|
|
574
581
|
return true;
|
|
575
582
|
}
|
|
576
583
|
return false;
|
|
584
|
+
};
|
|
585
|
+
export var getAlignmentOptionsConfig = function getAlignmentOptionsConfig(state, _ref6, editorAnalyticsAPI) {
|
|
586
|
+
var formatMessage = _ref6.formatMessage;
|
|
587
|
+
var alignmentIcons = [{
|
|
588
|
+
id: 'editor.table.alignLeft',
|
|
589
|
+
value: 'align-start',
|
|
590
|
+
icon: EditorAlignImageLeft
|
|
591
|
+
}, {
|
|
592
|
+
id: 'editor.table.alignCenter',
|
|
593
|
+
value: 'center',
|
|
594
|
+
icon: EditorAlignImageCenter
|
|
595
|
+
}];
|
|
596
|
+
|
|
597
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
598
|
+
var layoutToMessages = {
|
|
599
|
+
center: messages.alignTableCenter,
|
|
600
|
+
'align-start': messages.alignTableLeft
|
|
601
|
+
};
|
|
602
|
+
var alignmentButtons = alignmentIcons.map(function (alignmentIcon) {
|
|
603
|
+
var id = alignmentIcon.id,
|
|
604
|
+
value = alignmentIcon.value,
|
|
605
|
+
icon = alignmentIcon.icon;
|
|
606
|
+
return {
|
|
607
|
+
id: id,
|
|
608
|
+
type: 'button',
|
|
609
|
+
icon: icon,
|
|
610
|
+
title: formatMessage(layoutToMessages[value]),
|
|
611
|
+
selected: false,
|
|
612
|
+
// TODO - get the correct selected state based on the selected layout attr
|
|
613
|
+
onClick: makeAlignment()
|
|
614
|
+
};
|
|
615
|
+
});
|
|
616
|
+
var alignmentOptions = {
|
|
617
|
+
render: function render(props) {
|
|
618
|
+
return jsx(FloatingAlignmentButtons, _extends({
|
|
619
|
+
alignmentButtons: alignmentButtons
|
|
620
|
+
}, props));
|
|
621
|
+
},
|
|
622
|
+
width: 60,
|
|
623
|
+
height: 32
|
|
624
|
+
};
|
|
625
|
+
var alignmentToolbarItem = [{
|
|
626
|
+
id: 'table-layout',
|
|
627
|
+
testId: 'table-layout-dropdown',
|
|
628
|
+
type: 'dropdown',
|
|
629
|
+
options: alignmentOptions,
|
|
630
|
+
title: formatMessage(messages.tableAlignmentOptions),
|
|
631
|
+
// TODO - get the correct title based on the selected layout attr
|
|
632
|
+
icon: EditorAlignImageCenter // TODO - get the correct icon based on the selected layout attr
|
|
633
|
+
}];
|
|
634
|
+
return alignmentToolbarItem;
|
|
635
|
+
};
|
|
636
|
+
var makeAlignment = function makeAlignment() {
|
|
637
|
+
return function (state, dispatch) {
|
|
638
|
+
var tableObject = findTable(state.selection);
|
|
639
|
+
if (!tableObject || !dispatch) {
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
// TODO Add alignment logic here
|
|
643
|
+
return true;
|
|
644
|
+
};
|
|
577
645
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { ButtonGroup } from '@atlaskit/button';
|
|
4
|
+
import { FloatingToolbarButton as Button, FloatingToolbarSeparator } from '@atlaskit/editor-common/ui';
|
|
5
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
6
|
+
var containerStyles = xcss({
|
|
7
|
+
marginLeft: 'space.100'
|
|
8
|
+
});
|
|
9
|
+
export var FloatingAlignmentButtons = function FloatingAlignmentButtons(_ref) {
|
|
10
|
+
var alignmentButtons = _ref.alignmentButtons,
|
|
11
|
+
dispatchCommand = _ref.dispatchCommand;
|
|
12
|
+
return jsx(Box, {
|
|
13
|
+
xcss: containerStyles
|
|
14
|
+
}, jsx(ButtonGroup, null, alignmentButtons.map(function (item, idx) {
|
|
15
|
+
switch (item.type) {
|
|
16
|
+
case 'separator':
|
|
17
|
+
return jsx(FloatingToolbarSeparator, {
|
|
18
|
+
key: idx
|
|
19
|
+
});
|
|
20
|
+
case 'button':
|
|
21
|
+
var ButtonIcon = item.icon;
|
|
22
|
+
return jsx(Button, {
|
|
23
|
+
key: idx,
|
|
24
|
+
icon: item.icon ? jsx(ButtonIcon, {
|
|
25
|
+
label: item.title
|
|
26
|
+
}) : undefined,
|
|
27
|
+
title: item.title,
|
|
28
|
+
selected: item.selected,
|
|
29
|
+
disabled: item.disabled,
|
|
30
|
+
onClick: function onClick() {
|
|
31
|
+
dispatchCommand(item.onClick);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
})));
|
|
36
|
+
};
|
package/dist/types/toolbar.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export declare const getClosestSelectionOrTableRect: (state: EditorState) => Rec
|
|
|
12
12
|
export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions) => (config: PluginConfig) => FloatingToolbarHandler;
|
|
13
13
|
export declare const getLockBtnConfig: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
14
14
|
export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
|
|
15
|
+
export declare const getAlignmentOptionsConfig: (state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Array<FloatingToolbarDropdown<Command>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import type { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
4
|
+
type Props = {
|
|
5
|
+
alignmentButtons: FloatingToolbarItem<Command>[];
|
|
6
|
+
dispatchCommand: (command: Command) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const FloatingAlignmentButtons: ({ alignmentButtons, dispatchCommand, }: Props) => jsx.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -12,3 +12,4 @@ export declare const getClosestSelectionOrTableRect: (state: EditorState) => Rec
|
|
|
12
12
|
export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions) => (config: PluginConfig) => FloatingToolbarHandler;
|
|
13
13
|
export declare const getLockBtnConfig: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
|
|
14
14
|
export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
|
|
15
|
+
export declare const getAlignmentOptionsConfig: (state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Array<FloatingToolbarDropdown<Command>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import type { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
4
|
+
type Props = {
|
|
5
|
+
alignmentButtons: FloatingToolbarItem<Command>[];
|
|
6
|
+
dispatchCommand: (command: Command) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const FloatingAlignmentButtons: ({ alignmentButtons, dispatchCommand, }: Props) => jsx.JSX.Element;
|
|
9
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.14.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^36.1.0",
|
|
32
|
+
"@atlaskit/button": "^17.14.0",
|
|
32
33
|
"@atlaskit/custom-steps": "^0.1.0",
|
|
33
|
-
"@atlaskit/editor-common": "^79.
|
|
34
|
+
"@atlaskit/editor-common": "^79.5.0",
|
|
34
35
|
"@atlaskit/editor-palette": "1.6.0",
|
|
35
36
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.1.0",
|
|
36
37
|
"@atlaskit/editor-plugin-analytics": "^1.1.0",
|
|
@@ -138,6 +139,9 @@
|
|
|
138
139
|
},
|
|
139
140
|
"platform.editor.table.live-pages-sorting_4malx": {
|
|
140
141
|
"type": "boolean"
|
|
142
|
+
},
|
|
143
|
+
"platform.editor.table.allow-table-alignment": {
|
|
144
|
+
"type": "boolean"
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
}
|
package/src/toolbar.tsx
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
Command,
|
|
19
19
|
CommandDispatch,
|
|
20
20
|
ConfirmDialogOptions,
|
|
21
|
+
DropdownOptions,
|
|
21
22
|
DropdownOptionT,
|
|
22
23
|
FloatingToolbarDropdown,
|
|
23
24
|
FloatingToolbarHandler,
|
|
@@ -49,6 +50,8 @@ import {
|
|
|
49
50
|
isSelectionType,
|
|
50
51
|
splitCell,
|
|
51
52
|
} from '@atlaskit/editor-tables/utils';
|
|
53
|
+
import EditorAlignImageCenter from '@atlaskit/icon/glyph/editor/align-image-center';
|
|
54
|
+
import EditorAlignImageLeft from '@atlaskit/icon/glyph/editor/align-image-left';
|
|
52
55
|
import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
53
56
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
54
57
|
import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
|
|
@@ -93,6 +96,7 @@ import type {
|
|
|
93
96
|
ToolbarMenuState,
|
|
94
97
|
} from './types';
|
|
95
98
|
import { TableCssClassName } from './types';
|
|
99
|
+
import { FloatingAlignmentButtons } from './ui/FloatingAlignmentButtons/FloatingAlignmentButtons';
|
|
96
100
|
import { DisplayModeIcon } from './ui/icons';
|
|
97
101
|
import {
|
|
98
102
|
getMergedCellsPositions,
|
|
@@ -474,6 +478,14 @@ export const getToolbarConfig =
|
|
|
474
478
|
editorAnalyticsAPI,
|
|
475
479
|
);
|
|
476
480
|
|
|
481
|
+
let alignmentMenu: Array<FloatingToolbarItem<Command>>;
|
|
482
|
+
|
|
483
|
+
alignmentMenu = getBooleanFF(
|
|
484
|
+
'platform.editor.table.allow-table-alignment',
|
|
485
|
+
)
|
|
486
|
+
? getAlignmentOptionsConfig(pluginState, intl, editorAnalyticsAPI)
|
|
487
|
+
: [];
|
|
488
|
+
|
|
477
489
|
let cellItems: Array<FloatingToolbarItem<Command>>;
|
|
478
490
|
cellItems = pluginState.isDragAndDropEnabled
|
|
479
491
|
? []
|
|
@@ -568,6 +580,8 @@ export const getToolbarConfig =
|
|
|
568
580
|
items: [
|
|
569
581
|
menu,
|
|
570
582
|
separator(menu.hidden),
|
|
583
|
+
...alignmentMenu,
|
|
584
|
+
separator(alignmentMenu.length === 0),
|
|
571
585
|
...cellItems,
|
|
572
586
|
...columnSettingsItems,
|
|
573
587
|
...colorPicker,
|
|
@@ -577,6 +591,7 @@ export const getToolbarConfig =
|
|
|
577
591
|
},
|
|
578
592
|
{
|
|
579
593
|
type: 'copy-button',
|
|
594
|
+
supportsViewMode: true,
|
|
580
595
|
items: [
|
|
581
596
|
{
|
|
582
597
|
state,
|
|
@@ -587,9 +602,9 @@ export const getToolbarConfig =
|
|
|
587
602
|
onFocus: hoverTable(false, true),
|
|
588
603
|
onBlur: clearHoverSelection(),
|
|
589
604
|
},
|
|
590
|
-
{ type: 'separator' },
|
|
591
605
|
],
|
|
592
606
|
},
|
|
607
|
+
{ type: 'separator' },
|
|
593
608
|
{
|
|
594
609
|
id: 'editor.table.delete',
|
|
595
610
|
type: 'button',
|
|
@@ -870,3 +885,86 @@ const highlightColumnsHandler = (
|
|
|
870
885
|
}
|
|
871
886
|
return false;
|
|
872
887
|
};
|
|
888
|
+
|
|
889
|
+
export const getAlignmentOptionsConfig = (
|
|
890
|
+
state: ToolbarMenuState,
|
|
891
|
+
{ formatMessage }: ToolbarMenuContext,
|
|
892
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
893
|
+
): Array<FloatingToolbarDropdown<Command>> => {
|
|
894
|
+
type AlignmentIcon = {
|
|
895
|
+
id?: string;
|
|
896
|
+
value: string;
|
|
897
|
+
icon: React.ComponentClass<any>;
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
const alignmentIcons: AlignmentIcon[] = [
|
|
901
|
+
{
|
|
902
|
+
id: 'editor.table.alignLeft',
|
|
903
|
+
value: 'align-start',
|
|
904
|
+
icon: EditorAlignImageLeft,
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
id: 'editor.table.alignCenter',
|
|
908
|
+
value: 'center',
|
|
909
|
+
icon: EditorAlignImageCenter,
|
|
910
|
+
},
|
|
911
|
+
];
|
|
912
|
+
|
|
913
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
914
|
+
const layoutToMessages: Record<string, any> = {
|
|
915
|
+
center: messages.alignTableCenter,
|
|
916
|
+
'align-start': messages.alignTableLeft,
|
|
917
|
+
};
|
|
918
|
+
|
|
919
|
+
const alignmentButtons = alignmentIcons.map<FloatingToolbarItem<Command>>(
|
|
920
|
+
(alignmentIcon) => {
|
|
921
|
+
const { id, value, icon } = alignmentIcon;
|
|
922
|
+
return {
|
|
923
|
+
id: id,
|
|
924
|
+
type: 'button',
|
|
925
|
+
icon: icon,
|
|
926
|
+
title: formatMessage(layoutToMessages[value]),
|
|
927
|
+
selected: false, // TODO - get the correct selected state based on the selected layout attr
|
|
928
|
+
onClick: makeAlignment(),
|
|
929
|
+
};
|
|
930
|
+
},
|
|
931
|
+
);
|
|
932
|
+
|
|
933
|
+
const alignmentOptions: DropdownOptions<Command> = {
|
|
934
|
+
render: (props) => {
|
|
935
|
+
return (
|
|
936
|
+
<FloatingAlignmentButtons
|
|
937
|
+
alignmentButtons={alignmentButtons}
|
|
938
|
+
{...props}
|
|
939
|
+
/>
|
|
940
|
+
);
|
|
941
|
+
},
|
|
942
|
+
width: 60,
|
|
943
|
+
height: 32,
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
const alignmentToolbarItem: Array<FloatingToolbarDropdown<Command>> = [
|
|
947
|
+
{
|
|
948
|
+
id: 'table-layout',
|
|
949
|
+
testId: 'table-layout-dropdown',
|
|
950
|
+
type: 'dropdown',
|
|
951
|
+
options: alignmentOptions,
|
|
952
|
+
title: formatMessage(messages.tableAlignmentOptions), // TODO - get the correct title based on the selected layout attr
|
|
953
|
+
icon: EditorAlignImageCenter, // TODO - get the correct icon based on the selected layout attr
|
|
954
|
+
},
|
|
955
|
+
];
|
|
956
|
+
|
|
957
|
+
return alignmentToolbarItem;
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
const makeAlignment = (): Command => {
|
|
961
|
+
return (state, dispatch) => {
|
|
962
|
+
const tableObject = findTable(state.selection);
|
|
963
|
+
|
|
964
|
+
if (!tableObject || !dispatch) {
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
// TODO Add alignment logic here
|
|
968
|
+
return true;
|
|
969
|
+
};
|
|
970
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
|
|
4
|
+
import { ButtonGroup } from '@atlaskit/button';
|
|
5
|
+
import type {
|
|
6
|
+
Command,
|
|
7
|
+
FloatingToolbarItem,
|
|
8
|
+
} from '@atlaskit/editor-common/types';
|
|
9
|
+
import {
|
|
10
|
+
FloatingToolbarButton as Button,
|
|
11
|
+
FloatingToolbarSeparator,
|
|
12
|
+
} from '@atlaskit/editor-common/ui';
|
|
13
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
14
|
+
|
|
15
|
+
const containerStyles = xcss({
|
|
16
|
+
marginLeft: 'space.100',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
alignmentButtons: FloatingToolbarItem<Command>[];
|
|
21
|
+
dispatchCommand: (command: Command) => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const FloatingAlignmentButtons = ({
|
|
25
|
+
alignmentButtons,
|
|
26
|
+
dispatchCommand,
|
|
27
|
+
}: Props) => {
|
|
28
|
+
return (
|
|
29
|
+
<Box xcss={containerStyles}>
|
|
30
|
+
<ButtonGroup>
|
|
31
|
+
{alignmentButtons.map((item, idx) => {
|
|
32
|
+
switch (item.type) {
|
|
33
|
+
case 'separator':
|
|
34
|
+
return <FloatingToolbarSeparator key={idx} />;
|
|
35
|
+
case 'button':
|
|
36
|
+
const ButtonIcon = item.icon as React.ComponentClass<any>;
|
|
37
|
+
return (
|
|
38
|
+
<Button
|
|
39
|
+
key={idx}
|
|
40
|
+
icon={
|
|
41
|
+
item.icon ? <ButtonIcon label={item.title} /> : undefined
|
|
42
|
+
}
|
|
43
|
+
title={item.title}
|
|
44
|
+
selected={item.selected}
|
|
45
|
+
disabled={item.disabled}
|
|
46
|
+
onClick={() => {
|
|
47
|
+
dispatchCommand(item.onClick);
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
})}
|
|
53
|
+
</ButtonGroup>
|
|
54
|
+
</Box>
|
|
55
|
+
);
|
|
56
|
+
};
|