Skip to content
Permalink
Browse files

Merge branch 't/11244'

  • Loading branch information...
Reinmar committed Dec 4, 2013
2 parents 16b11f4 + 606b1df commit 35c31bcc29ee9a090576f188b3b40f899853691f
Showing with 58 additions and 60 deletions.
  1. +3 −2 CHANGES.md
  2. +55 −58 plugins/widget/plugin.js
@@ -9,10 +9,11 @@ CKEditor 4 Changelog

Fixed Issues:

* [#11244](http://dev.ckeditor.com/ticket/11244): Changed: The [`widget.repository.checkWidgets`](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget.repository-method-checkWidgets) method now fires the [`widget.repository.checkWidgets`](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget.repository-event-checkWidgets) event, so from CKEditor 4.3.1 it's preferred to use method rather than fire event.
* [#11171](http://dev.ckeditor.com/ticket/11171): Fixed: [`editor.insertElement`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertElement) and [`editor.insertText`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertText) methods do not call the [`widget.repository.checkWidgets`](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget.repository-method-checkWidgets) method.
* [#11044](http://dev.ckeditor.com/ticket/11044): Enhanced aria support for language plugin drop-down menu.
* [#11075](http://dev.ckeditor.com/ticket/11075): With drop-down menubutton focused, pressing down arrow key will now open menu and focus its first option.
* [#11165](http://dev.ckeditor.com/ticket/11165): The filebrowser plugin cannot be removed from the editor.
* [#11171](http://dev.ckeditor.com/ticket/11171): Fixed: [`editor.insertElement`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertElement) and [`editor.insertText`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertText) methods do not call the [`widget.repository.checkWidgets`](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget.repository-method-checkWidgets) method.
* [#11165](http://dev.ckeditor.com/ticket/11165): Fixed: The filebrowser plugin cannot be removed from the editor.
* [#11159](http://dev.ckeditor.com/ticket/11159): [Enhanced Image](http://ckeditor.com/addon/image2): Fixed buggy discovery of image dimensions in IE9 and IE10.
* [#11101](http://dev.ckeditor.com/ticket/11101): Richcombo no longer breaks when given double quotes.
* [#11077](http://dev.ckeditor.com/ticket/11077): [Enhanced Image](http://ckeditor.com/addon/image2): Empty undo step recorded when resizing the image.
@@ -262,8 +262,8 @@
* Reinitializes widgets on widget wrappers for which widget instances
* cannot be found.
*
* This method is triggered by the {@link #event-checkWidgets} event **and should
* not be called directly**.
* This method triggers the {@link #event-checkWidgets} event which listeners
* can cancel the execution or modify options.
*
* @param [options] The options object.
* @param {Boolean} [options.initOnlyNew] Init widgets only on newly created
@@ -274,47 +274,7 @@
* the method, then it will be focused.
*/
checkWidgets: function( options ) {
if ( this.editor.mode != 'wysiwyg' )
return;

var editable = this.editor.editable(),
instances = this.instances,
newInstances, i, count, wrapper;

if ( !editable )
return;

// Remove widgets which have no corresponding elements in DOM.
for ( i in instances ) {
if ( !editable.contains( instances[ i ].wrapper ) )
this.destroy( instances[ i ], true );
}

// Init on all (new) if initOnlyNew option was passed.
if ( options && options.initOnlyNew )
newInstances = this.initOnAll();
else {
var wrappers = editable.find( '.cke_widget_wrapper' );
newInstances = [];

// Create widgets on existing wrappers if they do not exists.
for ( i = 0, count = wrappers.count(); i < count; i++ ) {
wrapper = wrappers.getItem( i );

// Check if there's no instance for this widget and that
// wrapper is not inside some temporary element like copybin (#11088).
if ( !this.getByElement( wrapper, true ) && !findParent( wrapper, isTemp2 ) ) {
// Add cke_widget_new class because otherwise
// widget will not be created on such wrapper.
wrapper.addClass( 'cke_widget_new' );
newInstances.push( this.initOn( wrapper.getFirst( isWidgetElement2 ) ) );
}
}
}

// If only single widget was initialized and focusInited was passed, focus it.
if ( options && options.focusInited && newInstances.length == 1 )
newInstances[ 0 ].focus();
this.fire( 'checkWidgets', CKEDITOR.tools.copy( options || {} ) );
},

/**
@@ -638,15 +598,10 @@
*/

/**
* An event fired to trigger the widgets check.
* An event fired by the the {@link #method-checkWidgets} method.
*
* See the {@link #method-checkWidgets} method.
*
* // Will destroy old widgets and initialize new ones.
* editor.widgets.fire( 'checkWidgets' );
*
* // Initialized widget will be focused.
* editor.widgets.fire( 'checkWidgets', { focusInited: true } );
* It can be canceled in order to stop check widgets execution or
* listener can modify the options.
*
* @event checkWidgets
* @param [data]
@@ -1508,6 +1463,52 @@
}
}

function checkWidgets( evt ) {
var options = evt.data;

if ( this.editor.mode != 'wysiwyg' )
return;

var editable = this.editor.editable(),
instances = this.instances,
newInstances, i, count, wrapper;

if ( !editable )
return;

// Remove widgets which have no corresponding elements in DOM.
for ( i in instances ) {
if ( !editable.contains( instances[ i ].wrapper ) )
this.destroy( instances[ i ], true );
}

// Init on all (new) if initOnlyNew option was passed.
if ( options && options.initOnlyNew )
newInstances = this.initOnAll();
else {
var wrappers = editable.find( '.cke_widget_wrapper' );
newInstances = [];

// Create widgets on existing wrappers if they do not exists.
for ( i = 0, count = wrappers.count(); i < count; i++ ) {
wrapper = wrappers.getItem( i );

// Check if there's no instance for this widget and that
// wrapper is not inside some temporary element like copybin (#11088).
if ( !this.getByElement( wrapper, true ) && !findParent( wrapper, isTemp2 ) ) {
// Add cke_widget_new class because otherwise
// widget will not be created on such wrapper.
wrapper.addClass( 'cke_widget_new' );
newInstances.push( this.initOn( wrapper.getFirst( isWidgetElement2 ) ) );
}
}
}

// If only single widget was initialized and focusInited was passed, focus it.
if ( options && options.focusInited && newInstances.length == 1 )
newInstances[ 0 ].focus();
}

// Unwraps widget element and clean up element.
//
// This function is used to clean up pasted widgets.
@@ -2166,12 +2167,8 @@
setupWidgetsLifecycleStart( widgetsRepo );
setupWidgetsLifecycleEnd( widgetsRepo );

widgetsRepo.on( 'checkWidgets', function( evt ) {
widgetsRepo.checkWidgets( evt.data );
} );
widgetsRepo.editor.on( 'contentDomInvalidated', function() {
widgetsRepo.fire( 'checkWidgets' );
} );
widgetsRepo.on( 'checkWidgets', checkWidgets );
widgetsRepo.editor.on( 'contentDomInvalidated', widgetsRepo.checkWidgets, widgetsRepo );
}

function setupWidgetsLifecycleEnd( widgetsRepo ) {
@@ -2319,7 +2316,7 @@

// Init only new for performance reason.
// Focus inited if only widget was processed.
widgetsRepo.fire( 'checkWidgets', { initOnlyNew: true, focusInited: processedWidgetOnly } );
widgetsRepo.checkWidgets( { initOnlyNew: true, focusInited: processedWidgetOnly } );

editor.fire( 'unlockSnapshot' );
}

0 comments on commit 35c31bc

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