From 035b5cd4562fb99248c7c182ef00dbc3786d83c3 Mon Sep 17 00:00:00 2001 From: June Kelly Date: Wed, 8 Feb 2023 11:02:01 +0000 Subject: [PATCH] Merge pull request #11263 from overleaf/ae-rich-text-available Only enable the Rich Text option for supported file extensions GitOrigin-RevId: ae67435b50701bb5be71bab94d8c3c4da4129d88 --- .../js/features/source-editor/components/editor-switch.tsx | 6 +++++- services/web/frontend/stylesheets/app/editor/toolbar.less | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx index 941738be9e..b54491292f 100644 --- a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx +++ b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx @@ -4,6 +4,7 @@ import Tooltip from '../../../shared/components/tooltip' import { sendMB } from '../../../infrastructure/event-tracking' import getMeta from '../../../utils/meta' import SplitTestBadge from '../../../shared/components/split-test-badge' +import isValidTeXFile from '../../../main/is-valid-tex-file' function Badge() { const content = ( @@ -48,7 +49,9 @@ function EditorSwitch() { const [visual, setVisual] = useScopeValue('editor.showVisual') - const richTextOrVisual = richText || visual + const [docName] = useScopeValue('editor.open_doc_name') + const richTextAvailable = isValidTeXFile(docName) + const richTextOrVisual = richText || (richTextAvailable && visual) const handleChange = useCallback( event => { @@ -130,6 +133,7 @@ function EditorSwitch() { className="toggle-switch-input" checked={!!richTextOrVisual} onChange={handleChange} + disabled={!richTextAvailable} />