@atlaskit/editor-plugin-table 1.0.0 → 1.0.1
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 +6 -0
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +5 -1
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +1 -0
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/cjs/plugins/table/utils/decoration.js +19 -12
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +5 -1
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -2
- package/dist/es2019/plugins/table/utils/decoration.js +22 -13
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/tableCell.js +5 -1
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -2
- package/dist/esm/plugins/table/utils/decoration.js +19 -12
- package/dist/esm/version.json +1 -1
- package/package.json +1 -1
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +2 -2
- package/src/plugins/table/nodeviews/tableCell.tsx +3 -1
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +1 -0
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -1
- package/src/plugins/table/utils/decoration.ts +36 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`04f178ea323`](https://bitbucket.org/atlassian/atlassian-frontend/commits/04f178ea323) - [ux] ED-15823 - Table cells on the second column would change their color upon unchecking "Header Column" table option when the selection cursor was placed in the 3rd column. This was caused by a view update not identifying the cells to update correctly. This was causing table data cells to be changed to table header cells.
|
|
8
|
+
|
|
3
9
|
## 1.0.0
|
|
4
10
|
|
|
5
11
|
### Major Changes
|
|
@@ -106,7 +106,11 @@ var TableCellNodeView = /*#__PURE__*/function () {
|
|
|
106
106
|
key: "update",
|
|
107
107
|
value: function update(node) {
|
|
108
108
|
var didUpdate = this.updateNodeView(node);
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
if (didUpdate) {
|
|
111
|
+
this.node = node;
|
|
112
|
+
}
|
|
113
|
+
|
|
110
114
|
return didUpdate;
|
|
111
115
|
}
|
|
112
116
|
}, {
|
|
@@ -9,8 +9,6 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
|
9
9
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
11
|
|
|
12
|
-
var _prosemirrorView = require("prosemirror-view");
|
|
13
|
-
|
|
14
12
|
var _types = require("../../../types");
|
|
15
13
|
|
|
16
14
|
var _decoration = require("../../../utils/decoration");
|
|
@@ -80,7 +78,7 @@ var buildColumnControlsDecorations = function buildColumnControlsDecorations(_re
|
|
|
80
78
|
var decorationSet = _ref6.decorationSet,
|
|
81
79
|
tr = _ref6.tr;
|
|
82
80
|
return (0, _composeDecorations.composeDecorations)([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration, maybeUpdateColumnControlsDecoration])({
|
|
83
|
-
decorationSet:
|
|
81
|
+
decorationSet: decorationSet,
|
|
84
82
|
tr: tr
|
|
85
83
|
});
|
|
86
84
|
};
|
|
@@ -163,16 +163,21 @@ var createColumnControlsDecoration = function createColumnControlsDecoration(sel
|
|
|
163
163
|
var cells = (0, _utils.getCellsInRow)(0)(selection) || [];
|
|
164
164
|
var index = 0;
|
|
165
165
|
return cells.map(function (cell) {
|
|
166
|
-
var colspan = cell.node.attrs.colspan || 1;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
var colspan = cell.node.attrs.colspan || 1; // It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
167
|
+
// and we want to avoid value leak
|
|
168
|
+
|
|
169
|
+
var startIndex = index;
|
|
170
|
+
var endIndex = startIndex + colspan; // The next cell start index will commence from the current cell end index.
|
|
171
|
+
|
|
172
|
+
index = endIndex;
|
|
172
173
|
return _prosemirrorView.Decoration.widget(cell.pos + 1, function () {
|
|
174
|
+
var element = document.createElement('div');
|
|
175
|
+
element.classList.add(_types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
176
|
+
element.dataset.startIndex = "".concat(startIndex);
|
|
177
|
+
element.dataset.endIndex = "".concat(endIndex);
|
|
173
178
|
return element;
|
|
174
179
|
}, {
|
|
175
|
-
key: "".concat(_types.TableDecorations.COLUMN_CONTROLS_DECORATIONS, "_").concat(
|
|
180
|
+
key: "".concat(_types.TableDecorations.COLUMN_CONTROLS_DECORATIONS, "_").concat(endIndex),
|
|
176
181
|
// this decoration should be the first one, even before gap cursor.
|
|
177
182
|
side: -100
|
|
178
183
|
});
|
|
@@ -288,12 +293,14 @@ var createResizeHandleDecoration = function createResizeHandleDecoration(tr, row
|
|
|
288
293
|
}
|
|
289
294
|
|
|
290
295
|
var createResizerHandleDecoration = function createResizerHandleDecoration(cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) {
|
|
291
|
-
var element = document.createElement('div');
|
|
292
|
-
element.classList.add(_types.TableCssClassName.RESIZE_HANDLE_DECORATION);
|
|
293
|
-
element.dataset.startIndex = "".concat(cellColumnPositioning.left);
|
|
294
|
-
element.dataset.endIndex = "".concat(cellColumnPositioning.right);
|
|
295
296
|
var position = cellPos + cellNode.nodeSize - 1;
|
|
296
|
-
return _prosemirrorView.Decoration.widget(position,
|
|
297
|
+
return _prosemirrorView.Decoration.widget(position, function () {
|
|
298
|
+
var element = document.createElement('div');
|
|
299
|
+
element.classList.add(_types.TableCssClassName.RESIZE_HANDLE_DECORATION);
|
|
300
|
+
element.dataset.startIndex = "".concat(cellColumnPositioning.left);
|
|
301
|
+
element.dataset.endIndex = "".concat(cellColumnPositioning.right);
|
|
302
|
+
return element;
|
|
303
|
+
}, {
|
|
297
304
|
key: "".concat(_types.TableDecorations.COLUMN_RESIZING_HANDLE, "_").concat(rowIndex, "_").concat(columnIndex)
|
|
298
305
|
});
|
|
299
306
|
};
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
2
2
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
|
-
import { DecorationSet } from 'prosemirror-view';
|
|
4
3
|
import { TableDecorations } from '../../../types';
|
|
5
4
|
import { createColumnControlsDecoration, createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../../utils/decoration';
|
|
6
5
|
import { composeDecorations } from './compose-decorations';
|
|
@@ -61,7 +60,7 @@ export const buildColumnControlsDecorations = ({
|
|
|
61
60
|
tr
|
|
62
61
|
}) => {
|
|
63
62
|
return composeDecorations([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration, maybeUpdateColumnControlsDecoration])({
|
|
64
|
-
decorationSet
|
|
63
|
+
decorationSet,
|
|
65
64
|
tr
|
|
66
65
|
});
|
|
67
66
|
};
|
|
@@ -110,14 +110,21 @@ export const createColumnControlsDecoration = selection => {
|
|
|
110
110
|
const cells = getCellsInRow(0)(selection) || [];
|
|
111
111
|
let index = 0;
|
|
112
112
|
return cells.map(cell => {
|
|
113
|
-
const colspan = cell.node.attrs.colspan || 1;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
const colspan = cell.node.attrs.colspan || 1; // It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
114
|
+
// and we want to avoid value leak
|
|
115
|
+
|
|
116
|
+
const startIndex = index;
|
|
117
|
+
const endIndex = startIndex + colspan; // The next cell start index will commence from the current cell end index.
|
|
118
|
+
|
|
119
|
+
index = endIndex;
|
|
120
|
+
return Decoration.widget(cell.pos + 1, () => {
|
|
121
|
+
const element = document.createElement('div');
|
|
122
|
+
element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
123
|
+
element.dataset.startIndex = `${startIndex}`;
|
|
124
|
+
element.dataset.endIndex = `${endIndex}`;
|
|
125
|
+
return element;
|
|
126
|
+
}, {
|
|
127
|
+
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${endIndex}`,
|
|
121
128
|
// this decoration should be the first one, even before gap cursor.
|
|
122
129
|
side: -100
|
|
123
130
|
});
|
|
@@ -226,12 +233,14 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
|
|
|
226
233
|
}
|
|
227
234
|
|
|
228
235
|
const createResizerHandleDecoration = (cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) => {
|
|
229
|
-
const element = document.createElement('div');
|
|
230
|
-
element.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
231
|
-
element.dataset.startIndex = `${cellColumnPositioning.left}`;
|
|
232
|
-
element.dataset.endIndex = `${cellColumnPositioning.right}`;
|
|
233
236
|
const position = cellPos + cellNode.nodeSize - 1;
|
|
234
|
-
return Decoration.widget(position,
|
|
237
|
+
return Decoration.widget(position, () => {
|
|
238
|
+
const element = document.createElement('div');
|
|
239
|
+
element.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
240
|
+
element.dataset.startIndex = `${cellColumnPositioning.left}`;
|
|
241
|
+
element.dataset.endIndex = `${cellColumnPositioning.right}`;
|
|
242
|
+
return element;
|
|
243
|
+
}, {
|
|
235
244
|
key: `${TableDecorations.COLUMN_RESIZING_HANDLE}_${rowIndex}_${columnIndex}`
|
|
236
245
|
});
|
|
237
246
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -92,7 +92,11 @@ var TableCellNodeView = /*#__PURE__*/function () {
|
|
|
92
92
|
key: "update",
|
|
93
93
|
value: function update(node) {
|
|
94
94
|
var didUpdate = this.updateNodeView(node);
|
|
95
|
-
|
|
95
|
+
|
|
96
|
+
if (didUpdate) {
|
|
97
|
+
this.node = node;
|
|
98
|
+
}
|
|
99
|
+
|
|
96
100
|
return didUpdate;
|
|
97
101
|
}
|
|
98
102
|
}, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
2
2
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
|
-
import { DecorationSet } from 'prosemirror-view';
|
|
4
3
|
import { TableDecorations } from '../../../types';
|
|
5
4
|
import { createColumnControlsDecoration, createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../../utils/decoration';
|
|
6
5
|
import { composeDecorations } from './compose-decorations';
|
|
@@ -65,7 +64,7 @@ export var buildColumnControlsDecorations = function buildColumnControlsDecorati
|
|
|
65
64
|
var decorationSet = _ref6.decorationSet,
|
|
66
65
|
tr = _ref6.tr;
|
|
67
66
|
return composeDecorations([removeColumnControlsSelectedDecoration, removeControlsHoverDecoration, maybeUpdateColumnSelectedDecoration, maybeUpdateColumnControlsDecoration])({
|
|
68
|
-
decorationSet:
|
|
67
|
+
decorationSet: decorationSet,
|
|
69
68
|
tr: tr
|
|
70
69
|
});
|
|
71
70
|
};
|
|
@@ -133,16 +133,21 @@ export var createColumnControlsDecoration = function createColumnControlsDecorat
|
|
|
133
133
|
var cells = getCellsInRow(0)(selection) || [];
|
|
134
134
|
var index = 0;
|
|
135
135
|
return cells.map(function (cell) {
|
|
136
|
-
var colspan = cell.node.attrs.colspan || 1;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
var colspan = cell.node.attrs.colspan || 1; // It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
137
|
+
// and we want to avoid value leak
|
|
138
|
+
|
|
139
|
+
var startIndex = index;
|
|
140
|
+
var endIndex = startIndex + colspan; // The next cell start index will commence from the current cell end index.
|
|
141
|
+
|
|
142
|
+
index = endIndex;
|
|
142
143
|
return Decoration.widget(cell.pos + 1, function () {
|
|
144
|
+
var element = document.createElement('div');
|
|
145
|
+
element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
146
|
+
element.dataset.startIndex = "".concat(startIndex);
|
|
147
|
+
element.dataset.endIndex = "".concat(endIndex);
|
|
143
148
|
return element;
|
|
144
149
|
}, {
|
|
145
|
-
key: "".concat(TableDecorations.COLUMN_CONTROLS_DECORATIONS, "_").concat(
|
|
150
|
+
key: "".concat(TableDecorations.COLUMN_CONTROLS_DECORATIONS, "_").concat(endIndex),
|
|
146
151
|
// this decoration should be the first one, even before gap cursor.
|
|
147
152
|
side: -100
|
|
148
153
|
});
|
|
@@ -253,12 +258,14 @@ export var createResizeHandleDecoration = function createResizeHandleDecoration(
|
|
|
253
258
|
}
|
|
254
259
|
|
|
255
260
|
var createResizerHandleDecoration = function createResizerHandleDecoration(cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) {
|
|
256
|
-
var element = document.createElement('div');
|
|
257
|
-
element.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
258
|
-
element.dataset.startIndex = "".concat(cellColumnPositioning.left);
|
|
259
|
-
element.dataset.endIndex = "".concat(cellColumnPositioning.right);
|
|
260
261
|
var position = cellPos + cellNode.nodeSize - 1;
|
|
261
|
-
return Decoration.widget(position,
|
|
262
|
+
return Decoration.widget(position, function () {
|
|
263
|
+
var element = document.createElement('div');
|
|
264
|
+
element.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
265
|
+
element.dataset.startIndex = "".concat(cellColumnPositioning.left);
|
|
266
|
+
element.dataset.endIndex = "".concat(cellColumnPositioning.right);
|
|
267
|
+
return element;
|
|
268
|
+
}, {
|
|
262
269
|
key: "".concat(TableDecorations.COLUMN_RESIZING_HANDLE, "_").concat(rowIndex, "_").concat(columnIndex)
|
|
263
270
|
});
|
|
264
271
|
};
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
version https://git-lfs.github.com/spec/v1
|
|
2
|
-
oid sha256:
|
|
3
|
-
size
|
|
2
|
+
oid sha256:185a432916fe30487eec362617c510dd132f2a37a56bfceeca674da4c6512dc9
|
|
3
|
+
size 13986
|
|
@@ -83,5 +83,5 @@ export const buildColumnControlsDecorations: DecorationTransformer = ({
|
|
|
83
83
|
removeControlsHoverDecoration,
|
|
84
84
|
maybeUpdateColumnSelectedDecoration,
|
|
85
85
|
maybeUpdateColumnControlsDecoration,
|
|
86
|
-
])({ decorationSet
|
|
86
|
+
])({ decorationSet, tr });
|
|
87
87
|
};
|
|
@@ -182,17 +182,29 @@ export const createColumnControlsDecoration = (
|
|
|
182
182
|
let index = 0;
|
|
183
183
|
return cells.map((cell) => {
|
|
184
184
|
const colspan = (cell.node.attrs as CellAttributes).colspan || 1;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
185
|
+
// It's important these values are scoped locally as the widget callback could be executed anytime in the future
|
|
186
|
+
// and we want to avoid value leak
|
|
187
|
+
const startIndex = index;
|
|
188
|
+
const endIndex = startIndex + colspan;
|
|
189
|
+
|
|
190
|
+
// The next cell start index will commence from the current cell end index.
|
|
191
|
+
index = endIndex;
|
|
192
|
+
|
|
193
|
+
return Decoration.widget(
|
|
194
|
+
cell.pos + 1,
|
|
195
|
+
() => {
|
|
196
|
+
const element = document.createElement('div');
|
|
197
|
+
element.classList.add(ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
198
|
+
element.dataset.startIndex = `${startIndex}`;
|
|
199
|
+
element.dataset.endIndex = `${endIndex}`;
|
|
200
|
+
return element;
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
key: `${TableDecorations.COLUMN_CONTROLS_DECORATIONS}_${endIndex}`,
|
|
204
|
+
// this decoration should be the first one, even before gap cursor.
|
|
205
|
+
side: -100,
|
|
206
|
+
},
|
|
207
|
+
);
|
|
196
208
|
});
|
|
197
209
|
};
|
|
198
210
|
|
|
@@ -312,16 +324,20 @@ export const createResizeHandleDecoration = (
|
|
|
312
324
|
cellPos: number,
|
|
313
325
|
cellNode: PmNode,
|
|
314
326
|
): Decoration => {
|
|
315
|
-
const element = document.createElement('div');
|
|
316
|
-
element.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
317
|
-
|
|
318
|
-
element.dataset.startIndex = `${cellColumnPositioning.left}`;
|
|
319
|
-
element.dataset.endIndex = `${cellColumnPositioning.right}`;
|
|
320
327
|
const position = cellPos + cellNode.nodeSize - 1;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
328
|
+
return Decoration.widget(
|
|
329
|
+
position,
|
|
330
|
+
() => {
|
|
331
|
+
const element = document.createElement('div');
|
|
332
|
+
element.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
333
|
+
element.dataset.startIndex = `${cellColumnPositioning.left}`;
|
|
334
|
+
element.dataset.endIndex = `${cellColumnPositioning.right}`;
|
|
335
|
+
return element;
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
key: `${TableDecorations.COLUMN_RESIZING_HANDLE}_${rowIndex}_${columnIndex}`,
|
|
339
|
+
},
|
|
340
|
+
);
|
|
325
341
|
};
|
|
326
342
|
|
|
327
343
|
const createLastCellElementDecoration = (
|