diff --git a/services/web/app/src/Features/Editor/EditorHttpController.js b/services/web/app/src/Features/Editor/EditorHttpController.js index 8efdc23d89..5cdc205320 100644 --- a/services/web/app/src/Features/Editor/EditorHttpController.js +++ b/services/web/app/src/Features/Editor/EditorHttpController.js @@ -13,8 +13,6 @@ const Errors = require('../Errors/Errors') const DocstoreManager = require('../Docstore/DocstoreManager') const logger = require('@overleaf/logger') const { expressify } = require('@overleaf/promise-utils') -const Settings = require('@overleaf/settings') -const SplitTestHandler = require('../SplitTests/SplitTestHandler') module.exports = { joinProject: expressify(joinProject), @@ -29,6 +27,28 @@ module.exports = { _nameIsAcceptableLength, } +const unsupportedSpellcheckLanguages = [ + 'am', + 'hy', + 'bn', + 'gu', + 'he', + 'hi', + 'hu', + 'is', + 'kn', + 'ml', + 'mr', + 'or', + 'ss', + 'ta', + 'te', + 'uk', + 'uz', + 'zu', + 'fi', +] + async function joinProject(req, res, next) { const projectId = req.params.Project_id let userId = req.body.userId // keep schema in sync with router @@ -56,39 +76,15 @@ async function joinProject(req, res, next) { if (project.deletedByExternalDataSource) { await ProjectDeleter.promises.unmarkAsDeletedByExternalSource(projectId) } - - let spellCheckClient - try { - spellCheckClient = - (await SplitTestHandler.promises.getAssignment( - req, - res, - 'spell-check-client' - )?.variant) === 'enabled' - } catch { - spellCheckClient = false + // disable spellchecking for currently unsupported spell check languages + // preserve the value in the db so they can use it again once we add back + // support. + // TODO: allow these if in client-side spell check split test + if ( + unsupportedSpellcheckLanguages.indexOf(project.spellCheckLanguage) !== -1 + ) { + project.spellCheckLanguage = '' } - - let spellCheckNoServer - try { - spellCheckNoServer = - (await SplitTestHandler.promises.getAssignment( - req, - res, - 'spell-check-no-server' - )?.variant) === 'enabled' - } catch { - spellCheckNoServer = false - } - - if (project.spellCheckLanguage) { - project.spellCheckLanguage = await chooseSpellCheckLanguage( - project.spellCheckLanguage, - spellCheckClient, - spellCheckNoServer - ) - } - res.json({ project, privilegeLevel, @@ -290,55 +286,3 @@ async function deleteEntity(req, res, next) { ) res.sendStatus(204) } - -async function chooseSpellCheckLanguage( - spellCheckLanguage, - spellCheckClient = false, - spellCheckNoServer = false -) { - const supportedSpellCheckLanguages = new Set( - Settings.languages - // optionally only include languages which support client-side spell checking - .filter(language => { - if (!spellCheckClient) { - // only include spell-check languages that are available on the server - return language.server !== false - } - - if (spellCheckNoServer) { - // only include spell-check languages that are available in the client - return language.dic !== undefined - } - - return true - }) - .map(language => language.code) - ) - - if (supportedSpellCheckLanguages.has(spellCheckLanguage)) { - return spellCheckLanguage - } - - // Disable spell checking for currently unsupported spell check languages. - // Preserve the value in the database so they can use it again once we add back support. - - // existing behaviour: map all unsupported languages to "off" - if (!spellCheckNoServer) { - return '' - } - - // new behaviour: map some server-only languages to a specific variant - switch (spellCheckLanguage) { - case 'en': - // map "English" to "English (American)" - return 'en_US' - - case 'no': - // map "Norwegian" to "Norwegian (Bokmål)" - return 'nb_NO' - - default: - // map anything else to "off" - return '' - } -} diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index a836dac80d..e152a60f10 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -342,7 +342,6 @@ const _ProjectController = { 'default-visual-for-beginners', 'hotjar', 'spell-check-client', - 'spell-check-no-server', ].filter(Boolean) const getUserValues = async userId => diff --git a/services/web/config/settings.defaults.js b/services/web/config/settings.defaults.js index 78d253bb4b..fe040ac952 100644 --- a/services/web/config/settings.defaults.js +++ b/services/web/config/settings.defaults.js @@ -453,6 +453,7 @@ module.exports = { { code: 'an', dic: 'an_ES', name: 'Aragonese', server: false }, { code: 'ar', dic: 'ar', name: 'Arabic' }, { code: 'be_BY', dic: 'be_BY', name: 'Belarusian', server: false }, + { code: 'gl', dic: 'gl_ES', name: 'Galician' }, { code: 'eu', dic: 'eu', name: 'Basque' }, { code: 'bn_BD', dic: 'bn_BD', name: 'Bengali', server: false }, { code: 'bs_BA', dic: 'bs_BA', name: 'Bosnian', server: false }, @@ -468,7 +469,7 @@ module.exports = { { code: 'et', dic: 'et_EE', name: 'Estonian' }, { code: 'fo', dic: 'fo', name: 'Faroese' }, { code: 'fr', dic: 'fr', name: 'French' }, - { code: 'gl', dic: 'gl_ES', name: 'Galician', server: false }, + { code: 'gl_ES', dic: 'gl_ES', name: 'Galician', server: false }, { code: 'de', dic: 'de_DE', name: 'German' }, { code: 'de_AT', dic: 'de_AT', name: 'German (Austria)', server: false }, { @@ -510,6 +511,7 @@ module.exports = { code: 'pt_PT', dic: 'pt_PT', name: 'Portuguese (European)', + server: true, }, { code: 'pa', name: 'Punjabi' }, { code: 'ro', dic: 'ro_RO', name: 'Romanian' }, diff --git a/services/web/frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language.tsx b/services/web/frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language.tsx index 0d52ab4b49..896ca5ab62 100644 --- a/services/web/frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language.tsx +++ b/services/web/frontend/js/features/editor-left-menu/components/settings/settings-spell-check-language.tsx @@ -6,29 +6,27 @@ import SettingsMenuSelect from './settings-menu-select' import type { Optgroup } from './settings-menu-select' import { useFeatureFlag } from '@/shared/context/split-test-context' +// allow selection of spell-check languages that are only supported in the client-side spell checker +const showClientOnlyLanguages = true + export default function SettingsSpellCheckLanguage() { const { t } = useTranslation() const languages = getMeta('ol-languages') const spellCheckClientEnabled = useFeatureFlag('spell-check-client') - const spellCheckNoServer = useFeatureFlag('spell-check-no-server') const { spellCheckLanguage, setSpellCheckLanguage } = useProjectSettingsContext() const optgroup: Optgroup = useMemo(() => { - const options = (languages ?? []).filter(language => { - if (!spellCheckClientEnabled) { - // only include spell-check languages that are available on the server - return language.server !== false + const options = (languages ?? []).filter(lang => { + const clientOnly = lang.server === false + + if (clientOnly && !showClientOnlyLanguages) { + return false } - if (spellCheckNoServer) { - // only include spell-check languages that are available in the client - return language.dic !== undefined - } - - return true + return spellCheckClientEnabled || !clientOnly }) return { @@ -38,7 +36,7 @@ export default function SettingsSpellCheckLanguage() { label: language.name, })), } - }, [languages, spellCheckClientEnabled, spellCheckNoServer]) + }, [languages, spellCheckClientEnabled]) return (