@atlaskit/editor-plugin-block-menu 4.0.18 → 4.0.20
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 +16 -0
- package/dist/cjs/ui/block-menu-components.js +3 -4
- package/dist/cjs/ui/block-menu.compiled.css +3 -1
- package/dist/cjs/ui/block-menu.js +26 -15
- package/dist/cjs/ui/copy-section.js +1 -1
- package/dist/es2019/ui/block-menu-components.js +3 -4
- package/dist/es2019/ui/block-menu.compiled.css +3 -1
- package/dist/es2019/ui/block-menu.js +26 -15
- package/dist/es2019/ui/copy-section.js +1 -1
- package/dist/esm/ui/block-menu-components.js +3 -4
- package/dist/esm/ui/block-menu.compiled.css +3 -1
- package/dist/esm/ui/block-menu.js +26 -15
- package/dist/esm/ui/copy-section.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/ui/add-blocks-section.js +0 -21
- package/dist/es2019/ui/add-blocks-section.js +0 -15
- package/dist/esm/ui/add-blocks-section.js +0 -14
- package/dist/types/ui/add-blocks-section.d.ts +0 -7
- package/dist/types-ts4.5/ui/add-blocks-section.d.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 4.0.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e053b5e610ac2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e053b5e610ac2) -
|
|
8
|
+
[ux] EDITOR-1652 add convert to sync block to block menu
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 4.0.19
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`e3ca1a4b9b932`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3ca1a4b9b932) -
|
|
16
|
+
[ux] ED-29489 Remove focus ring when drag handle is clicked and fix menu closing on menu open
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 4.0.18
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -10,7 +10,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
11
11
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
|
-
var _addBlocksSection = require("./add-blocks-section");
|
|
14
13
|
var _copyBlock = _interopRequireDefault(require("./copy-block"));
|
|
15
14
|
var _copyLink = require("./copy-link");
|
|
16
15
|
var _copySection = require("./copy-section");
|
|
@@ -103,9 +102,9 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
103
102
|
rank: _blockMenu.BLOCK_MENU_SECTION_RANK[_blockMenu.ADD_BLOCKS_MENU_SECTION.key],
|
|
104
103
|
component: function component(_ref5) {
|
|
105
104
|
var children = _ref5.children;
|
|
106
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
107
|
-
|
|
108
|
-
},
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
106
|
+
hasSeparator: true
|
|
107
|
+
}, children);
|
|
109
108
|
}
|
|
110
109
|
}] : []), [{
|
|
111
110
|
type: 'block-menu-section',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
|
+
._1cc0glyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])~*){border-block-start:none}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
|
|
4
|
+
._1k2yglyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])){display:none}
|
|
3
5
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
@@ -24,20 +24,26 @@ var _blockMenuProvider = require("./block-menu-provider");
|
|
|
24
24
|
var _blockMenuRenderer = require("./block-menu-renderer");
|
|
25
25
|
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); }
|
|
26
26
|
var styles = {
|
|
27
|
-
base: "_2rko12b0 _bfhk1bhr _16qs1cd0"
|
|
27
|
+
base: "_2rko12b0 _bfhk1bhr _16qs1cd0",
|
|
28
|
+
emptyMenuSectionStyles: "_1cc0glyw _1k2yglyw"
|
|
28
29
|
};
|
|
29
30
|
var DEFAULT_MENU_WIDTH = 230;
|
|
30
31
|
var DRAG_HANDLE_OFFSET_PADDING = 5;
|
|
31
32
|
var PopupWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(_ui.Popup);
|
|
32
33
|
var BlockMenuContent = function BlockMenuContent(_ref) {
|
|
33
34
|
var _api$blockMenu;
|
|
34
|
-
var api = _ref.api
|
|
35
|
-
|
|
35
|
+
var api = _ref.api,
|
|
36
|
+
setRef = _ref.setRef;
|
|
36
37
|
var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
38
|
+
var setOutsideClickTargetRef = (0, _react.useContext)(_uiReact.OutsideClickTargetRefContext);
|
|
39
|
+
var ref = function ref(el) {
|
|
40
|
+
setOutsideClickTargetRef(el);
|
|
41
|
+
setRef === null || setRef === void 0 || setRef(el);
|
|
42
|
+
};
|
|
37
43
|
return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
38
44
|
testId: "editor-block-menu",
|
|
39
|
-
ref:
|
|
40
|
-
xcss: (0, _css.cx)(styles.base)
|
|
45
|
+
ref: ref,
|
|
46
|
+
xcss: (0, _css.cx)(styles.base, (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_synced_block', 'isEnabled', true) && styles.emptyMenuSectionStyles)
|
|
41
47
|
}, /*#__PURE__*/_react.default.createElement(_blockMenuRenderer.BlockMenuRenderer, {
|
|
42
48
|
components: blockMenuComponents || [],
|
|
43
49
|
fallbacks: {
|
|
@@ -82,15 +88,16 @@ var BlockMenu = function BlockMenu(_ref2) {
|
|
|
82
88
|
onDropdownOpenChanged = _useBlockMenu.onDropdownOpenChanged;
|
|
83
89
|
var targetHandleRef = editorView === null || editorView === void 0 || (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(_styles.DRAG_HANDLE_SELECTOR);
|
|
84
90
|
var prevIsMenuOpenRef = (0, _react.useRef)(false);
|
|
85
|
-
var
|
|
91
|
+
var popupRef = (0, _react.useRef)(undefined);
|
|
92
|
+
var hasFocus = (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? (_ref3 = (editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) || document.activeElement === targetHandleRef || popupRef.current && (popupRef.current.contains(document.activeElement) || popupRef.current === document.activeElement)) !== null && _ref3 !== void 0 ? _ref3 : false : (_editorView$hasFocus = editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) !== null && _editorView$hasFocus !== void 0 ? _editorView$hasFocus : false;
|
|
86
93
|
var hasSelection = !!editorView && !editorView.state.selection.empty;
|
|
87
94
|
// hasSelection true, always show block menu
|
|
88
95
|
// hasSelection false, only show block menu when empty line experiment is enabled
|
|
89
96
|
var shouldShowBlockMenuForEmptyLine = hasSelection || !hasSelection && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_empty_line', 'isEnabled', true);
|
|
90
|
-
var
|
|
97
|
+
var selectedByShortcutOrDragHandle = isSelectedViaDragHandle || openedViaKeyboard && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
|
|
91
98
|
(0, _react.useEffect)(function () {
|
|
92
99
|
var _api$userIntent;
|
|
93
|
-
if (!isMenuOpen || !menuTriggerBy || !
|
|
100
|
+
if (!isMenuOpen || !menuTriggerBy || !selectedByShortcutOrDragHandle || !hasFocus || !shouldShowBlockMenuForEmptyLine || ['resizing', 'dragging'].includes(currentUserIntent || '')) {
|
|
94
101
|
return;
|
|
95
102
|
}
|
|
96
103
|
|
|
@@ -110,7 +117,7 @@ var BlockMenu = function BlockMenu(_ref2) {
|
|
|
110
117
|
// Update the previous state
|
|
111
118
|
prevIsMenuOpenRef.current = isMenuOpen;
|
|
112
119
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen'));
|
|
113
|
-
}, [api, isMenuOpen, menuTriggerBy,
|
|
120
|
+
}, [api, isMenuOpen, menuTriggerBy, selectedByShortcutOrDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent, openedViaKeyboard]);
|
|
114
121
|
if (!isMenuOpen) {
|
|
115
122
|
return null;
|
|
116
123
|
}
|
|
@@ -130,10 +137,15 @@ var BlockMenu = function BlockMenu(_ref2) {
|
|
|
130
137
|
return tr;
|
|
131
138
|
});
|
|
132
139
|
};
|
|
133
|
-
if (!menuTriggerBy || !
|
|
140
|
+
if (!menuTriggerBy || !selectedByShortcutOrDragHandle || !hasFocus || !shouldShowBlockMenuForEmptyLine || ['resizing', 'dragging'].includes(currentUserIntent || '')) {
|
|
134
141
|
closeMenu();
|
|
135
142
|
return null;
|
|
136
143
|
}
|
|
144
|
+
var setRef = function setRef(el) {
|
|
145
|
+
if (el) {
|
|
146
|
+
popupRef.current = el;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
137
149
|
if (targetHandleRef instanceof HTMLElement) {
|
|
138
150
|
return /*#__PURE__*/_react.default.createElement(PopupWithListeners, {
|
|
139
151
|
alignX: 'right',
|
|
@@ -151,14 +163,13 @@ var BlockMenu = function BlockMenu(_ref2) {
|
|
|
151
163
|
preventOverflow: true // disables forced horizontal placement when forcePlacement is on, so fitWidth controls flipping
|
|
152
164
|
,
|
|
153
165
|
stick: true,
|
|
154
|
-
focusTrap: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ?
|
|
155
|
-
initialFocus: undefined
|
|
156
|
-
} : {
|
|
157
|
-
initialFocus: targetHandleRef
|
|
166
|
+
focusTrap: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? {
|
|
167
|
+
initialFocus: openedViaKeyboard ? undefined : targetHandleRef
|
|
158
168
|
} : undefined,
|
|
159
169
|
offset: [_styles.DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
|
|
160
170
|
}, /*#__PURE__*/_react.default.createElement(BlockMenuContent, {
|
|
161
|
-
api: api
|
|
171
|
+
api: api,
|
|
172
|
+
setRef: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? setRef : undefined
|
|
162
173
|
}));
|
|
163
174
|
} else {
|
|
164
175
|
return null;
|
|
@@ -23,6 +23,6 @@ var CopySection = exports.CopySection = function CopySection(_ref) {
|
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
26
|
-
hasSeparator: !isFormatMenuHidden()
|
|
26
|
+
hasSeparator: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_synced_block', 'isEnabled', true) ? true : !isFormatMenuHidden()
|
|
27
27
|
}, children);
|
|
28
28
|
};
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { ADD_BLOCKS_MENU_SECTION, MOVE_UP_MENU_ITEM, MOVE_UP_DOWN_MENU_SECTION, MOVE_DOWN_MENU_ITEM, MOVE_BLOCK_SECTION_RANK, PRIMARY_MENU_SECTION, BLOCK_MENU_SECTION_RANK, COPY_MENU_SECTION, COPY_BLOCK_MENU_ITEM, COPY_MENU_SECTION_RANK, COPY_LINK_MENU_ITEM, DELETE_MENU_SECTION, DELETE_MENU_ITEM, DELETE_SECTION_RANK, NESTED_FORMAT_MENU_SECTION, NESTED_FORMAT_MENU } from '@atlaskit/editor-common/block-menu';
|
|
3
3
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
-
import { AddBlocksSection } from './add-blocks-section';
|
|
6
5
|
import CopyBlockMenuItem from './copy-block';
|
|
7
6
|
import { CopyLinkDropdownItem } from './copy-link';
|
|
8
7
|
import { CopySection } from './copy-section';
|
|
@@ -93,9 +92,9 @@ export const getBlockMenuComponents = ({
|
|
|
93
92
|
rank: BLOCK_MENU_SECTION_RANK[ADD_BLOCKS_MENU_SECTION.key],
|
|
94
93
|
component: ({
|
|
95
94
|
children
|
|
96
|
-
}) => /*#__PURE__*/React.createElement(
|
|
97
|
-
|
|
98
|
-
},
|
|
95
|
+
}) => /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
96
|
+
hasSeparator: true
|
|
97
|
+
}, children)
|
|
99
98
|
}] : []), {
|
|
100
99
|
type: 'block-menu-section',
|
|
101
100
|
key: COPY_MENU_SECTION.key,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
|
+
._1cc0glyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])~*){border-block-start:none}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
|
|
4
|
+
._1k2yglyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])){display:none}
|
|
3
5
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
@@ -16,21 +16,27 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
|
|
|
16
16
|
import { useBlockMenu } from './block-menu-provider';
|
|
17
17
|
import { BlockMenuRenderer } from './block-menu-renderer';
|
|
18
18
|
const styles = {
|
|
19
|
-
base: "_2rko12b0 _bfhk1bhr _16qs1cd0"
|
|
19
|
+
base: "_2rko12b0 _bfhk1bhr _16qs1cd0",
|
|
20
|
+
emptyMenuSectionStyles: "_1cc0glyw _1k2yglyw"
|
|
20
21
|
};
|
|
21
22
|
const DEFAULT_MENU_WIDTH = 230;
|
|
22
23
|
const DRAG_HANDLE_OFFSET_PADDING = 5;
|
|
23
24
|
const PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
24
25
|
const BlockMenuContent = ({
|
|
25
|
-
api
|
|
26
|
+
api,
|
|
27
|
+
setRef
|
|
26
28
|
}) => {
|
|
27
29
|
var _api$blockMenu;
|
|
28
|
-
const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
29
30
|
const blockMenuComponents = api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
31
|
+
const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
32
|
+
const ref = el => {
|
|
33
|
+
setOutsideClickTargetRef(el);
|
|
34
|
+
setRef === null || setRef === void 0 ? void 0 : setRef(el);
|
|
35
|
+
};
|
|
30
36
|
return /*#__PURE__*/React.createElement(Box, {
|
|
31
37
|
testId: "editor-block-menu",
|
|
32
|
-
ref:
|
|
33
|
-
xcss: cx(styles.base)
|
|
38
|
+
ref: ref,
|
|
39
|
+
xcss: cx(styles.base, expValEqualsNoExposure('platform_synced_block', 'isEnabled', true) && styles.emptyMenuSectionStyles)
|
|
34
40
|
}, /*#__PURE__*/React.createElement(BlockMenuRenderer, {
|
|
35
41
|
components: blockMenuComponents || [],
|
|
36
42
|
fallbacks: {
|
|
@@ -72,15 +78,16 @@ const BlockMenu = ({
|
|
|
72
78
|
} = useBlockMenu();
|
|
73
79
|
const targetHandleRef = editorView === null || editorView === void 0 ? void 0 : (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(DRAG_HANDLE_SELECTOR);
|
|
74
80
|
const prevIsMenuOpenRef = useRef(false);
|
|
75
|
-
const
|
|
81
|
+
const popupRef = useRef(undefined);
|
|
82
|
+
const hasFocus = expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? (_ref = (editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) || document.activeElement === targetHandleRef || popupRef.current && (popupRef.current.contains(document.activeElement) || popupRef.current === document.activeElement)) !== null && _ref !== void 0 ? _ref : false : (_editorView$hasFocus = editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) !== null && _editorView$hasFocus !== void 0 ? _editorView$hasFocus : false;
|
|
76
83
|
const hasSelection = !!editorView && !editorView.state.selection.empty;
|
|
77
84
|
// hasSelection true, always show block menu
|
|
78
85
|
// hasSelection false, only show block menu when empty line experiment is enabled
|
|
79
86
|
const shouldShowBlockMenuForEmptyLine = hasSelection || !hasSelection && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true);
|
|
80
|
-
const
|
|
87
|
+
const selectedByShortcutOrDragHandle = isSelectedViaDragHandle || openedViaKeyboard && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
|
|
81
88
|
useEffect(() => {
|
|
82
89
|
var _api$userIntent;
|
|
83
|
-
if (!isMenuOpen || !menuTriggerBy || !
|
|
90
|
+
if (!isMenuOpen || !menuTriggerBy || !selectedByShortcutOrDragHandle || !hasFocus || !shouldShowBlockMenuForEmptyLine || ['resizing', 'dragging'].includes(currentUserIntent || '')) {
|
|
84
91
|
return;
|
|
85
92
|
}
|
|
86
93
|
|
|
@@ -100,7 +107,7 @@ const BlockMenu = ({
|
|
|
100
107
|
// Update the previous state
|
|
101
108
|
prevIsMenuOpenRef.current = isMenuOpen;
|
|
102
109
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen'));
|
|
103
|
-
}, [api, isMenuOpen, menuTriggerBy,
|
|
110
|
+
}, [api, isMenuOpen, menuTriggerBy, selectedByShortcutOrDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent, openedViaKeyboard]);
|
|
104
111
|
if (!isMenuOpen) {
|
|
105
112
|
return null;
|
|
106
113
|
}
|
|
@@ -121,10 +128,15 @@ const BlockMenu = ({
|
|
|
121
128
|
return tr;
|
|
122
129
|
});
|
|
123
130
|
};
|
|
124
|
-
if (!menuTriggerBy || !
|
|
131
|
+
if (!menuTriggerBy || !selectedByShortcutOrDragHandle || !hasFocus || !shouldShowBlockMenuForEmptyLine || ['resizing', 'dragging'].includes(currentUserIntent || '')) {
|
|
125
132
|
closeMenu();
|
|
126
133
|
return null;
|
|
127
134
|
}
|
|
135
|
+
const setRef = el => {
|
|
136
|
+
if (el) {
|
|
137
|
+
popupRef.current = el;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
128
140
|
if (targetHandleRef instanceof HTMLElement) {
|
|
129
141
|
return /*#__PURE__*/React.createElement(PopupWithListeners, {
|
|
130
142
|
alignX: 'right',
|
|
@@ -142,14 +154,13 @@ const BlockMenu = ({
|
|
|
142
154
|
preventOverflow: true // disables forced horizontal placement when forcePlacement is on, so fitWidth controls flipping
|
|
143
155
|
,
|
|
144
156
|
stick: true,
|
|
145
|
-
focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ?
|
|
146
|
-
initialFocus: undefined
|
|
147
|
-
} : {
|
|
148
|
-
initialFocus: targetHandleRef
|
|
157
|
+
focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? {
|
|
158
|
+
initialFocus: openedViaKeyboard ? undefined : targetHandleRef
|
|
149
159
|
} : undefined,
|
|
150
160
|
offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
|
|
151
161
|
}, /*#__PURE__*/React.createElement(BlockMenuContent, {
|
|
152
|
-
api: api
|
|
162
|
+
api: api,
|
|
163
|
+
setRef: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? setRef : undefined
|
|
153
164
|
}));
|
|
154
165
|
} else {
|
|
155
166
|
return null;
|
|
@@ -16,6 +16,6 @@ export const CopySection = ({
|
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
19
|
-
hasSeparator: !isFormatMenuHidden()
|
|
19
|
+
hasSeparator: expValEqualsNoExposure('platform_synced_block', 'isEnabled', true) ? true : !isFormatMenuHidden()
|
|
20
20
|
}, children);
|
|
21
21
|
};
|
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
|
3
3
|
import { ADD_BLOCKS_MENU_SECTION, MOVE_UP_MENU_ITEM, MOVE_UP_DOWN_MENU_SECTION, MOVE_DOWN_MENU_ITEM, MOVE_BLOCK_SECTION_RANK, PRIMARY_MENU_SECTION, BLOCK_MENU_SECTION_RANK, COPY_MENU_SECTION, COPY_BLOCK_MENU_ITEM, COPY_MENU_SECTION_RANK, COPY_LINK_MENU_ITEM, DELETE_MENU_SECTION, DELETE_MENU_ITEM, DELETE_SECTION_RANK, NESTED_FORMAT_MENU_SECTION, NESTED_FORMAT_MENU } from '@atlaskit/editor-common/block-menu';
|
|
4
4
|
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
5
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
|
-
import { AddBlocksSection } from './add-blocks-section';
|
|
7
6
|
import CopyBlockMenuItem from './copy-block';
|
|
8
7
|
import { CopyLinkDropdownItem } from './copy-link';
|
|
9
8
|
import { CopySection } from './copy-section';
|
|
@@ -96,9 +95,9 @@ export var getBlockMenuComponents = function getBlockMenuComponents(_ref4) {
|
|
|
96
95
|
rank: BLOCK_MENU_SECTION_RANK[ADD_BLOCKS_MENU_SECTION.key],
|
|
97
96
|
component: function component(_ref5) {
|
|
98
97
|
var children = _ref5.children;
|
|
99
|
-
return /*#__PURE__*/React.createElement(
|
|
100
|
-
|
|
101
|
-
},
|
|
98
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
99
|
+
hasSeparator: true
|
|
100
|
+
}, children);
|
|
102
101
|
}
|
|
103
102
|
}] : []), [{
|
|
104
103
|
type: 'block-menu-section',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
|
+
._1cc0glyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])~*){border-block-start:none}._16qs1cd0{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #091e4226,0 0 1px #091e424f)}
|
|
4
|
+
._1k2yglyw [data-toolbar-component=menu-section]:not(:has([data-toolbar-component=menu-item])){display:none}
|
|
3
5
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
@@ -16,20 +16,26 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
|
|
|
16
16
|
import { useBlockMenu } from './block-menu-provider';
|
|
17
17
|
import { BlockMenuRenderer } from './block-menu-renderer';
|
|
18
18
|
var styles = {
|
|
19
|
-
base: "_2rko12b0 _bfhk1bhr _16qs1cd0"
|
|
19
|
+
base: "_2rko12b0 _bfhk1bhr _16qs1cd0",
|
|
20
|
+
emptyMenuSectionStyles: "_1cc0glyw _1k2yglyw"
|
|
20
21
|
};
|
|
21
22
|
var DEFAULT_MENU_WIDTH = 230;
|
|
22
23
|
var DRAG_HANDLE_OFFSET_PADDING = 5;
|
|
23
24
|
var PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
24
25
|
var BlockMenuContent = function BlockMenuContent(_ref) {
|
|
25
26
|
var _api$blockMenu;
|
|
26
|
-
var api = _ref.api
|
|
27
|
-
|
|
27
|
+
var api = _ref.api,
|
|
28
|
+
setRef = _ref.setRef;
|
|
28
29
|
var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
|
|
30
|
+
var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
|
|
31
|
+
var ref = function ref(el) {
|
|
32
|
+
setOutsideClickTargetRef(el);
|
|
33
|
+
setRef === null || setRef === void 0 || setRef(el);
|
|
34
|
+
};
|
|
29
35
|
return /*#__PURE__*/React.createElement(Box, {
|
|
30
36
|
testId: "editor-block-menu",
|
|
31
|
-
ref:
|
|
32
|
-
xcss: cx(styles.base)
|
|
37
|
+
ref: ref,
|
|
38
|
+
xcss: cx(styles.base, expValEqualsNoExposure('platform_synced_block', 'isEnabled', true) && styles.emptyMenuSectionStyles)
|
|
33
39
|
}, /*#__PURE__*/React.createElement(BlockMenuRenderer, {
|
|
34
40
|
components: blockMenuComponents || [],
|
|
35
41
|
fallbacks: {
|
|
@@ -74,15 +80,16 @@ var BlockMenu = function BlockMenu(_ref2) {
|
|
|
74
80
|
onDropdownOpenChanged = _useBlockMenu.onDropdownOpenChanged;
|
|
75
81
|
var targetHandleRef = editorView === null || editorView === void 0 || (_editorView$dom = editorView.dom) === null || _editorView$dom === void 0 ? void 0 : _editorView$dom.querySelector(DRAG_HANDLE_SELECTOR);
|
|
76
82
|
var prevIsMenuOpenRef = useRef(false);
|
|
77
|
-
var
|
|
83
|
+
var popupRef = useRef(undefined);
|
|
84
|
+
var hasFocus = expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? (_ref3 = (editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) || document.activeElement === targetHandleRef || popupRef.current && (popupRef.current.contains(document.activeElement) || popupRef.current === document.activeElement)) !== null && _ref3 !== void 0 ? _ref3 : false : (_editorView$hasFocus = editorView === null || editorView === void 0 ? void 0 : editorView.hasFocus()) !== null && _editorView$hasFocus !== void 0 ? _editorView$hasFocus : false;
|
|
78
85
|
var hasSelection = !!editorView && !editorView.state.selection.empty;
|
|
79
86
|
// hasSelection true, always show block menu
|
|
80
87
|
// hasSelection false, only show block menu when empty line experiment is enabled
|
|
81
88
|
var shouldShowBlockMenuForEmptyLine = hasSelection || !hasSelection && expValEqualsNoExposure('platform_editor_block_menu_empty_line', 'isEnabled', true);
|
|
82
|
-
var
|
|
89
|
+
var selectedByShortcutOrDragHandle = isSelectedViaDragHandle || openedViaKeyboard && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
|
|
83
90
|
useEffect(function () {
|
|
84
91
|
var _api$userIntent;
|
|
85
|
-
if (!isMenuOpen || !menuTriggerBy || !
|
|
92
|
+
if (!isMenuOpen || !menuTriggerBy || !selectedByShortcutOrDragHandle || !hasFocus || !shouldShowBlockMenuForEmptyLine || ['resizing', 'dragging'].includes(currentUserIntent || '')) {
|
|
86
93
|
return;
|
|
87
94
|
}
|
|
88
95
|
|
|
@@ -102,7 +109,7 @@ var BlockMenu = function BlockMenu(_ref2) {
|
|
|
102
109
|
// Update the previous state
|
|
103
110
|
prevIsMenuOpenRef.current = isMenuOpen;
|
|
104
111
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.commands.setCurrentUserIntent('blockMenuOpen'));
|
|
105
|
-
}, [api, isMenuOpen, menuTriggerBy,
|
|
112
|
+
}, [api, isMenuOpen, menuTriggerBy, selectedByShortcutOrDragHandle, hasFocus, shouldShowBlockMenuForEmptyLine, currentUserIntent, openedViaKeyboard]);
|
|
106
113
|
if (!isMenuOpen) {
|
|
107
114
|
return null;
|
|
108
115
|
}
|
|
@@ -122,10 +129,15 @@ var BlockMenu = function BlockMenu(_ref2) {
|
|
|
122
129
|
return tr;
|
|
123
130
|
});
|
|
124
131
|
};
|
|
125
|
-
if (!menuTriggerBy || !
|
|
132
|
+
if (!menuTriggerBy || !selectedByShortcutOrDragHandle || !hasFocus || !shouldShowBlockMenuForEmptyLine || ['resizing', 'dragging'].includes(currentUserIntent || '')) {
|
|
126
133
|
closeMenu();
|
|
127
134
|
return null;
|
|
128
135
|
}
|
|
136
|
+
var setRef = function setRef(el) {
|
|
137
|
+
if (el) {
|
|
138
|
+
popupRef.current = el;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
129
141
|
if (targetHandleRef instanceof HTMLElement) {
|
|
130
142
|
return /*#__PURE__*/React.createElement(PopupWithListeners, {
|
|
131
143
|
alignX: 'right',
|
|
@@ -143,14 +155,13 @@ var BlockMenu = function BlockMenu(_ref2) {
|
|
|
143
155
|
preventOverflow: true // disables forced horizontal placement when forcePlacement is on, so fitWidth controls flipping
|
|
144
156
|
,
|
|
145
157
|
stick: true,
|
|
146
|
-
focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ?
|
|
147
|
-
initialFocus: undefined
|
|
148
|
-
} : {
|
|
149
|
-
initialFocus: targetHandleRef
|
|
158
|
+
focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? {
|
|
159
|
+
initialFocus: openedViaKeyboard ? undefined : targetHandleRef
|
|
150
160
|
} : undefined,
|
|
151
161
|
offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
|
|
152
162
|
}, /*#__PURE__*/React.createElement(BlockMenuContent, {
|
|
153
|
-
api: api
|
|
163
|
+
api: api,
|
|
164
|
+
setRef: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? setRef : undefined
|
|
154
165
|
}));
|
|
155
166
|
} else {
|
|
156
167
|
return null;
|
|
@@ -15,6 +15,6 @@ export var CopySection = function CopySection(_ref) {
|
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
18
|
-
hasSeparator: !isFormatMenuHidden()
|
|
18
|
+
hasSeparator: expValEqualsNoExposure('platform_synced_block', 'isEnabled', true) ? true : !isFormatMenuHidden()
|
|
19
19
|
}, children);
|
|
20
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.20",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"@atlaskit/icon-lab": "^5.10.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/primitives": "^14.15.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^13.6.0",
|
|
47
47
|
"@atlaskit/tokens": "^6.4.0",
|
|
48
48
|
"@babel/runtime": "^7.0.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@atlaskit/editor-common": "^110.
|
|
51
|
+
"@atlaskit/editor-common": "^110.9.0",
|
|
52
52
|
"react": "^18.2.0",
|
|
53
53
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
54
54
|
},
|
|
@@ -1,21 +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.AddBlocksSection = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
10
|
-
var AddBlocksSection = exports.AddBlocksSection = function AddBlocksSection(_ref) {
|
|
11
|
-
var _api$selection;
|
|
12
|
-
var api = _ref.api,
|
|
13
|
-
children = _ref.children;
|
|
14
|
-
var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
|
|
15
|
-
if (!(selection !== null && selection !== void 0 && selection.empty)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
19
|
-
hasSeparator: true
|
|
20
|
-
}, children);
|
|
21
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
|
-
export const AddBlocksSection = ({
|
|
4
|
-
api,
|
|
5
|
-
children
|
|
6
|
-
}) => {
|
|
7
|
-
var _api$selection, _api$selection$shared, _api$selection$shared2;
|
|
8
|
-
const selection = api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$shared = _api$selection.sharedState) === null || _api$selection$shared === void 0 ? void 0 : (_api$selection$shared2 = _api$selection$shared.currentState()) === null || _api$selection$shared2 === void 0 ? void 0 : _api$selection$shared2.selection;
|
|
9
|
-
if (!(selection !== null && selection !== void 0 && selection.empty)) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
13
|
-
hasSeparator: true
|
|
14
|
-
}, children);
|
|
15
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
3
|
-
export var AddBlocksSection = function AddBlocksSection(_ref) {
|
|
4
|
-
var _api$selection;
|
|
5
|
-
var api = _ref.api,
|
|
6
|
-
children = _ref.children;
|
|
7
|
-
var selection = api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.sharedState) === null || _api$selection === void 0 || (_api$selection = _api$selection.currentState()) === null || _api$selection === void 0 ? void 0 : _api$selection.selection;
|
|
8
|
-
if (!(selection !== null && selection !== void 0 && selection.empty)) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
12
|
-
hasSeparator: true
|
|
13
|
-
}, children);
|
|
14
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
4
|
-
export declare const AddBlocksSection: ({ api, children, }: {
|
|
5
|
-
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}) => React.JSX.Element | null;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import type { BlockMenuPlugin } from '../blockMenuPluginType';
|
|
4
|
-
export declare const AddBlocksSection: ({ api, children, }: {
|
|
5
|
-
api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}) => React.JSX.Element | null;
|