@atlaskit/editor-plugin-block-menu 6.0.18 → 6.0.20
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 +15 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/pm-plugins/main.js +3 -2
- package/dist/cjs/ui/block-menu.js +12 -1
- package/dist/cjs/ui/utils/getSuggestedItemsFromSelection.js +2 -1
- package/dist/es2019/pm-plugins/main.js +3 -2
- package/dist/es2019/ui/block-menu.js +12 -1
- package/dist/es2019/ui/utils/getSuggestedItemsFromSelection.js +4 -1
- package/dist/esm/pm-plugins/main.js +3 -2
- package/dist/esm/ui/block-menu.js +12 -1
- package/dist/esm/ui/utils/getSuggestedItemsFromSelection.js +2 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 6.0.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`edb1034803ecf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/edb1034803ecf) -
|
|
8
|
+
Fix undo/redo via keyboard when block menu is open
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 6.0.19
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`5a2e9d04ff4d5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5a2e9d04ff4d5) -
|
|
16
|
+
[ux] Shows only available transforms in 'Suggested' section.
|
|
17
|
+
|
|
3
18
|
## 6.0.18
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -35,12 +35,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// Block further handling of key events when block menu is open
|
|
38
|
-
// Except for backspace/delete/copy/cut/paste which should be handled by the selection preservation plugin
|
|
38
|
+
// Except for backspace/delete/copy/cut/paste/undo/redo which should be handled by the selection preservation plugin
|
|
39
39
|
var key = event.key.toLowerCase();
|
|
40
40
|
var isMetaCtrl = event.metaKey || event.ctrlKey;
|
|
41
41
|
var isBackspaceDelete = ['backspace', 'delete'].includes(key);
|
|
42
42
|
var isCopyCutPaste = isMetaCtrl && ['c', 'x', 'v'].includes(key);
|
|
43
|
-
var
|
|
43
|
+
var isUndoRedo = isMetaCtrl && ['z', 'y'].includes(key);
|
|
44
|
+
var suppressNativeHandling = !isCopyCutPaste && !isBackspaceDelete && !isUndoRedo;
|
|
44
45
|
return suppressNativeHandling;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -24,6 +24,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
24
24
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
25
25
|
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
|
|
26
26
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
27
|
+
var _prosemirrorHistory = require("@atlaskit/prosemirror-history");
|
|
27
28
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
28
29
|
var _blockMenuProvider = require("./block-menu-provider");
|
|
29
30
|
var _BlockMenuRenderer = require("./block-menu-renderer/BlockMenuRenderer");
|
|
@@ -198,12 +199,22 @@ var BlockMenu = function BlockMenu(_ref4) {
|
|
|
198
199
|
if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus() || isSelectionWithinCodeBlock(editorView.state)) {
|
|
199
200
|
return;
|
|
200
201
|
}
|
|
202
|
+
var key = event.key.toLowerCase();
|
|
203
|
+
var isMetaCtrl = event.metaKey || event.ctrlKey;
|
|
204
|
+
var isDelete = ['backspace', 'delete'].includes(key);
|
|
205
|
+
var isUndo = isMetaCtrl && key === 'z' && !event.shiftKey;
|
|
206
|
+
var isRedo = isMetaCtrl && (key === 'y' || key === 'z' && event.shiftKey);
|
|
201
207
|
|
|
202
208
|
// Necessary to prevent the editor from handling the delete natively
|
|
203
|
-
if (
|
|
209
|
+
if (isDelete || isUndo || isRedo) {
|
|
204
210
|
event.preventDefault();
|
|
205
211
|
event.stopPropagation();
|
|
206
212
|
}
|
|
213
|
+
if (isUndo) {
|
|
214
|
+
(0, _prosemirrorHistory.undo)(editorView.state, editorView.dispatch);
|
|
215
|
+
} else if (isRedo) {
|
|
216
|
+
(0, _prosemirrorHistory.redo)(editorView.state, editorView.dispatch);
|
|
217
|
+
}
|
|
207
218
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.handleKeyDownWithPreservedSelection(event));
|
|
208
219
|
};
|
|
209
220
|
var handleClickOutside = function handleClickOutside(e) {
|
|
@@ -35,6 +35,7 @@ var getSuggestedItemsFromSelection = exports.getSuggestedItemsFromSelection = fu
|
|
|
35
35
|
return sortedKeys.map(function (key) {
|
|
36
36
|
return menuItemsMap.get(key);
|
|
37
37
|
}).filter(function (item) {
|
|
38
|
-
|
|
38
|
+
var _item$isHidden;
|
|
39
|
+
return item !== undefined && !((_item$isHidden = item.isHidden) !== null && _item$isHidden !== void 0 && _item$isHidden.call(item));
|
|
39
40
|
});
|
|
40
41
|
};
|
|
@@ -29,12 +29,13 @@ export const createPlugin = api => {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Block further handling of key events when block menu is open
|
|
32
|
-
// Except for backspace/delete/copy/cut/paste which should be handled by the selection preservation plugin
|
|
32
|
+
// Except for backspace/delete/copy/cut/paste/undo/redo which should be handled by the selection preservation plugin
|
|
33
33
|
const key = event.key.toLowerCase();
|
|
34
34
|
const isMetaCtrl = event.metaKey || event.ctrlKey;
|
|
35
35
|
const isBackspaceDelete = ['backspace', 'delete'].includes(key);
|
|
36
36
|
const isCopyCutPaste = isMetaCtrl && ['c', 'x', 'v'].includes(key);
|
|
37
|
-
const
|
|
37
|
+
const isUndoRedo = isMetaCtrl && ['z', 'y'].includes(key);
|
|
38
|
+
const suppressNativeHandling = !isCopyCutPaste && !isBackspaceDelete && !isUndoRedo;
|
|
38
39
|
return suppressNativeHandling;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -15,6 +15,7 @@ import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styl
|
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
16
|
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
17
17
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
18
|
+
import { redo, undo } from '@atlaskit/prosemirror-history';
|
|
18
19
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
20
|
import { useBlockMenu } from './block-menu-provider';
|
|
20
21
|
import { BlockMenuRenderer } from './block-menu-renderer/BlockMenuRenderer';
|
|
@@ -188,12 +189,22 @@ const BlockMenu = ({
|
|
|
188
189
|
if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus() || isSelectionWithinCodeBlock(editorView.state)) {
|
|
189
190
|
return;
|
|
190
191
|
}
|
|
192
|
+
const key = event.key.toLowerCase();
|
|
193
|
+
const isMetaCtrl = event.metaKey || event.ctrlKey;
|
|
194
|
+
const isDelete = ['backspace', 'delete'].includes(key);
|
|
195
|
+
const isUndo = isMetaCtrl && key === 'z' && !event.shiftKey;
|
|
196
|
+
const isRedo = isMetaCtrl && (key === 'y' || key === 'z' && event.shiftKey);
|
|
191
197
|
|
|
192
198
|
// Necessary to prevent the editor from handling the delete natively
|
|
193
|
-
if (
|
|
199
|
+
if (isDelete || isUndo || isRedo) {
|
|
194
200
|
event.preventDefault();
|
|
195
201
|
event.stopPropagation();
|
|
196
202
|
}
|
|
203
|
+
if (isUndo) {
|
|
204
|
+
undo(editorView.state, editorView.dispatch);
|
|
205
|
+
} else if (isRedo) {
|
|
206
|
+
redo(editorView.state, editorView.dispatch);
|
|
207
|
+
}
|
|
197
208
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(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.handleKeyDownWithPreservedSelection(event));
|
|
198
209
|
};
|
|
199
210
|
const handleClickOutside = e => {
|
|
@@ -26,5 +26,8 @@ export const getSuggestedItemsFromSelection = (menuItemsMap, currentSelection) =
|
|
|
26
26
|
}
|
|
27
27
|
const nodeTypeName = firstNodeType;
|
|
28
28
|
const sortedKeys = getSortedSuggestedItems(nodeTypeName);
|
|
29
|
-
return sortedKeys.map(key => menuItemsMap.get(key)).filter(item =>
|
|
29
|
+
return sortedKeys.map(key => menuItemsMap.get(key)).filter(item => {
|
|
30
|
+
var _item$isHidden;
|
|
31
|
+
return item !== undefined && !((_item$isHidden = item.isHidden) !== null && _item$isHidden !== void 0 && _item$isHidden.call(item));
|
|
32
|
+
});
|
|
30
33
|
};
|
|
@@ -29,12 +29,13 @@ export var createPlugin = function createPlugin(api) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Block further handling of key events when block menu is open
|
|
32
|
-
// Except for backspace/delete/copy/cut/paste which should be handled by the selection preservation plugin
|
|
32
|
+
// Except for backspace/delete/copy/cut/paste/undo/redo which should be handled by the selection preservation plugin
|
|
33
33
|
var key = event.key.toLowerCase();
|
|
34
34
|
var isMetaCtrl = event.metaKey || event.ctrlKey;
|
|
35
35
|
var isBackspaceDelete = ['backspace', 'delete'].includes(key);
|
|
36
36
|
var isCopyCutPaste = isMetaCtrl && ['c', 'x', 'v'].includes(key);
|
|
37
|
-
var
|
|
37
|
+
var isUndoRedo = isMetaCtrl && ['z', 'y'].includes(key);
|
|
38
|
+
var suppressNativeHandling = !isCopyCutPaste && !isBackspaceDelete && !isUndoRedo;
|
|
38
39
|
return suppressNativeHandling;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -16,6 +16,7 @@ import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styl
|
|
|
16
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
17
|
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
18
18
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
19
|
+
import { redo, undo } from '@atlaskit/prosemirror-history';
|
|
19
20
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
20
21
|
import { useBlockMenu } from './block-menu-provider';
|
|
21
22
|
import { BlockMenuRenderer } from './block-menu-renderer/BlockMenuRenderer';
|
|
@@ -189,12 +190,22 @@ var BlockMenu = function BlockMenu(_ref4) {
|
|
|
189
190
|
if (!editorView || editorView !== null && editorView !== void 0 && editorView.hasFocus() || isSelectionWithinCodeBlock(editorView.state)) {
|
|
190
191
|
return;
|
|
191
192
|
}
|
|
193
|
+
var key = event.key.toLowerCase();
|
|
194
|
+
var isMetaCtrl = event.metaKey || event.ctrlKey;
|
|
195
|
+
var isDelete = ['backspace', 'delete'].includes(key);
|
|
196
|
+
var isUndo = isMetaCtrl && key === 'z' && !event.shiftKey;
|
|
197
|
+
var isRedo = isMetaCtrl && (key === 'y' || key === 'z' && event.shiftKey);
|
|
192
198
|
|
|
193
199
|
// Necessary to prevent the editor from handling the delete natively
|
|
194
|
-
if (
|
|
200
|
+
if (isDelete || isUndo || isRedo) {
|
|
195
201
|
event.preventDefault();
|
|
196
202
|
event.stopPropagation();
|
|
197
203
|
}
|
|
204
|
+
if (isUndo) {
|
|
205
|
+
undo(editorView.state, editorView.dispatch);
|
|
206
|
+
} else if (isRedo) {
|
|
207
|
+
redo(editorView.state, editorView.dispatch);
|
|
208
|
+
}
|
|
198
209
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.commands) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.handleKeyDownWithPreservedSelection(event));
|
|
199
210
|
};
|
|
200
211
|
var handleClickOutside = function handleClickOutside(e) {
|
|
@@ -30,6 +30,7 @@ export var getSuggestedItemsFromSelection = function getSuggestedItemsFromSelect
|
|
|
30
30
|
return sortedKeys.map(function (key) {
|
|
31
31
|
return menuItemsMap.get(key);
|
|
32
32
|
}).filter(function (item) {
|
|
33
|
-
|
|
33
|
+
var _item$isHidden;
|
|
34
|
+
return item !== undefined && !((_item$isHidden = item.isHidden) !== null && _item$isHidden !== void 0 && _item$isHidden.call(item));
|
|
34
35
|
});
|
|
35
36
|
};
|
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.20",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
47
47
|
"@atlaskit/primitives": "^17.1.0",
|
|
48
|
-
"@atlaskit/
|
|
48
|
+
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^16.24.0",
|
|
49
50
|
"@atlaskit/tokens": "^10.0.0",
|
|
50
51
|
"@babel/runtime": "^7.0.0"
|
|
51
52
|
},
|