jodit
Version:
Jodit is awesome and usefully wysiwyg editor with filebrowser
37 lines (28 loc) • 1.08 kB
text/typescript
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Licensed under GNU General Public License version 2 or later or a commercial license or MIT;
* For GPL see LICENSE-GPL.txt in the project root for license information.
* For MIT see LICENSE-MIT.txt in the project root for license information.
* For commercial licenses see https://xdsoft.net/jodit/commercial/
* Copyright (c) 2013-2019 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { IJodit, IPlugin } from '../types';
import { Component } from './Component';
export abstract class Plugin extends Component<IJodit> implements IPlugin {
public abstract afterInit(jodit: IJodit): void;
public abstract beforeDestruct(jodit: IJodit): void;
constructor(jodit: IJodit) {
super(jodit);
jodit.events
.on('afterInit', this.afterInit.bind(this, jodit))
.on('beforeDestruct', this.destruct);
}
destruct = () => {
if (!this.isDestructed) {
this.jodit.events &&
this.jodit.events.off('beforeDestruct', this.destruct);
this.beforeDestruct(this.jodit);
super.destruct();
}
};
}