Skip to content

Commit

Permalink
Merge branch 't/11372'
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Jan 13, 2014
2 parents 0016523 + d7507d9 commit d138ae0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Expand Up @@ -26,7 +26,8 @@ CKEditor 4 Changelog
* [#10787](http://dev.ckeditor.com/ticket/10787): [Firefox] Fixed: Broken replacement of text while pasting into div-based editor.
* [#10884](http://dev.ckeditor.com/ticket/10884): Widgets integration with [Showblocks](http://ckeditor.com/addon/showblocks) plugin.
* [#11021](http://dev.ckeditor.com/ticket/11021): Fixed: An error thrown when selecting entire editable's contents while fake selection is on.
* [#11086](http://dev.ckeditor.com/ticket/11086): [IE8]Re enable inline widgets drag & drop on IE8.
* [#11086](http://dev.ckeditor.com/ticket/11086): [IE8] Re-enable inline widgets drag&drop on IE8.
* [#11372](http://dev.ckeditor.com/ticket/11372): Widgets: Special characters encoded twice in nested editables.

## CKEditor 4.3.1

Expand Down
6 changes: 5 additions & 1 deletion core/htmlparser/element.js
Expand Up @@ -484,7 +484,8 @@ CKEDITOR.htmlParser.cssStyle = function() {
if ( !ctx ) {
ctx = {
off: false,
nonEditable: false
nonEditable: false,
nestedEditable: false
};
}

Expand All @@ -493,6 +494,9 @@ CKEDITOR.htmlParser.cssStyle = function() {

if ( !ctx.nonEditable && this.attributes[ 'contenteditable' ] == 'false' )
changes.push( 'nonEditable', true );
// A context to be given nestedEditable must be nonEditable first (by inheritance).
else if ( !ctx.nestedEditable && this.attributes[ 'contenteditable' ] == 'true' )
changes.push( 'nestedEditable', true );

if ( changes.length ) {
ctx = CKEDITOR.tools.copy( ctx );
Expand Down
9 changes: 7 additions & 2 deletions core/htmlparser/filter.js
Expand Up @@ -390,8 +390,13 @@
}

function isRuleApplicable( context, rule ) {
// Do not apply rule if context is nonEditable and rule doesn't have applyToAll option.
return !context.nonEditable || rule.options.applyToAll;
if ( context.nonEditable && !rule.options.applyToAll )
return false;

if ( context.nestedEditable && rule.options.excludeNestedEditable )
return false;

return true;
}

} )();
Expand Down
5 changes: 4 additions & 1 deletion plugins/entities/plugin.js
Expand Up @@ -151,7 +151,10 @@
text: function( text ) {
return text.replace( baseEntitiesRegex, getChar ).replace( entitiesRegex, getEntity );
}
}, { applyToAll: true } );
}, {
applyToAll: true,
excludeNestedEditable: true
} );
}
}
} );
Expand Down
23 changes: 16 additions & 7 deletions plugins/widget/plugin.js
Expand Up @@ -2234,7 +2234,8 @@
toBeDowncasted.push( {
wrapper: element,
element: widgetElement,
widget: widget
widget: widget,
editables: {}
} );

// If widget did not have data-cke-widget attribute before upcasting remove it.
Expand All @@ -2244,11 +2245,11 @@
}
// Nested editable.
else if ( 'data-cke-widget-editable' in attrs ) {
delete attrs[ 'contenteditable' ];

// Replace nested editable's content with its output data.
var editable = toBeDowncasted[ toBeDowncasted.length - 1 ].widget.editables[ attrs[ 'data-cke-widget-editable' ] ];
element.setHtml( editable.getData() );
// Save the reference to this nested editable in the closest widget to be downcasted.
// Nested editables are downcasted in the successive toDataFormat to create an opportunity
// for dataFilter's "excludeNestedEditable" option to do its job (that option relies on
// contenteditable="true" attribute) (#11372).
toBeDowncasted[ toBeDowncasted.length - 1 ].editables[ attrs[ 'data-cke-widget-editable' ] ] = element;

// Don't check children - there won't be next wrapper or nested editable which we
// should process in this session.
Expand All @@ -2265,13 +2266,21 @@
return;

var toBeDowncasted = downcastingSessions[ evt.data.downcastingSessionId ],
toBe, widget, widgetElement, retElement;
toBe, widget, widgetElement, retElement, editableElement, e;

while ( ( toBe = toBeDowncasted.shift() ) ) {
widget = toBe.widget;
widgetElement = toBe.element;
retElement = widget._.downcastFn && widget._.downcastFn.call( widget, widgetElement );

// Replace nested editables' content with their output data.
for ( e in toBe.editables ) {
editableElement = toBe.editables[ e ];

delete editableElement.attributes[ 'contenteditable' ];
editableElement.setHtml( widget.editables[ e ].getData() );
}

// Returned element always defaults to widgetElement.
if ( !retElement )
retElement = widgetElement;
Expand Down

0 comments on commit d138ae0

Please sign in to comment.