md/src/components/CodemirrorEditor/rightClickMenu.vue

137 lines
2.8 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;`"
>
2020-11-22 20:33:04 +08:00
<div class="menu__group" v-for="(menuItem, index) in menu" :key="index">
<li
v-for="item of menuItem"
:key="item.key"
class="menu_item"
@mousedown="onMouseDown(item.key)"
>
<span>{{ item.text }}</span>
</li>
</div>
2020-07-13 00:26:29 +08:00
</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 {
2020-11-22 20:33:04 +08:00
menu: [
2020-11-22 20:34:25 +08:00
[
{
text: "上传图片",
key: "insertPic",
},
{
text: "插入表格",
key: "insertTable",
},
{
text: "页面重置",
key: "pageReset",
},
],
[
{
text: "下载MD文档",
key: "downLoad",
},
],
],
2020-10-20 20:03:36 +08:00
};
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;
border-radius: 4px;
background-color: #ffffff;
2020-11-22 20:34:25 +08:00
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.08);
2020-07-13 00:26:29 +08:00
z-index: 9999;
}
.menu_item {
margin-top: 10px;
2020-11-22 20:33:04 +08:00
min-width: 200px;
font-size: 12px;
2020-07-13 00:26:29 +08:00
line-height: 20px;
2020-11-22 20:33:04 +08:00
color: #333333;
2020-07-13 00:26:29 +08:00
cursor: pointer;
&:first-of-type {
margin-top: 0;
}
&:hover {
2020-11-22 20:33:04 +08:00
background: #f0f0f0;
2020-07-13 00:26:29 +08:00
}
2020-10-20 20:03:36 +08:00
span,
.btn-upload {
2020-07-13 00:26:29 +08:00
display: inline-block;
padding: 4px 0;
2020-11-22 20:33:04 +08:00
padding-left: 24px;
2020-07-13 00:26:29 +08:00
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 {
2020-11-22 20:33:04 +08:00
background: #aaaaaa;
2020-07-26 18:39:27 +08:00
}
2020-09-03 09:26:26 +08:00
::v-deep .el-upload {
2020-07-13 00:26:29 +08:00
width: 100%;
}
}
2020-11-22 20:33:04 +08:00
.menu__group {
padding-top: 6px;
padding-bottom: 6px;
border-bottom: 1px solid #eeeeee;
&:last-of-type {
border-bottom: none;
}
}
2020-07-13 00:26:29 +08:00
li:hover {
background-color: #1790ff;
}
li {
font-size: 15px;
list-style: none;
}
</style>