Skip to content
Permalink
Browse files

Merge branch 't/11222'

  • Loading branch information...
oleq committed Dec 4, 2013
2 parents 73b3273 + b00fc1b commit 18df3e2d2c165b9052498de19e23d05306acb6f3
@@ -5,7 +5,8 @@ CKEditor 4 Changelog

**Important Notes:**

* To match the naming convention `image2` and `language` buttons are now `Image2` and `Language` ([#11201](http://dev.ckeditor.com/ticket/11201)).
* To match the naming convention `language` button is now `Language` ([#11201](http://dev.ckeditor.com/ticket/11201)).
* [Enhanced Image](http://ckeditor.com/addon/image2) button/context menu/command/icon names match those of Image plugin ([#11222](http://dev.ckeditor.com/ticket/11222)).

Fixed Issues:

@@ -85,9 +85,12 @@ CKEDITOR.plugins.add( 'forms', {
addButtonCommand( 'Select', 'select', dialogPath + 'select.js' );
addButtonCommand( 'Button', 'button', dialogPath + 'button.js' );

// If the "image" plugin is loaded.
var imagePlugin = CKEDITOR.plugins.get( 'image' );
imagePlugin && addButtonCommand( 'ImageButton', 'imagebutton', CKEDITOR.plugins.getPath( 'image' ) + 'dialogs/image.js' );
var imagePlugin = editor.plugins.image;

// Since Image plugin is disabled when Image2 is to be loaded,
// ImageButton also got to be off (#11222).
if ( imagePlugin && !editor.plugins.image2 )
addButtonCommand( 'ImageButton', 'imagebutton', CKEDITOR.plugins.getPath( 'image' ) + 'dialogs/image.js' );

addButtonCommand( 'HiddenField', 'hiddenfield', dialogPath + 'hiddenfield.js' );

@@ -15,6 +15,11 @@
icons: 'image', // %REMOVE_LINE_CORE%
hidpi: true, // %REMOVE_LINE_CORE%
init: function( editor ) {
// Abort when Image2 is to be loaded since both plugins
// share the same button, command, etc. names (#11222).
if ( editor.plugins.image2 )
return;

var pluginName = 'image';

// Register the dialog.
@@ -70,6 +75,11 @@
}
},
afterInit: function( editor ) {
// Abort when Image2 is to be loaded since both plugins
// share the same button, command, etc. names (#11222).
if ( editor.plugins.image2 )
return;

// Customize the behavior of the alignment commands. (#7430)
setupAlignCommand( 'left' );
setupAlignCommand( 'right' );
@@ -5,7 +5,7 @@
-->
<html>
<head>
<title>Widget image2 &mdash; CKEditor Sample</title>
<title>Widget Image &mdash; CKEditor Sample</title>
<meta charset="utf-8">
<script src="../../../ckeditor.js"></script>
<script src="../../../dev/console/console.js"></script>
@@ -40,10 +40,6 @@
</script>
<link href="../../../samples/sample.css" rel="stylesheet">
<meta name="ckeditor-sample-name" content="Widget image2">
<meta name="ckeditor-sample-group" content="Plugins">
<meta name="ckeditor-sample-description" content="Widget img showcase.">
<meta name="ckeditor-sample-isnew" content="1">

<style>
@@ -78,7 +74,7 @@
</head>
<body>
<h1 class="samples">
<a href="../../../samples/index.html">CKEditor Samples</a> &raquo; Widget image2
<a href="../../../samples/index.html">CKEditor Samples</a> &raquo; Widget Image
</h1>

<h2>Framed sample</h2>
@@ -199,7 +195,6 @@ <h2>Technical details <a id="tech-details" name="tech-details"></a></h2>
CKEDITOR.replace( 'editor1', {
extraPlugins: 'image2',
height: 600,
removePlugins: 'image,forms',
contentsCss: [ '../../../contents.css', 'contents.css' ],
filebrowserBrowseUrl: '/ckfinder/ckfinder.html',
@@ -209,7 +204,6 @@ <h2>Technical details <a id="tech-details" name="tech-details"></a></h2>
} );
CKEDITOR.inline( 'editor2', {
removePlugins: 'image,forms',
extraPlugins: 'image2,sourcedialog'
} );
@@ -243,7 +243,9 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {

// Activate (Un)LockRatio button
if ( lockButton ) {
dialog.addFocusable( lockButton, 4 );
// Consider that there's an additional focusable field
// in the dialog when the "browse" button is visible.
dialog.addFocusable( lockButton, 4 + hasFileBrowser );

lockButton.on( 'click', function( evt ) {
toggleLockRatio();
@@ -255,7 +257,9 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {

// Activate the reset size button.
if ( resetButton ) {
dialog.addFocusable( resetButton, 5 );
// Consider that there's an additional focusable field
// in the dialog when the "browse" button is visible.
dialog.addFocusable( resetButton, 5 + hasFileBrowser );

// Fills width and height fields with the original dimensions of the
// image (stored in widget#data since widget#init).
@@ -330,7 +334,41 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
heightField[ method ]();
}

var ret = {
var hasFileBrowser = !!( editor.config.filebrowserImageBrowseUrl || editor.config.filebrowserBrowseUrl ),
srcBoxChildren = [
{
id: 'src',
type: 'text',
label: commonLang.url,
onKeyup: onChangeSrc,
onChange: onChangeSrc,
setup: function( widget ) {
this.setValue( widget.data.src );
},
commit: function( widget ) {
widget.setData( 'src', this.getValue() );
},
validate: CKEDITOR.dialog.validate.notEmpty( lang.urlMissing )
}
];

// Render the "Browse" button on demand to avoid an "empty" (hidden child)
// space in dialog layout that distorts the UI.
if ( hasFileBrowser ) {
srcBoxChildren.push( {
type: 'button',
id: 'browse',
// v-align with the 'txtUrl' field.
// TODO: We need something better than a fixed size here.
style: 'display:inline-block;margin-top:16px;',
align: 'center',
label: editor.lang.common.browseServer,
hidden: true,
filebrowser: 'info:src'
} );
}

return {
title: lang.title,
minWidth: 250,
minHeight: 100,
@@ -371,37 +409,8 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
children: [
{
type: 'hbox',
widths: [ '280px', '110px' ],
align: 'right',
children: [
{
id: 'src',
type: 'text',
label: commonLang.url,
onKeyup: onChangeSrc,
onChange: onChangeSrc,
setup: function( widget ) {
this.setValue( widget.data.src );
},
commit: function( widget ) {
widget.setData( 'src', this.getValue() );
},
validate: CKEDITOR.dialog.validate.notEmpty( lang.urlMissing )
},
{
// Remark: button may be removed at the very bottom of
// the file, if browser config is not set.
type: 'button',
id: 'browse',
// v-align with the 'txtUrl' field.
// TODO: We need something better than a fixed size here.
style: 'display:inline-block;margin-top:16px;',
align: 'center',
label: editor.lang.common.browseServer,
hidden: true,
filebrowser: 'info:src'
}
]
widths: [ '100%' ],
children: srcBoxChildren
}
]
},
@@ -529,11 +538,4 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
}
]
};

if ( !editor.config.filebrowserImageBrowseUrl && !editor.config.filebrowserBrowseUrl ) {
// Replaces hbox (which should contain button#browse but is hidden) with text control.
ret.contents[ 0 ].elements[ 0 ].children[ 0 ] = ret.contents[ 0 ].elements[ 0 ].children[ 0 ].children[ 0 ];
}

return ret;
} );
File renamed without changes.
File renamed without changes.
@@ -17,14 +17,14 @@
CKEDITOR.plugins.add( 'image2', {
lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%
requires: 'widget,dialog',
icons: 'image2',
icons: 'image',
hidpi: true,

onLoad: function( editor ) {
CKEDITOR.addCss(
'.cke_editable.cke_image2_sw, .cke_editable.cke_image2_sw *{cursor:sw-resize !important}' +
'.cke_editable.cke_image2_se, .cke_editable.cke_image2_se *{cursor:se-resize !important}' +
'.cke_image2_resizer{' +
'.cke_editable.cke_image_sw, .cke_editable.cke_image_sw *{cursor:sw-resize !important}' +
'.cke_editable.cke_image_se, .cke_editable.cke_image_se *{cursor:se-resize !important}' +
'.cke_image_resizer{' +
'display:none;' +
'position:absolute;' +
'width:10px;' +
@@ -35,54 +35,58 @@
'outline:1px solid #fff;' +
'cursor:se-resize;' +
'}' +
'.cke_image2_resizer_wrapper{' +
'.cke_image_resizer_wrapper{' +
'position:relative;' +
'display:inline-block;' +
'line-height:0;' +
'}' +
// Bottom-left corner style of the resizer.
'.cke_image2_resizer.cke_image2_resizer_left{' +
'.cke_image_resizer.cke_image_resizer_left{' +
'right:auto;' +
'left:-5px;' +
'cursor:sw-resize;' +
'}' +
'.cke_widget_wrapper:hover .cke_image2_resizer,' +
'.cke_image2_resizer.cke_image2_resizing{' +
'.cke_widget_wrapper:hover .cke_image_resizer,' +
'.cke_image_resizer.cke_image_resizing{' +
'display:block' +
'}' );
},

init: function( editor ) {

// Adapts configuration from original image plugin. Should be removed
// when we'll rename image2 to image.
var config = editor.config,
lang = editor.lang.image2;

// Since filebrowser plugin discovers config properties by dialog (plugin?)
// names (sic!), this hack will be necessary as long as Image2 is not named
// Image. And since Image2 will never be Image, for sure some filebrowser logic
// got to be refined.
config.filebrowserImage2BrowseUrl = config.filebrowserImageBrowseUrl;
config.filebrowserImage2UploadUrl = config.filebrowserImageUploadUrl;

// Add custom elementspath names to widget definition.
image2.pathName = lang.pathName;
image2.editables.caption.pathName = lang.pathNameCaption;
image.pathName = lang.pathName;
image.editables.caption.pathName = lang.pathNameCaption;

// Register the widget.
editor.widgets.add( 'image2', image2 );
editor.widgets.add( 'image', image );

// Add toolbar button for this plugin.
editor.ui.addButton && editor.ui.addButton( 'Image2', {
editor.ui.addButton && editor.ui.addButton( 'Image', {
label: editor.lang.common.image,
command: 'image2',
command: 'image',
toolbar: 'insert,10'
} );

// Register context menu option for editing widget.
if ( editor.contextMenu ) {
editor.addMenuGroup( 'image2', 10 );
editor.addMenuGroup( 'image', 10 );

editor.addMenuItem( 'image2', {
editor.addMenuItem( 'image', {
label: lang.menu,
command: 'image2',
group: 'image2'
command: 'image',
group: 'image'
} );
}

@@ -98,8 +102,8 @@
}
} );

// Image2 widget definition.
var image2 = {
// Image widget definition.
var image = {
// Widget-specific rules for Allowed Content Filter.
allowedContent: {
// This widget may need <div> centering wrapper.
@@ -181,7 +185,7 @@
// non-captioned, block or inline according to what is the
// new state of the widget.
if ( this.destroyed ) {
widget = editor.widgets.initOn( element, 'image2', widget.data );
widget = editor.widgets.initOn( element, 'image', widget.data );

// Once widget was re-created, it may become an inline element without
// block wrapper (i.e. when unaligned, end not captioned). Let's do some
@@ -262,7 +266,7 @@

// Add widget editing option to its context menu.
this.on( 'contextMenu', function( evt ) {
evt.data.image2 = CKEDITOR.TRISTATE_OFF;
evt.data.image = CKEDITOR.TRISTATE_OFF;
} );

// Pass the reference to this widget to the dialog.
@@ -647,7 +651,7 @@
doc = editor.document,
resizer = doc.createElement( 'span' );

resizer.addClass( 'cke_image2_resizer' );
resizer.addClass( 'cke_image_resizer' );
resizer.setAttribute( 'title', editor.lang.image2.resizer );
resizer.append( new CKEDITOR.dom.text( '\u200b', doc ) );

@@ -656,7 +660,7 @@
var oldResizeWrapper = widget.element.getFirst(),
resizeWrapper = doc.createElement( 'span' );

resizeWrapper.addClass( 'cke_image2_resizer_wrapper' );
resizeWrapper.addClass( 'cke_image_resizer_wrapper' );
resizeWrapper.append( widget.parts.image );
resizeWrapper.append( resizer );
widget.element.append( resizeWrapper, true );
@@ -690,7 +694,7 @@
listeners = [],

// A class applied to editable during resizing.
cursorClass = 'cke_image2_s' + ( !~factor ? 'w' : 'e' ),
cursorClass = 'cke_image_s' + ( !~factor ? 'w' : 'e' ),

nativeEvt, newWidth, newHeight, updateData,
moveDiffX, moveDiffY, moveRatio;
@@ -708,7 +712,7 @@
editable.addClass( cursorClass );

// This is to always keep the resizer element visible while resizing.
resizer.addClass( 'cke_image2_resizing' );
resizer.addClass( 'cke_image_resizing' );

// Attaches an event to a global document if inline editor.
// Additionally, if framed, also attaches the same event to iframe's document.
@@ -843,7 +847,7 @@
editable.removeClass( cursorClass );

// This is to bring back the regular behaviour of the resizer.
resizer.removeClass( 'cke_image2_resizing' );
resizer.removeClass( 'cke_image_resizing' );

if ( updateData ) {
widget.setData( { width: newWidth, height: newHeight } );
@@ -859,7 +863,7 @@

// Change the position of the widget resizer when data changes.
widget.on( 'data', function() {
resizer[ widget.data.align == 'right' ? 'addClass' : 'removeClass' ]( 'cke_image2_resizer_left' );
resizer[ widget.data.align == 'right' ? 'addClass' : 'removeClass' ]( 'cke_image_resizer_left' );
} );
}

@@ -929,7 +933,7 @@
function getFocusedWidget( editor ) {
var widget = editor.widgets.focused;

if ( widget && widget.name == 'image2' )
if ( widget && widget.name == 'image' )
return widget;

return null;
Oops, something went wrong.

0 comments on commit 18df3e2

Please sign in to comment.
You can’t perform that action at this time.