Disable spell check if WebAssembly is not available (#23136)
GitOrigin-RevId: c209540579e0d8ff7f62dc66ff5d850450b18600
This commit is contained in:
+3
-2
@@ -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 { useEditorContext } from '@/shared/context/editor-context'
|
||||
import { supportsWebAssembly } from '@/utils/wasm'
|
||||
|
||||
export default function SettingsSpellCheckLanguage() {
|
||||
const { t } = useTranslation()
|
||||
@@ -30,12 +31,12 @@ export default function SettingsSpellCheckLanguage() {
|
||||
return (
|
||||
<SettingsMenuSelect
|
||||
onChange={setSpellCheckLanguage}
|
||||
value={spellCheckLanguage}
|
||||
value={supportsWebAssembly() ? spellCheckLanguage : ''}
|
||||
options={[{ value: '', label: t('off') }]}
|
||||
optgroup={optgroup}
|
||||
label={t('spell_check')}
|
||||
name="spellCheckLanguage"
|
||||
disabled={permissionsLevel === 'readOnly'}
|
||||
disabled={permissionsLevel === 'readOnly' || !supportsWebAssembly()}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@ import { globalIgnoredWords } from '@/features/dictionary/ignored-words'
|
||||
import { HunspellManager } from '@/features/source-editor/hunspell/HunspellManager'
|
||||
import { debugConsole } from '@/utils/debugging'
|
||||
import { learnedWords } from '@/features/source-editor/extensions/spelling/learned-words'
|
||||
import { supportsWebAssembly } from '@/utils/wasm'
|
||||
|
||||
export const useHunspell = (spellCheckLanguage: string | null) => {
|
||||
const [hunspellManager, setHunspellManager] = useState<HunspellManager>()
|
||||
|
||||
useEffect(() => {
|
||||
if (spellCheckLanguage) {
|
||||
if (spellCheckLanguage && supportsWebAssembly()) {
|
||||
const lang = (getMeta('ol-languages') ?? []).find(
|
||||
item => item.code === spellCheckLanguage
|
||||
)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export const supportsWebAssembly = () => typeof window.WebAssembly === 'object'
|
||||
Reference in New Issue
Block a user