Skip to content
Permalink
Browse files

Merge branch 't/11042'

  • Loading branch information...
Reinmar committed Dec 3, 2013
2 parents 6aca6fe + bc7a60b commit eaa4592db7e93bc41a98967004ce0a33fb77dcdf
Showing with 30 additions and 7 deletions.
  1. +1 −0 CHANGES.md
  2. +29 −7 core/selection.js
@@ -19,6 +19,7 @@ Fixed Issues:
* [#10890](http://dev.ckeditor.com/ticket/10890): Fixed: Error thrown when pressing *Delete* key in a list item.
* [#10055](http://dev.ckeditor.com/ticket/10055): [IE8-10] Fixed: *Delete* pressed on selected image causes browser to go back.
* [#11183](http://dev.ckeditor.com/ticket/11183): Fixed: Inserting line or table in multiple rows selection causes browser crash. Additionally, the [`editor.insertElement`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertElement) method does not insert element into every range of a selection any more.
* [#11042](http://dev.ckeditor.com/ticket/11042): Fixed: Selection made on element containing non-editable element was not auto faked.


## CKEditor 4.3
@@ -378,6 +378,31 @@
};
}

// If fake selection should be applied this function will return instance of
// CKEDITOR.dom.element which should gain fake selection.
function getNonEditableFakeSelectionReceiver( ranges ) {
var enclosedNode,
shrinkedNode,
clone,
range;

if ( ranges.length == 1 && !( range = ranges[ 0 ] ).collapsed &&
( enclosedNode = range.getEnclosedNode() ) && enclosedNode.type == CKEDITOR.NODE_ELEMENT ) {
// So far we can't say that enclosed element is non-editable. Before checking,
// we'll shrink range (clone). Shrinking will stop on non-editable range, or
// innermost element (#11114).
clone = range.clone();
clone.shrink( CKEDITOR.SHRINK_ELEMENT, true );

// If shrinked range still encloses an element, check this one (shrink stops only on non-editable elements).
if ( ( shrinkedNode = clone.getEnclosedNode() ) && shrinkedNode.type == CKEDITOR.NODE_ELEMENT )
enclosedNode = shrinkedNode;

if ( enclosedNode.getAttribute( 'contenteditable' ) == 'false' )
return enclosedNode;
}
}

// Setup all editor instances for the necessary selection hooks.
CKEDITOR.on( 'instanceCreated', function( ev ) {
var editor = ev.editor;
@@ -1713,13 +1738,10 @@
}

// Handle special case - automatic fake selection on non-editable elements.
var enclosedNode;
if (
ranges.length == 1 && !ranges[ 0 ].collapsed &&
( enclosedNode = ranges[ 0 ].getEnclosedNode() ) &&
enclosedNode.type == CKEDITOR.NODE_ELEMENT && enclosedNode.getAttribute( 'contenteditable' ) == 'false'
) {
this.fake( enclosedNode );
var receiver = getNonEditableFakeSelectionReceiver( ranges );

if ( receiver ) {
this.fake( receiver );
return;
}

0 comments on commit eaa4592

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