From ef8641b876d3442c666e6eaeb7184f2c998e96f7 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Fri, 16 Jan 2026 07:53:54 -0500 Subject: [PATCH] Merge pull request #30774 from overleaf/em-bibtex-editor-list Show list of entries in bibtex visual editor GitOrigin-RevId: 2038f70c8c5b73547764d4f9ad535596f3faaf8f --- .../components/editor-switch.tsx | 50 ++++++++++--------- .../hooks/use-codemirror-scope.ts | 5 +- 2 files changed, 29 insertions(+), 26 deletions(-) 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')} > -
- Editor mode. +
+
+ Editor mode. - - + + - -
+ +
+ ) } @@ -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,