@ckeditor/ckeditor5-core 41.3.1 → 41.4.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 (243) hide show
  1. package/dist/index-content.css +4 -0
  2. package/dist/index-editor.css +4 -0
  3. package/dist/index.css +4 -0
  4. package/dist/index.js +2132 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/translations/af.d.ts +8 -0
  7. package/dist/translations/af.js +5 -0
  8. package/dist/translations/af.umd.js +11 -0
  9. package/dist/translations/ar.d.ts +8 -0
  10. package/dist/translations/ar.js +5 -0
  11. package/dist/translations/ar.umd.js +11 -0
  12. package/dist/translations/ast.d.ts +8 -0
  13. package/dist/translations/ast.js +5 -0
  14. package/dist/translations/ast.umd.js +11 -0
  15. package/dist/translations/az.d.ts +8 -0
  16. package/dist/translations/az.js +5 -0
  17. package/dist/translations/az.umd.js +11 -0
  18. package/dist/translations/bg.d.ts +8 -0
  19. package/dist/translations/bg.js +5 -0
  20. package/dist/translations/bg.umd.js +11 -0
  21. package/dist/translations/bn.d.ts +8 -0
  22. package/dist/translations/bn.js +5 -0
  23. package/dist/translations/bn.umd.js +11 -0
  24. package/dist/translations/bs.d.ts +8 -0
  25. package/dist/translations/bs.js +5 -0
  26. package/dist/translations/bs.umd.js +11 -0
  27. package/dist/translations/ca.d.ts +8 -0
  28. package/dist/translations/ca.js +5 -0
  29. package/dist/translations/ca.umd.js +11 -0
  30. package/dist/translations/cs.d.ts +8 -0
  31. package/dist/translations/cs.js +5 -0
  32. package/dist/translations/cs.umd.js +11 -0
  33. package/dist/translations/da.d.ts +8 -0
  34. package/dist/translations/da.js +5 -0
  35. package/dist/translations/da.umd.js +11 -0
  36. package/dist/translations/de-ch.d.ts +8 -0
  37. package/dist/translations/de-ch.js +5 -0
  38. package/dist/translations/de-ch.umd.js +11 -0
  39. package/dist/translations/de.d.ts +8 -0
  40. package/dist/translations/de.js +5 -0
  41. package/dist/translations/de.umd.js +11 -0
  42. package/dist/translations/el.d.ts +8 -0
  43. package/dist/translations/el.js +5 -0
  44. package/dist/translations/el.umd.js +11 -0
  45. package/dist/translations/en-au.d.ts +8 -0
  46. package/dist/translations/en-au.js +5 -0
  47. package/dist/translations/en-au.umd.js +11 -0
  48. package/dist/translations/en-gb.d.ts +8 -0
  49. package/dist/translations/en-gb.js +5 -0
  50. package/dist/translations/en-gb.umd.js +11 -0
  51. package/dist/translations/en.d.ts +8 -0
  52. package/dist/translations/en.js +5 -0
  53. package/dist/translations/en.umd.js +11 -0
  54. package/dist/translations/eo.d.ts +8 -0
  55. package/dist/translations/eo.js +5 -0
  56. package/dist/translations/eo.umd.js +11 -0
  57. package/dist/translations/es-co.d.ts +8 -0
  58. package/dist/translations/es-co.js +5 -0
  59. package/dist/translations/es-co.umd.js +11 -0
  60. package/dist/translations/es.d.ts +8 -0
  61. package/dist/translations/es.js +5 -0
  62. package/dist/translations/es.umd.js +11 -0
  63. package/dist/translations/et.d.ts +8 -0
  64. package/dist/translations/et.js +5 -0
  65. package/dist/translations/et.umd.js +11 -0
  66. package/dist/translations/eu.d.ts +8 -0
  67. package/dist/translations/eu.js +5 -0
  68. package/dist/translations/eu.umd.js +11 -0
  69. package/dist/translations/fa.d.ts +8 -0
  70. package/dist/translations/fa.js +5 -0
  71. package/dist/translations/fa.umd.js +11 -0
  72. package/dist/translations/fi.d.ts +8 -0
  73. package/dist/translations/fi.js +5 -0
  74. package/dist/translations/fi.umd.js +11 -0
  75. package/dist/translations/fr.d.ts +8 -0
  76. package/dist/translations/fr.js +5 -0
  77. package/dist/translations/fr.umd.js +11 -0
  78. package/dist/translations/gl.d.ts +8 -0
  79. package/dist/translations/gl.js +5 -0
  80. package/dist/translations/gl.umd.js +11 -0
  81. package/dist/translations/gu.d.ts +8 -0
  82. package/dist/translations/gu.js +5 -0
  83. package/dist/translations/gu.umd.js +11 -0
  84. package/dist/translations/he.d.ts +8 -0
  85. package/dist/translations/he.js +5 -0
  86. package/dist/translations/he.umd.js +11 -0
  87. package/dist/translations/hi.d.ts +8 -0
  88. package/dist/translations/hi.js +5 -0
  89. package/dist/translations/hi.umd.js +11 -0
  90. package/dist/translations/hr.d.ts +8 -0
  91. package/dist/translations/hr.js +5 -0
  92. package/dist/translations/hr.umd.js +11 -0
  93. package/dist/translations/hu.d.ts +8 -0
  94. package/dist/translations/hu.js +5 -0
  95. package/dist/translations/hu.umd.js +11 -0
  96. package/dist/translations/hy.d.ts +8 -0
  97. package/dist/translations/hy.js +5 -0
  98. package/dist/translations/hy.umd.js +11 -0
  99. package/dist/translations/id.d.ts +8 -0
  100. package/dist/translations/id.js +5 -0
  101. package/dist/translations/id.umd.js +11 -0
  102. package/dist/translations/it.d.ts +8 -0
  103. package/dist/translations/it.js +5 -0
  104. package/dist/translations/it.umd.js +11 -0
  105. package/dist/translations/ja.d.ts +8 -0
  106. package/dist/translations/ja.js +5 -0
  107. package/dist/translations/ja.umd.js +11 -0
  108. package/dist/translations/jv.d.ts +8 -0
  109. package/dist/translations/jv.js +5 -0
  110. package/dist/translations/jv.umd.js +11 -0
  111. package/dist/translations/km.d.ts +8 -0
  112. package/dist/translations/km.js +5 -0
  113. package/dist/translations/km.umd.js +11 -0
  114. package/dist/translations/kn.d.ts +8 -0
  115. package/dist/translations/kn.js +5 -0
  116. package/dist/translations/kn.umd.js +11 -0
  117. package/dist/translations/ko.d.ts +8 -0
  118. package/dist/translations/ko.js +5 -0
  119. package/dist/translations/ko.umd.js +11 -0
  120. package/dist/translations/ku.d.ts +8 -0
  121. package/dist/translations/ku.js +5 -0
  122. package/dist/translations/ku.umd.js +11 -0
  123. package/dist/translations/lt.d.ts +8 -0
  124. package/dist/translations/lt.js +5 -0
  125. package/dist/translations/lt.umd.js +11 -0
  126. package/dist/translations/lv.d.ts +8 -0
  127. package/dist/translations/lv.js +5 -0
  128. package/dist/translations/lv.umd.js +11 -0
  129. package/dist/translations/ms.d.ts +8 -0
  130. package/dist/translations/ms.js +5 -0
  131. package/dist/translations/ms.umd.js +11 -0
  132. package/dist/translations/nb.d.ts +8 -0
  133. package/dist/translations/nb.js +5 -0
  134. package/dist/translations/nb.umd.js +11 -0
  135. package/dist/translations/ne.d.ts +8 -0
  136. package/dist/translations/ne.js +5 -0
  137. package/dist/translations/ne.umd.js +11 -0
  138. package/dist/translations/nl.d.ts +8 -0
  139. package/dist/translations/nl.js +5 -0
  140. package/dist/translations/nl.umd.js +11 -0
  141. package/dist/translations/no.d.ts +8 -0
  142. package/dist/translations/no.js +5 -0
  143. package/dist/translations/no.umd.js +11 -0
  144. package/dist/translations/oc.d.ts +8 -0
  145. package/dist/translations/oc.js +5 -0
  146. package/dist/translations/oc.umd.js +11 -0
  147. package/dist/translations/pl.d.ts +8 -0
  148. package/dist/translations/pl.js +5 -0
  149. package/dist/translations/pl.umd.js +11 -0
  150. package/dist/translations/pt-br.d.ts +8 -0
  151. package/dist/translations/pt-br.js +5 -0
  152. package/dist/translations/pt-br.umd.js +11 -0
  153. package/dist/translations/pt.d.ts +8 -0
  154. package/dist/translations/pt.js +5 -0
  155. package/dist/translations/pt.umd.js +11 -0
  156. package/dist/translations/ro.d.ts +8 -0
  157. package/dist/translations/ro.js +5 -0
  158. package/dist/translations/ro.umd.js +11 -0
  159. package/dist/translations/ru.d.ts +8 -0
  160. package/dist/translations/ru.js +5 -0
  161. package/dist/translations/ru.umd.js +11 -0
  162. package/dist/translations/si.d.ts +8 -0
  163. package/dist/translations/si.js +5 -0
  164. package/dist/translations/si.umd.js +11 -0
  165. package/dist/translations/sk.d.ts +8 -0
  166. package/dist/translations/sk.js +5 -0
  167. package/dist/translations/sk.umd.js +11 -0
  168. package/dist/translations/sl.d.ts +8 -0
  169. package/dist/translations/sl.js +5 -0
  170. package/dist/translations/sl.umd.js +11 -0
  171. package/dist/translations/sq.d.ts +8 -0
  172. package/dist/translations/sq.js +5 -0
  173. package/dist/translations/sq.umd.js +11 -0
  174. package/dist/translations/sr-latn.d.ts +8 -0
  175. package/dist/translations/sr-latn.js +5 -0
  176. package/dist/translations/sr-latn.umd.js +11 -0
  177. package/dist/translations/sr.d.ts +8 -0
  178. package/dist/translations/sr.js +5 -0
  179. package/dist/translations/sr.umd.js +11 -0
  180. package/dist/translations/sv.d.ts +8 -0
  181. package/dist/translations/sv.js +5 -0
  182. package/dist/translations/sv.umd.js +11 -0
  183. package/dist/translations/th.d.ts +8 -0
  184. package/dist/translations/th.js +5 -0
  185. package/dist/translations/th.umd.js +11 -0
  186. package/dist/translations/ti.d.ts +8 -0
  187. package/dist/translations/ti.js +5 -0
  188. package/dist/translations/ti.umd.js +11 -0
  189. package/dist/translations/tk.d.ts +8 -0
  190. package/dist/translations/tk.js +5 -0
  191. package/dist/translations/tk.umd.js +11 -0
  192. package/dist/translations/tr.d.ts +8 -0
  193. package/dist/translations/tr.js +5 -0
  194. package/dist/translations/tr.umd.js +11 -0
  195. package/dist/translations/tt.d.ts +8 -0
  196. package/dist/translations/tt.js +5 -0
  197. package/dist/translations/tt.umd.js +11 -0
  198. package/dist/translations/ug.d.ts +8 -0
  199. package/dist/translations/ug.js +5 -0
  200. package/dist/translations/ug.umd.js +11 -0
  201. package/dist/translations/uk.d.ts +8 -0
  202. package/dist/translations/uk.js +5 -0
  203. package/dist/translations/uk.umd.js +11 -0
  204. package/dist/translations/ur.d.ts +8 -0
  205. package/dist/translations/ur.js +5 -0
  206. package/dist/translations/ur.umd.js +11 -0
  207. package/dist/translations/uz.d.ts +8 -0
  208. package/dist/translations/uz.js +5 -0
  209. package/dist/translations/uz.umd.js +11 -0
  210. package/dist/translations/vi.d.ts +8 -0
  211. package/dist/translations/vi.js +5 -0
  212. package/dist/translations/vi.umd.js +11 -0
  213. package/dist/translations/zh-cn.d.ts +8 -0
  214. package/dist/translations/zh-cn.js +5 -0
  215. package/dist/translations/zh-cn.umd.js +11 -0
  216. package/dist/translations/zh.d.ts +8 -0
  217. package/dist/translations/zh.js +5 -0
  218. package/dist/translations/zh.umd.js +11 -0
  219. package/dist/types/accessibility.d.ts +365 -0
  220. package/dist/types/augmentation.d.ts +14 -0
  221. package/dist/types/command.d.ts +193 -0
  222. package/dist/types/commandcollection.d.ts +87 -0
  223. package/dist/types/context.d.ts +241 -0
  224. package/dist/types/contextplugin.d.ts +65 -0
  225. package/dist/types/editingkeystrokehandler.d.ts +60 -0
  226. package/dist/types/editor/editor.d.ts +482 -0
  227. package/dist/types/editor/editorconfig.d.ts +936 -0
  228. package/dist/types/editor/utils/attachtoform.d.ts +19 -0
  229. package/dist/types/editor/utils/dataapimixin.d.ts +83 -0
  230. package/dist/types/editor/utils/elementapimixin.d.ts +39 -0
  231. package/dist/types/editor/utils/securesourceelement.d.ts +21 -0
  232. package/dist/types/index.d.ts +94 -0
  233. package/dist/types/multicommand.d.ts +70 -0
  234. package/dist/types/pendingactions.d.ts +121 -0
  235. package/dist/types/plugin.d.ts +278 -0
  236. package/dist/types/plugincollection.d.ts +121 -0
  237. package/dist/types/typings.d.ts +16 -0
  238. package/lang/translations/ti.po +126 -0
  239. package/package.json +4 -3
  240. package/src/index.d.ts +2 -1
  241. package/src/index.js +2 -0
  242. package/src/typings.d.ts +1 -0
  243. package/theme/icons/object-size-custom.svg +1 -0
