@atlaskit/editor-tables 2.8.4 → 2.8.5
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
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-tables
|
|
2
2
|
|
|
3
|
+
## 2.8.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#109026](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109026)
|
|
8
|
+
[`05e5c3f595ae0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/05e5c3f595ae0) -
|
|
9
|
+
[ux] [ED-26076] Fixed bug where selecting from parent cell to nested table cell caused a cell
|
|
10
|
+
selection instead of a partial text selection.
|
|
11
|
+
|
|
3
12
|
## 2.8.4
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -9,6 +9,7 @@ exports.handleTripleClick = handleTripleClick;
|
|
|
9
9
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
10
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _cellSelection = require("../cell-selection");
|
|
13
14
|
var _utils = require("../utils");
|
|
14
15
|
var _cells = require("../utils/cells");
|
|
@@ -205,13 +206,20 @@ function handleMouseDown(view, event, dragAndDropEnabled) {
|
|
|
205
206
|
}
|
|
206
207
|
function move(event) {
|
|
207
208
|
var anchor = _pluginKey.tableEditingKey.getState(view.state);
|
|
209
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
210
|
+
var currDOMCell = domInCell(view, event.target);
|
|
211
|
+
var isCurrCellInsideNestedTable = isInsideNestedTable(view, event);
|
|
212
|
+
var isStartCellInsideNestedTable = isInsideNestedTable(view, startEvent);
|
|
213
|
+
var isBothCellsInSameTable = isCurrCellInsideNestedTable === isStartCellInsideNestedTable;
|
|
208
214
|
var $moveAnchor;
|
|
215
|
+
var oldIfStatement = currDOMCell !== startDOMCell;
|
|
216
|
+
var newIfStatement = currDOMCell !== startDOMCell && isBothCellsInSameTable;
|
|
217
|
+
var checkCellsAreDifferent = (0, _platformFeatureFlags.fg)('platform_editor_cell_selection_with_nested_tables') ? newIfStatement : oldIfStatement;
|
|
209
218
|
if (anchor != null) {
|
|
210
219
|
// Continuing an existing cross-cell selection
|
|
211
220
|
$moveAnchor = view.state.doc.resolve(anchor);
|
|
212
221
|
// Ignored via go/ees005
|
|
213
|
-
|
|
214
|
-
} else if (domInCell(view, event.target) !== startDOMCell) {
|
|
222
|
+
} else if (checkCellsAreDifferent) {
|
|
215
223
|
// Moving out of the initial cell -- start a new cell selection
|
|
216
224
|
$moveAnchor = cellUnderMouse(view, startEvent);
|
|
217
225
|
if (!$moveAnchor) {
|
|
@@ -275,4 +283,21 @@ function cellUnderMouse(view, event) {
|
|
|
275
283
|
return null;
|
|
276
284
|
}
|
|
277
285
|
return (0, _cells.cellAround)(view.state.doc.resolve(mousePos.pos));
|
|
286
|
+
}
|
|
287
|
+
function isInsideNestedTable(view, event) {
|
|
288
|
+
var mousePos = view.posAtCoords({
|
|
289
|
+
left: event.clientX,
|
|
290
|
+
top: event.clientY
|
|
291
|
+
});
|
|
292
|
+
if (!mousePos) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
var pos = view.state.doc.resolve(mousePos.pos);
|
|
296
|
+
var table = (0, _utils.findTableClosestToPos)(pos);
|
|
297
|
+
if (!table) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
var parent = view.state.doc.resolve(table.pos).parent;
|
|
301
|
+
var nodeTypes = view.state.schema.nodes;
|
|
302
|
+
return [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
278
303
|
}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
5
|
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { CellSelection } from '../cell-selection';
|
|
8
|
-
import { tableNodeTypes } from '../utils';
|
|
9
|
+
import { findTableClosestToPos, tableNodeTypes } from '../utils';
|
|
9
10
|
import { cellAround, nextCell } from '../utils/cells';
|
|
10
11
|
import { inSameTable } from '../utils/tables';
|
|
11
12
|
import { tableEditingKey } from './plugin-key';
|
|
@@ -204,13 +205,20 @@ export function handleMouseDown(view, event, dragAndDropEnabled) {
|
|
|
204
205
|
}
|
|
205
206
|
function move(event) {
|
|
206
207
|
const anchor = tableEditingKey.getState(view.state);
|
|
208
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
209
|
+
const currDOMCell = domInCell(view, event.target);
|
|
210
|
+
const isCurrCellInsideNestedTable = isInsideNestedTable(view, event);
|
|
211
|
+
const isStartCellInsideNestedTable = isInsideNestedTable(view, startEvent);
|
|
212
|
+
const isBothCellsInSameTable = isCurrCellInsideNestedTable === isStartCellInsideNestedTable;
|
|
207
213
|
let $moveAnchor;
|
|
214
|
+
const oldIfStatement = currDOMCell !== startDOMCell;
|
|
215
|
+
const newIfStatement = currDOMCell !== startDOMCell && isBothCellsInSameTable;
|
|
216
|
+
const checkCellsAreDifferent = fg('platform_editor_cell_selection_with_nested_tables') ? newIfStatement : oldIfStatement;
|
|
208
217
|
if (anchor != null) {
|
|
209
218
|
// Continuing an existing cross-cell selection
|
|
210
219
|
$moveAnchor = view.state.doc.resolve(anchor);
|
|
211
220
|
// Ignored via go/ees005
|
|
212
|
-
|
|
213
|
-
} else if (domInCell(view, event.target) !== startDOMCell) {
|
|
221
|
+
} else if (checkCellsAreDifferent) {
|
|
214
222
|
// Moving out of the initial cell -- start a new cell selection
|
|
215
223
|
$moveAnchor = cellUnderMouse(view, startEvent);
|
|
216
224
|
if (!$moveAnchor) {
|
|
@@ -276,4 +284,21 @@ function cellUnderMouse(view, event) {
|
|
|
276
284
|
return null;
|
|
277
285
|
}
|
|
278
286
|
return cellAround(view.state.doc.resolve(mousePos.pos));
|
|
287
|
+
}
|
|
288
|
+
function isInsideNestedTable(view, event) {
|
|
289
|
+
const mousePos = view.posAtCoords({
|
|
290
|
+
left: event.clientX,
|
|
291
|
+
top: event.clientY
|
|
292
|
+
});
|
|
293
|
+
if (!mousePos) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
const pos = view.state.doc.resolve(mousePos.pos);
|
|
297
|
+
const table = findTableClosestToPos(pos);
|
|
298
|
+
if (!table) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
const parent = view.state.doc.resolve(table.pos).parent;
|
|
302
|
+
const nodeTypes = view.state.schema.nodes;
|
|
303
|
+
return [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
279
304
|
}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
5
|
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { CellSelection } from '../cell-selection';
|
|
8
|
-
import { tableNodeTypes } from '../utils';
|
|
9
|
+
import { findTableClosestToPos, tableNodeTypes } from '../utils';
|
|
9
10
|
import { cellAround, nextCell } from '../utils/cells';
|
|
10
11
|
import { inSameTable } from '../utils/tables';
|
|
11
12
|
import { tableEditingKey } from './plugin-key';
|
|
@@ -197,13 +198,20 @@ export function handleMouseDown(view, event, dragAndDropEnabled) {
|
|
|
197
198
|
}
|
|
198
199
|
function move(event) {
|
|
199
200
|
var anchor = tableEditingKey.getState(view.state);
|
|
201
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
202
|
+
var currDOMCell = domInCell(view, event.target);
|
|
203
|
+
var isCurrCellInsideNestedTable = isInsideNestedTable(view, event);
|
|
204
|
+
var isStartCellInsideNestedTable = isInsideNestedTable(view, startEvent);
|
|
205
|
+
var isBothCellsInSameTable = isCurrCellInsideNestedTable === isStartCellInsideNestedTable;
|
|
200
206
|
var $moveAnchor;
|
|
207
|
+
var oldIfStatement = currDOMCell !== startDOMCell;
|
|
208
|
+
var newIfStatement = currDOMCell !== startDOMCell && isBothCellsInSameTable;
|
|
209
|
+
var checkCellsAreDifferent = fg('platform_editor_cell_selection_with_nested_tables') ? newIfStatement : oldIfStatement;
|
|
201
210
|
if (anchor != null) {
|
|
202
211
|
// Continuing an existing cross-cell selection
|
|
203
212
|
$moveAnchor = view.state.doc.resolve(anchor);
|
|
204
213
|
// Ignored via go/ees005
|
|
205
|
-
|
|
206
|
-
} else if (domInCell(view, event.target) !== startDOMCell) {
|
|
214
|
+
} else if (checkCellsAreDifferent) {
|
|
207
215
|
// Moving out of the initial cell -- start a new cell selection
|
|
208
216
|
$moveAnchor = cellUnderMouse(view, startEvent);
|
|
209
217
|
if (!$moveAnchor) {
|
|
@@ -267,4 +275,21 @@ function cellUnderMouse(view, event) {
|
|
|
267
275
|
return null;
|
|
268
276
|
}
|
|
269
277
|
return cellAround(view.state.doc.resolve(mousePos.pos));
|
|
278
|
+
}
|
|
279
|
+
function isInsideNestedTable(view, event) {
|
|
280
|
+
var mousePos = view.posAtCoords({
|
|
281
|
+
left: event.clientX,
|
|
282
|
+
top: event.clientY
|
|
283
|
+
});
|
|
284
|
+
if (!mousePos) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
var pos = view.state.doc.resolve(mousePos.pos);
|
|
288
|
+
var table = findTableClosestToPos(pos);
|
|
289
|
+
if (!table) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
var parent = view.state.doc.resolve(table.pos).parent;
|
|
293
|
+
var nodeTypes = view.state.schema.nodes;
|
|
294
|
+
return [nodeTypes.tableHeader, nodeTypes.tableCell].includes(parent.type);
|
|
270
295
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-tables",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.5",
|
|
4
4
|
"description": "A package that contains common classes and utility functions for editor tables",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -51,6 +51,9 @@
|
|
|
51
51
|
"platform-feature-flags": {
|
|
52
52
|
"platform_editor_table_fix_move_column": {
|
|
53
53
|
"type": "boolean"
|
|
54
|
+
},
|
|
55
|
+
"platform_editor_cell_selection_with_nested_tables": {
|
|
56
|
+
"type": "boolean"
|
|
54
57
|
}
|
|
55
58
|
},
|
|
56
59
|
"af:exports": {
|