mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
Merge pull request #22 from doocs/hotfix-rightClickEvent
Hotfix right click event
This commit is contained in:
commit
0921c783ac
@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<ul v-show="value" id="menu" class="menu" :style="`left: ${left}px;top: ${top}px;`">
|
<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">
|
<li v-for="item of list" :key="item.key" class="menu_item" @mousedown="onMouseDown(item.key)">
|
||||||
<el-upload v-if="item.key === 'insertPic'" action="" class="li__upload"
|
<el-upload v-if="item.key === 'insertPic'" action="" class="li__upload"
|
||||||
:show-file-list="false" :multiple="true" accept=".jpg,.jpeg,.png,.gif" name="file"
|
:show-file-list="false" :multiple="true" accept=".jpg,.jpeg,.png,.gif" name="file"
|
||||||
:before-upload="beforeUpload">
|
:before-upload="beforeUpload">
|
||||||
<span>{{item.text}}</span>
|
<button class="btn-upload">{{item.text}}</button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<span v-else @click="$emit('menuTick', item.key)">{{item.text}}</span>
|
<span v-else>{{item.text}}</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
@ -70,14 +70,13 @@ export default {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
},
|
onMouseDown(key){
|
||||||
watch: {
|
if (key == 'insertPic') {
|
||||||
value(newVal) {
|
document.querySelector('.li__upload button').click()
|
||||||
if (newVal) {
|
|
||||||
document.body.addEventListener('click', this.closeCB.bind(this));
|
|
||||||
} else {
|
} else {
|
||||||
document.body.removeEventListener('click', this.closeCB.bind(this));
|
this.$emit('menuTick', key)
|
||||||
}
|
}
|
||||||
|
this.$emit('closeMenu',false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -107,12 +106,22 @@ export default {
|
|||||||
color: white;
|
color: white;
|
||||||
background: rgb(139, 146, 148);
|
background: rgb(139, 146, 148);
|
||||||
}
|
}
|
||||||
span {
|
span,.btn-upload {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.btn-upload {
|
||||||
|
margin: 0;
|
||||||
|
border:none;
|
||||||
|
outline: none;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
.btn-upload:hover {
|
||||||
|
color: white;
|
||||||
|
background: rgb(139, 146, 148);
|
||||||
|
}
|
||||||
/deep/ .el-upload {
|
/deep/ .el-upload {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ const state = {
|
|||||||
currentSize: '',
|
currentSize: '',
|
||||||
currentColor: '',
|
currentColor: '',
|
||||||
citeStatus: 0,
|
citeStatus: 0,
|
||||||
nightMode: false
|
nightMode: false,
|
||||||
|
rightClickMenuVisible:false
|
||||||
};
|
};
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setEditorValue(state, data) {
|
setEditorValue(state, data) {
|
||||||
@ -51,6 +52,9 @@ const mutations = {
|
|||||||
state.currentColor = data;
|
state.currentColor = data;
|
||||||
localStorage.setItem('color', data)
|
localStorage.setItem('color', data)
|
||||||
},
|
},
|
||||||
|
setRightClickMenuVisible(state,data) {
|
||||||
|
state.rightClickMenuVisible = data;
|
||||||
|
},
|
||||||
themeChanged(state) {
|
themeChanged(state) {
|
||||||
state.nightMode = !state.nightMode;
|
state.nightMode = !state.nightMode;
|
||||||
},
|
},
|
||||||
@ -93,6 +97,7 @@ const mutations = {
|
|||||||
const doc = formatDoc(DEFAULT_CONTENT)
|
const doc = formatDoc(DEFAULT_CONTENT)
|
||||||
state.editor.setValue(doc)
|
state.editor.setValue(doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
initCssEditorEntity(state) {
|
initCssEditorEntity(state) {
|
||||||
state.cssEditor = CodeMirror.fromTextArea(
|
state.cssEditor = CodeMirror.fromTextArea(
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
:left="mouseLeft"
|
:left="mouseLeft"
|
||||||
:top="mouseTop"
|
:top="mouseTop"
|
||||||
@menuTick="onMenuEvent"
|
@menuTick="onMenuEvent"
|
||||||
|
@closeMenu="closeRightClickMenu"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -82,7 +83,6 @@ export default {
|
|||||||
showCssEditor: false,
|
showCssEditor: false,
|
||||||
aboutDialogVisible: false,
|
aboutDialogVisible: false,
|
||||||
dialogFormVisible: false,
|
dialogFormVisible: false,
|
||||||
rightClickMenuVisible: false,
|
|
||||||
isCoping: false,
|
isCoping: false,
|
||||||
isImgLoading: false,
|
isImgLoading: false,
|
||||||
backLight: false,
|
backLight: false,
|
||||||
@ -107,7 +107,8 @@ export default {
|
|||||||
cssEditor: state=> state.cssEditor,
|
cssEditor: state=> state.cssEditor,
|
||||||
currentSize: state=> state.currentSize,
|
currentSize: state=> state.currentSize,
|
||||||
currentColor: state=> state.currentColor,
|
currentColor: state=> state.currentColor,
|
||||||
nightMode: state=> state.nightMode
|
nightMode: state=> state.nightMode,
|
||||||
|
rightClickMenuVisible: state=> state.rightClickMenuVisible
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -158,6 +159,18 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.editor.on('mousedown', () => {
|
||||||
|
this.$store.commit('setRightClickMenuVisible', false);
|
||||||
|
});
|
||||||
|
this.editor.on('blur', () => {
|
||||||
|
//!影响到右键菜单的点击事件,右键菜单的点击事件在组件内通过mousedown触发
|
||||||
|
this.$store.commit('setRightClickMenuVisible', false);
|
||||||
|
});
|
||||||
|
this.editor.on('scroll', () => {
|
||||||
|
this.$store.commit('setRightClickMenuVisible', false);
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
initCssEditor() {
|
initCssEditor() {
|
||||||
this.initCssEditorEntity();
|
this.initCssEditorEntity();
|
||||||
@ -267,7 +280,10 @@ export default {
|
|||||||
const left = e.clientX - offsetLeft;
|
const left = e.clientX - offsetLeft;
|
||||||
this.mouseLeft = Math.min(maxLeft, left);
|
this.mouseLeft = Math.min(maxLeft, left);
|
||||||
this.mouseTop = e.clientY + 10;
|
this.mouseTop = e.clientY + 10;
|
||||||
this.rightClickMenuVisible = true;
|
this.$store.commit('setRightClickMenuVisible', true);
|
||||||
|
},
|
||||||
|
closeRightClickMenu(){
|
||||||
|
this.$store.commit('setRightClickMenuVisible', false);
|
||||||
},
|
},
|
||||||
onMenuEvent(type, info = {}) {
|
onMenuEvent(type, info = {}) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
Loading…
Reference in New Issue
Block a user