@atlaskit/editor-plugin-block-controls 7.10.2 → 7.11.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 +11 -0
- package/dist/cjs/blockControlsPlugin.js +5 -26
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/ui/consts.js +2 -7
- package/dist/cjs/ui/drag-handle.js +17 -57
- package/dist/es2019/blockControlsPlugin.js +5 -27
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/ui/consts.js +1 -6
- package/dist/es2019/ui/drag-handle.js +15 -55
- package/dist/esm/blockControlsPlugin.js +5 -26
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/ui/consts.js +1 -6
- package/dist/esm/ui/drag-handle.js +15 -55
- package/dist/types/ui/consts.d.ts +0 -2
- package/dist/types-ts4.5/ui/consts.d.ts +0 -2
- package/package.json +2 -2
- package/dist/cjs/ui/block-menu-items.js +0 -90
- package/dist/cjs/ui/block-menu.js +0 -110
- package/dist/es2019/ui/block-menu-items.js +0 -82
- package/dist/es2019/ui/block-menu.js +0 -108
- package/dist/esm/ui/block-menu-items.js +0 -82
- package/dist/esm/ui/block-menu.js +0 -102
- package/dist/types/ui/block-menu-items.d.ts +0 -15
- package/dist/types/ui/block-menu.d.ts +0 -16
- package/dist/types-ts4.5/ui/block-menu-items.d.ts +0 -15
- package/dist/types-ts4.5/ui/block-menu.d.ts +0 -16
|
@@ -22,7 +22,7 @@ import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
|
22
22
|
import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
|
|
23
23
|
import { DRAG_HANDLE_WIDTH, tableControlsSpacing } from '@atlaskit/editor-common/styles';
|
|
24
24
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
25
|
-
import {
|
|
25
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
26
26
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
27
27
|
import { akEditorFullPageNarrowBreakout, akEditorTableToolbarSize, relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles/consts';
|
|
28
28
|
import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
|
|
@@ -41,9 +41,9 @@ import { key } from '../pm-plugins/main';
|
|
|
41
41
|
import { selectionPreservationPluginKey } from '../pm-plugins/selection-preservation/plugin-key';
|
|
42
42
|
import { getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
|
|
43
43
|
import { getControlBottomCSSValue, getControlHeightCSSValue, getLeftPosition, getNodeHeight, getTopPosition, shouldBeSticky, shouldMaskNodeControls } from '../pm-plugins/utils/drag-handle-positions';
|
|
44
|
-
import { isHandleCorrelatedToSelection,
|
|
44
|
+
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
45
45
|
import { alignAnchorHeadInDirectionOfPos, expandSelectionHeadToNodeAtPos } from '../pm-plugins/utils/selection';
|
|
46
|
-
import {
|
|
46
|
+
import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, STICKY_CONTROLS_TOP_MARGIN, topPositionAdjustment } from './consts';
|
|
47
47
|
import { dragPreview } from './drag-preview';
|
|
48
48
|
import { refreshAnchorName } from './utils/anchor-name';
|
|
49
49
|
import { getAnchorAttrName } from './utils/dom-attr-name';
|
|
@@ -473,53 +473,13 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
473
473
|
var mSelect = api === null || api === void 0 || (_api$blockControls$sh = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.multiSelectDnD;
|
|
474
474
|
var $anchor = (mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) !== undefined ? tr.doc.resolve(mSelect === null || mSelect === void 0 ? void 0 : mSelect.anchor) : tr.selection.$anchor;
|
|
475
475
|
if (!isMultiSelect || tr.selection.empty || !e.shiftKey) {
|
|
476
|
-
|
|
477
|
-
var node = tr.doc.nodeAt(startPos);
|
|
478
|
-
var nodeSize = node ? node.nodeSize : 1;
|
|
479
|
-
// It this will be required in other places, where selectNode is used, we should
|
|
480
|
-
// move it inside of the newGetSelection in the selectNode
|
|
481
|
-
if (nodeType === 'blockquote' && isNodeWithCodeBlock(tr, startPos, nodeSize)) {
|
|
482
|
-
var _selection = new NodeSelection(tr.doc.resolve(startPos));
|
|
483
|
-
tr.setSelection(_selection);
|
|
484
|
-
} else {
|
|
485
|
-
tr = selectNode(tr, startPos, nodeType, api);
|
|
486
|
-
}
|
|
487
|
-
} else {
|
|
488
|
-
tr = selectNode(tr, startPos, nodeType, api);
|
|
489
|
-
}
|
|
490
|
-
var rootPos = editorExperiment('platform_synced_block', true) ? tr.doc.resolve(startPos).before(1) : undefined;
|
|
491
|
-
var triggerByNode = expValEqualsNoExposure('platform_synced_block', 'isEnabled', true) ? {
|
|
492
|
-
nodeType: nodeType,
|
|
493
|
-
pos: startPos,
|
|
494
|
-
rootPos: rootPos
|
|
495
|
-
} : undefined;
|
|
496
|
-
if (BLOCK_MENU_ENABLED && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
497
|
-
var _api$blockControls3;
|
|
498
|
-
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.toggleBlockMenu({
|
|
499
|
-
anchorName: anchorName,
|
|
500
|
-
triggerByNode: triggerByNode,
|
|
501
|
-
openedViaKeyboard: false
|
|
502
|
-
})({
|
|
503
|
-
tr: tr
|
|
504
|
-
});
|
|
505
|
-
e.stopPropagation();
|
|
506
|
-
} else if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
507
|
-
var _api$blockControls4;
|
|
508
|
-
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.toggleBlockMenu({
|
|
509
|
-
anchorName: anchorName,
|
|
510
|
-
triggerByNode: triggerByNode,
|
|
511
|
-
openedViaKeyboard: false
|
|
512
|
-
})({
|
|
513
|
-
tr: tr
|
|
514
|
-
});
|
|
515
|
-
e.stopPropagation();
|
|
516
|
-
}
|
|
476
|
+
tr = selectNode(tr, startPos, nodeType, api);
|
|
517
477
|
} else if (isTopLevelNode && $anchor.depth <= DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH && e.shiftKey && fg('platform_editor_elements_dnd_shift_click_select')) {
|
|
518
|
-
var _api$
|
|
478
|
+
var _api$blockControls3;
|
|
519
479
|
var alignAnchorHeadToSel = alignAnchorHeadInDirectionOfPos(tr.selection, startPos);
|
|
520
480
|
var selectionWithExpandedHead = expandSelectionHeadToNodeAtPos(alignAnchorHeadToSel, startPos);
|
|
521
481
|
tr.setSelection(selectionWithExpandedHead);
|
|
522
|
-
api === null || api === void 0 || (_api$
|
|
482
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.setMultiSelectPositions()({
|
|
523
483
|
tr: tr
|
|
524
484
|
});
|
|
525
485
|
}
|
|
@@ -539,7 +499,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
539
499
|
return tr;
|
|
540
500
|
});
|
|
541
501
|
view.focus();
|
|
542
|
-
}, [isMultiSelect, api, view, dragHandleSelected, getPos, isTopLevelNode, nodeType
|
|
502
|
+
}, [isMultiSelect, api, view, dragHandleSelected, getPos, isTopLevelNode, nodeType]);
|
|
543
503
|
var handleKeyDown = useCallback(function (e) {
|
|
544
504
|
// allow user to use spacebar to select the node
|
|
545
505
|
if (!e.repeat && e.key === ' ') {
|
|
@@ -581,7 +541,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
581
541
|
e.stopPropagation();
|
|
582
542
|
var startPos = getPos();
|
|
583
543
|
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
|
|
584
|
-
var _api$
|
|
544
|
+
var _api$blockControls4, _api$userIntent;
|
|
585
545
|
var tr = _ref6.tr;
|
|
586
546
|
if (startPos === undefined) {
|
|
587
547
|
return tr;
|
|
@@ -596,7 +556,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
596
556
|
pos: startPos,
|
|
597
557
|
rootPos: rootPos
|
|
598
558
|
} : undefined;
|
|
599
|
-
api === null || api === void 0 || (_api$
|
|
559
|
+
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.toggleBlockMenu({
|
|
600
560
|
anchorName: anchorName,
|
|
601
561
|
triggerByNode: triggerByNode,
|
|
602
562
|
openedViaKeyboard: true
|
|
@@ -612,10 +572,10 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
612
572
|
e.preventDefault();
|
|
613
573
|
e.stopPropagation();
|
|
614
574
|
api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
|
|
615
|
-
var _api$
|
|
575
|
+
var _api$blockControls5;
|
|
616
576
|
var tr = _ref7.tr;
|
|
617
577
|
deleteSelectedRange(tr);
|
|
618
|
-
api === null || api === void 0 || (_api$
|
|
578
|
+
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.toggleBlockMenu({
|
|
619
579
|
closeMenu: true
|
|
620
580
|
})({
|
|
621
581
|
tr: tr
|
|
@@ -656,8 +616,8 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
656
616
|
}
|
|
657
617
|
var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
658
618
|
if (!tr.selection.empty && newHandlePosCheck) {
|
|
659
|
-
var _api$
|
|
660
|
-
api === null || api === void 0 || (_api$
|
|
619
|
+
var _api$blockControls6;
|
|
620
|
+
api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setMultiSelectPositions()({
|
|
661
621
|
tr: tr
|
|
662
622
|
});
|
|
663
623
|
} else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
|
|
@@ -765,7 +725,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
765
725
|
return;
|
|
766
726
|
}
|
|
767
727
|
api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref1) {
|
|
768
|
-
var _api$blockControls$sh3, _api$
|
|
728
|
+
var _api$blockControls$sh3, _api$blockControls7, _api$analytics3;
|
|
769
729
|
var tr = _ref1.tr;
|
|
770
730
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
771
731
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
@@ -779,7 +739,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
779
739
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
780
740
|
hasSelectedMultipleNodes = false;
|
|
781
741
|
}
|
|
782
|
-
api === null || api === void 0 || (_api$
|
|
742
|
+
api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
783
743
|
tr: tr
|
|
784
744
|
});
|
|
785
745
|
tr.setMeta('scrollIntoView', false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.11.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
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": "^14.
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^14.2.0",
|
|
58
58
|
"@atlaskit/tokens": "^8.4.0",
|
|
59
59
|
"@atlaskit/tooltip": "^20.10.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.menuItemsCallback = exports.getBlockMenuItems = void 0;
|
|
8
|
-
var _react = require("@emotion/react");
|
|
9
|
-
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
10
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
|
-
var _types = require("@atlaskit/editor-common/types");
|
|
12
|
-
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
13
|
-
var _arrowDown = _interopRequireDefault(require("@atlaskit/icon/core/arrow-down"));
|
|
14
|
-
var _arrowLeft = _interopRequireDefault(require("@atlaskit/icon/core/arrow-left"));
|
|
15
|
-
var _arrowRight = _interopRequireDefault(require("@atlaskit/icon/core/arrow-right"));
|
|
16
|
-
var _arrowUp = _interopRequireDefault(require("@atlaskit/icon/core/arrow-up"));
|
|
17
|
-
var _moveNode = require("../editor-commands/move-node");
|
|
18
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
19
|
-
/**
|
|
20
|
-
* @jsxRuntime classic
|
|
21
|
-
* @jsx jsx
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
25
|
-
|
|
26
|
-
var getBlockMenuItems = exports.getBlockMenuItems = function getBlockMenuItems(formatMessage) {
|
|
27
|
-
return [{
|
|
28
|
-
items: [{
|
|
29
|
-
content: formatMessage(_messages.blockControlsMessages.moveUp),
|
|
30
|
-
elemBefore: (0, _react.jsx)(_arrowUp.default, {
|
|
31
|
-
label: ""
|
|
32
|
-
}),
|
|
33
|
-
value: {
|
|
34
|
-
name: 'moveUp'
|
|
35
|
-
},
|
|
36
|
-
key: 'move_up',
|
|
37
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
38
|
-
elemAfter: (0, _react.jsx)("div", {
|
|
39
|
-
css: _shortcut.shortcutStyle
|
|
40
|
-
}, (0, _keymaps.tooltip)(_keymaps.dragToMoveUp))
|
|
41
|
-
}, {
|
|
42
|
-
content: formatMessage(_messages.blockControlsMessages.moveDown),
|
|
43
|
-
elemBefore: (0, _react.jsx)(_arrowDown.default, {
|
|
44
|
-
label: ""
|
|
45
|
-
}),
|
|
46
|
-
value: {
|
|
47
|
-
name: 'moveDown'
|
|
48
|
-
},
|
|
49
|
-
key: 'move_down',
|
|
50
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
51
|
-
elemAfter: (0, _react.jsx)("div", {
|
|
52
|
-
css: _shortcut.shortcutStyle
|
|
53
|
-
}, (0, _keymaps.tooltip)(_keymaps.dragToMoveDown))
|
|
54
|
-
}, {
|
|
55
|
-
content: formatMessage(_messages.blockControlsMessages.moveLeft),
|
|
56
|
-
elemBefore: (0, _react.jsx)(_arrowLeft.default, {
|
|
57
|
-
label: ""
|
|
58
|
-
}),
|
|
59
|
-
value: {
|
|
60
|
-
name: 'moveLeft'
|
|
61
|
-
},
|
|
62
|
-
key: 'move_left',
|
|
63
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
64
|
-
elemAfter: (0, _react.jsx)("div", {
|
|
65
|
-
css: _shortcut.shortcutStyle
|
|
66
|
-
}, (0, _keymaps.tooltip)(_keymaps.dragToMoveLeft))
|
|
67
|
-
}, {
|
|
68
|
-
content: formatMessage(_messages.blockControlsMessages.moveRight),
|
|
69
|
-
elemBefore: (0, _react.jsx)(_arrowRight.default, {
|
|
70
|
-
label: ""
|
|
71
|
-
}),
|
|
72
|
-
value: {
|
|
73
|
-
name: 'moveRight'
|
|
74
|
-
},
|
|
75
|
-
key: 'move_right',
|
|
76
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
77
|
-
elemAfter: (0, _react.jsx)("div", {
|
|
78
|
-
css: _shortcut.shortcutStyle
|
|
79
|
-
}, (0, _keymaps.tooltip)(_keymaps.dragToMoveRight))
|
|
80
|
-
}]
|
|
81
|
-
}];
|
|
82
|
-
};
|
|
83
|
-
var menuItemsCallback = exports.menuItemsCallback = {
|
|
84
|
-
moveUp: function moveUp(api, formatMessage) {
|
|
85
|
-
return (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.UP, formatMessage);
|
|
86
|
-
},
|
|
87
|
-
moveDown: function moveDown(api, formatMessage) {
|
|
88
|
-
return (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.DOWN, formatMessage);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _reactIntlNext = require("react-intl-next");
|
|
10
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
12
|
-
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
13
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
14
|
-
var _blockMenuItems = require("./block-menu-items");
|
|
15
|
-
var _consts = require("./consts");
|
|
16
|
-
var _domAttrName = require("./utils/dom-attr-name");
|
|
17
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
18
|
-
var BlockMenuContent = function BlockMenuContent(_ref) {
|
|
19
|
-
var editorView = _ref.editorView,
|
|
20
|
-
mountPoint = _ref.mountPoint,
|
|
21
|
-
boundariesElement = _ref.boundariesElement,
|
|
22
|
-
scrollableElement = _ref.scrollableElement,
|
|
23
|
-
api = _ref.api,
|
|
24
|
-
menuTriggerBy = _ref.menuTriggerBy,
|
|
25
|
-
formatMessage = _ref.formatMessage;
|
|
26
|
-
var activeNodeSelector = "[".concat((0, _domAttrName.getAnchorAttrName)(), "=").concat(menuTriggerBy, "]");
|
|
27
|
-
var targetHandleRef = document.querySelector(activeNodeSelector);
|
|
28
|
-
var items = (0, _blockMenuItems.getBlockMenuItems)(formatMessage);
|
|
29
|
-
var handleOpenChange = (0, _react.useCallback)(function (payload) {
|
|
30
|
-
if (!(payload !== null && payload !== void 0 && payload.isOpen)) {
|
|
31
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.toggleBlockMenu({
|
|
32
|
-
closeMenu: true
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
}, [api === null || api === void 0 ? void 0 : api.core.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands]);
|
|
36
|
-
var onMenuItemActivated = (0, _react.useCallback)(function (_ref2) {
|
|
37
|
-
var item = _ref2.item;
|
|
38
|
-
if (editorView) {
|
|
39
|
-
var _menuItemsCallback, _menuItemsCallback$ca;
|
|
40
|
-
(_menuItemsCallback = _blockMenuItems.menuItemsCallback[item.value.name]) === null || _menuItemsCallback === void 0 || (_menuItemsCallback$ca = _menuItemsCallback.call(_blockMenuItems.menuItemsCallback, api, formatMessage)) === null || _menuItemsCallback$ca === void 0 || _menuItemsCallback$ca(editorView.state, editorView.dispatch, editorView);
|
|
41
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.toggleBlockMenu({
|
|
42
|
-
closeMenu: true
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
}, [api, editorView, formatMessage]);
|
|
46
|
-
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
47
|
-
alignX: 'left',
|
|
48
|
-
alignY: 'start'
|
|
49
|
-
// Ignored via go/ees005
|
|
50
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
51
|
-
,
|
|
52
|
-
target: targetHandleRef,
|
|
53
|
-
mountTo: undefined,
|
|
54
|
-
zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
|
|
55
|
-
forcePlacement: true,
|
|
56
|
-
stick: true,
|
|
57
|
-
offset: [-6, 8]
|
|
58
|
-
}, /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenu, {
|
|
59
|
-
mountTo: mountPoint,
|
|
60
|
-
boundariesElement: boundariesElement,
|
|
61
|
-
scrollableElement: scrollableElement
|
|
62
|
-
//This needs be removed when the a11y is completely handled
|
|
63
|
-
//Disabling key navigation now as it works only partially
|
|
64
|
-
,
|
|
65
|
-
arrowKeyNavigationProviderOptions: {
|
|
66
|
-
type: _uiMenu.ArrowKeyNavigationType.MENU
|
|
67
|
-
},
|
|
68
|
-
items: items,
|
|
69
|
-
isOpen: true,
|
|
70
|
-
fitWidth: _consts.BLOCK_MENU_WIDTH,
|
|
71
|
-
section: {
|
|
72
|
-
hasSeparator: true
|
|
73
|
-
},
|
|
74
|
-
onOpenChange: handleOpenChange,
|
|
75
|
-
onItemActivated: onMenuItemActivated
|
|
76
|
-
}));
|
|
77
|
-
};
|
|
78
|
-
var BlockMenu = function BlockMenu(_ref3) {
|
|
79
|
-
var editorView = _ref3.editorView,
|
|
80
|
-
mountPoint = _ref3.mountPoint,
|
|
81
|
-
boundariesElement = _ref3.boundariesElement,
|
|
82
|
-
scrollableElement = _ref3.scrollableElement,
|
|
83
|
-
api = _ref3.api,
|
|
84
|
-
formatMessage = _ref3.intl.formatMessage;
|
|
85
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
86
|
-
var _states$blockControls, _states$blockControls2;
|
|
87
|
-
return {
|
|
88
|
-
isMenuOpen: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isMenuOpen,
|
|
89
|
-
menuTriggerBy: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.menuTriggerBy
|
|
90
|
-
};
|
|
91
|
-
}),
|
|
92
|
-
isMenuOpen = _useSharedPluginState.isMenuOpen,
|
|
93
|
-
menuTriggerBy = _useSharedPluginState.menuTriggerBy;
|
|
94
|
-
if (isMenuOpen) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
if (!menuTriggerBy) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
return /*#__PURE__*/_react.default.createElement(BlockMenuContent, {
|
|
101
|
-
editorView: editorView,
|
|
102
|
-
mountPoint: mountPoint,
|
|
103
|
-
boundariesElement: boundariesElement,
|
|
104
|
-
scrollableElement: scrollableElement,
|
|
105
|
-
api: api,
|
|
106
|
-
menuTriggerBy: menuTriggerBy,
|
|
107
|
-
formatMessage: formatMessage
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(BlockMenu);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
|
-
/**
|
|
3
|
-
* @jsxRuntime classic
|
|
4
|
-
* @jsx jsx
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
import { jsx } from '@emotion/react';
|
|
9
|
-
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
10
|
-
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
11
|
-
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
12
|
-
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
13
|
-
import ArrowDownIcon from '@atlaskit/icon/core/arrow-down';
|
|
14
|
-
import ArrowLeftIcon from '@atlaskit/icon/core/arrow-left';
|
|
15
|
-
import ArrowRightnIcon from '@atlaskit/icon/core/arrow-right';
|
|
16
|
-
import ArrowUpIcon from '@atlaskit/icon/core/arrow-up';
|
|
17
|
-
import { moveNodeViaShortcut } from '../editor-commands/move-node';
|
|
18
|
-
export const getBlockMenuItems = formatMessage => {
|
|
19
|
-
return [{
|
|
20
|
-
items: [{
|
|
21
|
-
content: formatMessage(blockControlsMessages.moveUp),
|
|
22
|
-
elemBefore: jsx(ArrowUpIcon, {
|
|
23
|
-
label: ""
|
|
24
|
-
}),
|
|
25
|
-
value: {
|
|
26
|
-
name: 'moveUp'
|
|
27
|
-
},
|
|
28
|
-
key: 'move_up',
|
|
29
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
30
|
-
elemAfter: jsx("div", {
|
|
31
|
-
css: shortcutStyle
|
|
32
|
-
}, tooltip(dragToMoveUp))
|
|
33
|
-
}, {
|
|
34
|
-
content: formatMessage(blockControlsMessages.moveDown),
|
|
35
|
-
elemBefore: jsx(ArrowDownIcon, {
|
|
36
|
-
label: ""
|
|
37
|
-
}),
|
|
38
|
-
value: {
|
|
39
|
-
name: 'moveDown'
|
|
40
|
-
},
|
|
41
|
-
key: 'move_down',
|
|
42
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
43
|
-
elemAfter: jsx("div", {
|
|
44
|
-
css: shortcutStyle
|
|
45
|
-
}, tooltip(dragToMoveDown))
|
|
46
|
-
}, {
|
|
47
|
-
content: formatMessage(blockControlsMessages.moveLeft),
|
|
48
|
-
elemBefore: jsx(ArrowLeftIcon, {
|
|
49
|
-
label: ""
|
|
50
|
-
}),
|
|
51
|
-
value: {
|
|
52
|
-
name: 'moveLeft'
|
|
53
|
-
},
|
|
54
|
-
key: 'move_left',
|
|
55
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
56
|
-
elemAfter: jsx("div", {
|
|
57
|
-
css: shortcutStyle
|
|
58
|
-
}, tooltip(dragToMoveLeft))
|
|
59
|
-
}, {
|
|
60
|
-
content: formatMessage(blockControlsMessages.moveRight),
|
|
61
|
-
elemBefore: jsx(ArrowRightnIcon, {
|
|
62
|
-
label: ""
|
|
63
|
-
}),
|
|
64
|
-
value: {
|
|
65
|
-
name: 'moveRight'
|
|
66
|
-
},
|
|
67
|
-
key: 'move_right',
|
|
68
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
69
|
-
elemAfter: jsx("div", {
|
|
70
|
-
css: shortcutStyle
|
|
71
|
-
}, tooltip(dragToMoveRight))
|
|
72
|
-
}]
|
|
73
|
-
}];
|
|
74
|
-
};
|
|
75
|
-
export const menuItemsCallback = {
|
|
76
|
-
moveUp: (api, formatMessage) => {
|
|
77
|
-
return moveNodeViaShortcut(api, DIRECTION.UP, formatMessage);
|
|
78
|
-
},
|
|
79
|
-
moveDown: (api, formatMessage) => {
|
|
80
|
-
return moveNodeViaShortcut(api, DIRECTION.DOWN, formatMessage);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { injectIntl } from 'react-intl-next';
|
|
3
|
-
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
5
|
-
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
-
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
-
import { getBlockMenuItems, menuItemsCallback } from './block-menu-items';
|
|
8
|
-
import { BLOCK_MENU_WIDTH } from './consts';
|
|
9
|
-
import { getAnchorAttrName } from './utils/dom-attr-name';
|
|
10
|
-
const BlockMenuContent = ({
|
|
11
|
-
editorView,
|
|
12
|
-
mountPoint,
|
|
13
|
-
boundariesElement,
|
|
14
|
-
scrollableElement,
|
|
15
|
-
api,
|
|
16
|
-
menuTriggerBy,
|
|
17
|
-
formatMessage
|
|
18
|
-
}) => {
|
|
19
|
-
const activeNodeSelector = `[${getAnchorAttrName()}=${menuTriggerBy}]`;
|
|
20
|
-
const targetHandleRef = document.querySelector(activeNodeSelector);
|
|
21
|
-
const items = getBlockMenuItems(formatMessage);
|
|
22
|
-
const handleOpenChange = useCallback(payload => {
|
|
23
|
-
if (!(payload !== null && payload !== void 0 && payload.isOpen)) {
|
|
24
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.toggleBlockMenu({
|
|
25
|
-
closeMenu: true
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
}, [api === null || api === void 0 ? void 0 : api.core.actions, api === null || api === void 0 ? void 0 : api.blockControls.commands]);
|
|
29
|
-
const onMenuItemActivated = useCallback(({
|
|
30
|
-
item
|
|
31
|
-
}) => {
|
|
32
|
-
if (editorView) {
|
|
33
|
-
var _menuItemsCallback, _menuItemsCallback$ca;
|
|
34
|
-
(_menuItemsCallback = menuItemsCallback[item.value.name]) === null || _menuItemsCallback === void 0 ? void 0 : (_menuItemsCallback$ca = _menuItemsCallback.call(menuItemsCallback, api, formatMessage)) === null || _menuItemsCallback$ca === void 0 ? void 0 : _menuItemsCallback$ca(editorView.state, editorView.dispatch, editorView);
|
|
35
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.toggleBlockMenu({
|
|
36
|
-
closeMenu: true
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
}, [api, editorView, formatMessage]);
|
|
40
|
-
return /*#__PURE__*/React.createElement(Popup, {
|
|
41
|
-
alignX: 'left',
|
|
42
|
-
alignY: 'start'
|
|
43
|
-
// Ignored via go/ees005
|
|
44
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
45
|
-
,
|
|
46
|
-
target: targetHandleRef,
|
|
47
|
-
mountTo: undefined,
|
|
48
|
-
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
49
|
-
forcePlacement: true,
|
|
50
|
-
stick: true,
|
|
51
|
-
offset: [-6, 8]
|
|
52
|
-
}, /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
53
|
-
mountTo: mountPoint,
|
|
54
|
-
boundariesElement: boundariesElement,
|
|
55
|
-
scrollableElement: scrollableElement
|
|
56
|
-
//This needs be removed when the a11y is completely handled
|
|
57
|
-
//Disabling key navigation now as it works only partially
|
|
58
|
-
,
|
|
59
|
-
arrowKeyNavigationProviderOptions: {
|
|
60
|
-
type: ArrowKeyNavigationType.MENU
|
|
61
|
-
},
|
|
62
|
-
items: items,
|
|
63
|
-
isOpen: true,
|
|
64
|
-
fitWidth: BLOCK_MENU_WIDTH,
|
|
65
|
-
section: {
|
|
66
|
-
hasSeparator: true
|
|
67
|
-
},
|
|
68
|
-
onOpenChange: handleOpenChange,
|
|
69
|
-
onItemActivated: onMenuItemActivated
|
|
70
|
-
}));
|
|
71
|
-
};
|
|
72
|
-
const BlockMenu = ({
|
|
73
|
-
editorView,
|
|
74
|
-
mountPoint,
|
|
75
|
-
boundariesElement,
|
|
76
|
-
scrollableElement,
|
|
77
|
-
api,
|
|
78
|
-
intl: {
|
|
79
|
-
formatMessage
|
|
80
|
-
}
|
|
81
|
-
}) => {
|
|
82
|
-
const {
|
|
83
|
-
isMenuOpen,
|
|
84
|
-
menuTriggerBy
|
|
85
|
-
} = useSharedPluginStateWithSelector(api, ['blockControls'], states => {
|
|
86
|
-
var _states$blockControls, _states$blockControls2;
|
|
87
|
-
return {
|
|
88
|
-
isMenuOpen: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.isMenuOpen,
|
|
89
|
-
menuTriggerBy: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.menuTriggerBy
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
if (isMenuOpen) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
if (!menuTriggerBy) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
return /*#__PURE__*/React.createElement(BlockMenuContent, {
|
|
99
|
-
editorView: editorView,
|
|
100
|
-
mountPoint: mountPoint,
|
|
101
|
-
boundariesElement: boundariesElement,
|
|
102
|
-
scrollableElement: scrollableElement,
|
|
103
|
-
api: api,
|
|
104
|
-
menuTriggerBy: menuTriggerBy,
|
|
105
|
-
formatMessage: formatMessage
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
export default injectIntl(BlockMenu);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
|
-
/**
|
|
3
|
-
* @jsxRuntime classic
|
|
4
|
-
* @jsx jsx
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
import { jsx } from '@emotion/react';
|
|
9
|
-
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
10
|
-
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
11
|
-
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
12
|
-
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
13
|
-
import ArrowDownIcon from '@atlaskit/icon/core/arrow-down';
|
|
14
|
-
import ArrowLeftIcon from '@atlaskit/icon/core/arrow-left';
|
|
15
|
-
import ArrowRightnIcon from '@atlaskit/icon/core/arrow-right';
|
|
16
|
-
import ArrowUpIcon from '@atlaskit/icon/core/arrow-up';
|
|
17
|
-
import { moveNodeViaShortcut } from '../editor-commands/move-node';
|
|
18
|
-
export var getBlockMenuItems = function getBlockMenuItems(formatMessage) {
|
|
19
|
-
return [{
|
|
20
|
-
items: [{
|
|
21
|
-
content: formatMessage(blockControlsMessages.moveUp),
|
|
22
|
-
elemBefore: jsx(ArrowUpIcon, {
|
|
23
|
-
label: ""
|
|
24
|
-
}),
|
|
25
|
-
value: {
|
|
26
|
-
name: 'moveUp'
|
|
27
|
-
},
|
|
28
|
-
key: 'move_up',
|
|
29
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
30
|
-
elemAfter: jsx("div", {
|
|
31
|
-
css: shortcutStyle
|
|
32
|
-
}, tooltip(dragToMoveUp))
|
|
33
|
-
}, {
|
|
34
|
-
content: formatMessage(blockControlsMessages.moveDown),
|
|
35
|
-
elemBefore: jsx(ArrowDownIcon, {
|
|
36
|
-
label: ""
|
|
37
|
-
}),
|
|
38
|
-
value: {
|
|
39
|
-
name: 'moveDown'
|
|
40
|
-
},
|
|
41
|
-
key: 'move_down',
|
|
42
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
43
|
-
elemAfter: jsx("div", {
|
|
44
|
-
css: shortcutStyle
|
|
45
|
-
}, tooltip(dragToMoveDown))
|
|
46
|
-
}, {
|
|
47
|
-
content: formatMessage(blockControlsMessages.moveLeft),
|
|
48
|
-
elemBefore: jsx(ArrowLeftIcon, {
|
|
49
|
-
label: ""
|
|
50
|
-
}),
|
|
51
|
-
value: {
|
|
52
|
-
name: 'moveLeft'
|
|
53
|
-
},
|
|
54
|
-
key: 'move_left',
|
|
55
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
56
|
-
elemAfter: jsx("div", {
|
|
57
|
-
css: shortcutStyle
|
|
58
|
-
}, tooltip(dragToMoveLeft))
|
|
59
|
-
}, {
|
|
60
|
-
content: formatMessage(blockControlsMessages.moveRight),
|
|
61
|
-
elemBefore: jsx(ArrowRightnIcon, {
|
|
62
|
-
label: ""
|
|
63
|
-
}),
|
|
64
|
-
value: {
|
|
65
|
-
name: 'moveRight'
|
|
66
|
-
},
|
|
67
|
-
key: 'move_right',
|
|
68
|
-
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
69
|
-
elemAfter: jsx("div", {
|
|
70
|
-
css: shortcutStyle
|
|
71
|
-
}, tooltip(dragToMoveRight))
|
|
72
|
-
}]
|
|
73
|
-
}];
|
|
74
|
-
};
|
|
75
|
-
export var menuItemsCallback = {
|
|
76
|
-
moveUp: function moveUp(api, formatMessage) {
|
|
77
|
-
return moveNodeViaShortcut(api, DIRECTION.UP, formatMessage);
|
|
78
|
-
},
|
|
79
|
-
moveDown: function moveDown(api, formatMessage) {
|
|
80
|
-
return moveNodeViaShortcut(api, DIRECTION.DOWN, formatMessage);
|
|
81
|
-
}
|
|
82
|
-
};
|