@ckeditor/ckeditor5-ckbox 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.
@@ -1,283 +1,299 @@
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 ckbox/ckboxconfig
7
- */
8
- import type { TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
9
- /**
10
- * The configuration of the {@link module:ckbox/ckbox~CKBox CKBox feature}.
11
- *
12
- * The minimal configuration for the CKBox feature requires providing the
13
- * {@link module:ckbox/ckboxconfig~CKBoxConfig#tokenUrl `config.ckbox.tokenUrl`}:
14
- *
15
- * ```ts
16
- * ClassicEditor
17
- * .create( editorElement, {
18
- * ckbox: {
19
- * tokenUrl: 'https://example.com/cs-token-endpoint'
20
- * }
21
- * } )
22
- * .then( ... )
23
- * .catch( ... );
24
- * ```
25
- *
26
- * Hovewer, you can also adjust the feature to fit your needs:
27
- *
28
- * ```ts
29
- * ClassicEditor
30
- * .create( editorElement, {
31
- * ckbox: {
32
- * defaultUploadCategories: {
33
- * Bitmaps: [ 'bmp' ],
34
- * Pictures: [ 'jpg', 'jpeg' ],
35
- * Scans: [ 'png', 'tiff' ]
36
- * },
37
- * ignoreDataId: true,
38
- * serviceOrigin: 'https://example.com/',
39
- * tokenUrl: 'https://example.com/cs-token-endpoint'
40
- * }
41
- * } )
42
- * .then( ... )
43
- * .catch( ... );
44
- * ```
45
- *
46
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
47
- */
48
- export interface CKBoxConfig {
49
- /**
50
- * The authentication token URL for CKBox feature.
51
- *
52
- * Defaults to {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl `config.cloudServices.tokenUrl`}
53
- */
54
- tokenUrl?: TokenUrl;
55
- /**
56
- * The theme for CKBox dialog.
57
- */
58
- theme?: string;
59
- /**
60
- * Defines the categories to which the uploaded images will be assigned.
61
- * If configured, it overrides the category mappings defined on the cloud service.
62
- * The value of this option should be an object, where the keys define categories and their values are the types of images
63
- * that will be uploaded to these categories. The categories might be referenced by their name or ID.
64
- *
65
- * Example:
66
- *
67
- * ```ts
68
- * const ckboxConfig = {
69
- * defaultUploadCategories: {
70
- * Bitmaps: [ 'bmp' ],
71
- * Pictures: [ 'jpg', 'jpeg' ],
72
- * Scans: [ 'png', 'tiff' ],
73
- * // The category below is referenced by its ID.
74
- * 'fdf2a647-b67f-4a6c-b692-5ba1dc1ed87b': [ 'gif' ]
75
- * }
76
- * };
77
- * ```
78
- *
79
- * @default null
80
- */
81
- defaultUploadCategories?: Record<string, Array<string>> | null;
82
- /**
83
- * Defines the workspace id to use during upload when the user has access to more than one workspace.
84
- *
85
- * If defined, it is an error, when the user has no access to the specified workspace.
86
- */
87
- defaultUploadWorkspaceId?: string;
88
- /**
89
- * Inserts the unique asset ID as the `data-ckbox-resource-id` attribute. To disable this behavior, set it to `true`.
90
- *
91
- * @default false
92
- */
93
- ignoreDataId?: boolean;
94
- /**
95
- * Configures the base URL of the API service. Required only in on-premises installations.
96
- *
97
- * @default 'https://api.ckbox.io'
98
- */
99
- serviceOrigin?: string;
100
- /**
101
- * Configures the language for the CKBox dialog.
102
- *
103
- * Defaults to {@link module:utils/locale~Locale#uiLanguage `Locale#uiLanguage`}
104
- */
105
- language?: string;
106
- }
107
- /**
108
- * Asset definition.
109
- *
110
- * The definition contains the unique `id`, asset `type` and an `attributes` definition.
111
- */
112
- export type CKBoxAssetDefinition = CKBoxAssetImageDefinition | CKBoxAssetLinkDefinition;
113
- /**
114
- * Image asset definition.
115
- *
116
- * The definition contains the unique `id`, asset `type` and an `attributes` definition.
117
- */
118
- export interface CKBoxAssetImageDefinition {
119
- /**
120
- * An unique asset id.
121
- */
122
- id: string;
123
- /**
124
- * Asset type.
125
- */
126
- type: 'image';
127
- /**
128
- * Asset attributes.
129
- */
130
- attributes: CKBoxAssetImageAttributesDefinition;
131
- }
132
- /**
133
- * Link asset definition.
134
- *
135
- * The definition contains the unique `id`, asset `type` and an `attributes` definition.
136
- */
137
- export interface CKBoxAssetLinkDefinition {
138
- /**
139
- * An unique asset id.
140
- */
141
- id: string;
142
- /**
143
- * Asset type.
144
- */
145
- type: 'link';
146
- /**
147
- * Asset attributes.
148
- */
149
- attributes: CKBoxAssetLinkAttributesDefinition;
150
- }
151
- /**
152
- * Asset attributes definition for an image.
153
- *
154
- * The definition contains the `imageFallbackUrl`, an `imageSources` array with one image source definition object and the
155
- * `imageTextAlternative`.
156
- *
157
- * ```ts
158
- * {
159
- * imageFallbackUrl: 'https://example.com/assets/asset-id/images/1000.png',
160
- * imageSources: [
161
- * {
162
- * sizes: '1000px',
163
- * srcset:
164
- * 'https://example.com/assets/asset-id/images/100.webp 100w,' +
165
- * 'https://example.com/assets/asset-id/images/200.webp 200w,' +
166
- * 'https://example.com/assets/asset-id/images/300.webp 300w,' +
167
- * 'https://example.com/assets/asset-id/images/400.webp 400w,' +
168
- * 'https://example.com/assets/asset-id/images/500.webp 500w,' +
169
- * 'https://example.com/assets/asset-id/images/600.webp 600w,' +
170
- * 'https://example.com/assets/asset-id/images/700.webp 700w,' +
171
- * 'https://example.com/assets/asset-id/images/800.webp 800w,' +
172
- * 'https://example.com/assets/asset-id/images/900.webp 900w,' +
173
- * 'https://example.com/assets/asset-id/images/1000.webp 1000w',
174
- * type: 'image/webp'
175
- * }
176
- * ],
177
- * imageTextAlternative: 'An alternative text for the image'
178
- * }
179
- * ```
180
- */
181
- export interface CKBoxAssetImageAttributesDefinition {
182
- /**
183
- * A fallback URL for browsers that do not support the "webp" format.
184
- */
185
- imageFallbackUrl: string;
186
- /**
187
- * An array containing one image source definition object.
188
- */
189
- imageSources: Array<{
190
- srcset: string;
191
- sizes: string;
192
- type: string;
193
- }>;
194
- /**
195
- * An alternative text for an image.
196
- */
197
- imageTextAlternative: string;
198
- }
199
- /**
200
- * Asset attributes definition for a link.
201
- *
202
- * The definition contains the `linkName` and `linkHref` strings.
203
- *
204
- * ```ts
205
- * {
206
- * linkName: 'File name',
207
- * linkHref: 'https://example.com/assets/asset-id/file.pdf'
208
- * }
209
- * ```
210
- */
211
- export interface CKBoxAssetLinkAttributesDefinition {
212
- /**
213
- * A link name.
214
- */
215
- linkName: string;
216
- /**
217
- * An URL for the asset.
218
- */
219
- linkHref: string;
220
- }
221
- /**
222
- * The source set of the responsive image provided by the CKBox backend.
223
- *
224
- * Each numeric key corresponds to display width of the image.
225
- */
226
- export interface CKBoxImageUrls {
227
- [width: number]: string;
228
- /**
229
- * A fallback URL for browsers that do not support the "webp" format.
230
- */
231
- default: string;
232
- }
233
- /**
234
- * Raw asset definition that is received from the CKBox feature.
235
- */
236
- export interface CKBoxRawAssetDefinition {
237
- /**
238
- * A raw asset data definition.
239
- */
240
- data: CKBoxRawAssetDataDefinition;
241
- }
242
- /**
243
- * Part of raw asset data that is received from the CKBox feature.
244
- */
245
- export interface CKBoxRawAssetDataDefinition {
246
- /**
247
- * An unique asset id.
248
- */
249
- id: string;
250
- /**
251
- * An asset name.
252
- */
253
- name: string;
254
- /**
255
- * A raw asset metadata definition.
256
- */
257
- metadata?: CKBoxRawAssetMetadataDefinition;
258
- /**
259
- * The source set of the responsive image.
260
- */
261
- imageUrls?: CKBoxImageUrls;
262
- /**
263
- * The asset location.
264
- */
265
- url: string;
266
- }
267
- /**
268
- * Part of raw asset data that is received from the CKBox feature. Properties are set only if the chosen asset is an image.
269
- */
270
- export interface CKBoxRawAssetMetadataDefinition {
271
- /**
272
- * Image description.
273
- */
274
- description?: string;
275
- /**
276
- * Image width.
277
- */
278
- width?: number;
279
- /**
280
- * Image height.
281
- */
282
- height?: number;
283
- }
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 ckbox/ckboxconfig
7
+ */
8
+ import type { TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
9
+ /**
10
+ * The configuration of the {@link module:ckbox/ckbox~CKBox CKBox feature}.
11
+ *
12
+ * The minimal configuration for the CKBox feature requires providing the
13
+ * {@link module:ckbox/ckboxconfig~CKBoxConfig#tokenUrl `config.ckbox.tokenUrl`}:
14
+ *
15
+ * ```ts
16
+ * ClassicEditor
17
+ * .create( editorElement, {
18
+ * ckbox: {
19
+ * tokenUrl: 'https://example.com/cs-token-endpoint'
20
+ * }
21
+ * } )
22
+ * .then( ... )
23
+ * .catch( ... );
24
+ * ```
25
+ *
26
+ * Hovewer, you can also adjust the feature to fit your needs:
27
+ *
28
+ * ```ts
29
+ * ClassicEditor
30
+ * .create( editorElement, {
31
+ * ckbox: {
32
+ * defaultUploadCategories: {
33
+ * Bitmaps: [ 'bmp' ],
34
+ * Pictures: [ 'jpg', 'jpeg' ],
35
+ * Scans: [ 'png', 'tiff' ]
36
+ * },
37
+ * ignoreDataId: true,
38
+ * serviceOrigin: 'https://example.com/',
39
+ * tokenUrl: 'https://example.com/cs-token-endpoint'
40
+ * }
41
+ * } )
42
+ * .then( ... )
43
+ * .catch( ... );
44
+ * ```
45
+ *
46
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
47
+ */
48
+ export interface CKBoxConfig {
49
+ /**
50
+ * The authentication token URL for CKBox feature.
51
+ *
52
+ * Defaults to {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl `config.cloudServices.tokenUrl`}
53
+ */
54
+ tokenUrl?: TokenUrl;
55
+ /**
56
+ * The theme for CKBox dialog.
57
+ */
58
+ theme?: string;
59
+ /**
60
+ * Defines the categories to which the uploaded images will be assigned.
61
+ * If configured, it overrides the category mappings defined on the cloud service.
62
+ * The value of this option should be an object, where the keys define categories and their values are the types of images
63
+ * that will be uploaded to these categories. The categories might be referenced by their name or ID.
64
+ *
65
+ * Example:
66
+ *
67
+ * ```ts
68
+ * const ckboxConfig = {
69
+ * defaultUploadCategories: {
70
+ * Bitmaps: [ 'bmp' ],
71
+ * Pictures: [ 'jpg', 'jpeg' ],
72
+ * Scans: [ 'png', 'tiff' ],
73
+ * // The category below is referenced by its ID.
74
+ * 'fdf2a647-b67f-4a6c-b692-5ba1dc1ed87b': [ 'gif' ]
75
+ * }
76
+ * };
77
+ * ```
78
+ *
79
+ * @default null
80
+ */
81
+ defaultUploadCategories?: Record<string, Array<string>> | null;
82
+ /**
83
+ * Defines the workspace id to use during upload when the user has access to more than one workspace.
84
+ *
85
+ * If defined, it is an error, when the user has no access to the specified workspace.
86
+ */
87
+ defaultUploadWorkspaceId?: string;
88
+ /**
89
+ * Inserts the unique asset ID as the `data-ckbox-resource-id` attribute. To disable this behavior, set it to `true`.
90
+ *
91
+ * @default false
92
+ */
93
+ ignoreDataId?: boolean;
94
+ /**
95
+ * Configures the base URL of the API service. Required only in on-premises installations.
96
+ *
97
+ * @default 'https://api.ckbox.io'
98
+ */
99
+ serviceOrigin?: string;
100
+ /**
101
+ * Configures the language for the CKBox dialog.
102
+ *
103
+ * Defaults to {@link module:utils/locale~Locale#uiLanguage `Locale#uiLanguage`}
104
+ */
105
+ language?: string;
106
+ }
107
+ /**
108
+ * Asset definition.
109
+ *
110
+ * The definition contains the unique `id`, asset `type` and an `attributes` definition.
111
+ */
112
+ export type CKBoxAssetDefinition = CKBoxAssetImageDefinition | CKBoxAssetLinkDefinition;
113
+ /**
114
+ * Image asset definition.
115
+ *
116
+ * The definition contains the unique `id`, asset `type` and an `attributes` definition.
117
+ */
118
+ export interface CKBoxAssetImageDefinition {
119
+ /**
120
+ * An unique asset id.
121
+ */
122
+ id: string;
123
+ /**
124
+ * Asset type.
125
+ */
126
+ type: 'image';
127
+ /**
128
+ * Asset attributes.
129
+ */
130
+ attributes: CKBoxAssetImageAttributesDefinition;
131
+ }
132
+ /**
133
+ * Link asset definition.
134
+ *
135
+ * The definition contains the unique `id`, asset `type` and an `attributes` definition.
136
+ */
137
+ export interface CKBoxAssetLinkDefinition {
138
+ /**
139
+ * An unique asset id.
140
+ */
141
+ id: string;
142
+ /**
143
+ * Asset type.
144
+ */
145
+ type: 'link';
146
+ /**
147
+ * Asset attributes.
148
+ */
149
+ attributes: CKBoxAssetLinkAttributesDefinition;
150
+ }
151
+ /**
152
+ * Asset attributes definition for an image.
153
+ *
154
+ * The definition contains the `imageFallbackUrl`, an `imageSources` array with one image source definition object and the
155
+ * `imageTextAlternative`.
156
+ *
157
+ * ```ts
158
+ * {
159
+ * imageFallbackUrl: 'https://example.com/assets/asset-id/images/1000.png',
160
+ * imageSources: [
161
+ * {
162
+ * sizes: '1000px',
163
+ * srcset:
164
+ * 'https://example.com/assets/asset-id/images/100.webp 100w,' +
165
+ * 'https://example.com/assets/asset-id/images/200.webp 200w,' +
166
+ * 'https://example.com/assets/asset-id/images/300.webp 300w,' +
167
+ * 'https://example.com/assets/asset-id/images/400.webp 400w,' +
168
+ * 'https://example.com/assets/asset-id/images/500.webp 500w,' +
169
+ * 'https://example.com/assets/asset-id/images/600.webp 600w,' +
170
+ * 'https://example.com/assets/asset-id/images/700.webp 700w,' +
171
+ * 'https://example.com/assets/asset-id/images/800.webp 800w,' +
172
+ * 'https://example.com/assets/asset-id/images/900.webp 900w,' +
173
+ * 'https://example.com/assets/asset-id/images/1000.webp 1000w',
174
+ * type: 'image/webp'
175
+ * }
176
+ * ],
177
+ * imageTextAlternative: 'An alternative text for the image'
178
+ * }
179
+ * ```
180
+ */
181
+ export interface CKBoxAssetImageAttributesDefinition {
182
+ /**
183
+ * A fallback URL for browsers that do not support the "webp" format.
184
+ */
185
+ imageFallbackUrl: string;
186
+ /**
187
+ * An array containing one image source definition object.
188
+ */
189
+ imageSources: Array<{
190
+ srcset: string;
191
+ sizes: string;
192
+ type: string;
193
+ }>;
194
+ /**
195
+ * An alternative text for an image.
196
+ */
197
+ imageTextAlternative: string;
198
+ /**
199
+ * Image width.
200
+ */
201
+ imageWidth?: number;
202
+ /**
203
+ * Image height.
204
+ */
205
+ imageHeight?: number;
206
+ /**
207
+ * Image placeholder image.
208
+ */
209
+ imagePlaceholder?: string;
210
+ }
211
+ /**
212
+ * Asset attributes definition for a link.
213
+ *
214
+ * The definition contains the `linkName` and `linkHref` strings.
215
+ *
216
+ * ```ts
217
+ * {
218
+ * linkName: 'File name',
219
+ * linkHref: 'https://example.com/assets/asset-id/file.pdf'
220
+ * }
221
+ * ```
222
+ */
223
+ export interface CKBoxAssetLinkAttributesDefinition {
224
+ /**
225
+ * A link name.
226
+ */
227
+ linkName: string;
228
+ /**
229
+ * An URL for the asset.
230
+ */
231
+ linkHref: string;
232
+ }
233
+ /**
234
+ * The source set of the responsive image provided by the CKBox backend.
235
+ *
236
+ * Each numeric key corresponds to display width of the image.
237
+ */
238
+ export interface CKBoxImageUrls {
239
+ [width: number]: string;
240
+ /**
241
+ * A fallback URL for browsers that do not support the "webp" format.
242
+ */
243
+ default: string;
244
+ }
245
+ /**
246
+ * Raw asset definition that is received from the CKBox feature.
247
+ */
248
+ export interface CKBoxRawAssetDefinition {
249
+ /**
250
+ * A raw asset data definition.
251
+ */
252
+ data: CKBoxRawAssetDataDefinition;
253
+ }
254
+ /**
255
+ * Part of raw asset data that is received from the CKBox feature.
256
+ */
257
+ export interface CKBoxRawAssetDataDefinition {
258
+ /**
259
+ * An unique asset id.
260
+ */
261
+ id: string;
262
+ /**
263
+ * An asset name.
264
+ */
265
+ name: string;
266
+ /**
267
+ * A raw asset metadata definition.
268
+ */
269
+ metadata?: CKBoxRawAssetMetadataDefinition;
270
+ /**
271
+ * The source set of the responsive image.
272
+ */
273
+ imageUrls?: CKBoxImageUrls;
274
+ /**
275
+ * The asset location.
276
+ */
277
+ url: string;
278
+ }
279
+ /**
280
+ * Part of raw asset data that is received from the CKBox feature. Properties are set only if the chosen asset is an image.
281
+ */
282
+ export interface CKBoxRawAssetMetadataDefinition {
283
+ /**
284
+ * Image description.
285
+ */
286
+ description?: string;
287
+ /**
288
+ * Image width.
289
+ */
290
+ width?: number;
291
+ /**
292
+ * Image height.
293
+ */
294
+ height?: number;
295
+ /**
296
+ * The blurhash placeholder value.
297
+ */
298
+ blurHash?: string;
299
+ }
@@ -1,5 +1,5 @@
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
- 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
+ export {};