From 90929baa523c9aadc41abafc93a4b71e9787d684 Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Sat, 13 Oct 2018 21:43:35 +0200 Subject: [PATCH 1/2] Wrap images inserted with markdown editor with anchor tag to original file ref #1062 --- resources/assets/js/components/markdown-editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/components/markdown-editor.js b/resources/assets/js/components/markdown-editor.js index a555376e8..88b61f0be 100644 --- a/resources/assets/js/components/markdown-editor.js +++ b/resources/assets/js/components/markdown-editor.js @@ -304,7 +304,7 @@ class MarkdownEditor { let cursorPos = this.cm.getCursor('from'); window.ImageManager.show(image => { let selectedText = this.cm.getSelection(); - let newText = "![" + (selectedText || image.name) + "](" + image.thumbs.display + ")"; + let newText = "[![" + (selectedText || image.name) + "](" + image.thumbs.display + ")](" + image.url + ")"; this.cm.focus(); this.cm.replaceSelection(newText); this.cm.setCursor(cursorPos.line, cursorPos.ch + newText.length); @@ -427,4 +427,4 @@ class MarkdownEditor { } -module.exports = MarkdownEditor ; \ No newline at end of file +module.exports = MarkdownEditor ; From d0c166c207671f8b558173627160184809a1581a Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 10 Nov 2018 15:35:13 +0000 Subject: [PATCH 2/2] Added linked images to markdown paste insert --- resources/assets/js/components/markdown-editor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/components/markdown-editor.js b/resources/assets/js/components/markdown-editor.js index dd58a0ece..9228cfe2c 100644 --- a/resources/assets/js/components/markdown-editor.js +++ b/resources/assets/js/components/markdown-editor.js @@ -272,14 +272,15 @@ class MarkdownEditor { let placeHolderText = `![${selectedText}](${placeholderImage})`; let cursor = cm.getCursor(); cm.replaceSelection(placeHolderText); - cm.setCursor({line: cursor.line, ch: cursor.ch + selectedText.length + 2}); + cm.setCursor({line: cursor.line, ch: cursor.ch + selectedText.length + 3}); let remoteFilename = "image-" + Date.now() + "." + ext; let formData = new FormData(); formData.append('file', file, remoteFilename); window.$http.post('/images/gallery/upload', formData).then(resp => { - replaceContent(placeholderImage, resp.data.thumbs.display); + const newContent = `[![${selectedText}](${resp.data.thumbs.display})](${resp.data.url})`; + replaceContent(placeHolderText, newContent); }).catch(err => { window.$events.emit('error', trans('errors.image_upload_error')); replaceContent(placeHolderText, selectedText);