UNPKG

2.44 kBTypeScriptView Raw
1/**
2 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4 */
5/**
6 * @module core/contextplugin
7 */
8import { type Collection, type Config, type Locale, type LocaleTranslate } from '@ckeditor/ckeditor5-utils';
9import type Editor from './editor/editor.js';
10import type { EditorConfig } from './editor/editorconfig.js';
11import type Context from './context.js';
12import type { PluginDependencies, PluginInterface } from './plugin.js';
13import type PluginCollection from './plugincollection.js';
14declare const ContextPlugin_base: {
15 new (): import("@ckeditor/ckeditor5-utils").Observable;
16 prototype: import("@ckeditor/ckeditor5-utils").Observable;
17};
18/**
19 * The base class for {@link module:core/context~Context} plugin classes.
20 *
21 * A context plugin can either be initialized for an {@link module:core/editor/editor~Editor editor} or for
22 * a {@link module:core/context~Context context}. In other words, it can either
23 * work within one editor instance or with one or more editor instances that use a single context.
24 * It is the context plugin's role to implement handling for both modes.
25 *
26 * There are a few rules for interaction between the editor plugins and context plugins:
27 *
28 * * A context plugin can require another context plugin.
29 * * An {@link module:core/plugin~Plugin editor plugin} can require a context plugin.
30 * * A context plugin MUST NOT require an {@link module:core/plugin~Plugin editor plugin}.
31 */
32export default class ContextPlugin extends ContextPlugin_base implements PluginInterface {
33 /**
34 * The context or editor instance.
35 */
36 readonly context: ContextInterface;
37 /**
38 * Creates a new plugin instance.
39 */
40 constructor(context: Context | Editor);
41 /**
42 * @inheritDoc
43 */
44 destroy(): void;
45 /**
46 * @inheritDoc
47 */
48 static get isContextPlugin(): true;
49}
50/**
51 * The common interface of {@link module:core/context~Context} and {@link module:core/editor/editor~Editor}.
52 */
53export interface ContextInterface {
54 config: Config<Omit<EditorConfig, 'plugins' | 'substitutePlugins' | 'removePlugins' | 'extraPlugins'>>;
55 plugins: PluginCollection<Context | Editor>;
56 locale: Locale;
57 t: LocaleTranslate;
58 editors?: Collection<Editor>;
59}
60export type ContextPluginDependencies = PluginDependencies<Context | Editor>;
61export {};