@atlaskit/editor-plugin-block-menu 5.0.10 → 5.0.11
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 +8 -0
- package/afm-cc/tsconfig.json +1 -4
- package/dist/cjs/ui/block-menu.js +21 -4
- package/dist/cjs/ui/delete-button.js +17 -12
- package/dist/es2019/ui/block-menu.js +22 -4
- package/dist/es2019/ui/delete-button.js +17 -12
- package/dist/esm/ui/block-menu.js +21 -4
- package/dist/esm/ui/delete-button.js +17 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 5.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`bf1f847655683`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bf1f847655683) -
|
|
8
|
+
ED-29512: Fixed not able to delete node when block menu is visible
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 5.0.10
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -14,6 +14,7 @@ var _css = require("@atlaskit/css");
|
|
|
14
14
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
15
|
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
16
16
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
17
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
17
18
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
18
19
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
19
20
|
var _uiReact = require("@atlaskit/editor-common/ui-react");
|
|
@@ -185,15 +186,28 @@ var BlockMenu = function BlockMenu(_ref4) {
|
|
|
185
186
|
if (!isMenuOpen) {
|
|
186
187
|
return null;
|
|
187
188
|
}
|
|
188
|
-
var
|
|
189
|
+
var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown() {
|
|
189
190
|
api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
|
|
190
|
-
var _api$blockControls
|
|
191
|
+
var _api$blockControls;
|
|
191
192
|
var tr = _ref6.tr;
|
|
193
|
+
(0, _selection.deleteSelectedRange)(tr);
|
|
192
194
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.toggleBlockMenu({
|
|
193
195
|
closeMenu: true
|
|
194
196
|
})({
|
|
195
197
|
tr: tr
|
|
196
198
|
});
|
|
199
|
+
return tr;
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
var closeMenu = function closeMenu() {
|
|
203
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
|
|
204
|
+
var _api$blockControls2, _api$userIntent3;
|
|
205
|
+
var tr = _ref7.tr;
|
|
206
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
|
|
207
|
+
closeMenu: true
|
|
208
|
+
})({
|
|
209
|
+
tr: tr
|
|
210
|
+
});
|
|
197
211
|
onDropdownOpenChanged(false);
|
|
198
212
|
api === null || api === void 0 || (_api$userIntent3 = api.userIntent) === null || _api$userIntent3 === void 0 || _api$userIntent3.commands.setCurrentUserIntent(currentUserIntent === 'blockMenuOpen' ? 'default' : currentUserIntent || 'default')({
|
|
199
213
|
tr: tr
|
|
@@ -222,6 +236,7 @@ var BlockMenu = function BlockMenu(_ref4) {
|
|
|
222
236
|
,
|
|
223
237
|
handleClickOutside: closeMenu,
|
|
224
238
|
handleEscapeKeydown: closeMenu,
|
|
239
|
+
handleBackspaceDeleteKeydown: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? handleBackspaceDeleteKeydown : undefined,
|
|
225
240
|
mountTo: mountTo,
|
|
226
241
|
boundariesElement: boundariesElement,
|
|
227
242
|
scrollableElement: scrollableElement,
|
|
@@ -232,8 +247,10 @@ var BlockMenu = function BlockMenu(_ref4) {
|
|
|
232
247
|
preventOverflow: true // disables forced horizontal placement when forcePlacement is on, so fitWidth controls flipping
|
|
233
248
|
,
|
|
234
249
|
stick: true,
|
|
235
|
-
focusTrap: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ?
|
|
236
|
-
|
|
250
|
+
focusTrap: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) && openedViaKeyboard ?
|
|
251
|
+
// Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
|
|
252
|
+
{
|
|
253
|
+
initialFocus: undefined
|
|
237
254
|
} : undefined,
|
|
238
255
|
offset: [_styles.DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
|
|
239
256
|
}, /*#__PURE__*/_react.default.createElement(BlockMenuContent, {
|
|
@@ -11,6 +11,7 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
13
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
14
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
16
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
16
17
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
@@ -40,20 +41,24 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
|
|
|
40
41
|
eventType: _analytics.EVENT_TYPE.UI
|
|
41
42
|
};
|
|
42
43
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
from = from
|
|
48
|
-
to = to
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
|
|
45
|
+
(0, _selection.deleteSelectedRange)(tr);
|
|
46
|
+
} else {
|
|
47
|
+
var selection = tr.selection;
|
|
48
|
+
var from = selection.$from.pos;
|
|
49
|
+
var to = selection.$to.pos;
|
|
50
|
+
if (selection instanceof _state.TextSelection) {
|
|
51
|
+
from = from - 1;
|
|
52
|
+
to = to + 1;
|
|
53
|
+
} else if ((0, _utils.isTableSelected)(selection)) {
|
|
54
|
+
var table = (0, _utils.findTable)(selection);
|
|
55
|
+
if (table) {
|
|
56
|
+
from = table.pos;
|
|
57
|
+
to = table.pos + table.node.nodeSize;
|
|
58
|
+
}
|
|
54
59
|
}
|
|
60
|
+
tr.deleteRange(from, to);
|
|
55
61
|
}
|
|
56
|
-
tr.deleteRange(from, to);
|
|
57
62
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.toggleBlockMenu({
|
|
58
63
|
closeMenu: true
|
|
59
64
|
})({
|
|
@@ -7,6 +7,7 @@ import { cx } from '@atlaskit/css';
|
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
9
9
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
|
|
10
11
|
import { DRAG_HANDLE_SELECTOR, DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
|
|
11
12
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
12
13
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
@@ -175,16 +176,30 @@ const BlockMenu = ({
|
|
|
175
176
|
if (!isMenuOpen) {
|
|
176
177
|
return null;
|
|
177
178
|
}
|
|
178
|
-
const
|
|
179
|
+
const handleBackspaceDeleteKeydown = () => {
|
|
179
180
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
180
181
|
tr
|
|
181
182
|
}) => {
|
|
182
|
-
var _api$blockControls
|
|
183
|
+
var _api$blockControls;
|
|
184
|
+
deleteSelectedRange(tr);
|
|
183
185
|
api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.toggleBlockMenu({
|
|
184
186
|
closeMenu: true
|
|
185
187
|
})({
|
|
186
188
|
tr
|
|
187
189
|
});
|
|
190
|
+
return tr;
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
const closeMenu = () => {
|
|
194
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
195
|
+
tr
|
|
196
|
+
}) => {
|
|
197
|
+
var _api$blockControls2, _api$userIntent3;
|
|
198
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.toggleBlockMenu({
|
|
199
|
+
closeMenu: true
|
|
200
|
+
})({
|
|
201
|
+
tr
|
|
202
|
+
});
|
|
188
203
|
onDropdownOpenChanged(false);
|
|
189
204
|
api === null || api === void 0 ? void 0 : (_api$userIntent3 = api.userIntent) === null || _api$userIntent3 === void 0 ? void 0 : _api$userIntent3.commands.setCurrentUserIntent(currentUserIntent === 'blockMenuOpen' ? 'default' : currentUserIntent || 'default')({
|
|
190
205
|
tr
|
|
@@ -213,6 +228,7 @@ const BlockMenu = ({
|
|
|
213
228
|
,
|
|
214
229
|
handleClickOutside: closeMenu,
|
|
215
230
|
handleEscapeKeydown: closeMenu,
|
|
231
|
+
handleBackspaceDeleteKeydown: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? handleBackspaceDeleteKeydown : undefined,
|
|
216
232
|
mountTo: mountTo,
|
|
217
233
|
boundariesElement: boundariesElement,
|
|
218
234
|
scrollableElement: scrollableElement,
|
|
@@ -223,8 +239,10 @@ const BlockMenu = ({
|
|
|
223
239
|
preventOverflow: true // disables forced horizontal placement when forcePlacement is on, so fitWidth controls flipping
|
|
224
240
|
,
|
|
225
241
|
stick: true,
|
|
226
|
-
focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ?
|
|
227
|
-
|
|
242
|
+
focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) && openedViaKeyboard ?
|
|
243
|
+
// Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
|
|
244
|
+
{
|
|
245
|
+
initialFocus: undefined
|
|
228
246
|
} : undefined,
|
|
229
247
|
offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
|
|
230
248
|
}, /*#__PURE__*/React.createElement(BlockMenuContent, {
|
|
@@ -3,6 +3,7 @@ import { useIntl, injectIntl } from 'react-intl-next';
|
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { messages } from '@atlaskit/editor-common/block-menu';
|
|
5
5
|
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
|
|
6
7
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
8
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
8
9
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
@@ -34,20 +35,24 @@ const DeleteDropdownItemContent = ({
|
|
|
34
35
|
eventType: EVENT_TYPE.UI
|
|
35
36
|
};
|
|
36
37
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent(payload)(tr);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
from = from
|
|
42
|
-
to = to
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
if (expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
|
|
39
|
+
deleteSelectedRange(tr);
|
|
40
|
+
} else {
|
|
41
|
+
const selection = tr.selection;
|
|
42
|
+
let from = selection.$from.pos;
|
|
43
|
+
let to = selection.$to.pos;
|
|
44
|
+
if (selection instanceof TextSelection) {
|
|
45
|
+
from = from - 1;
|
|
46
|
+
to = to + 1;
|
|
47
|
+
} else if (isTableSelected(selection)) {
|
|
48
|
+
const table = findTable(selection);
|
|
49
|
+
if (table) {
|
|
50
|
+
from = table.pos;
|
|
51
|
+
to = table.pos + table.node.nodeSize;
|
|
52
|
+
}
|
|
48
53
|
}
|
|
54
|
+
tr.deleteRange(from, to);
|
|
49
55
|
}
|
|
50
|
-
tr.deleteRange(from, to);
|
|
51
56
|
api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$co = _api$blockControls.commands) === null || _api$blockControls$co === void 0 ? void 0 : _api$blockControls$co.toggleBlockMenu({
|
|
52
57
|
closeMenu: true
|
|
53
58
|
})({
|
|
@@ -7,6 +7,7 @@ import { cx } from '@atlaskit/css';
|
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
9
9
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
|
|
10
11
|
import { DRAG_HANDLE_SELECTOR, DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
|
|
11
12
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
12
13
|
import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
@@ -177,15 +178,28 @@ var BlockMenu = function BlockMenu(_ref4) {
|
|
|
177
178
|
if (!isMenuOpen) {
|
|
178
179
|
return null;
|
|
179
180
|
}
|
|
180
|
-
var
|
|
181
|
+
var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown() {
|
|
181
182
|
api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
|
|
182
|
-
var _api$blockControls
|
|
183
|
+
var _api$blockControls;
|
|
183
184
|
var tr = _ref6.tr;
|
|
185
|
+
deleteSelectedRange(tr);
|
|
184
186
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.toggleBlockMenu({
|
|
185
187
|
closeMenu: true
|
|
186
188
|
})({
|
|
187
189
|
tr: tr
|
|
188
190
|
});
|
|
191
|
+
return tr;
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
var closeMenu = function closeMenu() {
|
|
195
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
|
|
196
|
+
var _api$blockControls2, _api$userIntent3;
|
|
197
|
+
var tr = _ref7.tr;
|
|
198
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
|
|
199
|
+
closeMenu: true
|
|
200
|
+
})({
|
|
201
|
+
tr: tr
|
|
202
|
+
});
|
|
189
203
|
onDropdownOpenChanged(false);
|
|
190
204
|
api === null || api === void 0 || (_api$userIntent3 = api.userIntent) === null || _api$userIntent3 === void 0 || _api$userIntent3.commands.setCurrentUserIntent(currentUserIntent === 'blockMenuOpen' ? 'default' : currentUserIntent || 'default')({
|
|
191
205
|
tr: tr
|
|
@@ -214,6 +228,7 @@ var BlockMenu = function BlockMenu(_ref4) {
|
|
|
214
228
|
,
|
|
215
229
|
handleClickOutside: closeMenu,
|
|
216
230
|
handleEscapeKeydown: closeMenu,
|
|
231
|
+
handleBackspaceDeleteKeydown: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? handleBackspaceDeleteKeydown : undefined,
|
|
217
232
|
mountTo: mountTo,
|
|
218
233
|
boundariesElement: boundariesElement,
|
|
219
234
|
scrollableElement: scrollableElement,
|
|
@@ -224,8 +239,10 @@ var BlockMenu = function BlockMenu(_ref4) {
|
|
|
224
239
|
preventOverflow: true // disables forced horizontal placement when forcePlacement is on, so fitWidth controls flipping
|
|
225
240
|
,
|
|
226
241
|
stick: true,
|
|
227
|
-
focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ?
|
|
228
|
-
|
|
242
|
+
focusTrap: expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) && openedViaKeyboard ?
|
|
243
|
+
// Only enable focus trap when opened via keyboard to make sure the focus is on the first focusable menu item
|
|
244
|
+
{
|
|
245
|
+
initialFocus: undefined
|
|
229
246
|
} : undefined,
|
|
230
247
|
offset: [DRAG_HANDLE_WIDTH + DRAG_HANDLE_OFFSET_PADDING, 0]
|
|
231
248
|
}, /*#__PURE__*/React.createElement(BlockMenuContent, {
|
|
@@ -3,6 +3,7 @@ import { useIntl, injectIntl } from 'react-intl-next';
|
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { messages } from '@atlaskit/editor-common/block-menu';
|
|
5
5
|
import { blockMenuMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
|
|
6
7
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
8
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
8
9
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
@@ -31,20 +32,24 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
|
|
|
31
32
|
eventType: EVENT_TYPE.UI
|
|
32
33
|
};
|
|
33
34
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.attachAnalyticsEvent(payload)(tr);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
from = from
|
|
39
|
-
to = to
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
if (expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true)) {
|
|
36
|
+
deleteSelectedRange(tr);
|
|
37
|
+
} else {
|
|
38
|
+
var selection = tr.selection;
|
|
39
|
+
var from = selection.$from.pos;
|
|
40
|
+
var to = selection.$to.pos;
|
|
41
|
+
if (selection instanceof TextSelection) {
|
|
42
|
+
from = from - 1;
|
|
43
|
+
to = to + 1;
|
|
44
|
+
} else if (isTableSelected(selection)) {
|
|
45
|
+
var table = findTable(selection);
|
|
46
|
+
if (table) {
|
|
47
|
+
from = table.pos;
|
|
48
|
+
to = table.pos + table.node.nodeSize;
|
|
49
|
+
}
|
|
45
50
|
}
|
|
51
|
+
tr.deleteRange(from, to);
|
|
46
52
|
}
|
|
47
|
-
tr.deleteRange(from, to);
|
|
48
53
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 || _api$blockControls.toggleBlockMenu({
|
|
49
54
|
closeMenu: true
|
|
50
55
|
})({
|