@ckeditor/ckeditor5-editor-decoupled 40.0.0 → 40.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +3 -3
- package/package.json +2 -2
- package/src/decouplededitor.d.ts +215 -215
- package/src/decouplededitor.js +265 -265
- package/src/decouplededitorui.d.ts +42 -42
- package/src/decouplededitorui.js +97 -97
- package/src/decouplededitoruiview.d.ts +49 -49
- package/src/decouplededitoruiview.js +63 -63
- package/src/index.d.ts +8 -8
- package/src/index.js +8 -8
- package/build/editor-decoupled.js.map +0 -1
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**Decoupled editor implementation** – https://github.com/ckeditor/ckeditor5-editor-decoupled <br>
|
|
5
|
-
Copyright (c) 2003
|
|
5
|
+
Copyright (c) 2003–2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
|
6
6
|
|
|
7
7
|
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
|
8
8
|
|
|
@@ -13,9 +13,9 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
|
|
|
13
13
|
|
|
14
14
|
The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):
|
|
15
15
|
|
|
16
|
-
*
|
|
16
|
+
* Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
|
|
17
17
|
|
|
18
18
|
Trademarks
|
|
19
19
|
----------
|
|
20
20
|
|
|
21
|
-
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
|
|
21
|
+
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-editor-decoupled",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.1.0",
|
|
4
4
|
"description": "Decoupled editor implementation for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"main": "src/index.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"ckeditor5": "40.
|
|
14
|
+
"ckeditor5": "40.1.0",
|
|
15
15
|
"lodash-es": "4.17.21"
|
|
16
16
|
},
|
|
17
17
|
"author": "CKSource (http://cksource.com/)",
|
package/src/decouplededitor.d.ts
CHANGED
|
@@ -1,215 +1,215 @@
|
|
|
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, type EditorConfig } from 'ckeditor5/src/core';
|
|
9
|
-
import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog';
|
|
10
|
-
import DecoupledEditorUI from './decouplededitorui';
|
|
11
|
-
declare const DecoupledEditor_base: import("ckeditor5/src/utils").Mixed<import("ckeditor5/src/utils").Mixed<typeof Editor, import("ckeditor5/src/core").ElementApi>, import("ckeditor5/src/core").DataApi>;
|
|
12
|
-
/**
|
|
13
|
-
* The {@glink installation/getting-started/predefined-builds#document-editor decoupled editor} implementation.
|
|
14
|
-
* It provides an inline editable and a toolbar. However, unlike other editors,
|
|
15
|
-
* it does not render these components anywhere in the DOM unless configured.
|
|
16
|
-
*
|
|
17
|
-
* This type of an editor is dedicated to integrations which require a customized UI with an open
|
|
18
|
-
* structure, allowing developers to specify the exact location of the interface.
|
|
19
|
-
*
|
|
20
|
-
* See the document editor {@glink examples/builds/document-editor demo} to learn about possible use cases
|
|
21
|
-
* for the decoupled editor.
|
|
22
|
-
*
|
|
23
|
-
* In order to create a decoupled editor instance, use the static
|
|
24
|
-
* {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method.
|
|
25
|
-
*
|
|
26
|
-
* Note that you will need to attach the editor toolbar to your web page manually, in a desired place, after the editor is initialized.
|
|
27
|
-
*
|
|
28
|
-
* # Decoupled editor and document editor build
|
|
29
|
-
*
|
|
30
|
-
* The decoupled editor can be used directly from source (if you installed the
|
|
31
|
-
* [`@ckeditor/ckeditor5-editor-decoupled`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled) package)
|
|
32
|
-
* but it is also available in the
|
|
33
|
-
* {@glink installation/getting-started/predefined-builds#document-editor document editor build}.
|
|
34
|
-
*
|
|
35
|
-
* {@glink installation/getting-started/predefined-builds Builds}
|
|
36
|
-
* are ready-to-use editors with plugins bundled in. When using the editor from
|
|
37
|
-
* source you need to take care of loading all plugins by yourself
|
|
38
|
-
* (through the {@link module:core/editor/editorconfig~EditorConfig#plugins `config.plugins`} option).
|
|
39
|
-
* Using the editor from source gives much better flexibility and allows for easier customization.
|
|
40
|
-
*
|
|
41
|
-
* Read more about initializing the editor from source or as a build in
|
|
42
|
-
* {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}.
|
|
43
|
-
*/
|
|
44
|
-
export default class DecoupledEditor extends DecoupledEditor_base {
|
|
45
|
-
/**
|
|
46
|
-
* @inheritDoc
|
|
47
|
-
*/
|
|
48
|
-
readonly ui: DecoupledEditorUI;
|
|
49
|
-
/**
|
|
50
|
-
* Creates an instance of the decoupled editor.
|
|
51
|
-
*
|
|
52
|
-
* **Note:** Do not use the constructor to create editor instances. Use the static
|
|
53
|
-
* {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method instead.
|
|
54
|
-
*
|
|
55
|
-
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
|
56
|
-
* (on which the editor will be initialized) or initial data for the editor. For more information see
|
|
57
|
-
* {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}.
|
|
58
|
-
* @param config The editor configuration.
|
|
59
|
-
*/
|
|
60
|
-
protected constructor(sourceElementOrData: HTMLElement | string, config?: EditorConfig);
|
|
61
|
-
/**
|
|
62
|
-
* Destroys the editor instance, releasing all resources used by it.
|
|
63
|
-
*
|
|
64
|
-
* Updates the original editor element with the data if the
|
|
65
|
-
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
|
|
66
|
-
* configuration option is set to `true`.
|
|
67
|
-
*
|
|
68
|
-
* **Note**: The decoupled editor does not remove the toolbar and editable when destroyed. You can
|
|
69
|
-
* do that yourself in the destruction chain:
|
|
70
|
-
*
|
|
71
|
-
* ```ts
|
|
72
|
-
* editor.destroy()
|
|
73
|
-
* .then( () => {
|
|
74
|
-
* // Remove the toolbar from DOM.
|
|
75
|
-
* editor.ui.view.toolbar.element.remove();
|
|
76
|
-
*
|
|
77
|
-
* // Remove the editable from DOM.
|
|
78
|
-
* editor.ui.view.editable.element.remove();
|
|
79
|
-
*
|
|
80
|
-
* console.log( 'Editor was destroyed' );
|
|
81
|
-
* } );
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
destroy(): Promise<unknown>;
|
|
85
|
-
/**
|
|
86
|
-
* Creates a new decoupled editor instance.
|
|
87
|
-
*
|
|
88
|
-
* **Note:** remember that `DecoupledEditor` does not append the toolbar element to your web page, so you have to do it manually
|
|
89
|
-
* after the editor has been initialized.
|
|
90
|
-
*
|
|
91
|
-
* There are two ways how the editor can be initialized.
|
|
92
|
-
*
|
|
93
|
-
* # Using an existing DOM element (and loading data from it)
|
|
94
|
-
*
|
|
95
|
-
* You can initialize the editor using an existing DOM element:
|
|
96
|
-
*
|
|
97
|
-
* ```ts
|
|
98
|
-
* DecoupledEditor
|
|
99
|
-
* .create( document.querySelector( '#editor' ) )
|
|
100
|
-
* .then( editor => {
|
|
101
|
-
* console.log( 'Editor was initialized', editor );
|
|
102
|
-
*
|
|
103
|
-
* // Append the toolbar to the <body> element.
|
|
104
|
-
* document.body.appendChild( editor.ui.view.toolbar.element );
|
|
105
|
-
* } )
|
|
106
|
-
* .catch( err => {
|
|
107
|
-
* console.error( err.stack );
|
|
108
|
-
* } );
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* The element's content will be used as the editor data and the element will become the editable element.
|
|
112
|
-
*
|
|
113
|
-
* # Creating a detached editor
|
|
114
|
-
*
|
|
115
|
-
* Alternatively, you can initialize the editor by passing the initial data directly as a string.
|
|
116
|
-
* In this case, you will have to manually append both the toolbar element and the editable element to your web page.
|
|
117
|
-
*
|
|
118
|
-
* ```ts
|
|
119
|
-
* DecoupledEditor
|
|
120
|
-
* .create( '<p>Hello world!</p>' )
|
|
121
|
-
* .then( editor => {
|
|
122
|
-
* console.log( 'Editor was initialized', editor );
|
|
123
|
-
*
|
|
124
|
-
* // Append the toolbar to the <body> element.
|
|
125
|
-
* document.body.appendChild( editor.ui.view.toolbar.element );
|
|
126
|
-
*
|
|
127
|
-
* // Initial data was provided so the editor UI element needs to be added manually to the DOM.
|
|
128
|
-
* document.body.appendChild( editor.ui.getEditableElement() );
|
|
129
|
-
* } )
|
|
130
|
-
* .catch( err => {
|
|
131
|
-
* console.error( err.stack );
|
|
132
|
-
* } );
|
|
133
|
-
* ```
|
|
134
|
-
*
|
|
135
|
-
* This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
|
|
136
|
-
* web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
|
|
137
|
-
*
|
|
138
|
-
* # Using an existing DOM element (and data provided in `config.initialData`)
|
|
139
|
-
*
|
|
140
|
-
* You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
|
|
141
|
-
*
|
|
142
|
-
* ```ts
|
|
143
|
-
* DecoupledEditor
|
|
144
|
-
* .create( document.querySelector( '#editor' ), {
|
|
145
|
-
* initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
|
|
146
|
-
* } )
|
|
147
|
-
* .then( editor => {
|
|
148
|
-
* console.log( 'Editor was initialized', editor );
|
|
149
|
-
*
|
|
150
|
-
* // Append the toolbar to the <body> element.
|
|
151
|
-
* document.body.appendChild( editor.ui.view.toolbar.element );
|
|
152
|
-
* } )
|
|
153
|
-
* .catch( err => {
|
|
154
|
-
* console.error( err.stack );
|
|
155
|
-
* } );
|
|
156
|
-
* ```
|
|
157
|
-
*
|
|
158
|
-
* This method can be used to initialize the editor on an existing element with the specified content in case if your integration
|
|
159
|
-
* makes it difficult to set the content of the source element.
|
|
160
|
-
*
|
|
161
|
-
* Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
|
|
162
|
-
*
|
|
163
|
-
* # Configuring the editor
|
|
164
|
-
*
|
|
165
|
-
* See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
|
|
166
|
-
* customizing plugins, toolbar and more.
|
|
167
|
-
*
|
|
168
|
-
* # Using the editor from source
|
|
169
|
-
*
|
|
170
|
-
* The code samples listed in the previous sections of this documentation assume that you are using an
|
|
171
|
-
* {@glink installation/getting-started/predefined-builds editor build}
|
|
172
|
-
* (for example – `@ckeditor/ckeditor5-build-decoupled`).
|
|
173
|
-
*
|
|
174
|
-
* If you want to use the decoupled editor from source (`@ckeditor/ckeditor5-editor-decoupled/src/decouplededitor`),
|
|
175
|
-
* you need to define the list of
|
|
176
|
-
* {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
|
|
177
|
-
* {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
|
|
178
|
-
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
|
|
179
|
-
*
|
|
180
|
-
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
|
181
|
-
* or the editor's initial data.
|
|
182
|
-
*
|
|
183
|
-
* If a DOM element is passed, its content will be automatically loaded to the editor upon initialization.
|
|
184
|
-
* The editor data will be set back to the original element once the editor is destroyed only if the
|
|
185
|
-
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
|
|
186
|
-
* option is set to `true`.
|
|
187
|
-
*
|
|
188
|
-
* If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
|
|
189
|
-
* It is available via
|
|
190
|
-
* {@link module:editor-decoupled/decouplededitorui~DecoupledEditorUI#getEditableElement `editor.ui.getEditableElement()`}.
|
|
191
|
-
*
|
|
192
|
-
* @param config The editor configuration.
|
|
193
|
-
* @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
|
|
194
|
-
*/
|
|
195
|
-
static create(sourceElementOrData: HTMLElement | string, config?: EditorConfig): Promise<DecoupledEditor>;
|
|
196
|
-
/**
|
|
197
|
-
* The {@link module:core/context~Context} class.
|
|
198
|
-
*
|
|
199
|
-
* Exposed as static editor field for easier access in editor builds.
|
|
200
|
-
*/
|
|
201
|
-
static Context: typeof Context;
|
|
202
|
-
/**
|
|
203
|
-
* The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
|
|
204
|
-
*
|
|
205
|
-
* Exposed as static editor field for easier access in editor builds.
|
|
206
|
-
*/
|
|
207
|
-
static EditorWatchdog: typeof EditorWatchdog;
|
|
208
|
-
/**
|
|
209
|
-
* The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
|
|
210
|
-
*
|
|
211
|
-
* Exposed as static editor field for easier access in editor builds.
|
|
212
|
-
*/
|
|
213
|
-
static ContextWatchdog: typeof ContextWatchdog;
|
|
214
|
-
}
|
|
215
|
-
export {};
|
|
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, type EditorConfig } from 'ckeditor5/src/core';
|
|
9
|
+
import { ContextWatchdog, EditorWatchdog } from 'ckeditor5/src/watchdog';
|
|
10
|
+
import DecoupledEditorUI from './decouplededitorui';
|
|
11
|
+
declare const DecoupledEditor_base: import("ckeditor5/src/utils").Mixed<import("ckeditor5/src/utils").Mixed<typeof Editor, import("ckeditor5/src/core").ElementApi>, import("ckeditor5/src/core").DataApi>;
|
|
12
|
+
/**
|
|
13
|
+
* The {@glink installation/getting-started/predefined-builds#document-editor decoupled editor} implementation.
|
|
14
|
+
* It provides an inline editable and a toolbar. However, unlike other editors,
|
|
15
|
+
* it does not render these components anywhere in the DOM unless configured.
|
|
16
|
+
*
|
|
17
|
+
* This type of an editor is dedicated to integrations which require a customized UI with an open
|
|
18
|
+
* structure, allowing developers to specify the exact location of the interface.
|
|
19
|
+
*
|
|
20
|
+
* See the document editor {@glink examples/builds/document-editor demo} to learn about possible use cases
|
|
21
|
+
* for the decoupled editor.
|
|
22
|
+
*
|
|
23
|
+
* In order to create a decoupled editor instance, use the static
|
|
24
|
+
* {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method.
|
|
25
|
+
*
|
|
26
|
+
* Note that you will need to attach the editor toolbar to your web page manually, in a desired place, after the editor is initialized.
|
|
27
|
+
*
|
|
28
|
+
* # Decoupled editor and document editor build
|
|
29
|
+
*
|
|
30
|
+
* The decoupled editor can be used directly from source (if you installed the
|
|
31
|
+
* [`@ckeditor/ckeditor5-editor-decoupled`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled) package)
|
|
32
|
+
* but it is also available in the
|
|
33
|
+
* {@glink installation/getting-started/predefined-builds#document-editor document editor build}.
|
|
34
|
+
*
|
|
35
|
+
* {@glink installation/getting-started/predefined-builds Builds}
|
|
36
|
+
* are ready-to-use editors with plugins bundled in. When using the editor from
|
|
37
|
+
* source you need to take care of loading all plugins by yourself
|
|
38
|
+
* (through the {@link module:core/editor/editorconfig~EditorConfig#plugins `config.plugins`} option).
|
|
39
|
+
* Using the editor from source gives much better flexibility and allows for easier customization.
|
|
40
|
+
*
|
|
41
|
+
* Read more about initializing the editor from source or as a build in
|
|
42
|
+
* {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`}.
|
|
43
|
+
*/
|
|
44
|
+
export default class DecoupledEditor extends DecoupledEditor_base {
|
|
45
|
+
/**
|
|
46
|
+
* @inheritDoc
|
|
47
|
+
*/
|
|
48
|
+
readonly ui: DecoupledEditorUI;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an instance of the decoupled editor.
|
|
51
|
+
*
|
|
52
|
+
* **Note:** Do not use the constructor to create editor instances. Use the static
|
|
53
|
+
* {@link module:editor-decoupled/decouplededitor~DecoupledEditor.create `DecoupledEditor.create()`} method instead.
|
|
54
|
+
*
|
|
55
|
+
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
|
56
|
+
* (on which the editor will be initialized) or initial data for the editor. For more information see
|
|
57
|
+
* {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}.
|
|
58
|
+
* @param config The editor configuration.
|
|
59
|
+
*/
|
|
60
|
+
protected constructor(sourceElementOrData: HTMLElement | string, config?: EditorConfig);
|
|
61
|
+
/**
|
|
62
|
+
* Destroys the editor instance, releasing all resources used by it.
|
|
63
|
+
*
|
|
64
|
+
* Updates the original editor element with the data if the
|
|
65
|
+
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
|
|
66
|
+
* configuration option is set to `true`.
|
|
67
|
+
*
|
|
68
|
+
* **Note**: The decoupled editor does not remove the toolbar and editable when destroyed. You can
|
|
69
|
+
* do that yourself in the destruction chain:
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* editor.destroy()
|
|
73
|
+
* .then( () => {
|
|
74
|
+
* // Remove the toolbar from DOM.
|
|
75
|
+
* editor.ui.view.toolbar.element.remove();
|
|
76
|
+
*
|
|
77
|
+
* // Remove the editable from DOM.
|
|
78
|
+
* editor.ui.view.editable.element.remove();
|
|
79
|
+
*
|
|
80
|
+
* console.log( 'Editor was destroyed' );
|
|
81
|
+
* } );
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
destroy(): Promise<unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new decoupled editor instance.
|
|
87
|
+
*
|
|
88
|
+
* **Note:** remember that `DecoupledEditor` does not append the toolbar element to your web page, so you have to do it manually
|
|
89
|
+
* after the editor has been initialized.
|
|
90
|
+
*
|
|
91
|
+
* There are two ways how the editor can be initialized.
|
|
92
|
+
*
|
|
93
|
+
* # Using an existing DOM element (and loading data from it)
|
|
94
|
+
*
|
|
95
|
+
* You can initialize the editor using an existing DOM element:
|
|
96
|
+
*
|
|
97
|
+
* ```ts
|
|
98
|
+
* DecoupledEditor
|
|
99
|
+
* .create( document.querySelector( '#editor' ) )
|
|
100
|
+
* .then( editor => {
|
|
101
|
+
* console.log( 'Editor was initialized', editor );
|
|
102
|
+
*
|
|
103
|
+
* // Append the toolbar to the <body> element.
|
|
104
|
+
* document.body.appendChild( editor.ui.view.toolbar.element );
|
|
105
|
+
* } )
|
|
106
|
+
* .catch( err => {
|
|
107
|
+
* console.error( err.stack );
|
|
108
|
+
* } );
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* The element's content will be used as the editor data and the element will become the editable element.
|
|
112
|
+
*
|
|
113
|
+
* # Creating a detached editor
|
|
114
|
+
*
|
|
115
|
+
* Alternatively, you can initialize the editor by passing the initial data directly as a string.
|
|
116
|
+
* In this case, you will have to manually append both the toolbar element and the editable element to your web page.
|
|
117
|
+
*
|
|
118
|
+
* ```ts
|
|
119
|
+
* DecoupledEditor
|
|
120
|
+
* .create( '<p>Hello world!</p>' )
|
|
121
|
+
* .then( editor => {
|
|
122
|
+
* console.log( 'Editor was initialized', editor );
|
|
123
|
+
*
|
|
124
|
+
* // Append the toolbar to the <body> element.
|
|
125
|
+
* document.body.appendChild( editor.ui.view.toolbar.element );
|
|
126
|
+
*
|
|
127
|
+
* // Initial data was provided so the editor UI element needs to be added manually to the DOM.
|
|
128
|
+
* document.body.appendChild( editor.ui.getEditableElement() );
|
|
129
|
+
* } )
|
|
130
|
+
* .catch( err => {
|
|
131
|
+
* console.error( err.stack );
|
|
132
|
+
* } );
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
|
|
136
|
+
* web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
|
|
137
|
+
*
|
|
138
|
+
* # Using an existing DOM element (and data provided in `config.initialData`)
|
|
139
|
+
*
|
|
140
|
+
* You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* DecoupledEditor
|
|
144
|
+
* .create( document.querySelector( '#editor' ), {
|
|
145
|
+
* initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
|
|
146
|
+
* } )
|
|
147
|
+
* .then( editor => {
|
|
148
|
+
* console.log( 'Editor was initialized', editor );
|
|
149
|
+
*
|
|
150
|
+
* // Append the toolbar to the <body> element.
|
|
151
|
+
* document.body.appendChild( editor.ui.view.toolbar.element );
|
|
152
|
+
* } )
|
|
153
|
+
* .catch( err => {
|
|
154
|
+
* console.error( err.stack );
|
|
155
|
+
* } );
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* This method can be used to initialize the editor on an existing element with the specified content in case if your integration
|
|
159
|
+
* makes it difficult to set the content of the source element.
|
|
160
|
+
*
|
|
161
|
+
* Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
|
|
162
|
+
*
|
|
163
|
+
* # Configuring the editor
|
|
164
|
+
*
|
|
165
|
+
* See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
|
|
166
|
+
* customizing plugins, toolbar and more.
|
|
167
|
+
*
|
|
168
|
+
* # Using the editor from source
|
|
169
|
+
*
|
|
170
|
+
* The code samples listed in the previous sections of this documentation assume that you are using an
|
|
171
|
+
* {@glink installation/getting-started/predefined-builds editor build}
|
|
172
|
+
* (for example – `@ckeditor/ckeditor5-build-decoupled`).
|
|
173
|
+
*
|
|
174
|
+
* If you want to use the decoupled editor from source (`@ckeditor/ckeditor5-editor-decoupled/src/decouplededitor`),
|
|
175
|
+
* you need to define the list of
|
|
176
|
+
* {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
|
|
177
|
+
* {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
|
|
178
|
+
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
|
|
179
|
+
*
|
|
180
|
+
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
|
181
|
+
* or the editor's initial data.
|
|
182
|
+
*
|
|
183
|
+
* If a DOM element is passed, its content will be automatically loaded to the editor upon initialization.
|
|
184
|
+
* The editor data will be set back to the original element once the editor is destroyed only if the
|
|
185
|
+
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
|
|
186
|
+
* option is set to `true`.
|
|
187
|
+
*
|
|
188
|
+
* If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
|
|
189
|
+
* It is available via
|
|
190
|
+
* {@link module:editor-decoupled/decouplededitorui~DecoupledEditorUI#getEditableElement `editor.ui.getEditableElement()`}.
|
|
191
|
+
*
|
|
192
|
+
* @param config The editor configuration.
|
|
193
|
+
* @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
|
|
194
|
+
*/
|
|
195
|
+
static create(sourceElementOrData: HTMLElement | string, config?: EditorConfig): Promise<DecoupledEditor>;
|
|
196
|
+
/**
|
|
197
|
+
* The {@link module:core/context~Context} class.
|
|
198
|
+
*
|
|
199
|
+
* Exposed as static editor field for easier access in editor builds.
|
|
200
|
+
*/
|
|
201
|
+
static Context: typeof Context;
|
|
202
|
+
/**
|
|
203
|
+
* The {@link module:watchdog/editorwatchdog~EditorWatchdog} class.
|
|
204
|
+
*
|
|
205
|
+
* Exposed as static editor field for easier access in editor builds.
|
|
206
|
+
*/
|
|
207
|
+
static EditorWatchdog: typeof EditorWatchdog;
|
|
208
|
+
/**
|
|
209
|
+
* The {@link module:watchdog/contextwatchdog~ContextWatchdog} class.
|
|
210
|
+
*
|
|
211
|
+
* Exposed as static editor field for easier access in editor builds.
|
|
212
|
+
*/
|
|
213
|
+
static ContextWatchdog: typeof ContextWatchdog;
|
|
214
|
+
}
|
|
215
|
+
export {};
|