@ckeditor/ckeditor5-core 30.0.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/LICENSE.md +17 -0
- package/README.md +18 -0
- package/lang/contexts.json +8 -0
- package/lang/translations/af.po +41 -0
- package/lang/translations/ar.po +41 -0
- package/lang/translations/ast.po +41 -0
- package/lang/translations/az.po +41 -0
- package/lang/translations/bg.po +41 -0
- package/lang/translations/ca.po +41 -0
- package/lang/translations/cs.po +41 -0
- package/lang/translations/da.po +41 -0
- package/lang/translations/de-ch.po +41 -0
- package/lang/translations/de.po +41 -0
- package/lang/translations/el.po +41 -0
- package/lang/translations/en-au.po +41 -0
- package/lang/translations/en-gb.po +41 -0
- package/lang/translations/en.po +41 -0
- package/lang/translations/eo.po +41 -0
- package/lang/translations/es.po +41 -0
- package/lang/translations/et.po +41 -0
- package/lang/translations/eu.po +41 -0
- package/lang/translations/fa.po +41 -0
- package/lang/translations/fi.po +41 -0
- package/lang/translations/fr.po +41 -0
- package/lang/translations/gl.po +41 -0
- package/lang/translations/he.po +41 -0
- package/lang/translations/hi.po +41 -0
- package/lang/translations/hr.po +41 -0
- package/lang/translations/hu.po +41 -0
- package/lang/translations/id.po +41 -0
- package/lang/translations/it.po +41 -0
- package/lang/translations/ja.po +41 -0
- package/lang/translations/km.po +41 -0
- package/lang/translations/kn.po +41 -0
- package/lang/translations/ko.po +41 -0
- package/lang/translations/ku.po +41 -0
- package/lang/translations/lt.po +41 -0
- package/lang/translations/lv.po +41 -0
- package/lang/translations/nb.po +41 -0
- package/lang/translations/ne.po +41 -0
- package/lang/translations/nl.po +41 -0
- package/lang/translations/no.po +41 -0
- package/lang/translations/oc.po +41 -0
- package/lang/translations/pl.po +41 -0
- package/lang/translations/pt-br.po +41 -0
- package/lang/translations/pt.po +41 -0
- package/lang/translations/ro.po +41 -0
- package/lang/translations/ru.po +41 -0
- package/lang/translations/sk.po +41 -0
- package/lang/translations/sl.po +41 -0
- package/lang/translations/sq.po +41 -0
- package/lang/translations/sr-latn.po +41 -0
- package/lang/translations/sr.po +41 -0
- package/lang/translations/sv.po +41 -0
- package/lang/translations/th.po +41 -0
- package/lang/translations/tk.po +41 -0
- package/lang/translations/tr.po +41 -0
- package/lang/translations/tt.po +41 -0
- package/lang/translations/ug.po +41 -0
- package/lang/translations/uk.po +41 -0
- package/lang/translations/vi.po +41 -0
- package/lang/translations/zh-cn.po +41 -0
- package/lang/translations/zh.po +41 -0
- package/package.json +65 -0
- package/src/command.js +244 -0
- package/src/commandcollection.js +109 -0
- package/src/context.js +355 -0
- package/src/contextplugin.js +61 -0
- package/src/editingkeystrokehandler.js +72 -0
- package/src/editor/editor.js +448 -0
- package/src/editor/editorconfig.jsdoc +325 -0
- package/src/editor/editorui.js +275 -0
- package/src/editor/editorwithui.jsdoc +29 -0
- package/src/editor/utils/attachtoform.js +67 -0
- package/src/editor/utils/dataapimixin.js +81 -0
- package/src/editor/utils/elementapimixin.js +65 -0
- package/src/editor/utils/securesourceelement.js +49 -0
- package/src/index.js +95 -0
- package/src/multicommand.js +101 -0
- package/src/pendingactions.js +155 -0
- package/src/plugin.js +292 -0
- package/src/plugincollection.js +597 -0
- package/theme/icons/align-bottom.svg +1 -0
- package/theme/icons/align-center.svg +1 -0
- package/theme/icons/align-justify.svg +1 -0
- package/theme/icons/align-left.svg +1 -0
- package/theme/icons/align-middle.svg +1 -0
- package/theme/icons/align-right.svg +1 -0
- package/theme/icons/align-top.svg +1 -0
- package/theme/icons/cancel.svg +1 -0
- package/theme/icons/caption.svg +1 -0
- package/theme/icons/check.svg +1 -0
- package/theme/icons/cog.svg +1 -0
- package/theme/icons/eraser.svg +1 -0
- package/theme/icons/image.svg +1 -0
- package/theme/icons/low-vision.svg +1 -0
- package/theme/icons/object-center.svg +1 -0
- package/theme/icons/object-full-width.svg +1 -0
- package/theme/icons/object-inline-left.svg +1 -0
- package/theme/icons/object-inline-right.svg +1 -0
- package/theme/icons/object-inline.svg +1 -0
- package/theme/icons/object-left.svg +1 -0
- package/theme/icons/object-right.svg +1 -0
- package/theme/icons/object-size-full.svg +1 -0
- package/theme/icons/object-size-large.svg +1 -0
- package/theme/icons/object-size-medium.svg +1 -0
- package/theme/icons/object-size-small.svg +1 -0
- package/theme/icons/pencil.svg +1 -0
- package/theme/icons/pilcrow.svg +1 -0
- package/theme/icons/quote.svg +1 -0
- package/theme/icons/three-vertical-dots.svg +1 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @module core/editor/editor
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import Context from '../context';
|
|
11
|
+
import Config from '@ckeditor/ckeditor5-utils/src/config';
|
|
12
|
+
import EditingController from '@ckeditor/ckeditor5-engine/src/controller/editingcontroller';
|
|
13
|
+
import PluginCollection from '../plugincollection';
|
|
14
|
+
import CommandCollection from '../commandcollection';
|
|
15
|
+
import DataController from '@ckeditor/ckeditor5-engine/src/controller/datacontroller';
|
|
16
|
+
import Conversion from '@ckeditor/ckeditor5-engine/src/conversion/conversion';
|
|
17
|
+
import Model from '@ckeditor/ckeditor5-engine/src/model/model';
|
|
18
|
+
import EditingKeystrokeHandler from '../editingkeystrokehandler';
|
|
19
|
+
|
|
20
|
+
import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
21
|
+
import mix from '@ckeditor/ckeditor5-utils/src/mix';
|
|
22
|
+
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
23
|
+
import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The class representing a basic, generic editor.
|
|
27
|
+
*
|
|
28
|
+
* Check out the list of its subclasses to learn about specific editor implementations.
|
|
29
|
+
*
|
|
30
|
+
* All editor implementations (like {@link module:editor-classic/classiceditor~ClassicEditor} or
|
|
31
|
+
* {@link module:editor-inline/inlineeditor~InlineEditor}) should extend this class. They can add their
|
|
32
|
+
* own methods and properties.
|
|
33
|
+
*
|
|
34
|
+
* When you are implementing a plugin, this editor represents the API
|
|
35
|
+
* which your plugin can expect to get when using its {@link module:core/plugin~Plugin#editor} property.
|
|
36
|
+
*
|
|
37
|
+
* This API should be sufficient in order to implement the "editing" part of your feature
|
|
38
|
+
* (schema definition, conversion, commands, keystrokes, etc.).
|
|
39
|
+
* It does not define the editor UI, which is available only if
|
|
40
|
+
* the specific editor implements also the {@link module:core/editor/editorwithui~EditorWithUI} interface
|
|
41
|
+
* (as most editor implementations do).
|
|
42
|
+
*
|
|
43
|
+
* @abstract
|
|
44
|
+
* @mixes module:utils/observablemixin~ObservableMixin
|
|
45
|
+
*/
|
|
46
|
+
export default class Editor {
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new instance of the editor class.
|
|
49
|
+
*
|
|
50
|
+
* Usually, not to be used directly. See the static {@link module:core/editor/editor~Editor.create `create()`} method.
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} [config={}] The editor configuration.
|
|
53
|
+
*/
|
|
54
|
+
constructor( config = {} ) {
|
|
55
|
+
/**
|
|
56
|
+
* The editor context.
|
|
57
|
+
* When it is not provided through the configuration, the editor creates it.
|
|
58
|
+
*
|
|
59
|
+
* @protected
|
|
60
|
+
* @type {module:core/context~Context}
|
|
61
|
+
*/
|
|
62
|
+
this._context = config.context || new Context( { language: config.language } );
|
|
63
|
+
this._context._addEditor( this, !config.context );
|
|
64
|
+
|
|
65
|
+
// Clone the plugins to make sure that the plugin array will not be shared
|
|
66
|
+
// between editors and make the watchdog feature work correctly.
|
|
67
|
+
const availablePlugins = Array.from( this.constructor.builtinPlugins || [] );
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Stores all configurations specific to this editor instance.
|
|
71
|
+
*
|
|
72
|
+
* editor.config.get( 'image.toolbar' );
|
|
73
|
+
* // -> [ 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
|
|
74
|
+
*
|
|
75
|
+
* @readonly
|
|
76
|
+
* @member {module:utils/config~Config}
|
|
77
|
+
*/
|
|
78
|
+
this.config = new Config( config, this.constructor.defaultConfig );
|
|
79
|
+
this.config.define( 'plugins', availablePlugins );
|
|
80
|
+
this.config.define( this._context._getEditorConfig() );
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The plugins loaded and in use by this editor instance.
|
|
84
|
+
*
|
|
85
|
+
* editor.plugins.get( 'ClipboardPipeline' ); // -> An instance of the clipboard pipeline plugin.
|
|
86
|
+
*
|
|
87
|
+
* @readonly
|
|
88
|
+
* @member {module:core/plugincollection~PluginCollection}
|
|
89
|
+
*/
|
|
90
|
+
this.plugins = new PluginCollection( this, availablePlugins, this._context.plugins );
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The locale instance.
|
|
94
|
+
*
|
|
95
|
+
* @readonly
|
|
96
|
+
* @type {module:utils/locale~Locale}
|
|
97
|
+
*/
|
|
98
|
+
this.locale = this._context.locale;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Shorthand for {@link module:utils/locale~Locale#t}.
|
|
102
|
+
*
|
|
103
|
+
* @see module:utils/locale~Locale#t
|
|
104
|
+
* @method #t
|
|
105
|
+
*/
|
|
106
|
+
this.t = this.locale.t;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Commands registered to the editor.
|
|
110
|
+
*
|
|
111
|
+
* Use the shorthand {@link #execute `editor.execute()`} method to execute commands:
|
|
112
|
+
*
|
|
113
|
+
* // Execute the bold command:
|
|
114
|
+
* editor.execute( 'bold' );
|
|
115
|
+
*
|
|
116
|
+
* // Check the state of the bold command:
|
|
117
|
+
* editor.commands.get( 'bold' ).value;
|
|
118
|
+
*
|
|
119
|
+
* @readonly
|
|
120
|
+
* @member {module:core/commandcollection~CommandCollection}
|
|
121
|
+
*/
|
|
122
|
+
this.commands = new CommandCollection();
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Indicates the editor life-cycle state.
|
|
126
|
+
*
|
|
127
|
+
* The editor is in one of the following states:
|
|
128
|
+
*
|
|
129
|
+
* * `initializing` – During the editor initialization (before
|
|
130
|
+
* {@link module:core/editor/editor~Editor.create `Editor.create()`}) finished its job.
|
|
131
|
+
* * `ready` – After the promise returned by the {@link module:core/editor/editor~Editor.create `Editor.create()`}
|
|
132
|
+
* method is resolved.
|
|
133
|
+
* * `destroyed` – Once the {@link #destroy `editor.destroy()`} method was called.
|
|
134
|
+
*
|
|
135
|
+
* @observable
|
|
136
|
+
* @member {'initializing'|'ready'|'destroyed'} #state
|
|
137
|
+
*/
|
|
138
|
+
this.set( 'state', 'initializing' );
|
|
139
|
+
this.once( 'ready', () => ( this.state = 'ready' ), { priority: 'high' } );
|
|
140
|
+
this.once( 'destroy', () => ( this.state = 'destroyed' ), { priority: 'high' } );
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Defines whether this editor is in read-only mode.
|
|
144
|
+
*
|
|
145
|
+
* In read-only mode the editor {@link #commands commands} are disabled so it is not possible
|
|
146
|
+
* to modify the document by using them. Also, the editable element(s) become non-editable.
|
|
147
|
+
*
|
|
148
|
+
* In order to make the editor read-only, you can set this value directly:
|
|
149
|
+
*
|
|
150
|
+
* editor.isReadOnly = true;
|
|
151
|
+
*
|
|
152
|
+
* @observable
|
|
153
|
+
* @member {Boolean} #isReadOnly
|
|
154
|
+
*/
|
|
155
|
+
this.set( 'isReadOnly', false );
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The editor's model.
|
|
159
|
+
*
|
|
160
|
+
* The central point of the editor's abstract data model.
|
|
161
|
+
*
|
|
162
|
+
* @readonly
|
|
163
|
+
* @member {module:engine/model/model~Model}
|
|
164
|
+
*/
|
|
165
|
+
this.model = new Model();
|
|
166
|
+
|
|
167
|
+
const stylesProcessor = new StylesProcessor();
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The {@link module:engine/controller/datacontroller~DataController data controller}.
|
|
171
|
+
* Used e.g. for setting and retrieving the editor data.
|
|
172
|
+
*
|
|
173
|
+
* @readonly
|
|
174
|
+
* @member {module:engine/controller/datacontroller~DataController}
|
|
175
|
+
*/
|
|
176
|
+
this.data = new DataController( this.model, stylesProcessor );
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The {@link module:engine/controller/editingcontroller~EditingController editing controller}.
|
|
180
|
+
* Controls user input and rendering the content for editing.
|
|
181
|
+
*
|
|
182
|
+
* @readonly
|
|
183
|
+
* @member {module:engine/controller/editingcontroller~EditingController}
|
|
184
|
+
*/
|
|
185
|
+
this.editing = new EditingController( this.model, stylesProcessor );
|
|
186
|
+
this.editing.view.document.bind( 'isReadOnly' ).to( this );
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Conversion manager through which you can register model-to-view and view-to-model converters.
|
|
190
|
+
*
|
|
191
|
+
* See the {@link module:engine/conversion/conversion~Conversion} documentation to learn how to add converters.
|
|
192
|
+
*
|
|
193
|
+
* @readonly
|
|
194
|
+
* @member {module:engine/conversion/conversion~Conversion}
|
|
195
|
+
*/
|
|
196
|
+
this.conversion = new Conversion( [ this.editing.downcastDispatcher, this.data.downcastDispatcher ], this.data.upcastDispatcher );
|
|
197
|
+
this.conversion.addAlias( 'dataDowncast', this.data.downcastDispatcher );
|
|
198
|
+
this.conversion.addAlias( 'editingDowncast', this.editing.downcastDispatcher );
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* An instance of the {@link module:core/editingkeystrokehandler~EditingKeystrokeHandler}.
|
|
202
|
+
*
|
|
203
|
+
* It allows setting simple keystrokes:
|
|
204
|
+
*
|
|
205
|
+
* // Execute the bold command on Ctrl+E:
|
|
206
|
+
* editor.keystrokes.set( 'Ctrl+E', 'bold' );
|
|
207
|
+
*
|
|
208
|
+
* // Execute your own callback:
|
|
209
|
+
* editor.keystrokes.set( 'Ctrl+E', ( data, cancel ) => {
|
|
210
|
+
* console.log( data.keyCode );
|
|
211
|
+
*
|
|
212
|
+
* // Prevent the default (native) action and stop the underlying keydown event
|
|
213
|
+
* // so no other editor feature will interfere.
|
|
214
|
+
* cancel();
|
|
215
|
+
* } );
|
|
216
|
+
*
|
|
217
|
+
* Note: Certain typing-oriented keystrokes (like <kbd>Backspace</kbd> or <kbd>Enter</kbd>) are handled
|
|
218
|
+
* by a low-level mechanism and trying to listen to them via the keystroke handler will not work reliably.
|
|
219
|
+
* To handle these specific keystrokes, see the events fired by the
|
|
220
|
+
* {@link module:engine/view/document~Document editing view document} (`editor.editing.view.document`).
|
|
221
|
+
*
|
|
222
|
+
* @readonly
|
|
223
|
+
* @member {module:core/editingkeystrokehandler~EditingKeystrokeHandler}
|
|
224
|
+
*/
|
|
225
|
+
this.keystrokes = new EditingKeystrokeHandler( this );
|
|
226
|
+
this.keystrokes.listenTo( this.editing.view.document );
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Loads and initializes plugins specified in the configuration.
|
|
231
|
+
*
|
|
232
|
+
* @returns {Promise.<module:core/plugin~LoadedPlugins>} A promise which resolves
|
|
233
|
+
* once the initialization is completed, providing an array of loaded plugins.
|
|
234
|
+
*/
|
|
235
|
+
initPlugins() {
|
|
236
|
+
const config = this.config;
|
|
237
|
+
const plugins = config.get( 'plugins' );
|
|
238
|
+
const removePlugins = config.get( 'removePlugins' ) || [];
|
|
239
|
+
const extraPlugins = config.get( 'extraPlugins' ) || [];
|
|
240
|
+
const substitutePlugins = config.get( 'substitutePlugins' ) || [];
|
|
241
|
+
|
|
242
|
+
return this.plugins.init( plugins.concat( extraPlugins ), removePlugins, substitutePlugins );
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Destroys the editor instance, releasing all resources used by it.
|
|
247
|
+
*
|
|
248
|
+
* **Note** The editor cannot be destroyed during the initialization phase so if it is called
|
|
249
|
+
* while the editor {@link #state is being initialized}, it will wait for the editor initialization before destroying it.
|
|
250
|
+
*
|
|
251
|
+
* @fires destroy
|
|
252
|
+
* @returns {Promise} A promise that resolves once the editor instance is fully destroyed.
|
|
253
|
+
*/
|
|
254
|
+
destroy() {
|
|
255
|
+
let readyPromise = Promise.resolve();
|
|
256
|
+
|
|
257
|
+
if ( this.state == 'initializing' ) {
|
|
258
|
+
readyPromise = new Promise( resolve => this.once( 'ready', resolve ) );
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return readyPromise
|
|
262
|
+
.then( () => {
|
|
263
|
+
this.fire( 'destroy' );
|
|
264
|
+
this.stopListening();
|
|
265
|
+
this.commands.destroy();
|
|
266
|
+
} )
|
|
267
|
+
.then( () => this.plugins.destroy() )
|
|
268
|
+
.then( () => {
|
|
269
|
+
this.model.destroy();
|
|
270
|
+
this.data.destroy();
|
|
271
|
+
this.editing.destroy();
|
|
272
|
+
this.keystrokes.destroy();
|
|
273
|
+
} )
|
|
274
|
+
// Remove the editor from the context.
|
|
275
|
+
// When the context was created by this editor, the context will be destroyed.
|
|
276
|
+
.then( () => this._context._removeEditor( this ) );
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Executes the specified command with given parameters.
|
|
281
|
+
*
|
|
282
|
+
* Shorthand for:
|
|
283
|
+
*
|
|
284
|
+
* editor.commands.get( commandName ).execute( ... );
|
|
285
|
+
*
|
|
286
|
+
* @param {String} commandName The name of the command to execute.
|
|
287
|
+
* @param {*} [...commandParams] Command parameters.
|
|
288
|
+
* @returns {*} The value returned by the {@link module:core/commandcollection~CommandCollection#execute `commands.execute()`}.
|
|
289
|
+
*/
|
|
290
|
+
execute( ...args ) {
|
|
291
|
+
try {
|
|
292
|
+
return this.commands.execute( ...args );
|
|
293
|
+
} catch ( err ) {
|
|
294
|
+
// @if CK_DEBUG // throw err;
|
|
295
|
+
/* istanbul ignore next */
|
|
296
|
+
CKEditorError.rethrowUnexpectedError( err, this );
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Focuses the editor.
|
|
302
|
+
*
|
|
303
|
+
* **Note** To explicitly focus the editing area of the editor, use the
|
|
304
|
+
* {@link module:engine/view/view~View#focus `editor.editing.view.focus()`} method of the editing view.
|
|
305
|
+
*
|
|
306
|
+
* Check out the {@glink framework/guides/deep-dive/ui/focus-tracking#focus-in-the-editor-ui Focus in the editor UI} section
|
|
307
|
+
* of the {@glink framework/guides/deep-dive/ui/focus-tracking Deep dive into focus tracking} guide to learn more.
|
|
308
|
+
*/
|
|
309
|
+
focus() {
|
|
310
|
+
this.editing.view.focus();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Creates and initializes a new editor instance.
|
|
315
|
+
*
|
|
316
|
+
* This is an abstract method. Every editor type needs to implement its own initialization logic.
|
|
317
|
+
*
|
|
318
|
+
* See the `create()` methods of the existing editor types to learn how to use them:
|
|
319
|
+
*
|
|
320
|
+
* * {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}
|
|
321
|
+
* * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}
|
|
322
|
+
* * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}
|
|
323
|
+
* * {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}
|
|
324
|
+
*
|
|
325
|
+
* @abstract
|
|
326
|
+
* @method module:core/editor/editor~Editor.create
|
|
327
|
+
*/
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
mix( Editor, ObservableMixin );
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Fired when the {@link module:engine/controller/datacontroller~DataController#event:ready data} and all additional
|
|
334
|
+
* editor components are ready.
|
|
335
|
+
*
|
|
336
|
+
* Note: This event is most useful for plugin developers. When integrating the editor with your website or
|
|
337
|
+
* application, you do not have to listen to `editor#ready` because when the promise returned by the static
|
|
338
|
+
* {@link module:core/editor/editor~Editor.create `Editor.create()`} event is resolved, the editor is already ready.
|
|
339
|
+
* In fact, since the first moment when the editor instance is available to you is inside `then()`'s callback,
|
|
340
|
+
* you cannot even add a listener to the `editor#ready` event.
|
|
341
|
+
*
|
|
342
|
+
* See also the {@link #state `editor.state`} property.
|
|
343
|
+
*
|
|
344
|
+
* @event ready
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Fired when this editor instance is destroyed. The editor at this point is not usable and this event should be used to
|
|
349
|
+
* perform the clean-up in any plugin.
|
|
350
|
+
*
|
|
351
|
+
*
|
|
352
|
+
* See also the {@link #state `editor.state`} property.
|
|
353
|
+
*
|
|
354
|
+
* @event destroy
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* This error is thrown when trying to pass a `<textarea>` element to a `create()` function of an editor class.
|
|
359
|
+
*
|
|
360
|
+
* The only editor type which can be initialized on `<textarea>` elements is {@glink builds/guides/overview#classic-editor classic editor}.
|
|
361
|
+
* This editor hides the passed element and inserts its own UI next to it. Other types of editors reuse the passed element as their root
|
|
362
|
+
* editable element and therefore `<textarea>` is not appropriate for them. Use a `<div>` or another text container instead:
|
|
363
|
+
*
|
|
364
|
+
* <div id="editor">
|
|
365
|
+
* <p>Initial content.</p>
|
|
366
|
+
* </div>
|
|
367
|
+
*
|
|
368
|
+
* @error editor-wrong-element
|
|
369
|
+
*/
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* An array of plugins built into this editor class.
|
|
373
|
+
*
|
|
374
|
+
* It is used in CKEditor 5 builds to provide a list of plugins which are later automatically initialized
|
|
375
|
+
* during the editor initialization.
|
|
376
|
+
*
|
|
377
|
+
* They will be automatically initialized by the editor, unless listed in `config.removePlugins` and
|
|
378
|
+
* unless `config.plugins` is passed.
|
|
379
|
+
*
|
|
380
|
+
* // Build some plugins into the editor class first.
|
|
381
|
+
* ClassicEditor.builtinPlugins = [ FooPlugin, BarPlugin ];
|
|
382
|
+
*
|
|
383
|
+
* // Normally, you need to define config.plugins, but since ClassicEditor.builtinPlugins was
|
|
384
|
+
* // defined, now you can call create() without any configuration.
|
|
385
|
+
* ClassicEditor
|
|
386
|
+
* .create( sourceElement )
|
|
387
|
+
* .then( editor => {
|
|
388
|
+
* editor.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
|
|
389
|
+
* editor.plugins.get( BarPlugin ); // -> An instance of the Bar plugin.
|
|
390
|
+
* } );
|
|
391
|
+
*
|
|
392
|
+
* ClassicEditor
|
|
393
|
+
* .create( sourceElement, {
|
|
394
|
+
* // Do not initialize these plugins (note: it is defined by a string):
|
|
395
|
+
* removePlugins: [ 'Foo' ]
|
|
396
|
+
* } )
|
|
397
|
+
* .then( editor => {
|
|
398
|
+
* editor.plugins.get( FooPlugin ); // -> Undefined.
|
|
399
|
+
* editor.config.get( BarPlugin ); // -> An instance of the Bar plugin.
|
|
400
|
+
* } );
|
|
401
|
+
*
|
|
402
|
+
* ClassicEditor
|
|
403
|
+
* .create( sourceElement, {
|
|
404
|
+
* // Load only this plugin. It can also be defined by a string if
|
|
405
|
+
* // this plugin was built into the editor class.
|
|
406
|
+
* plugins: [ FooPlugin ]
|
|
407
|
+
* } )
|
|
408
|
+
* .then( editor => {
|
|
409
|
+
* editor.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
|
|
410
|
+
* editor.config.get( BarPlugin ); // -> Undefined.
|
|
411
|
+
* } );
|
|
412
|
+
*
|
|
413
|
+
* See also {@link module:core/editor/editor~Editor.defaultConfig}.
|
|
414
|
+
*
|
|
415
|
+
* @static
|
|
416
|
+
* @member {Array.<Function>} module:core/editor/editor~Editor.builtinPlugins
|
|
417
|
+
*/
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* The default configuration which is built into the editor class.
|
|
421
|
+
*
|
|
422
|
+
* It is used in CKEditor 5 builds to provide the default configuration options which are later used during the editor initialization.
|
|
423
|
+
*
|
|
424
|
+
* ClassicEditor.defaultConfig = {
|
|
425
|
+
* foo: 1,
|
|
426
|
+
* bar: 2
|
|
427
|
+
* };
|
|
428
|
+
*
|
|
429
|
+
* ClassicEditor
|
|
430
|
+
* .create( sourceElement )
|
|
431
|
+
* .then( editor => {
|
|
432
|
+
* editor.config.get( 'foo' ); // -> 1
|
|
433
|
+
* editor.config.get( 'bar' ); // -> 2
|
|
434
|
+
* } );
|
|
435
|
+
*
|
|
436
|
+
* // The default options can be overridden by the configuration passed to create().
|
|
437
|
+
* ClassicEditor
|
|
438
|
+
* .create( sourceElement, { bar: 3 } )
|
|
439
|
+
* .then( editor => {
|
|
440
|
+
* editor.config.get( 'foo' ); // -> 1
|
|
441
|
+
* editor.config.get( 'bar' ); // -> 3
|
|
442
|
+
* } );
|
|
443
|
+
*
|
|
444
|
+
* See also {@link module:core/editor/editor~Editor.builtinPlugins}.
|
|
445
|
+
*
|
|
446
|
+
* @static
|
|
447
|
+
* @member {Object} module:core/editor/editor~Editor.defaultConfig
|
|
448
|
+
*/
|