Skip to content
Permalink
Browse files

Merge branch 't/13040' into major

  • Loading branch information...
Reinmar committed Apr 8, 2015
2 parents 0c92f25 + 4764a7e commit 293d637ab593f0859d7a17937be65d6cee385cac
@@ -239,16 +239,16 @@ var CKCONSOLE = ( function() {
*
* or (with observed types):
*
* CKCONSOLE.addEventPanel( 'drop', [ 'nativeEvent', 'target' ] );
* CKCONSOLE.addEventPanel( 'drop', [ '$', 'target' ] );
* CKCONSOLE.create( 'drop', { editor: 'inline' } );
*
* or (with observed types mapping):
*
* CKCONSOLE.addEventPanel( 'drop',
* [ 'nativeEvent', 'target' ],
* [ '$', 'target' ],
* function( evt ) {
* return {
* 'nativeEvent': evt.data.nativeEvent,
* '$': evt.data.$,
* 'target': evt.data.target
* };
* }
@@ -166,10 +166,10 @@ <h2>Technical details <a id="tech-details" name="tech-details"></a></h2>
CKEDITOR.replace( 'classic' );
CKEDITOR.inline( 'inline' );
CKCONSOLE.addEventPanel( 'dragstart', [ 'nativeEvent', 'target', 'dataTransfer' ] );
CKCONSOLE.addEventPanel( 'dragend', [ 'nativeEvent', 'target', 'dataTransfer' ] );
CKCONSOLE.addEventPanel( 'dragstart', [ '$', 'target', 'dataTransfer' ] );
CKCONSOLE.addEventPanel( 'dragend', [ '$', 'target', 'dataTransfer' ] );
CKCONSOLE.addEventPanel( 'drop',
[ 'nativeEvent', 'target', 'dataTransfer', 'dragRange', 'dropRange' ] );
[ '$', 'target', 'dataTransfer', 'dragRange', 'dropRange' ] );
CKCONSOLE.create( 'dragstart', { editor: 'classic' } );
CKCONSOLE.create( 'drop', { editor: 'classic' } );
@@ -11,30 +11,36 @@
//
// COPY & PASTE EXECUTION FLOWS:
// -- CTRL+C
// * browser's default behaviour
// * if ( isDataFreelyAvailableInPasteEvent )
// * dataTransfer.setData( 'text/html', getSelectedHtml )
// * else
// * browser's default behavior
// -- CTRL+X
// * listen onKey (onkeydown)
// * fire 'saveSnapshot' on editor
// * if ( isDataFreelyAvailableInPasteEvent )
// * dataTransfer.setData( 'text/html', getSelectedHtml )
// * extractSelectedHtml // remove selected contents
// * else
// * browser's default behavior
// * deferred second 'saveSnapshot' event
// -- CTRL+V
// * listen onKey (onkeydown)
// * simulate 'beforepaste' for non-IEs on editable
// * simulate 'paste' for Fx2/Opera on editable
// * listen 'onpaste' on editable ('onbeforepaste' for IE)
// * fire 'beforePaste' on editor
// * !canceled && getClipboardDataByPastebin
// * if ( !canceled && !dataTransfer.getData( 'text/html' ) && !htmlAlwaysInDataTransfer ) getClipboardDataByPastebin
// * fire 'paste' on editor
// * !canceled && fire 'afterPaste' on editor
// -- CTRL+X
// * listen onKey (onkeydown)
// * fire 'saveSnapshot' on editor
// * browser's default behaviour
// * deferred second 'saveSnapshot' event
// -- Copy command
// * tryToCutCopy
// * execCommand
// * !success && alert
// * !success && notification
// -- Cut command
// * fixCut
// * tryToCutCopy
// * execCommand
// * !success && alert
// * !success && notification
// -- Paste command
// * fire 'paste' on editable ('beforepaste' for IE)
// * !canceled && execCommand 'paste'
@@ -46,7 +52,7 @@
// * listen 'onpaste'
// * cancel native event
// * fire 'beforePaste' on editor
// * !canceled && getClipboardDataByPastebin
// * if ( !canceled && !dataTransfer.getData( 'text/html' ) && !htmlAlwaysInDataTransfer ) getClipboardDataByPastebin
// * execIECommand( 'paste' ) -> this fires another 'paste' event, so cancel it
// * fire 'paste' on editor
// * !canceled && fire 'afterPaste' on editor
@@ -73,6 +79,7 @@
// * content: html -> filter
//
// -- Phases:
// * if dataValue is empty copy data from dataTransfer to dataValue (priority 1)
// * filtering (priorities 3-5) - e.g. pastefromword filters
// * content type sniffing (priority 6)
// * markup transformations for text (priority 6)
@@ -91,7 +98,7 @@
// * getRangeAtDropPosition
// * create bookmarks for drag and drop ranges starting from the end of the document
// * dragRange.deleteContents()
// * fire 'paste' with saved html
// * fire 'paste' with saved html and drop range
// * if events text == saved timestamp && editor != saved editor
// cross editor drag & drop occurred
// * getRangeAtDropPosition
@@ -139,6 +146,11 @@
CKEDITOR.dialog.add( 'paste', CKEDITOR.getUrl( this.path + 'dialogs/paste.js' ) );

editor.on( 'paste', function( evt ) {
// Init `dataTransfer` if `paste` event was fired without it, so it will be always available.
if ( !evt.data.dataTransfer ) {
evt.data.dataTransfer = new CKEDITOR.plugins.clipboard.dataTransfer();
}

// If dataValue is already set do not override it.
if ( evt.data.dataValue ) {
return;
@@ -248,9 +260,7 @@
trueType,
// Default is 'html'.
defaultType = editor.config.clipboard_defaultContentType || 'html',
transferType = dataObj.dataTransfer && dataObj.dataTransfer.getTransferType( editor ),
// Treat pasting without dataTransfer as external.
external = !transferType || ( transferType == CKEDITOR.DATA_TRANSFER_EXTERNAL );
transferType = dataObj.dataTransfer.getTransferType( editor );

// If forced type is 'html' we don't need to know true data type.
if ( type == 'html' || dataObj.preSniffing == 'html' ) {
@@ -273,7 +283,7 @@
data = filterContent( editor, data, filtersFactory.get( 'plain-text' ) );
}
// External paste and pasteFilter exists and filtering isn't disabled.
else if ( external && editor.pasteFilter && !dataObj.dontFilter ) {
else if ( transferType == CKEDITOR.DATA_TRANSFER_EXTERNAL && editor.pasteFilter && !dataObj.dontFilter ) {
data = filterContent( editor, data, editor.pasteFilter );
}

@@ -1448,7 +1458,7 @@
// Fire drag/drop events (dragstart, dragend, drop).
function fireDragEvent( evt, dragRange, dropRange ) {
var eventData = {
nativeEvent: evt.data.$,
$: evt.data.$,
target: evt.data.getTarget()
};

@@ -1784,7 +1794,7 @@
// Create a new dataTransfer object based on the drop event.
// If this event was used on dragstart to create dataTransfer
// both dataTransfer objects will have the same id.
var nativeDataTransfer = evt.data.nativeEvent ? evt.data.nativeEvent.dataTransfer : null,
var nativeDataTransfer = evt.data.$ ? evt.data.$.dataTransfer : null,
dataTransfer = new this.dataTransfer( nativeDataTransfer, sourceEditor );

if ( !nativeDataTransfer ) {
@@ -2350,7 +2360,7 @@
* @member CKEDITOR.editor
* @param {CKEDITOR.editor} editor This editor instance.
* @param data
* @param {Object} data.nativeEvent Native drop event.
* @param {Object} data.$ Native drop event.
* @param {CKEDITOR.dom.node} data.target Drop target.
* @param {CKEDITOR.plugins.clipboard.dataTransfer} data.dataTransfer DataTransfer facade.
* @param {CKEDITOR.dom.range} data.dragRange Drag range, let you manipulate with drag range.
@@ -2370,7 +2380,7 @@
* @member CKEDITOR.editor
* @param {CKEDITOR.editor} editor This editor instance.
* @param data
* @param {Object} data.nativeEvent Native dragstart event.
* @param {Object} data.$ Native dragstart event.
* @param {CKEDITOR.dom.node} data.target Drag target.
* @param {CKEDITOR.plugins.clipboard.dataTransfer} data.dataTransfer DataTransfer facade.
*/
@@ -2386,7 +2396,7 @@
* @member CKEDITOR.editor
* @param {CKEDITOR.editor} editor This editor instance.
* @param data
* @param {Object} data.nativeEvent Native dragend event.
* @param {Object} data.$ Native dragend event.
* @param {CKEDITOR.dom.node} data.target Drag target.
* @param {CKEDITOR.plugins.clipboard.dataTransfer} data.dataTransfer DataTransfer facade.
*/
@@ -648,9 +648,9 @@ bender.test( {
'test initDragDataTransfer binding': function() {
var nativeData1 = bender.tools.mockNativeDataTransfer(),
nativeData2 = bender.tools.mockNativeDataTransfer(),
evt1a = { data: { nativeEvent: { dataTransfer: nativeData1 } } },
evt1b = { data: { nativeEvent: { dataTransfer: nativeData1 } } },
evt2 = { data: { nativeEvent: { dataTransfer: nativeData2 } } };
evt1a = { data: { $: { dataTransfer: nativeData1 } } },
evt1b = { data: { $: { dataTransfer: nativeData1 } } },
evt2 = { data: { $: { dataTransfer: nativeData2 } } };

CKEDITOR.plugins.clipboard.initDragDataTransfer( evt1a );
CKEDITOR.plugins.clipboard.initDragDataTransfer( evt1b );
@@ -688,7 +688,7 @@ bender.test( {
bot.setHtmlWithSelection( '<p>x[x<b>foo</b>x]x</p>' );

var nativeData = bender.tools.mockNativeDataTransfer(),
evt = { data: { nativeEvent: { dataTransfer: nativeData } } };
evt = { data: { $: { dataTransfer: nativeData } } };

CKEDITOR.plugins.clipboard.initDragDataTransfer( evt, editor );

@@ -26,7 +26,7 @@ function drag( editor, evt ) {
dragEventCounter++;

assert.isInstanceOf( CKEDITOR.plugins.clipboard.dataTransfer, dragEvt.data.dataTransfer );
assert.areSame( evt.$, dragEvt.data.nativeEvent );
assert.areSame( evt.$, dragEvt.data.$ );
assert.areSame( 'targetMock', dragEvt.data.target.$ );
} );

@@ -64,7 +64,7 @@ function drop( editor, evt, config, onDrop, onFinish ) {
values.dropRangeStartContainerMatch = config.element == dropEvt.data.dropRange.startContainer;
values.dropRangeStartOffsetMatch = config.offset == dropEvt.data.dropRange.startOffset;
}
values.dropNativeEventMatch = evt.$ == dropEvt.data.nativeEvent;
values.dropNativeEventMatch = evt.$ == dropEvt.data.$;
values.dropTarget = dropEvt.data.target.$;

if ( onDrop ) {
@@ -720,7 +720,7 @@ var testsForMultipleEditor = {
dragendCount++;

assert.areSame( 'foo', dragendEvt.data.dataTransfer.getData( 'Text' ), 'cke/custom' );
assert.areSame( evt.data.$, dragendEvt.data.nativeEvent, 'nativeEvent' );
assert.areSame( evt.data.$, dragendEvt.data.$, 'nativeEvent' );
assert.areSame( 'targetMock', dragendEvt.data.target.$, 'target' );
} );

@@ -24,8 +24,7 @@
type: 'auto',
// This data will be recognized as pasted from Word.
dataValue: '<p>fail <strong class="MsoNormal">fail</strong></p>',
method: 'paste',
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer()
method: 'paste'
} );

wait();
@@ -43,8 +43,7 @@
type: 'auto',
// This data will be recognized as pasted from Word.
dataValue: '<p>text <strong class="MsoNormal">text</strong></p>',
method: 'paste',
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer()
method: 'paste'
} );

wait();
@@ -145,8 +144,7 @@
type: 'auto',
// This data will be recognized as pasted from Word.
dataValue: '<p>text <strong class="MsoNormal">text</strong></p>',
method: 'paste',
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer()
method: 'paste'
} );

wait();
@@ -243,7 +243,6 @@
} );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue: '<img src="' + bender.tools.pngBase64 + '">'
} );

@@ -269,7 +268,6 @@
} );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue: '<div>x<img src="' + bender.tools.pngBase64 + '">x' +
'<p>x<img src="' + bender.tools.pngBase64 + '">x</p></div>'
} );
@@ -288,7 +286,6 @@
} );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue: 'foo'
} );

