@atlaskit/editor-plugin-block-menu 5.0.9 → 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 CHANGED
@@ -1,5 +1,21 @@
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
+
11
+ ## 5.0.10
12
+
13
+ ### Patch Changes
14
+
15
+ - [`c0f06bd1a9b63`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c0f06bd1a9b63) -
16
+ Feature flag removal platform_editor_block_menu_patch_2
17
+ - Updated dependencies
18
+
3
19
  ## 5.0.9
4
20
 
5
21
  ### 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.*",
@@ -8,7 +8,6 @@ var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _monitoring = require("@atlaskit/editor-common/monitoring");
9
9
  var _state = require("@atlaskit/editor-prosemirror/state");
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
12
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
14
13
  var _selection = require("./selection");
@@ -124,7 +123,7 @@ var formatNode = exports.formatNode = function formatNode(api) {
124
123
  });
125
124
  // get the first list node as when click on drag handle if there are list node
126
125
  // can only select one list at a time, so we just need to find the first one
127
- if (listNodes.length > 0 && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_patch_2')) {
126
+ if (listNodes.length > 0) {
128
127
  var firstChild = listNodes[0];
129
128
  var newTr = formatNodeSelectEmptyList(tr, targetType, firstChild, schema);
130
129
  if (newTr) {
@@ -8,7 +8,6 @@ exports.unwrapAndConvertToList = exports.unwrapAndConvertToBlockType = exports.t
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _model = require("@atlaskit/editor-prosemirror/model");
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
11
  var _inlineNodeTransforms = require("./inline-node-transforms");
13
12
  var _utils2 = require("./utils");
14
13
  var convertInvalidNodeToValidNodeType = function convertInvalidNodeToValidNodeType(sourceContent, sourceNodeType, validNodeType, withMarks) {
@@ -204,7 +203,7 @@ var unwrapAndConvertToList = exports.unwrapAndConvertToList = function unwrapAnd
204
203
  heading = _schema$nodes2.heading;
205
204
  var isTargetTaskList = targetNodeType === taskList;
206
205
  var createListItemFromInline = function createListItemFromInline(content) {
207
- if (!content && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_patch_2')) {
206
+ if (!content) {
208
207
  return isTargetTaskList ? taskItem.create() : listItem.create(null, paragraph.create());
209
208
  } else {
210
209
  return isTargetTaskList ? taskItem.create(null, content) : listItem.create(null, paragraph.create(null, content));
@@ -243,7 +242,7 @@ var unwrapAndConvertToList = exports.unwrapAndConvertToList = function unwrapAnd
243
242
  var isOnlyNewLines = function isOnlyNewLines(codeText) {
244
243
  return codeText.replace(/\n/g, '').trim() === '';
245
244
  };
246
- if ((!codeText || isOnlyNewLines(codeText)) && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_patch_2')) {
245
+ if (!codeText || isOnlyNewLines(codeText)) {
247
246
  // Empty code block - create an empty list item
248
247
  currentListItems.push(createListItemFromInline());
249
248
  }
@@ -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, {
@@ -76,7 +76,7 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
76
76
  // if text is inside of an expand or extension, the selection contains an expand or extension for some reason
77
77
  // the expandNode or extensionNode always and only have one child, no matter how much contents are inside the expand or extension,
78
78
  // and the one child is the line that is being selected, so we can use the .firstChild again
79
- if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension' && (0, _platformFeatureFlags.fg)('platform_editor_block_menu_patch_2'))) {
79
+ if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension')) {
80
80
  var expandOrExtensionNode = fragment.firstChild;
81
81
  var actualNodeToCopy = expandOrExtensionNode.firstChild;
82
82
  fragment = _model.Fragment.from(actualNodeToCopy) || _model.Fragment.empty;
@@ -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
  })({
@@ -2,7 +2,6 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
2
2
  import { logException } from '@atlaskit/editor-common/monitoring';
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findParentNodeOfType, findSelectedNodeOfType, safeInsert as pmSafeInsert } from '@atlaskit/editor-prosemirror/utils';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
6
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
8
7
  import { setSelectionAfterTransform } from './selection';
@@ -129,7 +128,7 @@ export const formatNode = api => (targetType, analyticsAttrs) => {
129
128
  });
130
129
  // get the first list node as when click on drag handle if there are list node
131
130
  // can only select one list at a time, so we just need to find the first one
132
- if (listNodes.length > 0 && fg('platform_editor_block_menu_patch_2')) {
131
+ if (listNodes.length > 0) {
133
132
  const firstChild = listNodes[0];
134
133
  const newTr = formatNodeSelectEmptyList(tr, targetType, firstChild, schema);
135
134
  if (newTr) {
@@ -1,6 +1,5 @@
1
1
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
2
2
  import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { getInlineNodeTextContent } from './inline-node-transforms';
5
4
  import { isBlockNodeType, isListNodeType, isContainerNodeType, isBlockNodeForExtraction, convertNodeToInlineContent, getContentSupportChecker, convertCodeBlockContentToParagraphs, filterMarksForTargetNodeType, getMarksWithBreakout } from './utils';
6
5
  const convertInvalidNodeToValidNodeType = (sourceContent, sourceNodeType, validNodeType, withMarks) => {
@@ -205,7 +204,7 @@ export const unwrapAndConvertToList = ({
205
204
  } = schema.nodes;
206
205
  const isTargetTaskList = targetNodeType === taskList;
207
206
  const createListItemFromInline = content => {
208
- if (!content && fg('platform_editor_block_menu_patch_2')) {
207
+ if (!content) {
209
208
  return isTargetTaskList ? taskItem.create() : listItem.create(null, paragraph.create());
210
209
  } else {
211
210
  return isTargetTaskList ? taskItem.create(null, content) : listItem.create(null, paragraph.create(null, content));
@@ -242,7 +241,7 @@ export const unwrapAndConvertToList = ({
242
241
  // check if code block only contains newline characters
243
242
  // eslint-disable-next-line require-unicode-regexp
244
243
  const isOnlyNewLines = codeText => codeText.replace(/\n/g, '').trim() === '';
245
- if ((!codeText || isOnlyNewLines(codeText)) && fg('platform_editor_block_menu_patch_2')) {
244
+ if (!codeText || isOnlyNewLines(codeText)) {
246
245
  // Empty code block - create an empty list item
247
246
  currentListItems.push(createListItemFromInline());
248
247
  }
@@ -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, {
@@ -70,7 +70,7 @@ const CopyBlockMenuItem = ({
70
70
  // if text is inside of an expand or extension, the selection contains an expand or extension for some reason
71
71
  // the expandNode or extensionNode always and only have one child, no matter how much contents are inside the expand or extension,
72
72
  // and the one child is the line that is being selected, so we can use the .firstChild again
73
- if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension' && fg('platform_editor_block_menu_patch_2'))) {
73
+ if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension')) {
74
74
  const expandOrExtensionNode = fragment.firstChild;
75
75
  const actualNodeToCopy = expandOrExtensionNode.firstChild;
76
76
  fragment = Fragment.from(actualNodeToCopy) || Fragment.empty;
@@ -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
  })({
@@ -2,7 +2,6 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
2
2
  import { logException } from '@atlaskit/editor-common/monitoring';
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findParentNodeOfType, findSelectedNodeOfType, safeInsert as pmSafeInsert } from '@atlaskit/editor-prosemirror/utils';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
6
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
8
7
  import { setSelectionAfterTransform } from './selection';
@@ -119,7 +118,7 @@ export var formatNode = function formatNode(api) {
119
118
  });
120
119
  // get the first list node as when click on drag handle if there are list node
121
120
  // can only select one list at a time, so we just need to find the first one
122
- if (listNodes.length > 0 && fg('platform_editor_block_menu_patch_2')) {
121
+ if (listNodes.length > 0) {
123
122
  var firstChild = listNodes[0];
124
123
  var newTr = formatNodeSelectEmptyList(tr, targetType, firstChild, schema);
125
124
  if (newTr) {
@@ -1,7 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
4
- import { fg } from '@atlaskit/platform-feature-flags';
5
4
  import { getInlineNodeTextContent } from './inline-node-transforms';
6
5
  import { isBlockNodeType, isListNodeType, isContainerNodeType, isBlockNodeForExtraction, convertNodeToInlineContent, getContentSupportChecker, convertCodeBlockContentToParagraphs, filterMarksForTargetNodeType, getMarksWithBreakout } from './utils';
7
6
  var convertInvalidNodeToValidNodeType = function convertInvalidNodeToValidNodeType(sourceContent, sourceNodeType, validNodeType, withMarks) {
@@ -197,7 +196,7 @@ export var unwrapAndConvertToList = function unwrapAndConvertToList(_ref3) {
197
196
  heading = _schema$nodes2.heading;
198
197
  var isTargetTaskList = targetNodeType === taskList;
199
198
  var createListItemFromInline = function createListItemFromInline(content) {
200
- if (!content && fg('platform_editor_block_menu_patch_2')) {
199
+ if (!content) {
201
200
  return isTargetTaskList ? taskItem.create() : listItem.create(null, paragraph.create());
202
201
  } else {
203
202
  return isTargetTaskList ? taskItem.create(null, content) : listItem.create(null, paragraph.create(null, content));
@@ -236,7 +235,7 @@ export var unwrapAndConvertToList = function unwrapAndConvertToList(_ref3) {
236
235
  var isOnlyNewLines = function isOnlyNewLines(codeText) {
237
236
  return codeText.replace(/\n/g, '').trim() === '';
238
237
  };
239
- if ((!codeText || isOnlyNewLines(codeText)) && fg('platform_editor_block_menu_patch_2')) {
238
+ if (!codeText || isOnlyNewLines(codeText)) {
240
239
  // Empty code block - create an empty list item
241
240
  currentListItems.push(createListItemFromInline());
242
241
  }
@@ -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, {
@@ -69,7 +69,7 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
69
69
  // if text is inside of an expand or extension, the selection contains an expand or extension for some reason
70
70
  // the expandNode or extensionNode always and only have one child, no matter how much contents are inside the expand or extension,
71
71
  // and the one child is the line that is being selected, so we can use the .firstChild again
72
- if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension' && fg('platform_editor_block_menu_patch_2'))) {
72
+ if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && (fragment.firstChild.type.name === 'expand' || fragment.firstChild.type.name === 'bodiedExtension')) {
73
73
  var expandOrExtensionNode = fragment.firstChild;
74
74
  var actualNodeToCopy = expandOrExtensionNode.firstChild;
75
75
  fragment = Fragment.from(actualNodeToCopy) || Fragment.empty;
@@ -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.9",
3
+ "version": "5.0.11",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -102,9 +102,6 @@
102
102
  "platform_editor_block_menu_for_disabled_nodes": {
103
103
  "type": "boolean"
104
104
  },
105
- "platform_editor_block_menu_patch_2": {
106
- "type": "boolean"
107
- },
108
105
  "platform_editor_block_menu_shouldfitcontainer": {
109
106
  "type": "boolean"
110
107
  },