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

CKEDITOR.plugins.link.getSelectedLink does not fetch all links #936

Merged
merged 8 commits into from
Dec 15, 2017
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 @@ -7,6 +7,7 @@ Fixed Issues:

* [#1048](https://github.com/ckeditor/ckeditor-dev/issues/1048): Fixed: [Balloon Panel](https://ckeditor.com/cke4/addon/balloonpanel) is not properly positioned when margin added to its non-static parent.
* [#889](https://github.com/ckeditor/ckeditor-dev/issues/889): Fixed: Unclear error message for width and height fields in [Image](https://ckeditor.com/cke4/addon/image) and [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugins.
* [#859](https://github.com/ckeditor/ckeditor-dev/issues/859): Fixed: Can't edit link after double click on text in link.

## CKEditor 4.8

Expand Down
3 changes: 2 additions & 1 deletion plugins/link/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@
range = selection.getRanges()[ i ];

// Skip bogus to cover cases of multiple selection inside tables (#tp2245).
range.shrink( CKEDITOR.SHRINK_TEXT, false, { skipBogus: true } );
// Shrink to element to prevent losing anchor (#859).
range.shrink( CKEDITOR.SHRINK_ELEMENT, true, { skipBogus: true } );
link = editor.elementPath( range.getCommonAncestor() ).contains( 'a', 1 );

if ( link && returnMultiple ) {
Expand Down
18 changes: 17 additions & 1 deletion tests/plugins/link/link.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* bender-tags: editor */
/* bender-ckeditor-plugins: link,toolbar */
/* bender-ckeditor-plugins: link,toolbar,image */

( function() {
'use strict';
Expand Down Expand Up @@ -546,6 +546,22 @@
editor.ui.get( 'Unlink' ).click( editor );

assert.areSame( '<p>I am<a href="http://foo"> an </a>in<a href="http://bar">sta</a>nce of ^<s>CKEditor</s>.</p>', bot.htmlWithSelection() );
},

// 859
'test edit link with selection': function() {
var bot = this.editorBot;

bot.setData( '<p><a class="linkClass" href="linkUrl"><img src="someUrl"/>some button text</a>some text</p>', function() {
var editable = bot.editor.editable();

bot.editor.getSelection().selectElement( editable.findOne( 'a' ) );

bot.dialog( 'link', function( dialog ) {
assert.areSame( dialog.getValueOf( 'info', 'url' ), 'linkUrl' );
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to close the dialog after the test.

dialog.hide();
} );
} );
}
} );
} )();
30 changes: 30 additions & 0 deletions tests/plugins/link/manual/getselectedlink.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div id="editor">
<p>
<a class="linkClass" href="https://www.google.pl">
<img src="%BASE_PATH%_assets/logo.png"/>
some button text
</a>
some text
<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
<tbody>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<a class="linkClass" href="https://www.google.pl">
<img src="%BASE_PATH%_assets/logo.png"/>
some button text
</a>
</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</p>
</div>

<script>
CKEDITOR.replace( 'editor' );
</script>
15 changes: 15 additions & 0 deletions tests/plugins/link/manual/getselectedlink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@bender-tags: link, 4.8.0, 859, bug
@bender-ui: collapsed
@bender-ckeditor-plugins: link,toolbar,wysiwygarea,elementspath,contextmenu,image,table

1. Right-click on the span ("some button text") and select "Edit Link".

**Expected:**
* Link should have class `linkClass`.
* Link should point to `https://www.google.pl`.


1. Double-click on the span ("some button text").

**Excepted:**
* link also should have class and href as above.