mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Updated analytics event for visual bibtex editor
GitOrigin-RevId: ccca1ba7f60a7fa63a41866f780fbb73441b0c9a
This commit is contained in:
committed by
Copybot
parent
b7f140ba0b
commit
a7621a99c4
@@ -12,6 +12,7 @@ import { useProjectContext } from '@/shared/context/project-context'
|
||||
import { useIdeReactContext } from '@/features/ide-react/context/ide-react-context'
|
||||
import { useEditorManagerContext } from '@/features/ide-react/context/editor-manager-context'
|
||||
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
||||
import { useEditorPropertiesContext } from '@/features/ide-react/context/editor-properties-context'
|
||||
import {
|
||||
FileTreeDocumentFindResult,
|
||||
FileTreeFileRefFindResult,
|
||||
@@ -22,6 +23,7 @@ import { convertFileRefToBinaryFile } from '@/features/ide-react/util/file-view'
|
||||
import { sendMB } from '@/infrastructure/event-tracking'
|
||||
import { FileRef } from '../../../../../types/file-ref'
|
||||
import { useLayoutContext } from '@/shared/context/layout-context'
|
||||
import { isVisualEditorAvailable } from '@/features/source-editor/utils/visual-editor'
|
||||
|
||||
const FileTreeOpenContext = createContext<
|
||||
| {
|
||||
@@ -47,6 +49,7 @@ export const FileTreeOpenProvider: FC<React.PropsWithChildren> = ({
|
||||
const { eventEmitter, projectJoined } = useIdeReactContext()
|
||||
const { openDocWithId, openInitialDoc } = useEditorManagerContext()
|
||||
const { currentDocumentId } = useEditorOpenDocContext()
|
||||
const { showVisual } = useEditorPropertiesContext()
|
||||
const { setOpenFile } = useLayoutContext()
|
||||
const [openEntity, setOpenEntity] = useState<
|
||||
FileTreeDocumentFindResult | FileTreeFileRefFindResult | null
|
||||
@@ -89,6 +92,11 @@ export const FileTreeOpenProvider: FC<React.PropsWithChildren> = ({
|
||||
}
|
||||
|
||||
setOpenEntity(selected)
|
||||
const editorMode =
|
||||
isVisualEditorAvailable(selected.entity.name) && showVisual
|
||||
? 'visual'
|
||||
: 'code'
|
||||
|
||||
if (selected.type === 'doc' && fileTreeReady) {
|
||||
openDocWithId(selected.entity._id, { keepCurrentView: true })
|
||||
if (selected.entity.name.endsWith('.bib')) {
|
||||
@@ -96,6 +104,7 @@ export const FileTreeOpenProvider: FC<React.PropsWithChildren> = ({
|
||||
projectOwner,
|
||||
isSampleFile: selected.entity.name === 'sample.bib',
|
||||
linkedFileProvider: null,
|
||||
editorMode,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -112,12 +121,13 @@ export const FileTreeOpenProvider: FC<React.PropsWithChildren> = ({
|
||||
isSampleFile: false,
|
||||
linkedFileProvider: (selected.entity as FileRef).linkedFileData
|
||||
?.provider,
|
||||
editorMode,
|
||||
})
|
||||
}
|
||||
window.dispatchEvent(new CustomEvent('file-view:file-opened'))
|
||||
}
|
||||
},
|
||||
[fileTreeReady, setOpenFile, openDocWithId, projectOwner]
|
||||
[fileTreeReady, openDocWithId, projectOwner, setOpenFile, showVisual]
|
||||
)
|
||||
|
||||
const handleFileTreeDelete = useCallback(
|
||||
|
||||
@@ -4,6 +4,7 @@ import { sendMB } from '../../../infrastructure/event-tracking'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
||||
import { useEditorPropertiesContext } from '@/features/ide-react/context/editor-properties-context'
|
||||
import { getFileExtension } from '../utils/file'
|
||||
import { isVisualEditorAvailable } from '../utils/visual-editor'
|
||||
|
||||
function EditorSwitch() {
|
||||
@@ -16,6 +17,7 @@ function EditorSwitch() {
|
||||
const richTextAvailable = openDocName
|
||||
? isVisualEditorAvailable(openDocName)
|
||||
: false
|
||||
const extension = getFileExtension(openDocName || '')
|
||||
|
||||
const handleChange = useCallback(
|
||||
(event: ChangeEvent<HTMLInputElement>) => {
|
||||
@@ -31,9 +33,9 @@ function EditorSwitch() {
|
||||
break
|
||||
}
|
||||
|
||||
sendMB('editor-switch-change', { editorType })
|
||||
sendMB('editor-switch-change', { editorType, extension })
|
||||
},
|
||||
[setVisual]
|
||||
[extension, setVisual]
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user