@@ -0,0 +1,241 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module core/context
11
+ */
12
+ import { Config, Collection, Locale, type LocaleTranslate } from '@ckeditor/ckeditor5-utils';
13
+ import PluginCollection from './plugincollection.js';
14
+ import type Editor from './editor/editor.js';
15
+ import type { LoadedPlugins, PluginConstructor } from './plugin.js';
16
+ import type { EditorConfig } from './editor/editorconfig.js';
17
+ /**
18
+ * Provides a common, higher-level environment for solutions that use multiple {@link module:core/editor/editor~Editor editors}
19
+ * or plugins that work outside the editor. Use it instead of {@link module:core/editor/editor~Editor.create `Editor.create()`}
20
+ * in advanced application integrations.
21
+ *
22
+ * All configuration options passed to a context will be used as default options for the editor instances initialized in that context.
23
+ *
24
+ * {@link module:core/contextplugin~ContextPlugin Context plugins} passed to a context instance will be shared among all
25
+ * editor instances initialized in this context. These will be the same plugin instances for all the editors.
26
+ *
27
+ * **Note:** The context can only be initialized with {@link module:core/contextplugin~ContextPlugin context plugins}
28
+ * (e.g. [comments](https://ckeditor.com/collaboration/comments/)). Regular {@link module:core/plugin~Plugin plugins} require an
29
+ * editor instance to work and cannot be added to a context.
30
+ *
31
+ * **Note:** You can add a context plugin to an editor instance, though.
32
+ *
33
+ * If you are using multiple editor instances on one page and use any context plugins, create a context to share the configuration and
34
+ * plugins among these editors. Some plugins will use the information about all existing editors to better integrate between them.
35
+ *
36
+ * If you are using plugins that do not require an editor to work (e.g. [comments](https://ckeditor.com/collaboration/comments/)),
37
+ * enable and configure them using the context.
38
+ *
39
+ * If you are using only a single editor on each page, use {@link module:core/editor/editor~Editor.create `Editor.create()`} instead.
40
+ * In such a case, a context instance will be created by the editor instance in a transparent way.
41
+ *
42
+ * See {@link ~Context.create `Context.create()`} for usage examples.
43
+ */
44
+ export default class Context {
45
+ /**
46
+ * Stores all the configurations specific to this context instance.
47
+ */
48
+ readonly config: Config<ContextConfig>;
49
+ /**
50
+ * The plugins loaded and in use by this context instance.
51
+ */
52
+ readonly plugins: PluginCollection<Context | Editor>;
53
+ readonly locale: Locale;
54
+ /**
55
+ * Shorthand for {@link module:utils/locale~Locale#t}.
56
+ */
57
+ readonly t: LocaleTranslate;
58
+ /**
59
+ * A list of editors that this context instance is injected to.
60
+ */
61
+ readonly editors: Collection<Editor>;
62
+ /**
63
+ * The default configuration which is built into the `Context` class.
64
+ *
65
+ * It is used in CKEditor 5 builds featuring `Context` to provide the default configuration options which are later used during the
66
+ * context initialization.
67
+ *
68
+ * ```ts
69
+ * Context.defaultConfig = {
70
+ * foo: 1,
71
+ * bar: 2
72
+ * };
73
+ *
74
+ * Context
75
+ * .create()
76
+ * .then( context => {
77
+ * context.config.get( 'foo' ); // -> 1
78
+ * context.config.get( 'bar' ); // -> 2
79
+ * } );
80
+ *
81
+ * // The default options can be overridden by the configuration passed to create().
82
+ * Context
83
+ * .create( { bar: 3 } )
84
+ * .then( context => {
85
+ * context.config.get( 'foo' ); // -> 1
86
+ * context.config.get( 'bar' ); // -> 3
87
+ * } );
88
+ * ```
89
+ *
90
+ * See also {@link module:core/context~Context.builtinPlugins `Context.builtinPlugins`}
91
+ * and {@link module:core/editor/editor~Editor.defaultConfig `Editor.defaultConfig`}.
92
+ */
93
+ static defaultConfig: ContextConfig;
94
+ /**
95
+ * An array of plugins built into the `Context` class.
96
+ *
97
+ * It is used in CKEditor 5 builds featuring `Context` to provide a list of context plugins which are later automatically initialized
98
+ * during the context initialization.
99
+ *
100
+ * They will be automatically initialized by `Context` unless `config.plugins` is passed.
101
+ *
102
+ * ```ts
103
+ * // Build some context plugins into the Context class first.
104
+ * Context.builtinPlugins = [ FooPlugin, BarPlugin ];
105
+ *
106
+ * // Normally, you need to define config.plugins, but since Context.builtinPlugins was
107
+ * // defined, now you can call create() without any configuration.
108
+ * Context
109
+ * .create()
110
+ * .then( context => {
111
+ * context.plugins.get( FooPlugin ); // -> An instance of the Foo plugin.
112
+ * context.plugins.get( BarPlugin ); // -> An instance of the Bar plugin.
113
+ * } );
114
+ * ```
115
+ *
116
+ * See also {@link module:core/context~Context.defaultConfig `Context.defaultConfig`}
117
+ * and {@link module:core/editor/editor~Editor.builtinPlugins `Editor.builtinPlugins`}.
118
+ */
119
+ static builtinPlugins: Array<PluginConstructor<Context | Editor>>;
120
+ /**
121
+ * Reference to the editor which created the context.
122
+ * Null when the context was created outside of the editor.
123
+ *
124
+ * It is used to destroy the context when removing the editor that has created the context.
125
+ */
126
+ private _contextOwner;
127
+ /**
128
+ * Creates a context instance with a given configuration.
129
+ *
130
+ * Usually not to be used directly. See the static {@link module:core/context~Context.create `create()`} method.
131
+ *
132
+ * @param config The context configuration.
133
+ */
134
+ constructor(config?: ContextConfig);
135
+ /**
136
+ * Loads and initializes plugins specified in the configuration.
137
+ *
138
+ * @returns A promise which resolves once the initialization is completed, providing an array of loaded plugins.
139
+ */
140
+ initPlugins(): Promise<LoadedPlugins>;
141
+ /**
142
+ * Destroys the context instance and all editors used with the context,
143
+ * releasing all resources used by the context.
144
+ *
145
+ * @returns A promise that resolves once the context instance is fully destroyed.
146
+ */
147
+ destroy(): Promise<unknown>;
148
+ /**
149
+ * Adds a reference to the editor which is used with this context.
150
+ *
151
+ * When the given editor has created the context, the reference to this editor will be stored
152
+ * as a {@link ~Context#_contextOwner}.
153
+ *
154
+ * This method should only be used by the editor.
155
+ *
156
+ * @internal
157
+ * @param isContextOwner Stores the given editor as a context owner.
158
+ */
159
+ _addEditor(editor: Editor, isContextOwner: boolean): void;
160
+ /**
161
+ * Removes a reference to the editor which was used with this context.
162
+ * When the context was created by the given editor, the context will be destroyed.
163
+ *
164
+ * This method should only be used by the editor.
165
+ *
166
+ * @internal
167
+ * @return A promise that resolves once the editor is removed from the context or when the context was destroyed.
168
+ */
169
+ _removeEditor(editor: Editor): Promise<unknown>;
170
+ /**
171
+ * Returns the context configuration which will be copied to the editors created using this context.
172
+ *
173
+ * The configuration returned by this method has the plugins configuration removed &ndash; plugins are shared with all editors
174
+ * through another mechanism.
175
+ *
176
+ * This method should only be used by the editor.
177
+ *
178
+ * @internal
179
+ * @returns Configuration as a plain object.
180
+ */
181
+ _getEditorConfig(): Partial<EditorConfig>;
182
+ /**
183
+ * Creates and initializes a new context instance.
184
+ *
185
+ * ```ts
186
+ * const commonConfig = { ... }; // Configuration for all the plugins and editors.
187
+ * const editorPlugins = [ ... ]; // Regular plugins here.
188
+ *
189
+ * Context
190
+ * .create( {
191
+ * // Only context plugins here.
192
+ * plugins: [ ... ],
193
+ *
194
+ * // Configure the language for all the editors (it cannot be overwritten).
195
+ * language: { ... },
196
+ *
197
+ * // Configuration for context plugins.
198
+ * comments: { ... },
199
+ * ...
200
+ *
201
+ * // Default configuration for editor plugins.
202
+ * toolbar: { ... },
203
+ * image: { ... },
204
+ * ...
205
+ * } )
206
+ * .then( context => {
207
+ * const promises = [];
208
+ *
209
+ * promises.push( ClassicEditor.create(
210
+ * document.getElementById( 'editor1' ),
211
+ * {
212
+ * editorPlugins,
213
+ * context
214
+ * }
215
+ * ) );
216
+ *
217
+ * promises.push( ClassicEditor.create(
218
+ * document.getElementById( 'editor2' ),
219
+ * {
220
+ * editorPlugins,
221
+ * context,
222
+ * toolbar: { ... } // You can overwrite the configuration of the context.
223
+ * }
224
+ * ) );
225
+ *
226
+ * return Promise.all( promises );
227
+ * } );
228
+ * ```
229
+ *
230
+ * @param config The context configuration.
231
+ * @returns A promise resolved once the context is ready. The promise resolves with the created context instance.
232
+ */
233
+ static create(config?: ContextConfig): Promise<Context>;
234
+ }
235
+ /**
236
+ * The context configuration.
237
+ */
238
+ export type ContextConfig = {
239
+ plugins?: Array<PluginConstructor<Context | Editor>>;
240
+ substitutePlugins?: Array<PluginConstructor<Context | Editor>>;
241
+ } & Omit<EditorConfig, 'plugins' | 'substitutePlugins' | 'removePlugins' | 'extraPlugins'>;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module core/contextplugin
11
+ */
12
+ import { type Collection, type Config, type Locale, type LocaleTranslate } from '@ckeditor/ckeditor5-utils';
13
+ import type Editor from './editor/editor.js';
14
+ import type { EditorConfig } from './editor/editorconfig.js';
15
+ import type Context from './context.js';
16
+ import type { PluginDependencies, PluginInterface } from './plugin.js';
17
+ import type PluginCollection from './plugincollection.js';
18
+ declare const ContextPlugin_base: {
19
+ new (): import("@ckeditor/ckeditor5-utils").Observable;
20
+ prototype: import("@ckeditor/ckeditor5-utils").Observable;
21
+ };
22
+ /**
23
+ * The base class for {@link module:core/context~Context} plugin classes.
24
+ *
25
+ * A context plugin can either be initialized for an {@link module:core/editor/editor~Editor editor} or for
26
+ * a {@link module:core/context~Context context}. In other words, it can either
27
+ * work within one editor instance or with one or more editor instances that use a single context.
28
+ * It is the context plugin's role to implement handling for both modes.
29
+ *
30
+ * There are a few rules for interaction between the editor plugins and context plugins:
31
+ *
32
+ * * A context plugin can require another context plugin.
33
+ * * An {@link module:core/plugin~Plugin editor plugin} can require a context plugin.
34
+ * * A context plugin MUST NOT require an {@link module:core/plugin~Plugin editor plugin}.
35
+ */
36
+ export default class ContextPlugin extends ContextPlugin_base implements PluginInterface {
37
+ /**
38
+ * The context or editor instance.
39
+ */
40
+ readonly context: ContextInterface;
41
+ /**
42
+ * Creates a new plugin instance.
43
+ */
44
+ constructor(context: Context | Editor);
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ destroy(): void;
49
+ /**
50
+ * @inheritDoc
51
+ */
52
+ static get isContextPlugin(): true;
53
+ }
54
+ /**
55
+ * The common interface of {@link module:core/context~Context} and {@link module:core/editor/editor~Editor}.
56
+ */
57
+ export interface ContextInterface {
58
+ config: Config<Omit<EditorConfig, 'plugins' | 'substitutePlugins' | 'removePlugins' | 'extraPlugins'>>;
59
+ plugins: PluginCollection<Context | Editor>;
60
+ locale: Locale;
61
+ t: LocaleTranslate;
62
+ editors?: Collection<Editor>;
63
+ }
64
+ export type ContextPluginDependencies = PluginDependencies<Context | Editor>;
65
+ export {};
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module core/editingkeystrokehandler
11
+ */
12
+ import { KeystrokeHandler, type PriorityString } from '@ckeditor/ckeditor5-utils';
13
+ import type Editor from './editor/editor.js';
14
+ /**
15
+ * A keystroke handler for editor editing. Its instance is available
16
+ * in {@link module:core/editor/editor~Editor#keystrokes} so plugins
17
+ * can register their keystrokes.
18
+ *
19
+ * E.g. an undo plugin would do this:
20
+ *
21
+ * ```ts
22
+ * editor.keystrokes.set( 'Ctrl+Z', 'undo' );
23
+ * editor.keystrokes.set( 'Ctrl+Shift+Z', 'redo' );
24
+ * editor.keystrokes.set( 'Ctrl+Y', 'redo' );
25
+ * ```
26
+ */
27
+ export default class EditingKeystrokeHandler extends KeystrokeHandler {
28
+ /**
29
+ * The editor instance.
30
+ */
31
+ readonly editor: Editor;
32
+ /**
33
+ * Creates an instance of the keystroke handler.
34
+ */
35
+ constructor(editor: Editor);
36
+ /**
37
+ * Registers a handler for the specified keystroke.
38
+ *
39
+ * The handler can be specified as a command name or a callback.
40
+ *
41
+ * @param keystroke Keystroke defined in a format accepted by
42
+ * the {@link module:utils/keyboard~parseKeystroke} function.
43
+ * @param callback If a string is passed, then the keystroke will
44
+ * {@link module:core/editor/editor~Editor#execute execute a command}.
45
+ * If a function, then it will be called with the
46
+ * {@link module:engine/view/observer/keyobserver~KeyEventData key event data} object and
47
+ * a `cancel()` helper to both `preventDefault()` and `stopPropagation()` of the event.
48
+ * @param options Additional options.
49
+ * @param options.priority The priority of the keystroke callback. The higher the priority value
50
+ * the sooner the callback will be executed. Keystrokes having the same priority
51
+ * are called in the order they were added.
52
+ */
53
+ set(keystroke: string | Array<string | number>, callback: EditingKeystrokeCallback, options?: {
54
+ readonly priority?: PriorityString;
55
+ }): void;
56
+ }
57
+ /**
58
+ * Command name or a callback to be executed when a given keystroke is pressed.
59
+ */
60
+ export type EditingKeystrokeCallback = string | ((ev: KeyboardEvent, cancel: () => void) => void);