diff --git a/package-lock.json b/package-lock.json index 0ce7c4b186a..76c62d168ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -124,7 +124,7 @@ "npm": "^10.0.0" }, "optionalDependencies": { - "@rollup/rollup-linux-x64-gnu": "^4.45.3" + "@rollup/rollup-linux-x64-gnu": "^4.46.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -4878,9 +4878,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.45.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.45.3.tgz", - "integrity": "sha512-SUDXU5YabLAMl86FpupSQQEWzVG8X0HM+Q/famnJusbPiUgQnTGuSxtxg4UAYgv1ZmRV1nioYYXsgtSokU/7+Q==", + "version": "4.46.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.46.0.tgz", + "integrity": "sha512-Cv+moII5C8RM6gZbR3cb21o6rquVDZrN2o81maROg1LFzBz2dZUwIQSxFA8GtGZ/F2KtsqQ2z3eFPBb6akvQNg==", "cpu": [ "x64" ], @@ -23592,9 +23592,9 @@ "optional": true }, "@rollup/rollup-linux-x64-gnu": { - "version": "4.45.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.45.3.tgz", - "integrity": "sha512-SUDXU5YabLAMl86FpupSQQEWzVG8X0HM+Q/famnJusbPiUgQnTGuSxtxg4UAYgv1ZmRV1nioYYXsgtSokU/7+Q==", + "version": "4.46.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.46.0.tgz", + "integrity": "sha512-Cv+moII5C8RM6gZbR3cb21o6rquVDZrN2o81maROg1LFzBz2dZUwIQSxFA8GtGZ/F2KtsqQ2z3eFPBb6akvQNg==", "optional": true }, "@rollup/rollup-linux-x64-musl": { diff --git a/package.json b/package.json index de519b62bfe..40ed07982b9 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "vue-tsc": "^2.2.12" }, "optionalDependencies": { - "@rollup/rollup-linux-x64-gnu": "^4.45.3" + "@rollup/rollup-linux-x64-gnu": "^4.46.0" }, "engines": { "node": "^20.0.0", diff --git a/src/helpers/files.js b/src/helpers/files.js index 06d09670dea..cb0ba31d0a7 100644 --- a/src/helpers/files.js +++ b/src/helpers/files.js @@ -192,13 +192,15 @@ let FilesHeaderRichWorkspaceView let FilesHeaderRichWorkspaceInstance let latestFolder +function enabled(_, view) { + return ['files', 'favorites', 'public-share'].includes(view.id) +} + export const FilesWorkspaceHeader = new Header({ id: 'workspace', order: 10, + enabled, - enabled(_, view) { - return ['files', 'favorites', 'public-share'].includes(view.id) - }, render: async (el, folder) => { latestFolder = folder // Import the RichWorkspace component only when needed @@ -231,7 +233,7 @@ export const FilesWorkspaceHeader = new Header({ window.FilesHeaderRichWorkspaceInstance = FilesHeaderRichWorkspaceInstance }, - updated(folder) { + updated(folder, view) { latestFolder = folder if (!FilesHeaderRichWorkspaceInstance) { console.error('No vue instance found for FilesWorkspaceHeader') @@ -239,6 +241,7 @@ export const FilesWorkspaceHeader = new Header({ } const hasRichWorkspace = !!folder.attributes['rich-workspace-file'] + && enabled(folder, view) FilesHeaderRichWorkspaceInstance.hasRichWorkspace = hasRichWorkspace FilesHeaderRichWorkspaceInstance.content = folder.attributes['rich-workspace'] || '' diff --git a/src/views/RichWorkspace.vue b/src/views/RichWorkspace.vue index e46a20419d2..8053187caac 100644 --- a/src/views/RichWorkspace.vue +++ b/src/views/RichWorkspace.vue @@ -5,7 +5,7 @@ @@ -89,6 +88,7 @@ export default { loaded: false, ready: false, autofocus: false, + shouldAutofocus: false, hideMenu: true, darkTheme: window?.OCA?.Accessibility?.theme === 'dark', enabled: window?.OCA?.Text?.RichWorkspaceEnabled, @@ -98,10 +98,16 @@ export default { shareToken() { return getSharingToken() }, + shouldRender() { + return this.enabled && this.localHasRichWorkspace + }, }, watch: { path() { - this.getFileInfo() + this.reset() + }, + ready() { + this.shouldAutofocus = false }, focus(newValue) { if (!newValue) { @@ -110,18 +116,17 @@ export default { .scrollTo(0, 0) } }, - hasRichWorkspace(value) { - this.localHasRichWorkspace = value + shouldRender(value) { if (value) { this.getFileInfo() } }, + hasRichWorkspace(value) { + this.localHasRichWorkspace = value + }, }, mounted() { this.localHasRichWorkspace = this.hasRichWorkspace - if (this.enabled && this.hasRichWorkspace) { - this.getFileInfo() - } subscribe('Text::showRichWorkspace', this.showRichWorkspace) subscribe('Text::hideRichWorkspace', this.hideRichWorkspace) subscribe('files:node:created', this.onFileCreated) @@ -146,22 +151,19 @@ export default { this.unlistenKeydownEvents() }, reset() { - this.localHasRichWorkspace = false this.file = null this.focus = false + this.shouldAutofocus = false this.$nextTick(() => { - this.creating = false - this.getFileInfo() + if (this.shouldRender) { + this.getFileInfo() + } }) }, - getFileInfo(autofocus) { - if (!this.enabled) { - return - } + getFileInfo() { this.file = null this.ready = false this.loaded = true - this.autofocus = false const params = { path: this.path } if (IS_PUBLIC) { params.shareToken = this.shareToken @@ -174,8 +176,7 @@ export default { this.file = data.file this.editing = true this.loaded = true - this.autofocus = autofocus || false - this.localHasRichWorkspace = true + this.autofocus = this.shouldAutofocus return true }) .catch((error) => { @@ -190,13 +191,11 @@ export default { this.file = null this.loaded = true this.ready = true - this.creating = false return false }) }, showRichWorkspace(event) { this.enabled = true - this.getFileInfo(event?.autofocus || false) }, hideRichWorkspace() { this.enabled = false @@ -214,8 +213,8 @@ export default { }, onFileCreated(node) { if (SUPPORTED_STATIC_FILENAMES.includes(node.basename)) { + this.shouldAutofocus = this.enabled this.localHasRichWorkspace = true - this.getFileInfo(true) } }, onFileDeleted(node) {