@atlaskit/editor-plugin-block-controls 17.1.0 → 17.1.2
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 +15 -0
- package/dist/cjs/blockControlsPlugin.js +14 -6
- package/dist/cjs/pm-plugins/main.js +14 -6
- package/dist/cjs/ui/block-controls-surface-context.js +2 -1
- package/dist/cjs/ui/block-controls-surface-drag-handle-registration.js +37 -0
- package/dist/cjs/ui/block-controls-surface-drag-handle-utils.js +45 -0
- package/dist/cjs/ui/block-controls-surface-drag-handle.compiled.css +32 -0
- package/dist/cjs/ui/block-controls-surface-drag-handle.js +296 -0
- package/dist/cjs/ui/block-controls-surface.compiled.css +2 -1
- package/dist/cjs/ui/block-controls-surface.js +49 -24
- package/dist/cjs/ui/consts.js +2 -1
- package/dist/cjs/ui/surface-editor-view-context.js +12 -0
- package/dist/cjs/ui/use-block-controls-surface-drag-source.js +172 -0
- package/dist/cjs/ui/utils/get-surface-placement.js +8 -1
- package/dist/es2019/blockControlsPlugin.js +13 -6
- package/dist/es2019/pm-plugins/main.js +14 -7
- package/dist/es2019/ui/block-controls-surface-context.js +2 -2
- package/dist/es2019/ui/block-controls-surface-drag-handle-registration.js +26 -0
- package/dist/es2019/ui/block-controls-surface-drag-handle-utils.js +33 -0
- package/dist/es2019/ui/block-controls-surface-drag-handle.compiled.css +32 -0
- package/dist/es2019/ui/block-controls-surface-drag-handle.js +282 -0
- package/dist/es2019/ui/block-controls-surface.compiled.css +2 -1
- package/dist/es2019/ui/block-controls-surface.js +48 -22
- package/dist/es2019/ui/consts.js +1 -0
- package/dist/es2019/ui/surface-editor-view-context.js +4 -0
- package/dist/es2019/ui/use-block-controls-surface-drag-source.js +170 -0
- package/dist/es2019/ui/utils/get-surface-placement.js +15 -6
- package/dist/esm/blockControlsPlugin.js +14 -6
- package/dist/esm/pm-plugins/main.js +14 -6
- package/dist/esm/ui/block-controls-surface-context.js +2 -1
- package/dist/esm/ui/block-controls-surface-drag-handle-registration.js +30 -0
- package/dist/esm/ui/block-controls-surface-drag-handle-utils.js +38 -0
- package/dist/esm/ui/block-controls-surface-drag-handle.compiled.css +32 -0
- package/dist/esm/ui/block-controls-surface-drag-handle.js +290 -0
- package/dist/esm/ui/block-controls-surface.compiled.css +2 -1
- package/dist/esm/ui/block-controls-surface.js +49 -24
- package/dist/esm/ui/consts.js +1 -0
- package/dist/esm/ui/surface-editor-view-context.js +6 -0
- package/dist/esm/ui/use-block-controls-surface-drag-source.js +166 -0
- package/dist/esm/ui/utils/get-surface-placement.js +9 -2
- package/dist/types/pm-plugins/main.d.ts +6 -1
- package/dist/types/ui/block-controls-surface-context.d.ts +1 -1
- package/dist/types/ui/block-controls-surface-drag-handle-registration.d.ts +6 -0
- package/dist/types/ui/block-controls-surface-drag-handle-utils.d.ts +14 -0
- package/dist/types/ui/block-controls-surface-drag-handle.d.ts +10 -0
- package/dist/types/ui/block-controls-surface.d.ts +1 -0
- package/dist/types/ui/consts.d.ts +1 -0
- package/dist/types/ui/surface-editor-view-context.d.ts +5 -0
- package/dist/types/ui/use-block-controls-surface-drag-source.d.ts +19 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +1 -1
- package/package.json +4 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
5
|
import React from 'react';
|
|
@@ -26,7 +27,9 @@ import { createSelectionPreservationPlugin } from './pm-plugins/selection-preser
|
|
|
26
27
|
import { expandAndUpdateSelection as _expandAndUpdateSelection } from './pm-plugins/utils/expand-and-update-selection';
|
|
27
28
|
import { selectNode } from './pm-plugins/utils/getSelection';
|
|
28
29
|
import { BlockControlsSurface } from './ui/block-controls-surface';
|
|
30
|
+
import { getBlockControlsSurfaceDragHandleComponents } from './ui/block-controls-surface-drag-handle-registration';
|
|
29
31
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
32
|
+
import { SurfaceEditorViewContext } from './ui/surface-editor-view-context';
|
|
30
33
|
export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
31
34
|
var _config$rightSideCont, _config$quickInsertBu;
|
|
32
35
|
var api = _ref.api,
|
|
@@ -34,8 +37,9 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
34
37
|
var nodeDecorationRegistry = [];
|
|
35
38
|
var rightSideControlsEnabled = (_config$rightSideCont = config === null || config === void 0 ? void 0 : config.rightSideControlsEnabled) !== null && _config$rightSideCont !== void 0 ? _config$rightSideCont : false;
|
|
36
39
|
var quickInsertButtonEnabled = (_config$quickInsertBu = config === null || config === void 0 ? void 0 : config.quickInsertButtonEnabled) !== null && _config$quickInsertBu !== void 0 ? _config$quickInsertBu : true;
|
|
37
|
-
var
|
|
38
|
-
|
|
40
|
+
var registryBlockControlsEnabled = isExperimentEnabled('platform_editor_block_control_migration');
|
|
41
|
+
var legacyBlockControlsEnabled = !registryBlockControlsEnabled;
|
|
42
|
+
if (registryBlockControlsEnabled) {
|
|
39
43
|
var _api$uiControlRegistr;
|
|
40
44
|
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register([BLOCK_CONTROLS_LEFT_SURFACE, _objectSpread(_objectSpread({}, BLOCK_CONTROLS_LEFT_SECTION), {}, {
|
|
41
45
|
parents: [_objectSpread(_objectSpread({}, BLOCK_CONTROLS_LEFT_SURFACE), {}, {
|
|
@@ -45,7 +49,9 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
45
49
|
parents: [_objectSpread(_objectSpread({}, BLOCK_CONTROLS_LEFT_SECTION), {}, {
|
|
46
50
|
rank: 100
|
|
47
51
|
})]
|
|
48
|
-
})]
|
|
52
|
+
})].concat(_toConsumableArray(getBlockControlsSurfaceDragHandleComponents({
|
|
53
|
+
api: api
|
|
54
|
+
}))));
|
|
49
55
|
}
|
|
50
56
|
return {
|
|
51
57
|
name: 'blockControls',
|
|
@@ -115,7 +121,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
115
121
|
plugin: function plugin(_ref2) {
|
|
116
122
|
var getIntl = _ref2.getIntl,
|
|
117
123
|
nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI;
|
|
118
|
-
return createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled &&
|
|
124
|
+
return createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled);
|
|
119
125
|
}
|
|
120
126
|
}];
|
|
121
127
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
@@ -434,10 +440,12 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
434
440
|
var editorView = _ref0.editorView;
|
|
435
441
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStylesWrapper, {
|
|
436
442
|
api: api
|
|
437
|
-
}),
|
|
443
|
+
}), registryBlockControlsEnabled && editorView && api ? /*#__PURE__*/React.createElement(SurfaceEditorViewContext.Provider, {
|
|
444
|
+
value: editorView
|
|
445
|
+
}, /*#__PURE__*/React.createElement(BlockControlsSurface, {
|
|
438
446
|
api: api,
|
|
439
447
|
editorView: editorView
|
|
440
|
-
}) : null);
|
|
448
|
+
})) : null);
|
|
441
449
|
}
|
|
442
450
|
};
|
|
443
451
|
};
|
|
@@ -23,6 +23,7 @@ import { combine } from '@atlaskit/pragmatic-drag-and-drop/utils/combine';
|
|
|
23
23
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
|
|
24
24
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
25
25
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
26
|
+
import { BLOCK_CONTROLS_SURFACE_SELECTOR } from '../ui/consts';
|
|
26
27
|
import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
|
|
27
28
|
import { findNodeDecs, nodeDecorations } from './decorations-anchor';
|
|
28
29
|
import { createActiveDragHandleNodeDecoration, dragHandleDecoration, emptyParagraphNodeDecorations, findActiveDragHandleNodeDec, findHandleDec } from './decorations-drag-handle';
|
|
@@ -501,7 +502,8 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
501
502
|
}
|
|
502
503
|
} else if (api) {
|
|
503
504
|
var _latestActiveNode5, _latestActiveNode10;
|
|
504
|
-
|
|
505
|
+
// The registry surface replaces the legacy drag-handle decorations during migration.
|
|
506
|
+
if (flags.legacyDragHandleEnabled && shouldRecreateHandle && (!rightSideControlsEnabled || !isViewMode)) {
|
|
505
507
|
var _activeNode11, _activeNode12, _latestActiveNode, _latestActiveNode2, _latestActiveNode3, _latestActiveNode4;
|
|
506
508
|
var _oldHandle = findHandleDec(decorations, (_activeNode11 = activeNode) === null || _activeNode11 === void 0 ? void 0 : _activeNode11.pos, (_activeNode12 = activeNode) === null || _activeNode12 === void 0 ? void 0 : _activeNode12.pos);
|
|
507
509
|
decorations = decorations.remove(_oldHandle);
|
|
@@ -518,7 +520,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
518
520
|
});
|
|
519
521
|
decorations = decorations.add(newState.doc, [handleDec]);
|
|
520
522
|
}
|
|
521
|
-
if (expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && latestActiveNode) {
|
|
523
|
+
if (flags.legacyDragHandleEnabled && expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) && latestActiveNode) {
|
|
522
524
|
// Recreate the drag handle node decoration when the active node changed,
|
|
523
525
|
// its content was modified, or the document changed (e.g. Enter splits a node).
|
|
524
526
|
// This runs independently of shouldRecreateHandle so that doc changes (like pressing
|
|
@@ -793,11 +795,13 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
793
795
|
// remove isEmptyDoc check and let decorations render and determine their own visibility
|
|
794
796
|
// In view mode with right-side controls we render node decorations (right-edge button), not the
|
|
795
797
|
// handle - so findHandleDec is always empty. Don't clear activeNode in that case.
|
|
796
|
-
var hasHandleOrViewModeControls = findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0 || isViewMode && rightSideControlsEnabled;
|
|
797
|
-
|
|
798
|
+
var hasHandleOrViewModeControls = findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0 || isViewMode && rightSideControlsEnabled || !flags.legacyDragHandleEnabled;
|
|
799
|
+
// Keep the registry surface mounted while its Block Menu owns focus.
|
|
800
|
+
var keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen && editorExperiment('platform_editor_block_menu', true);
|
|
801
|
+
newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
|
|
798
802
|
} else {
|
|
799
803
|
var _latestActiveNode13, _latestActiveNode14;
|
|
800
|
-
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
|
|
804
|
+
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && flags.legacyDragHandleEnabled && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
|
|
801
805
|
}
|
|
802
806
|
var isMenuOpenNew = isMenuOpen;
|
|
803
807
|
if (editorExperiment('platform_editor_block_menu', true)) {
|
|
@@ -845,6 +849,7 @@ export { _apply as apply };
|
|
|
845
849
|
export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
846
850
|
var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
847
851
|
var quickInsertButtonEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
852
|
+
var legacyDragHandleEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
|
|
848
853
|
var _getIntl = getIntl(),
|
|
849
854
|
formatMessage = _getIntl.formatMessage;
|
|
850
855
|
var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
@@ -852,6 +857,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
852
857
|
});
|
|
853
858
|
var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
854
859
|
var flags = {
|
|
860
|
+
legacyDragHandleEnabled: legacyDragHandleEnabled,
|
|
855
861
|
toolbarFlagsEnabled: toolbarFlagsEnabled
|
|
856
862
|
};
|
|
857
863
|
var anchorRectCache;
|
|
@@ -1097,11 +1103,13 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1097
1103
|
}
|
|
1098
1104
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
1099
1105
|
var _api$core2;
|
|
1106
|
+
// Focus moving into the registry surface remains inside the editor experience.
|
|
1107
|
+
var isChildOfSurface = !flags.legacyDragHandleEnabled && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest(BLOCK_CONTROLS_SURFACE_SELECTOR) !== null;
|
|
1100
1108
|
var isChildOfEditor = event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest("#".concat(EDIT_AREA_ID)) !== null;
|
|
1101
1109
|
|
|
1102
1110
|
// don't do anything if the event relatedTarget (the element receiving focus) is a child of the editor
|
|
1103
1111
|
// or if the editor has focus
|
|
1104
|
-
if (isChildOfEditor || view.hasFocus()) {
|
|
1112
|
+
if (isChildOfEditor || isChildOfSurface || view.hasFocus()) {
|
|
1105
1113
|
return false;
|
|
1106
1114
|
}
|
|
1107
1115
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref6) {
|
|
@@ -31,6 +31,7 @@ var getNodeContext = function getNodeContext(view, pos) {
|
|
|
31
31
|
};
|
|
32
32
|
export var createBlockControlsSurfaceContext = function createBlockControlsSurfaceContext(view, activeNode) {
|
|
33
33
|
var _activeNode$rootPos, _activeNode$rootNodeT;
|
|
34
|
+
var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'root';
|
|
34
35
|
if (!activeNode) {
|
|
35
36
|
return undefined;
|
|
36
37
|
}
|
|
@@ -48,6 +49,6 @@ export var createBlockControlsSurfaceContext = function createBlockControlsSurfa
|
|
|
48
49
|
}
|
|
49
50
|
}),
|
|
50
51
|
rootNode: rootNodeContext,
|
|
51
|
-
targetNode: rootNodeContext
|
|
52
|
+
targetNode: target === 'active' ? activeNodeContext : rootNodeContext
|
|
52
53
|
};
|
|
53
54
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
6
|
+
import { BLOCK_CONTROLS_LEFT_GROUP } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
7
|
+
import { BlockControlsSurfaceDragHandle } from './block-controls-surface-drag-handle';
|
|
8
|
+
export var getBlockControlsSurfaceDragHandleComponents = function getBlockControlsSurfaceDragHandleComponents(_ref) {
|
|
9
|
+
var api = _ref.api;
|
|
10
|
+
return [{
|
|
11
|
+
component: function component(_ref2) {
|
|
12
|
+
var surfaceContext = _ref2.surfaceContext;
|
|
13
|
+
return /*#__PURE__*/React.createElement(BlockControlsSurfaceDragHandle, {
|
|
14
|
+
api: api,
|
|
15
|
+
surfaceContext: surfaceContext
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
isHidden: function isHidden() {
|
|
19
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
20
|
+
surfaceContext = _ref3.surfaceContext;
|
|
21
|
+
var context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
22
|
+
return !(context !== null && context !== void 0 && context.activeNode) || context.targetNode.pos !== context.activeNode.pos;
|
|
23
|
+
},
|
|
24
|
+
key: 'block-controls-drag-handle',
|
|
25
|
+
parents: [_objectSpread(_objectSpread({}, BLOCK_CONTROLS_LEFT_GROUP), {}, {
|
|
26
|
+
rank: 200
|
|
27
|
+
})],
|
|
28
|
+
type: 'button'
|
|
29
|
+
}];
|
|
30
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
5
|
+
import { nodeMargins, spacingBetweenNodesForPreview } from './consts';
|
|
6
|
+
export var buildLayoutColumnMenuMeta = function buildLayoutColumnMenuMeta(anchorPos, openedViaKeyboard) {
|
|
7
|
+
return _objectSpread(_objectSpread({
|
|
8
|
+
anchorPos: anchorPos
|
|
9
|
+
}, fg('platform_editor_layout_column_menu_kill_switch_1') ? {
|
|
10
|
+
isOpen: true
|
|
11
|
+
} : {}), {}, {
|
|
12
|
+
openedViaKeyboard: openedViaKeyboard
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export var getNodeSpacingForDragPreview = function getNodeSpacingForDragPreview(node) {
|
|
16
|
+
var _spacingBetweenNodesF2;
|
|
17
|
+
if (!node) {
|
|
18
|
+
return spacingBetweenNodesForPreview.default;
|
|
19
|
+
}
|
|
20
|
+
var nodeTypeName = node.type.name;
|
|
21
|
+
if (nodeTypeName === 'heading') {
|
|
22
|
+
var _spacingBetweenNodesF;
|
|
23
|
+
return (_spacingBetweenNodesF = spacingBetweenNodesForPreview["heading".concat(node.attrs.level)]) !== null && _spacingBetweenNodesF !== void 0 ? _spacingBetweenNodesF : spacingBetweenNodesForPreview.default;
|
|
24
|
+
}
|
|
25
|
+
return (_spacingBetweenNodesF2 = spacingBetweenNodesForPreview[nodeTypeName]) !== null && _spacingBetweenNodesF2 !== void 0 ? _spacingBetweenNodesF2 : spacingBetweenNodesForPreview.default;
|
|
26
|
+
};
|
|
27
|
+
export var getNodeMarginsForDragPreview = function getNodeMarginsForDragPreview(node) {
|
|
28
|
+
var _nodeMargins$nodeType;
|
|
29
|
+
if (!node) {
|
|
30
|
+
return nodeMargins.default;
|
|
31
|
+
}
|
|
32
|
+
var nodeTypeName = node.type.name;
|
|
33
|
+
if (nodeTypeName === 'heading') {
|
|
34
|
+
var _nodeMargins;
|
|
35
|
+
return (_nodeMargins = nodeMargins["heading".concat(node.attrs.level)]) !== null && _nodeMargins !== void 0 ? _nodeMargins : nodeMargins.default;
|
|
36
|
+
}
|
|
37
|
+
return (_nodeMargins$nodeType = nodeMargins[nodeTypeName]) !== null && _nodeMargins$nodeType !== void 0 ? _nodeMargins$nodeType : nodeMargins.default;
|
|
38
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
._19itglyw{border:none}
|
|
2
|
+
._1a37dfik{outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
3
|
+
._2rko1y44{border-radius:4px}._12ji1r31{outline-color:currentColor}
|
|
4
|
+
._12y31o36{outline-width:medium}
|
|
5
|
+
._19bvze3t{padding-left:var(--ds-space-0,0)}
|
|
6
|
+
._1bah1h6o{justify-content:center}
|
|
7
|
+
._1bsb1crf{width:9pt}
|
|
8
|
+
._1bsbx5ub{width:calc(var(--ak-editor-base-font-size)*12/16)}
|
|
9
|
+
._1e0c1txw{display:flex}
|
|
10
|
+
._1p1y1j28::selection{background-color:transparent}
|
|
11
|
+
._1pbyb4wl{z-index:100}
|
|
12
|
+
._1qu2glyw{outline-style:none}
|
|
13
|
+
._2lx21bp4{flex-direction:column}
|
|
14
|
+
._4cvr1h6o{align-items:center}
|
|
15
|
+
._4t3i1myc{height:calc(var(--ak-editor-base-font-size)*24/16)}
|
|
16
|
+
._4t3i1tcg{height:24px}
|
|
17
|
+
._80om1qgj{cursor:grab}
|
|
18
|
+
._bfhk15s3{background-color:var(--ds-background-selected,#e9f2fe)}
|
|
19
|
+
._bfhksm61{background-color:var(--ds-background-neutral-subtle,#00000000)}
|
|
20
|
+
._ca0qze3t{padding-top:var(--ds-space-0,0)}
|
|
21
|
+
._cun91j28:disabled{background-color:transparent}
|
|
22
|
+
._n3tdze3t{padding-bottom:var(--ds-space-0,0)}
|
|
23
|
+
._syazdgkc{color:var(--ds-icon-subtle,#505258)}
|
|
24
|
+
._syazxl6c{color:var(--ds-icon-selected,#1868db)}
|
|
25
|
+
._t9ec14w8{transform:rotate(90deg)}
|
|
26
|
+
._u5f3ze3t{padding-right:var(--ds-space-0,0)}
|
|
27
|
+
._vbqb2sac:disabled{color:var(--ds-icon-disabled,#080f214a)}
|
|
28
|
+
._vchhusvi{box-sizing:border-box}
|
|
29
|
+
._1ygbdfik:focus-visible{outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
30
|
+
._6g80187o:disabled:hover{background-color:var(--ds-background-disabled,#0515240f)}
|
|
31
|
+
._irr31dpa:hover{background-color:var(--ds-background-neutral-subtle-hovered,#0515240f)}
|
|
32
|
+
._1di6fcek:active{background-color:var(--ds-background-neutral-subtle-pressed,#0b120e24)}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/* block-controls-surface-drag-handle.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import "./block-controls-surface-drag-handle.compiled.css";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { useIntl } from 'react-intl';
|
|
8
|
+
|
|
9
|
+
// oxlint-disable-next-line typescript/consistent-type-imports -- jsx is the runtime factory for the classic JSX pragma above.
|
|
10
|
+
|
|
11
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
12
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
13
|
+
import { surfaceDragHandleElementStore } from '@atlaskit/editor-common/block-controls/surface-drag-handle-element';
|
|
14
|
+
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
15
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
16
|
+
import { TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
17
|
+
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
18
|
+
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
19
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
20
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
|
+
import Tooltip from '@atlaskit/tooltip/Tooltip';
|
|
22
|
+
import { selectionPreservationPluginKey } from '../pm-plugins/selection-preservation/plugin-key';
|
|
23
|
+
import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
|
|
24
|
+
import { isHandleCorrelatedToSelection } from '../pm-plugins/utils/getSelection';
|
|
25
|
+
import { buildLayoutColumnMenuMeta } from './block-controls-surface-drag-handle-utils';
|
|
26
|
+
import { DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH } from './consts';
|
|
27
|
+
import { DragHandleNestedIcon } from './drag-handle-nested-icon';
|
|
28
|
+
import { shouldUseNestedDragHandleIcon } from './should-use-nested-drag-handle-icon';
|
|
29
|
+
import { useSurfaceEditorView } from './surface-editor-view-context';
|
|
30
|
+
import { useBlockControlsSurfaceDragSource } from './use-block-controls-surface-drag-source';
|
|
31
|
+
import { getAnchorAttrName, NODE_ANCHOR_ATTR_NAME } from './utils/dom-attr-name';
|
|
32
|
+
|
|
33
|
+
// Keep style values co-located for Compiled while matching the legacy drag handle dimensions.
|
|
34
|
+
var SURFACE_DRAG_HANDLE_HEIGHT = 24;
|
|
35
|
+
var SURFACE_DRAG_HANDLE_WIDTH = 12;
|
|
36
|
+
var SURFACE_DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
37
|
+
var SURFACE_DRAG_HANDLE_Z_INDEX = 100;
|
|
38
|
+
var dragHandleStyles = {
|
|
39
|
+
root: "_19itglyw _2rko1y44 _12ji1r31 _1qu2glyw _12y31o36 _1e0c1txw _vchhusvi _2lx21bp4 _4cvr1h6o _1bah1h6o _4t3i1tcg _1bsb1crf _bfhksm61 _syazdgkc _80om1qgj _1pbyb4wl _ca0qze3t _u5f3ze3t _n3tdze3t _19bvze3t _cun91j28 _vbqb2sac _1ygbdfik _irr31dpa _6g80187o _1di6fcek",
|
|
40
|
+
scaled: "_4t3i1myc _1bsbx5ub",
|
|
41
|
+
selected: "_bfhk15s3 _syazxl6c",
|
|
42
|
+
keyboardFocused: "_1a37dfik",
|
|
43
|
+
firefoxSelection: "_1p1y1j28",
|
|
44
|
+
layoutColumn: "_t9ec14w8",
|
|
45
|
+
iconWrapper: "_1e0c1txw _4cvr1h6o _1bah1h6o"
|
|
46
|
+
};
|
|
47
|
+
var handleIconDragStart = function handleIconDragStart(event) {
|
|
48
|
+
var _event$currentTarget$;
|
|
49
|
+
if (!getBrowserInfo().chrome) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
(_event$currentTarget$ = event.currentTarget.parentElement) === null || _event$currentTarget$ === void 0 || _event$currentTarget$.dispatchEvent(new DragEvent('dragstart', {
|
|
54
|
+
bubbles: true,
|
|
55
|
+
cancelable: true,
|
|
56
|
+
dataTransfer: event.dataTransfer
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
var isSelected = function isSelected(selection, pos, view) {
|
|
60
|
+
if (typeof pos !== 'number' || !selection || !view) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return isHandleCorrelatedToSelection(view.state, selection, pos);
|
|
64
|
+
};
|
|
65
|
+
export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHandle(_ref) {
|
|
66
|
+
var _activeNode$type$name;
|
|
67
|
+
var api = _ref.api,
|
|
68
|
+
surfaceContext = _ref.surfaceContext;
|
|
69
|
+
var _useIntl = useIntl(),
|
|
70
|
+
formatMessage = _useIntl.formatMessage;
|
|
71
|
+
var view = useSurfaceEditorView();
|
|
72
|
+
var context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
73
|
+
var activeNode = context === null || context === void 0 ? void 0 : context.activeNode;
|
|
74
|
+
var pos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
|
|
75
|
+
var nodeType = (_activeNode$type$name = activeNode === null || activeNode === void 0 ? void 0 : activeNode.type.name) !== null && _activeNode$type$name !== void 0 ? _activeNode$type$name : '';
|
|
76
|
+
var buttonRef = useRef(null);
|
|
77
|
+
var posRef = useRef(pos);
|
|
78
|
+
posRef.current = pos;
|
|
79
|
+
var getPos = useCallback(function () {
|
|
80
|
+
return posRef.current;
|
|
81
|
+
}, []);
|
|
82
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls', 'interaction', 'selection'], function (states) {
|
|
83
|
+
var _states$blockControls, _states$blockControls2, _states$interactionSt, _states$blockControls3, _states$selectionStat;
|
|
84
|
+
return {
|
|
85
|
+
activeNodeAnchorName: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 || (_states$blockControls = _states$blockControls.activeNode) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.anchorName,
|
|
86
|
+
handleOptions: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 || (_states$blockControls2 = _states$blockControls2.activeNode) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.handleOptions,
|
|
87
|
+
interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
|
|
88
|
+
isShiftDown: (_states$blockControls3 = states.blockControlsState) === null || _states$blockControls3 === void 0 ? void 0 : _states$blockControls3.isShiftDown,
|
|
89
|
+
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection
|
|
90
|
+
};
|
|
91
|
+
}),
|
|
92
|
+
activeNodeAnchorName = _useSharedPluginState.activeNodeAnchorName,
|
|
93
|
+
handleOptions = _useSharedPluginState.handleOptions,
|
|
94
|
+
interactionState = _useSharedPluginState.interactionState,
|
|
95
|
+
isShiftDown = _useSharedPluginState.isShiftDown,
|
|
96
|
+
selection = _useSharedPluginState.selection;
|
|
97
|
+
var _useState = useState(false),
|
|
98
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
99
|
+
dragHandleSelected = _useState2[0],
|
|
100
|
+
setDragHandleSelected = _useState2[1];
|
|
101
|
+
useEffect(function () {
|
|
102
|
+
setDragHandleSelected(isSelected(selection, pos, view));
|
|
103
|
+
}, [pos, selection, view]);
|
|
104
|
+
var isLayoutColumn = nodeType === 'layoutColumn';
|
|
105
|
+
var isTopLevelNode = (activeNode === null || activeNode === void 0 ? void 0 : activeNode.parentType) === 'doc';
|
|
106
|
+
var isDisabled = useMemo(function () {
|
|
107
|
+
var _api$blockControls$sh;
|
|
108
|
+
if (!isShiftDown || !view || view.state.selection.empty || !fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (isLayoutColumn && expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
var multiSelect = api === null || api === void 0 || (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.multiSelectDnD;
|
|
115
|
+
var $anchor = (multiSelect === null || multiSelect === void 0 ? void 0 : multiSelect.anchor) !== undefined ? view.state.doc.resolve(multiSelect.anchor) : view.state.selection.$anchor;
|
|
116
|
+
return !isTopLevelNode || $anchor.depth > DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH;
|
|
117
|
+
}, [api, isLayoutColumn, isShiftDown, isTopLevelNode, view]);
|
|
118
|
+
var getAnchorName = useCallback(function () {
|
|
119
|
+
var _ref2, _ref3, _dom$getAttribute, _dom$closest;
|
|
120
|
+
if (activeNodeAnchorName) {
|
|
121
|
+
return activeNodeAnchorName;
|
|
122
|
+
}
|
|
123
|
+
var currentPos = posRef.current;
|
|
124
|
+
if (!view || currentPos === undefined) {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
var dom = view.nodeDOM(currentPos);
|
|
128
|
+
if (!(dom instanceof HTMLElement)) {
|
|
129
|
+
return '';
|
|
130
|
+
}
|
|
131
|
+
var anchorAttrName = getAnchorAttrName();
|
|
132
|
+
return (_ref2 = (_ref3 = (_dom$getAttribute = dom.getAttribute(anchorAttrName)) !== null && _dom$getAttribute !== void 0 ? _dom$getAttribute : dom.getAttribute(NODE_ANCHOR_ATTR_NAME)) !== null && _ref3 !== void 0 ? _ref3 : (_dom$closest = dom.closest("[".concat(anchorAttrName, "]"))) === null || _dom$closest === void 0 ? void 0 : _dom$closest.getAttribute(anchorAttrName)) !== null && _ref2 !== void 0 ? _ref2 : '';
|
|
133
|
+
}, [activeNodeAnchorName, view]);
|
|
134
|
+
useLayoutEffect(function () {
|
|
135
|
+
var element = buttonRef.current;
|
|
136
|
+
if (!view || !element) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
surfaceDragHandleElementStore.set(view, element);
|
|
140
|
+
return function () {
|
|
141
|
+
return surfaceDragHandleElementStore.release(view, element);
|
|
142
|
+
};
|
|
143
|
+
}, [view]);
|
|
144
|
+
useEffect(function () {
|
|
145
|
+
if (!(handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused) || !buttonRef.current || !view) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
var animationFrameId;
|
|
149
|
+
var attempts = 0;
|
|
150
|
+
var _focusHandle = function focusHandle() {
|
|
151
|
+
var button = buttonRef.current;
|
|
152
|
+
if (!button) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
button.focus();
|
|
156
|
+
if (button.ownerDocument.activeElement !== button && attempts < 5) {
|
|
157
|
+
attempts++;
|
|
158
|
+
animationFrameId = requestAnimationFrame(_focusHandle);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
_focusHandle();
|
|
162
|
+
return function () {
|
|
163
|
+
if (animationFrameId !== undefined) {
|
|
164
|
+
cancelAnimationFrame(animationFrameId);
|
|
165
|
+
}
|
|
166
|
+
view.focus();
|
|
167
|
+
};
|
|
168
|
+
}, [handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
|
|
169
|
+
useBlockControlsSurfaceDragSource({
|
|
170
|
+
api: api,
|
|
171
|
+
elementRef: buttonRef,
|
|
172
|
+
getAnchorName: getAnchorName,
|
|
173
|
+
getPos: getPos,
|
|
174
|
+
nodeType: nodeType,
|
|
175
|
+
start: pos,
|
|
176
|
+
view: view
|
|
177
|
+
});
|
|
178
|
+
var handleMouseDown = useCallback(function () {
|
|
179
|
+
var _api$core, _api$blockControls;
|
|
180
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.setSelectedViaDragHandle(true));
|
|
181
|
+
}, [api]);
|
|
182
|
+
var handleClick = useCallback(function (event) {
|
|
183
|
+
var _api$core2;
|
|
184
|
+
if (!view || isDisabled) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
var openedViaKeyboard = event.detail === 0;
|
|
188
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
|
|
189
|
+
var _selectionPreservatio, _selectionPreservatio2, _api$analytics, _resolvedStartPos$nod, _api$blockControls2, _api$blockControls3, _activeNode$rootPos;
|
|
190
|
+
var tr = _ref4.tr;
|
|
191
|
+
var startPos = getPos();
|
|
192
|
+
if (startPos === undefined) {
|
|
193
|
+
return tr;
|
|
194
|
+
}
|
|
195
|
+
if (nodeType === 'layoutColumn' && expValEquals('platform_editor_layout_column_menu', 'isEnabled', true)) {
|
|
196
|
+
tr.setMeta('toggleLayoutColumnMenu', buildLayoutColumnMenuMeta(startPos, openedViaKeyboard));
|
|
197
|
+
}
|
|
198
|
+
var selection = (_selectionPreservatio = (_selectionPreservatio2 = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) !== null && _selectionPreservatio !== void 0 ? _selectionPreservatio : tr.selection;
|
|
199
|
+
var resolvedStartPos = tr.doc.resolve(startPos);
|
|
200
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
201
|
+
action: ACTION.CLICKED,
|
|
202
|
+
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
203
|
+
actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
|
|
204
|
+
attributes: {
|
|
205
|
+
nodeDepth: resolvedStartPos.depth,
|
|
206
|
+
nodeTypes: ((_resolvedStartPos$nod = resolvedStartPos.nodeAfter) === null || _resolvedStartPos$nod === void 0 ? void 0 : _resolvedStartPos$nod.type.name) || ''
|
|
207
|
+
},
|
|
208
|
+
eventType: EVENT_TYPE.UI
|
|
209
|
+
})(tr);
|
|
210
|
+
expandAndUpdateSelection({
|
|
211
|
+
api: api,
|
|
212
|
+
isShiftPressed: event.shiftKey,
|
|
213
|
+
nodeType: nodeType,
|
|
214
|
+
selection: selection,
|
|
215
|
+
startPos: startPos,
|
|
216
|
+
tr: tr
|
|
217
|
+
});
|
|
218
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.startPreservingSelection()({
|
|
219
|
+
tr: tr
|
|
220
|
+
});
|
|
221
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.toggleBlockMenu({
|
|
222
|
+
anchorName: getAnchorName(),
|
|
223
|
+
openedViaKeyboard: openedViaKeyboard,
|
|
224
|
+
triggerByNode: {
|
|
225
|
+
nodeType: nodeType,
|
|
226
|
+
pos: startPos,
|
|
227
|
+
rootPos: (_activeNode$rootPos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.rootPos) !== null && _activeNode$rootPos !== void 0 ? _activeNode$rootPos : resolvedStartPos.before(1)
|
|
228
|
+
}
|
|
229
|
+
})({
|
|
230
|
+
tr: tr
|
|
231
|
+
});
|
|
232
|
+
tr.setMeta('scrollIntoView', false);
|
|
233
|
+
return tr;
|
|
234
|
+
});
|
|
235
|
+
view.focus();
|
|
236
|
+
}, [activeNode === null || activeNode === void 0 ? void 0 : activeNode.rootPos, api, getAnchorName, getPos, isDisabled, nodeType, view]);
|
|
237
|
+
var label = formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
238
|
+
br: ' '
|
|
239
|
+
});
|
|
240
|
+
var helpDescriptors = useMemo(function () {
|
|
241
|
+
return [{
|
|
242
|
+
description: formatMessage(blockControlsMessages.dragToMoveClickToOpen, {
|
|
243
|
+
br: /*#__PURE__*/React.createElement("br", null)
|
|
244
|
+
})
|
|
245
|
+
}];
|
|
246
|
+
}, [formatMessage]);
|
|
247
|
+
var handleTooltipShow = useCallback(function () {
|
|
248
|
+
var _api$accessibilityUti;
|
|
249
|
+
api === null || api === void 0 || (_api$accessibilityUti = api.accessibilityUtils) === null || _api$accessibilityUti === void 0 || _api$accessibilityUti.actions.ariaNotify(label, {
|
|
250
|
+
priority: 'important'
|
|
251
|
+
});
|
|
252
|
+
}, [api, label]);
|
|
253
|
+
if (!view || !activeNode || pos === undefined) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
var tooltipContent = /*#__PURE__*/React.createElement(TooltipContentWithMultipleShortcuts, {
|
|
257
|
+
helpDescriptors: helpDescriptors
|
|
258
|
+
});
|
|
259
|
+
var browser = getBrowserInfo();
|
|
260
|
+
var button = /*#__PURE__*/React.createElement("button", {
|
|
261
|
+
ref: buttonRef,
|
|
262
|
+
type: "button",
|
|
263
|
+
"aria-label": label,
|
|
264
|
+
disabled: isDisabled,
|
|
265
|
+
onClick: handleClick,
|
|
266
|
+
onMouseDown: handleMouseDown
|
|
267
|
+
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop -- Pragmatic DnD owns this native drag source.
|
|
268
|
+
,
|
|
269
|
+
onDrop: function onDrop(event) {
|
|
270
|
+
return event.stopPropagation();
|
|
271
|
+
},
|
|
272
|
+
"data-editor-block-ctrl-drag-handle": true,
|
|
273
|
+
"data-blocks-drag-handle": fg('confluence_remix_button_right_side_block_fg') || undefined,
|
|
274
|
+
"data-testid": "block-controls-surface-drag-handle",
|
|
275
|
+
className: ax([dragHandleStyles.root, browser.gecko && dragHandleStyles.firefoxSelection, isLayoutColumn && dragHandleStyles.layoutColumn, dragHandleSelected && interactionState !== 'hasNotHadInteraction' && dragHandleStyles.selected, (handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused) && dragHandleStyles.keyboardFocused, dragHandleStyles.scaled])
|
|
276
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
277
|
+
onDragStart: handleIconDragStart,
|
|
278
|
+
className: ax([dragHandleStyles.iconWrapper])
|
|
279
|
+
}, shouldUseNestedDragHandleIcon(Boolean(isTopLevelNode), isLayoutColumn) ? /*#__PURE__*/React.createElement(DragHandleNestedIcon, null) : /*#__PURE__*/React.createElement(DragHandleVerticalIcon, {
|
|
280
|
+
label: "",
|
|
281
|
+
size: "small",
|
|
282
|
+
spacing: "spacious"
|
|
283
|
+
})));
|
|
284
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
285
|
+
position: "top",
|
|
286
|
+
content: tooltipContent,
|
|
287
|
+
ignoreTooltipPointerEvents: true,
|
|
288
|
+
onShow: handleTooltipShow
|
|
289
|
+
}, button);
|
|
290
|
+
};
|