@@ -309,7 +306,6 @@
} );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue: '<img src="' + IMG_URL + '">'
} );

@@ -334,7 +330,6 @@
uploads.create( bender.tools.getTestPngFile() );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue: '<img src="' + bender.tools.pngBase64 + '" data-widget="uploadimage" data-cke-upload-id="0">'
} );

@@ -355,11 +350,10 @@
} );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue:
'<div contentEditable="false">' +
'<img src="' + bender.tools.pngBase64 + '">' +
'</div>'
'<div contentEditable="false">' +
'<img src="' + bender.tools.pngBase64 + '">' +
'</div>'
} );

wait();
@@ -379,13 +373,12 @@
} );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue:
'<div contentEditable="false">' +
'<div contentEditable="true">' +
'<img src="' + bender.tools.pngBase64 + '">' +
'</div>' +
'</div>'
'<div contentEditable="false">' +
'<div contentEditable="true">' +
'<img src="' + bender.tools.pngBase64 + '">' +
'</div>' +
'</div>'
} );

wait();
@@ -405,13 +398,12 @@
} );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue:
'<div contentEditable="false">' +
'<div data-cke-editable="1">' +
'<img src="' + bender.tools.pngBase64 + '">' +
'</div>' +
'</div>'
'<div contentEditable="false">' +
'<div data-cke-editable="1">' +
'<img src="' + bender.tools.pngBase64 + '">' +
'</div>' +
'</div>'
} );

wait();
@@ -430,7 +422,6 @@
} );

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue: '<img src="' + bender.tools.pngBase64 + '">'
} );

@@ -443,7 +434,6 @@
window.attacked = sinon.spy();

editor.fire( 'paste', {
dataTransfer: new CKEDITOR.plugins.clipboard.dataTransfer(),
dataValue: '<img src="x" onerror="window.attacked();">' + bender.tools.pngBase64
} );

0 comments on commit 293d637

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