@ckeditor/ckeditor5-editor-decoupled 38.1.1 → 38.2.0-alpha.1

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.
@@ -1,265 +1,265 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module editor-decoupled/decouplededitor
7
- */
8
- import { Editor, Context, ElementApiMixin, DataApiMixin, secureSourceElement } from 'ckeditor5/src/core';
9
- import { CKEditorError, getDataFromElement } from 'ckeditor5/src/utils';
10
- import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog';
11
- import DecoupledEditorUI from './decouplededitorui';
12
- import DecoupledEditorUIView from './decouplededitoruiview';
13
- import { isElement as _isElement } from 'lodash-es';
14
- /**
15
- * The {@glink installation/getting-started/predefined-builds#document-editor decoupled editor} implementation.
16
- * It provides an inline editable and a toolbar. However, unlike other editors,
17
- * it does not render these components anywhere in the DOM unless configured.
18
- *
19
- * This type of an editor is dedicated to integrations which require a customized UI with an open
20
- * structure, allowing developers to specify the exact location of the interface.
21
- *
22
- * See the document editor {@glink examples/builds/document-editor demo} to learn about possible use cases
23
- * for the decoupled editor.
24
- *
25
- * In order to create a decoupled editor instance, use the static
26
- * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method.
27
- *
28
- * Note that you will need to attach the editor toolbar to your web page manually, in a desired place, after the editor is initialized.
29
- *
30
- * # Decoupled editor and document editor build
31
- *
32
- * The decoupled editor can be used directly from source (if you installed the
33
- * [`@ckeditor/ckeditor5-editor-decoupled`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled) package)
34
- * but it is also available in the
35
- * {@glink installation/getting-started/predefined-builds#document-editor document editor build}.
36
- *
37
- * {@glink installation/getting-started/predefined-builds Builds}
38
- * are ready-to-use editors with plugins bundled in. When using the editor from
39
- * source you need to take care of loading all plugins by yourself
40
- * (through the {@link module:core/editor/editorconfig~EditorConfig#plugins `config.plugins`} option).
41
- * Using the editor from source gives much better flexibility and allows for easier customization.
42
- *
43
- * Read more about initializing the editor from source or as a build in
44
- * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}.
45
- */
46
- export default class DecoupledEditor extends DataApiMixin(ElementApiMixin(Editor)) {
47
- /**
48
- * Creates an instance of the decoupled editor.
49
- *
50
- * **Note:** Do not use the constructor to create editor instances. Use the static
51
- * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method instead.
52
- *
53
- * @param sourceElementOrData The DOM element that will be the source for the created editor
54
- * (on which the editor will be initialized) or initial data for the editor. For more information see
55
- * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}.
56
- * @param config The editor configuration.
57
- */
58
- constructor(sourceElementOrData, config = {}) {
59
- // If both `config.initialData` is set and initial data is passed as the constructor parameter, then throw.
60
- if (!isElement(sourceElementOrData) && config.initialData !== undefined) {
61
- // Documented in core/editor/editorconfig.jsdoc.
62
- // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
63
- throw new CKEditorError('editor-create-initial-data', null);
64
- }
65
- super(config);
66
- if (this.config.get('initialData') === undefined) {
67
- this.config.set('initialData', getInitialData(sourceElementOrData));
68
- }
69
- if (isElement(sourceElementOrData)) {
70
- this.sourceElement = sourceElementOrData;
71
- secureSourceElement(this, sourceElementOrData);
72
- }
73
- this.model.document.createRoot();
74
- const shouldToolbarGroupWhenFull = !this.config.get('toolbar.shouldNotGroupWhenFull');
75
- const view = new DecoupledEditorUIView(this.locale, this.editing.view, {
76
- editableElement: this.sourceElement,
77
- shouldToolbarGroupWhenFull
78
- });
79
- this.ui = new DecoupledEditorUI(this, view);
80
- }
81
- /**
82
- * Destroys the editor instance, releasing all resources used by it.
83
- *
84
- * Updates the original editor element with the data if the
85
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
86
- * configuration option is set to `true`.
87
- *
88
- * **Note**: The decoupled editor does not remove the toolbar and editable when destroyed. You can
89
- * do that yourself in the destruction chain:
90
- *
91
- * ```ts
92
- * editor.destroy()
93
- * .then( () => {
94
- * // Remove the toolbar from DOM.
95
- * editor.ui.view.toolbar.element.remove();
96
- *
97
- * // Remove the editable from DOM.
98
- * editor.ui.view.editable.element.remove();
99
- *
100
- * console.log( 'Editor was destroyed' );
101
- * } );
102
- * ```
103
- */
104
- destroy() {
105
- // Cache the data, then destroy.
106
- // It's safe to assume that the model->view conversion will not work after super.destroy().
107
- const data = this.getData();
108
- this.ui.destroy();
109
- return super.destroy()
110
- .then(() => {
111
- if (this.sourceElement) {
112
- this.updateSourceElement(data);
113
- }
114
- });
115
- }
116
- /**
117
- * Creates a new decoupled editor instance.
118
- *
119
- * **Note:** remember that `DecoupledEditor` does not append the toolbar element to your web page, so you have to do it manually
120
- * after the editor has been initialized.
121
- *
122
- * There are two ways how the editor can be initialized.
123
- *
124
- * # Using an existing DOM element (and loading data from it)
125
- *
126
- * You can initialize the editor using an existing DOM element:
127
- *
128
- * ```ts
129
- * DecoupledEditor
130
- * .create( document.querySelector( '#editor' ) )
131
- * .then( editor => {
132
- * console.log( 'Editor was initialized', editor );
133
- *
134
- * // Append the toolbar to the <body> element.
135
- * document.body.appendChild( editor.ui.view.toolbar.element );
136
- * } )
137
- * .catch( err => {
138
- * console.error( err.stack );
139
- * } );
140
- * ```
141
- *
142
- * The element's content will be used as the editor data and the element will become the editable element.
143
- *
144
- * # Creating a detached editor
145
- *
146
- * Alternatively, you can initialize the editor by passing the initial data directly as a string.
147
- * In this case, you will have to manually append both the toolbar element and the editable element to your web page.
148
- *
149
- * ```ts
150
- * DecoupledEditor
151
- * .create( '<p>Hello world!</p>' )
152
- * .then( editor => {
153
- * console.log( 'Editor was initialized', editor );
154
- *
155
- * // Append the toolbar to the <body> element.
156
- * document.body.appendChild( editor.ui.view.toolbar.element );
157
- *
158
- * // Initial data was provided so the editor UI element needs to be added manually to the DOM.
159
- * document.body.appendChild( editor.ui.getEditableElement() );
160
- * } )
161
- * .catch( err => {
162
- * console.error( err.stack );
163
- * } );
164
- * ```
165
- *
166
- * This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
167
- * web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
168
- *
169
- * # Using an existing DOM element (and data provided in `config.initialData`)
170
- *
171
- * You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
172
- *
173
- * ```ts
174
- * DecoupledEditor
175
- * .create( document.querySelector( '#editor' ), {
176
- * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
177
- * } )
178
- * .then( editor => {
179
- * console.log( 'Editor was initialized', editor );
180
- *
181
- * // Append the toolbar to the <body> element.
182
- * document.body.appendChild( editor.ui.view.toolbar.element );
183
- * } )
184
- * .catch( err => {
185
- * console.error( err.stack );
186
- * } );
187
- * ```
188
- *
189
- * This method can be used to initialize the editor on an existing element with the specified content in case if your integration
190
- * makes it difficult to set the content of the source element.
191
- *
192
- * Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
193
- *
194
- * # Configuring the editor
195
- *
196
- * See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
197
- * customizing plugins, toolbar and more.
198
- *
199
- * # Using the editor from source
200
- *
201
- * The code samples listed in the previous sections of this documentation assume that you are using an
202
- * {@glink installation/getting-started/predefined-builds editor build}
203
- * (for example – `@ckeditor/ckeditor5-build-decoupled`).
204
- *
205
- * If you want to use the decoupled editor from source (`@ckeditor/ckeditor5-editor-decoupled/src/decouplededitor`),
206
- * you need to define the list of
207
- * {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
208
- * {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
209
- * source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
210
- *
211
- * @param sourceElementOrData The DOM element that will be the source for the created editor
212
- * or the editor's initial data.
213
- *
214
- * If a DOM element is passed, its content will be automatically loaded to the editor upon initialization.
215
- * The editor data will be set back to the original element once the editor is destroyed only if the
216
- * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
217
- * option is set to `true`.
218
- *
219
- * If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
220
- * It is available via
221
- * {@link module:editor-decoupled/decouplededitorui~DecoupledEditorUI#getEditableElement `editor.ui.getEditableElement()`}.
222
- *
223
- * @param config The editor configuration.
224
- * @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
225
- */
226
- static create(sourceElementOrData, config = {}) {
227
- return new Promise(resolve => {
228
- if (isElement(sourceElementOrData) && sourceElementOrData.tagName === 'TEXTAREA') {
229
- // Documented in core/editor/editor.js
230
- // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
231
- throw new CKEditorError('editor-wrong-element', null);
232
- }
233
- const editor = new this(sourceElementOrData, config);
234
- resolve(editor.initPlugins()
235
- .then(() => editor.ui.init())
236
- .then(() => editor.data.init(editor.config.get('initialData')))
237
- .then(() => editor.fire('ready'))
238
- .then(() => editor));
239
- });
240
- }
241
- }
242
- /**
243
- * The {@link module:core/context~Context} class.
244
- *
245
- * Exposed as static editor field for easier access in editor builds.
246
- */
247
- DecoupledEditor.Context = Context;
248
- /**
249
- * The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
250
- *
251
- * Exposed as static editor field for easier access in editor builds.
252
- */
253
- DecoupledEditor.EditorWatchdog = EditorWatchdog;
254
- /**
255
- * The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
256
- *
257
- * Exposed as static editor field for easier access in editor builds.
258
- */
259
- DecoupledEditor.ContextWatchdog = ContextWatchdog;
260
- function getInitialData(sourceElementOrData) {
261
- return isElement(sourceElementOrData) ? getDataFromElement(sourceElementOrData) : sourceElementOrData;
262
- }
263
- function isElement(value) {
264
- return _isElement(value);
265
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module editor-decoupled/decouplededitor
7
+ */
8
+ import { Editor, Context, ElementApiMixin, DataApiMixin, secureSourceElement } from 'ckeditor5/src/core.js';
9
+ import { CKEditorError, getDataFromElement } from 'ckeditor5/src/utils.js';
10
+ import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog.js';
11
+ import DecoupledEditorUI from './decouplededitorui.js';
12
+ import DecoupledEditorUIView from './decouplededitoruiview.js';
13
+ import { isElement as _isElement } from 'lodash-es';
14
+ /**
15
+ * The {@glink installation/getting-started/predefined-builds#document-editor decoupled editor} implementation.
16
+ * It provides an inline editable and a toolbar. However, unlike other editors,
17
+ * it does not render these components anywhere in the DOM unless configured.
18
+ *
19
+ * This type of an editor is dedicated to integrations which require a customized UI with an open
20
+ * structure, allowing developers to specify the exact location of the interface.
21
+ *
22
+ * See the document editor {@glink examples/builds/document-editor demo} to learn about possible use cases
23
+ * for the decoupled editor.
24
+ *
25
+ * In order to create a decoupled editor instance, use the static
26
+ * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method.
27
+ *
28
+ * Note that you will need to attach the editor toolbar to your web page manually, in a desired place, after the editor is initialized.
29
+ *
30
+ * # Decoupled editor and document editor build
31
+ *
32
+ * The decoupled editor can be used directly from source (if you installed the
33
+ * [`@ckeditor/ckeditor5-editor-decoupled`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled) package)
34
+ * but it is also available in the
35
+ * {@glink installation/getting-started/predefined-builds#document-editor document editor build}.
36
+ *
37
+ * {@glink installation/getting-started/predefined-builds Builds}
38
+ * are ready-to-use editors with plugins bundled in. When using the editor from
39
+ * source you need to take care of loading all plugins by yourself
40
+ * (through the {@link module:core/editor/editorconfig~EditorConfig#plugins `config.plugins`} option).
41
+ * Using the editor from source gives much better flexibility and allows for easier customization.
42
+ *
43
+ * Read more about initializing the editor from source or as a build in
44
+ * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}.
45
+ */
46
+ export default class DecoupledEditor extends DataApiMixin(ElementApiMixin(Editor)) {
47
+ /**
48
+ * Creates an instance of the decoupled editor.
49
+ *
50
+ * **Note:** Do not use the constructor to create editor instances. Use the static
51
+ * {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method instead.
52
+ *
53
+ * @param sourceElementOrData The DOM element that will be the source for the created editor
54
+ * (on which the editor will be initialized) or initial data for the editor. For more information see
55
+ * {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}.
56
+ * @param config The editor configuration.
57
+ */
58
+ constructor(sourceElementOrData, config = {}) {
59
+ // If both `config.initialData` is set and initial data is passed as the constructor parameter, then throw.
60
+ if (!isElement(sourceElementOrData) && config.initialData !== undefined) {
61
+ // Documented in core/editor/editorconfig.jsdoc.
62
+ // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
63
+ throw new CKEditorError('editor-create-initial-data', null);
64
+ }
65
+ super(config);
66
+ if (this.config.get('initialData') === undefined) {
67
+ this.config.set('initialData', getInitialData(sourceElementOrData));
68
+ }
69
+ if (isElement(sourceElementOrData)) {
70
+ this.sourceElement = sourceElementOrData;
71
+ secureSourceElement(this, sourceElementOrData);
72
+ }
73
+ this.model.document.createRoot();
74
+ const shouldToolbarGroupWhenFull = !this.config.get('toolbar.shouldNotGroupWhenFull');
75
+ const view = new DecoupledEditorUIView(this.locale, this.editing.view, {
76
+ editableElement: this.sourceElement,
77
+ shouldToolbarGroupWhenFull
78
+ });
79
+ this.ui = new DecoupledEditorUI(this, view);
80
+ }
81
+ /**
82
+ * Destroys the editor instance, releasing all resources used by it.
83
+ *
84
+ * Updates the original editor element with the data if the
85
+ * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
86
+ * configuration option is set to `true`.
87
+ *
88
+ * **Note**: The decoupled editor does not remove the toolbar and editable when destroyed. You can
89
+ * do that yourself in the destruction chain:
90
+ *
91
+ * ```ts
92
+ * editor.destroy()
93
+ * .then( () => {
94
+ * // Remove the toolbar from DOM.
95
+ * editor.ui.view.toolbar.element.remove();
96
+ *
97
+ * // Remove the editable from DOM.
98
+ * editor.ui.view.editable.element.remove();
99
+ *
100
+ * console.log( 'Editor was destroyed' );
101
+ * } );
102
+ * ```
103
+ */
104
+ destroy() {
105
+ // Cache the data, then destroy.
106
+ // It's safe to assume that the model->view conversion will not work after super.destroy().
107
+ const data = this.getData();
108
+ this.ui.destroy();
109
+ return super.destroy()
110
+ .then(() => {
111
+ if (this.sourceElement) {
112
+ this.updateSourceElement(data);
113
+ }
114
+ });
115
+ }
116
+ /**
117
+ * Creates a new decoupled editor instance.
118
+ *
119
+ * **Note:** remember that `DecoupledEditor` does not append the toolbar element to your web page, so you have to do it manually
120
+ * after the editor has been initialized.
121
+ *
122
+ * There are two ways how the editor can be initialized.
123
+ *
124
+ * # Using an existing DOM element (and loading data from it)
125
+ *
126
+ * You can initialize the editor using an existing DOM element:
127
+ *
128
+ * ```ts
129
+ * DecoupledEditor
130
+ * .create( document.querySelector( '#editor' ) )
131
+ * .then( editor => {
132
+ * console.log( 'Editor was initialized', editor );
133
+ *
134
+ * // Append the toolbar to the <body> element.
135
+ * document.body.appendChild( editor.ui.view.toolbar.element );
136
+ * } )
137
+ * .catch( err => {
138
+ * console.error( err.stack );
139
+ * } );
140
+ * ```
141
+ *
142
+ * The element's content will be used as the editor data and the element will become the editable element.
143
+ *
144
+ * # Creating a detached editor
145
+ *
146
+ * Alternatively, you can initialize the editor by passing the initial data directly as a string.
147
+ * In this case, you will have to manually append both the toolbar element and the editable element to your web page.
148
+ *
149
+ * ```ts
150
+ * DecoupledEditor
151
+ * .create( '<p>Hello world!</p>' )
152
+ * .then( editor => {
153
+ * console.log( 'Editor was initialized', editor );
154
+ *
155
+ * // Append the toolbar to the <body> element.
156
+ * document.body.appendChild( editor.ui.view.toolbar.element );
157
+ *
158
+ * // Initial data was provided so the editor UI element needs to be added manually to the DOM.
159
+ * document.body.appendChild( editor.ui.getEditableElement() );
160
+ * } )
161
+ * .catch( err => {
162
+ * console.error( err.stack );
163
+ * } );
164
+ * ```
165
+ *
166
+ * This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
167
+ * web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
168
+ *
169
+ * # Using an existing DOM element (and data provided in `config.initialData`)
170
+ *
171
+ * You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
172
+ *
173
+ * ```ts
174
+ * DecoupledEditor
175
+ * .create( document.querySelector( '#editor' ), {
176
+ * initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
177
+ * } )
178
+ * .then( editor => {
179
+ * console.log( 'Editor was initialized', editor );
180
+ *
181
+ * // Append the toolbar to the <body> element.
182
+ * document.body.appendChild( editor.ui.view.toolbar.element );
183
+ * } )
184
+ * .catch( err => {
185
+ * console.error( err.stack );
186
+ * } );
187
+ * ```
188
+ *
189
+ * This method can be used to initialize the editor on an existing element with the specified content in case if your integration
190
+ * makes it difficult to set the content of the source element.
191
+ *
192
+ * Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
193
+ *
194
+ * # Configuring the editor
195
+ *
196
+ * See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
197
+ * customizing plugins, toolbar and more.
198
+ *
199
+ * # Using the editor from source
200
+ *
201
+ * The code samples listed in the previous sections of this documentation assume that you are using an
202
+ * {@glink installation/getting-started/predefined-builds editor build}
203
+ * (for example – `@ckeditor/ckeditor5-build-decoupled`).
204
+ *
205
+ * If you want to use the decoupled editor from source (`@ckeditor/ckeditor5-editor-decoupled/src/decouplededitor`),
206
+ * you need to define the list of
207
+ * {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
208
+ * {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
209
+ * source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
210
+ *
211
+ * @param sourceElementOrData The DOM element that will be the source for the created editor
212
+ * or the editor's initial data.
213
+ *
214
+ * If a DOM element is passed, its content will be automatically loaded to the editor upon initialization.
215
+ * The editor data will be set back to the original element once the editor is destroyed only if the
216
+ * {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
217
+ * option is set to `true`.
218
+ *
219
+ * If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
220
+ * It is available via
221
+ * {@link module:editor-decoupled/decouplededitorui~DecoupledEditorUI#getEditableElement `editor.ui.getEditableElement()`}.
222
+ *
223
+ * @param config The editor configuration.
224
+ * @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
225
+ */
226
+ static create(sourceElementOrData, config = {}) {
227
+ return new Promise(resolve => {
228
+ if (isElement(sourceElementOrData) && sourceElementOrData.tagName === 'TEXTAREA') {
229
+ // Documented in core/editor/editor.js
230
+ // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
231
+ throw new CKEditorError('editor-wrong-element', null);
232
+ }
233
+ const editor = new this(sourceElementOrData, config);
234
+ resolve(editor.initPlugins()
235
+ .then(() => editor.ui.init())
236
+ .then(() => editor.data.init(editor.config.get('initialData')))
237
+ .then(() => editor.fire('ready'))
238
+ .then(() => editor));
239
+ });
240
+ }
241
+ }
242
+ /**
243
+ * The {@link module:core/context~Context} class.
244
+ *
245
+ * Exposed as static editor field for easier access in editor builds.
246
+ */
247
+ DecoupledEditor.Context = Context;
248
+ /**
249
+ * The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
250
+ *
251
+ * Exposed as static editor field for easier access in editor builds.
252
+ */
253
+ DecoupledEditor.EditorWatchdog = EditorWatchdog;
254
+ /**
255
+ * The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
256
+ *
257
+ * Exposed as static editor field for easier access in editor builds.
258
+ */
259
+ DecoupledEditor.ContextWatchdog = ContextWatchdog;
260
+ function getInitialData(sourceElementOrData) {
261
+ return isElement(sourceElementOrData) ? getDataFromElement(sourceElementOrData) : sourceElementOrData;
262
+ }
263
+ function isElement(value) {
264
+ return _isElement(value);
265
+ }
@@ -1,42 +1,42 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module editor-decoupled/decouplededitorui
7
- */
8
- import { type Editor } from 'ckeditor5/src/core';
9
- import { EditorUI } from 'ckeditor5/src/ui';
10
- import type DecoupledEditorUIView from './decouplededitoruiview';
11
- /**
12
- * The decoupled editor UI class.
13
- */
14
- export default class DecoupledEditorUI extends EditorUI {
15
- /**
16
- * The main (top–most) view of the editor UI.
17
- */
18
- readonly view: DecoupledEditorUIView;
19
- /**
20
- * Creates an instance of the decoupled editor UI class.
21
- *
22
- * @param editor The editor instance.
23
- * @param view The view of the UI.
24
- */
25
- constructor(editor: Editor, view: DecoupledEditorUIView);
26
- /**
27
- * Initializes the UI.
28
- */
29
- init(): void;
30
- /**
31
- * @inheritDoc
32
- */
33
- destroy(): void;
34
- /**
35
- * Initializes the inline editor toolbar and its panel.
36
- */
37
- private _initToolbar;
38
- /**
39
- * Enable the placeholder text on the editing root, if any was configured.
40
- */
41
- private _initPlaceholder;
42
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module editor-decoupled/decouplededitorui
7
+ */
8
+ import { type Editor } from 'ckeditor5/src/core.js';
9
+ import { EditorUI } from 'ckeditor5/src/ui.js';
10
+ import type DecoupledEditorUIView from './decouplededitoruiview.js';
11
+ /**
12
+ * The decoupled editor UI class.
13
+ */
14
+ export default class DecoupledEditorUI extends EditorUI {
15
+ /**
16
+ * The main (top–most) view of the editor UI.
17
+ */
18
+ readonly view: DecoupledEditorUIView;
19
+ /**
20
+ * Creates an instance of the decoupled editor UI class.
21
+ *
22
+ * @param editor The editor instance.
23
+ * @param view The view of the UI.
24
+ */
25
+ constructor(editor: Editor, view: DecoupledEditorUIView);
26
+ /**
27
+ * Initializes the UI.
28
+ */
29
+ init(): void;
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ destroy(): void;
34
+ /**
35
+ * Initializes the inline editor toolbar and its panel.
36
+ */
37
+ private _initToolbar;
38
+ /**
39
+ * Enable the placeholder text on the editing root, if any was configured.
40
+ */
41
+ private _initPlaceholder;
42
+ }