Fix shortcut execution on several Editor instances (#631)

* Fix shortcut execution on several Editor instances

* fix problem before handling cmd+a
This commit is contained in:
Murod Khaydarov 2019-03-01 15:09:12 +03:00 committed by GitHub
parent a16767eb12
commit 681e8a5827
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 5 deletions

View file

@ -19,6 +19,7 @@ Welcome to testing stage. Please, join a [public Telegram-chat](//t.me/codex_edi
### 2.7-2.9 changelog
- `Fix` — Fix CMD+A Selection on multiple Editor instances
- `New` — Toolbox now have beautiful helpers with Tool names and shortcuts
- `Improvements` — Prevent navigating back on Firefox when Block is removing by backspace
- `New` — Blocks selected with Rectangle Selection can be also removed, copied or cut

8
dist/editor.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,13 @@
# Changelog
### 2.11.3
- `Fix` — Fix CMD+A Selection on multiple Editor instances
### 2.11.2
- `Improvements` — Docs updated and common enhancements
### 2.11.1
- `Fix` *RectangeSelection* — Selection is available only for the main mouse button

View file

@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.11.2",
"version": "2.11.3",
"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",

View file

@ -107,6 +107,18 @@ export default class BlockSelection extends Module {
Shortcuts.add({
name: 'CMD+A',
handler: (event) => {
const {BlockManager} = this.Editor;
/**
* When one page consist of two or more EditorJS instances
* Shortcut module tries to handle all events. Thats why Editor's selection works inside the target Editor, but for
* others error occurs because nothing to select.
*
* Prevent such actions if focus is not inside the Editor
*/
if (!BlockManager.currentBlock) {
return;
}
this.handleCommandA(event);
},
});