Skip to content

Commit

Permalink
Merge branch 'master' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Jul 3, 2014
2 parents 687b2d4 + 731ec29 commit 747e28e
Show file tree
Hide file tree
Showing 8 changed files with 454 additions and 313 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Expand Up @@ -19,6 +19,9 @@ Fixed Issues:
Fixed Issues:

* [#12110](http://dev.ckeditor.com/ticket/12110): Fixed: Editor crash after deleting a table. Thanks to [Alin Purcaru](https://github.com/mesmerizero)!
* [#11897](http://dev.ckeditor.com/ticket/11897): Fixed: Enter key in an empty formatted list item, creates a new line instead of breaking the list. Thanks to [noam-si](https://github.com/noam-si)!
* [#12140](http://dev.ckeditor.com/ticket/12140): Fixed: Double-clicking linked widgets opens two dialogs.
* [#12132](http://dev.ckeditor.com/ticket/12132): Fixed: Image is inserted with `width` and `height` styles even when they are not allowed.

## CKEditor 4.4.2

Expand Down
26 changes: 18 additions & 8 deletions plugins/enterkey/plugin.js
Expand Up @@ -58,6 +58,10 @@
if ( atBlockStart && atBlockEnd ) {
// Exit the list when we're inside an empty list item block. (#5376)
if ( block && ( block.is( 'li' ) || block.getParent().is( 'li' ) ) ) {
// Make sure to point to the li when dealing with empty list item.
if ( !block.is( 'li' ) )
block = block.getParent();

var blockParent = block.getParent(),
blockGrandParent = blockParent.getParent(),

Expand Down Expand Up @@ -175,17 +179,23 @@

block.remove();
} else {
// Use <div> block for ENTER_BR and ENTER_DIV.
newBlock = doc.createElement( mode == CKEDITOR.ENTER_P ? 'p' : 'div' );
// Original path block is the list item, create new block for the list item content.
if ( path.block.is( 'li' ) ) {
// Use <div> block for ENTER_BR and ENTER_DIV.
newBlock = doc.createElement( mode == CKEDITOR.ENTER_P ? 'p' : 'div' );

if ( dirLoose )
newBlock.setAttribute( 'dir', orgDir );
if ( dirLoose )
newBlock.setAttribute('dir', orgDir);

style && newBlock.setAttribute( 'style', style );
className && newBlock.setAttribute( 'class', className );
style && newBlock.setAttribute( 'style', style );
className && newBlock.setAttribute( 'class', className );

// Move all the child nodes to the new block.
block.moveChildren( newBlock );
// Move all the child nodes to the new block.
block.moveChildren( newBlock );
}
// The original path block is not a list item, just copy the block to out side of the list.
else
newBlock = path.block;

// If block is the first or last child of the parent
// list, move it out of the list:
Expand Down
4 changes: 2 additions & 2 deletions plugins/image/dialogs/image.js
Expand Up @@ -586,7 +586,7 @@
commit: function( type, element, internalCommit ) {
var value = this.getValue();
if ( type == IMAGE ) {
if ( value )
if ( value && editor.activeFilter.check( 'img{width,height}' ) )
element.setStyle( 'width', CKEDITOR.tools.cssLength( value ) );
else
element.removeStyle( 'width' );
Expand Down Expand Up @@ -626,7 +626,7 @@
commit: function( type, element, internalCommit ) {
var value = this.getValue();
if ( type == IMAGE ) {
if ( value )
if ( value && editor.activeFilter.check( 'img{width,height}' ) )
element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) );
else
element.removeStyle( 'height' );
Expand Down
15 changes: 0 additions & 15 deletions plugins/image2/plugin.js
Expand Up @@ -1341,21 +1341,6 @@
if ( !editor.plugins.link )
return;

// Generally speaking, link dialog does not open if double-clicked
// linked widget because widget internals are read-only:
//
// <wrapper><a><img/></a></wrapper> // <a> is not editable
//
// However, in the following case:
//
// <a>x<wrapper><img/></wrapper>x</a> // <a> is editable
//
// it would open along with Image2 dialog, if not blocked.
editor.on( 'doubleclick', function( evt ) {
if ( evt.data.dialog && evt.data.dialog == 'link' && getFocusedWidget( editor ) )
evt.cancel();
} );

CKEDITOR.on( 'dialogDefinition', function( evt ) {
var dialog = evt.data;

Expand Down
25 changes: 23 additions & 2 deletions plugins/widget/plugin.js
Expand Up @@ -1061,14 +1061,16 @@
*
* The dialog window name is obtained from the event's data `dialog` property or
* from {@link CKEDITOR.plugins.widget.definition#dialog}.
*
* @returns {Boolean} Returns `true` if dialog was opened.
*/
edit: function() {
var evtData = { dialog: this.dialog },
that = this;

// Edit event was blocked, but there's no dialog to be automatically opened.
if ( this.fire( 'edit', evtData ) === false || !evtData.dialog )
return;
return false;

this.editor.openDialog( evtData.dialog, function( dialog ) {
var showListener,
Expand Down Expand Up @@ -1110,6 +1112,8 @@
okListener.removeListener();
} );
} );

return true;
},

/**
Expand Down Expand Up @@ -1481,6 +1485,19 @@
/**
* An event fired when a widget is double clicked.
*
* **Note:** if a default editing action is executed on double click (i.e. widget has a
* {@link CKEDITOR.plugins.widget.definition#dialog dialog} defined and the {@link #event-doubleclick} event was not
* cancelled) this event will be automatically cancelled, so listener added with the default priority (10)
* will not be executed. Use listener with low priority (e.g. 5) to be sure that it will be executed.
*
* widget.on( 'doubleclick', function( evt ) {
* console.log( 'widget#doubleclick' );
* }, null, null, 5 );
*
* If your widget handles double click in a special way (so default editing action is not executed)
* make sure to cancel this event, because otherwise it will be propagated to {@link CKEDITOR.editor#doubleclick}
* and other feature may step in (e.g. link dialog may be opened if your widget was inside a link).
*
* @event doubleclick
* @param data
* @param {CKEDITOR.dom.element} data.element The double clicked element.
Expand Down Expand Up @@ -3171,7 +3188,11 @@
// to overwrite this callback.

widget.on( 'doubleclick', function( evt ) {
widget.edit();
if ( widget.edit() ) {
// We have to cancel event if edit method opens a dialog, otherwise
// link plugin may open extra dialog (#12140).
evt.cancel();
}
} );

if ( widgetDef.data )
Expand Down
38 changes: 38 additions & 0 deletions tests/plugins/enter/list.js
Expand Up @@ -514,6 +514,44 @@
true, 'Direction should be preserved if different than cointainer\'s.', true );
},

'test enterkey: leaves empty list item with h1 format': function() {
assertEnter( 'enterP',
'<ul>' +
'<li>x</li>' +
'<li><h1>^</h1></li>' +
'<li>y</li>' +
'</ul>',

'<ul>' +
'<li>x</li>' +
'</ul>' +
'<h1>^&nbsp;</h1>' +
'<ul>' +
'<li>y</li>' +
'</ul>',

true, 'List should be split and format preserved.', true );
},

'test enterkey: leaves empty list item with a paragraph': function() {
assertEnter( 'enterP',
'<ul>' +
'<li>x</li>' +
'<li><p>^</p></li>' +
'<li>y</li>' +
'</ul>',

'<ul>' +
'<li>x</li>' +
'</ul>' +
'<p>^&nbsp;</p>' +
'<ul>' +
'<li>y</li>' +
'</ul>',

true, 'List should be split.', true );
},

'test enterkey: force block: style (ENTER_BR)': function() {
assertEnter( 'enterBR',
'<ul>' +
Expand Down

0 comments on commit 747e28e

Please sign in to comment.