Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/composables/useEditorWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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) => {
Expand Down
5 changes: 5 additions & 0 deletions src/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>
}
Loading