image.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module image/image
  7. */
  8. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  9. import ImageEngine from './image/imageengine';
  10. import Widget from '@ckeditor/ckeditor5-widget/src/widget';
  11. import ImageTextAlternative from './imagetextalternative';
  12. import { isImageWidgetSelected } from './image/utils';
  13. import '../theme/theme.scss';
  14. /**
  15. * The image plugin.
  16. *
  17. * Uses the {@link module:image/image/imageengine~ImageEngine}.
  18. *
  19. * @extends module:core/plugin~Plugin
  20. */
  21. export default class Image extends Plugin {
  22. /**
  23. * @inheritDoc
  24. */
  25. static get requires() {
  26. return [ ImageEngine, Widget, ImageTextAlternative ];
  27. }
  28. /**
  29. * @inheritDoc
  30. */
  31. static get pluginName() {
  32. return 'Image';
  33. }
  34. /**
  35. * @inheritDoc
  36. */
  37. init() {
  38. const editor = this.editor;
  39. const contextualToolbar = editor.plugins.get( 'ContextualToolbar' );
  40. // If `ContextualToolbar` plugin is loaded, it should be disabled for images
  41. // which have their own toolbar to avoid duplication.
  42. // https://github.com/ckeditor/ckeditor5-image/issues/110
  43. if ( contextualToolbar ) {
  44. this.listenTo( contextualToolbar, 'show', evt => {
  45. if ( isImageWidgetSelected( editor.editing.view.selection ) ) {
  46. evt.stop();
  47. }
  48. }, { priority: 'high' } );
  49. }
  50. }
  51. }
  52. /**
  53. * The configuration of the image features. Used by the image features in `@ckeditor/ckeditor5-image` package.
  54. *
  55. * Read more in {@link module:image/image~ImageConfig}.
  56. *
  57. * @member {module:image/image~ImageConfig} module:core/editor/editorconfig~EditorConfig#image
  58. */
  59. /**
  60. * The configuration of the image features. Used by the image features in `@ckeditor/ckeditor5-image` package.
  61. *
  62. * ClassicEditor
  63. * .create( editorElement, {
  64. * image: ... // Image feature options.
  65. * } )
  66. * .then( ... )
  67. * .catch( ... );
  68. *
  69. * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
  70. *
  71. * @interface ImageConfig
  72. */