Merge branch 'thomasjsn-master'
This commit is contained in:
commit
ebd4c3327d
|
@ -272,14 +272,15 @@ class MarkdownEditor {
|
||||||
let placeHolderText = ``;
|
let placeHolderText = ``;
|
||||||
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 = `[](${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);
|
||||||
|
@ -304,7 +305,7 @@ class MarkdownEditor {
|
||||||
let cursorPos = this.cm.getCursor('from');
|
let cursorPos = this.cm.getCursor('from');
|
||||||
window.ImageManager.show(image => {
|
window.ImageManager.show(image => {
|
||||||
let selectedText = this.cm.getSelection();
|
let selectedText = this.cm.getSelection();
|
||||||
let newText = "";
|
let newText = "[](" + image.url + ")";
|
||||||
this.cm.focus();
|
this.cm.focus();
|
||||||
this.cm.replaceSelection(newText);
|
this.cm.replaceSelection(newText);
|
||||||
this.cm.setCursor(cursorPos.line, cursorPos.ch + newText.length);
|
this.cm.setCursor(cursorPos.line, cursorPos.ch + newText.length);
|
||||||
|
@ -427,4 +428,4 @@ class MarkdownEditor {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MarkdownEditor ;
|
export default MarkdownEditor ;
|
||||||
|
|
Loading…
Reference in New Issue