Skip to content

Commit

Permalink
Merge pull request #822 from ckeditor/t/817
Browse files Browse the repository at this point in the history
save support in source mode
  • Loading branch information
Comandeer authored Sep 6, 2017
2 parents 872b405 + 2c0fd8a commit 141fd23
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Fixed Issues:
* [#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.
* [#577](https://github.com/ckeditor/ckeditor-dev/issues/577): Fixed: "Delete Columns" command provided by [Table Tools](https://ckeditor.com/addon/tabletools) plugin throws an error while trying to delete columns.
* [#867](https://github.com/ckeditor/ckeditor-dev/issues/867): Fixed: Typing into selected table throws an error.
* [#817](https://github.com/ckeditor/ckeditor-dev/issues/817): Fixed: [Save](https://ckeditor.com/addon/save) plugin does not work in [Source Mode](https://ckeditor.com/addon/sourcearea).

Other Changes:

Expand Down
3 changes: 2 additions & 1 deletion plugins/save/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
( function() {
var saveCmd = {
readOnly: 1,
modes: { wysiwyg: 1,source: 1 },

exec: function( editor ) {
if ( editor.fire( 'save' ) ) {
Expand Down Expand Up @@ -45,7 +46,7 @@
return;

var command = editor.addCommand( pluginName, saveCmd );
command.modes = { wysiwyg: !!( editor.element.$.form ) };
command.startDisabled = !( editor.element.$.form );

editor.ui.addButton && editor.ui.addButton( 'Save', {
label: editor.lang.save.toolbar,
Expand Down
9 changes: 9 additions & 0 deletions tests/plugins/save/manual/sourcemode.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<form>
<textarea id="editor1">editor</textarea>
</form>

<script>
CKEDITOR.replace( 'editor1', {
startupMode: 'source'
} );
</script>
13 changes: 13 additions & 0 deletions tests/plugins/save/manual/sourcemode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@bender-ui: collapsed
@bender-tags: 817, 4.7.3, bug
@bender-ckeditor-plugins: wysiwygarea, save, sourcearea, toolbar

**Procedure:**

1. Check if "Save" button is enabled.
2. Switch to WYSIWYG mode.
3. Check if "Save" button is enabled.

**Expected result:**

* "Save" button should be enabled in both modes.
8 changes: 6 additions & 2 deletions tests/plugins/save/save.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<form id="form">
<textarea id="editor">editor</textarea>
<form id="form1">
<textarea id="editor1">editor</textarea>
</form>

<form id="form2">
<textarea id="editor2">editor</textarea>
</form>
41 changes: 25 additions & 16 deletions tests/plugins/save/save.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
/* bender-tags: editor */
/* bender-ckeditor-plugins: toolbar,save,wysiwygarea */
/* bender-ckeditor-plugins: toolbar,save,wysiwygarea,sourcearea */

bender.test( {
'test save event': function() {
var editor = CKEDITOR.replace( 'editor' ),
count = 0;
function saveTest( editor ) {
var count = 0;

editor.on( 'instanceReady', function() {
editor.execCommand( 'save' );
editor.on( 'instanceReady', function() {
editor.execCommand( 'save' );

setTimeout( function() {
resume( function() {
assert.areSame( 1, count, 'save was fired once' );
} );
setTimeout( function() {
resume( function() {
assert.areSame( 1, count, 'save was fired once' );
} );
} );
} );

editor.on( 'save', function() {
count++;
return false;
} );
editor.on( 'save', function() {
count++;
return false;
} );

wait();
}

bender.test( {
'test save event in WYSIWYG mode': function() {
var editor = CKEDITOR.replace( 'editor1' );
saveTest( editor );
},

wait();
'test save event in source mode': function() {
var editor = CKEDITOR.replace( 'editor2' , { startupMode: 'source' } );
saveTest( editor );
}
} );

0 comments on commit 141fd23

Please sign in to comment.