@ckeditor/ckeditor5-core 35.2.1 → 35.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +27 -19
- package/src/command.js +209 -238
- package/src/commandcollection.js +84 -96
- package/src/context.js +219 -314
- package/src/contextplugin.js +29 -36
- package/src/editingkeystrokehandler.js +42 -49
- package/src/editor/editor.js +360 -440
- package/src/editor/editorconfig.js +5 -0
- package/src/editor/editorui.js +436 -544
- package/src/editor/utils/attachtoform.js +39 -49
- package/src/editor/utils/dataapimixin.js +17 -68
- package/src/editor/utils/elementapimixin.js +32 -67
- package/src/editor/utils/securesourceelement.js +22 -32
- package/src/index.js +34 -51
- package/src/multicommand.js +59 -73
- package/src/pendingactions.js +77 -103
- package/src/plugin.js +119 -276
- package/src/plugincollection.js +470 -584
- package/src/editor/editorconfig.jsdoc +0 -426
- package/src/editor/editorwithui.jsdoc +0 -29
package/src/context.js
CHANGED
|
@@ -2,17 +2,14 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module core/context
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import Config from '@ckeditor/ckeditor5-utils/src/config';
|
|
11
9
|
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
|
|
12
10
|
import PluginCollection from './plugincollection';
|
|
13
11
|
import Locale from '@ckeditor/ckeditor5-utils/src/locale';
|
|
14
12
|
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
15
|
-
|
|
16
13
|
/**
|
|
17
14
|
* Provides a common, higher-level environment for solutions that use multiple {@link module:core/editor/editor~Editor editors}
|
|
18
15
|
* or plugins that work outside the editor. Use it instead of {@link module:core/editor/editor~Editor.create `Editor.create()`}
|
|
@@ -41,315 +38,223 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
41
38
|
* See {@link module:core/context~Context.create `Context.create()`} for usage examples.
|
|
42
39
|
*/
|
|
43
40
|
export default class Context {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
* const promises = [];
|
|
264
|
-
*
|
|
265
|
-
* promises.push( ClassicEditor.create(
|
|
266
|
-
* document.getElementById( 'editor1' ),
|
|
267
|
-
* {
|
|
268
|
-
* editorPlugins,
|
|
269
|
-
* context
|
|
270
|
-
* }
|
|
271
|
-
* ) );
|
|
272
|
-
*
|
|
273
|
-
* promises.push( ClassicEditor.create(
|
|
274
|
-
* document.getElementById( 'editor2' ),
|
|
275
|
-
* {
|
|
276
|
-
* editorPlugins,
|
|
277
|
-
* context,
|
|
278
|
-
* toolbar: { ... } // You can overwrite the configuration of the context.
|
|
279
|
-
* }
|
|
280
|
-
* ) );
|
|
281
|
-
*
|
|
282
|
-
* return Promise.all( promises );
|
|
283
|
-
* } );
|
|
284
|
-
*
|
|
285
|
-
* @param {Object} [config] The context configuration.
|
|
286
|
-
* @returns {Promise} A promise resolved once the context is ready. The promise resolves with the created context instance.
|
|
287
|
-
*/
|
|
288
|
-
static create( config ) {
|
|
289
|
-
return new Promise( resolve => {
|
|
290
|
-
const context = new this( config );
|
|
291
|
-
|
|
292
|
-
resolve( context.initPlugins().then( () => context ) );
|
|
293
|
-
} );
|
|
294
|
-
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a context instance with a given configuration.
|
|
43
|
+
*
|
|
44
|
+
* Usually not to be used directly. See the static {@link module:core/context~Context.create `create()`} method.
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} [config={}] The context configuration.
|
|
47
|
+
*/
|
|
48
|
+
constructor(config) {
|
|
49
|
+
/**
|
|
50
|
+
* Stores all the configurations specific to this context instance.
|
|
51
|
+
*
|
|
52
|
+
* @readonly
|
|
53
|
+
* @type {module:utils/config~Config}
|
|
54
|
+
*/
|
|
55
|
+
this.config = new Config(config, this.constructor.defaultConfig);
|
|
56
|
+
const availablePlugins = this.constructor.builtinPlugins;
|
|
57
|
+
this.config.define('plugins', availablePlugins);
|
|
58
|
+
/**
|
|
59
|
+
* The plugins loaded and in use by this context instance.
|
|
60
|
+
*
|
|
61
|
+
* @readonly
|
|
62
|
+
* @type {module:core/plugincollection~PluginCollection}
|
|
63
|
+
*/
|
|
64
|
+
this.plugins = new PluginCollection(this, availablePlugins);
|
|
65
|
+
const languageConfig = this.config.get('language') || {};
|
|
66
|
+
/**
|
|
67
|
+
* @readonly
|
|
68
|
+
* @type {module:utils/locale~Locale}
|
|
69
|
+
*/
|
|
70
|
+
this.locale = new Locale({
|
|
71
|
+
uiLanguage: typeof languageConfig === 'string' ? languageConfig : languageConfig.ui,
|
|
72
|
+
contentLanguage: this.config.get('language.content')
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* Shorthand for {@link module:utils/locale~Locale#t}.
|
|
76
|
+
*
|
|
77
|
+
* @see module:utils/locale~Locale#t
|
|
78
|
+
* @method #t
|
|
79
|
+
*/
|
|
80
|
+
this.t = this.locale.t;
|
|
81
|
+
/**
|
|
82
|
+
* A list of editors that this context instance is injected to.
|
|
83
|
+
*
|
|
84
|
+
* @readonly
|
|
85
|
+
* @type {module:utils/collection~Collection}
|
|
86
|
+
*/
|
|
87
|
+
this.editors = new Collection();
|
|
88
|
+
/**
|
|
89
|
+
* Reference to the editor which created the context.
|
|
90
|
+
* Null when the context was created outside of the editor.
|
|
91
|
+
*
|
|
92
|
+
* It is used to destroy the context when removing the editor that has created the context.
|
|
93
|
+
*
|
|
94
|
+
* @private
|
|
95
|
+
* @type {module:core/editor/editor~Editor|null}
|
|
96
|
+
*/
|
|
97
|
+
this._contextOwner = null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Loads and initializes plugins specified in the configuration.
|
|
101
|
+
*
|
|
102
|
+
* @returns {Promise.<module:core/plugin~LoadedPlugins>} A promise which resolves
|
|
103
|
+
* once the initialization is completed, providing an array of loaded plugins.
|
|
104
|
+
*/
|
|
105
|
+
initPlugins() {
|
|
106
|
+
const plugins = this.config.get('plugins') || [];
|
|
107
|
+
const substitutePlugins = this.config.get('substitutePlugins') || [];
|
|
108
|
+
// Plugins for substitution should be checked as well.
|
|
109
|
+
for (const Plugin of plugins.concat(substitutePlugins)) {
|
|
110
|
+
if (typeof Plugin != 'function') {
|
|
111
|
+
/**
|
|
112
|
+
* Only a constructor function is allowed as a {@link module:core/contextplugin~ContextPlugin context plugin}.
|
|
113
|
+
*
|
|
114
|
+
* @error context-initplugins-constructor-only
|
|
115
|
+
*/
|
|
116
|
+
throw new CKEditorError('context-initplugins-constructor-only', null, { Plugin });
|
|
117
|
+
}
|
|
118
|
+
if (Plugin.isContextPlugin !== true) {
|
|
119
|
+
/**
|
|
120
|
+
* Only a plugin marked as a {@link module:core/contextplugin~ContextPlugin.isContextPlugin context plugin}
|
|
121
|
+
* is allowed to be used with a context.
|
|
122
|
+
*
|
|
123
|
+
* @error context-initplugins-invalid-plugin
|
|
124
|
+
*/
|
|
125
|
+
throw new CKEditorError('context-initplugins-invalid-plugin', null, { Plugin });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return this.plugins.init(plugins, [], substitutePlugins);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Destroys the context instance and all editors used with the context,
|
|
132
|
+
* releasing all resources used by the context.
|
|
133
|
+
*
|
|
134
|
+
* @returns {Promise} A promise that resolves once the context instance is fully destroyed.
|
|
135
|
+
*/
|
|
136
|
+
destroy() {
|
|
137
|
+
return Promise.all(Array.from(this.editors, editor => editor.destroy()))
|
|
138
|
+
.then(() => this.plugins.destroy());
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Adds a reference to the editor which is used with this context.
|
|
142
|
+
*
|
|
143
|
+
* When the given editor has created the context, the reference to this editor will be stored
|
|
144
|
+
* as a {@link ~Context#_contextOwner}.
|
|
145
|
+
*
|
|
146
|
+
* This method should only be used by the editor.
|
|
147
|
+
*
|
|
148
|
+
* @protected
|
|
149
|
+
* @param {module:core/editor/editor~Editor} editor
|
|
150
|
+
* @param {Boolean} isContextOwner Stores the given editor as a context owner.
|
|
151
|
+
*/
|
|
152
|
+
_addEditor(editor, isContextOwner) {
|
|
153
|
+
if (this._contextOwner) {
|
|
154
|
+
/**
|
|
155
|
+
* Cannot add multiple editors to the context which is created by the editor.
|
|
156
|
+
*
|
|
157
|
+
* @error context-addeditor-private-context
|
|
158
|
+
*/
|
|
159
|
+
throw new CKEditorError('context-addeditor-private-context');
|
|
160
|
+
}
|
|
161
|
+
this.editors.add(editor);
|
|
162
|
+
if (isContextOwner) {
|
|
163
|
+
this._contextOwner = editor;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Removes a reference to the editor which was used with this context.
|
|
168
|
+
* When the context was created by the given editor, the context will be destroyed.
|
|
169
|
+
*
|
|
170
|
+
* This method should only be used by the editor.
|
|
171
|
+
*
|
|
172
|
+
* @protected
|
|
173
|
+
* @param {module:core/editor/editor~Editor} editor
|
|
174
|
+
* @return {Promise} A promise that resolves once the editor is removed from the context or when the context was destroyed.
|
|
175
|
+
*/
|
|
176
|
+
_removeEditor(editor) {
|
|
177
|
+
if (this.editors.has(editor)) {
|
|
178
|
+
this.editors.remove(editor);
|
|
179
|
+
}
|
|
180
|
+
if (this._contextOwner === editor) {
|
|
181
|
+
return this.destroy();
|
|
182
|
+
}
|
|
183
|
+
return Promise.resolve();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Returns the context configuration which will be copied to the editors created using this context.
|
|
187
|
+
*
|
|
188
|
+
* The configuration returned by this method has the plugins configuration removed — plugins are shared with all editors
|
|
189
|
+
* through another mechanism.
|
|
190
|
+
*
|
|
191
|
+
* This method should only be used by the editor.
|
|
192
|
+
*
|
|
193
|
+
* @protected
|
|
194
|
+
* @returns {Object} Configuration as a plain object.
|
|
195
|
+
*/
|
|
196
|
+
_getEditorConfig() {
|
|
197
|
+
const result = {};
|
|
198
|
+
for (const name of this.config.names()) {
|
|
199
|
+
if (!['plugins', 'removePlugins', 'extraPlugins'].includes(name)) {
|
|
200
|
+
result[name] = this.config.get(name);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Creates and initializes a new context instance.
|
|
207
|
+
*
|
|
208
|
+
* const commonConfig = { ... }; // Configuration for all the plugins and editors.
|
|
209
|
+
* const editorPlugins = [ ... ]; // Regular plugins here.
|
|
210
|
+
*
|
|
211
|
+
* Context
|
|
212
|
+
* .create( {
|
|
213
|
+
* // Only context plugins here.
|
|
214
|
+
* plugins: [ ... ],
|
|
215
|
+
*
|
|
216
|
+
* // Configure the language for all the editors (it cannot be overwritten).
|
|
217
|
+
* language: { ... },
|
|
218
|
+
*
|
|
219
|
+
* // Configuration for context plugins.
|
|
220
|
+
* comments: { ... },
|
|
221
|
+
* ...
|
|
222
|
+
*
|
|
223
|
+
* // Default configuration for editor plugins.
|
|
224
|
+
* toolbar: { ... },
|
|
225
|
+
* image: { ... },
|
|
226
|
+
* ...
|
|
227
|
+
* } )
|
|
228
|
+
* .then( context => {
|
|
229
|
+
* const promises = [];
|
|
230
|
+
*
|
|
231
|
+
* promises.push( ClassicEditor.create(
|
|
232
|
+
* document.getElementById( 'editor1' ),
|
|
233
|
+
* {
|
|
234
|
+
* editorPlugins,
|
|
235
|
+
* context
|
|
236
|
+
* }
|
|
237
|
+
* ) );
|
|
238
|
+
*
|
|
239
|
+
* promises.push( ClassicEditor.create(
|
|
240
|
+
* document.getElementById( 'editor2' ),
|
|
241
|
+
* {
|
|
242
|
+
* editorPlugins,
|
|
243
|
+
* context,
|
|
244
|
+
* toolbar: { ... } // You can overwrite the configuration of the context.
|
|
245
|
+
* }
|
|
246
|
+
* ) );
|
|
247
|
+
*
|
|
248
|
+
* return Promise.all( promises );
|
|
249
|
+
* } );
|
|
250
|
+
*
|
|
251
|
+
* @param {Object} [config] The context configuration.
|
|
252
|
+
* @returns {Promise} A promise resolved once the context is ready. The promise resolves with the created context instance.
|
|
253
|
+
*/
|
|
254
|
+
static create(config) {
|
|
255
|
+
return new Promise(resolve => {
|
|
256
|
+
const context = new this(config);
|
|
257
|
+
resolve(context.initPlugins().then(() => context));
|
|
258
|
+
});
|
|
259
|
+
}
|
|
295
260
|
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* An array of plugins built into the `Context` class.
|
|
299
|
-
*
|
|
300
|
-
* It is used in CKEditor 5 builds featuring `Context` to provide a list of context plugins which are later automatically initialized
|
|
301
|
-
* during the context initialization.
|
|
302
|
-
*
|
|
303
|
-
* They will be automatically initialized by `Context` unless `config.plugins` is passed.
|
|
304
|
-
*
|
|
305
|
-
* // Build some context plugins into the Context class first.
|
|
306
|
-
* Context.builtinPlugins = [ FooPlugin, BarPlugin ];
|
|
307
|
-
*
|
|
308
|
-
* // Normally, you need to define config.plugins, but since Context.builtinPlugins was
|
|
309
|
-
* // defined, now you can call create() without any configuration.
|
|
310
|
-
* Context
|
|
311
|
-
* .create()
|
|
312
|
-
* .then( context => {
|
|
313
|
-
* context.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
|
|
314
|
-
* context.plugins.get( BarPlugin ); // -> An instance of the Bar plugin.
|
|
315
|
-
* } );
|
|
316
|
-
*
|
|
317
|
-
* See also {@link module:core/context~Context.defaultConfig `Context.defaultConfig`}
|
|
318
|
-
* and {@link module:core/editor/editor~Editor.builtinPlugins `Editor.builtinPlugins`}.
|
|
319
|
-
*
|
|
320
|
-
* @static
|
|
321
|
-
* @member {Array.<Function>} module:core/context~Context.builtinPlugins
|
|
322
|
-
*/
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* The default configuration which is built into the `Context` class.
|
|
326
|
-
*
|
|
327
|
-
* It is used in CKEditor 5 builds featuring `Context` to provide the default configuration options which are later used during the
|
|
328
|
-
* context initialization.
|
|
329
|
-
*
|
|
330
|
-
* Context.defaultConfig = {
|
|
331
|
-
* foo: 1,
|
|
332
|
-
* bar: 2
|
|
333
|
-
* };
|
|
334
|
-
*
|
|
335
|
-
* Context
|
|
336
|
-
* .create()
|
|
337
|
-
* .then( context => {
|
|
338
|
-
* context.config.get( 'foo' ); // -> 1
|
|
339
|
-
* context.config.get( 'bar' ); // -> 2
|
|
340
|
-
* } );
|
|
341
|
-
*
|
|
342
|
-
* // The default options can be overridden by the configuration passed to create().
|
|
343
|
-
* Context
|
|
344
|
-
* .create( { bar: 3 } )
|
|
345
|
-
* .then( context => {
|
|
346
|
-
* context.config.get( 'foo' ); // -> 1
|
|
347
|
-
* context.config.get( 'bar' ); // -> 3
|
|
348
|
-
* } );
|
|
349
|
-
*
|
|
350
|
-
* See also {@link module:core/context~Context.builtinPlugins `Context.builtinPlugins`}
|
|
351
|
-
* and {@link module:core/editor/editor~Editor.defaultConfig `Editor.defaultConfig`}.
|
|
352
|
-
*
|
|
353
|
-
* @static
|
|
354
|
-
* @member {Object} module:core/context~Context.defaultConfig
|
|
355
|
-
*/
|
package/src/contextplugin.js
CHANGED
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module core/contextplugin
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
11
|
-
import mix from '@ckeditor/ckeditor5-utils/src/mix';
|
|
12
|
-
|
|
8
|
+
import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
13
9
|
/**
|
|
14
10
|
* The base class for {@link module:core/context~Context} plugin classes.
|
|
15
11
|
*
|
|
@@ -27,35 +23,32 @@ import mix from '@ckeditor/ckeditor5-utils/src/mix';
|
|
|
27
23
|
* @implements module:core/plugin~PluginInterface
|
|
28
24
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
29
25
|
*/
|
|
30
|
-
export default class ContextPlugin {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
26
|
+
export default class ContextPlugin extends Observable {
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new plugin instance.
|
|
29
|
+
*
|
|
30
|
+
* @param {module:core/context~Context|module:core/editor/editor~Editor} context
|
|
31
|
+
*/
|
|
32
|
+
constructor(context) {
|
|
33
|
+
super();
|
|
34
|
+
/**
|
|
35
|
+
* The context instance.
|
|
36
|
+
*
|
|
37
|
+
* @readonly
|
|
38
|
+
* @type {module:core/context~Context|module:core/editor/editor~Editor}
|
|
39
|
+
*/
|
|
40
|
+
this.context = context;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
45
|
+
destroy() {
|
|
46
|
+
this.stopListening();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @inheritDoc
|
|
50
|
+
*/
|
|
51
|
+
static get isContextPlugin() {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
59
54
|
}
|
|
60
|
-
|
|
61
|
-
mix( ContextPlugin, ObservableMixin );
|