@atlaskit/editor-plugin-table 0.2.2 → 0.2.4
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 +26 -0
- package/dist/cjs/plugins/table/commands/hover.js +2 -1
- package/dist/cjs/plugins/table/event-handlers.js +9 -13
- package/dist/cjs/plugins/table/index.js +3 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +15 -5
- package/dist/cjs/plugins/table/pm-plugins/default-table-selection.js +1 -2
- package/dist/cjs/plugins/table/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +42 -8
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +1 -1
- package/dist/cjs/plugins/table/toolbar.js +42 -10
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +7 -1
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/styles.js +34 -6
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +4 -4
- package/dist/cjs/plugins/table/ui/ui-styles.js +5 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/hover.js +2 -1
- package/dist/es2019/plugins/table/event-handlers.js +10 -13
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +12 -1
- package/dist/es2019/plugins/table/pm-plugins/default-table-selection.js +1 -2
- package/dist/es2019/plugins/table/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +31 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +1 -1
- package/dist/es2019/plugins/table/toolbar.js +43 -12
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +6 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/styles.js +47 -8
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/es2019/plugins/table/ui/common-styles.js +9 -9
- package/dist/es2019/plugins/table/ui/consts.js +5 -5
- package/dist/es2019/plugins/table/ui/ui-styles.js +5 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/hover.js +2 -1
- package/dist/esm/plugins/table/event-handlers.js +10 -14
- package/dist/esm/plugins/table/index.js +3 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +17 -6
- package/dist/esm/plugins/table/pm-plugins/default-table-selection.js +1 -2
- package/dist/esm/plugins/table/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +43 -8
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +1 -1
- package/dist/esm/plugins/table/toolbar.js +43 -12
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +8 -2
- package/dist/esm/plugins/table/ui/FloatingContextualButton/styles.js +28 -5
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -1
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- package/dist/esm/plugins/table/ui/consts.js +5 -5
- package/dist/esm/plugins/table/ui/ui-styles.js +5 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/event-handlers.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/default-table-selection.d.ts +0 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +8 -0
- package/dist/types/plugins/table/toolbar.d.ts +3 -2
- package/dist/types/plugins/table/ui/FloatingContextualButton/styles.d.ts +3 -1
- package/dist/types/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -2
- package/dist/types/plugins/table/ui/common-styles.d.ts +3 -3
- package/dist/types/plugins/table/ui/consts.d.ts +2 -2
- package/dist/types/plugins/table/ui/ui-styles.d.ts +14 -14
- package/package.json +4 -4
- package/src/__tests__/integration/__snapshots__/floating-toolbar.ts.snap +321 -0
- package/src/__tests__/integration/delete-last-column-in-full-width.ts +6 -5
- package/src/__tests__/integration/floating-toolbar.ts +169 -0
- package/src/__tests__/unit/get-toolbar-config.ts +1 -0
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +146 -4
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +82 -31
- package/src/__tests__/unit/toolbar.ts +165 -4
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +2 -2
- package/src/plugins/table/commands/hover.ts +1 -0
- package/src/plugins/table/event-handlers.ts +6 -17
- package/src/plugins/table/index.tsx +1 -0
- package/src/plugins/table/nodeviews/TableComponent.tsx +10 -2
- package/src/plugins/table/nodeviews/tableCell.tsx +1 -1
- package/src/plugins/table/pm-plugins/default-table-selection.ts +0 -1
- package/src/plugins/table/pm-plugins/main.ts +26 -28
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +44 -9
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +1 -1
- package/src/plugins/table/toolbar.tsx +60 -13
- package/src/plugins/table/ui/FloatingContextualButton/index.tsx +12 -2
- package/src/plugins/table/ui/FloatingContextualButton/styles.ts +51 -7
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +3 -0
- package/src/plugins/table/ui/common-styles.ts +24 -9
- package/src/plugins/table/ui/consts.ts +7 -5
- package/src/plugins/table/ui/ui-styles.ts +20 -5
|
@@ -23,13 +23,13 @@ var _components = require("@atlaskit/theme/components");
|
|
|
23
23
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4135
|
|
24
24
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
25
25
|
var tableCellBackgroundColor = (0, _components.themed)({
|
|
26
|
-
light: _colors.N0,
|
|
27
|
-
dark: _colors.DN30
|
|
26
|
+
light: (0, _tokens.token)('elevation.surface', _colors.N0),
|
|
27
|
+
dark: (0, _tokens.token)('elevation.surface', _colors.DN30)
|
|
28
28
|
});
|
|
29
29
|
exports.tableCellBackgroundColor = tableCellBackgroundColor;
|
|
30
30
|
var tableToolbarColor = (0, _components.themed)({
|
|
31
|
-
light: _editorSharedStyles.akEditorTableToolbar,
|
|
32
|
-
dark: _editorSharedStyles.akEditorTableToolbarDark
|
|
31
|
+
light: (0, _tokens.token)('color.background.neutral.subtle', _editorSharedStyles.akEditorTableToolbar),
|
|
32
|
+
dark: (0, _tokens.token)('color.background.neutral.subtle', _editorSharedStyles.akEditorTableToolbarDark)
|
|
33
33
|
});
|
|
34
34
|
exports.tableToolbarColor = tableToolbarColor;
|
|
35
35
|
var tableTextColor = (0, _components.themed)({
|
|
@@ -46,19 +46,19 @@ var Button = function Button(cssString) {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
var HeaderButton = function HeaderButton(props, cssString) {
|
|
49
|
-
return (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n background: ", ";\n border: 1px solid ", ";\n display: block;\n box-sizing: border-box;\n padding: 0;\n\n :focus {\n outline: none;\n }\n ", "\n }\n\n .", "::after {\n content: ' ';\n background-color: transparent;\n left: -15px;\n top: 0;\n position: absolute;\n width: 15px;\n height: 100%;\n z-index: 1;\n }\n\n .active .", " {\n color: ", ";\n background-color: ", ";\n border-color: ", ";\n }\n"])), _types.TableCssClassName.CONTROLS_BUTTON, (0, _consts.tableToolbarColor)(props), (0, _consts.tableBorderColor)(props), cssString, _types.TableCssClassName.ROW_CONTROLS_BUTTON, _types.TableCssClassName.CONTROLS_BUTTON, (0, _tokens.token)('color.icon.inverse', _colors.N0), _consts.tableToolbarSelectedColor, _consts.tableBorderSelectedColor);
|
|
49
|
+
return (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n background: ", ";\n border: 1px solid ", ";\n display: block;\n box-sizing: border-box;\n padding: 0;\n\n :focus {\n outline: none;\n }\n ", "\n }\n\n .", "::after {\n content: ' ';\n background-color: transparent;\n left: -15px;\n top: 0;\n position: absolute;\n width: 15px;\n height: 100%;\n z-index: 1;\n }\n\n .active .", " {\n color: ", ";\n background-color: ", ";\n border-color: ", ";\n }\n"])), _types.TableCssClassName.CONTROLS_BUTTON, (0, _consts.tableToolbarColor)(props), (0, _consts.tableBorderColor)(props), cssString, _types.TableCssClassName.ROW_CONTROLS_BUTTON, _types.TableCssClassName.CONTROLS_BUTTON, (0, _tokens.token)('color.icon.inverse', _colors.N0), (0, _tokens.token)('color.background.selected', _consts.tableToolbarSelectedColor), _consts.tableBorderSelectedColor);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
exports.HeaderButton = HeaderButton;
|
|
53
53
|
|
|
54
54
|
var HeaderButtonHover = function HeaderButtonHover() {
|
|
55
|
-
return (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n .", ":hover {\n color: ", ";\n background-color: ", ";\n border-color: ", ";\n cursor: pointer;\n }\n"])), _types.TableCssClassName.CONTROLS_BUTTON, (0, _tokens.token)('color.icon.inverse', _colors.N0), _consts.tableToolbarSelectedColor, _consts.tableBorderSelectedColor);
|
|
55
|
+
return (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n .", ":hover {\n color: ", ";\n background-color: ", ";\n border-color: ", ";\n cursor: pointer;\n }\n"])), _types.TableCssClassName.CONTROLS_BUTTON, (0, _tokens.token)('color.icon.inverse', _colors.N0), (0, _tokens.token)('color.background.selected', _consts.tableToolbarSelectedColor), _consts.tableBorderSelectedColor);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
exports.HeaderButtonHover = HeaderButtonHover;
|
|
59
59
|
|
|
60
60
|
var HeaderButtonDanger = function HeaderButtonDanger() {
|
|
61
|
-
return (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n .", " .", " {\n background-color: ", ";\n border-color: ", ";\n position: relative;\n z-index: ", ";\n }\n"])), _types.TableCssClassName.HOVERED_CELL_IN_DANGER, _types.TableCssClassName.CONTROLS_BUTTON, _consts.tableToolbarDeleteColor, _consts.tableBorderDeleteColor, _editorSharedStyles.akEditorUnitZIndex);
|
|
61
|
+
return (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n .", " .", " {\n background-color: ", ";\n border-color: ", ";\n position: relative;\n z-index: ", ";\n }\n"])), _types.TableCssClassName.HOVERED_CELL_IN_DANGER, _types.TableCssClassName.CONTROLS_BUTTON, (0, _tokens.token)('color.background.danger', _consts.tableToolbarDeleteColor), _consts.tableBorderDeleteColor, _editorSharedStyles.akEditorUnitZIndex);
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
exports.HeaderButtonDanger = HeaderButtonDanger;
|
|
@@ -99,10 +99,10 @@ var columnHeaderButton = function columnHeaderButton(props, cssString) {
|
|
|
99
99
|
return (0, _react.css)(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2.default)(["\n background: ", ";\n border: 1px solid ", ";\n display: block;\n box-sizing: border-box;\n padding: 0;\n\n :focus {\n outline: none;\n }\n\n ", "\n"])), (0, _consts.tableToolbarColor)(props), (0, _consts.tableBorderColor)(props), cssString);
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
var columnHeaderButtonSelected = (0, _react.css)(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n background-color: ", ";\n border-color: ", ";\n z-index: ", ";\n"])), (0, _tokens.token)('color.text.inverse', _colors.N0), _consts.tableToolbarSelectedColor, _consts.tableBorderSelectedColor, _consts.columnControlsSelectedZIndex);
|
|
102
|
+
var columnHeaderButtonSelected = (0, _react.css)(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n background-color: ", ";\n border-color: ", ";\n z-index: ", ";\n"])), (0, _tokens.token)('color.text.inverse', _colors.N0), (0, _tokens.token)('color.background.selected', _consts.tableToolbarSelectedColor), _consts.tableBorderSelectedColor, _consts.columnControlsSelectedZIndex);
|
|
103
103
|
|
|
104
104
|
var columnControlsDecoration = function columnControlsDecoration(props) {
|
|
105
|
-
return (0, _react.css)(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n display: none;\n cursor: pointer;\n position: absolute;\n width: calc(100% + ", "px);\n left: -1px;\n top: -", "px;\n height: ", "px;\n\n &::before {\n content: ' ';\n background-color: ", ";\n position: absolute;\n height: ", "px;\n width: ", "px;\n border-radius: 50%;\n pointer-events: none;\n top: 2px;\n right: -1px;\n }\n\n &::after {\n content: ' ';\n\n ", "\n }\n }\n\n div.", ">.", "::after {\n content: ' ';\n background-color: ", ";\n position: absolute;\n height: ", "px;\n width: ", "px;\n border-radius: 50%;\n pointer-events: none;\n top: -", "px;\n right: -1px;\n }\n\n .", " .", " {\n display: block;\n }\n\n table\n tr:first-of-type\n td.", ",\n table\n tr:first-of-type\n th.", " {\n &.", ",\n &.", ",\n &.", " {\n .", "::after {\n ", ";\n }\n\n &.", "\n .", "::after {\n background-color: ", ";\n border: 1px solid ", ";\n border-bottom: none;\n z-index: ", ";\n }\n }\n }\n\n .", "\n table\n tr:first-of-type\n td.", ",\n .", "\n table\n tr:first-of-type\n th.", " {\n .", "::after {\n ", ";\n }\n }\n"])), _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, _styles.tableCellBorderWidth * 2, _consts.columnControlsDecorationHeight + _styles.tableCellBorderWidth, _consts.columnControlsDecorationHeight, (0, _consts.tableBorderColor)(props), _consts.lineMarkerSize, _consts.lineMarkerSize, columnHeaderButton(props, "\n border-right: ".concat(_styles.tableCellBorderWidth, "px solid ").concat((0, _consts.tableBorderColor)(props), ";\n border-bottom: none;\n height: ").concat(_consts.tableToolbarSize, "px;\n width: 100%;\n position: absolute;\n top: ").concat(_consts.columnControlsDecorationHeight - _consts.tableToolbarSize, "px;\n left: 0px;\n z-index: ").concat(_consts.columnControlsZIndex, ";\n ")), _types.TableCssClassName.WITH_CONTROLS, _types.TableCssClassName.ROW_CONTROLS_WRAPPER, (0, _consts.tableBorderColor)(props), _consts.lineMarkerSize, _consts.lineMarkerSize, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _types.TableCssClassName.WITH_CONTROLS, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, _types.TableCssClassName.TABLE_CELL, _types.TableCssClassName.TABLE_HEADER_CELL, _types.TableCssClassName.COLUMN_SELECTED, _types.TableCssClassName.HOVERED_COLUMN, _types.TableCssClassName.HOVERED_TABLE, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, columnHeaderButtonSelected, _types.TableCssClassName.HOVERED_CELL_IN_DANGER, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, _consts.tableToolbarDeleteColor, _consts.tableBorderDeleteColor, _editorSharedStyles.akEditorUnitZIndex * 100, _types.TableCssClassName.TABLE_SELECTED, _types.TableCssClassName.TABLE_CELL, _types.TableCssClassName.TABLE_SELECTED, _types.TableCssClassName.TABLE_HEADER_CELL, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, columnHeaderButtonSelected);
|
|
105
|
+
return (0, _react.css)(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n display: none;\n cursor: pointer;\n position: absolute;\n width: calc(100% + ", "px);\n left: -1px;\n top: -", "px;\n height: ", "px;\n\n &::before {\n content: ' ';\n background-color: ", ";\n position: absolute;\n height: ", "px;\n width: ", "px;\n border-radius: 50%;\n pointer-events: none;\n top: 2px;\n right: -1px;\n }\n\n &::after {\n content: ' ';\n\n ", "\n }\n }\n\n div.", ">.", "::after {\n content: ' ';\n background-color: ", ";\n position: absolute;\n height: ", "px;\n width: ", "px;\n border-radius: 50%;\n pointer-events: none;\n top: -", "px;\n right: -1px;\n }\n\n .", " .", " {\n display: block;\n }\n\n table\n tr:first-of-type\n td.", ",\n table\n tr:first-of-type\n th.", " {\n &.", ",\n &.", ",\n &.", " {\n .", "::after {\n ", ";\n }\n\n &.", "\n .", "::after {\n background-color: ", ";\n border: 1px solid ", ";\n border-bottom: none;\n z-index: ", ";\n }\n }\n }\n\n .", "\n table\n tr:first-of-type\n td.", ",\n .", "\n table\n tr:first-of-type\n th.", " {\n .", "::after {\n ", ";\n }\n }\n"])), _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, _styles.tableCellBorderWidth * 2, _consts.columnControlsDecorationHeight + _styles.tableCellBorderWidth, _consts.columnControlsDecorationHeight, (0, _consts.tableBorderColor)(props), _consts.lineMarkerSize, _consts.lineMarkerSize, columnHeaderButton(props, "\n border-right: ".concat(_styles.tableCellBorderWidth, "px solid ").concat((0, _consts.tableBorderColor)(props), ";\n border-bottom: none;\n height: ").concat(_consts.tableToolbarSize, "px;\n width: 100%;\n position: absolute;\n top: ").concat(_consts.columnControlsDecorationHeight - _consts.tableToolbarSize, "px;\n left: 0px;\n z-index: ").concat(_consts.columnControlsZIndex, ";\n ")), _types.TableCssClassName.WITH_CONTROLS, _types.TableCssClassName.ROW_CONTROLS_WRAPPER, (0, _consts.tableBorderColor)(props), _consts.lineMarkerSize, _consts.lineMarkerSize, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _types.TableCssClassName.WITH_CONTROLS, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, _types.TableCssClassName.TABLE_CELL, _types.TableCssClassName.TABLE_HEADER_CELL, _types.TableCssClassName.COLUMN_SELECTED, _types.TableCssClassName.HOVERED_COLUMN, _types.TableCssClassName.HOVERED_TABLE, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, columnHeaderButtonSelected, _types.TableCssClassName.HOVERED_CELL_IN_DANGER, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, (0, _tokens.token)('color.background.danger', _consts.tableToolbarDeleteColor), _consts.tableBorderDeleteColor, _editorSharedStyles.akEditorUnitZIndex * 100, _types.TableCssClassName.TABLE_SELECTED, _types.TableCssClassName.TABLE_CELL, _types.TableCssClassName.TABLE_SELECTED, _types.TableCssClassName.TABLE_HEADER_CELL, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, columnHeaderButtonSelected);
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
exports.columnControlsDecoration = columnControlsDecoration;
|
package/dist/cjs/version.json
CHANGED
|
@@ -100,7 +100,8 @@ export const hoverTable = (isInDanger, isSelected) => createCommand(state => {
|
|
|
100
100
|
export const clearHoverSelection = () => createCommand(state => ({
|
|
101
101
|
type: 'CLEAR_HOVER_SELECTION',
|
|
102
102
|
data: {
|
|
103
|
-
decorationSet: updatePluginStateDecorations(state, [], TableDecorations.ALL_CONTROLS_HOVER)
|
|
103
|
+
decorationSet: updatePluginStateDecorations(state, [], TableDecorations.ALL_CONTROLS_HOVER),
|
|
104
|
+
isInDanger: false
|
|
104
105
|
}
|
|
105
106
|
}));
|
|
106
107
|
export const showResizeHandleLine = cellColumnPositioning => createCommand(state => ({
|
|
@@ -11,7 +11,7 @@ import { getPluginState } from './pm-plugins/plugin-factory';
|
|
|
11
11
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
12
12
|
import { deleteColumns, deleteRows } from './transforms';
|
|
13
13
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
14
|
-
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, isCell, isColumnControlsDecorations, isCornerButton, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableControlsButton, isTableContainerOrWrapper } from './utils';
|
|
14
|
+
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, isCell, isColumnControlsDecorations, isCornerButton, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableControlsButton, isTableContainerOrWrapper, hasResizeHandler } from './utils';
|
|
15
15
|
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
16
16
|
|
|
17
17
|
const isFocusingCalendar = event => event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
@@ -209,7 +209,7 @@ export const handleMouseLeave = (view, event) => {
|
|
|
209
209
|
|
|
210
210
|
return false;
|
|
211
211
|
};
|
|
212
|
-
export const handleMouseMove = getEditorFeatureFlags => (view, event,
|
|
212
|
+
export const handleMouseMove = getEditorFeatureFlags => (view, event, elementContentRects) => {
|
|
213
213
|
if (!(event.target instanceof HTMLElement)) {
|
|
214
214
|
return false;
|
|
215
215
|
}
|
|
@@ -225,7 +225,7 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, tableCellO
|
|
|
225
225
|
insertColumnButtonIndex
|
|
226
226
|
} = getPluginState(state);
|
|
227
227
|
const [startIndex, endIndex] = getColumnOrRowIndex(element);
|
|
228
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(event,
|
|
228
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(event, false, elementContentRects) === 'right' ? endIndex : startIndex;
|
|
229
229
|
|
|
230
230
|
if (positionColumn !== insertColumnButtonIndex) {
|
|
231
231
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
@@ -250,13 +250,10 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, tableCellO
|
|
|
250
250
|
|
|
251
251
|
const {
|
|
252
252
|
mouseMoveOptimization
|
|
253
|
-
} = getEditorFeatureFlags();
|
|
254
|
-
// because it relies on tableCell node view that is added via tableCellOptimization
|
|
255
|
-
|
|
256
|
-
const useMouseMoveOptimisation = tableCellOptimization && mouseMoveOptimization;
|
|
253
|
+
} = getEditorFeatureFlags();
|
|
257
254
|
|
|
258
255
|
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
259
|
-
const positionColumn = getMousePositionHorizontalRelativeByElement(event,
|
|
256
|
+
const positionColumn = getMousePositionHorizontalRelativeByElement(event, mouseMoveOptimization, elementContentRects, RESIZE_HANDLE_AREA_DECORATION_GAP);
|
|
260
257
|
|
|
261
258
|
if (positionColumn !== null) {
|
|
262
259
|
const {
|
|
@@ -275,7 +272,10 @@ export const handleMouseMove = getEditorFeatureFlags => (view, event, tableCellO
|
|
|
275
272
|
const columnEndIndexTarget = positionColumn === 'left' ? rect.left : rect.right;
|
|
276
273
|
const rowIndexTarget = rect.top;
|
|
277
274
|
|
|
278
|
-
if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex
|
|
275
|
+
if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
|
|
276
|
+
target: element,
|
|
277
|
+
columnEndIndexTarget
|
|
278
|
+
})) {
|
|
279
279
|
return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget)(state, dispatch);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
@@ -370,17 +370,14 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI) => {
|
|
|
370
370
|
return tr;
|
|
371
371
|
};
|
|
372
372
|
export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mouseEvent) => {
|
|
373
|
-
var _tablePluginState$plu;
|
|
374
|
-
|
|
375
373
|
const tableResizePluginState = getResizePluginState(view.state);
|
|
376
374
|
const tablePluginState = getPluginState(view.state);
|
|
377
375
|
const isDragging = tableResizePluginState && !!tableResizePluginState.dragging;
|
|
378
376
|
const hasTableNode = tablePluginState && tablePluginState.tableNode;
|
|
379
|
-
const tableCellOptimization = tablePluginState === null || tablePluginState === void 0 ? void 0 : (_tablePluginState$plu = tablePluginState.pluginConfig) === null || _tablePluginState$plu === void 0 ? void 0 : _tablePluginState$plu.tableCellOptimization;
|
|
380
377
|
|
|
381
378
|
if (!hasTableNode || isDragging) {
|
|
382
379
|
return false;
|
|
383
380
|
}
|
|
384
381
|
|
|
385
|
-
return eventHandler(view, mouseEvent,
|
|
382
|
+
return eventHandler(view, mouseEvent, elementContentRects);
|
|
386
383
|
};
|
|
@@ -349,7 +349,7 @@ const tablesPlugin = options => {
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
}],
|
|
352
|
-
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
352
|
+
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
355
|
};
|
|
@@ -3,12 +3,13 @@ import React from 'react';
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import rafSchedule from 'raf-schd';
|
|
6
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
6
7
|
import { calcTableWidth, tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
7
8
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
8
9
|
import { akEditorMobileBreakoutPoint, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
9
10
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
10
11
|
import { parsePx } from '@atlaskit/editor-common/utils';
|
|
11
|
-
import { autoSizeTable } from '../commands';
|
|
12
|
+
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
12
13
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
13
14
|
import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
|
|
14
15
|
import { scaleTable } from '../pm-plugins/table-resizing';
|
|
@@ -392,10 +393,20 @@ class TableComponent extends React.Component {
|
|
|
392
393
|
|
|
393
394
|
componentDidUpdate(prevProps) {
|
|
394
395
|
const {
|
|
396
|
+
view,
|
|
395
397
|
getNode,
|
|
396
398
|
isMediaFullscreen,
|
|
397
399
|
allowColumnResizing
|
|
398
400
|
} = this.props;
|
|
401
|
+
const {
|
|
402
|
+
isInDanger
|
|
403
|
+
} = getPluginState(view.state);
|
|
404
|
+
const table = findTable(view.state.selection);
|
|
405
|
+
|
|
406
|
+
if (isInDanger && !table) {
|
|
407
|
+
clearHoverSelection()(view.state, view.dispatch);
|
|
408
|
+
}
|
|
409
|
+
|
|
399
410
|
const {
|
|
400
411
|
tableOverflowShadowsOptimization
|
|
401
412
|
} = this.props.getEditorFeatureFlags();
|
|
@@ -49,10 +49,10 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
49
49
|
elementContentRects[entry.target.id] = entry.contentRect;
|
|
50
50
|
});
|
|
51
51
|
}) : undefined;
|
|
52
|
-
const tableCellNodeview =
|
|
52
|
+
const tableCellNodeview = {
|
|
53
53
|
tableCell: (node, view, getPos) => new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer),
|
|
54
54
|
tableHeader: (node, view, getPos) => new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer)
|
|
55
|
-
}
|
|
55
|
+
}; // Used to prevent invalid table cell spans being reported more than once per editor/document
|
|
56
56
|
|
|
57
57
|
const invalidTableIds = [];
|
|
58
58
|
let editorViewRef = null;
|
|
@@ -11,12 +11,35 @@ import debounce from 'lodash/debounce';
|
|
|
11
11
|
import throttle from 'lodash/throttle'; // limit scroll event calls
|
|
12
12
|
|
|
13
13
|
const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200; // timeout for resetting the scroll class - if it’s too long then users won’t be able to click on the header cells,
|
|
14
|
-
// if too short it would trigger too many dom
|
|
14
|
+
// if too short it would trigger too many dom updates.
|
|
15
15
|
|
|
16
16
|
const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
17
|
+
|
|
18
|
+
const anyChildCellMergedAcrossRow = node => mapChildren(node, child => child.attrs.rowspan || 0).some(rowspan => rowspan > 1);
|
|
19
|
+
/**
|
|
20
|
+
* Compare two table row nodes and return true if the two table rows have a
|
|
21
|
+
* different number of table cells or if table cell row spans are different
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const rowHasDifferentMergedCells = (prevNode, incomingNode) => {
|
|
26
|
+
const incomingNodeChildrenRowSpan = mapChildren(prevNode, child => child.attrs.rowspan || 0);
|
|
27
|
+
const currentNodeChildrenRowSpan = mapChildren(incomingNode, child => child.attrs.rowspan || 0);
|
|
28
|
+
return incomingNodeChildrenRowSpan.length !== currentNodeChildrenRowSpan.length || currentNodeChildrenRowSpan.some((child, index) => child !== incomingNodeChildrenRowSpan[index]);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Check if a given node is a header row with this definition:
|
|
32
|
+
* - all children are tableHeader cells
|
|
33
|
+
* - no table cells have been have merged with other table row cells
|
|
34
|
+
*
|
|
35
|
+
* @param node ProseMirror node
|
|
36
|
+
* @return boolean if it meets definition
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
17
40
|
export const supportedHeaderRow = node => {
|
|
18
41
|
const allHeaders = mapChildren(node, child => child.type.name === 'tableHeader').every(Boolean);
|
|
19
|
-
const someMerged =
|
|
42
|
+
const someMerged = anyChildCellMergedAcrossRow(node);
|
|
20
43
|
return allHeaders && !someMerged;
|
|
21
44
|
};
|
|
22
45
|
export class TableRowNodeView {
|
|
@@ -484,10 +507,14 @@ export class TableRowNodeView {
|
|
|
484
507
|
// changing away from one
|
|
485
508
|
|
|
486
509
|
|
|
487
|
-
const
|
|
510
|
+
const newNodeIsHeaderRow = supportedHeaderRow(node);
|
|
488
511
|
|
|
489
|
-
if (this.isHeaderRow !==
|
|
512
|
+
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
490
513
|
return false; // re-create nodeview
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
if (rowHasDifferentMergedCells(this.node, node)) {
|
|
517
|
+
return false;
|
|
491
518
|
} // node is different but no need to re-create nodeview
|
|
492
519
|
|
|
493
520
|
|
|
@@ -22,7 +22,7 @@ export const growColumn = (state, colIndex, amount, selectedColumns) => {
|
|
|
22
22
|
};
|
|
23
23
|
export const shrinkColumn = (state, colIndex, amount, selectedColumns) => {
|
|
24
24
|
// can't shrink if columns don't exist
|
|
25
|
-
if (!state.cols[colIndex]
|
|
25
|
+
if (!state.cols[colIndex]) {
|
|
26
26
|
return state;
|
|
27
27
|
} // try to shrink dragging column by giving from the column to the right first
|
|
28
28
|
|
|
@@ -3,12 +3,12 @@ import { jsx } from '@emotion/react';
|
|
|
3
3
|
import { defineMessages } from 'react-intl-next';
|
|
4
4
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
5
5
|
import commonMessages from '@atlaskit/editor-common/messages';
|
|
6
|
-
import { clearHoverSelection, hoverTable } from './commands';
|
|
6
|
+
import { clearHoverSelection, hoverTable, hoverColumns, hoverRows } from './commands';
|
|
7
7
|
import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics, sortColumnWithAnalytics, setColorWithAnalytics, distributeColumnsWidthsWithAnalytics } from './commands-with-analytics';
|
|
8
8
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
9
9
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
10
10
|
import { TableCssClassName } from './types';
|
|
11
|
-
import { getMergedCellsPositions } from './utils';
|
|
11
|
+
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
|
|
12
12
|
import { isReferencedSource } from './utils/referentiality';
|
|
13
13
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
14
14
|
import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
@@ -23,6 +23,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
|
|
|
23
23
|
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
24
24
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
25
25
|
import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
26
|
+
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
26
27
|
export const messages = defineMessages({
|
|
27
28
|
tableOptions: {
|
|
28
29
|
id: 'fabric.editor.tableOptions',
|
|
@@ -90,7 +91,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
90
91
|
// relay it to the native mobile. Native mobile displays the menu
|
|
91
92
|
// with native widgets. It's enabled via a plugin config.
|
|
92
93
|
|
|
93
|
-
export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
94
|
+
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
94
95
|
formatMessage
|
|
95
96
|
}, getEditorContainerWidth, editorAnalyticsAPI) => {
|
|
96
97
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
@@ -157,6 +158,17 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
157
158
|
|
|
158
159
|
return true;
|
|
159
160
|
},
|
|
161
|
+
onMouseOver: (state, dispatch) => {
|
|
162
|
+
const selectionRect = getClosestSelectionRect(state);
|
|
163
|
+
|
|
164
|
+
if (selectionRect) {
|
|
165
|
+
hoverColumns(getSelectedColumnIndexes(selectionRect), true)(state, dispatch);
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return false;
|
|
170
|
+
},
|
|
171
|
+
onMouseLeave: clearHoverSelection(),
|
|
160
172
|
selected: false,
|
|
161
173
|
disabled: false
|
|
162
174
|
}, {
|
|
@@ -173,6 +185,17 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
173
185
|
|
|
174
186
|
return true;
|
|
175
187
|
},
|
|
188
|
+
onMouseOver: (state, dispatch) => {
|
|
189
|
+
const selectionRect = getClosestSelectionRect(state);
|
|
190
|
+
|
|
191
|
+
if (selectionRect) {
|
|
192
|
+
hoverRows(getSelectedRowIndexes(selectionRect), true)(state, dispatch);
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return false;
|
|
197
|
+
},
|
|
198
|
+
onMouseLeave: clearHoverSelection(),
|
|
176
199
|
selected: false,
|
|
177
200
|
disabled: false
|
|
178
201
|
}, {
|
|
@@ -190,9 +213,12 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
190
213
|
}];
|
|
191
214
|
|
|
192
215
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
193
|
-
|
|
194
|
-
|
|
216
|
+
var _newResizeStateWithAn;
|
|
217
|
+
|
|
218
|
+
const newResizeStateWithAnalytics = editorView ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth) : undefined;
|
|
219
|
+
const wouldChange = (_newResizeStateWithAn = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn !== void 0 ? _newResizeStateWithAn : false;
|
|
195
220
|
|
|
221
|
+
const distributeColumnWidths = (state, dispatch) => {
|
|
196
222
|
if (newResizeStateWithAnalytics) {
|
|
197
223
|
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
198
224
|
return true;
|
|
@@ -206,12 +232,13 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
206
232
|
title: formatMessage(ContextualMenuMessages.distributeColumns),
|
|
207
233
|
onClick: distributeColumnWidths,
|
|
208
234
|
selected: false,
|
|
209
|
-
disabled:
|
|
235
|
+
disabled: !wouldChange
|
|
210
236
|
});
|
|
211
237
|
}
|
|
212
238
|
|
|
213
239
|
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo2 = pluginState.pluginConfig) !== null && _pluginState$pluginCo2 !== void 0 && _pluginState$pluginCo2.allowColumnSorting) {
|
|
214
240
|
const hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
|
|
241
|
+
const warning = hasMergedCellsInTable ? formatMessage(ContextualMenuMessages.canNotSortTable) : undefined;
|
|
215
242
|
options.push({
|
|
216
243
|
id: 'editor.table.sortColumnAsc',
|
|
217
244
|
title: formatMessage(ContextualMenuMessages.sortColumnASC),
|
|
@@ -220,7 +247,8 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
220
247
|
return true;
|
|
221
248
|
},
|
|
222
249
|
selected: false,
|
|
223
|
-
disabled: hasMergedCellsInTable
|
|
250
|
+
disabled: hasMergedCellsInTable,
|
|
251
|
+
tooltip: warning
|
|
224
252
|
});
|
|
225
253
|
options.push({
|
|
226
254
|
id: 'editor.table.sortColumnDesc',
|
|
@@ -230,7 +258,8 @@ export const getToolbarCellOptionsConfig = (editorState, initialSelectionRect, {
|
|
|
230
258
|
return true;
|
|
231
259
|
},
|
|
232
260
|
selected: false,
|
|
233
|
-
disabled: hasMergedCellsInTable
|
|
261
|
+
disabled: hasMergedCellsInTable,
|
|
262
|
+
tooltip: warning
|
|
234
263
|
});
|
|
235
264
|
}
|
|
236
265
|
|
|
@@ -268,7 +297,7 @@ const getClosestSelectionRect = state => {
|
|
|
268
297
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
269
298
|
};
|
|
270
299
|
|
|
271
|
-
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags) => config => (state, intl) => {
|
|
300
|
+
export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) => config => (state, intl) => {
|
|
272
301
|
const tableObject = findTable(state.selection);
|
|
273
302
|
const pluginState = getPluginState(state);
|
|
274
303
|
const resizeState = tableResizingPluginKey.getState(state);
|
|
@@ -279,7 +308,7 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
279
308
|
const {
|
|
280
309
|
tableCellOptionsInFloatingToolbar
|
|
281
310
|
} = getEditorFeatureFlags() || {};
|
|
282
|
-
const cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
311
|
+
const cellItems = getCellItems(config, state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
283
312
|
const colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar); // Check if we need to show confirm dialog for delete button
|
|
284
313
|
|
|
285
314
|
let confirmDialog;
|
|
@@ -313,6 +342,8 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
313
342
|
getDomRef,
|
|
314
343
|
nodeType,
|
|
315
344
|
offset: [0, 3],
|
|
345
|
+
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
346
|
+
// Place the context menu slightly above the others
|
|
316
347
|
items: [menu, separator(menu.hidden), ...cellItems, ...colorPicker, {
|
|
317
348
|
type: 'extensions-placeholder',
|
|
318
349
|
separator: 'end'
|
|
@@ -353,14 +384,14 @@ const separator = hidden => {
|
|
|
353
384
|
};
|
|
354
385
|
};
|
|
355
386
|
|
|
356
|
-
const getCellItems = (pluginConfig, state, {
|
|
387
|
+
const getCellItems = (pluginConfig, state, view, {
|
|
357
388
|
formatMessage
|
|
358
389
|
}, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) => {
|
|
359
390
|
if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
|
|
360
391
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
361
392
|
|
|
362
393
|
if (initialSelectionRect) {
|
|
363
|
-
const cellOptions = getToolbarCellOptionsConfig(state, initialSelectionRect, {
|
|
394
|
+
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
364
395
|
formatMessage
|
|
365
396
|
}, getEditorContainerWidth, editorAnalyticsAPI);
|
|
366
397
|
return [cellOptions, separator(cellOptions.hidden)];
|
|
@@ -15,7 +15,7 @@ import { TableCssClassName as ClassName } from '../../types';
|
|
|
15
15
|
import messages from '../../ui/messages';
|
|
16
16
|
import { CONTENT_COMPONENT } from '@atlaskit/editor-common/analytics';
|
|
17
17
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
18
|
-
import { tableFloatingCellButtonStyles } from './styles';
|
|
18
|
+
import { tableFloatingCellButtonStyles, tableFloatingCellButtonSelectedStyles } from './styles';
|
|
19
19
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
20
20
|
export class FloatingContextualButtonInner extends React.Component {
|
|
21
21
|
constructor(...args) {
|
|
@@ -84,7 +84,11 @@ export class FloatingContextualButtonInner extends React.Component {
|
|
|
84
84
|
const tableWrapper = closestElement(targetCellRef, `.${ClassName.TABLE_NODE_WRAPPER}`);
|
|
85
85
|
const labelCellOptions = formatMessage(messages.cellOptions);
|
|
86
86
|
const button = jsx("div", {
|
|
87
|
-
css: tableFloatingCellButtonStyles
|
|
87
|
+
css: theme => [tableFloatingCellButtonStyles({
|
|
88
|
+
theme
|
|
89
|
+
}), isContextualMenuOpen && tableFloatingCellButtonSelectedStyles({
|
|
90
|
+
theme
|
|
91
|
+
})]
|
|
88
92
|
}, jsx(ToolbarButton, {
|
|
89
93
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
90
94
|
selected: isContextualMenuOpen,
|
|
@@ -1,28 +1,67 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
-
import { N0, N20 } from '@atlaskit/theme/colors';
|
|
2
|
+
import { B75, DN0, DN60, N0, N20, N30A, N700 } from '@atlaskit/theme/colors';
|
|
3
3
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
4
4
|
import { contextualMenuTriggerSize } from '../consts';
|
|
5
|
-
import { token } from '@atlaskit/tokens';
|
|
6
|
-
|
|
7
|
-
export const tableFloatingCellButtonStyles = css`
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
6
|
+
import { themed } from '@atlaskit/theme/components';
|
|
7
|
+
export const tableFloatingCellButtonStyles = props => css`
|
|
8
8
|
> div {
|
|
9
|
-
|
|
9
|
+
// Sits behind button to provide surface-color background
|
|
10
|
+
background: ${token('elevation.surface', N20)};
|
|
10
11
|
border-radius: ${borderRadius()}px;
|
|
11
|
-
border: 2px solid ${token('color.border.inverse', N0)};
|
|
12
12
|
display: flex;
|
|
13
|
-
height: ${contextualMenuTriggerSize
|
|
13
|
+
height: ${contextualMenuTriggerSize + 2}px;
|
|
14
14
|
flex-direction: column;
|
|
15
15
|
}
|
|
16
16
|
&& button {
|
|
17
|
+
background: ${themed({
|
|
18
|
+
light: token('color.background.neutral', 'none'),
|
|
19
|
+
dark: token('color.background.neutral', 'none')
|
|
20
|
+
})(props)};
|
|
17
21
|
flex-direction: column;
|
|
22
|
+
margin: 2px;
|
|
23
|
+
outline: 2px solid ${token('color.border', N0)};
|
|
24
|
+
border-radius: 1px;
|
|
18
25
|
padding: 0;
|
|
19
|
-
height: 100
|
|
26
|
+
height: calc(100% - 4px);
|
|
20
27
|
display: flex;
|
|
21
28
|
}
|
|
29
|
+
&& button:hover {
|
|
30
|
+
background: ${themed({
|
|
31
|
+
light: token('color.background.neutral.hovered', N30A),
|
|
32
|
+
dark: token('color.background.neutral.hovered', DN60)
|
|
33
|
+
})(props)};
|
|
34
|
+
}
|
|
35
|
+
&& button:active {
|
|
36
|
+
background: ${themed({
|
|
37
|
+
light: token('color.background.neutral.pressed', 'rgba(179, 212, 255, 0.6)'),
|
|
38
|
+
dark: token('color.background.neutral.pressed', B75)
|
|
39
|
+
})(props)};
|
|
40
|
+
}
|
|
22
41
|
&& button > span {
|
|
23
42
|
margin: 0px -4px;
|
|
24
43
|
}
|
|
25
44
|
&& span {
|
|
26
45
|
pointer-events: none;
|
|
27
46
|
}
|
|
47
|
+
`;
|
|
48
|
+
export const tableFloatingCellButtonSelectedStyles = props => css`
|
|
49
|
+
&& button {
|
|
50
|
+
background: ${themed({
|
|
51
|
+
light: token('color.background.selected', N700),
|
|
52
|
+
dark: token('color.background.selected', DN0)
|
|
53
|
+
})(props)};
|
|
54
|
+
}
|
|
55
|
+
&& button:hover {
|
|
56
|
+
background: ${themed({
|
|
57
|
+
light: token('color.background.selected.hovered', N700),
|
|
58
|
+
dark: token('color.background.selected.hovered', DN0)
|
|
59
|
+
})(props)};
|
|
60
|
+
}
|
|
61
|
+
&& button:active {
|
|
62
|
+
background: ${themed({
|
|
63
|
+
light: token('color.background.selected.pressed', N700),
|
|
64
|
+
dark: token('color.background.selected.pressed', DN0)
|
|
65
|
+
})(props)};
|
|
66
|
+
}
|
|
28
67
|
`;
|
|
@@ -457,7 +457,10 @@ export class ContextualMenu extends Component {
|
|
|
457
457
|
"data-testid": "table-cell-contextual-menu",
|
|
458
458
|
onMouseLeave: this.closeSubmenu
|
|
459
459
|
}, jsx(DropdownMenu, {
|
|
460
|
-
mountTo: mountPoint
|
|
460
|
+
mountTo: mountPoint //This needs be removed when the a11y is completely handled
|
|
461
|
+
//Disabling key navigation now as it works only partially
|
|
462
|
+
,
|
|
463
|
+
disableArrowKeyNavigation: true,
|
|
461
464
|
items: items,
|
|
462
465
|
isOpen: isOpen,
|
|
463
466
|
onOpenChange: this.handleOpenChange,
|
|
@@ -360,7 +360,7 @@ export const tableStyles = props => {
|
|
|
360
360
|
}
|
|
361
361
|
.active .${ClassName.CONTROLS_CORNER_BUTTON} {
|
|
362
362
|
border-color: ${tableBorderSelectedColor};
|
|
363
|
-
background: ${tableToolbarSelectedColor};
|
|
363
|
+
background: ${token('color.background.selected', tableToolbarSelectedColor)};
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
.${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
|
|
@@ -374,14 +374,14 @@ export const tableStyles = props => {
|
|
|
374
374
|
|
|
375
375
|
:not(.${ClassName.IS_RESIZING}) .${ClassName.CONTROLS_CORNER_BUTTON}:hover {
|
|
376
376
|
border-color: ${tableBorderSelectedColor};
|
|
377
|
-
background: ${tableToolbarSelectedColor};
|
|
377
|
+
background: ${token('color.background.selected', tableToolbarSelectedColor)};
|
|
378
378
|
cursor: pointer;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
:not(.${ClassName.IS_RESIZING})
|
|
382
382
|
.${ClassName.CONTROLS_CORNER_BUTTON}.${ClassName.HOVERED_CELL_IN_DANGER} {
|
|
383
383
|
border-color: ${tableBorderDeleteColor};
|
|
384
|
-
background: ${tableToolbarDeleteColor};
|
|
384
|
+
background: ${token('color.background.danger', tableToolbarDeleteColor)};
|
|
385
385
|
}
|
|
386
386
|
|
|
387
387
|
/* Row controls */
|
|
@@ -482,10 +482,10 @@ export const tableStyles = props => {
|
|
|
482
482
|
.${ClassName.NUMBERED_COLUMN_BUTTON}.active {
|
|
483
483
|
border-bottom: 1px solid ${tableBorderSelectedColor};
|
|
484
484
|
border-color: ${tableBorderSelectedColor};
|
|
485
|
-
background-color: ${tableToolbarSelectedColor};
|
|
485
|
+
background-color: ${token('color.background.selected', tableToolbarSelectedColor)};
|
|
486
486
|
position: relative;
|
|
487
487
|
z-index: ${akEditorUnitZIndex};
|
|
488
|
-
color: ${token('color.text.
|
|
488
|
+
color: ${token('color.text.selected', N0)};
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
}
|
|
@@ -496,16 +496,16 @@ export const tableStyles = props => {
|
|
|
496
496
|
.${ClassName.NUMBERED_COLUMN_BUTTON}:hover {
|
|
497
497
|
border-bottom: 1px solid ${tableBorderSelectedColor};
|
|
498
498
|
border-color: ${tableBorderSelectedColor};
|
|
499
|
-
background-color: ${tableToolbarSelectedColor};
|
|
499
|
+
background-color: ${token('color.background.selected', tableToolbarSelectedColor)};
|
|
500
500
|
position: relative;
|
|
501
501
|
z-index: ${akEditorUnitZIndex};
|
|
502
|
-
color: ${token('color.text.
|
|
502
|
+
color: ${token('color.text.selected', N0)};
|
|
503
503
|
}
|
|
504
504
|
.${ClassName.NUMBERED_COLUMN_BUTTON}.${ClassName.HOVERED_CELL_IN_DANGER} {
|
|
505
|
-
background-color: ${tableToolbarDeleteColor};
|
|
505
|
+
background-color: ${token('color.background.danger', tableToolbarDeleteColor)};
|
|
506
506
|
border: 1px solid ${tableBorderDeleteColor};
|
|
507
507
|
border-left: 0;
|
|
508
|
-
color: ${token('color.text.
|
|
508
|
+
color: ${token('color.text.danger', R500)};
|
|
509
509
|
position: relative;
|
|
510
510
|
z-index: ${akEditorUnitZIndex};
|
|
511
511
|
}
|