@atlaskit/editor-plugin-block-controls 7.14.0 → 7.15.0
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 +21 -0
- package/dist/cjs/blockControlsPlugin.js +3 -0
- package/dist/cjs/ui/drag-handle.js +10 -12
- package/dist/es2019/blockControlsPlugin.js +3 -0
- package/dist/es2019/ui/drag-handle.js +7 -9
- package/dist/esm/blockControlsPlugin.js +3 -0
- package/dist/esm/ui/drag-handle.js +7 -9
- package/package.json +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 7.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`762b79e21f96a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/762b79e21f96a) -
|
|
8
|
+
Migrated and cleaned up legacy iconography usage.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [`e4dce058a2b52`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e4dce058a2b52) -
|
|
13
|
+
EDITOR-3793 Stop preserving selection on block menu close
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 7.14.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [`9391799e9bdf4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9391799e9bdf4) -
|
|
21
|
+
Clean up platform_editor_elements_dnd_select_node_on_drag
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 7.14.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -17,13 +17,13 @@ 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");
|
|
23
24
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
24
25
|
var _consts = require("@atlaskit/editor-shared-styles/consts");
|
|
25
26
|
var _dragHandleVertical = _interopRequireDefault(require("@atlaskit/icon/core/drag-handle-vertical"));
|
|
26
|
-
var _dragHandler = _interopRequireDefault(require("@atlaskit/icon/glyph/drag-handler"));
|
|
27
27
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
28
28
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
29
29
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
|
|
@@ -38,7 +38,7 @@ var _pluginKey = require("../pm-plugins/selection-preservation/plugin-key");
|
|
|
38
38
|
var _analytics2 = require("../pm-plugins/utils/analytics");
|
|
39
39
|
var _dragHandlePositions = require("../pm-plugins/utils/drag-handle-positions");
|
|
40
40
|
var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
41
|
-
var
|
|
41
|
+
var _selection2 = require("../pm-plugins/utils/selection");
|
|
42
42
|
var _consts2 = require("./consts");
|
|
43
43
|
var _dragPreview = require("./drag-preview");
|
|
44
44
|
var _anchorName = require("./utils/anchor-name");
|
|
@@ -332,7 +332,7 @@ var getExpandedSelectionRange = function getExpandedSelectionRange(_ref) {
|
|
|
332
332
|
var selectUp = resolvedStartPos.pos < selection.from;
|
|
333
333
|
var $from = isShiftPressed && selectUp ? resolvedStartPos : selection.$from;
|
|
334
334
|
var $to = isShiftPressed && !selectUp ? doc.resolve(resolvedStartPos.pos + 1) : selection.$to;
|
|
335
|
-
return
|
|
335
|
+
return (0, _selection.expandToBlockRange)($from, $to);
|
|
336
336
|
};
|
|
337
337
|
var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
338
338
|
var _api$core4;
|
|
@@ -427,7 +427,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
427
427
|
nodeType: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
|
|
428
428
|
}
|
|
429
429
|
})(tr);
|
|
430
|
-
var
|
|
430
|
+
var expandedRange = getExpandedSelectionRange({
|
|
431
431
|
doc: tr.doc,
|
|
432
432
|
selection: selection,
|
|
433
433
|
resolvedStartPos: resolvedStartPos,
|
|
@@ -435,11 +435,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
435
435
|
});
|
|
436
436
|
|
|
437
437
|
// 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)(
|
|
438
|
+
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiNodeRange(expandedRange.range)) {
|
|
439
|
+
var collapsed = (0, _getSelection.collapseToSelectionRange)(expandedRange.$from, expandedRange.$to);
|
|
440
440
|
|
|
441
441
|
// 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
|
|
442
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, Math.min(selection.from, collapsed.$from.pos), Math.max(selection.to, collapsed.$to.pos)));
|
|
443
443
|
} else {
|
|
444
444
|
// Select the clicked drag handle's node only
|
|
445
445
|
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType, api);
|
|
@@ -481,8 +481,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
481
481
|
tr = (0, _getSelection.selectNode)(tr, startPos, nodeType, api);
|
|
482
482
|
} 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
483
|
var _api$blockControls3;
|
|
484
|
-
var alignAnchorHeadToSel = (0,
|
|
485
|
-
var selectionWithExpandedHead = (0,
|
|
484
|
+
var alignAnchorHeadToSel = (0, _selection2.alignAnchorHeadInDirectionOfPos)(tr.selection, startPos);
|
|
485
|
+
var selectionWithExpandedHead = (0, _selection2.expandSelectionHeadToNodeAtPos)(alignAnchorHeadToSel, startPos);
|
|
486
486
|
tr.setSelection(selectionWithExpandedHead);
|
|
487
487
|
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.setMultiSelectPositions()({
|
|
488
488
|
tr: tr
|
|
@@ -611,7 +611,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
611
611
|
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
|
|
612
612
|
tr: tr
|
|
613
613
|
});
|
|
614
|
-
} else
|
|
614
|
+
} else {
|
|
615
615
|
tr = (0, _getSelection.selectNode)(tr, handlePos, nodeType, api);
|
|
616
616
|
}
|
|
617
617
|
return tr;
|
|
@@ -1048,8 +1048,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
1048
1048
|
}, (0, _react2.jsx)(_dragHandleVertical.default, {
|
|
1049
1049
|
spacing: "spacious",
|
|
1050
1050
|
label: "",
|
|
1051
|
-
LEGACY_fallbackIcon: _dragHandler.default,
|
|
1052
|
-
LEGACY_size: "medium",
|
|
1053
1051
|
size: "small"
|
|
1054
1052
|
})))
|
|
1055
1053
|
);
|
|
@@ -14,13 +14,13 @@ 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';
|
|
20
21
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
21
22
|
import { akEditorFullPageNarrowBreakout, akEditorTableToolbarSize, relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles/consts';
|
|
22
23
|
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
23
|
-
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
24
24
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
25
25
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
26
26
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
@@ -328,7 +328,7 @@ const getExpandedSelectionRange = ({
|
|
|
328
328
|
const selectUp = resolvedStartPos.pos < selection.from;
|
|
329
329
|
const $from = isShiftPressed && selectUp ? resolvedStartPos : selection.$from;
|
|
330
330
|
const $to = isShiftPressed && !selectUp ? doc.resolve(resolvedStartPos.pos + 1) : selection.$to;
|
|
331
|
-
return $from
|
|
331
|
+
return expandToBlockRange($from, $to);
|
|
332
332
|
};
|
|
333
333
|
export const DragHandle = ({
|
|
334
334
|
view,
|
|
@@ -405,7 +405,7 @@ export const DragHandle = ({
|
|
|
405
405
|
nodeType: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
|
|
406
406
|
}
|
|
407
407
|
})(tr);
|
|
408
|
-
const
|
|
408
|
+
const expandedRange = getExpandedSelectionRange({
|
|
409
409
|
doc: tr.doc,
|
|
410
410
|
selection,
|
|
411
411
|
resolvedStartPos,
|
|
@@ -413,11 +413,11 @@ export const DragHandle = ({
|
|
|
413
413
|
});
|
|
414
414
|
|
|
415
415
|
// 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(
|
|
416
|
+
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiNodeRange(expandedRange.range)) {
|
|
417
|
+
const collapsed = collapseToSelectionRange(expandedRange.$from, expandedRange.$to);
|
|
418
418
|
|
|
419
419
|
// 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
|
|
420
|
+
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, collapsed.$from.pos), Math.max(selection.to, collapsed.$to.pos)));
|
|
421
421
|
} else {
|
|
422
422
|
// Select the clicked drag handle's node only
|
|
423
423
|
tr = selectNode(tr, startPos, nodeType, api);
|
|
@@ -588,7 +588,7 @@ export const DragHandle = ({
|
|
|
588
588
|
api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.setMultiSelectPositions()({
|
|
589
589
|
tr
|
|
590
590
|
});
|
|
591
|
-
} else
|
|
591
|
+
} else {
|
|
592
592
|
tr = selectNode(tr, handlePos, nodeType, api);
|
|
593
593
|
}
|
|
594
594
|
return tr;
|
|
@@ -1033,8 +1033,6 @@ export const DragHandle = ({
|
|
|
1033
1033
|
}, jsx(DragHandleVerticalIcon, {
|
|
1034
1034
|
spacing: "spacious",
|
|
1035
1035
|
label: "",
|
|
1036
|
-
LEGACY_fallbackIcon: DragHandlerIcon,
|
|
1037
|
-
LEGACY_size: "medium",
|
|
1038
1036
|
size: "small"
|
|
1039
1037
|
})));
|
|
1040
1038
|
const stickyWithTooltip = () => jsx(Box
|
|
@@ -19,13 +19,13 @@ 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';
|
|
25
26
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
26
27
|
import { akEditorFullPageNarrowBreakout, akEditorTableToolbarSize, relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles/consts';
|
|
27
28
|
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
28
|
-
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
29
29
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
30
30
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
31
31
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
@@ -329,7 +329,7 @@ var getExpandedSelectionRange = function getExpandedSelectionRange(_ref) {
|
|
|
329
329
|
var selectUp = resolvedStartPos.pos < selection.from;
|
|
330
330
|
var $from = isShiftPressed && selectUp ? resolvedStartPos : selection.$from;
|
|
331
331
|
var $to = isShiftPressed && !selectUp ? doc.resolve(resolvedStartPos.pos + 1) : selection.$to;
|
|
332
|
-
return $from
|
|
332
|
+
return expandToBlockRange($from, $to);
|
|
333
333
|
};
|
|
334
334
|
export var DragHandle = function DragHandle(_ref2) {
|
|
335
335
|
var _api$core4;
|
|
@@ -424,7 +424,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
424
424
|
nodeType: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
|
|
425
425
|
}
|
|
426
426
|
})(tr);
|
|
427
|
-
var
|
|
427
|
+
var expandedRange = getExpandedSelectionRange({
|
|
428
428
|
doc: tr.doc,
|
|
429
429
|
selection: selection,
|
|
430
430
|
resolvedStartPos: resolvedStartPos,
|
|
@@ -432,11 +432,11 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
432
432
|
});
|
|
433
433
|
|
|
434
434
|
// 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(
|
|
435
|
+
if (expandedRange.range && isPosWithinRange(startPos, expandedRange.range) && isMultiNodeRange(expandedRange.range)) {
|
|
436
|
+
var collapsed = collapseToSelectionRange(expandedRange.$from, expandedRange.$to);
|
|
437
437
|
|
|
438
438
|
// 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
|
|
439
|
+
tr.setSelection(TextSelection.create(tr.doc, Math.min(selection.from, collapsed.$from.pos), Math.max(selection.to, collapsed.$to.pos)));
|
|
440
440
|
} else {
|
|
441
441
|
// Select the clicked drag handle's node only
|
|
442
442
|
tr = selectNode(tr, startPos, nodeType, api);
|
|
@@ -608,7 +608,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
608
608
|
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
|
|
609
609
|
tr: tr
|
|
610
610
|
});
|
|
611
|
-
} else
|
|
611
|
+
} else {
|
|
612
612
|
tr = selectNode(tr, handlePos, nodeType, api);
|
|
613
613
|
}
|
|
614
614
|
return tr;
|
|
@@ -1045,8 +1045,6 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
1045
1045
|
}, jsx(DragHandleVerticalIcon, {
|
|
1046
1046
|
spacing: "spacious",
|
|
1047
1047
|
label: "",
|
|
1048
|
-
LEGACY_fallbackIcon: DragHandlerIcon,
|
|
1049
|
-
LEGACY_size: "medium",
|
|
1050
1048
|
size: "small"
|
|
1051
1049
|
})))
|
|
1052
1050
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.15.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@atlaskit/editor-prosemirror": "^7.2.0",
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
48
48
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
49
|
-
"@atlaskit/icon": "^29.
|
|
49
|
+
"@atlaskit/icon": "^29.2.0",
|
|
50
50
|
"@atlaskit/link": "^3.2.0",
|
|
51
51
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.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.6.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.45.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
|
},
|