@ckeditor/ckeditor5-ckbox 41.2.0 → 41.3.0-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/content-index.css +4 -0
- package/dist/editor-index.css +31 -0
- package/dist/index.css +55 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +1713 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +32 -0
- package/dist/types/ckbox.d.ts +33 -0
- package/dist/types/ckboxcommand.d.ts +114 -0
- package/dist/types/ckboxconfig.d.ts +325 -0
- package/dist/types/ckboxediting.d.ts +54 -0
- package/dist/types/ckboximageedit/ckboximageeditcommand.d.ts +97 -0
- package/dist/types/ckboximageedit/ckboximageeditediting.d.ts +28 -0
- package/dist/types/ckboximageedit/ckboximageeditui.d.ts +24 -0
- package/dist/types/ckboximageedit/utils.d.ts +10 -0
- package/dist/types/ckboximageedit.d.ts +24 -0
- package/dist/types/ckboxui.d.ts +21 -0
- package/dist/types/ckboxuploadadapter.d.ts +33 -0
- package/dist/types/ckboxutils.d.ts +50 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/utils.d.ts +63 -0
- package/package.json +3 -2
@@ -0,0 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
import type { CKBox, CKBoxCommand, CKBoxConfig, CKBoxEditing, CKBoxImageEdit, CKBoxImageEditEditing, CKBoxImageEditCommand, CKBoxImageEditUI } from './index.js';
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
7
|
+
interface EditorConfig {
|
8
|
+
/**
|
9
|
+
* The configuration of the {@link module:ckbox/ckbox~CKBox CKBox feature}.
|
10
|
+
*
|
11
|
+
* Read more in {@link module:ckbox/ckboxconfig~CKBoxConfig}.
|
12
|
+
*/
|
13
|
+
ckbox?: CKBoxConfig;
|
14
|
+
}
|
15
|
+
interface PluginsMap {
|
16
|
+
[CKBox.pluginName]: CKBox;
|
17
|
+
[CKBoxEditing.pluginName]: CKBoxEditing;
|
18
|
+
[CKBoxImageEdit.pluginName]: CKBoxImageEdit;
|
19
|
+
[CKBoxImageEditEditing.pluginName]: CKBoxImageEditEditing;
|
20
|
+
[CKBoxImageEditUI.pluginName]: CKBoxImageEditUI;
|
21
|
+
}
|
22
|
+
interface CommandsMap {
|
23
|
+
ckbox: CKBoxCommand;
|
24
|
+
ckboxImageEdit: CKBoxImageEditCommand;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
declare global {
|
28
|
+
var CKBox: {
|
29
|
+
mount(wrapper: Element, options: Record<string, unknown>): void;
|
30
|
+
mountImageEditor(wrapper: Element, options: Record<string, unknown>): void;
|
31
|
+
};
|
32
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module ckbox/ckbox
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
9
|
+
import CKBoxUI from './ckboxui.js';
|
10
|
+
import CKBoxEditing from './ckboxediting.js';
|
11
|
+
/**
|
12
|
+
* The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
|
13
|
+
*
|
14
|
+
* This is a "glue" plugin which enables:
|
15
|
+
*
|
16
|
+
* * {@link module:ckbox/ckboxediting~CKBoxEditing},
|
17
|
+
* * {@link module:ckbox/ckboxui~CKBoxUI},
|
18
|
+
*
|
19
|
+
* See the {@glink features/file-management/ckbox CKBox integration} guide to learn how to configure and use this feature.
|
20
|
+
*
|
21
|
+
* Check out the {@glink features/images/image-upload/image-upload Image upload} guide to learn about other ways to upload
|
22
|
+
* images into CKEditor 5.
|
23
|
+
*/
|
24
|
+
export default class CKBox extends Plugin {
|
25
|
+
/**
|
26
|
+
* @inheritDoc
|
27
|
+
*/
|
28
|
+
static get pluginName(): "CKBox";
|
29
|
+
/**
|
30
|
+
* @inheritDoc
|
31
|
+
*/
|
32
|
+
static get requires(): readonly [typeof CKBoxEditing, typeof CKBoxUI];
|
33
|
+
}
|
@@ -0,0 +1,114 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
6
|
+
import type { CKBoxAssetDefinition, CKBoxAssetImageAttributesDefinition, CKBoxRawAssetDefinition } from './ckboxconfig.js';
|
7
|
+
/**
|
8
|
+
* The CKBox command. It is used by the {@link module:ckbox/ckboxediting~CKBoxEditing CKBox editing feature} to open the CKBox file manager.
|
9
|
+
* The file manager allows inserting an image or a link to a file into the editor content.
|
10
|
+
*
|
11
|
+
* ```ts
|
12
|
+
* editor.execute( 'ckbox' );
|
13
|
+
* ```
|
14
|
+
*
|
15
|
+
* **Note:** This command uses other features to perform the following tasks:
|
16
|
+
* - To insert images it uses the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command from the
|
17
|
+
* {@link module:image/image~Image Image feature}.
|
18
|
+
* - To insert links to other files it uses the {@link module:link/linkcommand~LinkCommand 'link'} command from the
|
19
|
+
* {@link module:link/link~Link Link feature}.
|
20
|
+
*/
|
21
|
+
export default class CKBoxCommand extends Command {
|
22
|
+
value: boolean;
|
23
|
+
/**
|
24
|
+
* A set of all chosen assets. They are stored temporarily and they are automatically removed 1 second after being chosen.
|
25
|
+
* Chosen assets have to be "remembered" for a while to be able to map the given asset with the element inserted into the model.
|
26
|
+
* This association map is then used to set the ID on the model element.
|
27
|
+
*
|
28
|
+
* All chosen assets are automatically removed after the timeout, because (theoretically) it may happen that they will never be
|
29
|
+
* inserted into the model, even if the {@link module:link/linkcommand~LinkCommand `'link'`} command or the
|
30
|
+
* {@link module:image/image/insertimagecommand~InsertImageCommand `'insertImage'`} command is enabled. Such a case may arise when
|
31
|
+
* another plugin blocks the command execution. Then, in order not to keep the chosen (but not inserted) assets forever, we delete
|
32
|
+
* them automatically to prevent memory leakage. The 1 second timeout is enough to insert the asset into the model and extract the
|
33
|
+
* ID from the chosen asset.
|
34
|
+
*
|
35
|
+
* The assets are stored only if
|
36
|
+
* the {@link module:ckbox/ckboxconfig~CKBoxConfig#ignoreDataId `config.ckbox.ignoreDataId`} option is set to `false` (by default).
|
37
|
+
*
|
38
|
+
* @internal
|
39
|
+
*/
|
40
|
+
readonly _chosenAssets: Set<CKBoxAssetDefinition>;
|
41
|
+
/**
|
42
|
+
* The DOM element that acts as a mounting point for the CKBox dialog.
|
43
|
+
*/
|
44
|
+
private _wrapper;
|
45
|
+
/**
|
46
|
+
* @inheritDoc
|
47
|
+
*/
|
48
|
+
constructor(editor: Editor);
|
49
|
+
/**
|
50
|
+
* @inheritDoc
|
51
|
+
*/
|
52
|
+
refresh(): void;
|
53
|
+
/**
|
54
|
+
* @inheritDoc
|
55
|
+
*/
|
56
|
+
execute(): void;
|
57
|
+
/**
|
58
|
+
* Indicates if the CKBox dialog is already opened.
|
59
|
+
*
|
60
|
+
* @protected
|
61
|
+
* @returns {Boolean}
|
62
|
+
*/
|
63
|
+
private _getValue;
|
64
|
+
/**
|
65
|
+
* Checks whether the command can be enabled in the current context.
|
66
|
+
*/
|
67
|
+
private _checkEnabled;
|
68
|
+
/**
|
69
|
+
* Creates the options object for the CKBox dialog.
|
70
|
+
*
|
71
|
+
* @returns The object with properties:
|
72
|
+
* - theme The theme for CKBox dialog.
|
73
|
+
* - language The language for CKBox dialog.
|
74
|
+
* - tokenUrl The token endpoint URL.
|
75
|
+
* - serviceOrigin The base URL of the API service.
|
76
|
+
* - forceDemoLabel Whether to force "Powered by CKBox" link.
|
77
|
+
* - dialog.onClose The callback function invoked after closing the CKBox dialog.
|
78
|
+
* - assets.onChoose The callback function invoked after choosing the assets.
|
79
|
+
*/
|
80
|
+
private _prepareOptions;
|
81
|
+
/**
|
82
|
+
* Initializes various event listeners for the `ckbox:*` events, because all functionality of the `ckbox` command is event-based.
|
83
|
+
*/
|
84
|
+
private _initListeners;
|
85
|
+
/**
|
86
|
+
* Inserts the asset into the model.
|
87
|
+
*
|
88
|
+
* @param asset The asset to be inserted.
|
89
|
+
* @param isLastAsset Indicates if the current asset is the last one from the chosen set.
|
90
|
+
* @param writer An instance of the model writer.
|
91
|
+
* @param isSingleAsset It's true when only one asset is processed.
|
92
|
+
*/
|
93
|
+
private _insertAsset;
|
94
|
+
/**
|
95
|
+
* Inserts the image by calling the `insertImage` command.
|
96
|
+
*
|
97
|
+
* @param asset The asset to be inserted.
|
98
|
+
*/
|
99
|
+
private _insertImage;
|
100
|
+
/**
|
101
|
+
* Inserts the link to the asset by calling the `link` command.
|
102
|
+
*
|
103
|
+
* @param asset The asset to be inserted.
|
104
|
+
* @param writer An instance of the model writer.
|
105
|
+
* @param isSingleAsset It's true when only one asset is processed.
|
106
|
+
*/
|
107
|
+
private _insertLink;
|
108
|
+
}
|
109
|
+
/**
|
110
|
+
* Parses the assets attributes into the internal data format.
|
111
|
+
*
|
112
|
+
* @internal
|
113
|
+
*/
|
114
|
+
export declare function prepareImageAssetAttributes(asset: CKBoxRawAssetDefinition): CKBoxAssetImageAttributesDefinition;
|
@@ -0,0 +1,325 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module ckbox/ckboxconfig
|
7
|
+
*/
|
8
|
+
import type { TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
|
9
|
+
import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
|
10
|
+
/**
|
11
|
+
* The configuration of the {@link module:ckbox/ckbox~CKBox CKBox feature}.
|
12
|
+
*
|
13
|
+
* The minimal configuration for the CKBox feature requires providing the
|
14
|
+
* {@link module:ckbox/ckboxconfig~CKBoxConfig#tokenUrl `config.ckbox.tokenUrl`}:
|
15
|
+
*
|
16
|
+
* ```ts
|
17
|
+
* ClassicEditor
|
18
|
+
* .create( editorElement, {
|
19
|
+
* ckbox: {
|
20
|
+
* tokenUrl: 'https://example.com/cs-token-endpoint'
|
21
|
+
* }
|
22
|
+
* } )
|
23
|
+
* .then( ... )
|
24
|
+
* .catch( ... );
|
25
|
+
* ```
|
26
|
+
*
|
27
|
+
* Hovewer, you can also adjust the feature to fit your needs:
|
28
|
+
*
|
29
|
+
* ```ts
|
30
|
+
* ClassicEditor
|
31
|
+
* .create( editorElement, {
|
32
|
+
* ckbox: {
|
33
|
+
* defaultUploadCategories: {
|
34
|
+
* Bitmaps: [ 'bmp' ],
|
35
|
+
* Pictures: [ 'jpg', 'jpeg' ],
|
36
|
+
* Scans: [ 'png', 'tiff' ]
|
37
|
+
* },
|
38
|
+
* ignoreDataId: true,
|
39
|
+
* serviceOrigin: 'https://example.com/',
|
40
|
+
* tokenUrl: 'https://example.com/cs-token-endpoint'
|
41
|
+
* }
|
42
|
+
* } )
|
43
|
+
* .then( ... )
|
44
|
+
* .catch( ... );
|
45
|
+
* ```
|
46
|
+
*
|
47
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
48
|
+
*/
|
49
|
+
export interface CKBoxConfig {
|
50
|
+
/**
|
51
|
+
* The authentication token URL for CKBox feature.
|
52
|
+
*
|
53
|
+
* Defaults to {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl `config.cloudServices.tokenUrl`}
|
54
|
+
*/
|
55
|
+
tokenUrl?: TokenUrl;
|
56
|
+
/**
|
57
|
+
* The theme for CKBox dialog.
|
58
|
+
*/
|
59
|
+
theme?: string;
|
60
|
+
/**
|
61
|
+
* Defines the categories to which the uploaded images will be assigned.
|
62
|
+
* If configured, it overrides the category mappings defined on the cloud service.
|
63
|
+
* The value of this option should be an object, where the keys define categories and their values are the types of images
|
64
|
+
* that will be uploaded to these categories. The categories might be referenced by their name or ID.
|
65
|
+
*
|
66
|
+
* Example:
|
67
|
+
*
|
68
|
+
* ```ts
|
69
|
+
* const ckboxConfig = {
|
70
|
+
* defaultUploadCategories: {
|
71
|
+
* Bitmaps: [ 'bmp' ],
|
72
|
+
* Pictures: [ 'jpg', 'jpeg' ],
|
73
|
+
* Scans: [ 'png', 'tiff' ],
|
74
|
+
* // The category below is referenced by its ID.
|
75
|
+
* 'fdf2a647-b67f-4a6c-b692-5ba1dc1ed87b': [ 'gif' ]
|
76
|
+
* }
|
77
|
+
* };
|
78
|
+
* ```
|
79
|
+
*
|
80
|
+
* @default null
|
81
|
+
*/
|
82
|
+
defaultUploadCategories?: Record<string, Array<string>> | null;
|
83
|
+
/**
|
84
|
+
* Defines the workspace id to use during upload when the user has access to more than one workspace.
|
85
|
+
*
|
86
|
+
* If defined, it is an error, when the user has no access to the specified workspace.
|
87
|
+
*/
|
88
|
+
defaultUploadWorkspaceId?: string;
|
89
|
+
/**
|
90
|
+
* Enforces displaying the "Powered by CKBox" link regardless of the CKBox plan used.
|
91
|
+
*/
|
92
|
+
forceDemoLabel?: boolean;
|
93
|
+
/**
|
94
|
+
* Allows editing images that are not hosted in CKBox service.
|
95
|
+
*
|
96
|
+
* This configuration option should whitelist URL(s) of images that should be editable.
|
97
|
+
* Make sure that allowed image resources have CORS enabled.
|
98
|
+
*
|
99
|
+
* The image is editable if this option is:
|
100
|
+
* * a regular expression and it matches the image URL, or
|
101
|
+
* * a custom function that returns `true` for the image URL, or
|
102
|
+
* * `'origin'` literal and the image URL is from the same origin, or
|
103
|
+
* * an array of the above and the image URL matches one of the array elements.
|
104
|
+
*
|
105
|
+
* Images hosted in CKBox are always editable.
|
106
|
+
*
|
107
|
+
* @default []
|
108
|
+
*/
|
109
|
+
allowExternalImagesEditing?: ArrayOrItem<RegExp | 'origin' | ((src: string) => boolean)>;
|
110
|
+
/**
|
111
|
+
* Inserts the unique asset ID as the `data-ckbox-resource-id` attribute. To disable this behavior, set it to `true`.
|
112
|
+
*
|
113
|
+
* @default false
|
114
|
+
*/
|
115
|
+
ignoreDataId?: boolean;
|
116
|
+
/**
|
117
|
+
* Configures the base URL of the API service. Required only in on-premises installations.
|
118
|
+
*
|
119
|
+
* @default 'https://api.ckbox.io'
|
120
|
+
*/
|
121
|
+
serviceOrigin?: string;
|
122
|
+
/**
|
123
|
+
* Configures the language for the CKBox dialog.
|
124
|
+
*
|
125
|
+
* Defaults to {@link module:utils/locale~Locale#uiLanguage `Locale#uiLanguage`}
|
126
|
+
*/
|
127
|
+
language?: string;
|
128
|
+
}
|
129
|
+
/**
|
130
|
+
* Asset definition.
|
131
|
+
*
|
132
|
+
* The definition contains the unique `id`, asset `type` and an `attributes` definition.
|
133
|
+
*/
|
134
|
+
export type CKBoxAssetDefinition = CKBoxAssetImageDefinition | CKBoxAssetLinkDefinition;
|
135
|
+
/**
|
136
|
+
* Image asset definition.
|
137
|
+
*
|
138
|
+
* The definition contains the unique `id`, asset `type` and an `attributes` definition.
|
139
|
+
*/
|
140
|
+
export interface CKBoxAssetImageDefinition {
|
141
|
+
/**
|
142
|
+
* An unique asset id.
|
143
|
+
*/
|
144
|
+
id: string;
|
145
|
+
/**
|
146
|
+
* Asset type.
|
147
|
+
*/
|
148
|
+
type: 'image';
|
149
|
+
/**
|
150
|
+
* Asset attributes.
|
151
|
+
*/
|
152
|
+
attributes: CKBoxAssetImageAttributesDefinition;
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* Link asset definition.
|
156
|
+
*
|
157
|
+
* The definition contains the unique `id`, asset `type` and an `attributes` definition.
|
158
|
+
*/
|
159
|
+
export interface CKBoxAssetLinkDefinition {
|
160
|
+
/**
|
161
|
+
* An unique asset id.
|
162
|
+
*/
|
163
|
+
id: string;
|
164
|
+
/**
|
165
|
+
* Asset type.
|
166
|
+
*/
|
167
|
+
type: 'link';
|
168
|
+
/**
|
169
|
+
* Asset attributes.
|
170
|
+
*/
|
171
|
+
attributes: CKBoxAssetLinkAttributesDefinition;
|
172
|
+
}
|
173
|
+
/**
|
174
|
+
* Asset attributes definition for an image.
|
175
|
+
*
|
176
|
+
* The definition contains the `imageFallbackUrl`, an `imageSources` array with one image source definition object and the
|
177
|
+
* `imageTextAlternative`.
|
178
|
+
*
|
179
|
+
* ```ts
|
180
|
+
* {
|
181
|
+
* imageFallbackUrl: 'https://example.com/assets/asset-id/images/1000.png',
|
182
|
+
* imageSources: [
|
183
|
+
* {
|
184
|
+
* sizes: '1000px',
|
185
|
+
* srcset:
|
186
|
+
* 'https://example.com/assets/asset-id/images/100.webp 100w,' +
|
187
|
+
* 'https://example.com/assets/asset-id/images/200.webp 200w,' +
|
188
|
+
* 'https://example.com/assets/asset-id/images/300.webp 300w,' +
|
189
|
+
* 'https://example.com/assets/asset-id/images/400.webp 400w,' +
|
190
|
+
* 'https://example.com/assets/asset-id/images/500.webp 500w,' +
|
191
|
+
* 'https://example.com/assets/asset-id/images/600.webp 600w,' +
|
192
|
+
* 'https://example.com/assets/asset-id/images/700.webp 700w,' +
|
193
|
+
* 'https://example.com/assets/asset-id/images/800.webp 800w,' +
|
194
|
+
* 'https://example.com/assets/asset-id/images/900.webp 900w,' +
|
195
|
+
* 'https://example.com/assets/asset-id/images/1000.webp 1000w',
|
196
|
+
* type: 'image/webp'
|
197
|
+
* }
|
198
|
+
* ],
|
199
|
+
* imageTextAlternative: 'An alternative text for the image'
|
200
|
+
* }
|
201
|
+
* ```
|
202
|
+
*/
|
203
|
+
export interface CKBoxAssetImageAttributesDefinition {
|
204
|
+
/**
|
205
|
+
* A fallback URL for browsers that do not support the "webp" format.
|
206
|
+
*/
|
207
|
+
imageFallbackUrl: string;
|
208
|
+
/**
|
209
|
+
* An array containing one image source definition object.
|
210
|
+
*/
|
211
|
+
imageSources: Array<{
|
212
|
+
srcset: string;
|
213
|
+
sizes: string;
|
214
|
+
type: string;
|
215
|
+
}>;
|
216
|
+
/**
|
217
|
+
* An alternative text for an image.
|
218
|
+
*/
|
219
|
+
imageTextAlternative: string;
|
220
|
+
/**
|
221
|
+
* Image width.
|
222
|
+
*/
|
223
|
+
imageWidth?: number;
|
224
|
+
/**
|
225
|
+
* Image height.
|
226
|
+
*/
|
227
|
+
imageHeight?: number;
|
228
|
+
/**
|
229
|
+
* Image placeholder image.
|
230
|
+
*/
|
231
|
+
imagePlaceholder?: string;
|
232
|
+
}
|
233
|
+
/**
|
234
|
+
* Asset attributes definition for a link.
|
235
|
+
*
|
236
|
+
* The definition contains the `linkName` and `linkHref` strings.
|
237
|
+
*
|
238
|
+
* ```ts
|
239
|
+
* {
|
240
|
+
* linkName: 'File name',
|
241
|
+
* linkHref: 'https://example.com/assets/asset-id/file.pdf'
|
242
|
+
* }
|
243
|
+
* ```
|
244
|
+
*/
|
245
|
+
export interface CKBoxAssetLinkAttributesDefinition {
|
246
|
+
/**
|
247
|
+
* A link name.
|
248
|
+
*/
|
249
|
+
linkName: string;
|
250
|
+
/**
|
251
|
+
* An URL for the asset.
|
252
|
+
*/
|
253
|
+
linkHref: string;
|
254
|
+
}
|
255
|
+
/**
|
256
|
+
* The source set of the responsive image provided by the CKBox backend.
|
257
|
+
*
|
258
|
+
* Each numeric key corresponds to display width of the image.
|
259
|
+
*/
|
260
|
+
export interface CKBoxImageUrls {
|
261
|
+
[width: number]: string;
|
262
|
+
/**
|
263
|
+
* A fallback URL for browsers that do not support the "webp" format.
|
264
|
+
*/
|
265
|
+
default: string;
|
266
|
+
}
|
267
|
+
/**
|
268
|
+
* Raw asset definition that is received from the CKBox feature.
|
269
|
+
*/
|
270
|
+
export interface CKBoxRawAssetDefinition {
|
271
|
+
/**
|
272
|
+
* A raw asset data definition.
|
273
|
+
*/
|
274
|
+
data: CKBoxRawAssetDataDefinition;
|
275
|
+
}
|
276
|
+
/**
|
277
|
+
* Part of raw asset data that is received from the CKBox feature.
|
278
|
+
*/
|
279
|
+
export interface CKBoxRawAssetDataDefinition {
|
280
|
+
/**
|
281
|
+
* An unique asset id.
|
282
|
+
*/
|
283
|
+
id: string;
|
284
|
+
/**
|
285
|
+
* An asset name.
|
286
|
+
*/
|
287
|
+
name: string;
|
288
|
+
/**
|
289
|
+
* A raw asset metadata definition.
|
290
|
+
*/
|
291
|
+
metadata?: CKBoxRawAssetMetadataDefinition;
|
292
|
+
/**
|
293
|
+
* The source set of the responsive image.
|
294
|
+
*/
|
295
|
+
imageUrls?: CKBoxImageUrls;
|
296
|
+
/**
|
297
|
+
* The asset location.
|
298
|
+
*/
|
299
|
+
url: string;
|
300
|
+
}
|
301
|
+
/**
|
302
|
+
* Part of raw asset data that is received from the CKBox feature. Properties are set only if the chosen asset is an image.
|
303
|
+
*/
|
304
|
+
export interface CKBoxRawAssetMetadataDefinition {
|
305
|
+
/**
|
306
|
+
* Image description.
|
307
|
+
*/
|
308
|
+
description?: string;
|
309
|
+
/**
|
310
|
+
* Image width.
|
311
|
+
*/
|
312
|
+
width?: number;
|
313
|
+
/**
|
314
|
+
* Image height.
|
315
|
+
*/
|
316
|
+
height?: number;
|
317
|
+
/**
|
318
|
+
* The blurhash placeholder value.
|
319
|
+
*/
|
320
|
+
blurHash?: string;
|
321
|
+
/**
|
322
|
+
* The processing status of the asset.
|
323
|
+
*/
|
324
|
+
metadataProcessingStatus?: string;
|
325
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
6
|
+
import CKBoxUploadAdapter from './ckboxuploadadapter.js';
|
7
|
+
import CKBoxUtils from './ckboxutils.js';
|
8
|
+
/**
|
9
|
+
* The CKBox editing feature. It introduces the {@link module:ckbox/ckboxcommand~CKBoxCommand CKBox command} and
|
10
|
+
* {@link module:ckbox/ckboxuploadadapter~CKBoxUploadAdapter CKBox upload adapter}.
|
11
|
+
*/
|
12
|
+
export default class CKBoxEditing extends Plugin {
|
13
|
+
/**
|
14
|
+
* CKEditor Cloud Services access token.
|
15
|
+
*/
|
16
|
+
private _token;
|
17
|
+
/**
|
18
|
+
* @inheritDoc
|
19
|
+
*/
|
20
|
+
static get pluginName(): "CKBoxEditing";
|
21
|
+
/**
|
22
|
+
* @inheritDoc
|
23
|
+
*/
|
24
|
+
static get requires(): readonly ["LinkEditing", "PictureEditing", typeof CKBoxUploadAdapter, typeof CKBoxUtils];
|
25
|
+
/**
|
26
|
+
* @inheritDoc
|
27
|
+
*/
|
28
|
+
init(): void;
|
29
|
+
/**
|
30
|
+
* @inheritDoc
|
31
|
+
*/
|
32
|
+
afterInit(): void;
|
33
|
+
/**
|
34
|
+
* Returns true only when the integrator intentionally wants to use the plugin, i.e. when the `config.ckbox` exists or
|
35
|
+
* the CKBox JavaScript library is loaded.
|
36
|
+
*/
|
37
|
+
private _shouldBeInitialised;
|
38
|
+
/**
|
39
|
+
* Checks if at least one image plugin is loaded.
|
40
|
+
*/
|
41
|
+
private _checkImagePlugins;
|
42
|
+
/**
|
43
|
+
* Extends the schema to allow the `ckboxImageId` and `ckboxLinkId` attributes for links and images.
|
44
|
+
*/
|
45
|
+
private _initSchema;
|
46
|
+
/**
|
47
|
+
* Configures the upcast and downcast conversions for the `ckboxImageId` and `ckboxLinkId` attributes.
|
48
|
+
*/
|
49
|
+
private _initConversion;
|
50
|
+
/**
|
51
|
+
* Registers post-fixers that add or remove the `ckboxLinkId` and `ckboxImageId` attributes.
|
52
|
+
*/
|
53
|
+
private _initFixers;
|
54
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module ckbox/ckboximageedit/ckboximageeditcommand
|
7
|
+
*/
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
9
|
+
/**
|
10
|
+
* The CKBox edit image command.
|
11
|
+
*
|
12
|
+
* Opens the CKBox dialog for editing the image.
|
13
|
+
*/
|
14
|
+
export default class CKBoxImageEditCommand extends Command {
|
15
|
+
/**
|
16
|
+
* Flag indicating whether the command is active, i.e. dialog is open.
|
17
|
+
*/
|
18
|
+
value: boolean;
|
19
|
+
/**
|
20
|
+
* The DOM element that acts as a mounting point for the CKBox Edit Image dialog.
|
21
|
+
*/
|
22
|
+
private _wrapper;
|
23
|
+
/**
|
24
|
+
* The states of image processing in progress.
|
25
|
+
*/
|
26
|
+
private _processInProgress;
|
27
|
+
/**
|
28
|
+
* Determines if the element can be edited.
|
29
|
+
*/
|
30
|
+
private _canEdit;
|
31
|
+
/**
|
32
|
+
* A wrapper function to prepare mount options. Ensures that at most one preparation is in-flight.
|
33
|
+
*/
|
34
|
+
private _prepareOptions;
|
35
|
+
/**
|
36
|
+
* @inheritDoc
|
37
|
+
*/
|
38
|
+
constructor(editor: Editor);
|
39
|
+
/**
|
40
|
+
* @inheritDoc
|
41
|
+
*/
|
42
|
+
refresh(): void;
|
43
|
+
/**
|
44
|
+
* Opens the CKBox Image Editor dialog for editing the image.
|
45
|
+
*/
|
46
|
+
execute(): void;
|
47
|
+
/**
|
48
|
+
* @inheritDoc
|
49
|
+
*/
|
50
|
+
destroy(): void;
|
51
|
+
/**
|
52
|
+
* Indicates if the CKBox Image Editor dialog is already opened.
|
53
|
+
*/
|
54
|
+
private _getValue;
|
55
|
+
/**
|
56
|
+
* Creates the options object for the CKBox Image Editor dialog.
|
57
|
+
*/
|
58
|
+
private _prepareOptionsAbortable;
|
59
|
+
/**
|
60
|
+
* Initializes event lister for an event of removing an image.
|
61
|
+
*/
|
62
|
+
private _prepareListeners;
|
63
|
+
/**
|
64
|
+
* Gets processing states of images that have been deleted in the mean time.
|
65
|
+
*/
|
66
|
+
private _getProcessingStatesOfDeletedImages;
|
67
|
+
private _checkIfElementIsBeingProcessed;
|
68
|
+
/**
|
69
|
+
* Closes the CKBox Image Editor dialog.
|
70
|
+
*/
|
71
|
+
private _handleImageEditorClose;
|
72
|
+
/**
|
73
|
+
* Save edited image. In case server respond with "success" replace with edited image,
|
74
|
+
* otherwise show notification error.
|
75
|
+
*/
|
76
|
+
private _handleImageEditorSave;
|
77
|
+
/**
|
78
|
+
* Get asset's status on server. If server responds with "success" status then
|
79
|
+
* image is already proceeded and ready for saving.
|
80
|
+
*/
|
81
|
+
private _getAssetStatusFromServer;
|
82
|
+
/**
|
83
|
+
* Waits for an asset to be processed.
|
84
|
+
* It retries retrieving asset status from the server in case of failure.
|
85
|
+
*/
|
86
|
+
private _waitForAssetProcessed;
|
87
|
+
/**
|
88
|
+
* Shows processing indicator while image is processing.
|
89
|
+
*
|
90
|
+
* @param asset Data about certain asset.
|
91
|
+
*/
|
92
|
+
private _showImageProcessingIndicator;
|
93
|
+
/**
|
94
|
+
* Replace the edited image with the new one.
|
95
|
+
*/
|
96
|
+
private _replaceImage;
|
97
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module ckbox/ckboximageedit/ckboximageeditediting
|
7
|
+
*/
|
8
|
+
import { PendingActions, Plugin } from 'ckeditor5/src/core.js';
|
9
|
+
import { Notification } from 'ckeditor5/src/ui.js';
|
10
|
+
import CKBoxEditing from '../ckboxediting.js';
|
11
|
+
import CKBoxUtils from '../ckboxutils.js';
|
12
|
+
/**
|
13
|
+
* The CKBox image edit editing plugin.
|
14
|
+
*/
|
15
|
+
export default class CKBoxImageEditEditing extends Plugin {
|
16
|
+
/**
|
17
|
+
* @inheritDoc
|
18
|
+
*/
|
19
|
+
static get pluginName(): "CKBoxImageEditEditing";
|
20
|
+
/**
|
21
|
+
* @inheritDoc
|
22
|
+
*/
|
23
|
+
static get requires(): readonly [typeof CKBoxEditing, typeof CKBoxUtils, typeof PendingActions, typeof Notification, "ImageUtils", "ImageEditing"];
|
24
|
+
/**
|
25
|
+
* @inheritDoc
|
26
|
+
*/
|
27
|
+
init(): void;
|
28
|
+
}
|