@atlaskit/editor-plugin-table 5.2.1 → 5.3.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 +13 -0
- package/dist/cjs/plugins/table/commands/selection.js +20 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +20 -2
- package/dist/cjs/plugins/table/nodeviews/table.js +1 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/handlers.js +24 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +29 -4
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +17 -5
- package/dist/cjs/plugins/table/pm-plugins/table-selection-keymap.js +4 -0
- package/dist/cjs/plugins/table/toolbar.js +2 -2
- package/dist/cjs/plugins/table/types.js +4 -0
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +106 -0
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +90 -0
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +12 -9
- package/dist/es2019/plugins/table/commands/selection.js +18 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +20 -2
- package/dist/es2019/plugins/table/nodeviews/table.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/handlers.js +10 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +28 -4
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +14 -3
- package/dist/es2019/plugins/table/pm-plugins/table-selection-keymap.js +6 -2
- package/dist/es2019/plugins/table/toolbar.js +1 -1
- package/dist/es2019/plugins/table/types.js +4 -0
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +101 -0
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +60 -0
- package/dist/es2019/plugins/table/ui/common-styles.js +13 -1
- package/dist/es2019/plugins/table/ui/ui-styles.js +13 -0
- package/dist/esm/plugins/table/commands/selection.js +19 -0
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +20 -2
- package/dist/esm/plugins/table/nodeviews/table.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/handlers.js +18 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin-factory.js +28 -3
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +18 -6
- package/dist/esm/plugins/table/pm-plugins/table-selection-keymap.js +6 -2
- package/dist/esm/plugins/table/toolbar.js +1 -1
- package/dist/esm/plugins/table/types.js +4 -0
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +97 -0
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +80 -0
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/ui-styles.js +11 -8
- package/dist/types/plugins/table/commands/selection.d.ts +1 -0
- package/dist/types/plugins/table/index.d.ts +1 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/handlers.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin-factory.d.ts +1 -2
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +2 -0
- package/dist/types/plugins/table/toolbar.d.ts +1 -0
- package/dist/types/plugins/table/types.d.ts +4 -0
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +11 -0
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +20 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/commands/selection.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/handlers.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin-factory.d.ts +1 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/toolbar.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +20 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
- package/package.json +5 -2
- package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +139 -0
- package/src/plugins/table/commands/selection.ts +24 -0
- package/src/plugins/table/index.tsx +1 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +25 -0
- package/src/plugins/table/nodeviews/table.tsx +1 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/handlers.ts +35 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin-factory.ts +27 -2
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +12 -3
- package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +3 -0
- package/src/plugins/table/pm-plugins/table-selection-keymap.ts +15 -1
- package/src/plugins/table/toolbar.tsx +3 -1
- package/src/plugins/table/types.ts +5 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +128 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +101 -0
- package/src/plugins/table/ui/common-styles.ts +13 -0
- package/src/plugins/table/ui/ui-styles.ts +14 -0
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.resizeHandle = exports.insertRowButtonWrapper = exports.insertColumnButtonWrapper = exports.hoveredWarningCell = exports.hoveredDeleteButton = exports.hoveredCell = exports.columnControlsLineMarker = exports.columnControlsDecoration = exports.OverflowShadow = exports.InsertMarker = exports.HeaderButtonHover = exports.HeaderButtonDanger = exports.HeaderButton = exports.DeleteButton = void 0;
|
|
7
|
+
exports.resizeHandle = exports.insertRowButtonWrapper = exports.insertColumnButtonWrapper = exports.hoveredWarningCell = exports.hoveredDeleteButton = exports.hoveredCell = exports.floatingColumnControls = exports.columnControlsLineMarker = exports.columnControlsDecoration = exports.OverflowShadow = exports.InsertMarker = exports.HeaderButtonHover = exports.HeaderButtonDanger = exports.HeaderButton = exports.DeleteButton = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
@@ -14,7 +14,7 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
14
14
|
var _constants = require("@atlaskit/theme/constants");
|
|
15
15
|
var _types = require("../types");
|
|
16
16
|
var _consts = require("./consts");
|
|
17
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25;
|
|
17
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26;
|
|
18
18
|
var InsertLine = function InsertLine(props, cssString) {
|
|
19
19
|
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n background: ", ";\n display: none;\n position: absolute;\n z-index: ", ";\n ", "\n }\n"])), _types.TableCssClassName.CONTROLS_INSERT_LINE, (0, _consts.tableBorderSelectedColor)(props), _editorSharedStyles.akEditorUnitZIndex, cssString);
|
|
20
20
|
};
|
|
@@ -70,25 +70,28 @@ var columnHeaderButtonSelected = function columnHeaderButtonSelected(props) {
|
|
|
70
70
|
var getFloatingDotOverrides = function getFloatingDotOverrides(props) {
|
|
71
71
|
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? (0, _react.css)(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2.default)(["\n tr\n th:last-child\n .", "::before,\n tr\n td:last-child\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: ", ";\n right: 0px;\n }\n "])), _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, (0, _consts.tableBorderColor)(props), _consts.lineMarkerSize, _consts.lineMarkerSize, "var(--ds-space-025, 2px)") : '';
|
|
72
72
|
};
|
|
73
|
+
var floatingColumnControls = exports.floatingColumnControls = function floatingColumnControls(props) {
|
|
74
|
+
return (0, _react.css)(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n box-sizing: border-box;\n position: absolute;\n\n .", " {\n display: flex;\n flex-direction: row;\n }\n }\n "])), _types.TableCssClassName.COLUMN_DROP_TARGET_CONTROLS, _types.TableCssClassName.COLUMN_CONTROLS_INNER);
|
|
75
|
+
};
|
|
73
76
|
var columnControlsDecoration = exports.columnControlsDecoration = function columnControlsDecoration(props) {
|
|
74
77
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.column-controls-styles-updated')) {
|
|
75
|
-
return (0, _react.css)(
|
|
78
|
+
return (0, _react.css)(_templateObject20 || (_templateObject20 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n display: none;\n cursor: pointer;\n position: absolute;\n width: 100%;\n left: 0;\n top: -", "px;\n height: ", "px;\n // floating dot for adding column button\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 // floating dot for adding column button - overriding style on last column to avoid scroll\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 tr:first-of-type th.", " {\n &.", ", &.", " {\n .", "::after {\n ", ";\n }\n\n &.", "\n .", "::after {\n background-color: ", ";\n border-color: ", ";\n z-index: ", ";\n }\n }\n }\n\n table tr:first-of-type th.", " {\n &.", ", &.", " {\n .", "::after {\n ", ";\n border-left: ", "px solid\n ", ";\n left: -", "px;\n }\n }\n }\n\n table tr:first-of-type th.", " {\n &.", " {\n .", "::after {\n ", ";\n }\n\n &.", "\n .", "::after {\n background-color: ", ";\n border-color: ", ";\n border-left: ", "px solid\n ", ";\n left: -", "px;\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, _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-top: ").concat(_styles.tableCellBorderWidth, "px solid ").concat((0, _consts.tableBorderColor)(props), ";\n border-bottom: ").concat(_styles.tableCellBorderWidth, "px solid ").concat((0, _consts.tableBorderColor)(props), ";\n box-sizing: content-box;\n height: ").concat(_consts.tableToolbarSize - 1, "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 ")), getFloatingDotOverrides(props), _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_HEADER_CELL, _types.TableCssClassName.COLUMN_SELECTED, _types.TableCssClassName.HOVERED_TABLE, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, columnHeaderButtonSelected(props), _types.TableCssClassName.HOVERED_CELL_IN_DANGER, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, (0, _consts.tableToolbarDeleteColor)(props), (0, _consts.tableBorderDeleteColor)(props), _editorSharedStyles.akEditorUnitZIndex * 100, _types.TableCssClassName.TABLE_HEADER_CELL, _types.TableCssClassName.COLUMN_SELECTED, _types.TableCssClassName.HOVERED_COLUMN, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, columnHeaderButtonSelected(props), _styles.tableCellBorderWidth, (0, _consts.tableBorderSelectedColor)(props), _styles.tableCellBorderWidth, _types.TableCssClassName.TABLE_HEADER_CELL, _types.TableCssClassName.HOVERED_COLUMN, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, columnHeaderButtonSelected(props), _types.TableCssClassName.HOVERED_CELL_IN_DANGER, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, (0, _consts.tableToolbarDeleteColor)(props), (0, _consts.tableBorderDeleteColor)(props), _styles.tableCellBorderWidth, (0, _consts.tableBorderDeleteColor)(props), _styles.tableCellBorderWidth, _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(props));
|
|
76
79
|
} else {
|
|
77
|
-
return (0, _react.css)(
|
|
80
|
+
return (0, _react.css)(_templateObject21 || (_templateObject21 = (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 // floating dot for adding column button\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 // floating dot for adding column button - overriding style on last column to avoid scroll\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 ")), getFloatingDotOverrides(props), _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(props), _types.TableCssClassName.HOVERED_CELL_IN_DANGER, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, (0, _consts.tableToolbarDeleteColor)(props), (0, _consts.tableBorderDeleteColor)(props), _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(props));
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
83
|
var hoveredDeleteButton = exports.hoveredDeleteButton = function hoveredDeleteButton(props) {
|
|
81
|
-
return (0, _react.css)(
|
|
84
|
+
return (0, _react.css)(_templateObject22 || (_templateObject22 = (0, _taggedTemplateLiteral2.default)(["\n .", ".", " {\n .", ",\n .", ",\n .", " {\n border: 1px solid ", ";\n }\n .", "::after {\n background: ", ";\n }\n }\n"])), _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.HOVERED_DELETE_BUTTON, _types.TableCssClassName.SELECTED_CELL, _types.TableCssClassName.COLUMN_SELECTED, _types.TableCssClassName.HOVERED_CELL, (0, _consts.tableBorderDeleteColor)(props), _types.TableCssClassName.SELECTED_CELL, (0, _consts.tableCellDeleteColor)(props));
|
|
82
85
|
};
|
|
83
86
|
var hoveredCell = exports.hoveredCell = function hoveredCell(props) {
|
|
84
|
-
return (0, _react.css)(
|
|
87
|
+
return (0, _react.css)(_templateObject23 || (_templateObject23 = (0, _taggedTemplateLiteral2.default)(["\n :not(.", ")\n .", ":not(.", ") {\n .", " {\n position: relative;\n border: 1px solid ", ";\n }\n }\n"])), _types.TableCssClassName.IS_RESIZING, _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.HOVERED_DELETE_BUTTON, _types.TableCssClassName.HOVERED_CELL, (0, _consts.tableBorderSelectedColor)(props));
|
|
85
88
|
};
|
|
86
|
-
var hoveredWarningCell = exports.hoveredWarningCell = (0, _react.css)(
|
|
89
|
+
var hoveredWarningCell = exports.hoveredWarningCell = (0, _react.css)(_templateObject24 || (_templateObject24 = (0, _taggedTemplateLiteral2.default)(["\n :not(.", ")\n .", ":not(.", ") {\n td.", " {\n background-color: ", " !important; // We need to override the background-color added to the cell\n border: 1px solid ", ";\n }\n }\n"])), _types.TableCssClassName.IS_RESIZING, _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.HOVERED_DELETE_BUTTON, _types.TableCssClassName.HOVERED_CELL_WARNING, "var(--ds-background-warning, ".concat(_colors.Y50, ")"), "var(--ds-border-warning, ".concat(_colors.Y200, ")"));
|
|
87
90
|
|
|
88
91
|
// move the resize handle zone completely inside the table cell to avoid overflow
|
|
89
92
|
var getLastColumnResizerOverrides = function getLastColumnResizerOverrides() {
|
|
90
|
-
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? (0, _react.css)(
|
|
93
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? (0, _react.css)(_templateObject25 || (_templateObject25 = (0, _taggedTemplateLiteral2.default)(["\n tr\n th:last-child\n .", ",\n tr\n td:last-child\n .", " {\n background-color: transparent;\n position: absolute;\n width: ", "px;\n height: 100%;\n top: 0;\n right: 0;\n cursor: col-resize;\n z-index: ", ";\n }\n "])), _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _consts.resizeHandlerAreaWidth / 2, _consts.resizeHandlerZIndex) : '';
|
|
91
94
|
};
|
|
92
95
|
var resizeHandle = exports.resizeHandle = function resizeHandle(props) {
|
|
93
|
-
return (0, _react.css)(
|
|
96
|
+
return (0, _react.css)(_templateObject26 || (_templateObject26 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n .", " {\n background-color: transparent;\n position: absolute;\n width: ", "px;\n height: 100%;\n top: 0;\n right: -", "px;\n cursor: col-resize;\n z-index: ", ";\n }\n\n ", "\n\n td.", "::before {\n content: ' ';\n position: absolute;\n left: ", ";\n top: -1px;\n width: ", "px;\n height: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n left: ", ";\n position: absolute;\n width: ", "px;\n height: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n top: -", "px;\n }\n\n td.", "::before {\n content: ' ';\n position: absolute;\n right: -1px;\n top: -1px;\n width: ", "px;\n height: calc(100% + 2px);\n background-color: ", ";\n z-index: ", ";\n }\n\n th.", "::before {\n content: ' ';\n right: -1px;\n position: absolute;\n width: ", "px;\n height: calc(100% + ", "px);\n background-color: ", ";\n z-index: ", ";\n top: -", "px;\n }\n\n table\n tr:first-of-type\n th.", "\n .", "::after,\n table\n tr:first-of-type\n td.", "\n .", "::after {\n top: -", "px;\n height: calc(100% + ", "px);\n }\n }\n"])), _types.TableCssClassName.TABLE_CONTAINER, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _consts.resizeHandlerAreaWidth, _consts.resizeHandlerAreaWidth / 2, _consts.resizeHandlerZIndex, getLastColumnResizerOverrides(), _types.TableCssClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", _consts.resizeLineWidth, (0, _consts.tableBorderSelectedColor)(props), _consts.columnControlsZIndex * 2, _types.TableCssClassName.WITH_RESIZE_LINE, "var(--ds-space-negative-025, -2px)", _consts.resizeLineWidth, _consts.tableToolbarSize + _styles.tableCellBorderWidth, (0, _consts.tableBorderSelectedColor)(props), _consts.columnControlsZIndex * 2, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _types.TableCssClassName.WITH_RESIZE_LINE_LAST_COLUMN, _consts.resizeLineWidth, (0, _consts.tableBorderSelectedColor)(props), _consts.columnControlsZIndex * 2, _types.TableCssClassName.WITH_RESIZE_LINE_LAST_COLUMN, _consts.resizeLineWidth, _consts.tableToolbarSize + _styles.tableCellBorderWidth, (0, _consts.tableBorderSelectedColor)(props), _consts.columnControlsZIndex * 2, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _types.TableCssClassName.WITH_RESIZE_LINE, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _types.TableCssClassName.WITH_RESIZE_LINE, _types.TableCssClassName.RESIZE_HANDLE_DECORATION, _consts.tableToolbarSize + _styles.tableCellBorderWidth, _consts.tableToolbarSize + _styles.tableCellBorderWidth);
|
|
94
97
|
};
|
|
@@ -3,6 +3,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
6
|
+
import { getClosestSelectionRect } from '../toolbar';
|
|
6
7
|
export let TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
|
|
7
8
|
TableSelectionDirection["TopToBottom"] = "TopToBottom";
|
|
8
9
|
TableSelectionDirection["BottomToTop"] = "BottomToTop";
|
|
@@ -305,4 +306,20 @@ const setGapCursorAfterTable = editorSelectionAPI => () => (state, dispatch) =>
|
|
|
305
306
|
return false;
|
|
306
307
|
};
|
|
307
308
|
const isSelectionAtStartOfTable = ($pos, selection) => isSelectionAtStartOfNode($pos, findTable(selection));
|
|
308
|
-
const isSelectionAtEndOfTable = ($pos, selection) => isSelectionAtEndOfNode($pos, findTable(selection));
|
|
309
|
+
const isSelectionAtEndOfTable = ($pos, selection) => isSelectionAtEndOfNode($pos, findTable(selection));
|
|
310
|
+
export const shiftArrowUpFromTable = editorSelectionAPI => () => (state, dispatch) => {
|
|
311
|
+
const {
|
|
312
|
+
selection
|
|
313
|
+
} = state;
|
|
314
|
+
const table = findTable(selection);
|
|
315
|
+
const selectionRect = getClosestSelectionRect(state);
|
|
316
|
+
const index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.top;
|
|
317
|
+
if (table && index === 0) {
|
|
318
|
+
return selectFullTable(editorSelectionAPI)({
|
|
319
|
+
node: table.node,
|
|
320
|
+
startPos: table.start,
|
|
321
|
+
dir: TableSelectionDirection.BottomToTop
|
|
322
|
+
})(state, dispatch);
|
|
323
|
+
}
|
|
324
|
+
return false;
|
|
325
|
+
};
|
|
@@ -20,6 +20,7 @@ import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup
|
|
|
20
20
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
21
21
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
22
22
|
import { tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
|
|
23
|
+
import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
|
|
23
24
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
24
25
|
import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
|
|
25
26
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
@@ -454,7 +455,8 @@ class TableComponent extends React.Component {
|
|
|
454
455
|
containerWidth,
|
|
455
456
|
options,
|
|
456
457
|
getPos,
|
|
457
|
-
pluginInjectionApi
|
|
458
|
+
pluginInjectionApi,
|
|
459
|
+
isDragAndDropEnabled
|
|
458
460
|
} = this.props;
|
|
459
461
|
const {
|
|
460
462
|
showBeforeShadow,
|
|
@@ -490,6 +492,22 @@ class TableComponent extends React.Component {
|
|
|
490
492
|
stickyHeader: this.state.stickyHeader,
|
|
491
493
|
getEditorFeatureFlags: this.props.getEditorFeatureFlags
|
|
492
494
|
}));
|
|
495
|
+
const colControls = /*#__PURE__*/React.createElement("div", {
|
|
496
|
+
className: ClassName.COLUMN_CONTROLS_WRAPPER
|
|
497
|
+
}, /*#__PURE__*/React.createElement(TableFloatingColumnControls, {
|
|
498
|
+
editorView: view,
|
|
499
|
+
tableRef: tableRef,
|
|
500
|
+
tableActive: tableActive,
|
|
501
|
+
hoveredRows: hoveredRows,
|
|
502
|
+
ordering: ordering,
|
|
503
|
+
hasHeaderRow: hasHeaderRow
|
|
504
|
+
// pass `selection` and `tableHeight` to control re-render
|
|
505
|
+
,
|
|
506
|
+
selection: view.state.selection,
|
|
507
|
+
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
508
|
+
stickyHeader: this.state.stickyHeader,
|
|
509
|
+
getEditorFeatureFlags: this.props.getEditorFeatureFlags
|
|
510
|
+
}));
|
|
493
511
|
const shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
|
|
494
512
|
const shadowStyle = memoizeOne(visible => ({
|
|
495
513
|
visibility: visible ? 'visible' : 'hidden'
|
|
@@ -530,7 +548,7 @@ class TableComponent extends React.Component {
|
|
|
530
548
|
}), getBooleanFF('platform.editor.table-sticky-scrollbar') && /*#__PURE__*/React.createElement("div", {
|
|
531
549
|
className: ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
|
|
532
550
|
"data-testid": "sticky-scrollbar-sentinel-top"
|
|
533
|
-
}), allowControls && rowControls, /*#__PURE__*/React.createElement("div", {
|
|
551
|
+
}), allowControls && rowControls, isDragAndDropEnabled && allowControls && colControls, /*#__PURE__*/React.createElement("div", {
|
|
534
552
|
style: shadowStyle(showBeforeShadow),
|
|
535
553
|
className: ClassName.TABLE_LEFT_SHADOW
|
|
536
554
|
}), this.state.stickyHeader && /*#__PURE__*/React.createElement("div", {
|
|
@@ -148,6 +148,7 @@ export default class TableView extends ReactNodeView {
|
|
|
148
148
|
allowControls: pluginState.pluginConfig.allowControls,
|
|
149
149
|
isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
|
|
150
150
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
151
|
+
isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
|
|
151
152
|
tableActive: tableActive,
|
|
152
153
|
ordering: pluginState.ordering,
|
|
153
154
|
isResizing: isResizing,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
2
|
+
|
|
3
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
4
|
+
const buildPluginState = builders => props => pluginState => {
|
|
5
|
+
return builders.reduce((_pluginState, transform) => transform(props)(_pluginState), pluginState);
|
|
6
|
+
};
|
|
7
|
+
export const handleDocOrSelectionChanged = (tr, pluginState) => buildPluginState([])({
|
|
8
|
+
tr,
|
|
9
|
+
table: findTable(tr.selection)
|
|
10
|
+
})(pluginState);
|
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
3
|
+
import { handleDocOrSelectionChanged } from './handlers';
|
|
2
4
|
import { pluginKey } from './plugin-key';
|
|
3
5
|
import reducer from './reducer';
|
|
4
|
-
const {
|
|
6
|
+
export const {
|
|
5
7
|
createPluginState,
|
|
6
|
-
createCommand
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
createCommand,
|
|
9
|
+
getPluginState
|
|
10
|
+
} = pluginFactory(pluginKey, reducer, {
|
|
11
|
+
mapping: (tr, pluginState) => {
|
|
12
|
+
if (tr.docChanged) {
|
|
13
|
+
let decorationSet = pluginState.decorationSet;
|
|
14
|
+
const meta = tr.getMeta(tablePluginKey);
|
|
15
|
+
if (meta && meta.data && meta.data.decorationSet) {
|
|
16
|
+
decorationSet = meta.data.decorationSet;
|
|
17
|
+
}
|
|
18
|
+
if (decorationSet) {
|
|
19
|
+
decorationSet = decorationSet.map(tr.mapping, tr.doc);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
...pluginState,
|
|
23
|
+
...{
|
|
24
|
+
decorationSet
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return pluginState;
|
|
29
|
+
},
|
|
30
|
+
onDocChanged: handleDocOrSelectionChanged,
|
|
31
|
+
onSelectionChanged: handleDocOrSelectionChanged
|
|
32
|
+
});
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import { DropTargetType } from './consts';
|
|
3
|
-
import { createPluginState } from './plugin-factory';
|
|
4
|
+
import { createPluginState, getPluginState } from './plugin-factory';
|
|
4
5
|
import { pluginKey } from './plugin-key';
|
|
5
6
|
export const createPlugin = (dispatch, eventDispatcher) => {
|
|
6
7
|
return new SafePlugin({
|
|
7
|
-
state: createPluginState(dispatch, {
|
|
8
|
+
state: createPluginState(dispatch, state => ({
|
|
9
|
+
decorationSet: DecorationSet.empty,
|
|
8
10
|
// TODO: This is example placeholder state. We could use this to track which row/col is currently set as the drop target
|
|
9
11
|
// This would result in a blue highlight being displayed on the corrisponding row/column to single the drop target location.
|
|
10
12
|
dropTargetType: DropTargetType.NONE,
|
|
11
13
|
dropTargetIndex: 0
|
|
12
|
-
}),
|
|
14
|
+
})),
|
|
13
15
|
key: pluginKey,
|
|
14
16
|
view: editorView => {
|
|
15
17
|
// TODO: Add Pragmatic DnD monitor when the view is constructed.
|
|
18
|
+
|
|
16
19
|
return {
|
|
17
20
|
// TODO: Cleanup monitor instance
|
|
18
21
|
// destroy: cleanup,
|
|
19
22
|
};
|
|
23
|
+
},
|
|
24
|
+
props: {
|
|
25
|
+
decorations: state => {
|
|
26
|
+
const {
|
|
27
|
+
decorationSet
|
|
28
|
+
} = getPluginState(state);
|
|
29
|
+
return decorationSet;
|
|
30
|
+
}
|
|
20
31
|
}
|
|
21
32
|
});
|
|
22
33
|
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { bindKeymapWithCommand, moveLeft, moveRight } from '@atlaskit/editor-common/keymaps';
|
|
1
|
+
import { bindKeymapWithCommand, moveLeft, moveRight, shiftArrowUp } from '@atlaskit/editor-common/keymaps';
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
-
import {
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { arrowLeftFromTable, arrowRightFromTable, shiftArrowUpFromTable } from '../commands/selection';
|
|
4
5
|
export function tableSelectionKeymapPlugin(editorSelectionAPI) {
|
|
5
6
|
const list = {};
|
|
6
7
|
bindKeymapWithCommand(moveRight.common, arrowRightFromTable(editorSelectionAPI)(), list);
|
|
7
8
|
bindKeymapWithCommand(moveLeft.common, arrowLeftFromTable(editorSelectionAPI)(), list);
|
|
9
|
+
if (getBooleanFF('platform.editor.table.shift-arrowup-fix')) {
|
|
10
|
+
bindKeymapWithCommand(shiftArrowUp.common, shiftArrowUpFromTable(editorSelectionAPI)(), list);
|
|
11
|
+
}
|
|
8
12
|
return keymap(list);
|
|
9
13
|
}
|
|
10
14
|
export default tableSelectionKeymapPlugin;
|
|
@@ -286,7 +286,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
286
286
|
showSelected: false
|
|
287
287
|
};
|
|
288
288
|
};
|
|
289
|
-
const getClosestSelectionRect = state => {
|
|
289
|
+
export const getClosestSelectionRect = state => {
|
|
290
290
|
const selection = state.selection;
|
|
291
291
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
292
292
|
};
|
|
@@ -34,6 +34,7 @@ export let TableDecorations = /*#__PURE__*/function (TableDecorations) {
|
|
|
34
34
|
TableDecorations["TABLE_CONTROLS_HOVER"] = "TABLE_CONTROLS_HOVER";
|
|
35
35
|
TableDecorations["CELL_CONTROLS_HOVER"] = "CELL_CONTROLS_HOVER";
|
|
36
36
|
TableDecorations["COLUMN_CONTROLS_DECORATIONS"] = "COLUMN_CONTROLS_DECORATIONS";
|
|
37
|
+
TableDecorations["COLUMN_DROP_TARGET_DECORATIONS"] = "COLUMN_DROP_TARGET_DECORATIONS";
|
|
37
38
|
TableDecorations["COLUMN_SELECTED"] = "COLUMN_SELECTED";
|
|
38
39
|
TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
|
|
39
40
|
TableDecorations["COLUMN_RESIZING_HANDLE_WIDGET"] = "COLUMN_RESIZING_HANDLE_WIDGET";
|
|
@@ -46,6 +47,9 @@ export const TableCssClassName = {
|
|
|
46
47
|
COLUMN_CONTROLS: `${tablePrefixSelector}-column-controls`,
|
|
47
48
|
COLUMN_CONTROLS_DECORATIONS: `${tablePrefixSelector}-column-controls-decoration`,
|
|
48
49
|
COLUMN_SELECTED: `${tablePrefixSelector}-column__selected`,
|
|
50
|
+
COLUMN_CONTROLS_WRAPPER: `${tablePrefixSelector}-col-controls-wrapper`,
|
|
51
|
+
COLUMN_DROP_TARGET_CONTROLS: `${tablePrefixSelector}-col-drop-target-controls`,
|
|
52
|
+
COLUMN_CONTROLS_INNER: `${tablePrefixSelector}-col-controls__inner`,
|
|
49
53
|
ROW_CONTROLS_WRAPPER: `${tablePrefixSelector}-row-controls-wrapper`,
|
|
50
54
|
ROW_CONTROLS: `${tablePrefixSelector}-row-controls`,
|
|
51
55
|
ROW_CONTROLS_INNER: `${tablePrefixSelector}-row-controls__inner`,
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
|
|
3
|
+
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
4
|
+
import { TableCssClassName as ClassName } from '../../../types';
|
|
5
|
+
import { getColumnsWidths, getRowHeights } from '../../../utils';
|
|
6
|
+
export const ColumnDropTargets = ({
|
|
7
|
+
editorView,
|
|
8
|
+
tableRef,
|
|
9
|
+
tableHeight,
|
|
10
|
+
stickyTop,
|
|
11
|
+
localId
|
|
12
|
+
}) => {
|
|
13
|
+
var _rowHeights$;
|
|
14
|
+
const colWidths = getColumnsWidths(editorView);
|
|
15
|
+
const rowHeights = useMemo(() => {
|
|
16
|
+
// NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
|
|
17
|
+
if (tableRef && !!tableHeight) {
|
|
18
|
+
return getRowHeights(tableRef);
|
|
19
|
+
}
|
|
20
|
+
return [0];
|
|
21
|
+
}, [tableRef, tableHeight]);
|
|
22
|
+
if (!tableRef) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const firstRow = tableRef.querySelector('tr');
|
|
26
|
+
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
27
|
+
const marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: ClassName.COLUMN_DROP_TARGET_CONTROLS
|
|
30
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: ClassName.COLUMN_CONTROLS_INNER,
|
|
32
|
+
"data-testid": "table-floating-column-controls-drop-targets"
|
|
33
|
+
}, colWidths.map((width, index) => {
|
|
34
|
+
return /*#__PURE__*/React.createElement(ColumnDropTarget, {
|
|
35
|
+
key: index,
|
|
36
|
+
index: index,
|
|
37
|
+
localId: localId,
|
|
38
|
+
width: width,
|
|
39
|
+
height: tableHeight,
|
|
40
|
+
marginTop: marginTop
|
|
41
|
+
});
|
|
42
|
+
})));
|
|
43
|
+
};
|
|
44
|
+
export default ColumnDropTargets;
|
|
45
|
+
const ColumnDropTarget = ({
|
|
46
|
+
index,
|
|
47
|
+
localId,
|
|
48
|
+
width,
|
|
49
|
+
height,
|
|
50
|
+
marginTop
|
|
51
|
+
}) => {
|
|
52
|
+
const dropTargetRef = useRef(null);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!dropTargetRef.current) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
return dropTargetForElements({
|
|
58
|
+
element: dropTargetRef.current,
|
|
59
|
+
canDrop({
|
|
60
|
+
source
|
|
61
|
+
}) {
|
|
62
|
+
var _data$indexes, _data$indexes2;
|
|
63
|
+
const data = source.data;
|
|
64
|
+
return (
|
|
65
|
+
// Only draggables of row type can be dropped on this target
|
|
66
|
+
data.type === 'table-column' &&
|
|
67
|
+
// Only draggables which came from the same table can be dropped on this target
|
|
68
|
+
data.localId === localId &&
|
|
69
|
+
// Only draggables which DO NOT include this drop targets index can be dropped
|
|
70
|
+
!!((_data$indexes = data.indexes) !== null && _data$indexes !== void 0 && _data$indexes.length) && ((_data$indexes2 = data.indexes) === null || _data$indexes2 === void 0 ? void 0 : _data$indexes2.indexOf(index)) === -1
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
getData({
|
|
74
|
+
input,
|
|
75
|
+
element
|
|
76
|
+
}) {
|
|
77
|
+
const data = {
|
|
78
|
+
localId,
|
|
79
|
+
type: 'table-column',
|
|
80
|
+
targetIndex: index
|
|
81
|
+
};
|
|
82
|
+
return attachClosestEdge(data, {
|
|
83
|
+
input,
|
|
84
|
+
element,
|
|
85
|
+
allowedEdges: ['left', 'right']
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}, [index, localId]);
|
|
90
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
91
|
+
ref: dropTargetRef,
|
|
92
|
+
style: {
|
|
93
|
+
width: width && `${width - 1}px`,
|
|
94
|
+
height: height && `${height}px`,
|
|
95
|
+
marginTop: marginTop && `${marginTop}px`
|
|
96
|
+
},
|
|
97
|
+
"data-drop-target-index": index,
|
|
98
|
+
"data-drop-target-localid": localId,
|
|
99
|
+
"data-testid": "table-floating-column-controls-drop-target"
|
|
100
|
+
});
|
|
101
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { findTable } from '@atlaskit/editor-tables';
|
|
3
|
+
import { ColumnDropTargets } from './ColumnDropTargets';
|
|
4
|
+
export const TableFloatingColumnControls = ({
|
|
5
|
+
editorView,
|
|
6
|
+
tableRef,
|
|
7
|
+
tableActive,
|
|
8
|
+
hasHeaderRow,
|
|
9
|
+
stickyHeader,
|
|
10
|
+
selection
|
|
11
|
+
}) => {
|
|
12
|
+
const [tableRect, setTableRect] = useState({
|
|
13
|
+
width: 0,
|
|
14
|
+
height: 0
|
|
15
|
+
});
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
var _window;
|
|
18
|
+
if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
|
|
19
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
20
|
+
for (let entry of entries) {
|
|
21
|
+
setTableRect(prev => {
|
|
22
|
+
if (prev.width !== entry.contentRect.width || prev.height !== entry.contentRect.height) {
|
|
23
|
+
return entry.contentRect;
|
|
24
|
+
}
|
|
25
|
+
return prev;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
resizeObserver.observe(tableRef);
|
|
30
|
+
return () => {
|
|
31
|
+
resizeObserver.disconnect();
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}, [tableRef]);
|
|
35
|
+
const selectedLocalId = useMemo(() => {
|
|
36
|
+
if (!selection) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const tableNode = findTable(selection);
|
|
40
|
+
if (!tableNode) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return tableNode.node.attrs.localId;
|
|
44
|
+
}, [selection]);
|
|
45
|
+
if (!tableRef) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
onMouseDown: e => e.preventDefault(),
|
|
51
|
+
"data-testid": "table-floating-column-controls-wrapper"
|
|
52
|
+
}, tableActive && /*#__PURE__*/React.createElement(ColumnDropTargets, {
|
|
53
|
+
editorView: editorView,
|
|
54
|
+
tableRef: tableRef,
|
|
55
|
+
stickyTop: tableActive ? stickyTop : undefined,
|
|
56
|
+
tableHeight: tableRect.height,
|
|
57
|
+
localId: selectedLocalId
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
export default TableFloatingColumnControls;
|
|
@@ -7,7 +7,7 @@ import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
|
|
|
7
7
|
import { fontSize } from '@atlaskit/theme/constants';
|
|
8
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
9
9
|
import { columnControlsDecorationHeight, resizeHandlerAreaWidth, resizeLineWidth, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableBorderColor, tableBorderDeleteColor, tableBorderRadiusSize, tableBorderSelectedColor, tableCellBackgroundColor, tableCellDeleteColor, tableCellSelectedColor, tableControlsSpacing, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tablePadding, tableScrollbarOffset, tableTextColor, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
10
|
-
import { columnControlsDecoration, columnControlsLineMarker, DeleteButton, HeaderButton, HeaderButtonDanger, HeaderButtonHover, hoveredCell, hoveredDeleteButton, hoveredWarningCell, insertColumnButtonWrapper, InsertMarker, insertRowButtonWrapper, OverflowShadow, resizeHandle } from './ui-styles';
|
|
10
|
+
import { columnControlsDecoration, columnControlsLineMarker, DeleteButton, floatingColumnControls, HeaderButton, HeaderButtonDanger, HeaderButtonHover, hoveredCell, hoveredDeleteButton, hoveredWarningCell, insertColumnButtonWrapper, InsertMarker, insertRowButtonWrapper, OverflowShadow, resizeHandle } from './ui-styles';
|
|
11
11
|
const cornerControlHeight = tableToolbarSize + 1;
|
|
12
12
|
|
|
13
13
|
/*
|
|
@@ -435,6 +435,10 @@ export const tableStyles = props => {
|
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
+
.${ClassName.COLUMN_CONTROLS_WRAPPER} {
|
|
439
|
+
padding: 0 ${tablePadding}px;
|
|
440
|
+
}
|
|
441
|
+
|
|
438
442
|
&.${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
|
|
439
443
|
padding-left: ${akEditorTableNumberColumnWidth + tablePadding - 1}px;
|
|
440
444
|
}
|
|
@@ -579,6 +583,8 @@ export const tableStyles = props => {
|
|
|
579
583
|
`)}
|
|
580
584
|
}
|
|
581
585
|
|
|
586
|
+
${floatingColumnControls(props)}
|
|
587
|
+
|
|
582
588
|
:not(.${ClassName.IS_RESIZING}) .${ClassName.ROW_CONTROLS} {
|
|
583
589
|
${HeaderButtonHover(props)}
|
|
584
590
|
${HeaderButtonDanger(props)}
|
|
@@ -760,6 +766,12 @@ export const tableStyles = props => {
|
|
|
760
766
|
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
761
767
|
left: -${tableToolbarSize}px;
|
|
762
768
|
}
|
|
769
|
+
|
|
770
|
+
.${ClassName.COLUMN_CONTROLS_WRAPPER} {
|
|
771
|
+
position: absolute;
|
|
772
|
+
top: ${tableMarginTop + 1}px;
|
|
773
|
+
}
|
|
774
|
+
|
|
763
775
|
${tableWrapperStyles()}
|
|
764
776
|
}
|
|
765
777
|
|
|
@@ -286,6 +286,19 @@ const getFloatingDotOverrides = props => {
|
|
|
286
286
|
}
|
|
287
287
|
` : '';
|
|
288
288
|
};
|
|
289
|
+
export const floatingColumnControls = props => {
|
|
290
|
+
return css`
|
|
291
|
+
.${ClassName.COLUMN_DROP_TARGET_CONTROLS} {
|
|
292
|
+
box-sizing: border-box;
|
|
293
|
+
position: absolute;
|
|
294
|
+
|
|
295
|
+
.${ClassName.COLUMN_CONTROLS_INNER} {
|
|
296
|
+
display: flex;
|
|
297
|
+
flex-direction: row;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
`;
|
|
301
|
+
};
|
|
289
302
|
export const columnControlsDecoration = props => {
|
|
290
303
|
if (getBooleanFF('platform.editor.table.column-controls-styles-updated')) {
|
|
291
304
|
return css`
|
|
@@ -3,6 +3,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
6
|
+
import { getClosestSelectionRect } from '../toolbar';
|
|
6
7
|
export var TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
|
|
7
8
|
TableSelectionDirection["TopToBottom"] = "TopToBottom";
|
|
8
9
|
TableSelectionDirection["BottomToTop"] = "BottomToTop";
|
|
@@ -338,4 +339,22 @@ var isSelectionAtStartOfTable = function isSelectionAtStartOfTable($pos, selecti
|
|
|
338
339
|
};
|
|
339
340
|
var isSelectionAtEndOfTable = function isSelectionAtEndOfTable($pos, selection) {
|
|
340
341
|
return isSelectionAtEndOfNode($pos, findTable(selection));
|
|
342
|
+
};
|
|
343
|
+
export var shiftArrowUpFromTable = function shiftArrowUpFromTable(editorSelectionAPI) {
|
|
344
|
+
return function () {
|
|
345
|
+
return function (state, dispatch) {
|
|
346
|
+
var selection = state.selection;
|
|
347
|
+
var table = findTable(selection);
|
|
348
|
+
var selectionRect = getClosestSelectionRect(state);
|
|
349
|
+
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.top;
|
|
350
|
+
if (table && index === 0) {
|
|
351
|
+
return selectFullTable(editorSelectionAPI)({
|
|
352
|
+
node: table.node,
|
|
353
|
+
startPos: table.start,
|
|
354
|
+
dir: TableSelectionDirection.BottomToTop
|
|
355
|
+
})(state, dispatch);
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
};
|
|
359
|
+
};
|
|
341
360
|
};
|