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