mirror of
https://github.com/doocs/md.git
synced 2024-11-28 21:46:25 +08:00
Merge branch 'feature-rebuild' of github.com:doocs/md into feature-rebuild
This commit is contained in:
commit
8233c9aba3
@ -184,35 +184,26 @@ export default {
|
|||||||
},
|
},
|
||||||
// 图片上传结束
|
// 图片上传结束
|
||||||
uploaded(response) {
|
uploaded(response) {
|
||||||
if (response) {
|
if (!response || !response.success) {
|
||||||
if (response.success) {
|
|
||||||
// 上传成功,获取光标
|
|
||||||
const cursor = this.editor.getCursor();
|
|
||||||
const imageUrl = response.data;
|
|
||||||
const markdownImage = `![](${imageUrl})`;
|
|
||||||
// 将 Markdown 形式的 URL 插入编辑框光标所在位置
|
|
||||||
this.editor.replaceSelection(`\n${markdownImage}\n`, cursor);
|
|
||||||
this.$message({
|
|
||||||
showClose: true,
|
|
||||||
message: '图片插入成功',
|
|
||||||
type: 'success'
|
|
||||||
});
|
|
||||||
this.onEditorRefresh();
|
|
||||||
} else {
|
|
||||||
// 上传失败
|
|
||||||
this.$message({
|
|
||||||
showClose: true,
|
|
||||||
message: response.message,
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.$message({
|
this.$message({
|
||||||
showClose: true,
|
showClose: true,
|
||||||
message: '上传图片未知异常',
|
message: '上传图片未知异常',
|
||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// 上传成功,获取光标
|
||||||
|
const cursor = this.editor.getCursor();
|
||||||
|
const imageUrl = response.data;
|
||||||
|
const markdownImage = `![](${imageUrl})`;
|
||||||
|
// 将 Markdown 形式的 URL 插入编辑框光标所在位置
|
||||||
|
this.editor.replaceSelection(`\n${markdownImage}\n`, cursor);
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: '图片插入成功',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
this.onEditorRefresh();
|
||||||
},
|
},
|
||||||
// 左右滚动
|
// 左右滚动
|
||||||
leftAndRightScroll() {
|
leftAndRightScroll() {
|
||||||
@ -274,13 +265,7 @@ export default {
|
|||||||
const offsetWidth = this.$el.offsetWidth;
|
const offsetWidth = this.$el.offsetWidth;
|
||||||
const maxLeft = offsetWidth - menuMinWidth;
|
const maxLeft = offsetWidth - menuMinWidth;
|
||||||
const left = e.clientX - offsetLeft;
|
const left = e.clientX - offsetLeft;
|
||||||
|
this.mouseLeft = Math.min(maxLeft, left);
|
||||||
if (left > maxLeft) {
|
|
||||||
this.mouseLeft = maxLeft;
|
|
||||||
} else {
|
|
||||||
this.mouseLeft = left;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mouseTop = e.clientY + 10;
|
this.mouseTop = e.clientY + 10;
|
||||||
this.rightClickMenuVisible = true;
|
this.rightClickMenuVisible = true;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user