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 012a785ae3..0f7c64d3a2 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
@@ -1,4 +1,4 @@
-import { ChangeEvent, FC, memo, useCallback } from 'react'
+import { ChangeEvent, FC, memo, useCallback, useId } from 'react'
import OLTooltip from '@/shared/components/ol/ol-tooltip'
import { sendMB } from '../../../infrastructure/event-tracking'
import { useTranslation } from 'react-i18next'
@@ -11,6 +11,7 @@ function EditorSwitch() {
const { showVisual: visual, setShowVisual: setVisual } =
useEditorPropertiesContext()
const { openDocName } = useEditorOpenDocContext()
+ const inputId = useId()
const richTextAvailable = openDocName
? isVisualEditorAvailable(openDocName)
@@ -40,28 +41,30 @@ function EditorSwitch() {
className="editor-toggle-switch"
aria-label={t('toolbar_code_visual_editor_switch')}
>
-
+
)
}
@@ -72,6 +75,7 @@ const RichTextToggle: FC<{
handleChange: (event: ChangeEvent) => void
}> = ({ checked, disabled, handleChange }) => {
const { t } = useTranslation()
+ const inputId = useId()
const toggle = (
@@ -79,13 +83,13 @@ const RichTextToggle: FC<{
type="radio"
name="editor"
value="rich-text"
- id="editor-switch-rich-text"
+ id={inputId}
className="toggle-switch-input"
checked={checked}
onChange={handleChange}
disabled={disabled}
/>
-
diff --git a/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts b/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts
index 058bb17cbf..e979347134 100644
--- a/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts
+++ b/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts
@@ -61,8 +61,8 @@ import { beforeChangeDocEffect } from '@/features/source-editor/extensions/befor
import { useActiveOverallTheme } from '@/shared/hooks/use-active-overall-theme'
import { useEditorSelectionContext } from '@/shared/context/editor-selection-context'
import { useActiveEditorTheme } from '@/shared/hooks/use-active-editor-theme'
-import { isVisualEditorAvailable } from '../utils/visual-editor'
import { useFeatureFlag } from '@/shared/context/split-test-context'
+import { isValidTeXFile } from '@/main/is-valid-tex-file'
function useCodeMirrorScope(view: EditorView) {
const { fileTreeData } = useFileTreeData()
@@ -276,8 +276,7 @@ function useCodeMirrorScope(view: EditorView) {
const { previewByPath } = useFileTreePathContext()
- const showVisual =
- visual && !!openDocName && isVisualEditorAvailable(openDocName)
+ const showVisual = visual && !!openDocName && isValidTeXFile(openDocName)
const visualRef = useRef({
previewByPath,