diff --git a/lib/Listeners/FilesLoadAdditionalScriptsListener.php b/lib/Listeners/FilesLoadAdditionalScriptsListener.php index ae822cb817..1f4ca3d84e 100644 --- a/lib/Listeners/FilesLoadAdditionalScriptsListener.php +++ b/lib/Listeners/FilesLoadAdditionalScriptsListener.php @@ -45,6 +45,7 @@ public function handle(Event $event): void { return; } + \OCP\Util::addInitScript('text', 'text-init'); \OCP\Util::addScript('text', 'text-files'); $this->initialStateProvider->provideState(); diff --git a/src/files.js b/src/files.js index 9dcb93108a..0b156bd050 100644 --- a/src/files.js +++ b/src/files.js @@ -21,11 +21,10 @@ */ import { linkTo } from '@nextcloud/router' import { loadState } from '@nextcloud/initial-state' -import { registerFileListHeaders, registerDavProperty } from '@nextcloud/files' import Vue from 'vue' import { logger } from './helpers/logger.js' -import { registerFileActionFallback, FilesWorkspaceHeader } from './helpers/files.js' +import { registerFileActionFallback } from './helpers/files.js' import FilesSettings from './views/FilesSettings.vue' import store from './store/index.js' @@ -35,9 +34,6 @@ __webpack_public_path__ = linkTo('text', 'js/') // eslint-disable-line const workspaceAvailable = loadState('text', 'workspace_available') const workspaceEnabled = loadState('text', 'workspace_enabled') -registerDavProperty('nc:rich-workspace', { nc: 'http://nextcloud.org/ns' }) -registerDavProperty('nc:rich-workspace-file', { nc: 'http://nextcloud.org/ns' }) - document.addEventListener('DOMContentLoaded', () => { if (typeof OCA.Viewer === 'undefined') { logger.error('Viewer app is not installed') @@ -59,9 +55,6 @@ document.addEventListener('DOMContentLoaded', () => { } }) -if (workspaceAvailable) { - registerFileListHeaders(FilesWorkspaceHeader) -} OCA.Text = { RichWorkspaceEnabled: workspaceEnabled, diff --git a/src/init.js b/src/init.js new file mode 100644 index 0000000000..47f61c0312 --- /dev/null +++ b/src/init.js @@ -0,0 +1,12 @@ +import { registerFileListHeaders, registerDavProperty } from '@nextcloud/files' +import { loadState } from '@nextcloud/initial-state' +import { FilesWorkspaceHeader } from './helpers/files.js' + +const workspaceAvailable = loadState('text', 'workspace_available') + +registerDavProperty('nc:rich-workspace', { nc: 'http://nextcloud.org/ns' }) +registerDavProperty('nc:rich-workspace-file', { nc: 'http://nextcloud.org/ns' }) + +if (workspaceAvailable) { + registerFileListHeaders(FilesWorkspaceHeader) +} diff --git a/webpack.config.js b/webpack.config.js index d63b690377..9334e526d0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,6 +8,7 @@ webpackConfig.entry = { public: path.join(__dirname, 'src', 'public.js'), viewer: path.join(__dirname, 'src', 'viewer.js'), editors: path.join(__dirname, 'src', 'editor.js'), + init: path.join(__dirname, 'src', 'init.js'), } webpackConfig.output.chunkFilename = '[id].js?v=[contenthash]'