Skip to content
Permalink
Browse files

Merge branch 't/11461' into major

  • Loading branch information...
Reinmar committed Jan 28, 2015
2 parents ab14440 + 390675e commit 51f9bf0ca8efb415ffd2c33cc9db91f40fe56f95
@@ -20,6 +20,7 @@ New Features:
* [#11905](http://dev.ckeditor.com/ticket/11905): [`resize` event](http://docs.ckeditor.dev/#!/api/CKEDITOR.editor-event-resize) pass dimensions in data.
* [#12126](http://dev.ckeditor.com/ticket/12126): Introduced [`image_prefillDimensions`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-image_prefillDimensions) and [`image2_prefillDimensions`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-image2_prefillDimensions) to make pre-filling 'width' and 'height' configurable.
* [#11580](http://dev.ckeditor.com/ticket/11580): Introduced the [notifications system](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.notification).
* [#11461](http://dev.ckeditor.com/ticket/11461): Introduced support for uploading pasted and dropped images with architecture for handling other types.

Fixed Issues:

@@ -776,32 +776,33 @@ CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, {
* element.isReadOnly(); // true
*
* @since 3.5
* @param {Boolean} [checkOnlyAttributes=false] If `true` only attributes will be checked, native methods will not
* be used. This parameter needs to be `true` to check hidden or detached elements. Note that root element
* should have `data-cke-editable` attribute if testing node should be not read only by default.
* @returns {Boolean}
*/
isReadOnly: function() {
isReadOnly: function( checkOnlyAttributes ) {
var element = this;
if ( this.type != CKEDITOR.NODE_ELEMENT )
element = this.getParent();

if ( element && typeof element.$.isContentEditable != 'undefined' )
if ( !checkOnlyAttributes && element && typeof element.$.isContentEditable != 'undefined' )
return !( element.$.isContentEditable || element.data( 'cke-editable' ) );
else {
// Degrade for old browsers which don't support "isContentEditable", e.g. FF3

while ( element ) {
if ( element.data( 'cke-editable' ) )
break;

if ( element.getAttribute( 'contentEditable' ) == 'false' )
return true;
else if ( element.getAttribute( 'contentEditable' ) == 'true' )
break;
if ( element.data( 'cke-editable' ) ) {
return false;
} else if ( element.hasAttribute( 'contenteditable' ) ) {
return element.getAttribute( 'contenteditable' ) == 'false';
}

element = element.getParent();
}

// Reached the root of DOM tree, no editable found.
return !element;
return true;
}
}
} );
@@ -2087,15 +2087,28 @@
* @returns {CKEDITOR.dom.selection} This selection object, after the ranges were selected.
*/
selectBookmarks: function( bookmarks ) {
var ranges = [];
var ranges = [],
node;

for ( var i = 0; i < bookmarks.length; i++ ) {
var range = new CKEDITOR.dom.range( this.root );
range.moveToBookmark( bookmarks[ i ] );
ranges.push( range );
}

// It may happen that the content change during loading, before selection is set so bookmark leads to text node.
if ( bookmarks.isFake ) {
node = ranges[ 0 ].getEnclosedNode();
if ( node && node.type != CKEDITOR.NODE_ELEMENT ) {
// %REMOVE_START%
window.console && console.log( 'Selection is no longer fake.' ); // jshint ignore:line
// %REMOVE_END%
bookmarks.isFake = 0;
}
}

if ( bookmarks.isFake )
this.fake( ranges[ 0 ].getEnclosedNode() );
this.fake( node );
else
this.selectRanges( ranges );

@@ -1,5 +1,3 @@
/* global alert */

/**
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
@@ -249,7 +247,7 @@
// Strip presentional markup & unify text markup.
else if ( type == 'text' && trueType == 'html' ) {
// Init filter only if needed and cache it.
data = htmlTextification( editor.config, data, textificationFilter || ( textificationFilter = getTextificationFilter( editor ) ) );
data = htmlTextification( editor.config, data, textificationFilter || ( textificationFilter = getTextificationFilter() ) );
}

if ( dataObj.startsWithEOL )
@@ -638,7 +636,8 @@
var success = tryToCutCopy( this.type );

if ( !success ) {
alert( editor.lang.clipboard[ this.type + 'Error' ] ); // Show cutError or copyError.
// Show cutError or copyError.
alert( editor.lang.clipboard[ this.type + 'Error' ] ); // jshint ignore:line
}

return success;
@@ -715,7 +714,11 @@
body.on( command, onExec );

// IE7: document.execCommand has problem to paste into positioned element.
( CKEDITOR.env.version > 7 ? doc.$ : doc.$.selection.createRange() ).execCommand( command );
if ( CKEDITOR.env.version > 7 ) {
doc.$.execCommand( command );
} else {
doc.$.selection.createRange().execCommand( command );
}

body.removeListener( command, onExec );

@@ -989,7 +992,7 @@
},
// True if we can fully rely on data from dataTransfer, this means that
// if HTML is available via native paste it is also available via getData.
htmlAlwaysInDataTransfer = CKEDITOR.env.chrome || CKEDITOR.env.gecko;
htmlAlwaysInDataTransfer = CKEDITOR.env.chrome;

eventData.dataTransfer.cacheData();

@@ -1138,7 +1141,6 @@
return switchEnterMode( config, data );
}

// Filter can be editor dependent.
function getTextificationFilter() {
var filter = new CKEDITOR.htmlParser.filter();

@@ -1448,6 +1450,11 @@
dropRange.select();

firePasteEvents( editor, { dataTransfer: dataTransfer, method: 'drop' }, 1 );

// Usually we reset DataTranfer on dragend,
// but dragend is called on the same element as dragstart
// so it will not be called on on external drop.
clipboard.resetDragDataTransfer();
}

// Fire drag/drop events (dragstart, dragend, drop).
@@ -1651,10 +1658,12 @@
range.collapse( true );
}
// IEs 9+.
else if ( CKEDITOR.env.ie && CKEDITOR.env.version > 8 )
else if ( CKEDITOR.env.ie && CKEDITOR.env.version > 8 && defaultRange ) {
// On IE 9+ range by default is where we expected it.
// defaultRange may be undefined if dragover was canceled (file drop).
return defaultRange;
// IE 8.
}
// IE 8 and all IEs if !defaultRange.
else if ( document.body.createTextRange ) {
$range = editor.document.getBody().$.createTextRange();
try {
@@ -2040,6 +2049,13 @@
data = result[ 1 ];
}
}
// Firefox on Linux put files paths as a text/plain data if there are files
// in the dataTransfer object. We need to hide it, because files should be
// handled on paste only if dataValue is empty.
else if ( type == 'Text' && CKEDITOR.env.gecko && this.getFilesCount() &&
data.substring( 0, 7 ) == 'file://' ) {
data = '';
}

return data;
},
@@ -2084,11 +2100,12 @@
},

/**
* Copy data from native data transfer to custom array.
* This function is needed, because data from native dataTransfer
* are available only in the event, it is not possible to get them
* after timeout, and clipboard plugin fires paste event after
* a timeout in some cases.
* Copies a data from the native data transfer to a private cache.
* This function is needed because the data from native the data transfer
* is available only by the event. It is not possible to get the data from after a timeout
* but the `clipboard` plugin fires the {@link CKEDITOR.editor#paste} event asynchronously.
* Therefore, this method is executed so the data can be retrieved at any point of the
* pasting process.
*/
cacheData: function() {
if ( !this.$ ) {
@@ -2129,6 +2146,11 @@
}
},

/**
* Get count of files in dataTransfer object.
*
* @returns {Number} Count of files.
*/
getFilesCount: function() {
if ( this._.files.length ) {
return this._.files.length;
@@ -2141,6 +2163,12 @@
return 0;
},

/**
* Get file of given index.
*
* @param {Number} i Index.
* @returns {File} File instance.
*/
getFile: function( i ) {
if ( this._.files.length ) {
return this._.files[ i ];
@@ -0,0 +1,45 @@
/**
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/

'use strict';

// Slow down the upload process.
// This trick works only on Chrome.

( function() {
XMLHttpRequest.prototype.baseSend = XMLHttpRequest.prototype.send;

XMLHttpRequest.prototype.send = function( data ) {
var baseOnProgress = this.onprogress,
baseOnLoad = this.onload;

this.onprogress = function() {};

this.onload = function( evt ) {
// Total file size.
var total = 1000 * 10,
loaded = 0;

function progress() {
setTimeout( function() {
// Load 1000 bytes every 300 milliseconds.
loaded += 1000;

if ( loaded < total ) {
evt.loaded = loaded;
baseOnProgress( evt );
progress();
} else {
baseOnLoad( evt );
}
}, 300 );
}

progress();
};

this.baseSend( data );
};
} )();
@@ -0,0 +1,13 @@
/**
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang( 'filetools', 'en', {
loadError: 'Error occurred during file reading.',
networkError: 'Network error occurred during file uploading.',
httpError404: 'HTTP error occurred during file uploading (404: file not found).',
httpError403: 'HTTP error occurred during file uploading (403: Forbidden).',
httpError: 'HTTP error occurred during file uploading (error status: %1).',
noUrlError: 'Upload URL is not defined.',
responseError: 'Incorrect server response format: %1'
} );

0 comments on commit 51f9bf0

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