Переглянути джерело

Remove config option for disabling the image resize handles.

panr 5 роки тому
батько
коміт
7d4e5dd2ae

+ 1 - 44
packages/ckeditor5-image/docs/features/image.md

@@ -338,50 +338,7 @@ const imageConfiguration = {
 
 ### Disabling image resize handles
 
-If for some reason you want to configure the editor where you can resize the images only by image toolbar UI, you can do it in two different ways.
-
- - Having installed {@link module:image/imageresize~ImageResize `ImageResize`} plugin you can set {@link module:image/image~ImageConfig#disableResizeHandles `image.disableResizeHandles: true`}. This setting will {@link module:core/plugin~Plugin#forceDisabled disable} the {@link module:image/imageresize/imageresizehandles~ImageResizeHandles `ImageResizeHandles`} plugin.
-
-```js
-import Image from '@ckeditor/ckeditor5-image/src/image';
-import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar';
-import ImageResize from '@ckeditor/ckeditor5-image/src/imageresize';
-
-ClassicEditor
-	.create( document.querySelector( '#editor' ), {
-		plugins: [ Image, ImageResize, ImageToolbar, ... ],
-		image: {
-			disableResizeHandles: true,
-			resizeOptions: [
-			{
-				name: 'imageResize:original',
-				value: null,
-				icon: 'original'
-			},
-			{
-				name: 'imageResize:50',
-				value: '50',
-				icon: 'medium'
-			},
-			{
-				name: 'imageResize:75',
-				value: '75',
-				icon: 'large'
-			}
-		],
-		toolbar: [
-			// ...,
-			'imageResize:50',
-			'imageResize:75',
-			'imageResize:original',
-		]
-		}
-	} )
-	.then( ... )
-	.catch( ... );
-```
-
-- Or you can simply do not install {@link module:image/imageresize/imageresizehandles~ImageResizeHandles `ImageResizeHandles`} plugin at all. This means that your plugins setup will look like this: `plugins: [ 'ImageResizeEditing', 'ImageResizeButtons', ... ]` which only enables resizing image feature by the choosen UI ([dropdown](#resize-image-using-the-plugin-dropdown) or [standalone buttons](#resize-image-using-the-standalone-buttons)) in the image toolbar.
+If for some reason you want to configure the editor where you can resize the images only by image toolbar UI, you can do it by omitting {@link module:image/imageresize/imageresizehandles~ImageResizeHandles `ImageResizeHandles`} plugin. This means that your plugins setup will look like this: `plugins: [ ... , 'ImageResizeEditing', 'ImageResizeButtons', ... ]` instead of `plugins: [ ... , 'ImageResize', ... ]`. It will only enable resizing image feature by the chosen UI ([dropdown](#using-the-dropdown) or [standalone buttons](#using-standalone-buttons)) in the image toolbar.
 
 ```js
 import Image from '@ckeditor/ckeditor5-image/src/image';

+ 0 - 35
packages/ckeditor5-image/src/imageresize.js

@@ -35,18 +35,6 @@ export default class ImageResize extends Plugin {
 	static get pluginName() {
 		return 'ImageResize';
 	}
-
-	/**
-	 * @inheritDoc
-	 */
-	init() {
-		const editor = this.editor;
-		const shouldDisableImageResizeHandles = editor.config.get( 'image.disableResizeHandles' );
-
-		if ( shouldDisableImageResizeHandles ) {
-			editor.plugins.get( 'ImageResizeHandles' ).forceDisabled( 'ImageResize' );
-		}
-	}
 }
 
 /**
@@ -70,29 +58,6 @@ export default class ImageResize extends Plugin {
  * @member {String} module:image/image~ImageConfig#resizeUnit
  */
 
-/**
- * The option for disabling image resize by handles.
- *
- * It's useful when you want to set certain options for image resize and be sure that other users
- * can only set one of those sizes by the dropdown or standalone buttons defined in
- * {@link module:image/image~ImageConfig#resizeOptions}.
- *
- *		ClassicEditor
- *			.create( editorElement, {
- *				image: {
- *					disableResizeHandles: true
- *				}
- *			} )
- *			.then( ... )
- *			.catch( ... );
- *
- *
- * This option is used by the {@link module:image/imageresize~ImageResize} feature.
- *
- * @default 'false'
- * @member {String} module:image/image~ImageConfig#disableResizeHandles
- */
-
 /**
  * The image resize options.
  *

+ 0 - 48
packages/ckeditor5-image/tests/imageresize/imageresize.js

@@ -3,11 +3,6 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* globals document */
-
-import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
-import Image from '../../src/image';
-import ImageStyle from '../../src/imagestyle';
 import ImageResize from '../../src/imageresize';
 import ImageResizeButtons from '../../src/imageresize/imageresizebuttons';
 import ImageResizeEditing from '../../src/imageresize/imageresizeediting';
@@ -21,47 +16,4 @@ describe( 'ImageResize', () => {
 	it( 'should be named', () => {
 		expect( ImageResize.pluginName ).to.equal( 'ImageResize' );
 	} );
-
-	describe( 'init()', () => {
-		describe( 'ImageResizeHandles', () => {
-			it( 'should force disable the "ImageResizeHandles" plugin if "image.disableResizeHandles: true"', async () => {
-				const element = document.createElement( 'div' );
-				document.body.appendChild( element );
-
-				const editor = await ClassicTestEditor.create( element, {
-					plugins: [ Image, ImageStyle, ImageResize ],
-					image: {
-						disableResizeHandles: true
-					}
-				} );
-
-				const imageResizeHandlesPlugin = editor.plugins.get( 'ImageResizeHandles' );
-
-				expect( imageResizeHandlesPlugin.isEnabled ).to.be.false;
-				expect( imageResizeHandlesPlugin._disableStack.size ).to.equal( 1 );
-				expect( imageResizeHandlesPlugin._disableStack.has( 'ImageResize' ) ).to.be.true;
-
-				editor.destroy();
-				element.remove();
-			} );
-
-			it( 'should not force disable the "ImageResizeHandles" plugin if no "image.disableResizeHandles" is provided', async () => {
-				const element = document.createElement( 'div' );
-				document.body.appendChild( element );
-
-				const editor = await ClassicTestEditor.create( element, {
-					plugins: [ Image, ImageStyle, ImageResize ]
-				} );
-
-				const imageResizeHandlesPlugin = editor.plugins.get( 'ImageResizeHandles' );
-
-				expect( imageResizeHandlesPlugin.isEnabled ).to.be.false;
-				expect( imageResizeHandlesPlugin._disableStack.size ).to.equal( 0 );
-				expect( imageResizeHandlesPlugin._disableStack.has( 'ImageResize' ) ).to.be.false;
-
-				editor.destroy();
-				element.remove();
-			} );
-		} );
-	} );
 } );