@atlaskit/editor-plugin-block-menu 5.1.10 → 5.1.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,13 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.1.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7c295bfea1292`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7c295bfea1292) -
8
+ EDITOR-3380 Use preserved selection when deleting selected range
9
+ - Updated dependencies
10
+
3
11
  ## 5.1.10
4
12
 
5
13
  ### Patch Changes
@@ -4,7 +4,8 @@
4
4
  "target": "es5",
5
5
  "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-plugin-block-menu",
6
6
  "rootDir": "../",
7
- "composite": true
7
+ "composite": true,
8
+ "noCheck": true
8
9
  },
9
10
  "include": [
10
11
  "../src/**/*.ts",
@@ -4,7 +4,8 @@
4
4
  "target": "es5",
5
5
  "outDir": "../../../../../jira/tsDist/@atlaskit__editor-plugin-block-menu/app",
6
6
  "rootDir": "../",
7
- "composite": true
7
+ "composite": true,
8
+ "noCheck": true
8
9
  },
9
10
  "include": [
10
11
  "../src/**/*.ts",
@@ -4,7 +4,8 @@
4
4
  "target": "es5",
5
5
  "outDir": "../../../../../tsDist/@atlaskit__editor-plugin-block-menu/app",
6
6
  "rootDir": "../",
7
- "composite": true
7
+ "composite": true,
8
+ "noCheck": true
8
9
  },
9
10
  "include": [
10
11
  "../src/**/*.ts",
@@ -195,24 +195,31 @@ var BlockMenu = function BlockMenu(_ref4) {
195
195
  if (!isMenuOpen) {
196
196
  return null;
197
197
  }
198
- var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown() {
198
+ var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown(event) {
199
+ // Pevents delete/backspace keypress being handled by editor, avoids double deletions
200
+ event === null || event === void 0 || event.preventDefault();
201
+ event === null || event === void 0 || event.stopPropagation();
199
202
  api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
200
- var _api$blockControls;
203
+ var _api$blockControls, _api$blockControls2;
201
204
  var tr = _ref6.tr;
202
- (0, _selection.deleteSelectedRange)(tr);
203
- api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.toggleBlockMenu({
205
+ (0, _selection.deleteSelectedRange)(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
206
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
204
207
  closeMenu: true
205
208
  })({
206
209
  tr: tr
207
210
  });
211
+ if (editorView && !editorView.hasFocus()) {
212
+ // if focus is outside editor, e.g. in block menu popup, then refocus editor after delete
213
+ editorView.focus();
214
+ }
208
215
  return tr;
209
216
  });
210
217
  };
211
218
  var closeMenu = function closeMenu() {
212
219
  api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
213
- var _api$blockControls2, _api$userIntent3;
220
+ var _api$blockControls3, _api$userIntent3;
214
221
  var tr = _ref7.tr;
215
- api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
222
+ api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.toggleBlockMenu({
216
223
  closeMenu: true
217
224
  })({
218
225
  tr: tr
@@ -25,7 +25,7 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
25
25
  var nodeTypes = Object.values((api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 || (_api$core$sharedState = _api$core$sharedState.schema) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.nodes) || {});
26
26
  var onClick = function onClick() {
27
27
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
28
- var _api$analytics, _api$blockControls;
28
+ var _api$analytics, _api$blockControls, _api$blockControls2;
29
29
  var tr = _ref2.tr;
30
30
  var payload = {
31
31
  action: _analytics.ACTION.CLICKED,
@@ -36,8 +36,8 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
36
36
  eventType: _analytics.EVENT_TYPE.UI
37
37
  };
38
38
  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);
39
- (0, _selection.deleteSelectedRange)(tr);
40
- 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({
39
+ (0, _selection.deleteSelectedRange)(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
40
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.toggleBlockMenu({
41
41
  closeMenu: true
42
42
  })({
43
43
  tr: tr
@@ -180,17 +180,24 @@ const BlockMenu = ({
180
180
  if (!isMenuOpen) {
181
181
  return null;
182
182
  }
183
- const handleBackspaceDeleteKeydown = () => {
183
+ const handleBackspaceDeleteKeydown = event => {
184
+ // Pevents delete/backspace keypress being handled by editor, avoids double deletions
185
+ event === null || event === void 0 ? void 0 : event.preventDefault();
186
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
184
187
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
185
188
  tr
186
189
  }) => {
187
- var _api$blockControls;
188
- deleteSelectedRange(tr);
189
- api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.toggleBlockMenu({
190
+ var _api$blockControls, _api$blockControls$sh, _api$blockControls2;
191
+ deleteSelectedRange(tr, api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection);
192
+ api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.toggleBlockMenu({
190
193
  closeMenu: true
191
194
  })({
192
195
  tr
193
196
  });
197
+ if (editorView && !editorView.hasFocus()) {
198
+ // if focus is outside editor, e.g. in block menu popup, then refocus editor after delete
199
+ editorView.focus();
200
+ }
194
201
  return tr;
195
202
  });
196
203
  };
@@ -198,8 +205,8 @@ const BlockMenu = ({
198
205
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
199
206
  tr
200
207
  }) => {
201
- var _api$blockControls2, _api$userIntent3;
202
- api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.toggleBlockMenu({
208
+ var _api$blockControls3, _api$userIntent3;
209
+ api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.toggleBlockMenu({
203
210
  closeMenu: true
204
211
  })({
205
212
  tr
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
- import { useIntl, injectIntl } from 'react-intl-next';
2
+ import { injectIntl, useIntl } from 'react-intl-next';
3
3
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
4
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
5
5
  import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
@@ -20,7 +20,7 @@ const DeleteDropdownItemContent = ({
20
20
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
21
21
  tr
22
22
  }) => {
23
- var _api$analytics, _api$analytics$action, _api$blockControls, _api$blockControls$co;
23
+ var _api$analytics, _api$analytics$action, _api$blockControls, _api$blockControls$sh, _api$blockControls2, _api$blockControls2$c;
24
24
  const payload = {
25
25
  action: ACTION.CLICKED,
26
26
  actionSubject: ACTION_SUBJECT.BLOCK_MENU_ITEM,
@@ -30,8 +30,8 @@ const DeleteDropdownItemContent = ({
30
30
  eventType: EVENT_TYPE.UI
31
31
  };
32
32
  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);
33
- deleteSelectedRange(tr);
34
- 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({
33
+ deleteSelectedRange(tr, api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection);
34
+ api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.toggleBlockMenu({
35
35
  closeMenu: true
36
36
  })({
37
37
  tr
@@ -186,24 +186,31 @@ var BlockMenu = function BlockMenu(_ref4) {
186
186
  if (!isMenuOpen) {
187
187
  return null;
188
188
  }
189
- var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown() {
189
+ var handleBackspaceDeleteKeydown = function handleBackspaceDeleteKeydown(event) {
190
+ // Pevents delete/backspace keypress being handled by editor, avoids double deletions
191
+ event === null || event === void 0 || event.preventDefault();
192
+ event === null || event === void 0 || event.stopPropagation();
190
193
  api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
191
- var _api$blockControls;
194
+ var _api$blockControls, _api$blockControls2;
192
195
  var tr = _ref6.tr;
193
- deleteSelectedRange(tr);
194
- api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.toggleBlockMenu({
196
+ deleteSelectedRange(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
197
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
195
198
  closeMenu: true
196
199
  })({
197
200
  tr: tr
198
201
  });
202
+ if (editorView && !editorView.hasFocus()) {
203
+ // if focus is outside editor, e.g. in block menu popup, then refocus editor after delete
204
+ editorView.focus();
205
+ }
199
206
  return tr;
200
207
  });
201
208
  };
202
209
  var closeMenu = function closeMenu() {
203
210
  api === null || api === void 0 || api.core.actions.execute(function (_ref7) {
204
- var _api$blockControls2, _api$userIntent3;
211
+ var _api$blockControls3, _api$userIntent3;
205
212
  var tr = _ref7.tr;
206
- api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.toggleBlockMenu({
213
+ api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.toggleBlockMenu({
207
214
  closeMenu: true
208
215
  })({
209
216
  tr: tr
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
- import { useIntl, injectIntl } from 'react-intl-next';
2
+ import { injectIntl, useIntl } from 'react-intl-next';
3
3
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
4
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
5
5
  import { deleteSelectedRange } from '@atlaskit/editor-common/selection';
@@ -16,7 +16,7 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
16
16
  var nodeTypes = Object.values((api === null || api === void 0 || (_api$core$sharedState = api.core.sharedState.currentState()) === null || _api$core$sharedState === void 0 || (_api$core$sharedState = _api$core$sharedState.schema) === null || _api$core$sharedState === void 0 ? void 0 : _api$core$sharedState.nodes) || {});
17
17
  var onClick = function onClick() {
18
18
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
19
- var _api$analytics, _api$blockControls;
19
+ var _api$analytics, _api$blockControls, _api$blockControls2;
20
20
  var tr = _ref2.tr;
21
21
  var payload = {
22
22
  action: ACTION.CLICKED,
@@ -27,8 +27,8 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
27
27
  eventType: EVENT_TYPE.UI
28
28
  };
29
29
  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);
30
- deleteSelectedRange(tr);
31
- 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({
30
+ deleteSelectedRange(tr, api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection);
31
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.toggleBlockMenu({
32
32
  closeMenu: true
33
33
  })({
34
34
  tr: tr
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.1.10",
3
+ "version": "5.1.11",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,12 +44,12 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
46
  "@atlaskit/primitives": "^16.4.0",
47
- "@atlaskit/tmp-editor-statsig": "^15.0.0",
47
+ "@atlaskit/tmp-editor-statsig": "^15.6.0",
48
48
  "@atlaskit/tokens": "^8.4.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },
51
51
  "peerDependencies": {
52
- "@atlaskit/editor-common": "^110.40.0",
52
+ "@atlaskit/editor-common": "^110.41.0",
53
53
  "react": "^18.2.0",
54
54
  "react-intl-next": "npm:react-intl@^5.18.1"
55
55
  },