Skip to content

Commit

Permalink
Fixed issue #6922: Problem with placing the cursor after placeholder …
Browse files Browse the repository at this point in the history
…in IE8

Dev Updating CKEditor to 3.6.5 - hopefull fixed issue above
  • Loading branch information
c-schmitz committed Nov 30, 2012
1 parent 68f980c commit 1cefb42
Show file tree
Hide file tree
Showing 57 changed files with 1,799 additions and 305 deletions.
44 changes: 41 additions & 3 deletions third_party/ckeditor/_source/core/dom/element.js
Expand Up @@ -105,6 +105,9 @@ CKEDITOR.dom.element.clearMarkers = function( database, element, removeFromDatab
}
};

( function()
{

CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
/** @lends CKEDITOR.dom.element.prototype */
{
Expand Down Expand Up @@ -504,7 +507,10 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
:
function( propertyName )
{
return this.getWindow().$.getComputedStyle( this.$, '' ).getPropertyValue( propertyName );
var style = this.getWindow().$.getComputedStyle( this.$, null );

// Firefox may return null if we call the above on a hidden iframe. (#9117)
return style ? style.getPropertyValue( propertyName ) : '';
},

/**
Expand Down Expand Up @@ -1186,6 +1192,16 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
{
// Removes the specified property from the current style object.
var $ = this.$.style;

// "removeProperty" need to be specific on the following styles.
if ( !$.removeProperty && ( name == 'border' || name == 'margin' || name == 'padding' ) )
{
var names = expandedRules( name );
for ( var i = 0 ; i < names.length ; i++ )
this.removeStyle( names[ i ] );
return;
}

$.removeProperty ? $.removeProperty( name ) : $.removeAttribute( CKEDITOR.tools.cssStyleToDomStyle( name ) );

if ( !this.$.style.cssText )
Expand Down Expand Up @@ -1752,13 +1768,35 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype,
}
});

( function()
{
var sides = {
width : [ "border-left-width", "border-right-width","padding-left", "padding-right" ],
height : [ "border-top-width", "border-bottom-width", "padding-top", "padding-bottom" ]
};

// Generate list of specific style rules, applicable to margin/padding/border.
function expandedRules( style )
{
var sides = [ 'top', 'left', 'right', 'bottom' ], components;

if ( style == 'border' )
components = [ 'color', 'style', 'width' ];

var styles = [];
for ( var i = 0 ; i < sides.length ; i++ )
{

if ( components )
{
for ( var j = 0 ; j < components.length ; j++ )
styles.push( [ style, sides[ i ], components[j] ].join( '-' ) );
}
else
styles.push( [ style, sides[ i ] ].join( '-' ) );
}

return styles;
}

function marginAndPaddingSize( type )
{
var adjustment = 0;
Expand Down
20 changes: 20 additions & 0 deletions third_party/ckeditor/_source/core/dom/event.js
Expand Up @@ -117,6 +117,26 @@ CKEDITOR.dom.event.prototype =
{
var rawNode = this.$.target || this.$.srcElement;
return rawNode ? new CKEDITOR.dom.node( rawNode ) : null;
},

/**
* Retrieves the coordinates of the mouse pointer relative to the top-left
* corner of the document, in mouse related event.
* @returns {Object} The object contains the position.
* @example
* element.on( 'mousemouse', function( ev )
* {
* var pageOffset = ev.data.getPageOffset();
* alert( pageOffset.x ); // page offset X
* alert( pageOffset.y ); // page offset Y
* });
*/
getPageOffset : function()
{
var doc = this.getTarget().getDocument().$;
var pageX = this.$.pageX || this.$.clientX + ( doc.documentElement.scrollLeft || doc.body.scrollLeft );
var pageY = this.$.pageY || this.$.clientY + ( doc.documentElement.scrollTop || doc.body.scrollTop );
return { x : pageX, y : pageY };
}
};

Expand Down
3 changes: 2 additions & 1 deletion third_party/ckeditor/_source/core/dom/node.js
Expand Up @@ -106,7 +106,8 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype,

if ( !cloneId )
node.removeAttribute( 'id', false );
node.removeAttribute( 'data-cke-expando', false );

node[ 'data-cke-expando' ] = undefined;

if ( includeChildren )
{
Expand Down
139 changes: 85 additions & 54 deletions third_party/ckeditor/_source/core/dom/range.js
Expand Up @@ -347,50 +347,38 @@ CKEDITOR.dom.range = function( document )

// Creates the appropriate node evaluator for the dom walker used inside
// check(Start|End)OfBlock.
function getCheckStartEndBlockEvalFunction( isStart )
function getCheckStartEndBlockEvalFunction()
{
var skipBogus = false,
whitespaces = CKEDITOR.dom.walker.whitespaces(),
bookmarkEvaluator = CKEDITOR.dom.walker.bookmark( true ),
nbspRegExp = /^[\t\r\n ]*(?:&nbsp;|\xa0)$/;
isBogus = CKEDITOR.dom.walker.bogus();

return function( node )
{
// First ignore bookmark nodes.
if ( bookmarkEvaluator( node ) )
// First skip empty nodes.
if ( bookmarkEvaluator( node ) || whitespaces( node ) )
return true;

if ( node.type == CKEDITOR.NODE_TEXT )
// Skip the bogus node at the end of block.
if ( isBogus( node ) &&
!skipBogus )
{
// Skip the block filler NBSP.
if ( CKEDITOR.env.ie &&
nbspRegExp.test( node.getText() ) &&
!skipBogus &&
!( isStart && node.getNext() ) )
{
skipBogus = true;
}
// If there's any visible text, then we're not at the start.
else if ( node.hasAscendant( 'pre' ) || CKEDITOR.tools.trim( node.getText() ).length )
return false;
}
else if ( node.type == CKEDITOR.NODE_ELEMENT )
{
// If there are non-empty inline elements (e.g. <img />), then we're not
// at the start.
if ( !inlineChildReqElements[ node.getName() ] )
{
// Skip the padding block br.
if ( !CKEDITOR.env.ie &&
node.is( 'br' ) &&
!skipBogus &&
!( isStart && node.getNext() ) )
{
skipBogus = true;
}
else
return false;
}
skipBogus = true;
return true;
}

// If there's any visible text, then we're not at the start.
if ( node.type == CKEDITOR.NODE_TEXT &&
( node.hasAscendant( 'pre' ) ||
CKEDITOR.tools.trim( node.getText() ).length ) )
return false;

// If there are non-empty inline elements (e.g. <img />), then we're not
// at the start.
if ( node.type == CKEDITOR.NODE_ELEMENT && !inlineChildReqElements[ node.getName() ] )
return false;

return true;
};
}
Expand All @@ -401,21 +389,28 @@ CKEDITOR.dom.range = function( document )
// text node and non-empty elements unless it's being bookmark text.
function elementBoundaryEval( checkStart )
{
var whitespaces = CKEDITOR.dom.walker.whitespaces(),
bookmark = CKEDITOR.dom.walker.bookmark( 1 );

return function( node )
{
// First skip empty nodes.
if ( bookmark( node ) || whitespaces( node ) )
return true;

// Tolerant bogus br when checking at the end of block.
// Reject any text node unless it's being bookmark
// OR it's spaces.
// Reject any element unless it's being invisible empty. (#3883)
return !checkStart && isBogus( node ) ||
( node.type == CKEDITOR.NODE_TEXT ?
!CKEDITOR.tools.trim( node.getText() ) || !!node.getParent().data( 'cke-bookmark' )
: node.getName() in CKEDITOR.dtd.$removeEmpty );
node.type == CKEDITOR.NODE_ELEMENT &&
node.getName() in CKEDITOR.dtd.$removeEmpty;
};
}

var whitespaceEval = new CKEDITOR.dom.walker.whitespaces(),
bookmarkEval = new CKEDITOR.dom.walker.bookmark();
bookmarkEval = new CKEDITOR.dom.walker.bookmark(),
nbspRegExp = /^[\t\r\n ]*(?:&nbsp;|\xa0)$/;

function nonWhitespaceOrBookmarkEval( node )
{
Expand Down Expand Up @@ -1834,13 +1829,13 @@ CKEDITOR.dom.range = function( document )
var startContainer = this.startContainer,
startOffset = this.startOffset;

// If the starting node is a text node, and non-empty before the offset,
// then we're surely not at the start of block.
if ( startOffset && startContainer.type == CKEDITOR.NODE_TEXT )
// [IE] Special handling for range start in text with a leading NBSP,
// we it to be isolated, for bogus check.
if ( CKEDITOR.env.ie && startOffset && startContainer.type == CKEDITOR.NODE_TEXT )
{
var textBefore = CKEDITOR.tools.ltrim( startContainer.substring( 0, startOffset ) );
if ( textBefore.length )
return false;
if ( nbspRegExp.test( textBefore ) )
this.trim( 0, 1 );
}

// We need to grab the block element holding the start boundary, so
Expand All @@ -1853,7 +1848,7 @@ CKEDITOR.dom.range = function( document )
walkerRange.setStartAt( path.block || path.blockLimit, CKEDITOR.POSITION_AFTER_START );

var walker = new CKEDITOR.dom.walker( walkerRange );
walker.evaluator = getCheckStartEndBlockEvalFunction( true );
walker.evaluator = getCheckStartEndBlockEvalFunction();

return walker.checkBackward();
},
Expand All @@ -1863,13 +1858,13 @@ CKEDITOR.dom.range = function( document )
var endContainer = this.endContainer,
endOffset = this.endOffset;

// If the ending node is a text node, and non-empty after the offset,
// then we're surely not at the end of block.
if ( endContainer.type == CKEDITOR.NODE_TEXT )
// [IE] Special handling for range end in text with a following NBSP,
// we it to be isolated, for bogus check.
if ( CKEDITOR.env.ie && endContainer.type == CKEDITOR.NODE_TEXT )
{
var textAfter = CKEDITOR.tools.rtrim( endContainer.substring( endOffset ) );
if ( textAfter.length )
return false;
if ( nbspRegExp.test( textAfter ) )
this.trim( 1, 0 );
}

// We need to grab the block element holding the start boundary, so
Expand All @@ -1882,15 +1877,53 @@ CKEDITOR.dom.range = function( document )
walkerRange.setEndAt( path.block || path.blockLimit, CKEDITOR.POSITION_BEFORE_END );

var walker = new CKEDITOR.dom.walker( walkerRange );
walker.evaluator = getCheckStartEndBlockEvalFunction( false );
walker.evaluator = getCheckStartEndBlockEvalFunction();

return walker.checkForward();
},

/**
* Check if elements at which the range boundaries anchor are read-only,
* with respect to "contenteditable" attribute.
* Traverse with {@link CKEDITOR.dom.walker} to retrieve the previous element before the range start.
* @param {Function} evaluator Function used as the walker's evaluator.
* @param {Function} [guard] Function used as the walker's guard.
* @param {CKEDITOR.dom.element} [boundary] A range ancestor element in which the traversal is limited,
* default to the root editable if not defined.
*
* @return {CKEDITOR.dom.element|null} The returned node from the traversal.
*/
getPreviousNode : function( evaluator, guard, boundary ) {

var walkerRange = this.clone();
walkerRange.collapse( 1 );
walkerRange.setStartAt( boundary || this.document.getBody(), CKEDITOR.POSITION_AFTER_START );

var walker = new CKEDITOR.dom.walker( walkerRange );
walker.evaluator = evaluator;
walker.guard = guard;
return walker.previous();
},

/**
* Traverse with {@link CKEDITOR.dom.walker} to retrieve the next element before the range start.
* @param {Function} evaluator Function used as the walker's evaluator.
* @param {Function} [guard] Function used as the walker's guard.
* @param {CKEDITOR.dom.element} [boundary] A range ancestor element in which the traversal is limited,
* default to the root editable if not defined.
*
* @return {CKEDITOR.dom.element|null} The returned node from the traversal.
*/
getNextNode: function( evaluator, guard, boundary )
{
var walkerRange = this.clone();
walkerRange.collapse();
walkerRange.setEndAt( boundary || this.document.getBody(), CKEDITOR.POSITION_BEFORE_END );

var walker = new CKEDITOR.dom.walker( walkerRange );
walker.evaluator = evaluator;
walker.guard = guard;
return walker.next();
},

checkReadOnly : ( function()
{
function checkNodesEditable( node, anotherEnd )
Expand Down Expand Up @@ -1939,8 +1972,6 @@ CKEDITOR.dom.range = function( document )
*/
moveToElementEditablePosition : function( el, isMoveToEnd )
{
var nbspRegExp = /^[\t\r\n ]*(?:&nbsp;|\xa0)$/;

function nextDFS( node, childOnly )
{
var next;
Expand Down
36 changes: 27 additions & 9 deletions third_party/ckeditor/_source/core/dom/walker.js
Expand Up @@ -413,8 +413,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
return function( node )
{
var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT )
&& !CKEDITOR.tools.trim( node.getText() );
var isWhitespace;
if ( node && node.type == CKEDITOR.NODE_TEXT )
{
// whitespace, as well as the text cursor filler node we used in Webkit. (#9384)
isWhitespace = !CKEDITOR.tools.trim( node.getText() ) ||
CKEDITOR.env.webkit && node.getText() == '\u200b';
}

return !! ( isReject ^ isWhitespace );
};
};
Expand All @@ -428,13 +434,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var whitespace = CKEDITOR.dom.walker.whitespaces();
return function( node )
{
// Nodes that take no spaces in wysiwyg:
// 1. White-spaces but not including NBSP;
// 2. Empty inline elements, e.g. <b></b> we're checking here
// 'offsetHeight' instead of 'offsetWidth' for properly excluding
// all sorts of empty paragraph, e.g. <br />.
var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight;
return !! ( isReject ^ isInvisible );
var invisible;

if ( whitespace( node ) )
invisible = 1;
else
{
// Visibility should be checked on element.
if ( node.type == CKEDITOR.NODE_TEXT )
node = node.getParent();

// Nodes that take no spaces in wysiwyg:
// 1. White-spaces but not including NBSP;
// 2. Empty inline elements, e.g. <b></b> we're checking here
// 'offsetHeight' instead of 'offsetWidth' for properly excluding
// all sorts of empty paragraph, e.g. <br />.
invisible = !node.$.offsetHeight;
}

return !! ( isReject ^ invisible );
};
};

Expand Down
Expand Up @@ -13,12 +13,14 @@ fr.js Found: 30 Missing: 0
gu.js Found: 12 Missing: 18
he.js Found: 30 Missing: 0
it.js Found: 30 Missing: 0
ku.js Found: 30 Missing: 0
mk.js Found: 5 Missing: 25
nb.js Found: 30 Missing: 0
nl.js Found: 30 Missing: 0
no.js Found: 30 Missing: 0
pt-br.js Found: 30 Missing: 0
ro.js Found: 6 Missing: 24
sk.js Found: 30 Missing: 0
tr.js Found: 30 Missing: 0
ug.js Found: 27 Missing: 3
vi.js Found: 6 Missing: 24
Expand Down

0 comments on commit 1cefb42

Please sign in to comment.