@ckeditor/ckeditor5-core 48.2.0-alpha.7 → 48.3.0-alpha.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.
Files changed (174) hide show
  1. package/dist/accessibility.d.ts +339 -339
  2. package/dist/augmentation.d.ts +8 -8
  3. package/dist/command.d.ts +188 -191
  4. package/dist/commandcollection.d.ts +76 -76
  5. package/dist/context.d.ts +238 -238
  6. package/dist/contextplugin.d.ts +57 -60
  7. package/dist/editingkeystrokehandler.d.ts +49 -49
  8. package/dist/editor/editor.d.ts +538 -576
  9. package/dist/editor/editorconfig.d.ts +1674 -1634
  10. package/dist/editor/utils/attachtoform.d.ts +12 -12
  11. package/dist/editor/utils/editorusagedata.d.ts +51 -51
  12. package/dist/editor/utils/elementapimixin.d.ts +39 -29
  13. package/dist/editor/utils/normalizerootsconfig.d.ts +65 -65
  14. package/dist/editor/utils/registerandinitializerootconfigattributes.d.ts +16 -12
  15. package/dist/editor/utils/rootacceptsblocks.d.ts +13 -13
  16. package/dist/editor/utils/securesourceelement.d.ts +13 -13
  17. package/dist/editor/utils/verifyrootelements.d.ts +8 -8
  18. package/dist/index.css.map +1 -1
  19. package/dist/index.d.ts +27 -27
  20. package/dist/index.js +3416 -3459
  21. package/dist/index.js.map +1 -1
  22. package/dist/legacyerrors.d.ts +0 -4
  23. package/dist/multicommand.d.ts +61 -61
  24. package/dist/pendingactions.d.ts +111 -111
  25. package/dist/plugin.d.ts +291 -283
  26. package/dist/plugincollection.d.ts +109 -108
  27. package/dist/translations/af.js +1 -1
  28. package/dist/translations/af.umd.js +1 -1
  29. package/dist/translations/ar.js +1 -1
  30. package/dist/translations/ar.umd.js +1 -1
  31. package/dist/translations/ast.js +1 -1
  32. package/dist/translations/ast.umd.js +1 -1
  33. package/dist/translations/az.js +1 -1
  34. package/dist/translations/az.umd.js +1 -1
  35. package/dist/translations/be.js +1 -1
  36. package/dist/translations/be.umd.js +1 -1
  37. package/dist/translations/bg.js +1 -1
  38. package/dist/translations/bg.umd.js +1 -1
  39. package/dist/translations/bn.js +1 -1
  40. package/dist/translations/bn.umd.js +1 -1
  41. package/dist/translations/bs.js +1 -1
  42. package/dist/translations/bs.umd.js +1 -1
  43. package/dist/translations/ca.js +1 -1
  44. package/dist/translations/ca.umd.js +1 -1
  45. package/dist/translations/cs.js +1 -1
  46. package/dist/translations/cs.umd.js +1 -1
  47. package/dist/translations/da.js +1 -1
  48. package/dist/translations/da.umd.js +1 -1
  49. package/dist/translations/de-ch.js +1 -1
  50. package/dist/translations/de-ch.umd.js +1 -1
  51. package/dist/translations/de.js +1 -1
  52. package/dist/translations/de.umd.js +1 -1
  53. package/dist/translations/el.js +1 -1
  54. package/dist/translations/el.umd.js +1 -1
  55. package/dist/translations/en-au.js +1 -1
  56. package/dist/translations/en-au.umd.js +1 -1
  57. package/dist/translations/en-gb.js +1 -1
  58. package/dist/translations/en-gb.umd.js +1 -1
  59. package/dist/translations/en.js +1 -1
  60. package/dist/translations/en.umd.js +1 -1
  61. package/dist/translations/eo.js +1 -1
  62. package/dist/translations/eo.umd.js +1 -1
  63. package/dist/translations/es-co.js +1 -1
  64. package/dist/translations/es-co.umd.js +1 -1
  65. package/dist/translations/es.js +1 -1
  66. package/dist/translations/es.umd.js +1 -1
  67. package/dist/translations/et.js +1 -1
  68. package/dist/translations/et.umd.js +1 -1
  69. package/dist/translations/eu.js +1 -1
  70. package/dist/translations/eu.umd.js +1 -1
  71. package/dist/translations/fa.js +1 -1
  72. package/dist/translations/fa.umd.js +1 -1
  73. package/dist/translations/fi.js +1 -1
  74. package/dist/translations/fi.umd.js +1 -1
  75. package/dist/translations/fr.js +1 -1
  76. package/dist/translations/fr.umd.js +1 -1
  77. package/dist/translations/gl.js +1 -1
  78. package/dist/translations/gl.umd.js +1 -1
  79. package/dist/translations/gu.js +1 -1
  80. package/dist/translations/gu.umd.js +1 -1
  81. package/dist/translations/he.js +1 -1
  82. package/dist/translations/he.umd.js +1 -1
  83. package/dist/translations/hi.js +1 -1
  84. package/dist/translations/hi.umd.js +1 -1
  85. package/dist/translations/hr.js +1 -1
  86. package/dist/translations/hr.umd.js +1 -1
  87. package/dist/translations/hu.js +1 -1
  88. package/dist/translations/hu.umd.js +1 -1
  89. package/dist/translations/hy.js +1 -1
  90. package/dist/translations/hy.umd.js +1 -1
  91. package/dist/translations/id.js +1 -1
  92. package/dist/translations/id.umd.js +1 -1
  93. package/dist/translations/it.js +1 -1
  94. package/dist/translations/it.umd.js +1 -1
  95. package/dist/translations/ja.js +1 -1
  96. package/dist/translations/ja.umd.js +1 -1
  97. package/dist/translations/jv.js +1 -1
  98. package/dist/translations/jv.umd.js +1 -1
  99. package/dist/translations/kk.js +1 -1
  100. package/dist/translations/kk.umd.js +1 -1
  101. package/dist/translations/km.js +1 -1
  102. package/dist/translations/km.umd.js +1 -1
  103. package/dist/translations/kn.js +1 -1
  104. package/dist/translations/kn.umd.js +1 -1
  105. package/dist/translations/ko.js +1 -1
  106. package/dist/translations/ko.umd.js +1 -1
  107. package/dist/translations/ku.js +1 -1
  108. package/dist/translations/ku.umd.js +1 -1
  109. package/dist/translations/lt.js +1 -1
  110. package/dist/translations/lt.umd.js +1 -1
  111. package/dist/translations/lv.js +1 -1
  112. package/dist/translations/lv.umd.js +1 -1
  113. package/dist/translations/ms.js +1 -1
  114. package/dist/translations/ms.umd.js +1 -1
  115. package/dist/translations/nb.js +1 -1
  116. package/dist/translations/nb.umd.js +1 -1
  117. package/dist/translations/ne.js +1 -1
  118. package/dist/translations/ne.umd.js +1 -1
  119. package/dist/translations/nl.js +1 -1
  120. package/dist/translations/nl.umd.js +1 -1
  121. package/dist/translations/no.js +1 -1
  122. package/dist/translations/no.umd.js +1 -1
  123. package/dist/translations/oc.js +1 -1
  124. package/dist/translations/oc.umd.js +1 -1
  125. package/dist/translations/pl.js +1 -1
  126. package/dist/translations/pl.umd.js +1 -1
  127. package/dist/translations/pt-br.js +1 -1
  128. package/dist/translations/pt-br.umd.js +1 -1
  129. package/dist/translations/pt.js +1 -1
  130. package/dist/translations/pt.umd.js +1 -1
  131. package/dist/translations/ro.js +1 -1
  132. package/dist/translations/ro.umd.js +1 -1
  133. package/dist/translations/ru.js +1 -1
  134. package/dist/translations/ru.umd.js +1 -1
  135. package/dist/translations/si.js +1 -1
  136. package/dist/translations/si.umd.js +1 -1
  137. package/dist/translations/sk.js +1 -1
  138. package/dist/translations/sk.umd.js +1 -1
  139. package/dist/translations/sl.js +1 -1
  140. package/dist/translations/sl.umd.js +1 -1
  141. package/dist/translations/sq.js +1 -1
  142. package/dist/translations/sq.umd.js +1 -1
  143. package/dist/translations/sr-latn.js +1 -1
  144. package/dist/translations/sr-latn.umd.js +1 -1
  145. package/dist/translations/sr.js +1 -1
  146. package/dist/translations/sr.umd.js +1 -1
  147. package/dist/translations/sv.js +1 -1
  148. package/dist/translations/sv.umd.js +1 -1
  149. package/dist/translations/th.js +1 -1
  150. package/dist/translations/th.umd.js +1 -1
  151. package/dist/translations/ti.js +1 -1
  152. package/dist/translations/ti.umd.js +1 -1
  153. package/dist/translations/tk.js +1 -1
  154. package/dist/translations/tk.umd.js +1 -1
  155. package/dist/translations/tr.js +1 -1
  156. package/dist/translations/tr.umd.js +1 -1
  157. package/dist/translations/tt.js +1 -1
  158. package/dist/translations/tt.umd.js +1 -1
  159. package/dist/translations/ug.js +1 -1
  160. package/dist/translations/ug.umd.js +1 -1
  161. package/dist/translations/uk.js +1 -1
  162. package/dist/translations/uk.umd.js +1 -1
  163. package/dist/translations/ur.js +1 -1
  164. package/dist/translations/ur.umd.js +1 -1
  165. package/dist/translations/uz.js +1 -1
  166. package/dist/translations/uz.umd.js +1 -1
  167. package/dist/translations/vi.js +1 -1
  168. package/dist/translations/vi.umd.js +1 -1
  169. package/dist/translations/zh-cn.js +1 -1
  170. package/dist/translations/zh-cn.umd.js +1 -1
  171. package/dist/translations/zh.js +1 -1
  172. package/dist/translations/zh.umd.js +1 -1
  173. package/dist/typings.d.ts +10 -7
  174. package/package.json +5 -5
