Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/components/md-toolbar-left.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@
<div class="op-image popup-dropdown" v-show="s_img_dropdown_open" @mouseleave="$mouseleave_img_dropdown" @mouseenter="$mouseenter_img_dropdown">
<div class="dropdown-item" @click.stop="$toggle_imgLinkAdd('imagelink')"><span>{{d_words.tl_image}}</span></div>
<div class="dropdown-item" style="overflow: hidden">
<input type="file" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" @change="$imgAdd($event)" :key="img_file[0][0]" multiple="multiple"/>{{d_words.tl_upload}}
<input type="file" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" @change="$imgAdd($event)" multiple="multiple"/>{{d_words.tl_upload}}
</div>

<div class="dropdown-item dropdown-images" :title="item[1].name" v-if="index > 0" v-for="(item, index) in img_file" @click.stop="$imgFileListClick(index)">
<span>{{item[1].name}}</span>
<div class="dropdown-item dropdown-images" :title="item[0].name" v-if="item" v-for="(item, index) in img_file" @click.stop="$imgFileListClick(index)">
<span>{{item[0].name}}</span>
<button slot="right" type="button" @click.stop="$imgDel(index)"
class="op-icon fa fa-mavon-trash-o" aria-hidden="true"
:title="d_words.tl_upload_remove"></button>
<!-- 缩略图展示 -->
<img class = "image-show" :src="item[1].miniurl" alt="none">
<img class = "image-show" :src="item[0].miniurl" alt="none">
</div>
</div>
</transition>
Expand Down Expand Up @@ -180,14 +180,16 @@
this.$emit('imgTouch', this.img_file[pos]);
},
$changeUrl(index,url) {
this.img_file[index][2] = url;
this.img_file[index][1] = url;
},
$imgFileAdd($file) {
this.img_file[0][0] = this.num;
this.img_file[0][1] = $file;
this.img_file.unshift([(this.num + 1), null]);
// this.img_file[0][0] = this.num;
// this.img_file[0][1] = $file;
// this.img_file.unshift([(this.num + 1), null]);
// this.num = this.num + 1;
this.img_file.push([$file,this.num])
this.$emit('imgAdd', this.num, $file);
this.num = this.num + 1;
this.$emit('imgAdd', this.img_file[1][0], $file);
this.s_img_dropdown_open = false;
},
$imgFilesAdd($files) {
Expand All @@ -206,7 +208,9 @@
},
$imgDel(pos) {
this.$emit('imgDel', this.img_file[pos]);
this.img_file.splice(pos, 1);
// this.img_file.splice(pos, 1);
delete this.img_file[pos];

this.s_img_dropdown_open = false;
},
isEqualName(filename, pos) {
Expand Down
7 changes: 4 additions & 3 deletions src/mavon-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,12 @@
$imgDel(file) {
this.markdownIt.image_del(file[0]);
// 删除所有markdown中的图片
let fileReg = file[2] ? file[2] : file[0]
let reg = new RegExp(`\\!\\[${file[1]._name}\\]\\(${fileReg}\\)`, "g")
let fileReg = file[1]
let reg = new RegExp(`\\!\\[${file[0]._name}\\]\\(${fileReg}\\)`, "g")

this.d_value = this.d_value.replace(reg, '');
this.iRender();
this.$emit('imgDel', fileReg);
this.$emit('imgDel', file);
},
$imgAdd(pos, $file, isinsert) {
if (isinsert === undefined) isinsert = true;
Expand Down