md/src/components/CodemirrorEditor/rightClickMenu.vue

126 lines
2.4 KiB
Vue
Raw Normal View History

2020-07-13 00:26:29 +08:00
<template>
2020-10-20 20:03:36 +08:00
<ul
v-show="value"
id="menu"
class="menu"
:style="`left: ${left}px;top: ${top}px;`"
>
<li
v-for="item of list"
:key="item.key"
class="menu_item"
@mousedown="onMouseDown(item.key)"
>
<span>{{ item.text }}</span>
2020-07-13 00:26:29 +08:00
</li>
</ul>
</template>
<script>
2020-10-20 20:03:36 +08:00
import { uploadImgFile } from "../../assets/scripts/uploadImageFile";
2020-07-13 00:26:29 +08:00
export default {
props: {
value: {
type: Boolean,
2020-10-20 20:03:36 +08:00
default: false,
2020-07-13 00:26:29 +08:00
},
top: {
type: Number,
2020-10-20 20:03:36 +08:00
default: 0,
2020-07-13 00:26:29 +08:00
},
left: {
type: Number,
2020-10-20 20:03:36 +08:00
default: 0,
},
2020-07-13 00:26:29 +08:00
},
data() {
return {
list: [
2020-08-29 11:55:16 +08:00
{
2020-10-20 20:03:36 +08:00
text: "上传图片",
key: "insertPic",
2020-08-29 11:55:16 +08:00
},
2020-07-13 00:26:29 +08:00
{
2020-10-20 20:03:36 +08:00
text: "插入表格",
key: "insertTable",
2020-07-13 00:26:29 +08:00
},
{
2020-10-20 20:03:36 +08:00
text: "页面重置",
key: "pageReset",
2020-07-13 00:26:29 +08:00
},
{
2020-10-20 20:03:36 +08:00
text: "下载MD文档",
key: "downLoad",
},
],
};
2020-07-13 00:26:29 +08:00
},
methods: {
closeCB() {
2020-10-20 20:03:36 +08:00
this.$emit("input", false);
},
onMouseDown(key) {
this.$emit("menuTick", key);
this.$emit("closeMenu", false);
2020-07-13 00:26:29 +08:00
},
},
2020-10-20 20:03:36 +08:00
};
2020-07-13 00:26:29 +08:00
</script>
<style lang="less" scoped>
.menu {
position: absolute;
padding: 6px 0;
border-radius: 4px;
border: 1px solid #aaaaaa;
background-color: #ffffff;
z-index: 9999;
}
.menu_item {
margin-top: 10px;
min-width: 125px;
font-size: 14px;
line-height: 20px;
color: #303133;
cursor: pointer;
&:first-of-type {
margin-top: 0;
}
&:hover {
color: white;
background: rgb(139, 146, 148);
}
2020-10-20 20:03:36 +08:00
span,
.btn-upload {
2020-07-13 00:26:29 +08:00
text-align: center;
display: inline-block;
padding: 4px 0;
width: 100%;
}
2020-07-26 18:39:27 +08:00
.btn-upload {
margin: 0;
2020-10-20 20:03:36 +08:00
border: none;
2020-07-26 18:39:27 +08:00
outline: none;
background: transparent;
}
.btn-upload:hover {
color: white;
background: rgb(139, 146, 148);
}
2020-09-03 09:26:26 +08:00
::v-deep .el-upload {
2020-07-13 00:26:29 +08:00
width: 100%;
}
}
li:hover {
background-color: #1790ff;
color: white;
}
li {
font-size: 15px;
list-style: none;
}
</style>