From ae601af566000bae29e4ef4335b9daef9eca4dab Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 31 Oct 2023 19:57:00 +0100 Subject: [PATCH] feat(editorApi): Use editor API for version view Also fix some further issues with version view along the way: * Show emoji and fix alignment of page title in version view * Mark selected version as active in sidebar version list Signed-off-by: Jonas --- src/components/Page/TextEditor.vue | 2 +- src/components/Page/Version.vue | 57 +++++++++++++++---- .../PageSidebar/SidebarTabVersions.vue | 10 ++++ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/src/components/Page/TextEditor.vue b/src/components/Page/TextEditor.vue index 31ad6e13aa..a0dbe62435 100644 --- a/src/components/Page/TextEditor.vue +++ b/src/components/Page/TextEditor.vue @@ -79,7 +79,7 @@ export default { contentLoaded() { // Either `pageContent` is filled from editor or we finished fetching it from DAV - return this.pageContent || !this.loading('pageContent') + return !!this.pageContent || !this.loading('pageContent') }, }, diff --git a/src/components/Page/Version.vue b/src/components/Page/Version.vue index ef8736455d..ff6f2463b1 100644 --- a/src/components/Page/Version.vue +++ b/src/components/Page/Version.vue @@ -1,6 +1,16 @@ @@ -39,40 +54,46 @@ import { showError, showSuccess } from '@nextcloud/dialogs' import { generateRemoteUrl } from '@nextcloud/router' import { mapActions, mapGetters, mapMutations } from 'vuex' import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js' +import EmoticonOutlineIcon from 'vue-material-design-icons/EmoticonOutline.vue' import { SELECT_VERSION } from '../../store/mutations.js' import { GET_VERSIONS } from '../../store/actions.js' import pageContentMixin from '../../mixins/pageContentMixin.js' +import editorMixin from '../../mixins/editorMixin.js' +import SkeletonLoading from '../SkeletonLoading.vue' export default { name: 'Version', components: { + EmoticonOutlineIcon, NcActionButton, NcActions, NcButton, RestoreIcon, Reader, + SkeletonLoading, }, mixins: [ + editorMixin, isMobile, pageContentMixin, ], - data() { - return { - pageVersionContent: '', - } - }, - computed: { ...mapGetters([ 'currentPage', 'isFullWidthView', - 'version', + 'loading', + 'useEditorApi', 'title', + 'version', ]), + pageTitleIconSize() { + return isMobile ? 25 : 30 + }, + restoreFolderUrl() { return generateRemoteUrl( `dav/versions/${this.getUser}/restore/${this.currentPage.id}`, @@ -86,15 +107,22 @@ export default { versionTitle() { return `${this.title} (${this.version.relativeTimestamp})` }, + + contentLoaded() { + // Either `pageContent` is filled from editor or we finished fetching it from DAV + return !!this.pageContent || !this.loading(`version-${this.currentPage.id}-${this.version.timestamp}`) + }, }, watch: { 'version.timestamp'() { + this.davContent = '' this.getPageContent() }, }, mounted() { + this.setupReader() this.getPageContent() }, @@ -139,9 +167,16 @@ export default { async getPageContent() { this.load(`version-${this.currentPage.id}-${this.version.timestamp}`) - this.pageVersionContent = await this.fetchPageContent(this.version.downloadUrl) + this.davContent = await this.fetchPageContent(this.version.downloadUrl) + this.reader?.setContent(this.pageContent) this.done(`version-${this.currentPage.id}-${this.version.timestamp}`) }, }, } + + diff --git a/src/components/PageSidebar/SidebarTabVersions.vue b/src/components/PageSidebar/SidebarTabVersions.vue index 0e47f13b8d..bb86b6d231 100644 --- a/src/components/PageSidebar/SidebarTabVersions.vue +++ b/src/components/PageSidebar/SidebarTabVersions.vue @@ -20,6 +20,8 @@