From 05e01eb14b5c65ec095792b1c5126655796a4e7d Mon Sep 17 00:00:00 2001 From: Henry Castro Date: Tue, 6 May 2025 09:07:31 -0400 Subject: [PATCH] add an initial state for 'browser_setting' variable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the file browsersettings.json is uploaded, it’s necessary to create an initial state for the user’s browser preference settings. This enables the Collabora iframe to include the POST variable and serve preprocessed HTML with accessibility features enabled, for example. Signed-off-by: Henry Castro --- lib/Service/InitialStateService.php | 9 +++++++++ lib/Service/SettingsService.php | 3 +++ src/view/Office.vue | 2 ++ 3 files changed, 14 insertions(+) diff --git a/lib/Service/InitialStateService.php b/lib/Service/InitialStateService.php index cf20af01e7..460fd833c6 100644 --- a/lib/Service/InitialStateService.php +++ b/lib/Service/InitialStateService.php @@ -14,6 +14,7 @@ use OCA\Richdocuments\TemplateManager; use OCA\Theming\ImageManager; use OCP\AppFramework\Services\IInitialState; +use OCA\Richdocuments\Service\SettingsService; use OCP\Defaults; use OCP\IConfig; use OCP\IURLGenerator; @@ -31,6 +32,7 @@ public function __construct( private Defaults $themingDefaults, private IConfig $config, private ?string $userId, + private SettingsService $settingsService, ) { } @@ -110,5 +112,12 @@ private function provideOptions(): void { $this->initialState->provideInitialState('theming-customLogo', $logo); $this->initialState->provideInitialState('open_local_editor', $this->config->getAppValue(Application::APPNAME, 'open_local_editor', 'yes') === 'yes'); + $fileName = $this->config->getUserValue($this->userId, Application::APPNAME, 'browsersetting'); + if ($fileName) { + $browserSetting = $this->settingsService->getSettingsFile('userconfig/' . $this->userId, + 'browsersetting', + $fileName); + $this->initialState->provideInitialState('browsersetting', $browserSetting->getContent()); + } } } diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index bc8b0e741a..e0f0313ec3 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -102,6 +102,9 @@ public function uploadFile(SettingsUrl $settingsUrl, string $fileData, string $u $fileUri = $this->generateFileUri($settingsUrl->getType(), $settingsUrl->getCategory(), $fileName, $token['token']); $this->refreshFolderEtag($settingsUrl->getType()); + if ($settingsUrl->getType() === 'userconfig' && $settingsUrl->getCategory() === 'browsersetting') { + $this->config->setUserValue($userId, 'richdocuments', 'browsersetting', $fileName); + } return [ 'stamp' => $newFile->getETag(), 'uri' => $fileUri, diff --git a/src/view/Office.vue b/src/view/Office.vue index c1426d3209..5364e7ed1a 100644 --- a/src/view/Office.vue +++ b/src/view/Office.vue @@ -55,6 +55,7 @@ +