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

View file

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

View file

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