@atlaskit/editor-plugin-table 0.0.6 → 0.0.8
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 +17 -0
- package/dist/cjs/plugins/table/event-handlers.js +7 -6
- package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +4 -4
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/cjs/plugins/table/toolbar.js +0 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +23 -10
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +23 -10
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -4
- package/dist/cjs/plugins/table/utils/column-controls.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/event-handlers.js +8 -7
- package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +3 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/es2019/plugins/table/toolbar.js +1 -2
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +18 -3
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +18 -3
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -2
- package/dist/es2019/plugins/table/utils/column-controls.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/event-handlers.js +8 -7
- package/dist/esm/plugins/table/nodeviews/table.js +4 -2
- package/dist/esm/plugins/table/nodeviews/tableCell.js +3 -4
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/esm/plugins/table/toolbar.js +1 -2
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +19 -9
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +19 -9
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -2
- package/dist/esm/plugins/table/utils/column-controls.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +5 -8
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +5 -5
- package/dist/types-ts4.0/plugins/table/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +5 -8
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +5 -5
- package/package.json +10 -3
- package/src/__tests__/unit/analytics.ts +737 -0
- package/src/__tests__/unit/collab.ts +76 -0
- package/src/__tests__/unit/commands/sort.ts +230 -0
- package/src/__tests__/unit/copy-paste.ts +686 -0
- package/src/__tests__/unit/event-handlers/index.ts +106 -0
- package/src/__tests__/unit/event-handlers.ts +202 -0
- package/src/__tests__/unit/fix-tables.ts +156 -0
- package/src/__tests__/unit/floating-toolbar.ts +95 -0
- package/src/__tests__/unit/handlers.ts +81 -0
- package/src/__tests__/unit/hover-selection.ts +277 -0
- package/src/__tests__/unit/index-with-fake-timers.ts +107 -0
- package/src/__tests__/unit/index.ts +986 -0
- package/src/__tests__/unit/keymap.ts +602 -0
- package/src/__tests__/unit/layout.ts +196 -0
- package/src/__tests__/unit/nodeviews/cell.ts +167 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/utils/resize-state.ts +33 -0
- package/src/__tests__/unit/sort-column.ts +512 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +499 -0
- package/src/__tests__/unit/transforms/delete-rows.ts +557 -0
- package/src/__tests__/unit/transforms/merging.ts +374 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +80 -0
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +95 -0
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +175 -0
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +266 -0
- package/src/__tests__/unit/ui/RowControls.tsx +301 -0
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +93 -0
- package/src/__tests__/unit/undo-redo.ts +202 -0
- package/src/__tests__/unit/utils/dom.ts +286 -0
- package/src/__tests__/unit/utils/nodes.ts +59 -0
- package/src/__tests__/unit/utils/row-controls.ts +176 -0
- package/src/__tests__/unit/utils/table.ts +93 -0
- package/src/__tests__/unit/utils.ts +652 -0
- package/src/plugins/table/__tests__/unit/commands/insert.ts +2 -2
- package/src/plugins/table/__tests__/unit/commands.ts +2 -2
- package/src/plugins/table/__tests__/unit/nodeviews/TableComponent.tsx +2 -2
- package/src/plugins/table/__tests__/unit/nodeviews/table.ts +1 -0
- package/src/plugins/table/event-handlers.ts +5 -6
- package/src/plugins/table/nodeviews/table.tsx +7 -0
- package/src/plugins/table/nodeviews/tableCell.tsx +5 -4
- package/src/plugins/table/nodeviews/types.ts +1 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/column-state.ts +1 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +6 -2
- package/src/plugins/table/toolbar.ts +0 -1
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +1 -1
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +1 -1
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +19 -1
- package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +16 -1
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +2 -2
- package/src/plugins/table/utils/column-controls.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 0.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e5b0deecf68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e5b0deecf68) - Add ability to localize for nodeview and add aria labels to RowControl and CornerControl
|
|
8
|
+
|
|
9
|
+
## 0.0.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`3b93848ef7e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3b93848ef7e) - This changes addresses a bug that occurs when a user is resizing tables and receives a TypeError (found on Sentry). This change adds a null check on columns existing in the growColumn and shrinkColumn functions so that we do not try to access a column that doesn't exist.
|
|
14
|
+
- [`a1b80e72418`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a1b80e72418) - This change addresses a RangeError on `getRelativeDomCellWidths` found on Sentry. It sets the check for `colspan` to be strict equals to one as the value comes from the first table row's colspan DOM attribute and cannot be negative.
|
|
15
|
+
|
|
16
|
+
Reference: https://sentry.io/organizations/atlassian-2y/issues/3434914334/?project=5988900
|
|
17
|
+
|
|
18
|
+
- [`b63aa34e1fe`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b63aa34e1fe) - This change addresses a bug that occurs when a user is clicking into an element inside the table and receives a RangeError (found on Sentry). This change adds bounds, NaN, and type checks when reading a cellIndex from tableMap so that we don't pass NaN or undefined to the call to nodeAt.
|
|
19
|
+
|
|
3
20
|
## 0.0.6
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -37,11 +37,6 @@ var _utils3 = require("./utils");
|
|
|
37
37
|
|
|
38
38
|
var _getAllowAddColumnCustomStep = require("./utils/get-allow-add-column-custom-step");
|
|
39
39
|
|
|
40
|
-
// import {
|
|
41
|
-
// isElementInTableCell,
|
|
42
|
-
// isLastItemMediaGroup,
|
|
43
|
-
// setNodeSelection,
|
|
44
|
-
// } from '@atlaskit/editor-core/src/utils';
|
|
45
40
|
// import { closestElement } from '@atlaskit/editor-core/src/utils/dom';
|
|
46
41
|
var isFocusingCalendar = function isFocusingCalendar(event) {
|
|
47
42
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
@@ -113,7 +108,13 @@ var handleClick = function handleClick(view, event) {
|
|
|
113
108
|
_view$state = view.state,
|
|
114
109
|
tr = _view$state.tr,
|
|
115
110
|
paragraph = _view$state.schema.nodes.paragraph;
|
|
116
|
-
var
|
|
111
|
+
var cellPos = map.map[cellIndex];
|
|
112
|
+
|
|
113
|
+
if (isNaN(cellPos) || cellPos === undefined || typeof cellPos !== 'number') {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var editorElement = table.node.nodeAt(cellPos);
|
|
117
118
|
/** Only if the last item is media group, insert a paragraph */
|
|
118
119
|
|
|
119
120
|
if ((0, _utils2.isLastItemMediaGroup)(editorElement)) {
|
|
@@ -81,7 +81,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
81
81
|
var _this;
|
|
82
82
|
|
|
83
83
|
(0, _classCallCheck2.default)(this, TableView);
|
|
84
|
-
_this = _super.call(this, props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
|
|
84
|
+
_this = _super.call(this, props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, undefined, undefined, props.hasIntlContext);
|
|
85
85
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getNode", function () {
|
|
86
86
|
return _this.node;
|
|
87
87
|
});
|
|
@@ -250,6 +250,7 @@ var createTableView = function createTableView(node, view, getPos, portalProvide
|
|
|
250
250
|
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
251
251
|
tableRenderOptimization = _getEditorFeatureFlag.tableRenderOptimization;
|
|
252
252
|
|
|
253
|
+
var hasIntlContext = true;
|
|
253
254
|
return new TableView({
|
|
254
255
|
node: node,
|
|
255
256
|
view: view,
|
|
@@ -260,7 +261,8 @@ var createTableView = function createTableView(node, view, getPos, portalProvide
|
|
|
260
261
|
options: options,
|
|
261
262
|
tableRenderOptimization: tableRenderOptimization,
|
|
262
263
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
263
|
-
getEditorFeatureFlags: getEditorFeatureFlags
|
|
264
|
+
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
265
|
+
hasIntlContext: hasIntlContext
|
|
264
266
|
}).init();
|
|
265
267
|
};
|
|
266
268
|
|
|
@@ -19,6 +19,9 @@ var _prosemirrorModel = require("prosemirror-model");
|
|
|
19
19
|
|
|
20
20
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
21
21
|
|
|
22
|
+
var DEFAULT_COL_SPAN = 1;
|
|
23
|
+
var DEFAULT_ROW_SPAN = 1;
|
|
24
|
+
|
|
22
25
|
var TableCellNodeView = /*#__PURE__*/function () {
|
|
23
26
|
function TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer) {
|
|
24
27
|
(0, _classCallCheck2.default)(this, TableCellNodeView);
|
|
@@ -62,10 +65,7 @@ var TableCellNodeView = /*#__PURE__*/function () {
|
|
|
62
65
|
// this can happen when undoing merge cells
|
|
63
66
|
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
defaultRowspan = 1;
|
|
67
|
-
|
|
68
|
-
if (colspan !== (node.attrs.colspan || defaultColspan) || rowspan !== (node.attrs.rowspan || defaultRowspan)) {
|
|
68
|
+
if (colspan !== (node.attrs.colspan || DEFAULT_COL_SPAN) || rowspan !== (node.attrs.rowspan || DEFAULT_ROW_SPAN)) {
|
|
69
69
|
return false;
|
|
70
70
|
} // added + changed attributes
|
|
71
71
|
|
|
@@ -54,7 +54,7 @@ var getCellsRefsInColumn = function getCellsRefsInColumn(columnIndex, table, tab
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
return cells;
|
|
57
|
-
}; // calculates column
|
|
57
|
+
}; // calculates column widths based on `cells` DOM refs
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
exports.getCellsRefsInColumn = getCellsRefsInColumn;
|
|
@@ -24,8 +24,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
24
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
25
|
|
|
26
26
|
var growColumn = function growColumn(state, colIndex, amount, selectedColumns) {
|
|
27
|
-
// can't grow the last column
|
|
28
|
-
if (!state.cols[colIndex + 1]) {
|
|
27
|
+
// can't grow if columns don't exist or it's the last column
|
|
28
|
+
if (!state.cols[colIndex] || !state.cols[colIndex + 1]) {
|
|
29
29
|
return state;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -47,7 +47,12 @@ var growColumn = function growColumn(state, colIndex, amount, selectedColumns) {
|
|
|
47
47
|
exports.growColumn = growColumn;
|
|
48
48
|
|
|
49
49
|
var shrinkColumn = function shrinkColumn(state, colIndex, amount, selectedColumns) {
|
|
50
|
-
//
|
|
50
|
+
// can't shrink if columns don't exist
|
|
51
|
+
if (!state.cols[colIndex] || !state.cols[colIndex + 1]) {
|
|
52
|
+
return state;
|
|
53
|
+
} // try to shrink dragging column by giving from the column to the right first
|
|
54
|
+
|
|
55
|
+
|
|
51
56
|
var res = moveSpaceFrom(state, colIndex, colIndex + 1, -amount);
|
|
52
57
|
var newState = res.state;
|
|
53
58
|
var isOverflownTable = (0, _resizeState.getTotalWidth)(newState) > newState.maxSize;
|
|
@@ -41,7 +41,6 @@ var _prosemirrorUtils = require("prosemirror-utils");
|
|
|
41
41
|
|
|
42
42
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
43
43
|
|
|
44
|
-
// TODO: ED-14403 investigate why these translations don't work
|
|
45
44
|
var messages = (0, _reactIntlNext.defineMessages)({
|
|
46
45
|
tableOptions: {
|
|
47
46
|
id: 'fabric.editor.tableOptions',
|
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.CornerControls = void 0;
|
|
11
11
|
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
|
|
@@ -25,6 +25,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
25
25
|
|
|
26
26
|
var _react = _interopRequireWildcard(require("react"));
|
|
27
27
|
|
|
28
|
+
var _reactIntlNext = require("react-intl-next");
|
|
29
|
+
|
|
28
30
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
29
31
|
|
|
30
32
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
@@ -43,15 +45,23 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
43
45
|
|
|
44
46
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
47
|
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
+
var messages = (0, _reactIntlNext.defineMessages)({
|
|
49
|
+
cornerControl: {
|
|
50
|
+
id: 'fabric.editor.cornerControl',
|
|
51
|
+
defaultMessage: 'Highlight table',
|
|
52
|
+
description: 'A button on the upper left corner of the table that shows up when the table is in focus. Clicking on it will select the entire table.'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
var CornerControlComponent = /*#__PURE__*/function (_Component) {
|
|
57
|
+
(0, _inherits2.default)(CornerControlComponent, _Component);
|
|
48
58
|
|
|
49
|
-
var _super = _createSuper(
|
|
59
|
+
var _super = _createSuper(CornerControlComponent);
|
|
50
60
|
|
|
51
|
-
function
|
|
61
|
+
function CornerControlComponent() {
|
|
52
62
|
var _this;
|
|
53
63
|
|
|
54
|
-
(0, _classCallCheck2.default)(this,
|
|
64
|
+
(0, _classCallCheck2.default)(this, CornerControlComponent);
|
|
55
65
|
|
|
56
66
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
57
67
|
args[_key] = arguments[_key];
|
|
@@ -93,14 +103,15 @@ var CornerControls = /*#__PURE__*/function (_Component) {
|
|
|
93
103
|
return _this;
|
|
94
104
|
}
|
|
95
105
|
|
|
96
|
-
(0, _createClass2.default)(
|
|
106
|
+
(0, _createClass2.default)(CornerControlComponent, [{
|
|
97
107
|
key: "render",
|
|
98
108
|
value: function render() {
|
|
99
109
|
var _this$props2 = this.props,
|
|
100
110
|
isInDanger = _this$props2.isInDanger,
|
|
101
111
|
tableRef = _this$props2.tableRef,
|
|
102
112
|
isHeaderColumnEnabled = _this$props2.isHeaderColumnEnabled,
|
|
103
|
-
isHeaderRowEnabled = _this$props2.isHeaderRowEnabled
|
|
113
|
+
isHeaderRowEnabled = _this$props2.isHeaderRowEnabled,
|
|
114
|
+
formatMessage = _this$props2.intl.formatMessage;
|
|
104
115
|
|
|
105
116
|
if (!tableRef) {
|
|
106
117
|
return null;
|
|
@@ -116,6 +127,7 @@ var CornerControls = /*#__PURE__*/function (_Component) {
|
|
|
116
127
|
top: this.props.stickyTop !== undefined ? "".concat(this.props.stickyTop, "px") : undefined
|
|
117
128
|
}
|
|
118
129
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
130
|
+
"aria-label": formatMessage(messages.cornerControl),
|
|
119
131
|
type: "button",
|
|
120
132
|
className: (0, _classnames.default)(_types.TableCssClassName.CONTROLS_CORNER_BUTTON, {
|
|
121
133
|
danger: isActive && isInDanger
|
|
@@ -134,7 +146,8 @@ var CornerControls = /*#__PURE__*/function (_Component) {
|
|
|
134
146
|
})));
|
|
135
147
|
}
|
|
136
148
|
}]);
|
|
137
|
-
return
|
|
149
|
+
return CornerControlComponent;
|
|
138
150
|
}(_react.Component);
|
|
139
151
|
|
|
140
|
-
|
|
152
|
+
var CornerControls = (0, _reactIntlNext.injectIntl)(CornerControlComponent);
|
|
153
|
+
exports.CornerControls = CornerControls;
|
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.RowControls = void 0;
|
|
11
11
|
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
|
|
@@ -25,6 +25,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
25
25
|
|
|
26
26
|
var _react = _interopRequireWildcard(require("react"));
|
|
27
27
|
|
|
28
|
+
var _reactIntlNext = require("react-intl-next");
|
|
29
|
+
|
|
28
30
|
var _commands = require("../../../commands");
|
|
29
31
|
|
|
30
32
|
var _types = require("../../../types");
|
|
@@ -41,15 +43,23 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
41
43
|
|
|
42
44
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
43
45
|
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
+
var messages = (0, _reactIntlNext.defineMessages)({
|
|
47
|
+
rowControl: {
|
|
48
|
+
id: 'fabric.editor.rowControl',
|
|
49
|
+
defaultMessage: 'Highlight row',
|
|
50
|
+
description: 'A button on the left of each row that shows up when the table is in focus. Clicking on it will select the entire row.'
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
var RowControlsComponent = /*#__PURE__*/function (_Component) {
|
|
55
|
+
(0, _inherits2.default)(RowControlsComponent, _Component);
|
|
46
56
|
|
|
47
|
-
var _super = _createSuper(
|
|
57
|
+
var _super = _createSuper(RowControlsComponent);
|
|
48
58
|
|
|
49
|
-
function
|
|
59
|
+
function RowControlsComponent() {
|
|
50
60
|
var _this;
|
|
51
61
|
|
|
52
|
-
(0, _classCallCheck2.default)(this,
|
|
62
|
+
(0, _classCallCheck2.default)(this, RowControlsComponent);
|
|
53
63
|
|
|
54
64
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
55
65
|
args[_key] = arguments[_key];
|
|
@@ -65,7 +75,7 @@ var RowControls = /*#__PURE__*/function (_Component) {
|
|
|
65
75
|
return _this;
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
(0, _createClass2.default)(
|
|
78
|
+
(0, _createClass2.default)(RowControlsComponent, [{
|
|
69
79
|
key: "render",
|
|
70
80
|
value: function render() {
|
|
71
81
|
var _this2 = this;
|
|
@@ -75,7 +85,8 @@ var RowControls = /*#__PURE__*/function (_Component) {
|
|
|
75
85
|
tableRef = _this$props.tableRef,
|
|
76
86
|
hoveredRows = _this$props.hoveredRows,
|
|
77
87
|
isInDanger = _this$props.isInDanger,
|
|
78
|
-
isResizing = _this$props.isResizing
|
|
88
|
+
isResizing = _this$props.isResizing,
|
|
89
|
+
formatMessage = _this$props.intl.formatMessage;
|
|
79
90
|
|
|
80
91
|
if (!tableRef) {
|
|
81
92
|
return null;
|
|
@@ -112,6 +123,7 @@ var RowControls = /*#__PURE__*/function (_Component) {
|
|
|
112
123
|
paddingTop: thisRowSticky ? "".concat(_consts.tableControlsSpacing, "px") : undefined
|
|
113
124
|
}
|
|
114
125
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
126
|
+
"aria-label": formatMessage(messages.rowControl),
|
|
115
127
|
type: "button",
|
|
116
128
|
className: "".concat(_types.TableCssClassName.ROW_CONTROLS_BUTTON, "\n ").concat(_types.TableCssClassName.CONTROLS_BUTTON, "\n "),
|
|
117
129
|
onClick: function onClick(event) {
|
|
@@ -129,7 +141,8 @@ var RowControls = /*#__PURE__*/function (_Component) {
|
|
|
129
141
|
})));
|
|
130
142
|
}
|
|
131
143
|
}]);
|
|
132
|
-
return
|
|
144
|
+
return RowControlsComponent;
|
|
133
145
|
}(_react.Component);
|
|
134
146
|
|
|
135
|
-
|
|
147
|
+
var RowControls = (0, _reactIntlNext.injectIntl)(RowControlsComponent);
|
|
148
|
+
exports.RowControls = RowControls;
|
|
@@ -31,11 +31,11 @@ var _commands = require("../../commands");
|
|
|
31
31
|
|
|
32
32
|
var _utils2 = require("../../utils");
|
|
33
33
|
|
|
34
|
-
var _CornerControls =
|
|
34
|
+
var _CornerControls = require("./CornerControls");
|
|
35
35
|
|
|
36
36
|
var _NumberColumn = _interopRequireDefault(require("./NumberColumn"));
|
|
37
37
|
|
|
38
|
-
var _RowControls =
|
|
38
|
+
var _RowControls = require("./RowControls");
|
|
39
39
|
|
|
40
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
41
41
|
|
|
@@ -201,7 +201,7 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
|
|
|
201
201
|
isResizing: isResizing,
|
|
202
202
|
selectRow: this.selectRow,
|
|
203
203
|
stickyTop: stickyTop
|
|
204
|
-
}) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.
|
|
204
|
+
}) : null, tableActive && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
|
|
205
205
|
editorView: editorView,
|
|
206
206
|
tableRef: tableRef,
|
|
207
207
|
isInDanger: isInDanger,
|
|
@@ -210,7 +210,7 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
|
|
|
210
210
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
211
211
|
hoveredRows: hoveredRows,
|
|
212
212
|
stickyTop: tableActive ? stickyTop : undefined
|
|
213
|
-
}), /*#__PURE__*/_react.default.createElement(_RowControls.
|
|
213
|
+
}), /*#__PURE__*/_react.default.createElement(_RowControls.RowControls, {
|
|
214
214
|
editorView: editorView,
|
|
215
215
|
tableRef: tableRef,
|
|
216
216
|
hoverRows: this.hoverRows,
|
|
@@ -149,7 +149,7 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
|
149
149
|
// for cells in a table with unchanged column widths,
|
|
150
150
|
// these are identified by the lack of colwidth data attribute,
|
|
151
151
|
// return equally partitioned total cell width in DOM for each cell.
|
|
152
|
-
if (colspan
|
|
152
|
+
if (colspan === 1 || !colwidth) {
|
|
153
153
|
return new Array(colspan).fill(width / colspan);
|
|
154
154
|
} // For cells that have colSpan > 1 and
|
|
155
155
|
// are part of a table with resized columns
|
package/dist/cjs/version.json
CHANGED
|
@@ -2,12 +2,7 @@ import { Selection, TextSelection } from 'prosemirror-state';
|
|
|
2
2
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
4
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
5
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
|
-
// isElementInTableCell,
|
|
7
|
-
// isLastItemMediaGroup,
|
|
8
|
-
// setNodeSelection,
|
|
9
|
-
// } from '@atlaskit/editor-core/src/utils';
|
|
10
|
-
|
|
5
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
11
6
|
import { isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils'; // import { closestElement } from '@atlaskit/editor-core/src/utils/dom';
|
|
12
7
|
|
|
13
8
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
@@ -89,7 +84,13 @@ export const handleClick = (view, event) => {
|
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
} = view;
|
|
92
|
-
const
|
|
87
|
+
const cellPos = map.map[cellIndex];
|
|
88
|
+
|
|
89
|
+
if (isNaN(cellPos) || cellPos === undefined || typeof cellPos !== 'number') {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const editorElement = table.node.nodeAt(cellPos);
|
|
93
94
|
/** Only if the last item is media group, insert a paragraph */
|
|
94
95
|
|
|
95
96
|
if (isLastItemMediaGroup(editorElement)) {
|
|
@@ -32,7 +32,7 @@ const toDOM = (node, props) => {
|
|
|
32
32
|
|
|
33
33
|
export default class TableView extends ReactNodeView {
|
|
34
34
|
constructor(props) {
|
|
35
|
-
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
|
|
35
|
+
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, undefined, undefined, props.hasIntlContext);
|
|
36
36
|
|
|
37
37
|
_defineProperty(this, "getNode", () => {
|
|
38
38
|
return this.node;
|
|
@@ -190,6 +190,7 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
190
190
|
const {
|
|
191
191
|
tableRenderOptimization
|
|
192
192
|
} = getEditorFeatureFlags();
|
|
193
|
+
const hasIntlContext = true;
|
|
193
194
|
return new TableView({
|
|
194
195
|
node,
|
|
195
196
|
view,
|
|
@@ -200,6 +201,7 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
|
|
|
200
201
|
options,
|
|
201
202
|
tableRenderOptimization,
|
|
202
203
|
getEditorContainerWidth,
|
|
203
|
-
getEditorFeatureFlags
|
|
204
|
+
getEditorFeatureFlags,
|
|
205
|
+
hasIntlContext
|
|
204
206
|
}).init();
|
|
205
207
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import uuid from 'uuid';
|
|
2
2
|
import { DOMSerializer } from 'prosemirror-model';
|
|
3
3
|
import { getCellDomAttrs, getCellAttrs } from '@atlaskit/adf-schema';
|
|
4
|
+
const DEFAULT_COL_SPAN = 1;
|
|
5
|
+
const DEFAULT_ROW_SPAN = 1;
|
|
4
6
|
export default class TableCellNodeView {
|
|
5
7
|
constructor(node, view, getPos, getEditorFeatureFlags, observer) {
|
|
6
8
|
this.view = view;
|
|
@@ -37,10 +39,7 @@ export default class TableCellNodeView {
|
|
|
37
39
|
} = getCellAttrs(this.dom); // need to rerender when colspan/rowspan in dom are different from the node attrs
|
|
38
40
|
// this can happen when undoing merge cells
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
defaultRowspan = 1;
|
|
42
|
-
|
|
43
|
-
if (colspan !== (node.attrs.colspan || defaultColspan) || rowspan !== (node.attrs.rowspan || defaultRowspan)) {
|
|
42
|
+
if (colspan !== (node.attrs.colspan || DEFAULT_COL_SPAN) || rowspan !== (node.attrs.rowspan || DEFAULT_ROW_SPAN)) {
|
|
44
43
|
return false;
|
|
45
44
|
} // added + changed attributes
|
|
46
45
|
|
|
@@ -35,7 +35,7 @@ export const getCellsRefsInColumn = (columnIndex, table, tableStart, domAtPos) =
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
return cells;
|
|
38
|
-
}; // calculates column
|
|
38
|
+
}; // calculates column widths based on `cells` DOM refs
|
|
39
39
|
|
|
40
40
|
export const calculateColumnWidth = (cells, calculateColumnWidthCb) => {
|
|
41
41
|
let maxColWidth = 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFreeSpace } from './column-state';
|
|
2
2
|
import { bulkColumnsResize, getTotalWidth } from './resize-state';
|
|
3
3
|
export const growColumn = (state, colIndex, amount, selectedColumns) => {
|
|
4
|
-
// can't grow the last column
|
|
5
|
-
if (!state.cols[colIndex + 1]) {
|
|
4
|
+
// can't grow if columns don't exist or it's the last column
|
|
5
|
+
if (!state.cols[colIndex] || !state.cols[colIndex + 1]) {
|
|
6
6
|
return state;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -21,7 +21,12 @@ export const growColumn = (state, colIndex, amount, selectedColumns) => {
|
|
|
21
21
|
return newState;
|
|
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] || !state.cols[colIndex + 1]) {
|
|
26
|
+
return state;
|
|
27
|
+
} // try to shrink dragging column by giving from the column to the right first
|
|
28
|
+
|
|
29
|
+
|
|
25
30
|
const res = moveSpaceFrom(state, colIndex, colIndex + 1, -amount);
|
|
26
31
|
let newState = res.state;
|
|
27
32
|
const isOverflownTable = getTotalWidth(newState) > newState.maxSize;
|
|
@@ -14,8 +14,7 @@ import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
|
14
14
|
import tableMessages from './ui/messages';
|
|
15
15
|
import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/ContextualMenu';
|
|
16
16
|
import { findParentDomRefOfType } from 'prosemirror-utils';
|
|
17
|
-
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
18
|
-
|
|
17
|
+
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
19
18
|
export const messages = defineMessages({
|
|
20
19
|
tableOptions: {
|
|
21
20
|
id: 'fabric.editor.tableOptions',
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
+
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
3
4
|
import classnames from 'classnames';
|
|
4
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
6
|
import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
|
|
6
7
|
import { clearHoverSelection, hoverTable } from '../../../commands';
|
|
7
8
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
8
|
-
|
|
9
|
+
const messages = defineMessages({
|
|
10
|
+
cornerControl: {
|
|
11
|
+
id: 'fabric.editor.cornerControl',
|
|
12
|
+
defaultMessage: 'Highlight table',
|
|
13
|
+
description: 'A button on the upper left corner of the table that shows up when the table is in focus. Clicking on it will select the entire table.'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
class CornerControlComponent extends Component {
|
|
9
18
|
constructor(...args) {
|
|
10
19
|
super(...args);
|
|
11
20
|
|
|
@@ -57,7 +66,10 @@ export default class CornerControls extends Component {
|
|
|
57
66
|
isInDanger,
|
|
58
67
|
tableRef,
|
|
59
68
|
isHeaderColumnEnabled,
|
|
60
|
-
isHeaderRowEnabled
|
|
69
|
+
isHeaderRowEnabled,
|
|
70
|
+
intl: {
|
|
71
|
+
formatMessage
|
|
72
|
+
}
|
|
61
73
|
} = this.props;
|
|
62
74
|
|
|
63
75
|
if (!tableRef) {
|
|
@@ -74,6 +86,7 @@ export default class CornerControls extends Component {
|
|
|
74
86
|
top: this.props.stickyTop !== undefined ? `${this.props.stickyTop}px` : undefined
|
|
75
87
|
}
|
|
76
88
|
}, /*#__PURE__*/React.createElement("button", {
|
|
89
|
+
"aria-label": formatMessage(messages.cornerControl),
|
|
77
90
|
type: "button",
|
|
78
91
|
className: classnames(ClassName.CONTROLS_CORNER_BUTTON, {
|
|
79
92
|
danger: isActive && isInDanger
|
|
@@ -92,4 +105,6 @@ export default class CornerControls extends Component {
|
|
|
92
105
|
})));
|
|
93
106
|
}
|
|
94
107
|
|
|
95
|
-
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const CornerControls = injectIntl(CornerControlComponent);
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
+
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
3
4
|
import { clearHoverSelection } from '../../../commands';
|
|
4
5
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
5
6
|
import { getRowClassNames, getRowHeights, getRowsParams } from '../../../utils';
|
|
6
7
|
import { tableControlsSpacing, tableToolbarSize } from '../../consts';
|
|
7
|
-
|
|
8
|
+
const messages = defineMessages({
|
|
9
|
+
rowControl: {
|
|
10
|
+
id: 'fabric.editor.rowControl',
|
|
11
|
+
defaultMessage: 'Highlight row',
|
|
12
|
+
description: 'A button on the left of each row that shows up when the table is in focus. Clicking on it will select the entire row.'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
class RowControlsComponent extends Component {
|
|
8
17
|
constructor(...args) {
|
|
9
18
|
super(...args);
|
|
10
19
|
|
|
@@ -23,7 +32,10 @@ export default class RowControls extends Component {
|
|
|
23
32
|
tableRef,
|
|
24
33
|
hoveredRows,
|
|
25
34
|
isInDanger,
|
|
26
|
-
isResizing
|
|
35
|
+
isResizing,
|
|
36
|
+
intl: {
|
|
37
|
+
formatMessage
|
|
38
|
+
}
|
|
27
39
|
} = this.props;
|
|
28
40
|
|
|
29
41
|
if (!tableRef) {
|
|
@@ -64,6 +76,7 @@ export default class RowControls extends Component {
|
|
|
64
76
|
paddingTop: thisRowSticky ? `${tableControlsSpacing}px` : undefined
|
|
65
77
|
}
|
|
66
78
|
}, /*#__PURE__*/React.createElement("button", {
|
|
79
|
+
"aria-label": formatMessage(messages.rowControl),
|
|
67
80
|
type: "button",
|
|
68
81
|
className: `${ClassName.ROW_CONTROLS_BUTTON}
|
|
69
82
|
${ClassName.CONTROLS_BUTTON}
|
|
@@ -79,4 +92,6 @@ export default class RowControls extends Component {
|
|
|
79
92
|
})));
|
|
80
93
|
}
|
|
81
94
|
|
|
82
|
-
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const RowControls = injectIntl(RowControlsComponent);
|
|
@@ -3,9 +3,9 @@ import React, { Component } from 'react';
|
|
|
3
3
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { hoverRows, selectRow } from '../../commands';
|
|
5
5
|
import { isSelectionUpdated } from '../../utils';
|
|
6
|
-
import CornerControls from './CornerControls';
|
|
6
|
+
import { CornerControls } from './CornerControls';
|
|
7
7
|
import NumberColumn from './NumberColumn';
|
|
8
|
-
import RowControls from './RowControls';
|
|
8
|
+
import { RowControls } from './RowControls';
|
|
9
9
|
export default class TableFloatingControls extends Component {
|
|
10
10
|
constructor(...args) {
|
|
11
11
|
super(...args);
|
|
@@ -115,7 +115,7 @@ const getRelativeDomCellWidths = ({
|
|
|
115
115
|
// for cells in a table with unchanged column widths,
|
|
116
116
|
// these are identified by the lack of colwidth data attribute,
|
|
117
117
|
// return equally partitioned total cell width in DOM for each cell.
|
|
118
|
-
if (colspan
|
|
118
|
+
if (colspan === 1 || !colwidth) {
|
|
119
119
|
return new Array(colspan).fill(width / colspan);
|
|
120
120
|
} // For cells that have colSpan > 1 and
|
|
121
121
|
// are part of a table with resized columns
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,12 +3,7 @@ import { Selection, TextSelection } from '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 { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
6
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
|
-
// isElementInTableCell,
|
|
8
|
-
// isLastItemMediaGroup,
|
|
9
|
-
// setNodeSelection,
|
|
10
|
-
// } from '@atlaskit/editor-core/src/utils';
|
|
11
|
-
|
|
6
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
12
7
|
import { isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils'; // import { closestElement } from '@atlaskit/editor-core/src/utils/dom';
|
|
13
8
|
|
|
14
9
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
@@ -84,7 +79,13 @@ export var handleClick = function handleClick(view, event) {
|
|
|
84
79
|
_view$state = view.state,
|
|
85
80
|
tr = _view$state.tr,
|
|
86
81
|
paragraph = _view$state.schema.nodes.paragraph;
|
|
87
|
-
var
|
|
82
|
+
var cellPos = map.map[cellIndex];
|
|
83
|
+
|
|
84
|
+
if (isNaN(cellPos) || cellPos === undefined || typeof cellPos !== 'number') {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var editorElement = table.node.nodeAt(cellPos);
|
|
88
89
|
/** Only if the last item is media group, insert a paragraph */
|
|
89
90
|
|
|
90
91
|
if (isLastItemMediaGroup(editorElement)) {
|