mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Cleanup editor-redesign-opt-out feature flag GitOrigin-RevId: 6a1dc6908fa6276181f9e3996e0b14cfb7537786
29 lines
948 B
TypeScript
29 lines
948 B
TypeScript
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
|
|
import getMeta from '@/utils/meta'
|
|
|
|
// For e2e tests purposes, allow overriding to old editor
|
|
export const oldEditorOverride =
|
|
new URLSearchParams(window.location.search).get('old-editor-override') ===
|
|
'true'
|
|
|
|
// We don't want to enable the new editor on server-pro/CE until we have fully rolled it out on SaaS
|
|
const { isOverleaf } = getMeta('ol-ExposedSettings')
|
|
|
|
export const canUseNewEditor = () => {
|
|
return isOverleaf && !oldEditorOverride
|
|
}
|
|
|
|
export const useIsNewEditorEnabled = () => {
|
|
const { userSettings } = useUserSettingsContext()
|
|
const hasAccess = canUseNewEditor()
|
|
const enabled = userSettings.enableNewEditor
|
|
return hasAccess && enabled
|
|
}
|
|
|
|
export const useIsNewToNewEditor = () => {
|
|
const { userSettings } = useUserSettingsContext()
|
|
const newEditor = useIsNewEditorEnabled()
|
|
|
|
return newEditor && !userSettings.enableNewEditorLegacy
|
|
}
|