@atlaskit/editor-plugin-block-controls 2.27.0 → 2.27.4
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 +39 -0
- package/dist/cjs/blockControlsPlugin.js +35 -6
- package/dist/cjs/pm-plugins/decorations-drop-target.js +11 -5
- package/dist/cjs/pm-plugins/main.js +2 -1
- package/dist/cjs/pm-plugins/utils/getSelection.js +2 -2
- package/dist/cjs/pm-plugins/utils/validation.js +2 -1
- package/dist/cjs/ui/block-menu-items.js +103 -0
- package/dist/cjs/ui/block-menu.js +77 -0
- package/dist/cjs/ui/consts.js +101 -2
- package/dist/cjs/ui/drag-handle.js +147 -41
- package/dist/cjs/ui/drag-preview.js +83 -34
- package/dist/es2019/blockControlsPlugin.js +34 -3
- package/dist/es2019/pm-plugins/decorations-drop-target.js +12 -5
- package/dist/es2019/pm-plugins/main.js +2 -1
- package/dist/es2019/pm-plugins/utils/getSelection.js +1 -1
- package/dist/es2019/pm-plugins/utils/validation.js +2 -1
- package/dist/es2019/ui/block-menu-items.js +92 -0
- package/dist/es2019/ui/block-menu.js +75 -0
- package/dist/es2019/ui/consts.js +100 -1
- package/dist/es2019/ui/drag-handle.js +152 -40
- package/dist/es2019/ui/drag-preview.js +83 -34
- package/dist/esm/blockControlsPlugin.js +35 -6
- package/dist/esm/pm-plugins/decorations-drop-target.js +11 -5
- package/dist/esm/pm-plugins/main.js +2 -1
- package/dist/esm/pm-plugins/utils/getSelection.js +1 -1
- package/dist/esm/pm-plugins/utils/validation.js +2 -1
- package/dist/esm/ui/block-menu-items.js +92 -0
- package/dist/esm/ui/block-menu.js +70 -0
- package/dist/esm/ui/consts.js +100 -1
- package/dist/esm/ui/drag-handle.js +149 -43
- package/dist/esm/ui/drag-preview.js +82 -34
- package/dist/types/blockControlsPluginType.d.ts +3 -0
- package/dist/types/pm-plugins/utils/getSelection.d.ts +3 -3
- package/dist/types/pm-plugins/utils/validation.d.ts +1 -1
- package/dist/types/ui/block-menu-items.d.ts +17 -0
- package/dist/types/ui/block-menu.d.ts +16 -0
- package/dist/types/ui/consts.d.ts +7 -0
- package/dist/types/ui/drag-preview.d.ts +9 -1
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/utils/getSelection.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/utils/validation.d.ts +1 -1
- package/dist/types-ts4.5/ui/block-menu-items.d.ts +17 -0
- package/dist/types-ts4.5/ui/block-menu.d.ts +16 -0
- package/dist/types-ts4.5/ui/consts.d.ts +7 -0
- package/dist/types-ts4.5/ui/drag-preview.d.ts +9 -1
- package/package.json +5 -5
|
@@ -4,9 +4,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
6
6
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { moveNode } from './editor-commands/move-node';
|
|
8
9
|
import { moveToLayout } from './editor-commands/move-to-layout';
|
|
9
10
|
import { createPlugin, key } from './pm-plugins/main';
|
|
11
|
+
import BlockMenu from './ui/block-menu';
|
|
10
12
|
import { DragHandleMenu } from './ui/drag-handle-menu';
|
|
11
13
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
12
14
|
export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
@@ -36,14 +38,31 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
36
38
|
anchorName: anchorName,
|
|
37
39
|
nodeType: nodeType,
|
|
38
40
|
handleOptions: handleOptions
|
|
39
|
-
}
|
|
41
|
+
},
|
|
42
|
+
closeMenu: editorExperiment('platform_editor_controls', 'variant1') ? true : undefined
|
|
40
43
|
}));
|
|
41
44
|
return tr;
|
|
42
45
|
};
|
|
43
46
|
},
|
|
44
|
-
|
|
47
|
+
toggleBlockMenu: function toggleBlockMenu(options) {
|
|
45
48
|
return function (_ref4) {
|
|
46
49
|
var tr = _ref4.tr;
|
|
50
|
+
var currMeta = tr.getMeta(key);
|
|
51
|
+
if (options !== null && options !== void 0 && options.closeMenu) {
|
|
52
|
+
tr.setMeta(key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
53
|
+
closeMenu: true
|
|
54
|
+
}));
|
|
55
|
+
return tr;
|
|
56
|
+
}
|
|
57
|
+
tr.setMeta(key, _objectSpread(_objectSpread({}, currMeta), {}, {
|
|
58
|
+
toggleMenu: true
|
|
59
|
+
}));
|
|
60
|
+
return tr;
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
setNodeDragged: function setNodeDragged(getPos, anchorName, nodeType) {
|
|
64
|
+
return function (_ref5) {
|
|
65
|
+
var tr = _ref5.tr;
|
|
47
66
|
var pos = getPos();
|
|
48
67
|
if (pos === undefined) {
|
|
49
68
|
return tr;
|
|
@@ -61,9 +80,9 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
61
80
|
};
|
|
62
81
|
},
|
|
63
82
|
setMultiSelectPositions: function setMultiSelectPositions(anchor, head) {
|
|
64
|
-
return function (
|
|
83
|
+
return function (_ref6) {
|
|
65
84
|
var _api$selection;
|
|
66
|
-
var tr =
|
|
85
|
+
var tr = _ref6.tr;
|
|
67
86
|
var _tr$selection = tr.selection,
|
|
68
87
|
userAnchor = _tr$selection.anchor,
|
|
69
88
|
userHead = _tr$selection.head;
|
|
@@ -111,8 +130,18 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
111
130
|
multiSelectDnD: (_key$getState$multiSe = (_key$getState5 = key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined
|
|
112
131
|
};
|
|
113
132
|
},
|
|
114
|
-
contentComponent: function contentComponent() {
|
|
115
|
-
|
|
133
|
+
contentComponent: function contentComponent(_ref7) {
|
|
134
|
+
var editorView = _ref7.editorView,
|
|
135
|
+
popupsMountPoint = _ref7.popupsMountPoint,
|
|
136
|
+
popupsBoundariesElement = _ref7.popupsBoundariesElement,
|
|
137
|
+
popupsScrollableElement = _ref7.popupsScrollableElement;
|
|
138
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, editorExperiment('platform_editor_controls', 'variant1') ? /*#__PURE__*/React.createElement(BlockMenu, {
|
|
139
|
+
editorView: editorView,
|
|
140
|
+
mountPoint: popupsMountPoint,
|
|
141
|
+
boundariesElement: popupsBoundariesElement,
|
|
142
|
+
scrollableElement: popupsScrollableElement,
|
|
143
|
+
api: api
|
|
144
|
+
}) : /*#__PURE__*/React.createElement(DragHandleMenu, {
|
|
116
145
|
api: api
|
|
117
146
|
}), /*#__PURE__*/React.createElement(GlobalStylesWrapper, null));
|
|
118
147
|
}
|
|
@@ -3,6 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
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
4
|
import { createElement } from 'react';
|
|
5
5
|
import uuid from 'uuid';
|
|
6
|
+
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
6
7
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
8
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -159,6 +160,15 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
159
160
|
prevNodeStack.push(node);
|
|
160
161
|
};
|
|
161
162
|
var isAdvancedLayoutsPreRelease2 = editorExperiment('advanced_layouts', true);
|
|
163
|
+
|
|
164
|
+
// For deciding to show drop targets or not when multiple nodes are selected
|
|
165
|
+
var selection = newState.selection;
|
|
166
|
+
var _expandSelectionBound = expandSelectionBounds(selection.$anchor, selection.$head),
|
|
167
|
+
expandedAnchor = _expandSelectionBound.$anchor,
|
|
168
|
+
expandedHead = _expandSelectionBound.$head;
|
|
169
|
+
var selectionFrom = Math.min(expandedAnchor.pos, expandedHead.pos);
|
|
170
|
+
var selectionTo = Math.max(expandedAnchor.pos, expandedHead.pos);
|
|
171
|
+
var handleInsideSelection = activeNodePos !== undefined && activeNodePos >= selectionFrom && activeNodePos <= selectionTo;
|
|
162
172
|
newState.doc.nodesBetween(docFrom, docTo, function (node, pos, parent, index) {
|
|
163
173
|
var depth = 0;
|
|
164
174
|
// drop target deco at the end position
|
|
@@ -193,10 +203,6 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
193
203
|
|
|
194
204
|
// When multi select is on, validate all the nodes in the selection instead of just the handle node
|
|
195
205
|
if (isMultiSelect) {
|
|
196
|
-
var selection = newState.selection;
|
|
197
|
-
var selectionFrom = selection.$from.pos;
|
|
198
|
-
var selectionTo = selection.$to.pos;
|
|
199
|
-
var handleInsideSelection = activeNodePos !== undefined && activeNodePos >= selectionFrom - 1 && activeNodePos <= selectionTo;
|
|
200
206
|
var selectionSlice = newState.doc.slice(selectionFrom, selectionTo, false);
|
|
201
207
|
var selectionSliceChildCount = selectionSlice.content.childCount;
|
|
202
208
|
var canDropSingleNode = true;
|
|
@@ -204,7 +210,7 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
204
210
|
|
|
205
211
|
// when there is only one node in the slice, use the same logic as when multi select is not on
|
|
206
212
|
if (selectionSliceChildCount > 1 && handleInsideSelection) {
|
|
207
|
-
canDropMultipleNodes = canMoveSliceToIndex(selectionSlice, selectionFrom,
|
|
213
|
+
canDropMultipleNodes = canMoveSliceToIndex(selectionSlice, selectionFrom, parent, index, $pos);
|
|
208
214
|
} else {
|
|
209
215
|
canDropSingleNode = !!(activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node));
|
|
210
216
|
}
|
|
@@ -275,11 +275,12 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
|
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
var newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && findHandleDec(decorations, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos).length === 0 ? null : latestActiveNode;
|
|
278
|
+
var isMenuOpenNew = editorExperiment('platform_editor_controls', 'variant1') ? meta !== null && meta !== void 0 && meta.closeMenu ? false : meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen : meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen;
|
|
278
279
|
return {
|
|
279
280
|
decorations: decorations,
|
|
280
281
|
activeNode: newActiveNode,
|
|
281
282
|
isDragging: (_meta$isDragging2 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging2 !== void 0 ? _meta$isDragging2 : isDragging,
|
|
282
|
-
isMenuOpen:
|
|
283
|
+
isMenuOpen: isMenuOpenNew,
|
|
283
284
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : editorHeight,
|
|
284
285
|
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : editorWidthLeft,
|
|
285
286
|
editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : editorWidthRight,
|
|
@@ -94,7 +94,7 @@ export var setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(
|
|
|
94
94
|
* @param handlePos
|
|
95
95
|
* @returns
|
|
96
96
|
*/
|
|
97
|
-
export var
|
|
97
|
+
export var isHandleCorrelatedToSelection = function isHandleCorrelatedToSelection(state, selection, handlePos) {
|
|
98
98
|
if (selection.empty) {
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
@@ -112,8 +112,9 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
|
|
|
112
112
|
}
|
|
113
113
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
114
114
|
}
|
|
115
|
-
export function canMoveSliceToIndex(slice, sliceFromPos,
|
|
115
|
+
export function canMoveSliceToIndex(slice, sliceFromPos, destParent, indexIntoParent, $destNodePos, destNode) {
|
|
116
116
|
var canMoveNodes = true;
|
|
117
|
+
var doc = $destNodePos.doc;
|
|
117
118
|
var nodesPos = [];
|
|
118
119
|
for (var i = 0; i < slice.content.childCount; i++) {
|
|
119
120
|
var node = slice.content.maybeChild(i);
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { copy, deleteKey, dragToMoveDown, dragToMoveUp, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
10
|
+
import commonMessages, { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
11
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
12
|
+
import ArrowDownIcon from '@atlaskit/icon/core/arrow-down';
|
|
13
|
+
import ArrowUpIcon from '@atlaskit/icon/core/arrow-up';
|
|
14
|
+
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
15
|
+
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
16
|
+
import { moveNodeViaShortcut } from '../editor-commands/move-node';
|
|
17
|
+
import { DIRECTION } from '../pm-plugins/utils/consts';
|
|
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
|
+
}, {
|
|
48
|
+
items: [{
|
|
49
|
+
content: formatMessage(commonMessages.copyToClipboard),
|
|
50
|
+
value: {
|
|
51
|
+
name: 'copy'
|
|
52
|
+
},
|
|
53
|
+
elemBefore: jsx(CopyIcon, {
|
|
54
|
+
label: ""
|
|
55
|
+
}),
|
|
56
|
+
key: 'copy',
|
|
57
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
58
|
+
elemAfter: jsx("div", {
|
|
59
|
+
css: shortcutStyle
|
|
60
|
+
}, tooltip(copy))
|
|
61
|
+
}, {
|
|
62
|
+
content: formatMessage(blockControlsMessages.delete),
|
|
63
|
+
value: {
|
|
64
|
+
name: 'delete'
|
|
65
|
+
},
|
|
66
|
+
elemBefore: jsx(DeleteIcon, {
|
|
67
|
+
label: ""
|
|
68
|
+
}),
|
|
69
|
+
key: 'delete',
|
|
70
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
71
|
+
elemAfter: jsx("div", {
|
|
72
|
+
css: shortcutStyle
|
|
73
|
+
}, tooltip(deleteKey))
|
|
74
|
+
}]
|
|
75
|
+
}];
|
|
76
|
+
};
|
|
77
|
+
export var menuItemsCallback = {
|
|
78
|
+
moveUp: function moveUp(api, formatMessage) {
|
|
79
|
+
return moveNodeViaShortcut(api, DIRECTION.UP, formatMessage);
|
|
80
|
+
},
|
|
81
|
+
moveDown: function moveDown(api, formatMessage) {
|
|
82
|
+
return moveNodeViaShortcut(api, DIRECTION.DOWN, formatMessage);
|
|
83
|
+
},
|
|
84
|
+
copy: function copy() {
|
|
85
|
+
// TODO: implement copy
|
|
86
|
+
// console.log('copy');
|
|
87
|
+
},
|
|
88
|
+
delete: function _delete() {
|
|
89
|
+
// TODO: implement delete
|
|
90
|
+
// console.log('delete');
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { injectIntl } from 'react-intl-next';
|
|
3
|
+
import { useSharedPluginState } 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
|
+
var dragHandleSelector = '[data-blocks-drag-handle-container="true"] button';
|
|
10
|
+
var BlockMenu = function BlockMenu(_ref) {
|
|
11
|
+
var editorView = _ref.editorView,
|
|
12
|
+
mountPoint = _ref.mountPoint,
|
|
13
|
+
boundariesElement = _ref.boundariesElement,
|
|
14
|
+
scrollableElement = _ref.scrollableElement,
|
|
15
|
+
api = _ref.api,
|
|
16
|
+
formatMessage = _ref.intl.formatMessage;
|
|
17
|
+
var _useSharedPluginState = useSharedPluginState(api, ['blockControls']),
|
|
18
|
+
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
19
|
+
if (!(blockControlsState !== null && blockControlsState !== void 0 && blockControlsState.isMenuOpen)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
var targetHandleRef = document.querySelector(dragHandleSelector);
|
|
23
|
+
var items = getBlockMenuItems(formatMessage);
|
|
24
|
+
var handleOpenChange = function handleOpenChange(payload) {
|
|
25
|
+
if (!(payload !== null && payload !== void 0 && payload.isOpen)) {
|
|
26
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.toggleBlockMenu({
|
|
27
|
+
closeMenu: true
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var onMenuItemActivated = function onMenuItemActivated(_ref2) {
|
|
32
|
+
var item = _ref2.item;
|
|
33
|
+
if (editorView) {
|
|
34
|
+
var _menuItemsCallback, _menuItemsCallback$ca;
|
|
35
|
+
(_menuItemsCallback = menuItemsCallback[item.value.name]) === null || _menuItemsCallback === void 0 || (_menuItemsCallback$ca = _menuItemsCallback.call(menuItemsCallback, api, formatMessage)) === null || _menuItemsCallback$ca === void 0 || _menuItemsCallback$ca(editorView.state, editorView.dispatch, editorView);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
39
|
+
alignX: 'right',
|
|
40
|
+
alignY: 'start'
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
43
|
+
,
|
|
44
|
+
target: targetHandleRef,
|
|
45
|
+
mountTo: undefined,
|
|
46
|
+
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
47
|
+
forcePlacement: true,
|
|
48
|
+
stick: true,
|
|
49
|
+
offset: [-18, 8]
|
|
50
|
+
}, /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
51
|
+
mountTo: mountPoint,
|
|
52
|
+
boundariesElement: boundariesElement,
|
|
53
|
+
scrollableElement: scrollableElement
|
|
54
|
+
//This needs be removed when the a11y is completely handled
|
|
55
|
+
//Disabling key navigation now as it works only partially
|
|
56
|
+
,
|
|
57
|
+
arrowKeyNavigationProviderOptions: {
|
|
58
|
+
type: ArrowKeyNavigationType.MENU
|
|
59
|
+
},
|
|
60
|
+
items: items,
|
|
61
|
+
isOpen: true,
|
|
62
|
+
fitWidth: BLOCK_MENU_WIDTH,
|
|
63
|
+
section: {
|
|
64
|
+
hasSeparator: true
|
|
65
|
+
},
|
|
66
|
+
onOpenChange: handleOpenChange,
|
|
67
|
+
onItemActivated: onMenuItemActivated
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
export default injectIntl(BlockMenu);
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -104,6 +104,104 @@ Array.from({
|
|
|
104
104
|
}, 1000);
|
|
105
105
|
return [currKeyValue, dropTargetMarginMap[value]];
|
|
106
106
|
}));
|
|
107
|
+
export var spacingBetweenNodesForPreview = {
|
|
108
|
+
paragraph: {
|
|
109
|
+
top: '0.75rem',
|
|
110
|
+
bottom: '0'
|
|
111
|
+
},
|
|
112
|
+
heading1: {
|
|
113
|
+
top: '1.45833em',
|
|
114
|
+
bottom: '0'
|
|
115
|
+
},
|
|
116
|
+
heading2: {
|
|
117
|
+
top: '1.4em',
|
|
118
|
+
bottom: '0'
|
|
119
|
+
},
|
|
120
|
+
heading3: {
|
|
121
|
+
top: '1.31249em',
|
|
122
|
+
bottom: '0'
|
|
123
|
+
},
|
|
124
|
+
heading4: {
|
|
125
|
+
top: '1.25em',
|
|
126
|
+
bottom: '0'
|
|
127
|
+
},
|
|
128
|
+
heading5: {
|
|
129
|
+
top: '1.45833em',
|
|
130
|
+
bottom: '0'
|
|
131
|
+
},
|
|
132
|
+
heading6: {
|
|
133
|
+
top: '1.59091em',
|
|
134
|
+
bottom: '0'
|
|
135
|
+
},
|
|
136
|
+
table: {
|
|
137
|
+
top: '0',
|
|
138
|
+
bottom: '0'
|
|
139
|
+
},
|
|
140
|
+
bulletList: {
|
|
141
|
+
top: '10px',
|
|
142
|
+
bottom: '0'
|
|
143
|
+
},
|
|
144
|
+
orderedList: {
|
|
145
|
+
top: '10px',
|
|
146
|
+
bottom: '0'
|
|
147
|
+
},
|
|
148
|
+
decisionList: {
|
|
149
|
+
top: '0.5rem',
|
|
150
|
+
bottom: '0'
|
|
151
|
+
},
|
|
152
|
+
taskList: {
|
|
153
|
+
top: '0.75rem',
|
|
154
|
+
bottom: '0'
|
|
155
|
+
},
|
|
156
|
+
codeBlock: {
|
|
157
|
+
top: '0.75rem',
|
|
158
|
+
bottom: '0'
|
|
159
|
+
},
|
|
160
|
+
panel: {
|
|
161
|
+
top: '0.75rem',
|
|
162
|
+
bottom: '0'
|
|
163
|
+
},
|
|
164
|
+
rule: {
|
|
165
|
+
top: '1.5rem',
|
|
166
|
+
bottom: '1.5rem'
|
|
167
|
+
},
|
|
168
|
+
mediaSingle: {
|
|
169
|
+
top: '24px',
|
|
170
|
+
bottom: '24px'
|
|
171
|
+
},
|
|
172
|
+
media: {
|
|
173
|
+
top: '24px',
|
|
174
|
+
bottom: '24px'
|
|
175
|
+
},
|
|
176
|
+
bodiedExtension: {
|
|
177
|
+
top: '0',
|
|
178
|
+
bottom: '0'
|
|
179
|
+
},
|
|
180
|
+
extension: {
|
|
181
|
+
top: '0',
|
|
182
|
+
bottom: '0'
|
|
183
|
+
},
|
|
184
|
+
layoutSection: {
|
|
185
|
+
top: '0',
|
|
186
|
+
bottom: '0'
|
|
187
|
+
},
|
|
188
|
+
blockquote: {
|
|
189
|
+
top: '0',
|
|
190
|
+
bottom: '0'
|
|
191
|
+
},
|
|
192
|
+
embedCard: {
|
|
193
|
+
top: '24px',
|
|
194
|
+
bottom: '24px'
|
|
195
|
+
},
|
|
196
|
+
blockCard: {
|
|
197
|
+
top: '0.75rem',
|
|
198
|
+
bottom: '0'
|
|
199
|
+
},
|
|
200
|
+
default: {
|
|
201
|
+
top: '0',
|
|
202
|
+
bottom: '0'
|
|
203
|
+
}
|
|
204
|
+
};
|
|
107
205
|
|
|
108
206
|
// This table contains the "margins" of different nodes
|
|
109
207
|
// Note this is not the actually margin of the DOM elements,
|
|
@@ -205,4 +303,5 @@ export var DEFAULT_COLUMN_DISTRIBUTIONS = {
|
|
|
205
303
|
3: 33.33,
|
|
206
304
|
4: 25,
|
|
207
305
|
5: 20
|
|
208
|
-
};
|
|
306
|
+
};
|
|
307
|
+
export var BLOCK_MENU_WIDTH = 220;
|