-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
save support in source mode #822
Conversation
plugins/save/plugin.js
Outdated
@@ -45,7 +45,7 @@ | |||
return; | |||
|
|||
var command = editor.addCommand( pluginName, saveCmd ); | |||
command.modes = { wysiwyg: !!( editor.element.$.form ) }; | |||
command.modes = { wysiwyg: !!( editor.element.$.form ), source: !!( editor.element.$.form ) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If at last we got to fix it, let's do it properly! I don't feel that command.modes
is a proper place to do any of such checks (apparently not only me). Modes should be just enabled and check should be moved e.g. to command.startDisabled
.
tests/plugins/save/save.js
Outdated
|
||
bender.test( { | ||
'test save event': function() { | ||
var editor = CKEDITOR.replace( 'editor' ), | ||
'test save event in WYSIWYG mode': function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As code for tests is nearly identical, I'd think about creating some function to generate them or just to move common logic into it.
plugins/save/plugin.js
Outdated
@@ -44,8 +44,9 @@ | |||
if ( editor.elementMode != CKEDITOR.ELEMENT_MODE_REPLACE ) | |||
return; | |||
|
|||
saveCmd.startDisabled = !( editor.element.$.form ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property should be added to command
, not saveCmd
. saveCmd
is a template to create commands in all editors and command
is an instance of that command in particular editor. We shouldn't modify the template, but the instance.
resume( function() { | ||
assert.areSame( 1, count, 'save was fired once' ); | ||
} ); | ||
setTimeout( function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if afterCommandExec
could be used here instead of setTimeout
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately no, save plugin doesn't fire afterCommandExec
plugins/save/plugin.js
Outdated
var command = editor.addCommand( pluginName, saveCmd ); | ||
command.modes = { wysiwyg: !!( editor.element.$.form ) }; | ||
command.modes = { wysiwyg: 1,source: 1 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property OTOH should be added to template (saveCmd
) as it's shared across all commands created using that template.
What is the purpose of this pull request?
bug fix
Does your PR contain necessary tests?
All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
What changes did you make?
Added support for save button is source mode
closes #817