@ckeditor/ckeditor5-ckbox 39.0.2 → 40.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,283 +1,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
- /**
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
+ /**
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,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 {};