mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Add Markdown visual editor support
GitOrigin-RevId: 4ec2ffb276c729a58f82ccb26ed571f4187a4178
This commit is contained in:
committed by
Copybot
parent
e38f4e18e4
commit
5cf1b43ce7
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user