mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Added linked images to markdown paste insert
This commit is contained in:
parent
321b53c827
commit
d0c166c207
@ -272,14 +272,15 @@ class MarkdownEditor {
|
|||||||
let placeHolderText = `![${selectedText}](${placeholderImage})`;
|
let placeHolderText = `![${selectedText}](${placeholderImage})`;
|
||||||
let cursor = cm.getCursor();
|
let cursor = cm.getCursor();
|
||||||
cm.replaceSelection(placeHolderText);
|
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 remoteFilename = "image-" + Date.now() + "." + ext;
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append('file', file, remoteFilename);
|
formData.append('file', file, remoteFilename);
|
||||||
|
|
||||||
window.$http.post('/images/gallery/upload', formData).then(resp => {
|
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 => {
|
}).catch(err => {
|
||||||
window.$events.emit('error', trans('errors.image_upload_error'));
|
window.$events.emit('error', trans('errors.image_upload_error'));
|
||||||
replaceContent(placeHolderText, selectedText);
|
replaceContent(placeHolderText, selectedText);
|
||||||
|
Loading…
Reference in New Issue
Block a user