imageupload.js 2.7 KB

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