1 | /**
|
2 | * @license Copyright (c) 2003-2022, 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 | /**
|
7 | * @module image/imageupload
|
8 | */
|
9 |
|
10 | import { Plugin } from 'ckeditor5/src/core';
|
11 | import ImageUploadUI from './imageupload/imageuploadui';
|
12 | import ImageUploadProgress from './imageupload/imageuploadprogress';
|
13 | import ImageUploadEditing from './imageupload/imageuploadediting';
|
14 |
|
15 | /**
|
16 | * The image upload plugin.
|
17 | *
|
18 | * For a detailed overview, check the {@glink features/images/image-upload/image-upload image upload feature} documentation.
|
19 | *
|
20 | * This plugin does not do anything directly, but it loads a set of specific plugins to enable image uploading:
|
21 | *
|
22 | * * {@link module:image/imageupload/imageuploadediting~ImageUploadEditing},
|
23 | * * {@link module:image/imageupload/imageuploadui~ImageUploadUI},
|
24 | * * {@link module:image/imageupload/imageuploadprogress~ImageUploadProgress}.
|
25 | *
|
26 | * @extends module:core/plugin~Plugin
|
27 | */
|
28 | export default class ImageUpload extends Plugin {
|
29 | /**
|
30 | * @inheritDoc
|
31 | */
|
32 | static get pluginName() {
|
33 | return 'ImageUpload';
|
34 | }
|
35 |
|
36 | /**
|
37 | * @inheritDoc
|
38 | */
|
39 | static get requires() {
|
40 | return [ ImageUploadEditing, ImageUploadUI, ImageUploadProgress ];
|
41 | }
|
42 | }
|
43 |
|
44 | /**
|
45 | * The image upload configuration.
|
46 | *
|
47 | * @member {module:image/imageupload~ImageUploadConfig} module:image/image~ImageConfig#upload
|
48 | */
|
49 |
|
50 | /**
|
51 | * The configuration of the image upload feature. Used by the image upload feature in the `@ckeditor/ckeditor5-image` package.
|
52 | *
|
53 | * ClassicEditor
|
54 | * .create( editorElement, {
|
55 | * image: {
|
56 | * upload: ... // Image upload feature options.
|
57 | * }
|
58 | * } )
|
59 | * .then( ... )
|
60 | * .catch( ... );
|
61 | *
|
62 | * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
63 | *
|
64 | * @interface module:image/imageupload~ImageUploadConfig
|
65 | */
|
66 |
|
67 | /**
|
68 | * The list of accepted image types.
|
69 | *
|
70 | * The accepted types of images can be customized to allow only certain types of images:
|
71 | *
|
72 | * // Allow only JPEG and PNG images:
|
73 | * const imageUploadConfig = {
|
74 | * types: [ 'png', 'jpeg' ]
|
75 | * };
|
76 | *
|
77 | * The type string should match [one of the sub-types](https://www.iana.org/assignments/media-types/media-types.xhtml#image)
|
78 | * of the image MIME type. For example, for the `image/jpeg` MIME type, add `'jpeg'` to your image upload configuration.
|
79 | *
|
80 | * **Note:** This setting only restricts some image types to be selected and uploaded through the CKEditor UI and commands. Image type
|
81 | * recognition and filtering should also be implemented on the server which accepts image uploads.
|
82 | *
|
83 | * @member {Array.<String>} module:image/imageupload~ImageUploadConfig#types
|
84 | * @default [ 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff' ]
|
85 | */
|