@ckeditor/ckeditor5-editor-classic 36.0.1 → 37.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -16
- package/src/classiceditor.d.ts +161 -0
- package/src/classiceditor.js +1 -1
- package/src/classiceditorui.d.ts +56 -0
- package/src/classiceditoruiview.d.ts +47 -0
- package/src/index.d.ts +8 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-editor-classic",
|
3
|
-
"version": "
|
3
|
+
"version": "37.0.0-alpha.0",
|
4
4
|
"description": "Classic editor implementation for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -11,23 +11,23 @@
|
|
11
11
|
],
|
12
12
|
"main": "src/index.js",
|
13
13
|
"dependencies": {
|
14
|
-
"ckeditor5": "^
|
14
|
+
"ckeditor5": "^37.0.0-alpha.0",
|
15
15
|
"lodash-es": "^4.17.15"
|
16
16
|
},
|
17
17
|
"devDependencies": {
|
18
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
19
|
-
"@ckeditor/ckeditor5-core": "^
|
20
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
21
|
-
"@ckeditor/ckeditor5-engine": "^
|
22
|
-
"@ckeditor/ckeditor5-enter": "^
|
23
|
-
"@ckeditor/ckeditor5-heading": "^
|
24
|
-
"@ckeditor/ckeditor5-image": "^
|
25
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
26
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
27
|
-
"@ckeditor/ckeditor5-typing": "^
|
28
|
-
"@ckeditor/ckeditor5-ui": "^
|
29
|
-
"@ckeditor/ckeditor5-undo": "^
|
30
|
-
"@ckeditor/ckeditor5-utils": "^
|
18
|
+
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
|
19
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
|
20
|
+
"@ckeditor/ckeditor5-dev-utils": "^34.0.0",
|
21
|
+
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
|
22
|
+
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
|
23
|
+
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
|
24
|
+
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
|
25
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
|
26
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
|
27
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
|
28
|
+
"@ckeditor/ckeditor5-ui": "^37.0.0-alpha.0",
|
29
|
+
"@ckeditor/ckeditor5-undo": "^37.0.0-alpha.0",
|
30
|
+
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
|
31
31
|
"typescript": "^4.8.4",
|
32
32
|
"webpack": "^5.58.1",
|
33
33
|
"webpack-cli": "^4.9.0"
|
@@ -58,5 +58,6 @@
|
|
58
58
|
"dll:build": "webpack",
|
59
59
|
"build": "tsc -p ./tsconfig.release.json",
|
60
60
|
"postversion": "npm run build"
|
61
|
-
}
|
61
|
+
},
|
62
|
+
"types": "src/index.d.ts"
|
62
63
|
}
|
@@ -0,0 +1,161 @@
|
|
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-classic/classiceditor
|
7
|
+
*/
|
8
|
+
import ClassicEditorUI from './classiceditorui';
|
9
|
+
import { Editor, type EditorConfig } from 'ckeditor5/src/core';
|
10
|
+
declare const ClassicEditor_base: import("ckeditor5/src/utils").Mixed<import("ckeditor5/src/utils").Mixed<typeof Editor, import("ckeditor5/src/core").ElementApi>, import("ckeditor5/src/core").DataApi>;
|
11
|
+
/**
|
12
|
+
* The {@glink installation/getting-started/predefined-builds#classic-editor classic editor} implementation.
|
13
|
+
* It uses an inline editable and a sticky toolbar, all enclosed in a boxed UI.
|
14
|
+
* See the {@glink examples/builds/classic-editor demo}.
|
15
|
+
*
|
16
|
+
* In order to create a classic editor instance, use the static
|
17
|
+
* {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`} method.
|
18
|
+
*
|
19
|
+
* # Classic editor and classic build
|
20
|
+
*
|
21
|
+
* The classic editor can be used directly from source (if you installed the
|
22
|
+
* [`@ckeditor/ckeditor5-editor-classic`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-classic) package)
|
23
|
+
* but it is also available in the {@glink installation/getting-started/predefined-builds#classic-editor classic build}.
|
24
|
+
*
|
25
|
+
* {@glink installation/getting-started/predefined-builds Builds}
|
26
|
+
* are ready-to-use editors with plugins bundled in. When using the editor from
|
27
|
+
* source you need to take care of loading all plugins by yourself
|
28
|
+
* (through the {@link module:core/editor/editorconfig~EditorConfig#plugins `config.plugins`} option).
|
29
|
+
* Using the editor from source gives much better flexibility and allows easier customization.
|
30
|
+
*
|
31
|
+
* Read more about initializing the editor from source or as a build in
|
32
|
+
* {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
|
33
|
+
*/
|
34
|
+
export default class ClassicEditor extends ClassicEditor_base {
|
35
|
+
/**
|
36
|
+
* @inheritDoc
|
37
|
+
*/
|
38
|
+
readonly ui: ClassicEditorUI;
|
39
|
+
/**
|
40
|
+
* Creates an instance of the classic editor.
|
41
|
+
*
|
42
|
+
* **Note:** do not use the constructor to create editor instances. Use the static
|
43
|
+
* {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`} method instead.
|
44
|
+
*
|
45
|
+
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
46
|
+
* or the editor's initial data. For more information see
|
47
|
+
* {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}.
|
48
|
+
* @param config The editor configuration.
|
49
|
+
*/
|
50
|
+
protected constructor(sourceElementOrData: HTMLElement | string, config?: EditorConfig);
|
51
|
+
/**
|
52
|
+
* Destroys the editor instance, releasing all resources used by it.
|
53
|
+
*
|
54
|
+
* Updates the original editor element with the data if the
|
55
|
+
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
|
56
|
+
* configuration option is set to `true`.
|
57
|
+
*/
|
58
|
+
destroy(): Promise<unknown>;
|
59
|
+
/**
|
60
|
+
* Creates a new classic editor instance.
|
61
|
+
*
|
62
|
+
* There are three ways how the editor can be initialized.
|
63
|
+
*
|
64
|
+
* # Replacing a DOM element (and loading data from it)
|
65
|
+
*
|
66
|
+
* You can initialize the editor using an existing DOM element:
|
67
|
+
*
|
68
|
+
* ```ts
|
69
|
+
* ClassicEditor
|
70
|
+
* .create( document.querySelector( '#editor' ) )
|
71
|
+
* .then( editor => {
|
72
|
+
* console.log( 'Editor was initialized', editor );
|
73
|
+
* } )
|
74
|
+
* .catch( err => {
|
75
|
+
* console.error( err.stack );
|
76
|
+
* } );
|
77
|
+
* ```
|
78
|
+
*
|
79
|
+
* The element's content will be used as the editor data and the element will be replaced by the editor UI.
|
80
|
+
*
|
81
|
+
* # Creating a detached editor
|
82
|
+
*
|
83
|
+
* Alternatively, you can initialize the editor by passing the initial data directly as a string.
|
84
|
+
* In this case, the editor will render an element that must be inserted into the DOM:
|
85
|
+
*
|
86
|
+
* ```ts
|
87
|
+
* ClassicEditor
|
88
|
+
* .create( '<p>Hello world!</p>' )
|
89
|
+
* .then( editor => {
|
90
|
+
* console.log( 'Editor was initialized', editor );
|
91
|
+
*
|
92
|
+
* // Initial data was provided so the editor UI element needs to be added manually to the DOM.
|
93
|
+
* document.body.appendChild( editor.ui.element );
|
94
|
+
* } )
|
95
|
+
* .catch( err => {
|
96
|
+
* console.error( err.stack );
|
97
|
+
* } );
|
98
|
+
* ```
|
99
|
+
*
|
100
|
+
* This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
|
101
|
+
* web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
|
102
|
+
*
|
103
|
+
* # Replacing a DOM element (and data provided in `config.initialData`)
|
104
|
+
*
|
105
|
+
* You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
|
106
|
+
*
|
107
|
+
* ```ts
|
108
|
+
* ClassicEditor
|
109
|
+
* .create( document.querySelector( '#editor' ), {
|
110
|
+
* initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
|
111
|
+
* } )
|
112
|
+
* .then( editor => {
|
113
|
+
* console.log( 'Editor was initialized', editor );
|
114
|
+
* } )
|
115
|
+
* .catch( err => {
|
116
|
+
* console.error( err.stack );
|
117
|
+
* } );
|
118
|
+
* ```
|
119
|
+
*
|
120
|
+
* This method can be used to initialize the editor on an existing element with the specified content in case if your integration
|
121
|
+
* makes it difficult to set the content of the source element.
|
122
|
+
*
|
123
|
+
* Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
|
124
|
+
*
|
125
|
+
* # Configuring the editor
|
126
|
+
*
|
127
|
+
* See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
|
128
|
+
* customizing plugins, toolbar and more.
|
129
|
+
*
|
130
|
+
* # Using the editor from source
|
131
|
+
*
|
132
|
+
* The code samples listed in the previous sections of this documentation assume that you are using an
|
133
|
+
* {@glink installation/getting-started/predefined-builds editor build} (for example – `@ckeditor/ckeditor5-build-classic`).
|
134
|
+
*
|
135
|
+
* If you want to use the classic editor from source (`@ckeditor/ckeditor5-editor-classic/src/classiceditor`),
|
136
|
+
* you need to define the list of
|
137
|
+
* {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
|
138
|
+
* {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
|
139
|
+
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
|
140
|
+
*
|
141
|
+
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
142
|
+
* or the editor's initial data.
|
143
|
+
*
|
144
|
+
* If a DOM element is passed, its content will be automatically loaded to the editor upon initialization
|
145
|
+
* and the {@link module:editor-classic/classiceditorui~ClassicEditorUI#element editor element} will replace the passed element
|
146
|
+
* in the DOM (the original one will be hidden and the editor will be injected next to it).
|
147
|
+
*
|
148
|
+
* If the {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
|
149
|
+
* option is set to `true`, the editor data will be set back to the original element once the editor is destroyed and when a form,
|
150
|
+
* in which this element is contained, is submitted (if the original element is a `<textarea>`). This ensures seamless integration
|
151
|
+
* with native web forms.
|
152
|
+
*
|
153
|
+
* If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
|
154
|
+
* It is available under the {@link module:editor-classic/classiceditorui~ClassicEditorUI#element `editor.ui.element`} property.
|
155
|
+
*
|
156
|
+
* @param config The editor configuration.
|
157
|
+
* @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
|
158
|
+
*/
|
159
|
+
static create(sourceElementOrData: HTMLElement | string, config?: EditorConfig): Promise<ClassicEditor>;
|
160
|
+
}
|
161
|
+
export {};
|
package/src/classiceditor.js
CHANGED
@@ -161,7 +161,7 @@ export default class ClassicEditor extends DataApiMixin(ElementApiMixin(Editor))
|
|
161
161
|
* you need to define the list of
|
162
162
|
* {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
|
163
163
|
* {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
|
164
|
-
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source dedicated guide}.
|
164
|
+
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
|
165
165
|
*
|
166
166
|
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
167
167
|
* or the editor's initial data.
|
@@ -0,0 +1,56 @@
|
|
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-classic/classiceditorui
|
7
|
+
*/
|
8
|
+
import type { Editor } from 'ckeditor5/src/core';
|
9
|
+
import { EditorUI } from 'ckeditor5/src/ui';
|
10
|
+
import type ClassicEditorUIView from './classiceditoruiview';
|
11
|
+
/**
|
12
|
+
* The classic editor UI class.
|
13
|
+
*/
|
14
|
+
export default class ClassicEditorUI extends EditorUI {
|
15
|
+
/**
|
16
|
+
* The main (top–most) view of the editor UI.
|
17
|
+
*/
|
18
|
+
readonly view: ClassicEditorUIView;
|
19
|
+
/**
|
20
|
+
* A normalized `config.toolbar` object.
|
21
|
+
*/
|
22
|
+
private readonly _toolbarConfig;
|
23
|
+
/**
|
24
|
+
* The element replacer instance used to hide the editor's source element.
|
25
|
+
*/
|
26
|
+
private readonly _elementReplacer;
|
27
|
+
/**
|
28
|
+
* Creates an instance of the classic editor UI class.
|
29
|
+
*
|
30
|
+
* @param editor The editor instance.
|
31
|
+
* @param view The view of the UI.
|
32
|
+
*/
|
33
|
+
constructor(editor: Editor, view: ClassicEditorUIView);
|
34
|
+
/**
|
35
|
+
* @inheritDoc
|
36
|
+
*/
|
37
|
+
get element(): HTMLElement | null;
|
38
|
+
/**
|
39
|
+
* Initializes the UI.
|
40
|
+
*
|
41
|
+
* @param replacementElement The DOM element that will be the source for the created editor.
|
42
|
+
*/
|
43
|
+
init(replacementElement: HTMLElement | null): void;
|
44
|
+
/**
|
45
|
+
* @inheritDoc
|
46
|
+
*/
|
47
|
+
destroy(): void;
|
48
|
+
/**
|
49
|
+
* Initializes the editor toolbar.
|
50
|
+
*/
|
51
|
+
private _initToolbar;
|
52
|
+
/**
|
53
|
+
* Enable the placeholder text on the editing root, if any was configured.
|
54
|
+
*/
|
55
|
+
private _initPlaceholder;
|
56
|
+
}
|
@@ -0,0 +1,47 @@
|
|
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-classic/classiceditoruiview
|
7
|
+
*/
|
8
|
+
import { BoxedEditorUIView, InlineEditableUIView, StickyPanelView, ToolbarView } from 'ckeditor5/src/ui';
|
9
|
+
import type { Locale } from 'ckeditor5/src/utils';
|
10
|
+
import type { View } from 'ckeditor5/src/engine';
|
11
|
+
import '../theme/classiceditor.css';
|
12
|
+
/**
|
13
|
+
* Classic editor UI view. Uses an inline editable and a sticky toolbar, all
|
14
|
+
* enclosed in a boxed UI view.
|
15
|
+
*/
|
16
|
+
export default class ClassicEditorUIView extends BoxedEditorUIView {
|
17
|
+
/**
|
18
|
+
* Sticky panel view instance. This is a parent view of a {@link #toolbar}
|
19
|
+
* that makes toolbar sticky.
|
20
|
+
*/
|
21
|
+
readonly stickyPanel: StickyPanelView;
|
22
|
+
/**
|
23
|
+
* Toolbar view instance.
|
24
|
+
*/
|
25
|
+
readonly toolbar: ToolbarView;
|
26
|
+
/**
|
27
|
+
* Editable UI view.
|
28
|
+
*/
|
29
|
+
readonly editable: InlineEditableUIView;
|
30
|
+
/**
|
31
|
+
* Creates an instance of the classic editor UI view.
|
32
|
+
*
|
33
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
34
|
+
* @param editingView The editing view instance this view is related to.
|
35
|
+
* @param options Configuration options for the view instance.
|
36
|
+
* @param options.shouldToolbarGroupWhenFull When set `true` enables automatic items grouping
|
37
|
+
* in the main {@link module:editor-classic/classiceditoruiview~ClassicEditorUIView#toolbar toolbar}.
|
38
|
+
* See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
|
39
|
+
*/
|
40
|
+
constructor(locale: Locale, editingView: View, options?: {
|
41
|
+
shouldToolbarGroupWhenFull?: boolean;
|
42
|
+
});
|
43
|
+
/**
|
44
|
+
* @inheritDoc
|
45
|
+
*/
|
46
|
+
render(): void;
|
47
|
+
}
|
package/src/index.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
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-classic
|
7
|
+
*/
|
8
|
+
export { default as ClassicEditor } from './classiceditor';
|