@@ -1,1660 +1,1700 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module core/editor/editorconfig
7
- */
8
- import type { ArrayOrItem, Translations } from '@ckeditor/ckeditor5-utils';
9
- import { type Context } from '../context.js';
10
- import type { PluginConstructor } from '../plugin.js';
11
- import type { EditorRootAttributes, Editor } from './editor.js';
12
- import type { MenuBarConfig } from '@ckeditor/ckeditor5-ui';
13
- import type { EngineConfig } from '@ckeditor/ckeditor5-engine';
6
+ * @module core/editor/editorconfig
7
+ */
8
+ import type { ArrayOrItem, Translations } from "@ckeditor/ckeditor5-utils";
9
+ import { type Context } from "../context.js";
10
+ import type { PluginConstructor } from "../plugin.js";
11
+ import type { EditorRootAttributes, Editor } from "./editor.js";
12
+ import type { MenuBarConfig } from "@ckeditor/ckeditor5-ui";
13
+ import type { EngineConfig } from "@ckeditor/ckeditor5-engine";
14
14
  /**
15
- * CKEditor configuration options.
16
- *
17
- * An object defining the editor configuration can be passed when initializing the editor:
18
- *
19
- * ```ts
20
- * EditorClass
21
- * .create( {
22
- * toolbar: [ 'bold', 'italic' ],
23
- * image: {
24
- * styles: [
25
- * ...
26
- * ]
27
- * }
28
- * } )
29
- * .then( ... )
30
- * .catch( ... );
31
- * ```
32
- */
15
+ * CKEditor configuration options.
16
+ *
17
+ * An object defining the editor configuration can be passed when initializing the editor:
18
+ *
19
+ * ```ts
20
+ * EditorClass
21
+ * .create( {
22
+ * toolbar: [ 'bold', 'italic' ],
23
+ * image: {
24
+ * styles: [
25
+ * ...
26
+ * ]
27
+ * }
28
+ * } )
29
+ * .then( ... )
30
+ * .catch( ... );
31
+ * ```
32
+ */
33
33
  export interface EditorConfig extends EngineConfig {
34
- /**
35
- * The DOM element that will be the source for the created editor.
36
- *
37
- * **Note:** This option is only available in the {@link module:editor-classic/classiceditor~ClassicEditor}.
38
- * Other editor types expect configuration for the root elements to be passed in the
39
- * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots`} configuration.
40
- *
41
- * If a DOM element is passed, its content will be automatically loaded to the editor upon initialization
42
- * and the {@link module:editor-classic/classiceditorui~ClassicEditorUI#element editor element} will replace the passed element
43
- * in the DOM (the original one will be hidden and the editor will be injected next to it).
44
- *
45
- * If the {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
46
- * option is set to `true`, the editor data will be set back to the original element once the editor is destroyed and when a form,
47
- * in which this element is contained, is submitted (if the original element is a `<textarea>`). This ensures seamless integration
48
- * with native web forms.
49
- *
50
- * If the element is not provided, a detached editor will be created. In this case you need to insert it into the DOM manually.
51
- * It is available under the {@link module:editor-classic/classiceditorui~ClassicEditorUI#element `editor.ui.element`} property.
52
- */
53
- attachTo?: HTMLElement;
54
- context?: Context;
55
- /**
56
- * The list of additional plugins to load along those already available in the
57
- * editor. It extends the {@link #plugins `plugins`} configuration.
58
- *
59
- * ```ts
60
- * function MyPlugin( editor ) {
61
- * // ...
62
- * }
63
- *
64
- * const config = {
65
- * extraPlugins: [ MyPlugin ]
66
- * };
67
- * ```
68
- *
69
- * **Note:** This configuration works only for simple plugins which utilize the
70
- * {@link module:core/plugin~PluginInterface plugin interface} and have no dependencies. To extend a
71
- * build with complex features, try [CKEditr 5 Builder](https://ckeditor.com/ckeditor-5/builder?redirect=docs).
72
- *
73
- * **Note:** Make sure you include the new features in you toolbar configuration. Learn more
74
- * about the {@glink getting-started/setup/toolbar toolbar setup}.
75
- */
76
- extraPlugins?: Array<PluginConstructor<Editor>>;
77
- /**
78
- * The initial editor data to be used instead of the provided element's HTML content.
79
- *
80
- * ```ts
81
- * ClassicEditor
82
- * .create( {
83
- * attachTo: document.querySelector( '#editor' ),
84
- * root: {
85
- * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
86
- * }
87
- * } )
88
- * .then( ... )
89
- * .catch( ... );
90
- * ```
91
- *
92
- * By default, the editor is initialized with the content of the element on which this editor is initialized.
93
- * This configuration option lets you override this behavior and pass different initial data.
94
- * It is especially useful if it is difficult for your integration to put the data inside the HTML element.
95
- *
96
- * If your editor implementation uses multiple roots, you should pass an object with keys corresponding to the editor
97
- * roots names and values equal to the data that should be set in each root:
98
- *
99
- * ```ts
100
- * MultiRootEditor.create( {
101
- * roots: {
102
- * header: {
103
- * element: document.querySelector( '#header' ),
104
- * initialData: '<p>Content for header part.</p>'
105
- * },
106
- * content: {
107
- * element: document.querySelector( '#content' ),
108
- * initialData: '<p>Content for main part.</p>'
109
- * },
110
- * leftSide: {
111
- * element: document.querySelector( '#left-side' ),
112
- * initialData: '<p>Content for left-side box.</p>'
113
- * },
114
- * rightSide: {
115
- * element: document.querySelector( '#right-side' ),
116
- * initialData: '<p>Content for right-side box.</p>'
117
- * }
118
- * }
119
- * } )
120
- * .then( ... )
121
- * .catch( ... );
122
- * ```
123
- *
124
- * See also {@link module:core/editor/editor~Editor.create Editor.create()} documentation for the editor implementation which you use.
125
- *
126
- * **Note:** If `config.initialData` is set together with `config.root.initialData` or `config.roots.<rootName>.initialData`,
127
- * an error will be thrown as those options exclude themselves.
128
- *
129
- * If `config.initialData` is not set when the editor is initialized, the data received in `Editor.create()` call
130
- * will be used to set `config.initialData`. As a result, `initialData` is always set in the editor's config and
131
- * plugins can read and/or modify it during initialization.
132
- *
133
- * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
134
- * {@link module:core/editor/editorconfig~EditorConfig#root `config.root.initialData`} instead.
135
- * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use
136
- * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.initialData`}.**
137
- *
138
- * @deprecated
139
- */
140
- initialData?: string | Record<string, string>;
141
- /**
142
- * The language of the editor UI and its content.
143
- *
144
- * Simple usage (change the language of the UI and the content):
145
- *
146
- * ```ts
147
- * ClassicEditor
148
- * .create( {
149
- * attachTo: document.querySelector( '#editor' ),
150
- * // The UI of the editor as well as its content will be in German.
151
- * language: 'de'
152
- * } )
153
- * .then( editor => {
154
- * console.log( editor );
155
- * } )
156
- * .catch( error => {
157
- * console.error( error );
158
- * } );
159
- * ```
160
- *
161
- * Use different languages for the UI and the content using the {@link module:core/editor/editorconfig~LanguageConfig configuration}
162
- * syntax:
163
- *
164
- * ```ts
165
- * ClassicEditor
166
- * .create( {
167
- * attachTo: document.querySelector( '#editor' ),
168
- * language: {
169
- * // The UI will be in English.
170
- * ui: 'en',
171
- *
172
- * // But the content will be edited in Arabic.
173
- * content: 'ar'
174
- * }
175
- * } )
176
- * .then( editor => {
177
- * console.log( editor );
178
- * } )
179
- * .catch( error => {
180
- * console.error( error );
181
- * } );
182
- * ```
183
- *
184
- * The language of the content has an impact on the editing experience, for instance it affects screen readers
185
- * and spell checkers. It is also particularly useful for typing in certain languages (e.g. right–to–left ones)
186
- * because it changes the default alignment of the text.
187
- *
188
- * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
189
- *
190
- * You need to add the corresponding translation file for the new UI language to work.
191
- * Translation files are available on CDN:
192
- *
193
- * ```html
194
- * <script type="importmap">
195
- * {
196
- * "imports": {
197
- * "ckeditor5": "https://cdn.ckeditor.com/ckeditor5/<VERSION>/ckeditor5.js",
198
- * "ckeditor5/": "https://cdn.ckeditor.com/ckeditor5/<VERSION>/"
199
- * }
200
- * }
201
- * </script>
202
- * <script type="module">
203
- * import { ClassicEditor, Essentials, Paragraph } from 'ckeditor5';
204
- * import { translations } from 'ckeditor5/dist/translations/pl.js';
205
- *
206
- * await ClassicEditor.create( {
207
- * attachTo: document.querySelector( '#editor' ),
208
- * plugins: [
209
- * Essentials,
210
- * Paragraph,
211
- * ],
212
- * toolbar: {
213
- * items: [ 'undo', 'redo' ]
214
- * },
215
- * translations
216
- * } );
217
- * </script>
218
- * ```
219
- *
220
- * You can add translation using NPM as well.
221
- *
222
- * ```html
223
- * import { ClassicEditor, Essentials, Paragraph } from 'ckeditor5';
224
- * import { translations } from 'ckeditor5/dist/translations/pl.js';
225
- *
226
- * import 'ckeditor5/dist/styles.css';
227
- *
228
- * await ClassicEditor.create( {
229
- * attachTo: document.querySelector( '#editor' ),
230
- * plugins: [
231
- * Essentials,
232
- * Paragraph,
233
- * ],
234
- * toolbar: {
235
- * items: [ 'undo', 'redo' ]
236
- * },
237
- * translations
238
- * } );
239
- * ```
240
- *
241
- * Check the {@glink getting-started/setup/ui-language UI language} guide for more information about
242
- * the localization options and translation process.
243
- */
244
- language?: string | LanguageConfig;
245
- /**
246
- * The editor menu bar configuration.
247
- *
248
- * **Note**: The menu bar is not available in all editor types. Currently, only the
249
- * {@link module:editor-classic/classiceditor~ClassicEditor Classic editor} and
250
- * {@link module:editor-decoupled/decouplededitor~DecoupledEditor Decoupled editor}
251
- * support this feature. Setting the `config.menuBar` configuration for other editor types will have no effect.
252
- *
253
- * In Classic editor, the menu bar is hidden by default. Set the `isVisible` configuration flag to `true` in order to show it:
254
- *
255
- * ```ts
256
- * ClassicEditor
257
- * .create( {
258
- * attachTo: document.querySelector( '#editor' ),
259
- * menuBar: {
260
- * isVisible: true
261
- * }
262
- * } )
263
- * .then( ... );
264
- * ```
265
- *
266
- * When using the Decoupled editor, you will need to insert the menu bar in a desired place yourself. For example:
267
- *
268
- * ```ts
269
- * DecoupledEditor
270
- * .create( {
271
- * root: { element: document.querySelector( '#editor' ) },
272
- * toolbar: [ 'undo', 'redo', 'bold', 'italic', 'numberedList', 'bulletedList' ],
273
- * } )
274
- * .then( editor => {
275
- * document.getElementById( '#menuBarContainer' ).appendChild( editor.ui.view.menuBarView.element );
276
- * } );
277
- * ```
278
- *
279
- * **Note**: You do not have to set the `items` property in this configuration in order to use the menu bar.
280
- * By default, a {@link module:ui/menubar/utils#DefaultMenuBarItems default set of items} is used that already includes
281
- * **all core editor features**. For your convenience, there are `config.menuBar.addItems` and
282
- * `config.menuBar.removeItems` options available that will help you adjust the default configuration without setting the
283
- * entire menu bar structure from scratch (see below).
284
- *
285
- * **Removing items from the menu bar**
286
- *
287
- * You can use the `config.menuBar.removeItems` option to remove items from the default menu bar configuration. You can
288
- * remove individual buttons (e.g. "Bold" or "Block quote"), item groups (e.g. the basic styles section that
289
- * includes multiple buttons such as "Bold", "Italic", "Underline", etc.), or whole menus (e.g. the "Insert" menu). Please
290
- * refer to the {@link module:ui/menubar/utils#DefaultMenuBarItems default configuration} to see default buttons/groups/menus
291
- * and their structure.
292
- *
293
- * To remove individual buttons from the menu bar:
294
- *
295
- * ```ts
296
- * ClassicEditor
297
- * .create( {
298
- * attachTo: document.querySelector( '#editor' ),
299
- * menuBar: {
300
- * // Removes "Bold" and "Block quote" buttons from their respective menus.
301
- * removeItems: [ 'menuBar:bold', 'menuBar:blockQuote' ]
302
- * }
303
- * } )
304
- * .then( ... );
305
- * ```
306
- *
307
- * To remove a group of buttons from the menu bar:
308
- *
309
- * ```ts
310
- * ClassicEditor
311
- * .create( {
312
- * attachTo: document.querySelector( '#editor' ),
313
- * menuBar: {
314
- * // Removes the entire basic styles group ("Bold", "Italic", "Underline", etc.) from the "Format" menu.
315
- * removeItems: [ 'basicStyles' ]
316
- * }
317
- * } )
318
- * .then( ... );
319
- * ```
320
- *
321
- * To remove a menu from the menu bar:
322
- *
323
- * ```ts
324
- * ClassicEditor
325
- * .create( {
326
- * attachTo: document.querySelector( '#editor' ),
327
- * menuBar: {
328
- * // Removes the whole top-level "Insert" menu from the menu bar.
329
- * removeItems: [ 'insert' ]
330
- * }
331
- * } )
332
- * .then( ... );
333
- * ```
334
- *
335
- * **Adding items to the menu bar**
336
- *
337
- * Using the `config.menuBar.addItems` option you can add individual buttons, button groups or entire menus to the structure
338
- * of the menu bar. You can add existing components that you removed from their original position, or add your own components.
339
- *
340
- * **Note**: When adding items please make sure that features (editor plugins) that bring specific menu bar items are loaded.
341
- * For instance, the "Bold" button will not show up in the menu bar unless the {@glink features/basic-styles basic styles} feature is
342
- * loaded. {@link module:core/editor/editorconfig~EditorConfig#plugins Learn more} about loading plugins.
343
- *
344
- * Each entry in the `config.menuBar.addItems` is an object with one of the following properties:
345
- *
346
- * * `item` &ndash; A name of the button to be added to a specific button group (e.g. `'menuBar:bold'` or `'myButton'`),
347
- * * `menu` &ndash; A {@link module:ui/menubar/menubarview#MenuBarMenuDefinition definition of a menu} that should be added to
348
- * the menu bar,
349
- * * `group` &ndash; A {@link module:ui/menubar/menubarview#MenuBarMenuGroupDefinition definition of a button group} that should be
350
- * added to a specific menu.
351
- *
352
- * Additionally, each entry must define the `position` property that accepts the following values:
353
- * * `'start'` &ndash; Adds a top-level menu (e.g. "Format", "Insert", etc.) at the beginning of the menu bar,
354
- * * `'start:GROUP_OR_MENU'` &ndash; Adds a button/group at the beginning of the specific group/menu,
355
- * * `'end'` &ndash; Adds a top-level menu (e.g. "Format", "Insert", etc.) at the end of the menu bar,
356
- * * `'end:GROUP_OR_MENU'` &ndash; Adds a button/group at the end of the specific group/menu,
357
- * * `'after:BUTTON_OR_GROUP_OR_MENU'` &ndash; Adds a button/group/menu right after the specific button/group/menu,
358
- * * `'before:BUTTON_OR_GROUP_OR_MENU'` &ndash; Adds a button/group/menu right after the specific button/group/menu.
359
- *
360
- * Please refer to the {@link module:ui/menubar/utils#DefaultMenuBarItems default configuration} to learn about the
361
- * names of buttons and positions they can be added at.
362
- *
363
- * To add a new top-level menu with specific buttons at the end of the menu bar:
364
- *
365
- * ```ts
366
- * ClassicEditor
367
- * .create( {
368
- * attachTo: document.querySelector( '#editor' ),
369
- * menuBar: {
370
- * addItems: [
371
- * {
372
- * menu: {
373
- * menuId: 'my-menu',
374
- * label: 'My menu',
375
- * groups: [
376
- * {
377
- * groupId: 'my-buttons',
378
- * items: [
379
- * 'menuBar:bold',
380
- * 'menuBar:italic',
381
- * 'menuBar:underline'
382
- * ]
383
- * }
384
- * ]
385
- * },
386
- * position: 'end'
387
- * }
388
- * ]
389
- * }
390
- * } )
391
- * .then( ... );
392
- * ```
393
- *
394
- * To add a new group of buttons to the "Format" menu after basic styles buttons ("Bold", "Italic", "Underline", etc.):
395
- *
396
- * ```ts
397
- * ClassicEditor
398
- * .create( {
399
- * attachTo: document.querySelector( '#editor' ),
400
- * menuBar: {
401
- * addItems: [
402
- * {
403
- * group: {
404
- * groupId: 'my-buttons',
405
- * items: [
406
- * 'myButton1',
407
- * 'myButton2',
408
- * ]
409
- * },
410
- * position: 'after:basicStyles'
411
- * }
412
- * ]
413
- * }
414
- * } )
415
- * .then( ... );
416
- * ```
417
- *
418
- * To add a new button to the basic styles group ("Bold", "Italic", "Underline", etc.) in the "Format" menu:
419
- *
420
- * ```ts
421
- * ClassicEditor
422
- * .create( {
423
- * attachTo: document.querySelector( '#editor' ),
424
- * menuBar: {
425
- * addItems: [
426
- * {
427
- * item: 'myButton',
428
- * position: 'end:basicStyles'
429
- * }
430
- * ]
431
- * }
432
- * } )
433
- * .then( ... );
434
- * ```
435
- *
436
- * To add a new sub-menu in the "Format" menu:
437
- *
438
- * ```ts
439
- * ClassicEditor
440
- * .create( {
441
- * attachTo: document.querySelector( '#editor' ),
442
- * menuBar: {
443
- * addItems: [
444
- * {
445
- * menu: {
446
- * menuId: 'my-sub-menu',
447
- * label: 'My sub-menu',
448
- * groups: [
449
- * {
450
- * groupId: 'my-buttons',
451
- * items: [
452
- * 'myButton1',
453
- * 'myButton2',
454
- * ]
455
- * }
456
- * ]
457
- * },
458
- * position: 'after:basicStyles'
459
- * }
460
- * ]
461
- * }
462
- * } )
463
- * .then( ... );
464
- * ```
465
- *
466
- * **Defining menu bar from scratch**
467
- *
468
- * If the `config.menuBar.addItems` and `config.menuBar.removeItems` options are not enough to adjust the
469
- * {@link module:ui/menubar/utils#DefaultMenuBarItems default configuration}, you can set the menu bar structure from scratch.
470
- *
471
- * For instance, to create a minimalistic menu bar configuration with just two main categories (menus), use the following code snippet:
472
- *
473
- * ```ts
474
- * ClassicEditor
475
- * .create( {
476
- * attachTo: document.querySelector( '#editor' ),
477
- * menuBar: {
478
- * items: [
479
- * {
480
- * menuId: 'formatting',
481
- * label: 'Formatting',
482
- * groups: [
483
- * {
484
- * groupId: 'basicStyles',
485
- * items: [
486
- * 'menuBar:bold',
487
- * 'menuBar:italic',
488
- * ]
489
- * },
490
- * {
491
- * groupId: 'misc',
492
- * items: [
493
- * 'menuBar:heading',
494
- * 'menuBar:bulletedList',
495
- * 'menuBar:numberedList'
496
- * ]
497
- * }
498
- * ]
499
- * },
500
- * {
501
- * menuId: 'myButtons',
502
- * label: 'My actions',
503
- * groups: [
504
- * {
505
- * groupId: 'undo',
506
- * items: [
507
- * 'myButton1',
508
- * 'myButton2'
509
- * ]
510
- * }
511
- * ]
512
- * }
513
- * ]
514
- * }
515
- * } )
516
- * .then( ... );
517
- * ```
518
- */
519
- menuBar?: MenuBarConfig;
520
- /**
521
- * Specifies the text displayed in the editor when there is no content (editor is empty). It is intended to
522
- * help users locate the editor in the application (form) and prompt them to input the content. Work similarly
523
- * as to the native DOM
524
- * [`placeholder` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#The_placeholder_attribute)
525
- * used by inputs.
526
- *
527
- * ```ts
528
- * ClassicEditor
529
- * .create( {
530
- * attachTo: document.querySelector( '#editor' ),
531
- * root: {
532
- * placeholder: 'Type some text...'
533
- * }
534
- * } )
535
- * .then( ... )
536
- * .catch( ... );
537
- * ```
538
- *
539
- * If your editor implementation uses multiple roots, you should pass an object with keys corresponding to the editor
540
- * roots names and values equal to the placeholder that should be set in each root:
541
- *
542
- * ```ts
543
- * MultiRootEditor.create( {
544
- * roots: {
545
- * header: {
546
- * element: document.querySelector( '#header' ),
547
- * placeholder: 'Type header...'
548
- * },
549
- * content: {
550
- * element: document.querySelector( '#content' ),
551
- * placeholder: 'Type content...'
552
- * },
553
- * leftSide: {
554
- * element: document.querySelector( '#left-side' ),
555
- * placeholder: 'Type left-side...'
556
- * },
557
- * rightSide: {
558
- * element: document.querySelector( '#right-side' ),
559
- * placeholder: 'Type right-side...'
560
- * }
561
- * }
562
- * } )
563
- * .then( ... )
564
- * .catch( ... );
565
- * ```
566
- *
567
- * The placeholder text is displayed as a pseudo–element of an empty paragraph in the editor content.
568
- * The paragraph has the `.ck-placeholder` CSS class and the `data-placeholder` attribute.
569
- *
570
- * ```html
571
- * <p data-placeholder="Type some text..." class="ck-placeholder">
572
- * ::before
573
- * </p>
574
- * ```
575
- *
576
- * **Note**: Placeholder text can also be set using the `placeholder` attribute if a `<textarea>` is passed to
577
- * the `create()` method, e.g. {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
578
- *
579
- * **Note**: This configuration has precedence over the value of the `placeholder` attribute of a `<textarea>`
580
- * element passed to the `create()` method.
581
- *
582
- * See the {@glink features/editor-placeholder "Editor placeholder"} guide for more information and live examples.
583
- *
584
- * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
585
- * {@link module:core/editor/editorconfig~EditorConfig#root `config.root.placeholder`} instead.
586
- * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use
587
- * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.placeholder`}.**
588
- *
589
- * @deprecated
590
- */
591
- placeholder?: string | Record<string, string>;
592
- /**
593
- * The list of plugins to load.
594
- *
595
- * ```ts
596
- * import {
597
- * // A preset of plugins is a plugin as well.
598
- * Essentials,
599
- * // The bold plugin.
600
- * Bold
601
- * } from 'ckeditor5';
602
- *
603
- * const config = {
604
- * plugins: [ Essentials, Bold ]
605
- * };
606
- * ```
607
- *
608
- * **Note:** To load additional plugins, you should use the {@link #extraPlugins `extraPlugins`} configuration.
609
- * To narrow the list of loaded plugins, use the {@link #removePlugins `removePlugins`} configuration.
610
- */
611
- plugins?: Array<PluginConstructor<Editor> | string>;
612
- /**
613
- * The list of plugins which should not be loaded despite being available in
614
- * the editor.
615
- *
616
- * ```ts
617
- * const config = {
618
- * removePlugins: [ 'Bold', 'Italic' ]
619
- * };
620
- * ```
621
- *
622
- * **Note:** Be careful when removing plugins using `config.removePlugins`.
623
- * If removed plugins were providing toolbar buttons, the default toolbar configuration included in a build
624
- * will become invalid. In such case you need to provide the updated
625
- * {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar configuration}.
626
- */
627
- removePlugins?: Array<PluginConstructor<Editor> | string>;
628
- substitutePlugins?: Array<PluginConstructor<Editor>>;
629
- /**
630
- * The editor toolbar configuration.
631
- *
632
- * Simple format (specifies only toolbar items):
633
- *
634
- * ```ts
635
- * const config = {
636
- * toolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ]
637
- * };
638
- * ```
639
- *
640
- * Extended format:
641
- *
642
- * ```ts
643
- * const config = {
644
- * toolbar: {
645
- * items: [ 'bold', 'italic', '|', 'undo', 'redo', '-', 'numberedList', 'bulletedList' ],
646
- *
647
- * shouldNotGroupWhenFull: true
648
- * }
649
- * };
650
- * ```
651
- *
652
- * Options which can be set using the extended format:
653
- *
654
- * * **`toolbar.items`** &ndash; An array of toolbar item names. The components (buttons, dropdowns, etc.) which can be used
655
- * as toolbar items are defined in `editor.ui.componentFactory` and can be listed using the following snippet:
656
- *
657
- * ```ts
658
- * Array.from( editor.ui.componentFactory.names() );
659
- * ```
660
- *
661
- * You can also use `'|'` to create a separator between groups of items:
662
- *
663
- * ```
664
- * toolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ]
665
- * ```
666
- *
667
- * or `'-'` to make a line break and render items in multiple lines:
668
- *
669
- * ```
670
- * toolbar: [ 'bold', 'italic', '-', 'undo', 'redo' ]
671
- * ```
672
- *
673
- * Line break will work only in the extended format when `shouldNotGroupWhenFull` option is set to `true`.
674
- *
675
- * **Note**: To save space in your toolbar, you can group several items into a dropdown:
676
- *
677
- * ```
678
- * toolbar: [
679
- * {
680
- * label: 'Basic styles',
681
- * icon: 'text',
682
- * items: [ 'bold', 'italic', ... ]
683
- * },
684
- * '|',
685
- * 'undo', 'redo'
686
- * ]
687
- * ```
688
- *
689
- * The code above will create a "Basic styles" dropdown with a "text" icon containing the "bold" and "italic" buttons.
690
- * You can customize the look of the dropdown by setting the `withText`, `icon`, and `tooltip` properties:
691
- *
692
- * * **Displaying a label**
693
- *
694
- * For instance, to hide the icon and to display the label only, you can use the following configuration:
695
- *
696
- * ```ts
697
- * {
698
- * label: 'Basic styles',
699
- * // Show the textual label of the drop-down. Note that the "icon" property is not configured.
700
- * withText: true,
701
- * items: [ 'bold', 'italic', ... ]
702
- * }
703
- * ```
704
- *
705
- * * **Selecting an icon**
706
- *
707
- * You can use one of the common icons provided by the editor (`'bold'`, `'plus'`, `'text'`, `'importExport'`, `'alignLeft'`,
708
- * `'paragraph'`, `'threeVerticalDots'`, `'dragIndicator'`, `'pilcrow'`):
709
- *
710
- * ```ts
711
- * {
712
- * label: '...',
713
- * // A "plus" sign icon works best for content insertion tools.
714
- * icon: 'plus',
715
- * items: [ ... ]
716
- * }
717
- * ```
718
- *
719
- * If no icon is specified, `'threeVerticalDots'` will be used as a default:
720
- *
721
- * ```ts
722
- * // No icon specified, using a default one.
723
- * {
724
- * label: 'Default icon',
725
- * items: [ ... ]
726
- * }
727
- * ```
728
- *
729
- * If `icon: false` is configured, no icon will be displayed at all and the text label will show up instead:
730
- *
731
- * ```ts
732
- * // This drop-down has no icon. The text label will be displayed instead.
733
- * {
734
- * label: 'No icon',
735
- * icon: false,
736
- * items: [ ... ]
737
- * }
738
- * ```
739
- *
740
- * You can also set a custom icon for the drop-down by passing an SVG string:
741
- *
742
- * ```ts
743
- * {
744
- * label: '...',
745
- * // If you want your icon to change the color dynamically (e.g. when the dropdown opens), avoid fill="..."
746
- * // and stroke="..." styling attributes. Use solid shapes and avoid paths with strokes.
747
- * icon: '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">...</svg>',
748
- * items: [ ... ]
749
- * }
750
- * ```
751
- *
752
- * * **Customizing the tooltip**
753
- *
754
- * By default, the tooltip of the button shares its text with the label. You can customize it to better describe your dropdown
755
- * using the `tooltip` property ({@link module:ui/button/buttonview~ButtonView#tooltip learn more}):
756
- *
757
- * ```ts
758
- * {
759
- * label: 'Drop-down label',
760
- * tooltip: 'Custom tooltip of the drop-down',
761
- * icon: '...',
762
- * items: [ ... ]
763
- * }
764
- * ```
765
- *
766
- * * **`toolbar.viewportTopOffset` (deprecated)** &ndash; The offset (in pixels) from the top of the viewport used when positioning a
767
- * sticky toolbar.
768
- * Useful when a page with which the editor is being integrated has some other sticky or fixed elements
769
- * (e.g. the top menu). Thanks to setting the toolbar offset the toolbar will not be positioned underneath or above the page's UI.
770
- *
771
- * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
772
- * `{@link module:core/editor/editorconfig~EditorConfig#ui EditorConfig#ui.viewportOffset}` instead.**
773
- *
774
- * * **`toolbar.shouldNotGroupWhenFull`** &ndash; When set to `true`, the toolbar will stop grouping items
775
- * and let them wrap to the next line if there is not enough space to display them in a single row.
776
- */
777
- toolbar?: ToolbarConfig;
778
- /**
779
- * The editor UI configuration.
780
- *
781
- * ```ts
782
- * ClassicEditor
783
- * .create( {
784
- * attachTo: document.querySelector( '#editor' ),
785
- * ui: { ... }
786
- * } )
787
- * .then( ... )
788
- * .catch( ... );
789
- * ```
790
- *
791
- * Options which can be set using the UI configuration:
792
- *
793
- * * **`ui.viewportOffset`** &ndash; The offset (in pixels) of the viewport from every direction. It is
794
- * used when positioning a sticky toolbar or other absolutely positioned UI elements.
795
- * Useful when a page with which the editor is being integrated has some other sticky or fixed elements
796
- * (e.g. the top menu). Thanks to setting the UI viewport offset, the toolbar and other contextual balloons will not be positioned
797
- * underneath or above the page's UI.
798
- *
799
- * ```ts
800
- * ui: {
801
- * viewportOffset: { top: 10, right: 10, bottom: 10, left: 10 }
802
- * }
803
- * ```
804
- *
805
- * **Note:** If you want to modify the viewport offset in runtime (after the editor was created), you can do that by overriding
806
- * {@link module:ui/editorui/editorui~EditorUI#viewportOffset `editor.ui.viewportOffset`}.
807
- *
808
- * * **`ui.poweredBy`** &ndash; The configuration of the project logo displayed over the editor's editing area in
809
- * open-source integrations. It allows customizing the position of the logo to minimize the risk of collision with the
810
- * editor content and UI.
811
- *
812
- * The following configuration properties are supported:
813
- *
814
- * * **`position`** &ndash; The position of the project's logo (default: `'border'`).
815
- * * When `'inside'`, the logo will be displayed within the boundaries of the editing area.
816
- * * When `'border'`, the logo will be displayed over the bottom border of the editing area.
817
- *
818
- * * **`side`** (`'left'` or `'right'`, default: `'right'`) &ndash; The side of the editing area where the
819
- * logo will be displayed.
820
- *
821
- * **Note**: If {@link module:core/editor/editorconfig~EditorConfig#language `config.language`} is set to an RTL (right-to-left)
822
- * language, the side switches to `'left'` by default.
823
- *
824
- * * **`label`** (default: `'Powered by'`) &ndash; The label displayed next to the project's logo.
825
- *
826
- * **Note**: Set the value to `null` to display the logo without any text.
827
- *
828
- * * **`verticalOffset`** (default: `5`) &ndash; The vertical distance the logo can be moved away from its default position.
829
- *
830
- * **Note**: If `position` is `'border'`, the offset is measured from the (vertical) center of the logo.
831
- *
832
- * * **`horizontalOffset`** (default: `5`) &ndash; The horizontal distance between the side of the editing root and the
833
- * nearest side of the logo.
834
- *
835
- * ```ts
836
- * ui: {
837
- * poweredBy: {
838
- * position: 'border',
839
- * side: 'left',
840
- * verticalOffset: 2,
841
- * horizontalOffset: 30
842
- * }
843
- * }
844
- */
845
- ui?: UiConfig;
846
- /**
847
- * Enables updating the source element after the editor is destroyed.
848
- *
849
- * Enabling this option might have some security implications, as the editor doesn't have control over all data
850
- * in the output.
851
- *
852
- * Be careful, especially while using the
853
- * {@glink features/markdown Markdown}, {@glink features/html/general-html-support General HTML Support}, or
854
- * {@glink features/html/html-embed HTML embed} features.
855
- */
856
- updateSourceElementOnDestroy?: boolean;
857
- /**
858
- * The CKEditor 5 license key. If you want to obtain a license key, please do one of the following:
859
- *
860
- * * Create a free account, and test the premium features with a [14-day free trial](https://portal.ckeditor.com/checkout?plan=free).
861
- * * [Contact us](https://ckeditor.com/contact/) for a commercial license.
862
- * * If you are using the editor under a GPL license or another license from our Open Source Initiative,
863
- * use the 'GPL' license key instead.
864
- */
865
- licenseKey?: string;
866
- /**
867
- * Translations to be used in the editor.
868
- */
869
- translations?: ArrayOrItem<Translations>;
870
- /**
871
- * Label which briefly describes the editing area. Used for the `aria-label` attribute set on the editor editing area,
872
- * helping assistive technologies to tell apart multiple editor instances (editing areas) on the page. If not set,
873
- * a default "Rich Text Editor. Editing area [name of the area]" is used instead.
874
- *
875
- * It can also be used by other features when referring to this editing area (e.g. AI features).
876
- *
877
- * ```ts
878
- * ClassicEditor
879
- * .create( {
880
- * attachTo: document.querySelector( '#editor' ),
881
- * root: {
882
- * label: 'Article main content'
883
- * }
884
- * } )
885
- * .then( ... )
886
- * .catch( ... );
887
- * ```
888
- *
889
- * If your editor implementation uses multiple roots, you should pass an object with keys corresponding to the editor
890
- * roots names and values equal to the label that should be used for each root:
891
- *
892
- * ```ts
893
- * MultiRootEditor.create( {
894
- * roots: {
895
- * header: {
896
- * element: document.querySelector( '#header' ),
897
- * label: 'Article header'
898
- * },
899
- * content: {
900
- * element: document.querySelector( '#content' ),
901
- * label: 'Article main content'
902
- * },
903
- * sideQuote: {
904
- * element: document.querySelector( '#side-quote' ),
905
- * label: 'Side-quote'
906
- * },
907
- * relatedLinks: {
908
- * element: document.querySelector( '#related-links' ),
909
- * label: 'Related links'
910
- * }
911
- * }
912
- * } )
913
- * .then( ... )
914
- * .catch( ... );
915
- * ```
916
- *
917
- * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
918
- * {@link module:core/editor/editorconfig~EditorConfig#root `config.root.label`} instead.
919
- * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use
920
- * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.label`}.**
921
- *
922
- * @deprecated
923
- */
924
- label?: string | Record<string, string>;
925
- /**
926
- * The root configuration for the default `main` root. Use this option to configure the initial data,
927
- * placeholder, label, and source element for a single-root editor.
928
- *
929
- * This is the recommended way to configure a single-root editor:
930
- *
931
- * ```ts
932
- * // Classic editor – uses `attachTo` for the source element.
933
- * ClassicEditor
934
- * .create( {
935
- * attachTo: document.querySelector( '#editor' ),
936
- * root: {
937
- * initialData: '<p>Hello world!</p>',
938
- * placeholder: 'Type some text...'
939
- * }
940
- * } )
941
- * .then( ... )
942
- * .catch( ... );
943
- * ```
944
- *
945
- * ```ts
946
- * // Inline editor – uses `root.element` for the source element.
947
- * InlineEditor
948
- * .create( {
949
- * root: {
950
- * element: document.querySelector( '#editor' ),
951
- * initialData: '<p>Hello world!</p>',
952
- * placeholder: 'Type some text...'
953
- * }
954
- * } )
955
- * .then( ... )
956
- * .catch( ... );
957
- * ```
958
- *
959
- * ```ts
960
- * // Balloon editor – uses `root.element` for the source element.
961
- * BalloonEditor
962
- * .create( {
963
- * root: {
964
- * element: document.querySelector( '#editor' ),
965
- * placeholder: 'Type some text...'
966
- * }
967
- * } )
968
- * .then( ... )
969
- * .catch( ... );
970
- * ```
971
- *
972
- * ```ts
973
- * // Decoupled editor – uses `root.element` for the source element.
974
- * // The toolbar and editable area must be manually added to the DOM.
975
- * DecoupledEditor
976
- * .create( {
977
- * root: {
978
- * element: document.querySelector( '#editor' ),
979
- * initialData: '<p>Hello world!</p>'
980
- * }
981
- * } )
982
- * .then( editor => {
983
- * document.querySelector( '#toolbar' ).appendChild( editor.ui.view.toolbar.element );
984
- * } )
985
- * .catch( ... );
986
- * ```
987
- *
988
- * Internally, this option is an alias for `config.roots.main`. If both `config.root` and `config.roots.main`
989
- * are set, an error will be thrown.
990
- *
991
- * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use the
992
- * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots`} option instead to define
993
- * configuration for each root individually.
994
- */
995
- root?: RootConfig;
996
- /**
997
- * The root configuration options grouped by the root name. This option is used primarily by the
998
- * {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor} to define
999
- * configuration for each root individually.
1000
- *
1001
- * For a typical single-root editor, use the simpler {@link module:core/editor/editorconfig~EditorConfig#root `config.root`}
1002
- * option instead.
1003
- *
1004
- * ```ts
1005
- * // Using existing DOM elements as source for each root.
1006
- * MultiRootEditor.create( {
1007
- * roots: {
1008
- * header: {
1009
- * element: document.querySelector( '#header' ),
1010
- * placeholder: 'Type header...',
1011
- * label: 'Article header'
1012
- * },
1013
- * content: {
1014
- * element: document.querySelector( '#content' ),
1015
- * placeholder: 'Type content...',
1016
- * label: 'Article main content'
1017
- * }
1018
- * }
1019
- * } )
1020
- * .then( editor => {
1021
- * document.querySelector( '#toolbar' ).appendChild( editor.ui.view.toolbar.element );
1022
- * } )
1023
- * .catch( ... );
1024
- * ```
1025
- *
1026
- * ```ts
1027
- * // Creating a detached editor with initial data for each root.
1028
- * MultiRootEditor.create( {
1029
- * roots: {
1030
- * header: {
1031
- * initialData: '<h2>Article title</h2>',
1032
- * placeholder: 'Type header...',
1033
- * label: 'Article header'
1034
- * },
1035
- * content: {
1036
- * initialData: '<p>Article body...</p>',
1037
- * placeholder: 'Type content...',
1038
- * label: 'Article main content'
1039
- * }
1040
- * }
1041
- * } )
1042
- * .then( editor => {
1043
- * document.querySelector( '#toolbar' ).appendChild( editor.ui.view.toolbar.element );
1044
- *
1045
- * for ( const rootName of editor.ui.getEditableElementsNames() ) {
1046
- * document.querySelector( '#editables' ).appendChild( editor.ui.view.getEditable( rootName ).element );
1047
- * }
1048
- * } )
1049
- * .catch( ... );
1050
- * ```
1051
- */
1052
- roots?: Record<string, RootConfig>;
34
+ /**
35
+ * The DOM element that will be the source for the created editor.
36
+ *
37
+ * **Note:** This option is only available in the {@link module:editor-classic/classiceditor~ClassicEditor}.
38
+ * Other editor types expect configuration for the root elements to be passed in the
39
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots`} configuration.
40
+ *
41
+ * If a DOM element is passed, its content will be automatically loaded to the editor upon initialization
42
+ * and the {@link module:editor-classic/classiceditorui~ClassicEditorUI#element editor element} will replace the passed element
43
+ * in the DOM (the original one will be hidden and the editor will be injected next to it).
44
+ *
45
+ * If the {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
46
+ * option is set to `true`, the editor data will be set back to the original element once the editor is destroyed and when a form,
47
+ * in which this element is contained, is submitted (if the original element is a `<textarea>`). This ensures seamless integration
48
+ * with native web forms.
49
+ *
50
+ * If the element is not provided, a detached editor will be created. In this case you need to insert it into the DOM manually.
51
+ * It is available under the {@link module:editor-classic/classiceditorui~ClassicEditorUI#element `editor.ui.element`} property.
52
+ */
53
+ attachTo?: HTMLElement;
54
+ context?: Context;
55
+ /**
56
+ * The list of additional plugins to load along those already available in the
57
+ * editor. It extends the {@link #plugins `plugins`} configuration.
58
+ *
59
+ * ```ts
60
+ * function MyPlugin( editor ) {
61
+ * // ...
62
+ * }
63
+ *
64
+ * const config = {
65
+ * extraPlugins: [ MyPlugin ]
66
+ * };
67
+ * ```
68
+ *
69
+ * **Note:** This configuration works only for simple plugins which utilize the
70
+ * {@link module:core/plugin~PluginInterface plugin interface} and have no dependencies. To extend a
71
+ * build with complex features, try [CKEditr 5 Builder](https://ckeditor.com/ckeditor-5/builder?redirect=docs).
72
+ *
73
+ * **Note:** Make sure you include the new features in you toolbar configuration. Learn more
74
+ * about the {@glink getting-started/setup/toolbar toolbar setup}.
75
+ */
76
+ extraPlugins?: Array<PluginConstructor<Editor>>;
77
+ /**
78
+ * The initial editor data to be used instead of the provided element's HTML content.
79
+ *
80
+ * ```ts
81
+ * ClassicEditor
82
+ * .create( {
83
+ * attachTo: document.querySelector( '#editor' ),
84
+ * root: {
85
+ * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
86
+ * }
87
+ * } )
88
+ * .then( ... )
89
+ * .catch( ... );
90
+ * ```
91
+ *
92
+ * By default, the editor is initialized with the content of the element on which this editor is initialized.
93
+ * This configuration option lets you override this behavior and pass different initial data.
94
+ * It is especially useful if it is difficult for your integration to put the data inside the HTML element.
95
+ *
96
+ * If your editor implementation uses multiple roots, you should pass an object with keys corresponding to the editor
97
+ * roots names and values equal to the data that should be set in each root:
98
+ *
99
+ * ```ts
100
+ * MultiRootEditor.create( {
101
+ * roots: {
102
+ * header: {
103
+ * element: document.querySelector( '#header' ),
104
+ * initialData: '<p>Content for header part.</p>'
105
+ * },
106
+ * content: {
107
+ * element: document.querySelector( '#content' ),
108
+ * initialData: '<p>Content for main part.</p>'
109
+ * },
110
+ * leftSide: {
111
+ * element: document.querySelector( '#left-side' ),
112
+ * initialData: '<p>Content for left-side box.</p>'
113
+ * },
114
+ * rightSide: {
115
+ * element: document.querySelector( '#right-side' ),
116
+ * initialData: '<p>Content for right-side box.</p>'
117
+ * }
118
+ * }
119
+ * } )
120
+ * .then( ... )
121
+ * .catch( ... );
122
+ * ```
123
+ *
124
+ * See also {@link module:core/editor/editor~Editor.create Editor.create()} documentation for the editor implementation which you use.
125
+ *
126
+ * **Note:** If `config.initialData` is set together with `config.root.initialData` or `config.roots.<rootName>.initialData`,
127
+ * an error will be thrown as those options exclude themselves.
128
+ *
129
+ * If `config.initialData` is not set when the editor is initialized, the data received in `Editor.create()` call
130
+ * will be used to set `config.initialData`. As a result, `initialData` is always set in the editor's config and
131
+ * plugins can read and/or modify it during initialization.
132
+ *
133
+ * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
134
+ * {@link module:core/editor/editorconfig~EditorConfig#root `config.root.initialData`} instead.
135
+ * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use
136
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.initialData`}.**
137
+ *
138
+ * @deprecated
139
+ */
140
+ initialData?: string | Record<string, string>;
141
+ /**
142
+ * The language of the editor UI and its content.
143
+ *
144
+ * Simple usage (change the language of the UI and the content):
145
+ *
146
+ * ```ts
147
+ * ClassicEditor
148
+ * .create( {
149
+ * attachTo: document.querySelector( '#editor' ),
150
+ * // The UI of the editor as well as its content will be in German.
151
+ * language: 'de'
152
+ * } )
153
+ * .then( editor => {
154
+ * console.log( editor );
155
+ * } )
156
+ * .catch( error => {
157
+ * console.error( error );
158
+ * } );
159
+ * ```
160
+ *
161
+ * Use different languages for the UI and the content using the {@link module:core/editor/editorconfig~LanguageConfig configuration}
162
+ * syntax:
163
+ *
164
+ * ```ts
165
+ * ClassicEditor
166
+ * .create( {
167
+ * attachTo: document.querySelector( '#editor' ),
168
+ * language: {
169
+ * // The UI will be in English.
170
+ * ui: 'en',
171
+ *
172
+ * // But the content will be edited in Arabic.
173
+ * content: 'ar'
174
+ * }
175
+ * } )
176
+ * .then( editor => {
177
+ * console.log( editor );
178
+ * } )
179
+ * .catch( error => {
180
+ * console.error( error );
181
+ * } );
182
+ * ```
183
+ *
184
+ * The language of the content has an impact on the editing experience, for instance it affects screen readers
185
+ * and spell checkers. It is also particularly useful for typing in certain languages (e.g. right–to–left ones)
186
+ * because it changes the default alignment of the text.
187
+ *
188
+ * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
189
+ *
190
+ * You need to add the corresponding translation file for the new UI language to work.
191
+ * Translation files are available on CDN:
192
+ *
193
+ * ```html
194
+ * <script type="importmap">
195
+ * {
196
+ * "imports": {
197
+ * "ckeditor5": "https://cdn.ckeditor.com/ckeditor5/<VERSION>/ckeditor5.js",
198
+ * "ckeditor5/": "https://cdn.ckeditor.com/ckeditor5/<VERSION>/"
199
+ * }
200
+ * }
201
+ * <\/script>
202
+ * <script type="module">
203
+ * import { ClassicEditor, Essentials, Paragraph } from 'ckeditor5';
204
+ * import { translations } from 'ckeditor5/dist/translations/pl.js';
205
+ *
206
+ * await ClassicEditor.create( {
207
+ * attachTo: document.querySelector( '#editor' ),
208
+ * plugins: [
209
+ * Essentials,
210
+ * Paragraph,
211
+ * ],
212
+ * toolbar: {
213
+ * items: [ 'undo', 'redo' ]
214
+ * },
215
+ * translations
216
+ * } );
217
+ * <\/script>
218
+ * ```
219
+ *
220
+ * You can add translation using NPM as well.
221
+ *
222
+ * ```html
223
+ * import { ClassicEditor, Essentials, Paragraph } from 'ckeditor5';
224
+ * import { translations } from 'ckeditor5/dist/translations/pl.js';
225
+ *
226
+ * import 'ckeditor5/dist/styles.css';
227
+ *
228
+ * await ClassicEditor.create( {
229
+ * attachTo: document.querySelector( '#editor' ),
230
+ * plugins: [
231
+ * Essentials,
232
+ * Paragraph,
233
+ * ],
234
+ * toolbar: {
235
+ * items: [ 'undo', 'redo' ]
236
+ * },
237
+ * translations
238
+ * } );
239
+ * ```
240
+ *
241
+ * Check the {@glink getting-started/setup/ui-language UI language} guide for more information about
242
+ * the localization options and translation process.
243
+ */
244
+ language?: string | LanguageConfig;
245
+ /**
246
+ * The editor menu bar configuration.
247
+ *
248
+ * **Note**: The menu bar is not available in all editor types. Currently, only the
249
+ * {@link module:editor-classic/classiceditor~ClassicEditor Classic editor} and
250
+ * {@link module:editor-decoupled/decouplededitor~DecoupledEditor Decoupled editor}
251
+ * support this feature. Setting the `config.menuBar` configuration for other editor types will have no effect.
252
+ *
253
+ * In Classic editor, the menu bar is hidden by default. Set the `isVisible` configuration flag to `true` in order to show it:
254
+ *
255
+ * ```ts
256
+ * ClassicEditor
257
+ * .create( {
258
+ * attachTo: document.querySelector( '#editor' ),
259
+ * menuBar: {
260
+ * isVisible: true
261
+ * }
262
+ * } )
263
+ * .then( ... );
264
+ * ```
265
+ *
266
+ * When using the Decoupled editor, you will need to insert the menu bar in a desired place yourself. For example:
267
+ *
268
+ * ```ts
269
+ * DecoupledEditor
270
+ * .create( {
271
+ * root: { element: document.querySelector( '#editor' ) },
272
+ * toolbar: [ 'undo', 'redo', 'bold', 'italic', 'numberedList', 'bulletedList' ],
273
+ * } )
274
+ * .then( editor => {
275
+ * document.getElementById( '#menuBarContainer' ).appendChild( editor.ui.view.menuBarView.element );
276
+ * } );
277
+ * ```
278
+ *
279
+ * **Note**: You do not have to set the `items` property in this configuration in order to use the menu bar.
280
+ * By default, a {@link module:ui/menubar/utils#DefaultMenuBarItems default set of items} is used that already includes
281
+ * **all core editor features**. For your convenience, there are `config.menuBar.addItems` and
282
+ * `config.menuBar.removeItems` options available that will help you adjust the default configuration without setting the
283
+ * entire menu bar structure from scratch (see below).
284
+ *
285
+ * **Removing items from the menu bar**
286
+ *
287
+ * You can use the `config.menuBar.removeItems` option to remove items from the default menu bar configuration. You can
288
+ * remove individual buttons (e.g. "Bold" or "Block quote"), item groups (e.g. the basic styles section that
289
+ * includes multiple buttons such as "Bold", "Italic", "Underline", etc.), or whole menus (e.g. the "Insert" menu). Please
290
+ * refer to the {@link module:ui/menubar/utils#DefaultMenuBarItems default configuration} to see default buttons/groups/menus
291
+ * and their structure.
292
+ *
293
+ * To remove individual buttons from the menu bar:
294
+ *
295
+ * ```ts
296
+ * ClassicEditor
297
+ * .create( {
298
+ * attachTo: document.querySelector( '#editor' ),
299
+ * menuBar: {
300
+ * // Removes "Bold" and "Block quote" buttons from their respective menus.
301
+ * removeItems: [ 'menuBar:bold', 'menuBar:blockQuote' ]
302
+ * }
303
+ * } )
304
+ * .then( ... );
305
+ * ```
306
+ *
307
+ * To remove a group of buttons from the menu bar:
308
+ *
309
+ * ```ts
310
+ * ClassicEditor
311
+ * .create( {
312
+ * attachTo: document.querySelector( '#editor' ),
313
+ * menuBar: {
314
+ * // Removes the entire basic styles group ("Bold", "Italic", "Underline", etc.) from the "Format" menu.
315
+ * removeItems: [ 'basicStyles' ]
316
+ * }
317
+ * } )
318
+ * .then( ... );
319
+ * ```
320
+ *
321
+ * To remove a menu from the menu bar:
322
+ *
323
+ * ```ts
324
+ * ClassicEditor
325
+ * .create( {
326
+ * attachTo: document.querySelector( '#editor' ),
327
+ * menuBar: {
328
+ * // Removes the whole top-level "Insert" menu from the menu bar.
329
+ * removeItems: [ 'insert' ]
330
+ * }
331
+ * } )
332
+ * .then( ... );
333
+ * ```
334
+ *
335
+ * **Adding items to the menu bar**
336
+ *
337
+ * Using the `config.menuBar.addItems` option you can add individual buttons, button groups or entire menus to the structure
338
+ * of the menu bar. You can add existing components that you removed from their original position, or add your own components.
339
+ *
340
+ * **Note**: When adding items please make sure that features (editor plugins) that bring specific menu bar items are loaded.
341
+ * For instance, the "Bold" button will not show up in the menu bar unless the {@glink features/basic-styles basic styles} feature is
342
+ * loaded. {@link module:core/editor/editorconfig~EditorConfig#plugins Learn more} about loading plugins.
343
+ *
344
+ * Each entry in the `config.menuBar.addItems` is an object with one of the following properties:
345
+ *
346
+ * * `item` &ndash; A name of the button to be added to a specific button group (e.g. `'menuBar:bold'` or `'myButton'`),
347
+ * * `menu` &ndash; A {@link module:ui/menubar/menubarview#MenuBarMenuDefinition definition of a menu} that should be added to
348
+ * the menu bar,
349
+ * * `group` &ndash; A {@link module:ui/menubar/menubarview#MenuBarMenuGroupDefinition definition of a button group} that should be
350
+ * added to a specific menu.
351
+ *
352
+ * Additionally, each entry must define the `position` property that accepts the following values:
353
+ * * `'start'` &ndash; Adds a top-level menu (e.g. "Format", "Insert", etc.) at the beginning of the menu bar,
354
+ * * `'start:GROUP_OR_MENU'` &ndash; Adds a button/group at the beginning of the specific group/menu,
355
+ * * `'end'` &ndash; Adds a top-level menu (e.g. "Format", "Insert", etc.) at the end of the menu bar,
356
+ * * `'end:GROUP_OR_MENU'` &ndash; Adds a button/group at the end of the specific group/menu,
357
+ * * `'after:BUTTON_OR_GROUP_OR_MENU'` &ndash; Adds a button/group/menu right after the specific button/group/menu,
358
+ * * `'before:BUTTON_OR_GROUP_OR_MENU'` &ndash; Adds a button/group/menu right after the specific button/group/menu.
359
+ *
360
+ * Please refer to the {@link module:ui/menubar/utils#DefaultMenuBarItems default configuration} to learn about the
361
+ * names of buttons and positions they can be added at.
362
+ *
363
+ * To add a new top-level menu with specific buttons at the end of the menu bar:
364
+ *
365
+ * ```ts
366
+ * ClassicEditor
367
+ * .create( {
368
+ * attachTo: document.querySelector( '#editor' ),
369
+ * menuBar: {
370
+ * addItems: [
371
+ * {
372
+ * menu: {
373
+ * menuId: 'my-menu',
374
+ * label: 'My menu',
375
+ * groups: [
376
+ * {
377
+ * groupId: 'my-buttons',
378
+ * items: [
379
+ * 'menuBar:bold',
380
+ * 'menuBar:italic',
381
+ * 'menuBar:underline'
382
+ * ]
383
+ * }
384
+ * ]
385
+ * },
386
+ * position: 'end'
387
+ * }
388
+ * ]
389
+ * }
390
+ * } )
391
+ * .then( ... );
392
+ * ```
393
+ *
394
+ * To add a new group of buttons to the "Format" menu after basic styles buttons ("Bold", "Italic", "Underline", etc.):
395
+ *
396
+ * ```ts
397
+ * ClassicEditor
398
+ * .create( {
399
+ * attachTo: document.querySelector( '#editor' ),
400
+ * menuBar: {
401
+ * addItems: [
402
+ * {
403
+ * group: {
404
+ * groupId: 'my-buttons',
405
+ * items: [
406
+ * 'myButton1',
407
+ * 'myButton2',
408
+ * ]
409
+ * },
410
+ * position: 'after:basicStyles'
411
+ * }
412
+ * ]
413
+ * }
414
+ * } )
415
+ * .then( ... );
416
+ * ```
417
+ *
418
+ * To add a new button to the basic styles group ("Bold", "Italic", "Underline", etc.) in the "Format" menu:
419
+ *
420
+ * ```ts
421
+ * ClassicEditor
422
+ * .create( {
423
+ * attachTo: document.querySelector( '#editor' ),
424
+ * menuBar: {
425
+ * addItems: [
426
+ * {
427
+ * item: 'myButton',
428
+ * position: 'end:basicStyles'
429
+ * }
430
+ * ]
431
+ * }
432
+ * } )
433
+ * .then( ... );
434
+ * ```
435
+ *
436
+ * To add a new sub-menu in the "Format" menu:
437
+ *
438
+ * ```ts
439
+ * ClassicEditor
440
+ * .create( {
441
+ * attachTo: document.querySelector( '#editor' ),
442
+ * menuBar: {
443
+ * addItems: [
444
+ * {
445
+ * menu: {
446
+ * menuId: 'my-sub-menu',
447
+ * label: 'My sub-menu',
448
+ * groups: [
449
+ * {
450
+ * groupId: 'my-buttons',
451
+ * items: [
452
+ * 'myButton1',
453
+ * 'myButton2',
454
+ * ]
455
+ * }
456
+ * ]
457
+ * },
458
+ * position: 'after:basicStyles'
459
+ * }
460
+ * ]
461
+ * }
462
+ * } )
463
+ * .then( ... );
464
+ * ```
465
+ *
466
+ * **Defining menu bar from scratch**
467
+ *
468
+ * If the `config.menuBar.addItems` and `config.menuBar.removeItems` options are not enough to adjust the
469
+ * {@link module:ui/menubar/utils#DefaultMenuBarItems default configuration}, you can set the menu bar structure from scratch.
470
+ *
471
+ * For instance, to create a minimalistic menu bar configuration with just two main categories (menus), use the following code snippet:
472
+ *
473
+ * ```ts
474
+ * ClassicEditor
475
+ * .create( {
476
+ * attachTo: document.querySelector( '#editor' ),
477
+ * menuBar: {
478
+ * items: [
479
+ * {
480
+ * menuId: 'formatting',
481
+ * label: 'Formatting',
482
+ * groups: [
483
+ * {
484
+ * groupId: 'basicStyles',
485
+ * items: [
486
+ * 'menuBar:bold',
487
+ * 'menuBar:italic',
488
+ * ]
489
+ * },
490
+ * {
491
+ * groupId: 'misc',
492
+ * items: [
493
+ * 'menuBar:heading',
494
+ * 'menuBar:bulletedList',
495
+ * 'menuBar:numberedList'
496
+ * ]
497
+ * }
498
+ * ]
499
+ * },
500
+ * {
501
+ * menuId: 'myButtons',
502
+ * label: 'My actions',
503
+ * groups: [
504
+ * {
505
+ * groupId: 'undo',
506
+ * items: [
507
+ * 'myButton1',
508
+ * 'myButton2'
509
+ * ]
510
+ * }
511
+ * ]
512
+ * }
513
+ * ]
514
+ * }
515
+ * } )
516
+ * .then( ... );
517
+ * ```
518
+ */
519
+ menuBar?: MenuBarConfig;
520
+ /**
521
+ * Specifies the text displayed in the editor when there is no content (editor is empty). It is intended to
522
+ * help users locate the editor in the application (form) and prompt them to input the content. Work similarly
523
+ * as to the native DOM
524
+ * [`placeholder` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#The_placeholder_attribute)
525
+ * used by inputs.
526
+ *
527
+ * ```ts
528
+ * ClassicEditor
529
+ * .create( {
530
+ * attachTo: document.querySelector( '#editor' ),
531
+ * root: {
532
+ * placeholder: 'Type some text...'
533
+ * }
534
+ * } )
535
+ * .then( ... )
536
+ * .catch( ... );
537
+ * ```
538
+ *
539
+ * If your editor implementation uses multiple roots, you should pass an object with keys corresponding to the editor
540
+ * roots names and values equal to the placeholder that should be set in each root:
541
+ *
542
+ * ```ts
543
+ * MultiRootEditor.create( {
544
+ * roots: {
545
+ * header: {
546
+ * element: document.querySelector( '#header' ),
547
+ * placeholder: 'Type header...'
548
+ * },
549
+ * content: {
550
+ * element: document.querySelector( '#content' ),
551
+ * placeholder: 'Type content...'
552
+ * },
553
+ * leftSide: {
554
+ * element: document.querySelector( '#left-side' ),
555
+ * placeholder: 'Type left-side...'
556
+ * },
557
+ * rightSide: {
558
+ * element: document.querySelector( '#right-side' ),
559
+ * placeholder: 'Type right-side...'
560
+ * }
561
+ * }
562
+ * } )
563
+ * .then( ... )
564
+ * .catch( ... );
565
+ * ```
566
+ *
567
+ * The placeholder text is displayed as a pseudo–element of an empty paragraph in the editor content.
568
+ * The paragraph has the `.ck-placeholder` CSS class and the `data-placeholder` attribute.
569
+ *
570
+ * ```html
571
+ * <p data-placeholder="Type some text..." class="ck-placeholder">
572
+ * ::before
573
+ * </p>
574
+ * ```
575
+ *
576
+ * **Note**: Placeholder text can also be set using the `placeholder` attribute if a `<textarea>` is passed to
577
+ * the `create()` method, e.g. {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
578
+ *
579
+ * **Note**: This configuration has precedence over the value of the `placeholder` attribute of a `<textarea>`
580
+ * element passed to the `create()` method.
581
+ *
582
+ * See the {@glink features/editor-placeholder "Editor placeholder"} guide for more information and live examples.
583
+ *
584
+ * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
585
+ * {@link module:core/editor/editorconfig~EditorConfig#root `config.root.placeholder`} instead.
586
+ * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use
587
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.placeholder`}.**
588
+ *
589
+ * @deprecated
590
+ */
591
+ placeholder?: string | Record<string, string>;
592
+ /**
593
+ * The list of plugins to load.
594
+ *
595
+ * ```ts
596
+ * import {
597
+ * // A preset of plugins is a plugin as well.
598
+ * Essentials,
599
+ * // The bold plugin.
600
+ * Bold
601
+ * } from 'ckeditor5';
602
+ *
603
+ * const config = {
604
+ * plugins: [ Essentials, Bold ]
605
+ * };
606
+ * ```
607
+ *
608
+ * **Note:** To load additional plugins, you should use the {@link #extraPlugins `extraPlugins`} configuration.
609
+ * To narrow the list of loaded plugins, use the {@link #removePlugins `removePlugins`} configuration.
610
+ */
611
+ plugins?: Array<PluginConstructor<Editor> | string>;
612
+ /**
613
+ * The list of plugins which should not be loaded despite being available in
614
+ * the editor.
615
+ *
616
+ * ```ts
617
+ * const config = {
618
+ * removePlugins: [ 'Bold', 'Italic' ]
619
+ * };
620
+ * ```
621
+ *
622
+ * **Note:** Be careful when removing plugins using `config.removePlugins`.
623
+ * If removed plugins were providing toolbar buttons, the default toolbar configuration included in a build
624
+ * will become invalid. In such case you need to provide the updated
625
+ * {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar configuration}.
626
+ */
627
+ removePlugins?: Array<PluginConstructor<Editor> | string>;
628
+ substitutePlugins?: Array<PluginConstructor<Editor>>;
629
+ /**
630
+ * The editor toolbar configuration.
631
+ *
632
+ * Simple format (specifies only toolbar items):
633
+ *
634
+ * ```ts
635
+ * const config = {
636
+ * toolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ]
637
+ * };
638
+ * ```
639
+ *
640
+ * Extended format:
641
+ *
642
+ * ```ts
643
+ * const config = {
644
+ * toolbar: {
645
+ * items: [ 'bold', 'italic', '|', 'undo', 'redo', '-', 'numberedList', 'bulletedList' ],
646
+ *
647
+ * shouldNotGroupWhenFull: true
648
+ * }
649
+ * };
650
+ * ```
651
+ *
652
+ * Options which can be set using the extended format:
653
+ *
654
+ * * **`toolbar.items`** &ndash; An array of toolbar item names. The components (buttons, dropdowns, etc.) which can be used
655
+ * as toolbar items are defined in `editor.ui.componentFactory` and can be listed using the following snippet:
656
+ *
657
+ * ```ts
658
+ * Array.from( editor.ui.componentFactory.names() );
659
+ * ```
660
+ *
661
+ * You can also use `'|'` to create a separator between groups of items:
662
+ *
663
+ * ```
664
+ * toolbar: [ 'bold', 'italic', '|', 'undo', 'redo' ]
665
+ * ```
666
+ *
667
+ * or `'-'` to make a line break and render items in multiple lines:
668
+ *
669
+ * ```
670
+ * toolbar: [ 'bold', 'italic', '-', 'undo', 'redo' ]
671
+ * ```
672
+ *
673
+ * Line break will work only in the extended format when `shouldNotGroupWhenFull` option is set to `true`.
674
+ *
675
+ * **Note**: To save space in your toolbar, you can group several items into a dropdown:
676
+ *
677
+ * ```
678
+ * toolbar: [
679
+ * {
680
+ * label: 'Basic styles',
681
+ * icon: 'text',
682
+ * items: [ 'bold', 'italic', ... ]
683
+ * },
684
+ * '|',
685
+ * 'undo', 'redo'
686
+ * ]
687
+ * ```
688
+ *
689
+ * The code above will create a "Basic styles" dropdown with a "text" icon containing the "bold" and "italic" buttons.
690
+ * You can customize the look of the dropdown by setting the `withText`, `icon`, and `tooltip` properties:
691
+ *
692
+ * * **Displaying a label**
693
+ *
694
+ * For instance, to hide the icon and to display the label only, you can use the following configuration:
695
+ *
696
+ * ```ts
697
+ * {
698
+ * label: 'Basic styles',
699
+ * // Show the textual label of the drop-down. Note that the "icon" property is not configured.
700
+ * withText: true,
701
+ * items: [ 'bold', 'italic', ... ]
702
+ * }
703
+ * ```
704
+ *
705
+ * * **Selecting an icon**
706
+ *
707
+ * You can use one of the common icons provided by the editor (`'bold'`, `'plus'`, `'text'`, `'importExport'`, `'alignLeft'`,
708
+ * `'paragraph'`, `'threeVerticalDots'`, `'dragIndicator'`, `'pilcrow'`):
709
+ *
710
+ * ```ts
711
+ * {
712
+ * label: '...',
713
+ * // A "plus" sign icon works best for content insertion tools.
714
+ * icon: 'plus',
715
+ * items: [ ... ]
716
+ * }
717
+ * ```
718
+ *
719
+ * If no icon is specified, `'threeVerticalDots'` will be used as a default:
720
+ *
721
+ * ```ts
722
+ * // No icon specified, using a default one.
723
+ * {
724
+ * label: 'Default icon',
725
+ * items: [ ... ]
726
+ * }
727
+ * ```
728
+ *
729
+ * If `icon: false` is configured, no icon will be displayed at all and the text label will show up instead:
730
+ *
731
+ * ```ts
732
+ * // This drop-down has no icon. The text label will be displayed instead.
733
+ * {
734
+ * label: 'No icon',
735
+ * icon: false,
736
+ * items: [ ... ]
737
+ * }
738
+ * ```
739
+ *
740
+ * You can also set a custom icon for the drop-down by passing an SVG string:
741
+ *
742
+ * ```ts
743
+ * {
744
+ * label: '...',
745
+ * // If you want your icon to change the color dynamically (e.g. when the dropdown opens), avoid fill="..."
746
+ * // and stroke="..." styling attributes. Use solid shapes and avoid paths with strokes.
747
+ * icon: '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">...</svg>',
748
+ * items: [ ... ]
749
+ * }
750
+ * ```
751
+ *
752
+ * * **Customizing the tooltip**
753
+ *
754
+ * By default, the tooltip of the button shares its text with the label. You can customize it to better describe your dropdown
755
+ * using the `tooltip` property ({@link module:ui/button/buttonview~ButtonView#tooltip learn more}):
756
+ *
757
+ * ```ts
758
+ * {
759
+ * label: 'Drop-down label',
760
+ * tooltip: 'Custom tooltip of the drop-down',
761
+ * icon: '...',
762
+ * items: [ ... ]
763
+ * }
764
+ * ```
765
+ *
766
+ * * **`toolbar.viewportTopOffset` (deprecated)** &ndash; The offset (in pixels) from the top of the viewport used when positioning a
767
+ * sticky toolbar.
768
+ * Useful when a page with which the editor is being integrated has some other sticky or fixed elements
769
+ * (e.g. the top menu). Thanks to setting the toolbar offset the toolbar will not be positioned underneath or above the page's UI.
770
+ *
771
+ * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
772
+ * `{@link module:core/editor/editorconfig~EditorConfig#ui EditorConfig#ui.viewportOffset}` instead.**
773
+ *
774
+ * * **`toolbar.shouldNotGroupWhenFull`** &ndash; When set to `true`, the toolbar will stop grouping items
775
+ * and let them wrap to the next line if there is not enough space to display them in a single row.
776
+ */
777
+ toolbar?: ToolbarConfig;
778
+ /**
779
+ * The editor UI configuration.
780
+ *
781
+ * ```ts
782
+ * ClassicEditor
783
+ * .create( {
784
+ * attachTo: document.querySelector( '#editor' ),
785
+ * ui: { ... }
786
+ * } )
787
+ * .then( ... )
788
+ * .catch( ... );
789
+ * ```
790
+ *
791
+ * Options which can be set using the UI configuration:
792
+ *
793
+ * * **`ui.viewportOffset`** &ndash; The offset (in pixels) of the viewport from every direction. It is
794
+ * used when positioning a sticky toolbar or other absolutely positioned UI elements.
795
+ * Useful when a page with which the editor is being integrated has some other sticky or fixed elements
796
+ * (e.g. the top menu). Thanks to setting the UI viewport offset, the toolbar and other contextual balloons will not be positioned
797
+ * underneath or above the page's UI.
798
+ *
799
+ * ```ts
800
+ * ui: {
801
+ * viewportOffset: { top: 10, right: 10, bottom: 10, left: 10 }
802
+ * }
803
+ * ```
804
+ *
805
+ * **Note:** If you want to modify the viewport offset in runtime (after the editor was created), you can do that by overriding
806
+ * {@link module:ui/editorui/editorui~EditorUI#viewportOffset `editor.ui.viewportOffset`}.
807
+ *
808
+ * * **`ui.poweredBy`** &ndash; The configuration of the project logo displayed over the editor's editing area in
809
+ * open-source integrations. It allows customizing the position of the logo to minimize the risk of collision with the
810
+ * editor content and UI.
811
+ *
812
+ * The following configuration properties are supported:
813
+ *
814
+ * * **`position`** &ndash; The position of the project's logo (default: `'border'`).
815
+ * * When `'inside'`, the logo will be displayed within the boundaries of the editing area.
816
+ * * When `'border'`, the logo will be displayed over the bottom border of the editing area.
817
+ *
818
+ * * **`side`** (`'left'` or `'right'`, default: `'right'`) &ndash; The side of the editing area where the
819
+ * logo will be displayed.
820
+ *
821
+ * **Note**: If {@link module:core/editor/editorconfig~EditorConfig#language `config.language`} is set to an RTL (right-to-left)
822
+ * language, the side switches to `'left'` by default.
823
+ *
824
+ * * **`label`** (default: `'Powered by'`) &ndash; The label displayed next to the project's logo.
825
+ *
826
+ * **Note**: Set the value to `null` to display the logo without any text.
827
+ *
828
+ * * **`verticalOffset`** (default: `5`) &ndash; The vertical distance the logo can be moved away from its default position.
829
+ *
830
+ * **Note**: If `position` is `'border'`, the offset is measured from the (vertical) center of the logo.
831
+ *
832
+ * * **`horizontalOffset`** (default: `5`) &ndash; The horizontal distance between the side of the editing root and the
833
+ * nearest side of the logo.
834
+ *
835
+ * ```ts
836
+ * ui: {
837
+ * poweredBy: {
838
+ * position: 'border',
839
+ * side: 'left',
840
+ * verticalOffset: 2,
841
+ * horizontalOffset: 30
842
+ * }
843
+ * }
844
+ */
845
+ ui?: UiConfig;
846
+ /**
847
+ * Enables updating the source element after the editor is destroyed.
848
+ *
849
+ * Enabling this option might have some security implications, as the editor doesn't have control over all data
850
+ * in the output.
851
+ *
852
+ * Be careful, especially while using the
853
+ * {@glink features/markdown Markdown}, {@glink features/html/general-html-support General HTML Support}, or
854
+ * {@glink features/html/html-embed HTML embed} features.
855
+ */
856
+ updateSourceElementOnDestroy?: boolean;
857
+ /**
858
+ * The CKEditor 5 license key. If you want to obtain a license key, please do one of the following:
859
+ *
860
+ * * Create a free account, and test the premium features with a [14-day free trial](https://portal.ckeditor.com/checkout?plan=free).
861
+ * * [Contact us](https://ckeditor.com/contact/) for a commercial license.
862
+ * * If you are using the editor under a GPL license or another license from our Open Source Initiative,
863
+ * use the 'GPL' license key instead.
864
+ */
865
+ licenseKey?: string;
866
+ /**
867
+ * Translations to be used in the editor.
868
+ */
869
+ translations?: ArrayOrItem<Translations>;
870
+ /**
871
+ * Label which briefly describes the editing area. Used for the `aria-label` attribute set on the editor editing area,
872
+ * helping assistive technologies to tell apart multiple editor instances (editing areas) on the page. If not set,
873
+ * a default "Rich Text Editor. Editing area [name of the area]" is used instead.
874
+ *
875
+ * It can also be used by other features when referring to this editing area (e.g. AI features).
876
+ *
877
+ * ```ts
878
+ * ClassicEditor
879
+ * .create( {
880
+ * attachTo: document.querySelector( '#editor' ),
881
+ * root: {
882
+ * label: 'Article main content'
883
+ * }
884
+ * } )
885
+ * .then( ... )
886
+ * .catch( ... );
887
+ * ```
888
+ *
889
+ * If your editor implementation uses multiple roots, you should pass an object with keys corresponding to the editor
890
+ * roots names and values equal to the label that should be used for each root:
891
+ *
892
+ * ```ts
893
+ * MultiRootEditor.create( {
894
+ * roots: {
895
+ * header: {
896
+ * element: document.querySelector( '#header' ),
897
+ * label: 'Article header'
898
+ * },
899
+ * content: {
900
+ * element: document.querySelector( '#content' ),
901
+ * label: 'Article main content'
902
+ * },
903
+ * sideQuote: {
904
+ * element: document.querySelector( '#side-quote' ),
905
+ * label: 'Side-quote'
906
+ * },
907
+ * relatedLinks: {
908
+ * element: document.querySelector( '#related-links' ),
909
+ * label: 'Related links'
910
+ * }
911
+ * }
912
+ * } )
913
+ * .then( ... )
914
+ * .catch( ... );
915
+ * ```
916
+ *
917
+ * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use
918
+ * {@link module:core/editor/editorconfig~EditorConfig#root `config.root.label`} instead.
919
+ * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use
920
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>.label`}.**
921
+ *
922
+ * @deprecated
923
+ */
924
+ label?: string | Record<string, string>;
925
+ /**
926
+ * The root configuration for the default `main` root. Use this option to configure the initial data,
927
+ * placeholder, label, and source element for a single-root editor.
928
+ *
929
+ * This is the recommended way to configure a single-root editor:
930
+ *
931
+ * ```ts
932
+ * // Classic editor – uses `attachTo` for the source element.
933
+ * ClassicEditor
934
+ * .create( {
935
+ * attachTo: document.querySelector( '#editor' ),
936
+ * root: {
937
+ * initialData: '<p>Hello world!</p>',
938
+ * placeholder: 'Type some text...'
939
+ * }
940
+ * } )
941
+ * .then( ... )
942
+ * .catch( ... );
943
+ * ```
944
+ *
945
+ * ```ts
946
+ * // Inline editor – uses `root.element` for the source element.
947
+ * InlineEditor
948
+ * .create( {
949
+ * root: {
950
+ * element: document.querySelector( '#editor' ),
951
+ * initialData: '<p>Hello world!</p>',
952
+ * placeholder: 'Type some text...'
953
+ * }
954
+ * } )
955
+ * .then( ... )
956
+ * .catch( ... );
957
+ * ```
958
+ *
959
+ * ```ts
960
+ * // Balloon editor – uses `root.element` for the source element.
961
+ * BalloonEditor
962
+ * .create( {
963
+ * root: {
964
+ * element: document.querySelector( '#editor' ),
965
+ * placeholder: 'Type some text...'
966
+ * }
967
+ * } )
968
+ * .then( ... )
969
+ * .catch( ... );
970
+ * ```
971
+ *
972
+ * ```ts
973
+ * // Decoupled editor – uses `root.element` for the source element.
974
+ * // The toolbar and editable area must be manually added to the DOM.
975
+ * DecoupledEditor
976
+ * .create( {
977
+ * root: {
978
+ * element: document.querySelector( '#editor' ),
979
+ * initialData: '<p>Hello world!</p>'
980
+ * }
981
+ * } )
982
+ * .then( editor => {
983
+ * document.querySelector( '#toolbar' ).appendChild( editor.ui.view.toolbar.element );
984
+ * } )
985
+ * .catch( ... );
986
+ * ```
987
+ *
988
+ * Internally, this option is an alias for `config.roots.main`. If both `config.root` and `config.roots.main`
989
+ * are set, an error will be thrown.
990
+ *
991
+ * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use the
992
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots`} option instead to define
993
+ * configuration for each root individually.
994
+ */
995
+ root?: RootConfig;
996
+ /**
997
+ * The root configuration options grouped by the root name. This option is used primarily by the
998
+ * {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor} to define
999
+ * configuration for each root individually.
1000
+ *
1001
+ * For a typical single-root editor, use the simpler {@link module:core/editor/editorconfig~EditorConfig#root `config.root`}
1002
+ * option instead.
1003
+ *
1004
+ * ```ts
1005
+ * // Using existing DOM elements as source for each root.
1006
+ * MultiRootEditor.create( {
1007
+ * roots: {
1008
+ * header: {
1009
+ * element: document.querySelector( '#header' ),
1010
+ * placeholder: 'Type header...',
1011
+ * label: 'Article header'
1012
+ * },
1013
+ * content: {
1014
+ * element: document.querySelector( '#content' ),
1015
+ * placeholder: 'Type content...',
1016
+ * label: 'Article main content'
1017
+ * }
1018
+ * }
1019
+ * } )
1020
+ * .then( editor => {
1021
+ * document.querySelector( '#toolbar' ).appendChild( editor.ui.view.toolbar.element );
1022
+ * } )
1023
+ * .catch( ... );
1024
+ * ```
1025
+ *
1026
+ * ```ts
1027
+ * // Creating a detached editor with initial data for each root.
1028
+ * MultiRootEditor.create( {
1029
+ * roots: {
1030
+ * header: {
1031
+ * initialData: '<h2>Article title</h2>',
1032
+ * placeholder: 'Type header...',
1033
+ * label: 'Article header'
1034
+ * },
1035
+ * content: {
1036
+ * initialData: '<p>Article body...</p>',
1037
+ * placeholder: 'Type content...',
1038
+ * label: 'Article main content'
1039
+ * }
1040
+ * }
1041
+ * } )
1042
+ * .then( editor => {
1043
+ * document.querySelector( '#toolbar' ).appendChild( editor.ui.view.toolbar.element );
1044
+ *
1045
+ * for ( const rootName of editor.ui.getEditableElementsNames() ) {
1046
+ * document.querySelector( '#editables' ).appendChild( editor.ui.view.getEditable( rootName ).element );
1047
+ * }
1048
+ * } )
1049
+ * .catch( ... );
1050
+ * ```
1051
+ */
1052
+ roots?: Record<string, RootConfig>;
1053
1053
  }
