|
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' |
@@ -556,6 +558,7 @@ export default defineComponent({ |
556 | 558 | subscribe('files:node:updated', this.handleFileUpdated) |
557 | 559 | subscribe('viewer:trapElements:changed', this.handleTrapElementsChange) |
558 | 560 | subscribe('editor:toggle', this.toggleEditor) |
| 561 | + subscribe('editor:file:created', this.handleNewFile) |
559 | 562 | window.addEventListener('keydown', this.keyboardDeleteFile) |
560 | 563 | window.addEventListener('keydown', this.keyboardDownloadFile) |
561 | 564 | window.addEventListener('keydown', this.keyboardEditFile) |
@@ -671,6 +674,22 @@ export default defineComponent({ |
671 | 674 | } |
672 | 675 | } |
673 | 676 | }, |
| 677 | + async handleNewFile(source) { |
| 678 | + let path |
| 679 | + try { |
| 680 | + path = extractFilePathFromSource(source) |
| 681 | + this.openFile(path) |
| 682 | +
|
| 683 | + } catch (e) { |
| 684 | + logger.error('Could not extract file path from source', { source, e }) |
| 685 | + } |
| 686 | + try { |
| 687 | + const node = await fetchNode('/' + path) |
| 688 | + emit('files:node:created', node) |
| 689 | + } catch (e) { |
| 690 | + logger.error('Could not fetch new file', { path, e }) |
| 691 | + } |
| 692 | + }, |
674 | 693 |
|
675 | 694 | /** |
676 | 695 | * Open the view and display the clicked file from a known file info object |
|
0 commit comments