2021-12-11 22:18:48 +05:30
|
|
|
import { EDITOR_EXTENSION_DEFINITION_ERROR } from './constants';
|
|
|
|
|
|
|
|
export default class EditorExtension {
|
|
|
|
constructor({ definition, setupOptions } = {}) {
|
|
|
|
if (typeof definition !== 'function') {
|
|
|
|
throw new Error(EDITOR_EXTENSION_DEFINITION_ERROR);
|
|
|
|
}
|
|
|
|
this.setupOptions = setupOptions;
|
|
|
|
// eslint-disable-next-line new-cap
|
|
|
|
this.obj = new definition();
|
2022-01-26 12:08:38 +05:30
|
|
|
this.extensionName = definition.extensionName || this.obj.extensionName; // both class- and fn-based extensions have a name
|
2021-12-11 22:18:48 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
get api() {
|
|
|
|
return this.obj.provides?.();
|
|
|
|
}
|
|
|
|
}
|