增加插入文档链接快捷键

This commit is contained in:
purocean
2019-05-03 20:58:35 +08:00
parent 58f0b1b62e
commit 5a73246545
3 changed files with 18 additions and 4 deletions
+2
View File
@@ -27,12 +27,14 @@ export default {
this.onGotAmdLoader()
}
window.addEventListener('resize', this.resize)
this.$bus.on('editor-insert-value', this.insert)
this.$bus.on('editor-replace-value', this.replaceValue)
this.$bus.on('editor-toggle-wrap', this.toggleWrap)
},
beforeDestroy () {
window.removeEventListener('paste', this.paste)
window.removeEventListener('resize', this.resize)
this.$bus.off('editor-insert-value', this.insert)
this.$bus.off('editor-replace-value', this.replaceValue)
this.$bus.off('editor-toggle-wrap', this.toggleWrap)
},
-1
View File
@@ -168,7 +168,6 @@ export default {
const file = item || this.selected
if (file) {
this.$emit('choose-file', file)
this.$bus.emit('choose-file', file)
}
},
switchTab (tab = null) {
+16 -3
View File
@@ -13,7 +13,7 @@
@delete="onDelete" />
<transition name="fade">
<div v-if="showFilter" class="filter-wrapper" @click="showFilter = false">
<XFilter @choose-file="f => { showFilter = false }" :repo="repo" :files="files" />
<XFilter @choose-file="showFilter" :repo="repo" :files="files" />
</div>
</transition>
</template>
@@ -105,8 +105,21 @@ export default {
this.init(null, path)
},
keydownHandler (e) {
if (e.key === 'p' && e.ctrlKey) {
this.showFilter = true
if (e.key === 'i' && e.ctrlKey && e.altKey) {
this.showFilter = f => {
if (this.file) {
const relativePath = f.path.replace(this.file.path.substr(0, this.file.path.lastIndexOf('/')), '.')
this.$bus.emit('editor-insert-value', `[${f.name.replace(/\.[^.]$/, '')}](${encodeURI(relativePath)})`)
}
this.showFilter = false
}
e.preventDefault()
e.stopPropagation()
} else if (e.key === 'p' && e.ctrlKey) {
this.showFilter = f => {
this.$bus.emit('choose-file', f)
this.showFilter = false
}
e.preventDefault()
e.stopPropagation()
} else if (e.key === 'Escape' && this.showFilter) {