mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
chore: migration rightClickMenuVisible (#178)
从 vuex 当中抽离 `rightClickMenuVisible`,该值并不需要放入 Vuex 当中共享
This commit is contained in:
parent
0542f26d15
commit
bbf47a5002
@ -2,13 +2,13 @@
|
|||||||
<div
|
<div
|
||||||
id="menu"
|
id="menu"
|
||||||
class="menu"
|
class="menu"
|
||||||
v-show="value"
|
v-show="visible"
|
||||||
:style="`left: ${left}px;top: ${top}px;`"
|
:style="`left: ${left}px;top: ${top}px;`"
|
||||||
>
|
>
|
||||||
<ul class="menu__group" v-for="(menuItem, index) in menu" :key="index">
|
<ul class="menu__group" v-for="(menuItem, index) in menu" :key="index">
|
||||||
<li
|
<li
|
||||||
class="menu_item"
|
class="menu_item"
|
||||||
v-for="{ key, text } of menuItem"
|
v-for="{ key, text } in menuItem"
|
||||||
:key="key"
|
:key="key"
|
||||||
@mousedown="onMouseDown(key)"
|
@mousedown="onMouseDown(key)"
|
||||||
>
|
>
|
||||||
@ -21,7 +21,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
value: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
@ -73,9 +73,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeCB() {
|
|
||||||
this.$emit(`input`, false)
|
|
||||||
},
|
|
||||||
onMouseDown(key) {
|
onMouseDown(key) {
|
||||||
this.$emit(`menuTick`, key)
|
this.$emit(`menuTick`, key)
|
||||||
this.$emit(`closeMenu`, false)
|
this.$emit(`closeMenu`, false)
|
||||||
|
@ -6,7 +6,7 @@ import { marked } from 'marked'
|
|||||||
import CodeMirror from 'codemirror/lib/codemirror'
|
import CodeMirror from 'codemirror/lib/codemirror'
|
||||||
import DEFAULT_CONTENT from '@/assets/example/markdown.md'
|
import DEFAULT_CONTENT from '@/assets/example/markdown.md'
|
||||||
import DEFAULT_CSS_CONTENT from '@/assets/example/theme-css.txt'
|
import DEFAULT_CSS_CONTENT from '@/assets/example/theme-css.txt'
|
||||||
import { setColor, formatDoc, formatCss } from '../assets/scripts/util'
|
import { setColor, formatDoc, formatCss } from '@/assets/scripts/util'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
@ -22,7 +22,6 @@ const state = {
|
|||||||
citeStatus: 0,
|
citeStatus: 0,
|
||||||
nightMode: false,
|
nightMode: false,
|
||||||
codeTheme: config.codeThemeOption[0].value,
|
codeTheme: config.codeThemeOption[0].value,
|
||||||
rightClickMenuVisible: false,
|
|
||||||
}
|
}
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setEditorValue(state, data) {
|
setEditorValue(state, data) {
|
||||||
@ -54,9 +53,6 @@ const mutations = {
|
|||||||
state.codeTheme = data
|
state.codeTheme = data
|
||||||
localStorage.setItem(`codeTheme`, data)
|
localStorage.setItem(`codeTheme`, data)
|
||||||
},
|
},
|
||||||
setRightClickMenuVisible(state, data) {
|
|
||||||
state.rightClickMenuVisible = data
|
|
||||||
},
|
|
||||||
themeChanged(state) {
|
themeChanged(state) {
|
||||||
state.nightMode = !state.nightMode
|
state.nightMode = !state.nightMode
|
||||||
localStorage.setItem(`nightMode`, state.nightMode)
|
localStorage.setItem(`nightMode`, state.nightMode)
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
:span="12"
|
:span="12"
|
||||||
class="codeMirror-wrapper"
|
class="codeMirror-wrapper"
|
||||||
ref="codeMirrorWrapper"
|
ref="codeMirrorWrapper"
|
||||||
@contextmenu.prevent.native="openMenu($event)"
|
@contextmenu.prevent.native="openMenu"
|
||||||
>
|
>
|
||||||
<textarea
|
<textarea
|
||||||
id="editor"
|
id="editor"
|
||||||
@ -96,7 +96,7 @@
|
|||||||
<insert-form-dialog v-model="dialogFormVisible"></insert-form-dialog>
|
<insert-form-dialog v-model="dialogFormVisible"></insert-form-dialog>
|
||||||
|
|
||||||
<right-click-menu
|
<right-click-menu
|
||||||
v-model="rightClickMenuVisible"
|
:visible="rightClickMenuVisible"
|
||||||
:left="mouseLeft"
|
:left="mouseLeft"
|
||||||
:top="mouseTop"
|
:top="mouseTop"
|
||||||
@menuTick="onMenuEvent"
|
@menuTick="onMenuEvent"
|
||||||
@ -144,6 +144,7 @@ export default {
|
|||||||
source: ``,
|
source: ``,
|
||||||
mouseLeft: 0,
|
mouseLeft: 0,
|
||||||
mouseTop: 0,
|
mouseTop: 0,
|
||||||
|
rightClickMenuVisible: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
@ -163,7 +164,6 @@ export default {
|
|||||||
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,
|
|
||||||
codeTheme: (state) => state.codeTheme,
|
codeTheme: (state) => state.codeTheme,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -304,14 +304,14 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.editor.on(`mousedown`, () => {
|
this.editor.on(`mousedown`, () => {
|
||||||
this.$store.commit(`setRightClickMenuVisible`, false)
|
this.rightClickMenuVisible = false
|
||||||
})
|
})
|
||||||
this.editor.on(`blur`, () => {
|
this.editor.on(`blur`, () => {
|
||||||
//!影响到右键菜单的点击事件,右键菜单的点击事件在组件内通过mousedown触发
|
//!影响到右键菜单的点击事件,右键菜单的点击事件在组件内通过mousedown触发
|
||||||
this.$store.commit(`setRightClickMenuVisible`, false)
|
this.rightClickMenuVisible = false
|
||||||
})
|
})
|
||||||
this.editor.on(`scroll`, () => {
|
this.editor.on(`scroll`, () => {
|
||||||
this.$store.commit(`setRightClickMenuVisible`, false)
|
this.rightClickMenuVisible = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
initCssEditor() {
|
initCssEditor() {
|
||||||
@ -575,10 +575,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.$store.commit(`setRightClickMenuVisible`, true)
|
this.rightClickMenuVisible = true
|
||||||
},
|
},
|
||||||
closeRightClickMenu() {
|
closeRightClickMenu() {
|
||||||
this.$store.commit(`setRightClickMenuVisible`, false)
|
this.rightClickMenuVisible = false
|
||||||
},
|
},
|
||||||
onMenuEvent(type, info = {}) {
|
onMenuEvent(type, info = {}) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
Loading…
Reference in New Issue
Block a user