mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
Disable spell check setting when doc is read-only (#21253)
GitOrigin-RevId: 1053fefd953d4f60b1c2aef4170f99c6885c265d
This commit is contained in:
parent
baed6cc291
commit
98bf2ac055
3 changed files with 9 additions and 4 deletions
|
@ -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'}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,6 @@ export class SpellChecker {
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this._clearPendingSpellCheck()
|
this._clearPendingSpellCheck()
|
||||||
// this.hunspellManager?.destroy()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_abortRequest() {
|
_abortRequest() {
|
||||||
|
|
|
@ -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'
|
||||||
|
|
Loading…
Reference in a new issue