Skip to content
Permalink
Browse files

Merge branch 't/11004b'

  • Loading branch information...
oleq committed Feb 17, 2014
2 parents bb0ed1c + cfe7d02 commit 24f740616162b1336564de6f41acc3e1bf3e09d7
Showing with 71 additions and 17 deletions.
  1. +1 −0 CHANGES.md
  2. +7 −1 plugins/image2/dialogs/image2.js
  3. +63 −16 plugins/image2/plugin.js
@@ -23,6 +23,7 @@ Fixed Issues:
* [#11390](http://dev.ckeditor.com/ticket/11390): All [XML](http://docs.ckeditor.com/#!/api/CKEDITOR.xml) plugin's methods work now on IE10+.
* [#11542](http://dev.ckeditor.com/ticket/11542): [IE11] Fixed: Blurry toolbar icons when right-to-left UI language is set.
* [#11504](http://dev.ckeditor.com/ticket/11504): Fixed: When `config.fullPage` is set `true`, entities are not encoded in editor's output.
* [#11004](http://dev.ckeditor.com/ticket/11004): Integrated [Enhanced Image](http://ckeditor.com/addon/image2) dialog with [Advanced Content Filter](http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter).

## CKEditor 4.3.2

@@ -38,6 +38,10 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {

helpers = CKEDITOR.plugins.image2,

// Content restrictions defined by the widget which
// impact on dialog structure and presence of fields.
features = editor.widgets.registered.image.features,

// Functions inherited from image2 plugin.
checkHasNaturalRatio = helpers.checkHasNaturalRatio,
getNatural = helpers.getNatural,
@@ -428,7 +432,7 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
{
type: 'hbox',
widths: [ '25%', '25%', '50%' ],
requiredContent: 'img[width,height]',
requiredContent: features.dimension.requiredContent,
children: [
{
type: 'text',
@@ -482,6 +486,7 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
{
type: 'hbox',
id: 'alignment',
requiredContent: features.align.requiredContent,
children: [
{
id: 'align',
@@ -505,6 +510,7 @@ CKEDITOR.dialog.add( 'image2', function( editor ) {
id: 'hasCaption',
type: 'checkbox',
label: lang.captioned,
requiredContent: features.caption.requiredContent,
setup: function( widget ) {
this.setValue( widget.data.hasCaption );
},
@@ -132,6 +132,22 @@
}
},

requiredContent: 'img[src,alt]',

// Note: The following may not cover all the possible cases since
// requiredContent supports a single tag only.
features: {
dimension: {
requiredContent: 'img[width,height]'
},
align: {
requiredContent: 'img{float}'
},
caption: {
requiredContent: 'figcaption'
}
},

// This widget converts style-driven dimensions to attributes.
contentTransformations: [
[ 'img[width]: sizeToAttribute' ]
@@ -162,7 +178,16 @@
doc = editor.document,
editable = editor.editable(),
oldState = widget.oldData,
newState = widget.data;
newState = widget.data,
features = this.features;

// Image can't be captioned when figcaption is disallowed (#11004).
if ( newState.hasCaption && !editor.filter.checkFeature( features.caption ) )
newState.hasCaption = false;

// Image can't be aligned when floating is disallowed (#11004).
if ( newState.align != 'none' && !editor.filter.checkFeature( features.align ) )
newState.align = 'none';

// Convert the internal form of the widget from the old state to the new one.
widget.shiftState( {
@@ -229,7 +254,9 @@
} );

// Set dimensions of the image according to gathered data.
setDimensions( widget );
// Do it only when the attributes are allowed (#11004).
if ( editor.filter.checkFeature( features.dimension ) )
setDimensions( widget );

// Cache current data.
widget.oldData = CKEDITOR.tools.extend( {}, widget.data );
@@ -265,7 +292,9 @@
this.setData( data );

// Setup dynamic image resizing with mouse.
setupResizer( this );
// Don't initialize resizer when dimensions are disallowed (#11004).
if ( editor.filter.checkFeature( this.features.dimension ) )
setupResizer( this );

this.shiftState = helpers.stateShifter( this.editor );

@@ -593,9 +622,13 @@
// Only block widgets have one.
if ( !this.inline ) {
var resizeWrapper = el.getFirst( 'span' ),
img = resizeWrapper.getFirst( 'img' );
img;

resizeWrapper.replaceWith( img );
if ( resizeWrapper ) {
img = resizeWrapper.getFirst( 'img' );
resizeWrapper.replaceWith( img );
} else
img = el.getFirst( 'img' );
}

if ( align && align != 'none' ) {
@@ -702,7 +735,9 @@
var editor = widget.editor,
editable = editor.editable(),
doc = editor.document,
resizer = doc.createElement( 'span' );

// Store the resizer in a widget for testing (#11004).
resizer = widget.resizer = doc.createElement( 'span' );

resizer.addClass( 'cke_image_resizer' );
resizer.setAttribute( 'title', editor.lang.image2.resizer );
@@ -925,7 +960,8 @@
// @param {CKEDITOR.editor} editor
// @param {String} value 'left', 'right', 'center' or 'block'
function alignCommandIntegrator( editor ) {
var execCallbacks = [];
var execCallbacks = [],
enabled;

return function( value ) {
var command = editor.getCommand( 'justify' + value );
@@ -964,14 +1000,25 @@
if ( !widget )
return;

this.setState(
( widget.data.align == value ) ?
CKEDITOR.TRISTATE_ON
:
( value in allowed ) ?
CKEDITOR.TRISTATE_OFF
:
CKEDITOR.TRISTATE_DISABLED );
// Cache "enabled" on first use. This is because filter#checkFeature may
// not be available during plugin's afterInit in the future — a moment when
// alignCommandIntegrator is called.
if ( enabled == undefined )
enabled = editor.filter.checkFeature( editor.widgets.registered.image.features.align );

// Don't allow justify commands when widget alignment is disabled (#11004).
if ( !enabled )
this.setState( CKEDITOR.TRISTATE_DISABLED );
else {
this.setState(
( widget.data.align == value ) ?
CKEDITOR.TRISTATE_ON
:
( value in allowed ) ?
CKEDITOR.TRISTATE_OFF
:
CKEDITOR.TRISTATE_DISABLED );
}

evt.cancel();
} );
@@ -991,4 +1038,4 @@

return null;
}
} )();
} )();

0 comments on commit 24f7406

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