@atlaskit/editor-plugin-block-menu 6.0.12 → 6.0.14

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,20 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 6.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [`3a117b2d76d59`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3a117b2d76d59) -
8
+ [ux] Transform decision -> codeBlock and quote -> headings are disabled.
9
+ - Updated dependencies
10
+
11
+ ## 6.0.13
12
+
13
+ ### Patch Changes
14
+
15
+ - [`799170edab4f8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/799170edab4f8) -
16
+ Fix the delete wrong content via keyboard when block menu open
17
+
3
18
  ## 6.0.12
4
19
 
5
20
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "../../../../tsconfig.entry-points.confluence.json",
2
+ "extends": "../../../../tsconfig.local-consumption.json",
3
3
  "compilerOptions": {
4
4
  "target": "es5",
5
5
  "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-plugin-block-menu",
@@ -77,7 +77,6 @@ var TRANSFORMATION_MATRIX = exports.TRANSFORMATION_MATRIX = {
77
77
  layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
78
78
  panel: [_unwrapStep.unwrapStep, _wrapStep.wrapStep],
79
79
  paragraph: [_unwrapStep.unwrapStep],
80
- heading: [_unwrapStep.unwrapStep, _applyTargetTextTypeStep.applyTargetTextTypeStep],
81
80
  decisionList: [_unwrapStep.unwrapStep, _wrapBlockquoteToDecisionListStep.wrapBlockquoteToDecisionListStep]
82
81
  },
83
82
  layoutSection: {
@@ -165,7 +164,6 @@ var TRANSFORMATION_MATRIX = exports.TRANSFORMATION_MATRIX = {
165
164
  orderedList: [_decisionListToListStep.decisionListToListStep],
166
165
  taskList: [_decisionListToListStep.decisionListToListStep],
167
166
  blockquote: [_unwrapListStep.unwrapListStep, _wrapStep.wrapStep],
168
- codeBlock: [_unwrapListStep.unwrapListStep, _wrapMixedContentStep.wrapMixedContentStep],
169
167
  expand: [_wrapStep.wrapStep],
170
168
  nestedExpand: [_wrapStep.wrapStep],
171
169
  layoutSection: [_wrapMixedContentStep.wrapMixedContentStep],
@@ -105,6 +105,12 @@ var useConditionalBlockMenuEffect = (0, _platformFeatureFlagsReact.conditionalHo
105
105
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('blockMenuOpen'));
106
106
  }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutOrDragHandle, hasFocus, currentUserIntent, openedViaKeyboard, prevIsMenuOpenRef]);
107
107
  });
108
+ var isSelectionWithinCodeBlock = function isSelectionWithinCodeBlock(state) {
109
+ var _state$selection = state.selection,
110
+ $from = _state$selection.$from,
111
+ $to = _state$selection.$to;
112
+ return $from.sameParent($to) && $from.parent.type === state.schema.nodes.codeBlock;
113
+ };
108
114
  var BlockMenuContent = function BlockMenuContent(_ref3) {
109
115
  var _api$blockMenu;
110
116
  var api = _ref3.api,
@@ -188,7 +194,8 @@ var BlockMenu = function BlockMenu(_ref4) {
188
194
  var _api$core, _api$blockControls;
189
195
  // When the editor view has focus, the keydown will be handled by the
190
196
  // selection preservation plugin – exit early to avoid double handling
191
- if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus()) {
197
+ // Also exit if selection is within a code block to avoid double handling when code block got focus when the node after it is deleted
198
+ if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus() || isSelectionWithinCodeBlock(editorView.state)) {
192
199
  return;
193
200
  }
194
201
 
@@ -72,7 +72,6 @@ export const TRANSFORMATION_MATRIX = {
72
72
  layoutSection: [wrapMixedContentStep],
73
73
  panel: [unwrapStep, wrapStep],
74
74
  paragraph: [unwrapStep],
75
- heading: [unwrapStep, applyTargetTextTypeStep],
76
75
  decisionList: [unwrapStep, wrapBlockquoteToDecisionListStep]
77
76
  },
78
77
  layoutSection: {
@@ -160,7 +159,6 @@ export const TRANSFORMATION_MATRIX = {
160
159
  orderedList: [decisionListToListStep],
161
160
  taskList: [decisionListToListStep],
162
161
  blockquote: [unwrapListStep, wrapStep],
163
- codeBlock: [unwrapListStep, wrapMixedContentStep],
164
162
  expand: [wrapStep],
165
163
  nestedExpand: [wrapStep],
166
164
  layoutSection: [wrapMixedContentStep],
@@ -95,6 +95,13 @@ const useConditionalBlockMenuEffect = conditionalHooksFactory(() => fg('platform
95
95
  api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('blockMenuOpen'));
96
96
  }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutOrDragHandle, hasFocus, currentUserIntent, openedViaKeyboard, prevIsMenuOpenRef]);
97
97
  });
98
+ const isSelectionWithinCodeBlock = state => {
99
+ const {
100
+ $from,
101
+ $to
102
+ } = state.selection;
103
+ return $from.sameParent($to) && $from.parent.type === state.schema.nodes.codeBlock;
104
+ };
98
105
  const BlockMenuContent = ({
99
106
  api,
100
107
  setRef
@@ -177,7 +184,8 @@ const BlockMenu = ({
177
184
  var _api$core, _api$blockControls, _api$blockControls$co;
178
185
  // When the editor view has focus, the keydown will be handled by the
179
186
  // selection preservation plugin – exit early to avoid double handling
180
- if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus()) {
187
+ // Also exit if selection is within a code block to avoid double handling when code block got focus when the node after it is deleted
188
+ if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus() || isSelectionWithinCodeBlock(editorView.state)) {
181
189
  return;
182
190
  }
183
191
 
@@ -72,7 +72,6 @@ export var TRANSFORMATION_MATRIX = {
72
72
  layoutSection: [wrapMixedContentStep],
73
73
  panel: [unwrapStep, wrapStep],
74
74
  paragraph: [unwrapStep],
75
- heading: [unwrapStep, applyTargetTextTypeStep],
76
75
  decisionList: [unwrapStep, wrapBlockquoteToDecisionListStep]
77
76
  },
78
77
  layoutSection: {
@@ -160,7 +159,6 @@ export var TRANSFORMATION_MATRIX = {
160
159
  orderedList: [decisionListToListStep],
161
160
  taskList: [decisionListToListStep],
162
161
  blockquote: [unwrapListStep, wrapStep],
163
- codeBlock: [unwrapListStep, wrapMixedContentStep],
164
162
  expand: [wrapStep],
165
163
  nestedExpand: [wrapStep],
166
164
  layoutSection: [wrapMixedContentStep],
@@ -96,6 +96,12 @@ var useConditionalBlockMenuEffect = conditionalHooksFactory(function () {
96
96
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands.setCurrentUserIntent('blockMenuOpen'));
97
97
  }, [api, isMenuOpen, menuTriggerBy, selectedByShortcutOrDragHandle, hasFocus, currentUserIntent, openedViaKeyboard, prevIsMenuOpenRef]);
98
98
  });
99
+ var isSelectionWithinCodeBlock = function isSelectionWithinCodeBlock(state) {
100
+ var _state$selection = state.selection,
101
+ $from = _state$selection.$from,
102
+ $to = _state$selection.$to;
103
+ return $from.sameParent($to) && $from.parent.type === state.schema.nodes.codeBlock;
104
+ };
99
105
  var BlockMenuContent = function BlockMenuContent(_ref3) {
100
106
  var _api$blockMenu;
101
107
  var api = _ref3.api,
@@ -179,7 +185,8 @@ var BlockMenu = function BlockMenu(_ref4) {
179
185
  var _api$core, _api$blockControls;
180
186
  // When the editor view has focus, the keydown will be handled by the
181
187
  // selection preservation plugin – exit early to avoid double handling
182
- if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus()) {
188
+ // Also exit if selection is within a code block to avoid double handling when code block got focus when the node after it is deleted
189
+ if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus() || isSelectionWithinCodeBlock(editorView.state)) {
183
190
  return;
184
191
  }
185
192
 
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
- import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { BlockMenuPlugin } from '../blockMenuPluginType';
6
6
  export type BlockMenuProps = {
7
7
  api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
- import { type EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { BlockMenuPlugin } from '../blockMenuPluginType';
6
6
  export type BlockMenuProps = {
7
7
  api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "6.0.12",
3
+ "version": "6.0.14",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
46
  "@atlaskit/primitives": "^17.0.0",
47
- "@atlaskit/tmp-editor-statsig": "^16.11.0",
47
+ "@atlaskit/tmp-editor-statsig": "^16.13.0",
48
48
  "@atlaskit/tokens": "^9.1.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },