Skip to content

Commit

Permalink
Merge pull request #757 from ckeditor/t/719
Browse files Browse the repository at this point in the history
T/719 Image could be resized in read-only mode
  • Loading branch information
Comandeer authored Aug 29, 2017
2 parents a3483c3 + 1ad3317 commit 51c188c
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Fixed Issues:
* [#566](https://github.com/ckeditor/ckeditor-dev/issues/566): Fixed: The CSS border shorthand property with zero width (`border: 0px solid #000;`) no longer causes table to have border attribute set to 1.
* [#779](https://github.com/ckeditor/ckeditor-dev/issues/779): Fixed: [Remove Format](https://ckeditor.com/addon/removeformat) plugin removes elements with language definition inserted by [Language](https://ckeditor.com/addon/language) plugin.
* [#423](https://github.com/ckeditor/ckeditor-dev/issues/423): Fixed: [Paste from Word](https://ckeditor.com/addon/pastefromword) plugin pastes paragraphs into the editor even if [`CKEDITOR.config.enterMode`](https://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode) is set to `CKEDITOR.ENTER_BR`.
* [#719](https://github.com/ckeditor/ckeditor-dev/issues/719): Fixed: Image inserted using [Enhanced Image](https://ckeditor.com/addon/image2) plugin could be resized when editor is in read-only mode.

## CKEditor 4.7.2

Expand Down
4 changes: 3 additions & 1 deletion plugins/image2/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,10 @@

// Setup dynamic image resizing with mouse.
// Don't initialize resizer when dimensions are disallowed (http://dev.ckeditor.com/ticket/11004).
if ( editor.filter.checkFeature( this.features.dimension ) && editor.config.image2_disableResizer !== true )
// Don't initialize resizer when editor.readOnly is set to true (#719).
if ( editor.filter.checkFeature( this.features.dimension ) && editor.config.image2_disableResizer !== true && editor.readOnly != true ) {
setupResizer( this );
}

this.shiftState = helpers.stateShifter( this.editor );

Expand Down
13 changes: 13 additions & 0 deletions tests/plugins/image2/manual/resizerwithreadonly.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div id="editor1" contenteditable="true">
<img src="%BASE_PATH%/_assets/logo.png" />
</div>
<div id="editor2" contenteditable="true">
<img src="%BASE_PATH%/_assets/logo.png" />
</div>

<script>
CKEDITOR.replace( 'editor1' );
CKEDITOR.replace( 'editor2', {
readOnly: true
} );
</script>
5 changes: 5 additions & 0 deletions tests/plugins/image2/manual/resizerwithreadonly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@bender-tags: 4.7.3, bug, 719
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, image2

Only **first** editor should have enabled mouse resizer on image.
54 changes: 54 additions & 0 deletions tests/plugins/image2/resizerwithreadonly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* bender-tags: editor,widget */
/* bender-ckeditor-plugins: image2,toolbar */

( function() {
'use strict';

bender.test( {
// #719
'test readOnly set to false': function() {
bender.editorBot.create( {
name: 'editor1',
config: {
language: 'en'
}
}, function( bot ) {
var editor = bot.editor;

bot.dialog( 'image', function( dialog ) {
dialog.setValueOf( 'info', 'src', '_assets/foo.png' );
dialog.getButton( 'ok' ).click();

assert.sameData(
'cke_image_resizer',
editor.editable().getElementsByTag( 'span' ).$[ 2 ].outerHTML.match( /(cke_image_resizer)/g )[ 0 ]
);
} );
} );
},

// #719
'test readOnly set to true': function() {
bender.editorBot.create( {
name: 'editor2',
config: {
readOnly: true
}
}, function( bot ) {
var editor = bot.editor,
listener;

listener = editor.on( 'dataReady', function() {
listener.removeListener();

resume( function() {
assert.areSame( 2, editor.editable().getElementsByTag( 'span' ).$.length );
} );
} );

editor.setData( '<img src="_assets/foo.png" alt="" />' );
wait();
} );
}
} );
}() );

0 comments on commit 51c188c

Please sign in to comment.