@atlaskit/editor-plugin-block-menu 5.0.10 → 5.0.12

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 5.0.11
10
+
11
+ ### Patch Changes
12
+
13
+ - [`bf1f847655683`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bf1f847655683) -
14
+ ED-29512: Fixed not able to delete node when block menu is visible
15
+ - Updated dependencies
16
+
3
17
  ## 5.0.10
4
18
 
5
19
  ### Patch Changes
@@ -6,10 +6,7 @@
6
6
  "rootDir": "../",
7
7
  "composite": true
8
8
  },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
9
+ "include": ["../src/**/*.ts", "../src/**/*.tsx"],
13
10
  "exclude": [
14
11
  "../src/**/__tests__/*",
15
12
  "../src/**/*.test.*",
@@ -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 closeMenu = function closeMenu() {
189
+ var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown() {
189
190
  api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
190
- var _api$blockControls, _api$userIntent3;
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
- initialFocus: openedViaKeyboard ? undefined : targetHandleRef
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
- var selection = tr.selection;
44
- var from = selection.$from.pos;
45
- var to = selection.$to.pos;
46
- if (selection instanceof _state.TextSelection) {
47
- from = from - 1;
48
- to = to + 1;
49
- } else if ((0, _utils.isTableSelected)(selection)) {
50
- var table = (0, _utils.findTable)(selection);
51
- if (table) {
52
- from = table.pos;
53
- to = table.pos + table.node.nodeSize;
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 closeMenu = () => {
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, _api$userIntent3;
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
- initialFocus: openedViaKeyboard ? undefined : targetHandleRef
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
- const selection = tr.selection;
38
- let from = selection.$from.pos;
39
- let to = selection.$to.pos;
40
- if (selection instanceof TextSelection) {
41
- from = from - 1;
42
- to = to + 1;
43
- } else if (isTableSelected(selection)) {
44
- const table = findTable(selection);
45
- if (table) {
46
- from = table.pos;
47
- to = table.pos + table.node.nodeSize;
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 closeMenu = function closeMenu() {
181
+ var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown() {
181
182
  api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
182
- var _api$blockControls, _api$userIntent3;
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
- initialFocus: openedViaKeyboard ? undefined : targetHandleRef
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
- var selection = tr.selection;
35
- var from = selection.$from.pos;
36
- var to = selection.$to.pos;
37
- if (selection instanceof TextSelection) {
38
- from = from - 1;
39
- to = to + 1;
40
- } else if (isTableSelected(selection)) {
41
- var table = findTable(selection);
42
- if (table) {
43
- from = table.pos;
44
- to = table.pos + table.node.nodeSize;
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
  })({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.0.10",
3
+ "version": "5.0.12",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,7 +28,7 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/css": "^0.15.0",
31
+ "@atlaskit/css": "^0.16.0",
32
32
  "@atlaskit/dropdown-menu": "^16.3.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
34
34
  "@atlaskit/editor-plugin-block-controls": "^7.7.0",
@@ -36,20 +36,20 @@
36
36
  "@atlaskit/editor-plugin-selection": "^6.1.0",
37
37
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
38
38
  "@atlaskit/editor-prosemirror": "7.0.0",
39
- "@atlaskit/editor-shared-styles": "^3.9.0",
39
+ "@atlaskit/editor-shared-styles": "^3.10.0",
40
40
  "@atlaskit/editor-tables": "^2.9.0",
41
41
  "@atlaskit/editor-toolbar": "^0.17.0",
42
42
  "@atlaskit/icon": "^29.0.0",
43
43
  "@atlaskit/icon-lab": "^5.12.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
- "@atlaskit/primitives": "^16.1.0",
47
- "@atlaskit/tmp-editor-statsig": "^13.38.0",
48
- "@atlaskit/tokens": "^8.0.0",
46
+ "@atlaskit/primitives": "^16.2.0",
47
+ "@atlaskit/tmp-editor-statsig": "^13.39.0",
48
+ "@atlaskit/tokens": "^8.1.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@atlaskit/editor-common": "^110.31.0",
52
+ "@atlaskit/editor-common": "^110.32.0",
53
53
  "react": "^18.2.0",
54
54
  "react-intl-next": "npm:react-intl@^5.18.1"
55
55
  },