@atlaskit/editor-plugin-block-controls 7.18.1 → 7.18.2

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,12 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 7.18.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`275b01c2a180f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/275b01c2a180f) -
8
+ EDITOR-3911 fix key handling while preserving selection
9
+
3
10
  ## 7.18.1
4
11
 
5
12
  ### Patch Changes
@@ -137,15 +137,18 @@ var createSelectionPreservationPlugin = exports.createSelectionPreservationPlugi
137
137
  }
138
138
  var blockMenuOpen = (api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'blockMenuOpen';
139
139
 
140
- // When block menu isn't open and user presses any key, stop preserving selection
141
- if (!blockMenuOpen) {
142
- var tr = view.state.tr;
143
- (0, _editorCommands.stopPreservingSelection)({
144
- tr: tr
145
- });
146
- view.dispatch(tr);
147
- return false;
140
+ // When block menu is open, prevent all key events to avoid changing selection or editing content
141
+ if (blockMenuOpen) {
142
+ return true;
148
143
  }
144
+
145
+ // When block menu isn't open and user presses any key, stop preserving selection
146
+ var tr = view.state.tr;
147
+ (0, _editorCommands.stopPreservingSelection)({
148
+ tr: tr
149
+ });
150
+ view.dispatch(tr);
151
+ return false;
149
152
  }
150
153
  }
151
154
  });
@@ -131,15 +131,18 @@ export const createSelectionPreservationPlugin = api => () => {
131
131
  }
132
132
  const blockMenuOpen = (api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$share = _api$userIntent.sharedState.currentState()) === null || _api$userIntent$share === void 0 ? void 0 : _api$userIntent$share.currentUserIntent) === 'blockMenuOpen';
133
133
 
134
- // When block menu isn't open and user presses any key, stop preserving selection
135
- if (!blockMenuOpen) {
136
- const tr = view.state.tr;
137
- stopPreservingSelection({
138
- tr
139
- });
140
- view.dispatch(tr);
141
- return false;
134
+ // When block menu is open, prevent all key events to avoid changing selection or editing content
135
+ if (blockMenuOpen) {
136
+ return true;
142
137
  }
138
+
139
+ // When block menu isn't open and user presses any key, stop preserving selection
140
+ const tr = view.state.tr;
141
+ stopPreservingSelection({
142
+ tr
143
+ });
144
+ view.dispatch(tr);
145
+ return false;
143
146
  }
144
147
  }
145
148
  });
@@ -131,15 +131,18 @@ export var createSelectionPreservationPlugin = function createSelectionPreservat
131
131
  }
132
132
  var blockMenuOpen = (api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.sharedState.currentState()) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.currentUserIntent) === 'blockMenuOpen';
133
133
 
134
- // When block menu isn't open and user presses any key, stop preserving selection
135
- if (!blockMenuOpen) {
136
- var tr = view.state.tr;
137
- stopPreservingSelection({
138
- tr: tr
139
- });
140
- view.dispatch(tr);
141
- return false;
134
+ // When block menu is open, prevent all key events to avoid changing selection or editing content
135
+ if (blockMenuOpen) {
136
+ return true;
142
137
  }
138
+
139
+ // When block menu isn't open and user presses any key, stop preserving selection
140
+ var tr = view.state.tr;
141
+ stopPreservingSelection({
142
+ tr: tr
143
+ });
144
+ view.dispatch(tr);
145
+ return false;
143
146
  }
144
147
  }
145
148
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "7.18.1",
3
+ "version": "7.18.2",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",