Skip to content

Commit

Permalink
check if url exists
Browse files Browse the repository at this point in the history
  • Loading branch information
indreklasn committed Jul 22, 2018
1 parent 54e8c47 commit 32ebdf4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/TextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,17 @@ export default class TextEditor extends Component {
change.call(this.unwrapLink);
} else if (value.isExpanded) {
const href = window.prompt('Enter the URL of the link:');
change.call(this.wrapLink, href);
href.length > 0 ? change.call(this.wrapLink, href) : null;
} else {
const href = window.prompt('Enter the URL of the link:');
const text = window.prompt('Enter the text for the link:');

change
.insertText(text)
.extend(0 - text.length)
.call(this.wrapLink, href);
href.length > 0
? change
.insertText(text)
.extend(0 - text.length)
.call(this.wrapLink, href)
: null;
}

this.onChange(change);
Expand Down

0 comments on commit 32ebdf4

Please sign in to comment.