diff --git a/frontend/src/components/Editor.vue b/frontend/src/components/Editor.vue index 13357dd0..a8ebeecd 100644 --- a/frontend/src/components/Editor.vue +++ b/frontend/src/components/Editor.vue @@ -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) }, diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index dba3c425..87313082 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -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) { diff --git a/frontend/src/components/Tree.vue b/frontend/src/components/Tree.vue index a61378f6..6a6d3cca 100644 --- a/frontend/src/components/Tree.vue +++ b/frontend/src/components/Tree.vue @@ -13,7 +13,7 @@ @delete="onDelete" />
- +
@@ -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) {