Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed May 2, 2019
1 parent 6142355 commit dc0ab36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/linkcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class LinkCommand extends Command {

const node = writer.createText( href, attributes );

writer.insert( node, position );
model.insertContent( node, position );

// Create new range wrapping created node.
writer.setSelection( writer.createRangeOn( node ) );
Expand Down
14 changes: 11 additions & 3 deletions src/linkui.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ export default class LinkUI extends Plugin {
// Execute link command after clicking the "Save" button.
this.listenTo( formView, 'submit', () => {
editor.execute( 'link', formView.urlInputView.inputView.element.value );
this._removeFormView();
this._closeFormView();
} );

// Hide the panel after clicking the "Cancel" button.
this.listenTo( formView, 'cancel', () => {
this._removeFormView();
this._closeFormView();
} );

// Close the panel on esc key press when the **form has focus**.
formView.keystrokes.set( 'Esc', ( data, cancel ) => {
this._removeFormView();
this._closeFormView();
cancel();
} );

Expand Down Expand Up @@ -306,6 +306,14 @@ export default class LinkUI extends Plugin {
this.formView.urlInputView.inputView.element.value = linkCommand.value || '';
}

_closeFormView() {
if ( this.editor.model.document.selection.hasAttribute( 'linkHref' ) ) {
this._removeFormView();
} else {
this._hideUI();
}
}

/**
* Removes the {@link #formView} from the {@link #_balloon}.
*
Expand Down

0 comments on commit dc0ab36

Please sign in to comment.