@atlaskit/editor-plugin-block-controls 7.14.0 → 7.14.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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 7.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9391799e9bdf4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9391799e9bdf4) -
|
|
8
|
+
Clean up platform_editor_elements_dnd_select_node_on_drag
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 7.14.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -17,6 +17,7 @@ var _browser = require("@atlaskit/editor-common/browser");
|
|
|
17
17
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
18
18
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
19
19
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
20
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
20
21
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
21
22
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
22
23
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -38,7 +39,7 @@ var _pluginKey = require("../pm-plugins/selection-preservation/plugin-key");
|
|
|
38
39
|
var _analytics2 = require("../pm-plugins/utils/analytics");
|
|
39
40
|
var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
|
|
40
41
|
var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
41
|
-
var
|
|
42
|
+
var _selection2 = require("../pm-plugins/utils/selection");
|
|
42
43
|
var _consts2 = require("./consts");
|
|
43
44
|
var _dragPreview = require("./drag-preview");
|
|
44
45
|
var _anchorName = require("./utils/anchor-name");
|
|
@@ -332,7 +333,7 @@ var getExpandedSelectionRange = function getExpandedSelectionRange(_ref) {
|
|
|
332
333
|
var selectUp = resolvedStartPos.pos < selection.from;
|
|
333
334
|
var $from = isShiftPressed && selectUp ? resolvedStartPos : selection.$from;
|
|
334
335
|
var $to = isShiftPressed && !selectUp ? doc.resolve(resolvedStartPos.pos + 1) : selection.$to;
|
|
335
|
-
return
|
|
336
|
+
return (0, _selection.expandToBlockRange)($from, $to);
|
|
336
337
|
};
|
|
337
338
|
var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
338
339
|
var _api$core4;
|
|
@@ -427,7 +428,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
427
428
|
nodeType: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
|
|
428
429
|
}
|
|
429
430
|
})(tr);
|
|
430
|
-
var
|
|
431
|
+
var expandedRange = getExpandedSelectionRange({
|
|
431
432
|
doc: tr.doc,
|
|
432
433
|
selection: selection,
|
|
433
434
|
resolvedStartPos: resolvedStartPos,
|
|
@@ -435,11 +436,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
435
436
|
});
|
|
436
437
|
|
|
437
438
|
// Set selection to expanded selection range if it encompases the clicked drag handle
|
|
438
|
-
if (range && isPosWithinRange(startPos, range) && isMultiNodeRange(range)) {
|
|
439
|
-
var collapsed = (0, _getSelection.collapseToSelectionRange)(
|
|
439
|
+
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiNodeRange(expandedRange.range)) {
|
|
440
|
+
var collapsed = (0, _getSelection.collapseToSelectionRange)(expandedRange.$from, expandedRange.$to);
|
|
440
441
|
|
|
441
442
|
// Then create a selection from the start of the first node to the end of the last node
|
|
442
|
-
tr.setSelection(_state.TextSelection.create(tr.doc, Math.min(selection.from, collapsed
|
|
443
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, Math.min(selection.from, collapsed.$from.pos), Math.max(selection.to, collapsed.$to.pos)));
|
|
443
444
|
} else {
|
|
444
445
|
// Select the clicked drag handle's node only
|
|
445
446
|
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType, api);
|
|
@@ -481,8 +482,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
481
482
|
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType, api);
|
|
482
483
|
} else if (isTopLevelNode && $anchor.depth <= _consts2.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_shift_click_select')) {
|
|
483
484
|
var _api$blockControls3;
|
|
484
|
-
var alignAnchorHeadToSel = (0,
|
|
485
|
-
var selectionWithExpandedHead = (0,
|
|
485
|
+
var alignAnchorHeadToSel = (0, _selection2.alignAnchorHeadInDirectionOfPos)(tr.selection, startPos);
|
|
486
|
+
var selectionWithExpandedHead = (0, _selection2.expandSelectionHeadToNodeAtPos)(alignAnchorHeadToSel, startPos);
|
|
486
487
|
tr.setSelection(selectionWithExpandedHead);
|
|
487
488
|
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.setMultiSelectPositions()({
|
|
488
489
|
tr: tr
|
|
@@ -611,7 +612,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
611
612
|
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
|
|
612
613
|
tr: tr
|
|
613
614
|
});
|
|
614
|
-
} else
|
|
615
|
+
} else {
|
|
615
616
|
tr = (0, _getSelection.selectNode)(tr, handlePos, nodeType, api);
|
|
616
617
|
}
|
|
617
618
|
return tr;
|
|
@@ -14,6 +14,7 @@ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-commo
|
|
|
14
14
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
15
15
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
16
16
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
17
|
+
import { expandToBlockRange } from '@atlaskit/editor-common/selection';
|
|
17
18
|
import { DRAG_HANDLE_WIDTH, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
18
19
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
19
20
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -328,7 +329,7 @@ const getExpandedSelectionRange = ({
|
|
|
328
329
|
const selectUp = resolvedStartPos.pos < selection.from;
|
|
329
330
|
const $from = isShiftPressed && selectUp ? resolvedStartPos : selection.$from;
|
|
330
331
|
const $to = isShiftPressed && !selectUp ? doc.resolve(resolvedStartPos.pos + 1) : selection.$to;
|
|
331
|
-
return $from
|
|
332
|
+
return expandToBlockRange($from, $to);
|
|
332
333
|
};
|
|
333
334
|
export const DragHandle = ({
|
|
334
335
|
view,
|
|
@@ -405,7 +406,7 @@ export const DragHandle = ({
|
|
|
405
406
|
nodeType: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
|
|
406
407
|
}
|
|
407
408
|
})(tr);
|
|
408
|
-
const
|
|
409
|
+
const expandedRange = getExpandedSelectionRange({
|
|
409
410
|
doc: tr.doc,
|
|
410
411
|
selection,
|
|
411
412
|
resolvedStartPos,
|
|
@@ -413,11 +414,11 @@ export const DragHandle = ({
|
|
|
413
414
|
});
|
|
414
415
|
|
|
415
416
|
// Set selection to expanded selection range if it encompases the clicked drag handle
|
|
416
|
-
if (range && isPosWithinRange(startPos, range) && isMultiNodeRange(range)) {
|
|
417
|
-
const collapsed = collapseToSelectionRange(
|
|
417
|
+
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiNodeRange(expandedRange.range)) {
|
|
418
|
+
const collapsed = collapseToSelectionRange(expandedRange.$from, expandedRange.$to);
|
|
418
419
|
|
|
419
420
|
// Then create a selection from the start of the first node to the end of the last node
|
|
420
|
-
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, collapsed
|
|
421
|
+
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, collapsed.$from.pos), Math.max(selection.to, collapsed.$to.pos)));
|
|
421
422
|
} else {
|
|
422
423
|
// Select the clicked drag handle's node only
|
|
423
424
|
tr = selectNode(tr, startPos, nodeType, api);
|
|
@@ -588,7 +589,7 @@ export const DragHandle = ({
|
|
|
588
589
|
api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.setMultiSelectPositions()({
|
|
589
590
|
tr
|
|
590
591
|
});
|
|
591
|
-
} else
|
|
592
|
+
} else {
|
|
592
593
|
tr = selectNode(tr, handlePos, nodeType, api);
|
|
593
594
|
}
|
|
594
595
|
return tr;
|
|
@@ -19,6 +19,7 @@ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-commo
|
|
|
19
19
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
20
20
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
21
21
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
22
|
+
import { expandToBlockRange } from '@atlaskit/editor-common/selection';
|
|
22
23
|
import { DRAG_HANDLE_WIDTH, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
23
24
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
24
25
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -329,7 +330,7 @@ var getExpandedSelectionRange = function getExpandedSelectionRange(_ref) {
|
|
|
329
330
|
var selectUp = resolvedStartPos.pos < selection.from;
|
|
330
331
|
var $from = isShiftPressed && selectUp ? resolvedStartPos : selection.$from;
|
|
331
332
|
var $to = isShiftPressed && !selectUp ? doc.resolve(resolvedStartPos.pos + 1) : selection.$to;
|
|
332
|
-
return $from
|
|
333
|
+
return expandToBlockRange($from, $to);
|
|
333
334
|
};
|
|
334
335
|
export var DragHandle = function DragHandle(_ref2) {
|
|
335
336
|
var _api$core4;
|
|
@@ -424,7 +425,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
424
425
|
nodeType: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
|
|
425
426
|
}
|
|
426
427
|
})(tr);
|
|
427
|
-
var
|
|
428
|
+
var expandedRange = getExpandedSelectionRange({
|
|
428
429
|
doc: tr.doc,
|
|
429
430
|
selection: selection,
|
|
430
431
|
resolvedStartPos: resolvedStartPos,
|
|
@@ -432,11 +433,11 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
432
433
|
});
|
|
433
434
|
|
|
434
435
|
// Set selection to expanded selection range if it encompases the clicked drag handle
|
|
435
|
-
if (range && isPosWithinRange(startPos, range) && isMultiNodeRange(range)) {
|
|
436
|
-
var collapsed = collapseToSelectionRange(
|
|
436
|
+
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiNodeRange(expandedRange.range)) {
|
|
437
|
+
var collapsed = collapseToSelectionRange(expandedRange.$from, expandedRange.$to);
|
|
437
438
|
|
|
438
439
|
// Then create a selection from the start of the first node to the end of the last node
|
|
439
|
-
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, collapsed
|
|
440
|
+
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, collapsed.$from.pos), Math.max(selection.to, collapsed.$to.pos)));
|
|
440
441
|
} else {
|
|
441
442
|
// Select the clicked drag handle's node only
|
|
442
443
|
tr = selectNode(tr, startPos, nodeType, api);
|
|
@@ -608,7 +609,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
608
609
|
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
|
|
609
610
|
tr: tr
|
|
610
611
|
});
|
|
611
|
-
} else
|
|
612
|
+
} else {
|
|
612
613
|
tr = selectNode(tr, handlePos, nodeType, api);
|
|
613
614
|
}
|
|
614
615
|
return tr;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "7.14.
|
|
3
|
+
"version": "7.14.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
|
|
55
55
|
"@atlaskit/primitives": "^16.4.0",
|
|
56
56
|
"@atlaskit/theme": "^21.0.0",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^15.
|
|
58
|
-
"@atlaskit/tokens": "^8.
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^15.12.0",
|
|
58
|
+
"@atlaskit/tokens": "^8.5.0",
|
|
59
59
|
"@atlaskit/tooltip": "^20.11.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
61
61
|
"@emotion/react": "^11.7.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"uuid": "^3.1.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@atlaskit/editor-common": "^110.
|
|
69
|
+
"@atlaskit/editor-common": "^110.44.0",
|
|
70
70
|
"react": "^18.2.0",
|
|
71
71
|
"react-dom": "^18.2.0",
|
|
72
72
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -119,9 +119,6 @@
|
|
|
119
119
|
"platform_editor_elements_dnd_shift_click_select": {
|
|
120
120
|
"type": "boolean"
|
|
121
121
|
},
|
|
122
|
-
"platform_editor_elements_dnd_select_node_on_drag": {
|
|
123
|
-
"type": "boolean"
|
|
124
|
-
},
|
|
125
122
|
"platform_editor_ease_of_use_metrics": {
|
|
126
123
|
"type": "boolean"
|
|
127
124
|
},
|