1 | import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
2 | import Context from './context';
|
3 | import Editor from './editor/editor';
|
4 |
|
5 | // tslint:disable-next-line:no-empty-interface
|
6 | export default interface ContextPlugin extends Observable {}
|
7 |
|
8 | /**
|
9 | * The base class for {@link module:core/context~Context} plugin classes.
|
10 | *
|
11 | * A context plugin can either be initialized for an {@link module:core/editor/editor~Editor editor} or for
|
12 | * a {@link module:core/context~Context context}. In other words, it can either
|
13 | * work within one editor instance or with one or more editor instances that use a single context.
|
14 | * It is the context plugin's role to implement handling for both modes.
|
15 | *
|
16 | * There are a few rules for interaction between the editor plugins and context plugins:
|
17 | *
|
18 | * * A context plugin can require another context plugin.
|
19 | * * An {@link module:core/plugin~Plugin editor plugin} can require a context plugin.
|
20 | * * A context plugin MUST NOT require an {@link module:core/plugin~Plugin editor plugin}.
|
21 | */
|
22 | export default abstract class ContextPlugin implements Observable {
|
23 | /**
|
24 | * Creates a new plugin instance.
|
25 | */
|
26 | constructor(context: Context | Editor);
|
27 | /**
|
28 | * The context instance.
|
29 | */
|
30 | readonly context: Context | Editor;
|
31 | init?(): Promise<void> | void;
|
32 | afterInit?(): Promise<void> | void;
|
33 | destroy(): Promise<void> | void;
|
34 |
|
35 | static readonly isContextPlugin: true;
|
36 | static readonly pluginName?: string | undefined;
|
37 | static readonly requires?: Array<typeof ContextPlugin> | undefined;
|
38 | }
|
39 |
|
40 | export interface ContextPluginInterface<T = ContextPlugin> {
|
41 | new (context: Context): T;
|
42 | init?(): Promise<void> | void;
|
43 | afterInit?(): Promise<void> | void;
|
44 | destroy?(): Promise<void> | void;
|
45 | }
|