mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #35725 from overleaf/ds-unable-to-sync-modal
[WEB] adds unable-to-sync modal for intermittent connection improvements GitOrigin-RevId: 4cd85cf742cb3f36cc0c97f83bdeab09bb6f7c53
This commit is contained in:
+2
-9
@@ -3,6 +3,7 @@ import { useCodeMirrorViewContext } from '../codemirror-context'
|
||||
import { useCallback } from 'react'
|
||||
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { downloadFileContent } from '@/utils/download-file'
|
||||
|
||||
const DownloadFileButton = () => {
|
||||
const view = useCodeMirrorViewContext()
|
||||
@@ -11,15 +12,7 @@ const DownloadFileButton = () => {
|
||||
|
||||
const downloadFile = useCallback(() => {
|
||||
const doc = view.state.doc.toString()
|
||||
const blob = new Blob([doc], { type: 'application/octet-stream' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = openDocName ?? 'document.txt'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
setTimeout(() => URL.revokeObjectURL(url), 0)
|
||||
downloadFileContent(doc, openDocName ?? 'document.txt')
|
||||
}, [view, openDocName])
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user