Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Image2 link dialog integration will now hide display text field if ne…
…cessary.
  • Loading branch information
mlewand committed Aug 25, 2016
1 parent 4ba96ff commit f94651a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
14 changes: 11 additions & 3 deletions plugins/image2/plugin.js
Expand Up @@ -1428,14 +1428,22 @@
onOk = def.onOk;

def.onShow = function() {
var widget = getFocusedWidget( editor );
var widget = getFocusedWidget( editor ),
displayTextField = this.getContentElement( 'info', 'linkDisplayText' ).getElement();

// Widget cannot be enclosed in a link, i.e.
// <a>foo<inline widget/>bar</a>
if ( widget && ( widget.inline ? !widget.wrapper.getAscendant( 'a' ) : 1 ) )
if ( widget && ( widget.inline ? !widget.wrapper.getAscendant( 'a' ) : 1 ) ) {
this.setupContent( widget.data.link || {} );
else

// Hide the display text in case of linking image2 widget.
displayTextField.hide();
} else {
// Make sure that display text is visible, as it might be hidden by image2 integration
// before.
displayTextField.show();
onShow.apply( this, arguments );
}
};

// Set widget data if linking the widget using
Expand Down
7 changes: 7 additions & 0 deletions tests/plugins/image2/manual/link.html
@@ -0,0 +1,7 @@
<div id="editor1" contenteditable="true">
<p>An example image: <img alt="alt" src="%BASE_PATH%/_assets/logo.png" />.</p>
</div>

<script>
CKEDITOR.replace( 'editor1' );
</script>
21 changes: 21 additions & 0 deletions tests/plugins/image2/manual/link.md
@@ -0,0 +1,21 @@
@bender-tags: 4.5.11, tc, 7154
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, sourcearea, toolbar, image2, link

## Link dialog integration

1. Click on image to focus it.
1. Use Link button.
* Make sure Display Text field is **hidden**.
1. Put `foo` into URL.
1. Click OK button.

**Expected:** Following source `<p>An example image: <a href="http://foo"><img alt="alt" src="/tests//_assets/logo.png" /></a>.</p>`

## Restoring Display Text

1. Perform the above "Link dialog integration" TC.
1. Put selection on `example` word.
1. Use Link button.

**Expected:** Display Text field is visible.

0 comments on commit f94651a

Please sign in to comment.