From 32ebdf42908f66f6e10c72ddf26f7f6642d66907 Mon Sep 17 00:00:00 2001 From: Indrek Lasn Date: Sun, 22 Jul 2018 19:17:15 +0200 Subject: [PATCH] check if url exists --- src/components/TextEditor.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/TextEditor.js b/src/components/TextEditor.js index b6320b7..4048226 100644 --- a/src/components/TextEditor.js +++ b/src/components/TextEditor.js @@ -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);