Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/issue1133 selection shortcut removed on editor destroy #1140

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Removed shortcut CMD+A on editor destroy #1133
  • Loading branch information
sisir-hellosivi committed May 1, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
aitbw Angel Perez
commit f7801396728b61366fb4f8797aa6b61ab102ec47
2 changes: 1 addition & 1 deletion dist/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/editor.js.LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Editor.js
*
* @version 2.18.0
* @version 2.18.1
*
* @licence Apache-2.0
* @author CodeX <https://codex.so>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.18.0",
"version": "2.18.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.18 is not released yet, so you can include patch to 2.18 instead of bumping patch version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok

"description": "Editor.js — Native JS, based on API and Open Source",
"main": "dist/editor.js",
"types": "./types/index.d.ts",
12 changes: 9 additions & 3 deletions src/codex.ts
Original file line number Diff line number Diff line change
@@ -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,14 @@ 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();
for(const moduleName in editor.moduleInstances) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not?

Object.values(editor).forEach(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No specific reason. Object.values looks cleaner. Will change.

if (Object.prototype.hasOwnProperty.call(editor.moduleInstances, moduleName)) {
const moduleInstance = editor.moduleInstances[moduleName];
if(moduleInstance.destroy && _.isFunction(moduleInstance.destroy)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its better to add check for undefined inside the isFunction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove the 'moduleInstance.destroy' check from the if condition. Is a separate check in isFunction required? I can leave the isFunction code as it is and the typeof check should take care even if I pass undefined?

moduleInstance.destroy();
}
}
}
editor = null;

for (const field in this) {
11 changes: 11 additions & 0 deletions src/components/modules/blockSelection.ts
Original file line number Diff line number Diff line change
@@ -384,4 +384,15 @@ export default class BlockSelection extends Module {
/** close InlineToolbar if we selected all Blocks */
this.Editor.InlineToolbar.close();
}

/**
* Module destruction
* De-registers Shortcut CMD+A
*/
public destroy(): void {
const { Shortcuts } = this.Editor;

/** Selection shortcut */
Shortcuts.remove('CMD+A');
}
}
7 changes: 7 additions & 0 deletions src/components/modules/listeners.ts
Original file line number Diff line number Diff line change
@@ -204,4 +204,11 @@ export default class Listeners extends Module {
}
});
}

/**
* Module cleanup on destruction
*/
public destroy(): void {
this.removeAll();
}
}