@atlaskit/editor-plugin-table 0.0.5 → 0.0.7
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/commands-with-analytics.js +6 -0
- package/dist/cjs/plugins/table/event-handlers.js +7 -6
- 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/utils/column-controls.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands-with-analytics.js +6 -0
- package/dist/es2019/plugins/table/event-handlers.js +8 -7
- 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/utils/column-controls.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands-with-analytics.js +6 -0
- package/dist/esm/plugins/table/event-handlers.js +8 -7
- 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/utils/column-controls.js +1 -1
- package/dist/esm/version.json +1 -1
- package/package.json +9 -7
- package/report.api.md +13 -6
- 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 +106 -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/commands-with-analytics.ts +3 -0
- package/src/plugins/table/event-handlers.ts +5 -6
- package/src/plugins/table/nodeviews/tableCell.tsx +5 -4
- 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/utils/column-controls.ts +1 -1
- package/tmp/api-report-tmp.d.ts +91 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 0.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`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.
|
|
8
|
+
- [`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.
|
|
9
|
+
|
|
10
|
+
Reference: https://sentry.io/organizations/atlassian-2y/issues/3434914334/?project=5988900
|
|
11
|
+
|
|
12
|
+
- [`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.
|
|
13
|
+
|
|
14
|
+
## 0.0.6
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 0.0.5
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -99,6 +99,8 @@ var mergeCellsWithAnalytics = function mergeCellsWithAnalytics(editorAnalyticsAP
|
|
|
99
99
|
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
100
100
|
actionSubjectId: null,
|
|
101
101
|
attributes: {
|
|
102
|
+
inputMethod: _analytics.INPUT_METHOD.CONTEXT_MENU,
|
|
103
|
+
// TODO: merge with floating toolbar once command is updated
|
|
102
104
|
horizontalCells: horizontalCells,
|
|
103
105
|
verticalCells: verticalCells,
|
|
104
106
|
totalCells: totalCells,
|
|
@@ -137,6 +139,8 @@ var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI)
|
|
|
137
139
|
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
138
140
|
actionSubjectId: null,
|
|
139
141
|
attributes: {
|
|
142
|
+
inputMethod: _analytics.INPUT_METHOD.CONTEXT_MENU,
|
|
143
|
+
// TODO: merge with floating toolbar once command is updated
|
|
140
144
|
horizontalCells: horizontalCells,
|
|
141
145
|
verticalCells: verticalCells,
|
|
142
146
|
totalCells: horizontalCells * verticalCells,
|
|
@@ -170,6 +174,8 @@ var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
|
|
|
170
174
|
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
171
175
|
actionSubjectId: null,
|
|
172
176
|
attributes: {
|
|
177
|
+
inputMethod: _analytics.INPUT_METHOD.CONTEXT_MENU,
|
|
178
|
+
// TODO: merge with floating toolbar once command is updated
|
|
173
179
|
cellColor: (_adfSchema.tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
|
|
174
180
|
horizontalCells: horizontalCells,
|
|
175
181
|
verticalCells: verticalCells,
|
|
@@ -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)) {
|
|
@@ -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;
|
|
@@ -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
|
@@ -59,6 +59,8 @@ export const mergeCellsWithAnalytics = editorAnalyticsAPI => withEditorAnalytics
|
|
|
59
59
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
60
60
|
actionSubjectId: null,
|
|
61
61
|
attributes: {
|
|
62
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
63
|
+
// TODO: merge with floating toolbar once command is updated
|
|
62
64
|
horizontalCells,
|
|
63
65
|
verticalCells,
|
|
64
66
|
totalCells,
|
|
@@ -93,6 +95,8 @@ export const splitCellWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsA
|
|
|
93
95
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
94
96
|
actionSubjectId: null,
|
|
95
97
|
attributes: {
|
|
98
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
99
|
+
// TODO: merge with floating toolbar once command is updated
|
|
96
100
|
horizontalCells,
|
|
97
101
|
verticalCells,
|
|
98
102
|
totalCells: horizontalCells * verticalCells,
|
|
@@ -120,6 +124,8 @@ export const setColorWithAnalytics = editorAnalyticsAPI => (cellColor, targetCel
|
|
|
120
124
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
121
125
|
actionSubjectId: null,
|
|
122
126
|
attributes: {
|
|
127
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
128
|
+
// TODO: merge with floating toolbar once command is updated
|
|
123
129
|
cellColor: (tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
|
|
124
130
|
horizontalCells,
|
|
125
131
|
verticalCells,
|
|
@@ -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)) {
|
|
@@ -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;
|
|
@@ -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
|
@@ -70,6 +70,8 @@ export var mergeCellsWithAnalytics = function mergeCellsWithAnalytics(editorAnal
|
|
|
70
70
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
71
71
|
actionSubjectId: null,
|
|
72
72
|
attributes: {
|
|
73
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
74
|
+
// TODO: merge with floating toolbar once command is updated
|
|
73
75
|
horizontalCells: horizontalCells,
|
|
74
76
|
verticalCells: verticalCells,
|
|
75
77
|
totalCells: totalCells,
|
|
@@ -105,6 +107,8 @@ export var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyt
|
|
|
105
107
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
106
108
|
actionSubjectId: null,
|
|
107
109
|
attributes: {
|
|
110
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
111
|
+
// TODO: merge with floating toolbar once command is updated
|
|
108
112
|
horizontalCells: horizontalCells,
|
|
109
113
|
verticalCells: verticalCells,
|
|
110
114
|
totalCells: horizontalCells * verticalCells,
|
|
@@ -135,6 +139,8 @@ export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalytic
|
|
|
135
139
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
136
140
|
actionSubjectId: null,
|
|
137
141
|
attributes: {
|
|
142
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
143
|
+
// TODO: merge with floating toolbar once command is updated
|
|
138
144
|
cellColor: (tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
|
|
139
145
|
horizontalCells: horizontalCells,
|
|
140
146
|
verticalCells: verticalCells,
|
|
@@ -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)) {
|
|
@@ -4,6 +4,8 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
4
4
|
import uuid from 'uuid';
|
|
5
5
|
import { DOMSerializer } from 'prosemirror-model';
|
|
6
6
|
import { getCellDomAttrs, getCellAttrs } from '@atlaskit/adf-schema';
|
|
7
|
+
var DEFAULT_COL_SPAN = 1;
|
|
8
|
+
var DEFAULT_ROW_SPAN = 1;
|
|
7
9
|
|
|
8
10
|
var TableCellNodeView = /*#__PURE__*/function () {
|
|
9
11
|
function TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer) {
|
|
@@ -49,10 +51,7 @@ var TableCellNodeView = /*#__PURE__*/function () {
|
|
|
49
51
|
// this can happen when undoing merge cells
|
|
50
52
|
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
defaultRowspan = 1;
|
|
54
|
-
|
|
55
|
-
if (colspan !== (node.attrs.colspan || defaultColspan) || rowspan !== (node.attrs.rowspan || defaultRowspan)) {
|
|
54
|
+
if (colspan !== (node.attrs.colspan || DEFAULT_COL_SPAN) || rowspan !== (node.attrs.rowspan || DEFAULT_ROW_SPAN)) {
|
|
56
55
|
return false;
|
|
57
56
|
} // added + changed attributes
|
|
58
57
|
|
|
@@ -35,7 +35,7 @@ export var getCellsRefsInColumn = function getCellsRefsInColumn(columnIndex, tab
|
|
|
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 var calculateColumnWidth = function calculateColumnWidth(cells, calculateColumnWidthCb) {
|
|
41
41
|
var maxColWidth = 0;
|
|
@@ -9,8 +9,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
9
9
|
import { getFreeSpace } from './column-state';
|
|
10
10
|
import { bulkColumnsResize, getTotalWidth } from './resize-state';
|
|
11
11
|
export var growColumn = function growColumn(state, colIndex, amount, selectedColumns) {
|
|
12
|
-
// can't grow the last column
|
|
13
|
-
if (!state.cols[colIndex + 1]) {
|
|
12
|
+
// can't grow if columns don't exist or it's the last column
|
|
13
|
+
if (!state.cols[colIndex] || !state.cols[colIndex + 1]) {
|
|
14
14
|
return state;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -29,7 +29,12 @@ export var growColumn = function growColumn(state, colIndex, amount, selectedCol
|
|
|
29
29
|
return newState;
|
|
30
30
|
};
|
|
31
31
|
export var shrinkColumn = function shrinkColumn(state, colIndex, amount, selectedColumns) {
|
|
32
|
-
//
|
|
32
|
+
// can't shrink if columns don't exist
|
|
33
|
+
if (!state.cols[colIndex] || !state.cols[colIndex + 1]) {
|
|
34
|
+
return state;
|
|
35
|
+
} // try to shrink dragging column by giving from the column to the right first
|
|
36
|
+
|
|
37
|
+
|
|
33
38
|
var res = moveSpaceFrom(state, colIndex, colIndex + 1, -amount);
|
|
34
39
|
var newState = res.state;
|
|
35
40
|
var isOverflownTable = getTotalWidth(newState) > newState.maxSize;
|
|
@@ -119,7 +119,7 @@ var getRelativeDomCellWidths = function getRelativeDomCellWidths(_ref) {
|
|
|
119
119
|
// for cells in a table with unchanged column widths,
|
|
120
120
|
// these are identified by the lack of colwidth data attribute,
|
|
121
121
|
// return equally partitioned total cell width in DOM for each cell.
|
|
122
|
-
if (colspan
|
|
122
|
+
if (colspan === 1 || !colwidth) {
|
|
123
123
|
return new Array(colspan).fill(width / colspan);
|
|
124
124
|
} // For cells that have colSpan > 1 and
|
|
125
125
|
// are part of a table with resized columns
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaskit/adf-schema": "^24.0.0",
|
|
28
|
-
"@atlaskit/editor-common": "^
|
|
28
|
+
"@atlaskit/editor-common": "^70.1.0",
|
|
29
29
|
"@atlaskit/editor-shared-styles": "^2.2.0",
|
|
30
|
-
"@atlaskit/editor-tables": "^2.
|
|
31
|
-
"@atlaskit/icon": "^21.
|
|
30
|
+
"@atlaskit/editor-tables": "^2.2.0",
|
|
31
|
+
"@atlaskit/icon": "^21.11.0",
|
|
32
32
|
"@atlaskit/theme": "^12.1.0",
|
|
33
33
|
"@atlaskit/tokens": "^0.10.0",
|
|
34
|
-
"@atlaskit/tooltip": "^17.
|
|
34
|
+
"@atlaskit/tooltip": "^17.6.0",
|
|
35
35
|
"@babel/runtime": "^7.0.0",
|
|
36
36
|
"@emotion/react": "^11.7.1",
|
|
37
37
|
"@types/prosemirror-state": "^1.2.0",
|
|
@@ -56,13 +56,15 @@
|
|
|
56
56
|
"styled-components": "^3.2.6"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
+
"@atlaskit/analytics-next": "^8.3.3",
|
|
59
60
|
"@atlaskit/button": "^16.3.0",
|
|
60
|
-
"@atlaskit/editor-core": "^
|
|
61
|
+
"@atlaskit/editor-core": "^173.0.0",
|
|
61
62
|
"@atlaskit/editor-test-helpers": "^17.2.0",
|
|
62
63
|
"@atlaskit/link-provider": "^1.2.6",
|
|
63
|
-
"@atlaskit/logo": "^13.
|
|
64
|
+
"@atlaskit/logo": "^13.10.0",
|
|
64
65
|
"@atlaskit/media-integration-test-helpers": "^2.6.0",
|
|
65
66
|
"@atlaskit/synchrony-test-helpers": "^2.3.0",
|
|
67
|
+
"@atlaskit/util-data-test": "^17.5.5",
|
|
66
68
|
"@atlaskit/visual-regression": "*",
|
|
67
69
|
"@atlaskit/webdriver-runner": "*",
|
|
68
70
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
package/report.api.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
<!-- API Report Version: 2.2 -->
|
|
2
|
+
|
|
1
3
|
## API Report File for "@atlaskit/editor-plugin-table"
|
|
2
4
|
|
|
3
|
-
> Do not edit this file.
|
|
5
|
+
> Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
|
|
6
|
+
> [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
7
|
+
|
|
8
|
+
### Table of contents
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
Generated API Report version: 2.0
|
|
7
|
-
-->
|
|
10
|
+
- [Main Entry Types](#main-entry-types)
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
### Main Entry Types
|
|
13
|
+
|
|
14
|
+
<!--SECTION START: Main Entry Types-->
|
|
10
15
|
|
|
11
16
|
```ts
|
|
12
17
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
@@ -16,7 +21,7 @@ import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
|
16
21
|
import { TableLayout } from '@atlaskit/adf-schema';
|
|
17
22
|
|
|
18
23
|
// @public (undocumented)
|
|
19
|
-
type PermittedLayoutsDescriptor = TableLayout[]
|
|
24
|
+
type PermittedLayoutsDescriptor = 'all' | TableLayout[];
|
|
20
25
|
|
|
21
26
|
// @public (undocumented)
|
|
22
27
|
interface PluginConfig {
|
|
@@ -95,3 +100,5 @@ export const tablesPlugin: (
|
|
|
95
100
|
|
|
96
101
|
// (No @packageDocumentation comment for this package)
|
|
97
102
|
```
|
|
103
|
+
|
|
104
|
+
<!--SECTION END: Main Entry Types-->
|