1054
1054
  /**
1055
- * Configuration for an editor root. It is used in {@link module:core/editor/editorconfig~EditorConfig#root `EditorConfig#root`} and
1056
- * {@link module:core/editor/editorconfig~EditorConfig#roots `EditorConfig#roots.<rootName>`}.
1057
- *
1058
- * For a typical single-root editor (Classic, Inline, Balloon, Decoupled), use
1059
- * {@link module:core/editor/editorconfig~EditorConfig#root `config.root`} to set the root configuration.
1060
- * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use
1061
- * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots`} to define configuration for each root.
1062
- *
1063
- * ```ts
1064
- * // Classic editor – the source element is set via `config.attachTo`.
1065
- * ClassicEditor.create( {
1066
- * attachTo: document.querySelector( '#editor' ),
1067
- * root: {
1068
- * initialData: '<p>Hello world!</p>',
1069
- * placeholder: 'Type some text...',
1070
- * label: 'Article main content'
1071
- * }
1072
- * } );
1073
- * ```
1074
- *
1075
- * ```ts
1076
- * // Inline editor – the source element is set via `root.element`.
1077
- * InlineEditor.create( {
1078
- * root: {
1079
- * element: document.querySelector( '#editor' ),
1080
- * initialData: '<p>Hello world!</p>',
1081
- * placeholder: 'Type some text...',
1082
- * label: 'Article main content'
1083
- * }
1084
- * } );
1085
- * ```
1086
- *
1087
- * ```ts
1088
- * // Multi-root editor – each root is configured separately via `config.roots`.
1089
- * MultiRootEditor.create( {
1090
- * roots: {
1091
- * header: {
1092
- * element: document.querySelector( '#header' ),
1093
- * placeholder: 'Type header...',
1094
- * label: 'Article header'
1095
- * },
1096
- * content: {
1097
- * element: document.querySelector( '#content' ),
1098
- * placeholder: 'Type content...',
1099
- * label: 'Article main content'
1100
- * }
1101
- * }
1102
- * } );
1103
- * ```
1104
- */
1055
+ * Configuration for an editor root. It is used in {@link module:core/editor/editorconfig~EditorConfig#root `EditorConfig#root`} and
1056
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `EditorConfig#roots.<rootName>`}.
1057
+ *
1058
+ * For a typical single-root editor (Classic, Inline, Balloon, Decoupled), use
1059
+ * {@link module:core/editor/editorconfig~EditorConfig#root `config.root`} to set the root configuration.
1060
+ * For the {@link module:editor-multi-root/multirooteditor~MultiRootEditor multi-root editor}, use
1061
+ * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots`} to define configuration for each root.
1062
+ *
1063
+ * ```ts
1064
+ * // Classic editor – the source element is set via `config.attachTo`.
1065
+ * ClassicEditor.create( {
1066
+ * attachTo: document.querySelector( '#editor' ),
1067
+ * root: {
1068
+ * initialData: '<p>Hello world!</p>',
1069
+ * placeholder: 'Type some text...',
1070
+ * label: 'Article main content'
1071
+ * }
1072
+ * } );
1073
+ * ```
1074
+ *
1075
+ * ```ts
1076
+ * // Inline editor – the source element is set via `root.element`.
1077
+ * InlineEditor.create( {
1078
+ * root: {
1079
+ * element: document.querySelector( '#editor' ),
1080
+ * initialData: '<p>Hello world!</p>',
1081
+ * placeholder: 'Type some text...',
1082
+ * label: 'Article main content'
1083
+ * }
1084
+ * } );
1085
+ * ```
1086
+ *
1087
+ * ```ts
1088
+ * // Multi-root editor – each root is configured separately via `config.roots`.
1089
+ * MultiRootEditor.create( {
1090
+ * roots: {
1091
+ * header: {
1092
+ * element: document.querySelector( '#header' ),
1093
+ * placeholder: 'Type header...',
1094
+ * label: 'Article header'
1095
+ * },
1096
+ * content: {
1097
+ * element: document.querySelector( '#content' ),
1098
+ * placeholder: 'Type content...',
1099
+ * label: 'Article main content'
1100
+ * }
1101
+ * }
1102
+ * } );
1103
+ * ```
1104
+ */
1105
1105
  export interface RootConfig {
1106
- /**
1107
- * The DOM element to use as the editor's editable root, or a description of one to create.
1108
- *
1109
- * Accepted forms:
1110
- *
1111
- * * An existing DOM element.
1112
- *
1113
- * Its content is automatically loaded to the editor upon initialization (but only when
1114
- * {@link #initialData `initialData`} is not set).
1115
- *
1116
- * The editor data will be set back to the original element once the editor is destroyed only if the
1117
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
1118
- * option is set to `true`.
1119
- *
1120
- * Not accepted by {@link module:editor-classic/classiceditor~ClassicEditor} - use
1121
- * {@link module:core/editor/editorconfig~EditorConfig#attachTo `config.attachTo`} instead.
1122
- *
1123
- * * A tag name string, e.g. `'h1'`. The editor creates a fresh element with that tag and uses it as the editable.
1124
- *
1125
- * * A {@link ~ViewRootElementDefinition} object. The editor creates a fresh element matching the definition and
1126
- * uses it as the editable.
1127
- *
1128
- * ```ts
1129
- * // Tag name string.
1130
- * BalloonEditor.create( {
1131
- * root: {
1132
- * element: 'h1'
1133
- * }
1134
- * } );
1135
- *
1136
- * // Element definition.
1137
- * BalloonEditor.create( {
1138
- * root: {
1139
- * element: {
1140
- * name: 'h1',
1141
- * classes: [ 'article-title' ],
1142
- * styles: { 'font-weight': 'bold' },
1143
- * attributes: { 'data-id': '123' }
1144
- * }
1145
- * }
1146
- * } );
1147
- * ```
1148
- *
1149
- * Unless an existing DOM element is provided, a detached editor will be created. In this case you need to insert
1150
- * it into the DOM manually.
1151
- */
1152
- element?: HTMLElement | string | ViewRootElementDefinition;
1153
- /**
1154
- * The initial editor data to be used instead of the HTML content of the
1155
- * {@link module:core/editor/editorconfig~RootConfig#element source element}.
1156
- *
1157
- * ```ts
1158
- * ClassicEditor
1159
- * .create( {
1160
- * attachTo: document.querySelector( '#editor' ),
1161
- * root: {
1162
- * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
1163
- * }
1164
- * } )
1165
- * .then( ... )
1166
- * .catch( ... );
1167
- * ```
1168
- *
1169
- * By default, the editor is initialized with the content of the source element on which this editor root is initialized.
1170
- * This configuration option lets you override this behavior and pass different initial data.
1171
- * It is especially useful if it is difficult for your integration to put the data inside the HTML element.
1172
- *
1173
- * If your editor implementation uses multiple roots, you should provide config for roots individually:
1174
- *
1175
- * ```ts
1176
- * MultiRootEditor.create( {
1177
- * roots: {
1178
- * header: {
1179
- * element: document.querySelector( '#header' ),
1180
- * initialData: '<p>Content for header part.</p>'
1181
- * },
1182
- * content: {
1183
- * element: document.querySelector( '#content' ),
1184
- * initialData: '<p>Content for main part.</p>'
1185
- * },
1186
- * leftSide: {
1187
- * element: document.querySelector( '#left-side' ),
1188
- * initialData: '<p>Content for left-side box.</p>'
1189
- * },
1190
- * rightSide: {
1191
- * element: document.querySelector( '#right-side' ),
1192
- * initialData: '<p>Content for right-side box.</p>'
1193
- * }
1194
- * }
1195
- * } )
1196
- * .then( ... )
1197
- * .catch( ... );
1198
- * ```
1199
- *
1200
- * See also {@link module:core/editor/editor~Editor.create Editor.create()} documentation for the editor implementation which you use.
1201
- */
1202
- initialData?: string;
1203
- /**
1204
- * Specifies the text displayed in the editor when there is no content (editor is empty). It is intended to
1205
- * help users locate the editor in the application (form) and prompt them to input the content. Works similarly
1206
- * to the native DOM
1207
- * [`placeholder` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#The_placeholder_attribute)
1208
- * used by inputs.
1209
- *
1210
- * ```ts
1211
- * ClassicEditor
1212
- * .create( {
1213
- * attachTo: document.querySelector( '#editor' ),
1214
- * root: {
1215
- * placeholder: 'Type some text...'
1216
- * }
1217
- * } )
1218
- * .then( ... )
1219
- * .catch( ... );
1220
- * ```
1221
- *
1222
- * If your editor implementation uses multiple roots, you should provide config for roots individually:
1223
- *
1224
- * ```ts
1225
- * MultiRootEditor.create( {
1226
- * roots: {
1227
- * header: {
1228
- * element: document.querySelector( '#header' ),
1229
- * placeholder: 'Type header...'
1230
- * },
1231
- * content: {
1232
- * element: document.querySelector( '#content' ),
1233
- * placeholder: 'Type content...'
1234
- * },
1235
- * leftSide: {
1236
- * element: document.querySelector( '#left-side' ),
1237
- * placeholder: 'Type left-side...'
1238
- * },
1239
- * rightSide: {
1240
- * element: document.querySelector( '#right-side' ),
1241
- * placeholder: 'Type right-side...'
1242
- * }
1243
- * }
1244
- * } )
1245
- * .then( ... )
1246
- * .catch( ... );
1247
- * ```
1248
- *
1249
- * The placeholder text is displayed as a pseudo–element of an empty paragraph in the editor content.
1250
- * The paragraph has the `.ck-placeholder` CSS class and the `data-placeholder` attribute.
1251
- *
1252
- * ```html
1253
- * <p data-placeholder="Type some text..." class="ck-placeholder">
1254
- * ::before
1255
- * </p>
1256
- * ```
1257
- *
1258
- * **Note**: Placeholder text can also be set using the `placeholder` attribute if a `<textarea>` is passed to
1259
- * the `create()` method, e.g. {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
1260
- *
1261
- * **Note**: This configuration has precedence over the value of the `placeholder` attribute of a `<textarea>`
1262
- * element passed to the `create()` method.
1263
- *
1264
- * See the {@glink features/editor-placeholder "Editor placeholder"} guide for more information and live examples.
1265
- */
1266
- placeholder?: string;
1267
- /**
1268
- * The name of the model root element to use for this editor root.
1269
- *
1270
- * By default, the editor creates model roots using the generic `$root` element, which allows all standard block
1271
- * content (paragraphs, headings, lists, tables, etc.). You can set this option to a custom element name if you
1272
- * need a root with different schema rules — for example, a root that restricts or extends what content is allowed
1273
- * at the top level.
1274
- *
1275
- * The element name must be registered in the {@link module:engine/model/schema~ModelSchema schema} before or during
1276
- * editor initialization. See the {@glink framework/deep-dive/schema "Schema"} guide for more information about
1277
- * generic items like `$root` and `$inlineRoot`.
1278
- *
1279
- * ```ts
1280
- * ClassicEditor
1281
- * .create( {
1282
- * root: {
1283
- * modelElement: '$inlineRoot'
1284
- * }
1285
- * } )
1286
- * .then( ... )
1287
- * .catch( ... );
1288
- * ```
1289
- *
1290
- * If your editor implementation uses multiple roots, you can set a different model element for each root:
1291
- *
1292
- * ```ts
1293
- * MultiRootEditor.create( {
1294
- * roots: {
1295
- * header: {
1296
- * modelElement: '$inlineRoot',
1297
- * initialData: 'My document title'
1298
- * },
1299
- * content: {
1300
- * initialData: '<p>Main content goes here.</p>'
1301
- * }
1302
- * }
1303
- * } )
1304
- * .then( ... )
1305
- * .catch( ... );
1306
- * ```
1307
- *
1308
- * @default '$root'
1309
- */
1310
- modelElement?: string;
1311
- /**
1312
- * Label which briefly describes this editing area.
1313
- *
1314
- * It is used for the `aria-label` attribute set on the editor editing area, helping assistive technologies
1315
- * to tell apart multiple editor instances (editing areas) on the page. If not set, a default
1316
- * "Rich Text Editor. Editing area [name of the area]" is used instead.
1317
- *
1318
- * It can also be used by other features when referring to this editing area.
1319
- *
1320
- * ```ts
1321
- * ClassicEditor
1322
- * .create( {
1323
- * attachTo: document.querySelector( '#editor' ),
1324
- * root: {
1325
- * label: 'Article main content'
1326
- * }
1327
- * } )
1328
- * .then( ... )
1329
- * .catch( ... );
1330
- * ```
1331
- *
1332
- * If your editor implementation uses multiple roots, you should provide config for roots individually:
1333
- *
1334
- * ```ts
1335
- * MultiRootEditor.create( {
1336
- * roots: {
1337
- * header: {
1338
- * element: document.querySelector( '#header' ),
1339
- * label: 'Article header'
1340
- * },
1341
- * content: {
1342
- * element: document.querySelector( '#content' ),
1343
- * label: 'Article main content'
1344
- * },
1345
- * sideQuote: {
1346
- * element: document.querySelector( '#side-quote' ),
1347
- * label: 'Side-quote'
1348
- * },
1349
- * relatedLinks: {
1350
- * element: document.querySelector( '#related-links' ),
1351
- * label: 'Related links'
1352
- * }
1353
- * }
1354
- * } )
1355
- * .then( ... )
1356
- * .catch( ... );
1357
- * ```
1358
- */
1359
- label?: string;
1360
- /**
1361
- * An optional, longer description of this editing area. It is intended as a stable, human-readable identifier
1362
- * so features can match a root across sessions, for instance AI features interacting with multiple editor instances
1363
- * and multi-root editors.
1364
- *
1365
- * ```ts
1366
- * ClassicEditor
1367
- * .create( {
1368
- * attachTo: document.querySelector( '#editor' ),
1369
- * root: {
1370
- * description: '...'
1371
- * }
1372
- * } )
1373
- * .then( ... )
1374
- * .catch( ... );
1375
- * ```
1376
- *
1377
- * If your editor implementation uses multiple roots, you should provide config for roots individually:
1378
- *
1379
- * ```ts
1380
- * MultiRootEditor.create( {
1381
- * roots: {
1382
- * chapter1: {
1383
- * element: document.querySelector( '#chapter1' ),
1384
- * description: 'Editing root for the first chapter.'
1385
- * },
1386
- * chapter2: {
1387
- * element: document.querySelector( '#chapter2' ),
1388
- * description: 'Editing root for the second chapter.'
1389
- * },
1390
- * chapter3: {
1391
- * element: document.querySelector( '#chapter3' ),
1392
- * description: 'Editing root for the third chapter.'
1393
- * }
1394
- * }
1395
- * } )
1396
- * .then( ... )
1397
- * .catch( ... );
1398
- * ```
1399
- */
1400
- description?: string;
1401
- /**
1402
- * Initial root attributes for a root.
1403
- *
1404
- * **Note: You must provide full set of attributes for each root. If an attribute is not set on a root, set the value to `null`.
1405
- * Only provided attribute keys will be returned by {@link module:core/editor/editor~Editor#getRootAttributes} or
1406
- * {@link module:editor-multi-root/multirooteditor~MultiRootEditor#getRootsAttributes}.**
1407
- *
1408
- * Roots attributes hold additional data related to the document roots, in addition to the regular document data (which usually is
1409
- * HTML). In roots attributes, for each root, you can store arbitrary key-value pairs with attributes connected with that root.
1410
- * Use it to store any custom data that is specific to your integration or custom features.
1411
- *
1412
- * Currently, any official plugins do not use root attributes. This is a mechanism that is prepared for custom features
1413
- * and non-standard integrations. If you do not provide any custom feature that would use root attributes, you do not need to
1414
- * handle (save and load) this property.
1415
- *
1416
- * ```ts
1417
- * ClassicEditor.create( {
1418
- * root: {
1419
- * modelAttributes: { customAttribute: true }
1420
- * }
1421
- * } )
1422
- * .then( ... )
1423
- * .catch( ... );
1424
- * ```
1425
- *
1426
- * If your editor implementation uses multiple roots, you should provide attributes for roots individually:
1427
- *
1428
- * ```ts
1429
- * MultiRootEditor.create(
1430
- * {
1431
- * roots: {
1432
- * uid1: {
1433
- * // ... other root config
1434
- * modelAttributes: { order: 20, isLocked: false } // Third, unlocked.
1435
- * },
1436
- * uid2: {
1437
- * // ... other root config
1438
- * modelAttributes: { order: 10, isLocked: true } // Second, locked.
1439
- * },
1440
- * uid3: {
1441
- * // ... other root config
1442
- * modelAttributes: { order: 30, isLocked: true } // Fourth, locked.
1443
- * },
1444
- * uid4: {
1445
- * // ... other root config
1446
- * modelAttributes: { order: 0, isLocked: false } // First, unlocked.
1447
- * }
1448
- * }
1449
- * }
1450
- * )
1451
- * .then( ... )
1452
- * .catch( ... );
1453
- * ```
1454
- *
1455
- * Note, that the above code snippet is only an example. You need to implement your own features that will use these attributes.
1456
- *
1457
- * Roots attributes can be changed the same way as attributes set on other model nodes:
1458
- *
1459
- * ```ts
1460
- * editor.model.change( writer => {
1461
- * const root = editor.model.getRoot( 'uid3' );
1462
- *
1463
- * writer.setAttribute( 'order', 40, root );
1464
- * } );
1465
- * ```
1466
- *
1467
- * You can react to root attributes changes by listening to
1468
- * {@link module:engine/model/document~ModelDocument#event:change:data document `change:data` event}:
1469
- *
1470
- * ```ts
1471
- * editor.model.document.on( 'change:data', () => {
1472
- * const changedRoots = editor.model.document.differ.getChangedRoots();
1473
- *
1474
- * for ( const change of changedRoots ) {
1475
- * if ( change.attributes ) {
1476
- * const root = editor.model.getRoot( change.name );
1477
- *
1478
- * // ...
1479
- * }
1480
- * }
1481
- * } );
1482
- * ```
1483
- */
1484
- modelAttributes?: EditorRootAttributes;
1106
+ /**
1107
+ * The DOM element to use as the editor's editable root, or a description of one to create.
1108
+ *
1109
+ * Accepted forms:
1110
+ *
1111
+ * * An existing DOM element.
1112
+ *
1113
+ * Its content is automatically loaded to the editor upon initialization (but only when
1114
+ * {@link #initialData `initialData`} is not set).
1115
+ *
1116
+ * The editor data will be set back to the original element once the editor is destroyed only if the
1117
+ * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
1118
+ * option is set to `true`.
1119
+ *
1120
+ * Not accepted by {@link module:editor-classic/classiceditor~ClassicEditor} - use
1121
+ * {@link module:core/editor/editorconfig~EditorConfig#attachTo `config.attachTo`} instead.
1122
+ *
1123
+ * * A tag name string, e.g. `'h1'`. The editor creates a fresh element with that tag and uses it as the editable.
1124
+ *
1125
+ * * A {@link ~ViewRootElementDefinition} object. The editor creates a fresh element matching the definition and
1126
+ * uses it as the editable.
1127
+ *
1128
+ * ```ts
1129
+ * // Tag name string.
1130
+ * BalloonEditor.create( {
1131
+ * root: {
1132
+ * element: 'h1'
1133
+ * }
1134
+ * } );
1135
+ *
1136
+ * // Element definition.
1137
+ * BalloonEditor.create( {
1138
+ * root: {
1139
+ * element: {
1140
+ * name: 'h1',
1141
+ * classes: [ 'article-title' ],
1142
+ * styles: { 'font-weight': 'bold' },
1143
+ * attributes: { 'data-id': '123' }
1144
+ * }
1145
+ * }
1146
+ * } );
1147
+ * ```
1148
+ *
1149
+ * Unless an existing DOM element is provided, a detached editor will be created. In this case you need to insert
1150
+ * it into the DOM manually.
1151
+ */
1152
+ element?: HTMLElement | string | ViewRootElementDefinition;
1153
+ /**
1154
+ * The initial editor data to be used instead of the HTML content of the
1155
+ * {@link module:core/editor/editorconfig~RootConfig#element source element}.
1156
+ *
1157
+ * ```ts
1158
+ * ClassicEditor
1159
+ * .create( {
1160
+ * attachTo: document.querySelector( '#editor' ),
1161
+ * root: {
1162
+ * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
1163
+ * }
1164
+ * } )
1165
+ * .then( ... )
1166
+ * .catch( ... );
1167
+ * ```
1168
+ *
1169
+ * By default, the editor is initialized with the content of the source element on which this editor root is initialized.
1170
+ * This configuration option lets you override this behavior and pass different initial data.
1171
+ * It is especially useful if it is difficult for your integration to put the data inside the HTML element.
1172
+ *
1173
+ * If your editor implementation uses multiple roots, you should provide config for roots individually:
1174
+ *
1175
+ * ```ts
1176
+ * MultiRootEditor.create( {
1177
+ * roots: {
1178
+ * header: {
1179
+ * element: document.querySelector( '#header' ),
1180
+ * initialData: '<p>Content for header part.</p>'
1181
+ * },
1182
+ * content: {
1183
+ * element: document.querySelector( '#content' ),
1184
+ * initialData: '<p>Content for main part.</p>'
1185
+ * },
1186
+ * leftSide: {
1187
+ * element: document.querySelector( '#left-side' ),
1188
+ * initialData: '<p>Content for left-side box.</p>'
1189
+ * },
1190
+ * rightSide: {
1191
+ * element: document.querySelector( '#right-side' ),
1192
+ * initialData: '<p>Content for right-side box.</p>'
1193
+ * }
1194
+ * }
1195
+ * } )
1196
+ * .then( ... )
1197
+ * .catch( ... );
1198
+ * ```
1199
+ *
1200
+ * See also {@link module:core/editor/editor~Editor.create Editor.create()} documentation for the editor implementation which you use.
1201
+ */
1202
+ initialData?: string;
1203
+ /**
1204
+ * Specifies the text displayed in the editor when there is no content (editor is empty). It is intended to
1205
+ * help users locate the editor in the application (form) and prompt them to input the content. Works similarly
1206
+ * to the native DOM
1207
+ * [`placeholder` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#The_placeholder_attribute)
1208
+ * used by inputs.
1209
+ *
1210
+ * ```ts
1211
+ * ClassicEditor
1212
+ * .create( {
1213
+ * attachTo: document.querySelector( '#editor' ),
1214
+ * root: {
1215
+ * placeholder: 'Type some text...'
1216
+ * }
1217
+ * } )
1218
+ * .then( ... )
1219
+ * .catch( ... );
1220
+ * ```
1221
+ *
1222
+ * If your editor implementation uses multiple roots, you should provide config for roots individually:
1223
+ *
1224
+ * ```ts
1225
+ * MultiRootEditor.create( {
1226
+ * roots: {
1227
+ * header: {
1228
+ * element: document.querySelector( '#header' ),
1229
+ * placeholder: 'Type header...'
1230
+ * },
1231
+ * content: {
1232
+ * element: document.querySelector( '#content' ),
1233
+ * placeholder: 'Type content...'
1234
+ * },
1235
+ * leftSide: {
1236
+ * element: document.querySelector( '#left-side' ),
1237
+ * placeholder: 'Type left-side...'
1238
+ * },
1239
+ * rightSide: {
1240
+ * element: document.querySelector( '#right-side' ),
1241
+ * placeholder: 'Type right-side...'
1242
+ * }
1243
+ * }
1244
+ * } )
1245
+ * .then( ... )
1246
+ * .catch( ... );
1247
+ * ```
1248
+ *
1249
+ * The placeholder text is displayed as a pseudo–element of an empty paragraph in the editor content.
1250
+ * The paragraph has the `.ck-placeholder` CSS class and the `data-placeholder` attribute.
1251
+ *
1252
+ * ```html
1253
+ * <p data-placeholder="Type some text..." class="ck-placeholder">
1254
+ * ::before
1255
+ * </p>
1256
+ * ```
1257
+ *
1258
+ * **Note**: Placeholder text can also be set using the `placeholder` attribute if a `<textarea>` is passed to
1259
+ * the `create()` method, e.g. {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
1260
+ *
1261
+ * **Note**: This configuration has precedence over the value of the `placeholder` attribute of a `<textarea>`
1262
+ * element passed to the `create()` method.
1263
+ *
1264
+ * See the {@glink features/editor-placeholder "Editor placeholder"} guide for more information and live examples.
1265
+ */
1266
+ placeholder?: string;
1267
+ /**
1268
+ * The name of the model root element to use for this editor root.
1269
+ *
1270
+ * By default, the editor creates model roots using the generic `$root` element, which allows all standard block
1271
+ * content (paragraphs, headings, lists, tables, etc.). You can set this option to a custom element name if you
1272
+ * need a root with different schema rules — for example, a root that restricts or extends what content is allowed
1273
+ * at the top level.
1274
+ *
1275
+ * The element name must be registered in the {@link module:engine/model/schema~ModelSchema schema} before or during
1276
+ * editor initialization. See the {@glink framework/deep-dive/schema "Schema"} guide for more information about
1277
+ * generic items like `$root` and `$inlineRoot`.
1278
+ *
1279
+ * ```ts
1280
+ * ClassicEditor
1281
+ * .create( {
1282
+ * root: {
1283
+ * modelElement: '$inlineRoot'
1284
+ * }
1285
+ * } )
1286
+ * .then( ... )
1287
+ * .catch( ... );
1288
+ * ```
1289
+ *
1290
+ * If your editor implementation uses multiple roots, you can set a different model element for each root:
1291
+ *
1292
+ * ```ts
1293
+ * MultiRootEditor.create( {
1294
+ * roots: {
1295
+ * header: {
1296
+ * modelElement: '$inlineRoot',
1297
+ * initialData: 'My document title'
1298
+ * },
1299
+ * content: {
1300
+ * initialData: '<p>Main content goes here.</p>'
1301
+ * }
1302
+ * }
1303
+ * } )
1304
+ * .then( ... )
1305
+ * .catch( ... );
1306
+ * ```
1307
+ *
1308
+ * @default '$root'
1309
+ */
1310
+ modelElement?: string;
1311
+ /**
1312
+ * Label which briefly describes this editing area.
1313
+ *
1314
+ * It is used for the `aria-label` attribute set on the editor editing area, helping assistive technologies
1315
+ * to tell apart multiple editor instances (editing areas) on the page. If not set, a default
1316
+ * "Rich Text Editor. Editing area [name of the area]" is used instead.
1317
+ *
1318
+ * It can also be used by other features when referring to this editing area.
1319
+ *
1320
+ * ```ts
1321
+ * ClassicEditor
1322
+ * .create( {
1323
+ * attachTo: document.querySelector( '#editor' ),
1324
+ * root: {
1325
+ * label: 'Article main content'
1326
+ * }
1327
+ * } )
1328
+ * .then( ... )
1329
+ * .catch( ... );
1330
+ * ```
1331
+ *
1332
+ * If your editor implementation uses multiple roots, you should provide config for roots individually:
1333
+ *
1334
+ * ```ts
1335
+ * MultiRootEditor.create( {
1336
+ * roots: {
1337
+ * header: {
1338
+ * element: document.querySelector( '#header' ),
1339
+ * label: 'Article header'
1340
+ * },
1341
+ * content: {
1342
+ * element: document.querySelector( '#content' ),
1343
+ * label: 'Article main content'
1344
+ * },
1345
+ * sideQuote: {
1346
+ * element: document.querySelector( '#side-quote' ),
1347
+ * label: 'Side-quote'
1348
+ * },
1349
+ * relatedLinks: {
1350
+ * element: document.querySelector( '#related-links' ),
1351
+ * label: 'Related links'
1352
+ * }
1353
+ * }
1354
+ * } )
1355
+ * .then( ... )
1356
+ * .catch( ... );
1357
+ * ```
1358
+ */
1359
+ label?: string;
1360
+ /**
1361
+ * An optional, longer description of this editing area. It is intended as a stable, human-readable identifier
1362
+ * so features can match a root across sessions, for instance AI features interacting with multiple editor instances
1363
+ * and multi-root editors.
1364
+ *
1365
+ * ```ts
1366
+ * ClassicEditor
1367
+ * .create( {
1368
+ * attachTo: document.querySelector( '#editor' ),
1369
+ * root: {
1370
+ * description: '...'
1371
+ * }
1372
+ * } )
1373
+ * .then( ... )
1374
+ * .catch( ... );
1375
+ * ```
1376
+ *
1377
+ * If your editor implementation uses multiple roots, you should provide config for roots individually:
1378
+ *
1379
+ * ```ts
1380
+ * MultiRootEditor.create( {
1381
+ * roots: {
1382
+ * chapter1: {
1383
+ * element: document.querySelector( '#chapter1' ),
1384
+ * description: 'Editing root for the first chapter.'
1385
+ * },
1386
+ * chapter2: {
1387
+ * element: document.querySelector( '#chapter2' ),
1388
+ * description: 'Editing root for the second chapter.'
1389
+ * },
1390
+ * chapter3: {
1391
+ * element: document.querySelector( '#chapter3' ),
1392
+ * description: 'Editing root for the third chapter.'
1393
+ * }
1394
+ * }
1395
+ * } )
1396
+ * .then( ... )
1397
+ * .catch( ... );
1398
+ * ```
1399
+ */
1400
+ description?: string;
1401
+ /**
1402
+ * An optional, human-readable name of this editing area.
1403
+ *
1404
+ * Unlike {@link #label `label`} (which is primarily used as the `aria-label` accessibility text), the title is
1405
+ * intended as a semantic name that features can present to users or send to external services. For instance, the
1406
+ * AI features use it to tell roots apart, so that requests scoped to a specific area ("edit the title",
1407
+ * "summarize the introduction") can be routed to the intended root.
1408
+ *
1409
+ * ```ts
1410
+ * ClassicEditor
1411
+ * .create( {
1412
+ * attachTo: document.querySelector( '#editor' ),
1413
+ * root: {
1414
+ * title: 'Article main content'
1415
+ * }
1416
+ * } )
1417
+ * .then( ... )
1418
+ * .catch( ... );
1419
+ * ```
1420
+ *
1421
+ * If your editor implementation uses multiple roots, you should provide config for roots individually:
1422
+ *
1423
+ * ```ts
1424
+ * MultiRootEditor.create( {
1425
+ * roots: {
1426
+ * header: {
1427
+ * element: document.querySelector( '#header' ),
1428
+ * title: 'Article header'
1429
+ * },
1430
+ * content: {
1431
+ * element: document.querySelector( '#content' ),
1432
+ * title: 'Article main content'
1433
+ * }
1434
+ * }
1435
+ * } )
1436
+ * .then( ... )
1437
+ * .catch( ... );
1438
+ * ```
1439
+ */
1440
+ title?: string;
1441
+ /**
1442
+ * Initial root attributes for a root.
1443
+ *
1444
+ * **Note: You must provide full set of attributes for each root. If an attribute is not set on a root, set the value to `null`.
1445
+ * Only provided attribute keys will be returned by {@link module:core/editor/editor~Editor#getRootAttributes} or
1446
+ * {@link module:editor-multi-root/multirooteditor~MultiRootEditor#getRootsAttributes}.**
1447
+ *
1448
+ * Roots attributes hold additional data related to the document roots, in addition to the regular document data (which usually is
1449
+ * HTML). In roots attributes, for each root, you can store arbitrary key-value pairs with attributes connected with that root.
1450
+ * Use it to store any custom data that is specific to your integration or custom features.
1451
+ *
1452
+ * Currently, any official plugins do not use root attributes. This is a mechanism that is prepared for custom features
1453
+ * and non-standard integrations. If you do not provide any custom feature that would use root attributes, you do not need to
1454
+ * handle (save and load) this property.
1455
+ *
1456
+ * ```ts
1457
+ * ClassicEditor.create( {
1458
+ * root: {
1459
+ * modelAttributes: { customAttribute: true }
1460
+ * }
1461
+ * } )
1462
+ * .then( ... )
1463
+ * .catch( ... );
1464
+ * ```
1465
+ *
1466
+ * If your editor implementation uses multiple roots, you should provide attributes for roots individually:
1467
+ *
1468
+ * ```ts
1469
+ * MultiRootEditor.create(
1470
+ * {
1471
+ * roots: {
1472
+ * uid1: {
1473
+ * // ... other root config
1474
+ * modelAttributes: { order: 20, isLocked: false } // Third, unlocked.
1475
+ * },
1476
+ * uid2: {
1477
+ * // ... other root config
1478
+ * modelAttributes: { order: 10, isLocked: true } // Second, locked.
1479
+ * },
1480
+ * uid3: {
1481
+ * // ... other root config
1482
+ * modelAttributes: { order: 30, isLocked: true } // Fourth, locked.
1483
+ * },
1484
+ * uid4: {
1485
+ * // ... other root config
1486
+ * modelAttributes: { order: 0, isLocked: false } // First, unlocked.
1487
+ * }
1488
+ * }
1489
+ * }
1490
+ * )
1491
+ * .then( ... )
1492
+ * .catch( ... );
1493
+ * ```
1494
+ *
1495
+ * Note, that the above code snippet is only an example. You need to implement your own features that will use these attributes.
1496
+ *
1497
+ * Roots attributes can be changed the same way as attributes set on other model nodes:
1498
+ *
1499
+ * ```ts
1500
+ * editor.model.change( writer => {
1501
+ * const root = editor.model.getRoot( 'uid3' );
1502
+ *
1503
+ * writer.setAttribute( 'order', 40, root );
1504
+ * } );
1505
+ * ```
1506
+ *
1507
+ * You can react to root attributes changes by listening to
1508
+ * {@link module:engine/model/document~ModelDocument#event:change:data document `change:data` event}:
1509
+ *
1510
+ * ```ts
1511
+ * editor.model.document.on( 'change:data', () => {
1512
+ * const changedRoots = editor.model.document.differ.getChangedRoots();
1513
+ *
1514
+ * for ( const change of changedRoots ) {
1515
+ * if ( change.attributes ) {
1516
+ * const root = editor.model.getRoot( change.name );
1517
+ *
1518
+ * // ...
1519
+ * }
1520
+ * }
1521
+ * } );
1522
+ * ```
1523
+ */
1524
+ modelAttributes?: EditorRootAttributes;
1485
1525
  }
1486
1526
  /**
1487
- * A description of the DOM element used as an editor's editable root, accepted by
1488
- * {@link module:core/editor/editorconfig~RootConfig#element `config.root.element`}.
1489
- *
1490
- * ```ts
1491
- * const element: ViewRootElementDefinition = {
1492
- * name: 'h1',
1493
- * classes: [ 'article-title' ],
1494
- * styles: { 'font-weight': 'bold' },
1495
- * attributes: { 'data-id': '123' }
1496
- * };
1497
- * ```
1498
- *
1499
- * `class` and `style` may also be passed as strings inside `attributes` as a shorthand:
1500
- *
1501
- * ```ts
1502
- * const element: ViewRootElementDefinition = {
1503
- * name: 'h1',
1504
- * attributes: { class: 'article-title', style: 'font-weight: bold' }
1505
- * };
1506
- * ```
1507
- */
1527
+ * A description of the DOM element used as an editor's editable root, accepted by
1528
+ * {@link module:core/editor/editorconfig~RootConfig#element `config.root.element`}.
1529
+ *
1530
+ * ```ts
1531
+ * const element: ViewRootElementDefinition = {
1532
+ * name: 'h1',
1533
+ * classes: [ 'article-title' ],
1534
+ * styles: { 'font-weight': 'bold' },
1535
+ * attributes: { 'data-id': '123' }
1536
+ * };
1537
+ * ```
1538
+ *
1539
+ * `class` and `style` may also be passed as strings inside `attributes` as a shorthand:
1540
+ *
1541
+ * ```ts
1542
+ * const element: ViewRootElementDefinition = {
1543
+ * name: 'h1',
1544
+ * attributes: { class: 'article-title', style: 'font-weight: bold' }
1545
+ * };
1546
+ * ```
1547
+ */
1508
1548
  export interface ViewRootElementDefinition {
1509
- /**
1510
- * The DOM tag name to use. Defaults to `'div'` when not provided, so integrators can keep the default element and
1511
- * still specify {@link #classes}, {@link #styles}, or {@link #attributes}.
1512
- */
1513
- name?: string;
1514
- /**
1515
- * Class name or array of class names to apply to the editable element. Each name can be provided as a string.
1516
- */
1517
- classes?: string | Array<string>;
1518
- /**
1519
- * Inline styles to apply to the editable element as a record of style properties.
1520
- */
1521
- styles?: Record<string, string>;
1522
- /**
1523
- * Additional DOM attributes to apply to the editable element.
1524
- */
1525
- attributes?: Record<string, string>;
1549
+ /**
1550
+ * The DOM tag name to use. Defaults to `'div'` when not provided, so integrators can keep the default element and
1551
+ * still specify {@link #classes}, {@link #styles}, or {@link #attributes}.
1552
+ */
1553
+ name?: string;
1554
+ /**
1555
+ * Class name or array of class names to apply to the editable element. Each name can be provided as a string.
1556
+ */
1557
+ classes?: string | Array<string>;
1558
+ /**
1559
+ * Inline styles to apply to the editable element as a record of style properties.
1560
+ */
1561
+ styles?: Record<string, string>;
1562
+ /**
1563
+ * Additional DOM attributes to apply to the editable element.
1564
+ */
1565
+ attributes?: Record<string, string>;
1526
1566
  }
1527
1567
  /**
1528
- * The configuration of the editor language.
1529
- *
1530
- * ```ts
1531
- * ClassicEditor
1532
- * .create( {
1533
- * attachTo: document.querySelector( '#editor' ),
1534
- * language: ... // The editor language configuration.
1535
- * } )
1536
- * .then( editor => {
1537
- * console.log( editor );
1538
- * } )
1539
- * .catch( error => {
1540
- * console.error( error );
1541
- * } );
1542
- * ```
1543
- *
1544
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
1545
- */
1568
+ * The configuration of the editor language.
1569
+ *
1570
+ * ```ts
1571
+ * ClassicEditor
1572
+ * .create( {
1573
+ * attachTo: document.querySelector( '#editor' ),
1574
+ * language: ... // The editor language configuration.
1575
+ * } )
1576
+ * .then( editor => {
1577
+ * console.log( editor );
1578
+ * } )
1579
+ * .catch( error => {
1580
+ * console.error( error );
1581
+ * } );
1582
+ * ```
1583
+ *
1584
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
1585
+ */
1546
1586
  export interface LanguageConfig {
1547
- /**
1548
- * Allows to use a different language for the editor UI.
1549
- *
1550
- * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
1551
- */
1552
- ui?: string;
1553
- /**
1554
- * Allows to use a different language of the editor content.
1555
- *
1556
- * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
1557
- */
1558
- content?: string;
1587
+ /**
1588
+ * Allows to use a different language for the editor UI.
1589
+ *
1590
+ * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
1591
+ */
1592
+ ui?: string;
1593
+ /**
1594
+ * Allows to use a different language of the editor content.
1595
+ *
1596
+ * The language codes are defined in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) standard.
1597
+ */
1598
+ content?: string;
1559
1599
  }
1560
1600
  export type ToolbarConfig = Array<ToolbarConfigItem> | {
1561
- items?: Array<ToolbarConfigItem>;
1562
- removeItems?: Array<string>;
1563
- shouldNotGroupWhenFull?: boolean;
1564
- icon?: string;
1601
+ items?: Array<ToolbarConfigItem>;
1602
+ removeItems?: Array<string>;
1603
+ shouldNotGroupWhenFull?: boolean;
1604
+ icon?: string;
1565
1605
  };
1566
1606
  export type ToolbarConfigItem = string | {
1567
- items: Array<ToolbarConfigItem>;
1568
- label: string;
1569
- icon?: string | false;
1570
- withText?: boolean;
1571
- tooltip?: boolean | string | ((label: string, keystroke: string | undefined) => string);
1607
+ items: Array<ToolbarConfigItem>;
1608
+ label: string;
1609
+ icon?: string | false;
1610
+ withText?: boolean;
1611
+ tooltip?: boolean | string | ((label: string, keystroke: string | undefined) => string);
1572
1612
  };
1573
1613
  /**
1574
- * The “Powered by CKEditor” logo configuration options.
1575
- **/
1614
+ * The “Powered by CKEditor” logo configuration options.
1615
+ **/
1576
1616
  export interface PoweredByConfig {
1577
- /**
1578
- * The position of the project's logo.
1579
- *
1580
- * * When `'inside'`, the logo will be displayed within the boundaries of the editing area.
1581
- * * When `'border'`, the logo will be displayed over the bottom border of the editing area.
1582
- *
1583
- * @default 'border'
1584
- */
1585
- position?: 'inside' | 'border';
1586
- /**
1587
- * Allows choosing the side of the editing area where the logo will be displayed.
1588
- *
1589
- * **Note:** If {@link module:core/editor/editorconfig~EditorConfig#language `config.language`} is set to an RTL (right-to-left)
1590
- * language, the side switches to `'left'` by default.
1591
- *
1592
- * @default 'right'
1593
- */
1594
- side?: 'left' | 'right';
1595
- /**
1596
- * Allows changing the label displayed next to the CKEditor logo.
1597
- *
1598
- * **Note:** Set the value to `null` to hide the label.
1599
- *
1600
- * @default 'Powered by'
1601
- */
1602
- label?: string | null;
1603
- /**
1604
- * The vertical distance the logo can be moved away from its default position.
1605
- *
1606
- * **Note:** If `position` is `'border'`, the offset is measured from the (vertical) center of the logo.
1607
- *
1608
- * @default 5
1609
- */
1610
- verticalOffset?: number;
1611
- /**
1612
- * The horizontal distance between the side of the editing root and the nearest side of the logo.
1613
- *
1614
- * @default 5
1615
- */
1616
- horizontalOffset?: number;
1617
- /**
1618
- * Allows to show the logo even if the valid commercial license is configured using
1619
- * the {@link module:core/editor/editorconfig~EditorConfig#licenseKey `config.licenseKey`} setting.
1620
- *
1621
- * @default false
1622
- */
1623
- forceVisible?: boolean;
1617
+ /**
1618
+ * The position of the project's logo.
1619
+ *
1620
+ * * When `'inside'`, the logo will be displayed within the boundaries of the editing area.
1621
+ * * When `'border'`, the logo will be displayed over the bottom border of the editing area.
1622
+ *
1623
+ * @default 'border'
1624
+ */
1625
+ position?: "inside" | "border";
1626
+ /**
1627
+ * Allows choosing the side of the editing area where the logo will be displayed.
1628
+ *
1629
+ * **Note:** If {@link module:core/editor/editorconfig~EditorConfig#language `config.language`} is set to an RTL (right-to-left)
1630
+ * language, the side switches to `'left'` by default.
1631
+ *
1632
+ * @default 'right'
1633
+ */
1634
+ side?: "left" | "right";
1635
+ /**
1636
+ * Allows changing the label displayed next to the CKEditor logo.
1637
+ *
1638
+ * **Note:** Set the value to `null` to hide the label.
1639
+ *
1640
+ * @default 'Powered by'
1641
+ */
1642
+ label?: string | null;
1643
+ /**
1644
+ * The vertical distance the logo can be moved away from its default position.
1645
+ *
1646
+ * **Note:** If `position` is `'border'`, the offset is measured from the (vertical) center of the logo.
1647
+ *
1648
+ * @default 5
1649
+ */
1650
+ verticalOffset?: number;
1651
+ /**
1652
+ * The horizontal distance between the side of the editing root and the nearest side of the logo.
1653
+ *
1654
+ * @default 5
1655
+ */
1656
+ horizontalOffset?: number;
1657
+ /**
1658
+ * Allows to show the logo even if the valid commercial license is configured using
1659
+ * the {@link module:core/editor/editorconfig~EditorConfig#licenseKey `config.licenseKey`} setting.
1660
+ *
1661
+ * @default false
1662
+ */
1663
+ forceVisible?: boolean;
1624
1664
  }
1625
1665
  /**
1626
- * The offset (in pixels) of the viewport from every direction used when positioning a sticky toolbar or other
1627
- * absolutely positioned UI elements.
1628
- */
1666
+ * The offset (in pixels) of the viewport from every direction used when positioning a sticky toolbar or other
1667
+ * absolutely positioned UI elements.
1668
+ */
1629
1669
  export interface ViewportOffsetConfig {
1630
- /**
1631
- * The bottom offset in pixels.
1632
- */
1633
- bottom?: number;
1634
- /**
1635
- * The left offset in pixels.
1636
- */
1637
- left?: number;
1638
- /**
1639
- * The right offset in pixels.
1640
- */
1641
- right?: number;
1642
- /**
1643
- * The top offset in pixels.
1644
- */
1645
- top?: number;
1670
+ /**
1671
+ * The bottom offset in pixels.
1672
+ */
1673
+ bottom?: number;
1674
+ /**
1675
+ * The left offset in pixels.
1676
+ */
1677
+ left?: number;
1678
+ /**
1679
+ * The right offset in pixels.
1680
+ */
1681
+ right?: number;
1682
+ /**
1683
+ * The top offset in pixels.
1684
+ */
1685
+ top?: number;
1646
1686
  }
1647
1687
  export interface UiConfig {
1648
- /**
1649
- * The viewport offset used for positioning various absolutely positioned UI elements.
1650
- *
1651
- * Read more in {@link module:core/editor/editorconfig~ViewportOffsetConfig}.
1652
- **/
1653
- viewportOffset?: ViewportOffsetConfig;
1654
- /**
1655
- * The configuration of the “Powered by CKEditor” logo.
1656
- *
1657
- * Read more in {@link module:core/editor/editorconfig~PoweredByConfig}.
1658
- **/
1659
- poweredBy?: PoweredByConfig;
1688
+ /**
1689
+ * The viewport offset used for positioning various absolutely positioned UI elements.
1690
+ *
1691
+ * Read more in {@link module:core/editor/editorconfig~ViewportOffsetConfig}.
1692
+ **/
1693
+ viewportOffset?: ViewportOffsetConfig;
1694
+ /**
1695
+ * The configuration of the “Powered by CKEditor” logo.
1696
+ *
1697
+ * Read more in {@link module:core/editor/editorconfig~PoweredByConfig}.
1698
+ **/
1699
+ poweredBy?: PoweredByConfig;
1660
1700
  }