Skip to content
Permalink
Browse files

Merge branch 't/13872'

  • Loading branch information...
mlewand committed Nov 4, 2015
2 parents 0f7494b + eb8a56c commit 48311f85728398dd4b616b240292cffed6ec9d15
@@ -12,6 +12,7 @@ Fixed Issues:
* [#13887](https://dev.ckeditor.com/ticket/13887): Fixed: Link target now supports wider ASCII character range. Thanks to [SamZiemer](https://github.com/SamZiemer)!
* [#13790](https://dev.ckeditor.com/ticket/13790): Fixed: Allow for the iframe having been removed already. Thanks to [Stefan Rijnhart](https://github.com/StefanRijnhart)!
* [#13803](https://dev.ckeditor.com/ticket/13803): Fixed: Allow the editor to be destroyed before being fully initialized. Thanks to [Cyril Fluck](https://github.com/cyril-sf)!
* [#13872](http://dev.ckeditor.com/ticket/13872): Fixed: Cut is no longer possible in [read-only](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-property-readOnly) mode.
* [#13879](http://dev.ckeditor.com/ticket/13879): Fixed: Preventing [`editor.drop`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-drop) event.
* [#12848](http://dev.ckeditor.com/ticket/12848): Fixed: Opening find dialog in [read-only](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-property-readOnly) mode will no longer throw an exception.
* [#12189](http://dev.ckeditor.com/ticket/12189): Fixed: Link plugin dialog does not display subject of email links if subject parameter is not lowercase.
@@ -525,7 +525,10 @@

if ( CKEDITOR.plugins.clipboard.isCustomCopyCutSupported ) {
var initOnCopyCut = function( evt ) {
clipboard.initPasteDataTransfer( evt, editor );
// If user tries to cut in read-only editor, we must prevent default action. (#13872)
if ( !editor.readOnly || evt.name != 'cut' ) {
clipboard.initPasteDataTransfer( evt, editor );
}
evt.data.preventDefault();
};

@@ -534,7 +537,10 @@

// Delete content with the low priority so one can overwrite cut data.
editable.on( 'cut', function() {
editor.extractSelectedHtml();
// If user tries to cut in read-only editor, we must prevent default action. (#13872)
if ( !editor.readOnly ) {
editor.extractSelectedHtml();
}
}, null, null, 999 );
}

@@ -0,0 +1,17 @@
<body>
<div>
<textarea></textarea>
</div>
<div id="classic">
<p>Example text</p>
</div>

<div id="inline">
<p>Example text</p>
</div>

<script>
CKEDITOR.replace( 'classic', { readOnly: true } );
CKEDITOR.inline( 'inline', { readOnly: true } );
</script>
</body>
@@ -0,0 +1,23 @@
@bender-tags: tc, 4.5.5, 13782, editor
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, clipboard, toolbar, floatingspace

----

1. Select some text in the first editor.
2. Press `CTRL + X`.
3. Try to paste into the textarea above the editors.

**Expected:**
* Text shouldn't be removed from editor.
* Text selected in the editor shouldn't be pasted into the textarea.

----

1. Select some text in the second editor.
2. Press `CTRL + X`.
3. Try to paste into the textarea above the editors.

**Expected:**
* Text shouldn't be removed from editor.
* Text selected in the editor shouldn't be pasted into the textarea.
@@ -0,0 +1,61 @@
/* bender-tags: editor, clipboard, 13872 */
/* bender-ckeditor-plugins: toolbar, clipboard */

'use strict';

bender.editors = {
classic: {
config: {
readOnly: true
}
},
classic_editable: {},
inline: {
creator: 'inline',
config: {
readOnly: true
}
},
inline_editable: {
creator: 'inline'
}
};

var tests = {
setUp: function() {
// The native handling of copy/cut doesn't have such problems.
if ( !CKEDITOR.plugins.clipboard.isCustomCopyCutSupported ) {
assert.ignore();
}

this.initPasteSpy = sinon.spy( CKEDITOR.plugins.clipboard, 'initPasteDataTransfer' );
},

tearDown: function() {
this.initPasteSpy.restore();
},

'test if cut is prevented depending on read-only mode': function( editor, bot ) {
var content = '<p>[Some] text</p>',
expected = editor.readOnly ? content : '<p>^ text</p>';

bot.setHtmlWithSelection( content );

editor.editable().fire( 'cut', new CKEDITOR.dom.event( {} ) );

assert.areSame( expected, bot.htmlWithSelection() );
assert.areSame( !editor.readOnly, CKEDITOR.plugins.clipboard.initPasteDataTransfer.called, 'initPasteDataTransfer call' );
},

'test copy depending on read-only mode': function( editor, bot ) {
bot.setHtmlWithSelection( '<p>[Some] text</p>' );

editor.editable().fire( 'copy', new CKEDITOR.dom.event( {} ) );

assert.areSame( true, CKEDITOR.plugins.clipboard.initPasteDataTransfer.called, 'initPasteDataTransfer call' );
}
};

tests = bender.tools.createTestsForEditors( CKEDITOR.tools.objectKeys( bender.editors ), tests );

bender.test( tests );

0 comments on commit 48311f8

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