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

T/501 Allow opening dialog for an empty anchor #564

Merged
merged 6 commits into from
Jul 18, 2017
Merged

T/501 Allow opening dialog for an empty anchor #564

merged 6 commits into from
Jul 18, 2017

Conversation

beatadelura
Copy link
Contributor

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

Yes

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

Add a new condition to element variable on double-click.

Closes #501

@Comandeer Comandeer self-requested a review June 29, 2017 12:28
@@ -94,10 +94,11 @@
editor.on( 'doubleclick', function( evt ) {
// If the link has descendants and the last part of it is also a part of a word partially
// unlinked, clicked element may be a descendant of the link, not the link itself. (http://dev.ckeditor.com/ticket/11956)
var element = CKEDITOR.plugins.link.getSelectedLink( editor ) || evt.data.element.getAscendant( 'a', 1 );
// evt.data.element condition allows opening anchor dialog if the anchor is empty (#501).
var element = CKEDITOR.plugins.link.getSelectedLink( editor ) || evt.data.element.getAscendant( 'a', 1 ) || evt.data.element;
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 this condition could be simplified, e.g. setting element only if evt.data.element is a or img.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Comandeer PTAL 👀

if ( element && !element.isReadOnly() ) {
if ( element.is( 'a' ) ) {
if ( element ) {
if ( element.is( 'a' ) && !element.isReadOnly() ) {
Copy link
Member

Choose a reason for hiding this comment

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

Why this condition is moved here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a remnant of the experiments. I moved it to the right place :)


**Unexpected result:**

Nothing happend.
Copy link
Member

Choose a reason for hiding this comment

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

Typo ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed 👍

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Looks good, only few cosmetic changes needed.

@@ -94,7 +94,8 @@
editor.on( 'doubleclick', function( evt ) {
// If the link has descendants and the last part of it is also a part of a word partially
// unlinked, clicked element may be a descendant of the link, not the link itself. (http://dev.ckeditor.com/ticket/11956)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please adjust the comment to standard format ...descendant of the link, not the link itself (http://dev.ckeditor.com/ticket/11956). (I know it was not changed, but we should correct it anyway).

@@ -94,7 +94,8 @@
editor.on( 'doubleclick', function( evt ) {
// If the link has descendants and the last part of it is also a part of a word partially
// unlinked, clicked element may be a descendant of the link, not the link itself. (http://dev.ckeditor.com/ticket/11956)
var element = CKEDITOR.plugins.link.getSelectedLink( editor ) || evt.data.element.getAscendant( 'a', 1 );
// evt.data.element condition allows opening anchor dialog if the anchor is empty (#501).
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to always start a sentence with uppercase. In this case you could use The so The evt.data.element ....


editor.on( 'dialogShow', function( evt ) {
resume( function() {
assert.areSame( evt.data._.name, 'anchor' );
Copy link
Contributor

Choose a reason for hiding this comment

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

You can pass 3rd parameter as an assert description. In this case it could be useful because it might not be clear at the first glance what this assert is checking. It could look something like:
assert.areSame( evt.data._.name, 'anchor', 'Anchor dialog has been opened.' )

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

LGTM!

@f1ames
Copy link
Contributor

f1ames commented Jul 12, 2017

@Comandeer, please check if all your requests were resolved.

Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

Just one small thing ;)

var element = CKEDITOR.plugins.link.getSelectedLink( editor ) || evt.data.element.getAscendant( 'a', 1 );
// unlinked, clicked element may be a descendant of the link, not the link itself (http://dev.ckeditor.com/ticket/11956).
// The evt.data.element.getAscendant( 'img', 1 ) condition allows opening anchor dialog if the anchor is empty (#501).
var element = evt.data.element.getAscendant( 'a', 1 ) || evt.data.element.getAscendant( 'img', 1 );
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't it be further simplified to:

evt.data.element.getAscendant( { a: 1, img: 1 }, true );

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, it looks better this way :) Changed 👍 PTAL @Comandeer

@Comandeer Comandeer merged commit f450a78 into master Jul 18, 2017
@Comandeer Comandeer deleted the t/501 branch July 18, 2017 13:39
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.

3 participants