Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/CollaborativeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ import createSyncServiceProvider from './../services/SyncServiceProvider.js'
import {
ATTACHMENT_RESOLVER,
EDITOR_UPLOAD,
HOOK_FILE_WRITTEN,
HOOK_MENTION_SEARCH,
IS_MOBILE,
} from './Editor.provider.ts'
Expand Down Expand Up @@ -171,6 +172,7 @@ export default defineComponent({

inject: {
isEmbedded: { default: false },
fileWritten: { from: HOOK_FILE_WRITTEN, default: null },
},

props: {
Expand Down Expand Up @@ -772,6 +774,7 @@ export default defineComponent({
// Cheap file update for Files app while the editor is still open
this.fileNode.mtime = new Date()
this.fileNode.size = new Blob([this.serialize()]).size
this.fileWritten?.(this.fileNode)
emit('files:node:updated', this.fileNode)
}
this.$nextTick(() => {
Expand Down
1 change: 1 addition & 0 deletions src/components/Editor.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const EDITOR_UPLOAD = Symbol('editor:upload')
export const HOOK_MENTION_SEARCH = Symbol('hook:mention-search')
export const HOOK_MENTION_INSERT = Symbol('hook:mention-insert')
export const HOOK_MENUBAR_LINK_CUSTOM_ACTION = Symbol('menubar:link-custom-action')
export const HOOK_FILE_WRITTEN = Symbol('hook:file-written')

export const useIsMobileMixin = {
inject: {
Expand Down
8 changes: 7 additions & 1 deletion src/views/TextViewerWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import type { IFile } from '@nextcloud/files'
import type { ViewerBeforeDownloadDetail } from '@nextcloud/viewer'

import { computed, onMounted, useHost, useTemplateRef } from 'vue'
import { computed, onMounted, provide, useHost, useTemplateRef } from 'vue'
import ViewerComponent from '../components/ViewerComponent.vue'
import ViewerVersionComparison from '../components/ViewerVersionComparison.vue'
import { HOOK_FILE_WRITTEN } from '../components/Editor.provider.ts'
import { openMimetypesMarkdown } from '../helpers/mime.js'

// Of what the viewer gives a handler's element (`ViewerProps` in
Expand All @@ -24,6 +25,7 @@ const props = defineProps<{
const emit = defineEmits<{
loaded: []
'update:canSwipe': [canSwipe: boolean]
'update:file': [file: IFile]
// 'update:comparison': [comparison: 'side-by-side' | 'differences']
}>()

Expand Down Expand Up @@ -58,6 +60,10 @@ function showChange() {
// emit('update:comparison', 'side-by-side')
}

// The viewer keeps the editor for a file the editor wrote itself, rather
// than mounting a new one for what it takes as another version
provide(HOOK_FILE_WRITTEN, (file: IFile) => emit('update:file', file))

// Swiping to select text would otherwise step to the next file
onMounted(() => emit('update:canSwipe', false))

Expand Down
Loading