From 14bf65d9a13b941eb75b1e74a6fea198c364476f Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 13 Dec 2025 19:38:54 +0100 Subject: [PATCH] fix(useEditorWidth): no full width toggle in rich workspace and on mobile There's no use in toggling full width in either of them. Signed-off-by: Jonas --- src/composables/useEditorWidth.ts | 9 ++++++++- src/declarations.d.ts | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/composables/useEditorWidth.ts b/src/composables/useEditorWidth.ts index ee0dac3a4a0..1d6f3d2f6e8 100644 --- a/src/composables/useEditorWidth.ts +++ b/src/composables/useEditorWidth.ts @@ -22,6 +22,7 @@ import axios from '@nextcloud/axios' import { emit, subscribe } from '@nextcloud/event-bus' import { loadState } from '@nextcloud/initial-state' import { generateUrl } from '@nextcloud/router' +import { useIsMobile } from '@nextcloud/vue/composables/useIsMobile' import { computed, inject, @@ -32,6 +33,7 @@ import { type InjectionKey, type Ref, } from 'vue' +import { useEditorFlags } from './useEditorFlags' // Keep the current value around when leaving the editor and reopening let valueSingleton = loadState('text', 'is_full_width_editor', false) @@ -83,9 +85,14 @@ export const provideEditorWidth = () => { } export const useEditorWidth = () => { + const isMobile = useIsMobile() + const { isRichWorkspace } = useEditorFlags() + // This will be null if the width is already configured outside of text. const isFullWidth = inject(editorWidthKey) - if (isFullWidth === null) { + + // Disable if `editorWidthKey` got `null` injected or if in rich workspace or mobile view + if (isFullWidth === null || isRichWorkspace || isMobile.value) { return { canToggleWidth: false } } const setFullWidth = (checked: boolean) => { diff --git a/src/declarations.d.ts b/src/declarations.d.ts index f741c0d8e0b..8b262647e4b 100644 --- a/src/declarations.d.ts +++ b/src/declarations.d.ts @@ -7,3 +7,8 @@ declare module '*?raw' { const content: string export default content } + +declare module '@nextcloud/vue/composables/useIsMobile' { + import { Ref } from 'vue' + export function useIsMobile(): Ref +}