@ckeditor/ckeditor5-editor-decoupled 40.0.0 → 40.2.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/CHANGELOG.md +20 -20
- 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/CHANGELOG.md
CHANGED
|
@@ -5,36 +5,36 @@ All changes in the package are documented in the main repository. See: https://g
|
|
|
5
5
|
|
|
6
6
|
Changes for the past releases are available below.
|
|
7
7
|
|
|
8
|
-
## [19.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v18.0.0...v19.0.0) (2020
|
|
8
|
+
## [19.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v18.0.0...v19.0.0) (April 29, 2020)
|
|
9
9
|
|
|
10
10
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
## [18.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v17.0.0...v18.0.0) (2020
|
|
13
|
+
## [18.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v17.0.0...v18.0.0) (March 19, 2020)
|
|
14
14
|
|
|
15
15
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
## [17.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v16.0.0...v17.0.0) (2020
|
|
18
|
+
## [17.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v16.0.0...v17.0.0) (February 19, 2020)
|
|
19
19
|
|
|
20
20
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
## [16.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v15.0.0...v16.0.0) (2019
|
|
23
|
+
## [16.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v15.0.0...v16.0.0) (December 4, 2019)
|
|
24
24
|
|
|
25
25
|
### Features
|
|
26
26
|
|
|
27
27
|
* The main editor toolbar should respect the `config.toolbar.shouldNotGroupWhenFull` configuration (see [ckeditor/ckeditor5#5692](https://github.com/ckeditor/ckeditor5/issues/5692)). ([35b3cbf](https://github.com/ckeditor/ckeditor5-editor-decoupled/commit/35b3cbf))
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
## [15.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.2.2...v15.0.0) (2019
|
|
30
|
+
## [15.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.2.2...v15.0.0) (October 23, 2019)
|
|
31
31
|
|
|
32
32
|
### Features
|
|
33
33
|
|
|
34
34
|
* Enabled automatic items grouping in the main editor toolbar when there is not enough space to display them in a single row (see [ckeditor/ckeditor5#416](https://github.com/ckeditor/ckeditor5/issues/416)). ([eb52505](https://github.com/ckeditor/ckeditor5-editor-decoupled/commit/eb52505))
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
## [12.2.2](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.2.1...v12.2.2) (2019
|
|
37
|
+
## [12.2.2](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.2.1...v12.2.2) (August 26, 2019)
|
|
38
38
|
|
|
39
39
|
### Other changes
|
|
40
40
|
|
|
@@ -42,31 +42,31 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
42
42
|
* Introduced a check that prevents sharing source elements between editor instances. See [ckeditor/ckeditor5#746](https://github.com/ckeditor/ckeditor5/issues/746). ([c73b045](https://github.com/ckeditor/ckeditor5-editor-decoupled/commit/c73b045))
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
## [12.2.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.2.0...v12.2.1) (2019
|
|
45
|
+
## [12.2.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.2.0...v12.2.1) (July 10, 2019)
|
|
46
46
|
|
|
47
47
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
## [12.2.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.1.1...v12.2.0) (2019
|
|
50
|
+
## [12.2.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.1.1...v12.2.0) (July 4, 2019)
|
|
51
51
|
|
|
52
52
|
### Features
|
|
53
53
|
|
|
54
54
|
* `DecoupledEditor.create()` will throw an error, when a `<textarea>` element is used. ([af4daea](https://github.com/ckeditor/ckeditor5-editor-decoupled/commit/af4daea))
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
## [12.1.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.1.0...v12.1.1) (2019
|
|
57
|
+
## [12.1.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.1.0...v12.1.1) (June 6, 2019)
|
|
58
58
|
|
|
59
59
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
## [12.1.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.0.0...v12.1.0) (2019
|
|
62
|
+
## [12.1.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v12.0.0...v12.1.0) (April 4, 2019)
|
|
63
63
|
|
|
64
64
|
### Features
|
|
65
65
|
|
|
66
66
|
* Introduced `EditorConfig#initialData`. ([7e01ca7](https://github.com/ckeditor/ckeditor5-editor-decoupled/commit/7e01ca7))
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
## [12.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v11.0.2...v12.0.0) (2019
|
|
69
|
+
## [12.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v11.0.2...v12.0.0) (February 28, 2019)
|
|
70
70
|
|
|
71
71
|
### Features
|
|
72
72
|
|
|
@@ -91,17 +91,17 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
91
91
|
* Removed `DecoupledEditorUIView#editableElement`. Instead `DecoupledEditorUI#getEditableElement()` method should be used.
|
|
92
92
|
|
|
93
93
|
|
|
94
|
-
## [11.0.2](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v11.0.1...v11.0.2) (2018
|
|
94
|
+
## [11.0.2](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v11.0.1...v11.0.2) (December 5, 2018)
|
|
95
95
|
|
|
96
96
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
## [11.0.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v11.0.0...v11.0.1) (2018
|
|
99
|
+
## [11.0.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v11.0.0...v11.0.1) (October 8, 2018)
|
|
100
100
|
|
|
101
101
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
## [11.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v10.0.2...v11.0.0) (2018
|
|
104
|
+
## [11.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v10.0.2...v11.0.0) (July 18, 2018)
|
|
105
105
|
|
|
106
106
|
### Other changes
|
|
107
107
|
|
|
@@ -113,19 +113,19 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
113
113
|
* The `DecoupledEditor#element` property was renamed to `DecoupledEditor#sourceElement`. See [ckeditor/ckeditor5-core#64](https://github.com/ckeditor/ckeditor5-core/issues/64).
|
|
114
114
|
|
|
115
115
|
|
|
116
|
-
## [10.0.2](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v10.0.1...v10.0.2) (2018
|
|
116
|
+
## [10.0.2](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v10.0.1...v10.0.2) (June 21, 2018)
|
|
117
117
|
|
|
118
118
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
## [10.0.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v10.0.0...v10.0.1) (2018
|
|
121
|
+
## [10.0.1](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v10.0.0...v10.0.1) (May 22, 2018)
|
|
122
122
|
|
|
123
123
|
### Bug fixes
|
|
124
124
|
|
|
125
125
|
* Added missing `return` to the data initialization step (fixes asynchronous data initialization, important for real-time collaboration features). Closes [#13](https://github.com/ckeditor/ckeditor5-editor-decoupled/issues/13). ([f4e496d](https://github.com/ckeditor/ckeditor5-editor-decoupled/commit/f4e496d))
|
|
126
126
|
|
|
127
127
|
|
|
128
|
-
## [10.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v1.0.0-beta.4...v10.0.0) (2018
|
|
128
|
+
## [10.0.0](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v1.0.0-beta.4...v10.0.0) (April 25, 2018)
|
|
129
129
|
|
|
130
130
|
### Other changes
|
|
131
131
|
|
|
@@ -136,12 +136,12 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
136
136
|
* The license under which CKEditor 5 is released has been changed from a triple GPL, LGPL and MPL license to a GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991) for more information.
|
|
137
137
|
|
|
138
138
|
|
|
139
|
-
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v1.0.0-beta.2...v1.0.0-beta.4) (2018
|
|
139
|
+
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v1.0.0-beta.2...v1.0.0-beta.4) (April 19, 2018)
|
|
140
140
|
|
|
141
141
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
142
142
|
|
|
143
143
|
|
|
144
|
-
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2018
|
|
144
|
+
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-editor-decoupled/compare/v1.0.0-beta.1...v1.0.0-beta.2) (April 10, 2018)
|
|
145
145
|
|
|
146
146
|
### Other changes
|
|
147
147
|
|
|
@@ -152,7 +152,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
152
152
|
* The config options `config.toolbarContainer` and `config.editableContainer` have been removed. Please refer to the `DecoupledEditor` class API documentation to learn about possible methods of bootstrapping the UI.
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
## 1.0.0-beta.1 (2018
|
|
155
|
+
## 1.0.0-beta.1 (March 15, 2018)
|
|
156
156
|
|
|
157
157
|
### Features
|
|
158
158
|
|
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.2.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.2.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 {};
|