@atlaskit/editor-plugin-block-menu 6.0.12 → 6.0.13
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-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`799170edab4f8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/799170edab4f8) -
|
|
8
|
+
Fix the delete wrong content via keyboard when block menu open
|
|
9
|
+
|
|
3
10
|
## 6.0.12
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -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
|
|
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
|
|
|
@@ -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
|
|
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
|
|
|
@@ -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
|
|
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 {
|
|
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 {
|
|
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.
|
|
3
|
+
"version": "6.0.13",
|
|
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.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^16.12.0",
|
|
48
48
|
"@atlaskit/tokens": "^9.1.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0"
|
|
50
50
|
},
|