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

Add Ctrl+K keystroke for link command #2479

Merged
merged 8 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ New Features:
* [#706](https://github.com/ckeditor/ckeditor-dev/issues/706): Added different cursor style when selecting cells for [Table Selection](https://ckeditor.com/cke4/addon/tableselection) plugin.
* [#651](https://github.com/ckeditor/ckeditor-dev/issues/651): Text pasted using [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) preservers indentation in paragraphs.
* [#1176](https://github.com/ckeditor/ckeditor-dev/pull/1176): The [Balloon Panel](https://ckeditor.com/cke4/addon/balloonpanel) can be attached to selection instead of element.
* [#2478](https://github.com/ckeditor/ckeditor-dev/issues/2478): [Link](https://ckeditor.com/cke4/addon/link) can be inserted using <kbd>Ctrl</kbd>/<kbd>Cmd</kbd> + <kbd>K</kbd> keystroke.

Fixed Issues:

Expand Down
3 changes: 3 additions & 0 deletions plugins/link/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@

editor.setKeystroke( CKEDITOR.CTRL + 76 /*L*/, 'link' );

// (#2478)
editor.setKeystroke( CKEDITOR.CTRL + 75 /*K*/, 'link' );

if ( editor.ui.addButton ) {
editor.ui.addButton( 'Link', {
label: editor.lang.link.toolbar,
Expand Down
31 changes: 30 additions & 1 deletion tests/plugins/link/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,38 @@
correctInput: '123456789',
incorrectLinkAssertionCallback: assertIncorrectLinks,
correctLinkAssertionCallback: assertCorrectLinks
} )
} ),

// (#2478)
'test Ctrl+K keystroke': assertKeystroke( 75 ),

'test Ctrl+L keystroke': assertKeystroke( 76 )
} );

function assertKeystroke( key ) {
return function() {
var bot = this.editorBots.noValidation,
editor = bot.editor;

bot.setData( '', function() {
editor.once( 'dialogShow', function( evt ) {
resume( function() {
var dialog = evt.data;

dialog.hide();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hiding dialog here, you could move the whole teardown login into tearDown test function. Something like:

  var dialog = CKEDITOR.dialog.getCurrent();
  if ( dialog ) {
    dialog.hide();
  }

It also applies to the second unit test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's necessary. Every other test in this file hides dialog on its own. Having two tests that are using tearDown for it would break consistency.

Copy link
Member

@jacekbogdanski jacekbogdanski Oct 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2479 (comment)

Not if you refactor other tests. However, following the rule "If it ain't broke, don't fix it", lets deal with important stuff, not test refactoring.

assert.areSame( 'link', dialog._.name );
} );
} );

editor.editable().fire( 'keydown', new CKEDITOR.dom.event( {
keyCode: key,
ctrlKey: true
} ) );
wait();
} );
};
}

function assertPhoneLinks( config ) {
return function() {
var bot = this.editorBots[ config.editorName ];
Expand Down
6 changes: 6 additions & 0 deletions tests/plugins/link/manual/keystroke.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div id="editor">
<p>Hi, I'm CKEditor 4!</p>
</div>
<script>
CKEDITOR.replace( 'editor' );
</script>
18 changes: 18 additions & 0 deletions tests/plugins/link/manual/keystroke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@bender-tags: feature, link, 2478, 4.11.0
@bender-ckeditor-plugins: link, toolbar, wysiwygarea
@bender-ui: collapsed
----

1. Focus the editor.
2. Press <kbd>Ctrl</kbd>/<kbd>Cmd</kbd> + <kbd>K</kbd>.

## Expected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure about test construction. I'm more used to linear tests. Although it's subjective, so would like to see the opinion of another reviewer.


Link dialog is open.

## Unexpected

Nothing happens.

3. Close the dialog.
4. Repeat the procedure for <kbd>Ctrl</kbd>/<kbd>Cmd</kbd> + <kbd>L</kbd> keystroke.