Hotfix/issue1133 selection shortcut removed on editor destroy (#1140)

* Removed shortcut CMD+A on editor destroy #1133

* Removed patch version and made code cleaner #1133

* lint error fixes #1133

Co-authored-by: Sisir <sisir@hellosivi.com>
Co-authored-by: George Berezhnoy <gohabereg@gmail.com>
This commit is contained in:
Sisir Das K 2020-05-28 01:13:24 +05:30 committed by GitHub
parent 5fe8b089ef
commit 7c3bf76050
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 4 deletions

2
dist/editor.js vendored

File diff suppressed because one or more lines are too long

View file

@ -12,11 +12,13 @@
- `Improvements` - Improve performance of DOM traversing at the `isEmpty()` method [#1095](https://github.com/codex-team/editor.js/issues/1095)
- `Improvements` - Add code of conduct
- `Improvements` - Disabled useCapture flag for a block keydown handling. That will allow plugins to override keydown and stop event propagation, for example, to make own Tab behavior.
- `Improvements` - All modules now might have `destroy` method called on Editor.js destroy
- `Fix` - Editor's styles won't be appended to the `<head>` when another instance have already do that [#1079](https://github.com/codex-team/editor.js/issues/1079)
- `Fix` - Fixed wrong toolbar icon centering in Firefox [#1120](https://github.com/codex-team/editor.js/pull/1120)
- `Fix` - Toolbox: Tool's order in Toolbox now saved in accordance with `tools` object keys order [#1073](https://github.com/codex-team/editor.js/issues/1073)
- `Fix` - Setting `autofocus` config property to `true` cause adding `.ce-block--focused` for the autofocused block [#1073](https://github.com/codex-team/editor.js/issues/1124)
- `Fix` - Public getter `shortcut` now works for Inline Tools [#1132](https://github.com/codex-team/editor.js/issues/1132)
- `Fix` - `CMD+A` handler removed after Editor.js destroy [#1133](https://github.com/codex-team/editor.js/issues/1133)
### 2.17

View file

@ -9,6 +9,7 @@ import '@babel/register';
import 'components/polyfills';
import Core from './components/core';
import * as _ from './components/utils';
declare const VERSION: string;
@ -81,9 +82,13 @@ export default class EditorJS {
public exportAPI(editor: Core): void {
const fieldsToExport = [ 'configuration' ];
const destroy = (): void => {
editor.moduleInstances.Listeners.removeAll();
editor.moduleInstances.UI.destroy();
editor.moduleInstances.ModificationsObserver.destroy();
Object.values(editor.moduleInstances)
.forEach((moduleInstance) => {
if (_.isFunction(moduleInstance.destroy)) {
moduleInstance.destroy();
}
});
editor = null;
for (const field in this) {

View file

@ -291,6 +291,17 @@ export default class BlockSelection extends Module {
this.Editor.InlineToolbar.close();
}
/**
* Module destruction
* De-registers Shortcut CMD+A
*/
public destroy(): void {
const { Shortcuts } = this.Editor;
/** Selection shortcut */
Shortcuts.remove('CMD+A');
}
/**
* First CMD+A selects all input content by native behaviour,
* next CMD+A keypress selects all blocks

View file

@ -160,6 +160,13 @@ export default class Listeners extends Module {
this.allListeners = [];
}
/**
* Module cleanup on destruction
*/
public destroy(): void {
this.removeAll();
}
/**
* Search method: looks for listener by passed element
*