mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 00:01:19 +08:00
Merge 07a1afd589
into 11c8cc1e19
This commit is contained in:
commit
2b12eeebcc
@ -176,6 +176,7 @@ export default {
|
|||||||
bus.$on('findPrev', this.listenFindPrev)
|
bus.$on('findPrev', this.listenFindPrev)
|
||||||
document.addEventListener('click', this.docClick)
|
document.addEventListener('click', this.docClick)
|
||||||
document.addEventListener('keyup', this.docKeyup)
|
document.addEventListener('keyup', this.docKeyup)
|
||||||
|
bus.$on('search-blur', this.blurSearch)
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
@ -185,6 +186,7 @@ export default {
|
|||||||
bus.$off('findPrev', this.listenFindPrev)
|
bus.$off('findPrev', this.listenFindPrev)
|
||||||
document.removeEventListener('click', this.docClick)
|
document.removeEventListener('click', this.docClick)
|
||||||
document.removeEventListener('keyup', this.docKeyup)
|
document.removeEventListener('keyup', this.docKeyup)
|
||||||
|
bus.$off('search-blur', this.blurSearch)
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@ -228,6 +230,10 @@ export default {
|
|||||||
this.emptySearch(true)
|
this.emptySearch(true)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
blurSearch () {
|
||||||
|
this.emptySearch(true)
|
||||||
|
},
|
||||||
|
|
||||||
emptySearch (selectHighlight = false) {
|
emptySearch (selectHighlight = false) {
|
||||||
this.showSearch = false
|
this.showSearch = false
|
||||||
const searchValue = this.searchValue = ''
|
const searchValue = this.searchValue = ''
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
type="text" v-model="keyword"
|
type="text" v-model="keyword"
|
||||||
placeholder="Search in folder..."
|
placeholder="Search in folder..."
|
||||||
@keyup="search"
|
@keyup="search"
|
||||||
|
ref="search"
|
||||||
>
|
>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<span
|
<span
|
||||||
@ -125,14 +126,18 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
showSideBar: function (value, oldValue) {
|
showSideBar: function (value, oldValue) {
|
||||||
if (value && !oldValue && this.rightColumn === 'search') {
|
if (this.rightColumn === 'search') {
|
||||||
this.keyword = this.searchMatches.value
|
if (value && !oldValue) {
|
||||||
|
this.handleFindInFolder(false)
|
||||||
|
} else {
|
||||||
|
bus.$emit('search-blur')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.keyword = this.searchMatches.value
|
this.handleFindInFolder()
|
||||||
bus.$on('findInFolder', this.handleFindInFolder)
|
bus.$on('findInFolder', this.handleFindInFolder)
|
||||||
if (this.keyword.length > 0 && this.searcherRunning === false) {
|
if (this.keyword.length > 0 && this.searcherRunning === false) {
|
||||||
this.searcherRunning = true
|
this.searcherRunning = true
|
||||||
@ -316,8 +321,13 @@ export default {
|
|||||||
openFolder () {
|
openFolder () {
|
||||||
this.$store.dispatch('ASK_FOR_OPEN_PROJECT')
|
this.$store.dispatch('ASK_FOR_OPEN_PROJECT')
|
||||||
},
|
},
|
||||||
handleFindInFolder () {
|
handleFindInFolder (focus = true) {
|
||||||
this.keyword = this.searchMatches.value
|
this.keyword = this.searchMatches.value
|
||||||
|
if (focus) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.search.focus()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
|
Loading…
Reference in New Issue
Block a user