diff --git a/frontend/src/components/Filter.vue b/frontend/src/components/Filter.vue index 1924a584..4b5bb41d 100644 --- a/frontend/src/components/Filter.vue +++ b/frontend/src/components/Filter.vue @@ -74,10 +74,10 @@ export default { this.updateSelected(this.list[index]) }, chooseItem (item = null) { - if (item) { - this.$emit('choose-item', item) - } else if (this.selected) { - this.$emit('choose-item', this.selected) + const file = item || this.selected + if (file) { + this.$emit('choose-file', file) + this.$bus.emit('choose-file', file) } } }, diff --git a/frontend/src/components/Tree.vue b/frontend/src/components/Tree.vue index 9ec06947..24b5126b 100644 --- a/frontend/src/components/Tree.vue +++ b/frontend/src/components/Tree.vue @@ -11,7 +11,7 @@ @delete="onDelete" />
- +
diff --git a/frontend/src/components/TreeNode.vue b/frontend/src/components/TreeNode.vue index cdcac710..0c6364f5 100644 --- a/frontend/src/components/TreeNode.vue +++ b/frontend/src/components/TreeNode.vue @@ -43,15 +43,20 @@ export default { }, mounted () { this.$bus.on('editor-ready', () => { - const filePath = this.getSelectedFilePath() + this.chooseFile(this.getSelectedFilePath()) + }) + this.$bus.on('choose-file', file => { + this.chooseFile(file.path) + }) + }, + methods: { + chooseFile (filePath) { if (this.item.type === 'dir' && filePath.startsWith(this.item.path)) { this.$refs.dir.open = true } else if (filePath === this.item.path) { this.select(this.item) } - }) - }, - methods: { + }, select (f) { if (f.name.endsWith('.md')) { this.$nextTick(() => {