diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 2a031a4b808..5651ce13315 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -16,7 +16,8 @@ class SettingsController extends Controller { public const ACCEPTED_KEYS = [ - 'workspace_enabled' + 'workspace_enabled', + 'is_full_width_editor' ]; public function __construct( @@ -31,7 +32,7 @@ public function __construct( /** * @throws \OCP\PreConditionNotMetException * - * @psalm-return DataResponse<200|400, array{workspace_enabled?: mixed, message?: 'Invalid config key'}, array> + * @psalm-return DataResponse<200|400, array{workspace_enabled?: mixed, is_full_width_editor?: mixed, message?: 'Invalid config key'}, array> */ #[NoAdminRequired] public function updateConfig(string $key, int|string $value): DataResponse { diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 0fd85cb8f80..da3af31a768 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -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'; + } } diff --git a/lib/Service/InitialStateProvider.php b/lib/Service/InitialStateProvider.php index c88ea4a1958..f8138f03574 100644 --- a/lib/Service/InitialStateProvider.php +++ b/lib/Service/InitialStateProvider.php @@ -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 { diff --git a/src/components/Editor.vue b/src/components/Editor.vue index fc81550499e..2df18ff259b 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -5,67 +5,68 @@ @@ -321,6 +322,9 @@ export default { }, } }, + editorMaxWidth() { + return loadState('text', 'is_full_width_editor', false) ? '100%' : '80ch' + }, }, watch: { displayed() { @@ -328,6 +332,12 @@ export default { this.contentWrapper = this.$refs.contentWrapper }) }, + editorMaxWidth: { + immediate: true, + handler(newWidth) { + this.updateEditorWidth(newWidth) + }, + }, }, mounted() { if (this.active && (this.hasDocumentParameters)) { @@ -860,6 +870,19 @@ export default { }) this.translateModal = false }, + + handleEditorWidthChange(newWidth) { + this.updateEditorWidth(newWidth) + this.$nextTick(() => { + if (this.$editor) { + this.$editor.view.updateState(this.$editor.view.state) + this.$editor.commands.focus() + } + }) + }, + updateEditorWidth(newWidth) { + document.documentElement.style.setProperty('--text-editor-max-width', newWidth) + }, }, } @@ -931,75 +954,75 @@ export default { diff --git a/src/components/Editor/SessionList.vue b/src/components/Editor/SessionList.vue index d99cdf29376..296ea908529 100644 --- a/src/components/Editor/SessionList.vue +++ b/src/components/Editor/SessionList.vue @@ -1,169 +1,197 @@ - - - - - - - + + + + + + + diff --git a/src/components/Editor/Status.vue b/src/components/Editor/Status.vue index e211192edcb..72113249ef9 100644 --- a/src/components/Editor/Status.vue +++ b/src/components/Editor/Status.vue @@ -15,7 +15,8 @@ - +

{{ t('text', 'Last saved') }}: {{ lastSavedString }}

@@ -72,7 +73,9 @@ export default { }, sessions: { type: Object, - default: () => { return {} }, + default: () => { + return {} + }, }, }, @@ -128,35 +131,38 @@ export default { this.$syncService.forceSave() } }, + onEditorWidthChange(newWidth) { + this.$emit('editor-width-change', newWidth) + }, }, }