Skip to content
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

Merged
merged 6 commits into from
Sep 6, 2017
Merged

save support in source mode #822

merged 6 commits into from
Sep 6, 2017

Conversation

wojtekw92
Copy link
Contributor

@wojtekw92 wojtekw92 commented Aug 23, 2017

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

  • Unit tests
  • Manual tests

What changes did you make?

Added support for save button is source mode

closes #817

@@ -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 ) };
Copy link
Member

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.


bender.test( {
'test save event': function() {
var editor = CKEDITOR.replace( 'editor' ),
'test save event in WYSIWYG mode': function() {
Copy link
Member

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.

@@ -44,8 +44,9 @@
if ( editor.elementMode != CKEDITOR.ELEMENT_MODE_REPLACE )
return;

saveCmd.startDisabled = !( editor.element.$.form );
Copy link
Member

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() {
Copy link
Member

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.

Copy link
Contributor Author

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

var command = editor.addCommand( pluginName, saveCmd );
command.modes = { wysiwyg: !!( editor.element.$.form ) };
command.modes = { wysiwyg: 1,source: 1 };
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants