Disable spell check setting when doc is read-only (#21253)

GitOrigin-RevId: 1053fefd953d4f60b1c2aef4170f99c6885c265d
This commit is contained in:
Alf Eaton 2024-10-22 12:23:36 +01:00 committed by Copybot
parent baed6cc291
commit 98bf2ac055
3 changed files with 9 additions and 4 deletions

View file

@ -5,6 +5,7 @@ import { useProjectSettingsContext } from '../../context/project-settings-contex
import SettingsMenuSelect from './settings-menu-select' import SettingsMenuSelect from './settings-menu-select'
import type { Optgroup } from './settings-menu-select' import type { Optgroup } from './settings-menu-select'
import { useFeatureFlag } from '@/shared/context/split-test-context' import { useFeatureFlag } from '@/shared/context/split-test-context'
import { useEditorContext } from '@/shared/context/editor-context'
export default function SettingsSpellCheckLanguage() { export default function SettingsSpellCheckLanguage() {
const { t } = useTranslation() const { t } = useTranslation()
@ -15,6 +16,7 @@ export default function SettingsSpellCheckLanguage() {
const { spellCheckLanguage, setSpellCheckLanguage } = const { spellCheckLanguage, setSpellCheckLanguage } =
useProjectSettingsContext() useProjectSettingsContext()
const { permissionsLevel } = useEditorContext()
const optgroup: Optgroup = useMemo(() => { const optgroup: Optgroup = useMemo(() => {
const options = (languages ?? []).filter(language => { const options = (languages ?? []).filter(language => {
@ -48,6 +50,7 @@ export default function SettingsSpellCheckLanguage() {
optgroup={optgroup} optgroup={optgroup}
label={t('spell_check')} label={t('spell_check')}
name="spellCheckLanguage" name="spellCheckLanguage"
disabled={permissionsLevel === 'readOnly'}
/> />
) )
} }

View file

@ -62,7 +62,6 @@ export class SpellChecker {
destroy() { destroy() {
this._clearPendingSpellCheck() this._clearPendingSpellCheck()
// this.hunspellManager?.destroy()
} }
_abortRequest() { _abortRequest() {

View file

@ -108,9 +108,12 @@ function useCodeMirrorScope(view: EditorView) {
'onlineUserCursorHighlights' 'onlineUserCursorHighlights'
) )
const [spellCheckLanguage] = useScopeValue<string>( let [spellCheckLanguage] = useScopeValue<string>('project.spellCheckLanguage')
'project.spellCheckLanguage' // spell check is off when read-only
) if (!permissions.write) {
spellCheckLanguage = ''
}
const [projectFeatures] = const [projectFeatures] =
useScopeValue<Record<string, boolean | string | number | undefined>>( useScopeValue<Record<string, boolean | string | number | undefined>>(
'project.features' 'project.features'