|
148 | 148 | :is-sidebar-shown="isSidebarShown" |
149 | 149 | :loaded.sync="currentFile.loaded" |
150 | 150 | class="viewer__file viewer__file--active" |
| 151 | + @update:editing="toggleEditor" |
151 | 152 | @error="currentFailed" /> |
152 | 153 | <Error v-else |
153 | 154 | :name="currentFile.basename" /> |
@@ -187,12 +188,13 @@ import isFullscreen from '@nextcloud/vue/dist/Mixins/isFullscreen.js' |
187 | 188 | import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js' |
188 | 189 |
|
189 | 190 | import { canDownload } from '../utils/canDownload.ts' |
190 | | -import { extractFilePaths, sortCompare } from '../utils/fileUtils.ts' |
| 191 | +import { extractFilePaths, sortCompare, extractFilePathFromSource } from '../utils/fileUtils.ts' |
191 | 192 | import getSortingConfig from '../services/FileSortingConfig.ts' |
192 | 193 | import cancelableRequest from '../utils/CancelableRequest.js' |
193 | 194 | import Error from '../components/Error.vue' |
194 | 195 | import File from '../models/file.js' |
195 | 196 | import getFileInfo from '../services/FileInfo.ts' |
| 197 | +import fetchNode from '../services/FetchFile.ts' |
196 | 198 | import getFileList from '../services/FileList.ts' |
197 | 199 | import Mime from '../mixins/Mime.js' |
198 | 200 | import logger from '../services/logger.js' |
@@ -545,6 +547,7 @@ export default defineComponent({ |
545 | 547 | subscribe('files:node:updated', this.handleFileUpdated) |
546 | 548 | subscribe('viewer:trapElements:changed', this.handleTrapElementsChange) |
547 | 549 | subscribe('editor:toggle', this.toggleEditor) |
| 550 | + subscribe('editor:file:created', this.handleNewFile) |
548 | 551 | window.addEventListener('keydown', this.keyboardDeleteFile) |
549 | 552 | window.addEventListener('keydown', this.keyboardDownloadFile) |
550 | 553 | window.addEventListener('keydown', this.keyboardEditFile) |
@@ -659,6 +662,22 @@ export default defineComponent({ |
659 | 662 | } |
660 | 663 | } |
661 | 664 | }, |
| 665 | + async handleNewFile(source) { |
| 666 | + let path |
| 667 | + try { |
| 668 | + path = extractFilePathFromSource(source) |
| 669 | + this.openFile(path) |
| 670 | +
|
| 671 | + } catch (e) { |
| 672 | + logger.error('Could not extract file path from source', { source, e }) |
| 673 | + } |
| 674 | + try { |
| 675 | + const node = await fetchNode('/' + path) |
| 676 | + emit('files:node:created', node) |
| 677 | + } catch (e) { |
| 678 | + logger.error('Could not fetch new file', { path, e }) |
| 679 | + } |
| 680 | + }, |
662 | 681 |
|
663 | 682 | /** |
664 | 683 | * Open the view and display the clicked file from a known file info object |
|
0 commit comments