X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fresize%2Fplugin.js;h=8c250355ab0acbba875a71a29457903e1ba81f4e;hp=780f319388b09d898b7c323c02c80d5bf2d7d58c;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1 diff --git a/_source/plugins/resize/plugin.js b/_source/plugins/resize/plugin.js index 780f319..8c25035 100644 --- a/_source/plugins/resize/plugin.js +++ b/_source/plugins/resize/plugin.js @@ -11,18 +11,30 @@ CKEDITOR.plugins.add( 'resize', if ( config.resize_enabled ) { - var container = null; - var origin, startSize; + var container = null, + origin, + startSize, + resizeHorizontal = ( config.resize_dir == 'both' || config.resize_dir == 'horizontal' ) && + ( config.resize_minWidth != config.resize_maxWidth ), + resizeVertical = ( config.resize_dir == 'both' || config.resize_dir == 'vertical' ) && + ( config.resize_minHeight != config.resize_maxHeight ); function dragHandler( evt ) { - var dx = evt.data.$.screenX - origin.x; - var dy = evt.data.$.screenY - origin.y; - var internalWidth = startSize.width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ); - var internalHeight = startSize.height + dy; + var dx = evt.data.$.screenX - origin.x, + dy = evt.data.$.screenY - origin.y, + width = startSize.width, + height = startSize.height, + internalWidth = width + dx * ( editor.lang.dir == 'rtl' ? -1 : 1 ), + internalHeight = height + dy; - editor.resize( Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ), - Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ) ); + if ( resizeHorizontal ) + width = Math.max( config.resize_minWidth, Math.min( internalWidth, config.resize_maxWidth ) ); + + if ( resizeVertical ) + height = Math.max( config.resize_minHeight, Math.min( internalHeight, config.resize_maxHeight ) ); + + editor.resize( width, height ); } function dragEndHandler ( evt ) @@ -61,7 +73,13 @@ CKEDITOR.plugins.add( 'resize', { if ( event.data.space == 'bottom' ) { - event.data.html += '
'; @@ -108,10 +126,21 @@ CKEDITOR.config.resize_maxWidth = 3000; CKEDITOR.config.resize_maxHeight = 3000; /** - * Whether to enable the resizing feature. If disabed the resize handler will not be visible. + * Whether to enable the resizing feature. If disabled the resize handler will not be visible. * @type Boolean * @default true * @example * config.resize_enabled = false; */ CKEDITOR.config.resize_enabled = true; + +/** + * The directions to which the editor resizing is enabled. Possible values + * are "both", "vertical" and "horizontal". + * @type String + * @default 'both' + * @since 3.3 + * @example + * config.resize_dir = 'vertical'; + */ +CKEDITOR.config.resize_dir = 'both';