Skip to content

Commit

Permalink
Add per user setting for text editor max width
Browse files Browse the repository at this point in the history
Signed-off-by: Azri Adam <[email protected]>
  • Loading branch information
azri-cs committed Nov 1, 2024
1 parent c50b8ff commit e67590a
Show file tree
Hide file tree
Showing 6 changed files with 1,221 additions and 1,147 deletions.
5 changes: 3 additions & 2 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

class SettingsController extends Controller {
public const ACCEPTED_KEYS = [
'workspace_enabled'
'workspace_enabled',
'is_full_width_editor'
];

public function __construct(
Expand All @@ -31,7 +32,7 @@ public function __construct(
/**
* @throws \OCP\PreConditionNotMetException
*
* @psalm-return DataResponse<200|400, array{workspace_enabled?: mixed, message?: 'Invalid config key'}, array<never, never>>
* @psalm-return DataResponse<200|400, array{workspace_enabled?: mixed, is_full_width_editor?: mixed, message?: 'Invalid config key'}, array<never, never>>
*/
#[NoAdminRequired]
public function updateConfig(string $key, int|string $value): DataResponse {
Expand Down
4 changes: 4 additions & 0 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ public function isNotifyPushSyncEnabled(): bool {
return $this->appConfig->getValueBool(Application::APP_NAME, 'notify_push');

}

public function isFullWidthEditor(?string $userId): bool {
return $this->config->getUserValue($userId, Application::APP_NAME, 'is_full_width_editor', '0') === '1';
}
}
5 changes: 5 additions & 0 deletions lib/Service/InitialStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public function provideState(): void {
'notify_push',
$this->configService->isNotifyPushSyncEnabled(),
);

$this->initialState->provideInitialState(
'is_full_width_editor',
$this->configService->isFullWidthEditor($this->userId),
);
}

public function provideFileId(int $fileId): void {
Expand Down
Loading

0 comments on commit e67590a

Please sign in to comment.