Skip to content
Permalink
Browse files

Merge branch 't/10881' into major

  • Loading branch information...
oleq committed Oct 4, 2013
2 parents 563c991 + 4fbc393 commit 628ea19d714e993e6748e77529eb19a681825bcc
Showing with 67 additions and 13 deletions.
  1. +1 −0 CHANGES.md
  2. +4 −1 core/editor.js
  3. +10 −3 core/filter.js
  4. +52 −9 plugins/widget/plugin.js
@@ -14,6 +14,7 @@ Fixed Issues:
* [#10831](http://dev.ckeditor.com/ticket/10831): Image2: Merged `image2inline` and `image2block` into `image2` widget.
* [#10835](http://dev.ckeditor.com/ticket/10835): Image2: Improved visibility of the resize handler.
* [#10836](http://dev.ckeditor.com/ticket/10836): Image2: Preserve custom mouse cursor while resizing the image.
* [#10881](http://dev.ckeditor.com/ticket/10881): Various improvements to *Enter* key behaviour in nested editables.

## CKEditor 4.3 Beta

@@ -1168,7 +1168,10 @@
if ( filter === this.filter )
this.setActiveEnterMode( null, null );
else
this.setActiveEnterMode( filter.getAllowedEnterMode(), filter.getAllowedEnterMode( true ) );
this.setActiveEnterMode(
filter.getAllowedEnterMode( this.enterMode ),
filter.getAllowedEnterMode( this.shiftEnterMode, true )
);
}
},

@@ -656,21 +656,28 @@
* Returns first enter mode allowed by this filter rules. Modes are checked in `p`, `div`, `br` order.
* If none of tags is allowed this method will return {@link CKEDITOR#ENTER_BR}.
*
* @since 4.3
* @param {Number} defaultMode The default mode which will be checked as the first one.
* @param {Boolean} [reverse] Whether to check modes in reverse order (used for shift enter mode).
* @returns {Number} Allowed enter mode.
*/
getAllowedEnterMode: (function() {
var enterModeTags = [ 'p', 'div', 'br' ],
var tagsToCheck = [ 'p', 'div', 'br' ],
enterModes = {
p: CKEDITOR.ENTER_P,
div: CKEDITOR.ENTER_DIV,
br: CKEDITOR.ENTER_BR
};

return function( reverse ) {
var tags = enterModeTags.slice(),
return function( defaultMode, reverse ) {
// Clone the array first.
var tags = tagsToCheck.slice(),
tag;

// Check the default mode first.
if ( this.check( enterModeTags[ defaultMode ] ) )
return defaultMode;

// If not reverse order, reverse array so we can pop() from it.
if ( !reverse )
tags = tags.reverse();
@@ -823,7 +823,7 @@
if ( !offline ) {
editable.removeClass( 'cke_widget_editable' );
editable.removeClass( 'cke_widget_editable_focused' );
editable.removeAttributes( [ 'contenteditable', 'data-cke-widget-editable' ] );
editable.removeAttributes( [ 'contenteditable', 'data-cke-widget-editable', 'data-cke-enter-mode' ] );
}

delete this.editables[ editableName ];
@@ -911,7 +911,8 @@

editable.setAttributes( {
contenteditable: 'true',
'data-cke-widget-editable': editableName
'data-cke-widget-editable': editableName,
'data-cke-enter-mode': editable.enterMode
} );
editable.addClass( 'cke_widget_editable' );
// This class may be left when d&ding widget which
@@ -1171,7 +1172,15 @@
// Call the base constructor.
CKEDITOR.dom.element.call( this, element.$ );
this.editor = editor;
this.filter = config.filter;
var filter = this.filter = config.filter;

// If blockless editable - always use BR mode.
if ( !CKEDITOR.dtd[ this.getName() ].p )
this.enterMode = this.shiftEnterMode = CKEDITOR.ENTER_BR;
else {
this.enterMode = filter ? filter.getAllowedEnterMode( editor.enterMode ) : editor.enterMode;
this.shiftEnterMode = filter ? filter.getAllowedEnterMode( editor.shiftEnterMode, true ) : editor.shiftEnterMode;
}
}

NestedEditable.prototype = CKEDITOR.tools.extend( CKEDITOR.tools.prototypedCopy( CKEDITOR.dom.element.prototype ), {
@@ -1186,7 +1195,7 @@
data = this.editor.dataProcessor.toHtml( data, {
context: this.getName(),
filter: this.filter,
enterMode: this.filter ? this.filter.getAllowedEnterMode() : this.editor.enterMode
enterMode: this.enterMode
} );
this.setHtml( data );
},
@@ -1200,11 +1209,41 @@
return this.editor.dataProcessor.toDataFormat( this.getHtml(), {
context: this.getName(),
filter: this.filter,
enterMode: this.filter ? this.filter.getAllowedEnterMode() : this.editor.enterMode
enterMode: this.enterMode
} );
}
} );

/**
* The editor instance.
*
* @readonly
* @property {CKEDITOR.editor} editor
*/

/**
* The filter instance if allowed content rules were defined.
*
* @readonly
* @property {CKEDITOR.filter} filter
*/

/**
* The enter mode active in this editable.
* It is determined from editable's name (whether it is a blockless editable),
* its allowed content rules (if defined) and the default editor's mode.
*
* @readonly
* @property {Number} enterMode
*/

/**
* The shift enter move active in this editable.
*
* @readonly
* @property {Number} shiftEnterMode
*/


//
// REPOSITORY helpers -----------------------------------------------------
@@ -1616,7 +1655,9 @@
}

function setFocusedEditable( widgetsRepo, widget, editableElement, offline ) {
widgetsRepo.editor.fire( 'lockSnapshot' );
var editor = widgetsRepo.editor;

editor.fire( 'lockSnapshot' );

if ( editableElement ) {
var editableName = editableElement.data( 'cke-widget-editable' ),
@@ -1627,17 +1668,19 @@
editableElement.addClass( 'cke_widget_editable_focused' );

if ( editableInstance.filter )
widgetsRepo.editor.setActiveFilter( editableInstance.filter );
editor.setActiveFilter( editableInstance.filter );
editor.setActiveEnterMode( editableInstance.enterMode, editableInstance.shiftEnterMode );
} else {
if ( !offline )
widget.focusedEditable.removeClass( 'cke_widget_editable_focused' );

widget.focusedEditable = null;
widgetsRepo.widgetHoldingFocusedEditable = null;
widgetsRepo.editor.setActiveFilter( null );
editor.setActiveFilter( null );
editor.setActiveEnterMode( null, null );
}

widgetsRepo.editor.fire( 'unlockSnapshot' );
editor.fire( 'unlockSnapshot' );
}

function setupContextMenu( editor ) {

0 comments on commit 628ea19

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