Add Markdown visual editor support

GitOrigin-RevId: 4ec2ffb276c729a58f82ccb26ed571f4187a4178
This commit is contained in:
Domagoj Kriskovic
2026-06-04 08:06:04 +00:00
committed by Copybot
parent e38f4e18e4
commit 5cf1b43ce7
10 changed files with 45 additions and 9 deletions
@@ -2,13 +2,37 @@ import importOverleafModules from '../../../../macros/import-overleaf-module.mac
import { isValidTeXFile } from '../../../main/is-valid-tex-file'
const visualEditorProviders = importOverleafModules('visualEditorProviders')
const cmVisualEditorProviders = importOverleafModules(
'sourceEditorVisualExtensions'
)
export function isVisualEditorAvailable(filename: string): boolean {
// Core LaTeX visual editor
/**
* This currently covers LaTeX and Markdown. Other file
* types (e.g. .bib) use module-provided visual editors that render their own
* component instead, so they must NOT enable the CodeMirror visual extensions.
*/
export function isCmVisualEditorAvailable(filename: string): boolean {
if (isValidTeXFile(filename)) {
return true
}
for (const provider of cmVisualEditorProviders) {
if (provider.import.isCmVisualEditorFile?.(filename)) {
return true
}
}
return false
}
/**
* Whether any visual editor exists for the file, including module-provided
* ones. Drives the editor toggle UI and the default editor mode for a file.
*/
export function isVisualEditorAvailable(filename: string): boolean {
if (isCmVisualEditorAvailable(filename)) {
return true
}
// Visual editors provided by modules
for (const provider of visualEditorProviders) {
if (provider.import.isVisualEditorAvailable(filename)) {