Fix typst export 500, add export-as-latex for typst projects
Build and Deploy Verso / deploy (push) Successful in 10m4s
Build and Deploy Verso / deploy (push) Successful in 10m4s
- clsi-nginx: allow hyphens in project-id regex — conversion IDs are UUIDs which nginx was rejecting, causing 500 on file download after conversion - CLSI ConversionController/Manager: add 'latex' export type (typst→latex via pandoc) - Web: add 'latex' to SUPPORTED_CONVERSION_TYPES - Frontend: add Export as LaTeX button (visible only for typst projects) - Fix visibility logic: export-as-latex shows for typst, export-as-typst shows for latex - Add export_as_latex translation key (en + fr) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,7 @@ const CONVERSION_CONFIGS = {
|
||||
markdown: { extension: 'zip' },
|
||||
html: { extension: 'zip' },
|
||||
typst: { extension: 'typ' },
|
||||
latex: { extension: 'tex' },
|
||||
}
|
||||
|
||||
async function convertDocumentToLaTeX(req, res) {
|
||||
|
||||
@@ -191,6 +191,19 @@ const LATEX_EXPORT_CONFIGS = {
|
||||
'typst',
|
||||
],
|
||||
},
|
||||
latex: {
|
||||
fileExtension: 'tex',
|
||||
compressOutput: false,
|
||||
getPandocArgs: ({ outputPath }) => [
|
||||
'--output',
|
||||
outputPath,
|
||||
'--from',
|
||||
'typst',
|
||||
'--to',
|
||||
'latex',
|
||||
'--standalone',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
async function convertLaTeXToDocumentInDirWithLock(
|
||||
|
||||
@@ -21,6 +21,7 @@ const SUPPORTED_CONVERSION_TYPES = new Map([
|
||||
['markdown', 'zip'],
|
||||
['html', 'zip'],
|
||||
['typst', 'typ'],
|
||||
['latex', 'tex'],
|
||||
])
|
||||
|
||||
const exportProjectConversionSchema = z.object({
|
||||
@@ -100,14 +101,14 @@ async function exportProjectConversion(req, res) {
|
||||
{ compileFromHistory, rootResourcePath }
|
||||
)
|
||||
AnalyticsManager.recordEventForUserInBackground(userId, 'convert-format', {
|
||||
sourceFormat: 'latex',
|
||||
sourceFormat: type === 'latex' ? 'typst' : 'latex',
|
||||
targetFormat: type,
|
||||
status: 'success',
|
||||
operation: 'export',
|
||||
})
|
||||
} catch (error) {
|
||||
AnalyticsManager.recordEventForUserInBackground(userId, 'convert-format', {
|
||||
sourceFormat: 'latex',
|
||||
sourceFormat: type === 'latex' ? 'typst' : 'latex',
|
||||
targetFormat: type,
|
||||
status: 'failure',
|
||||
operation: 'export',
|
||||
|
||||
+5
-2
@@ -10,7 +10,7 @@ import { useProjectSettingsContext } from '@/features/editor-left-menu/context/p
|
||||
|
||||
type ExportProjectWithConversionProps = {
|
||||
featureFlag?: string
|
||||
conversionType: 'docx' | 'markdown' | 'html' | 'typst'
|
||||
conversionType: 'docx' | 'markdown' | 'html' | 'typst' | 'latex'
|
||||
label: string
|
||||
menuBarId: string
|
||||
}
|
||||
@@ -25,6 +25,9 @@ export const ExportProjectWithConversionButton: FC<
|
||||
const anonymous = getMeta('ol-anonymous')
|
||||
const { compiler } = useProjectSettingsContext()
|
||||
const isLatexProject = !['typst', 'quarto'].includes(compiler ?? '')
|
||||
// latex export is for converting Typst projects to LaTeX; all others are for LaTeX projects
|
||||
const isProjectTypeMatch =
|
||||
conversionType === 'latex' ? compiler === 'typst' : isLatexProject
|
||||
const getRootDocInfo = useRootDoc()
|
||||
const { openDocs } = useEditorManagerContext()
|
||||
const downloadConversion = useConvertProject(
|
||||
@@ -37,7 +40,7 @@ export const ExportProjectWithConversionButton: FC<
|
||||
splitTestEnabledIfNeeded &&
|
||||
enablePandocConversions &&
|
||||
!anonymous &&
|
||||
isLatexProject
|
||||
isProjectTypeMatch
|
||||
|
||||
useCommandProvider(
|
||||
() =>
|
||||
|
||||
@@ -98,6 +98,7 @@ export const ToolbarMenuBar = () => {
|
||||
'export-as-markdown',
|
||||
'export-as-html',
|
||||
'export-as-typst',
|
||||
'export-as-latex',
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -100,6 +100,11 @@ export const ToolbarProjectTitle = () => {
|
||||
label={t('export_as_typst')}
|
||||
menuBarId="export-as-typst"
|
||||
/>
|
||||
<ExportProjectWithConversionButton
|
||||
conversionType="latex"
|
||||
label={t('export_as_latex')}
|
||||
menuBarId="export-as-latex"
|
||||
/>
|
||||
<DropdownDivider />
|
||||
<DuplicateProject />
|
||||
<OLDropdownMenuItem
|
||||
|
||||
@@ -16,7 +16,7 @@ import { OpenDocuments } from '../editor/open-documents'
|
||||
const SLOW_CONVERSION_THRESHOLD = 2000
|
||||
|
||||
export default function useConvertProject(
|
||||
type: 'docx' | 'markdown' | 'html' | 'typst',
|
||||
type: 'docx' | 'markdown' | 'html' | 'typst' | 'latex',
|
||||
openDocs: OpenDocuments,
|
||||
getRootDocInfo: () => RootDocInfo
|
||||
) {
|
||||
|
||||
@@ -879,6 +879,7 @@
|
||||
"export_as_docx": "Export as Word document (.docx)",
|
||||
"export_as_html": "Export as HTML (.html)",
|
||||
"export_as_typst": "Export as Typst",
|
||||
"export_as_latex": "Export as LaTeX (.tex)",
|
||||
"export_as_markdown": "Export as Markdown (.md)",
|
||||
"export_csv": "Export CSV",
|
||||
"export_project_to_github": "Export Project to GitHub",
|
||||
|
||||
@@ -882,6 +882,7 @@
|
||||
"export_as_docx": "Exporter sous forme de document Word (.docx)",
|
||||
"export_as_html": "Exporter au format HTML (.html)",
|
||||
"export_as_typst": "Exporter en Typst",
|
||||
"export_as_latex": "Exporter en LaTeX (.tex)",
|
||||
"export_as_markdown": "Exporter en Markdown (.md)",
|
||||
"export_csv": "Exporter en CSV",
|
||||
"export_project_to_github": "Exporter le projet vers GitHub",
|
||||
|
||||
Reference in New Issue
Block a user