mirror of
https://github.com/codex-team/editor.js
synced 2024-06-10 18:03:25 +02:00
fix(blocks): plugin's destroy() method will be called on blocks removing (#1719)
* Plugin's destroy() method on blocks removing * Add changelog Co-authored-by: Georgy Berezhnoy <gohabereg@gmail.com> Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com>
This commit is contained in:
parent
6f36707f67
commit
9190824b1d
|
@ -6,6 +6,7 @@
|
|||
- `Improvement` *Tunes API* - Tunes now can provide sanitize configuration
|
||||
- `Fix` *Tunes API* - Tune config now passed to constructor under `config` property
|
||||
- `Fix` *Types* - Add common type for internal and external Tools configuration
|
||||
- `Fix` — Block's destroy method is called on block deletion
|
||||
|
||||
### 2.22.1
|
||||
|
||||
|
|
|
@ -439,6 +439,7 @@ export default class BlockManager extends Module {
|
|||
|
||||
const blockToRemove = this._blocks[index];
|
||||
|
||||
blockToRemove.destroy();
|
||||
this._blocks.remove(index);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { isEmpty } from '../utils';
|
||||
|
||||
/**
|
||||
* @class EventDispatcher
|
||||
*
|
||||
|
@ -68,7 +70,7 @@ export default class EventsDispatcher<Events extends string = string> {
|
|||
* @param {object} data - subscribers get this data when they were fired
|
||||
*/
|
||||
public emit(eventName: Events, data?: object): void {
|
||||
if (!this.subscribers[eventName]) {
|
||||
if (isEmpty(this.subscribers) || !this.subscribers[eventName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue