From f8cdb22b93dbec8fbfd108dae641ada5f48fc77c Mon Sep 17 00:00:00 2001 From: Mustafa Buyukcelebi Date: Thu, 21 Feb 2019 11:07:15 +0300 Subject: [PATCH] Fixed image upload erro --- .../view/formats/applyWebLinkFormat.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/markdownEditor/view/formats/applyWebLinkFormat.js b/src/components/markdownEditor/view/formats/applyWebLinkFormat.js index 723ef00a9..98090c27b 100644 --- a/src/components/markdownEditor/view/formats/applyWebLinkFormat.js +++ b/src/components/markdownEditor/view/formats/applyWebLinkFormat.js @@ -30,10 +30,17 @@ export default ({ } } else { newText = replaceBetween(text, selection, `${imagePrefix}[${itemText}](${itemUrl})`); - newSelection = { - start: selection.start + 1, - end: selection.start + 1 + itemText && itemText.length, - }; + if (isImage) { + newSelection = { + start: newText && newText.length, + end: newText && newText.length, + }; + } else { + newSelection = { + start: selection.start + 1, + end: selection.start + 1 + (itemText && itemText.length), + }; + } } setState({ text: newText }, () => { setState({ newSelection });