fix(workspace): 修复 Markdown 预览和编辑

Taskr: 2026-05-12-fix-workspace-preview-markdown-editing
This commit is contained in:
Wenjie Zhang 2026-05-12 14:30:28 +08:00
parent 6315f9ccae
commit e513ce9c5d
2 changed files with 13 additions and 5 deletions

View File

@ -327,14 +327,16 @@ const fullscreenPreviewVisible = ref(false)
const htmlPreviewRenderKey = ref(0)
const isMarkdown = computed(() => isMarkdownPreview(props.filePath, props.file?.previewType))
const canEdit = computed(
() =>
const canEdit = computed(() => {
const previewType = props.file?.previewType
return (
props.editable &&
props.file?.supported !== false &&
typeof props.file?.content === 'string' &&
props.file?.previewType === 'text' &&
(previewType === 'text' || previewType === 'markdown') &&
(props.editAllText || EDITABLE_EXTENSIONS.has(getPreviewFileExtension(props.filePath)))
)
)
})
const savedContent = computed(() => formatContent(props.file?.content))
const draftChanged = computed(() => draftContent.value !== savedContent.value)
const isHtmlFile = computed(

View File

@ -145,7 +145,13 @@ const ensureLanguages = async (highlighter, languages) => {
await Promise.all(
languages
.filter((language) => !loaded.has(language))
.map((language) => highlighter.loadLanguage(language).catch(() => null))
.map((language) => {
try {
return highlighter.loadLanguage(language).catch(() => null)
} catch {
return null
}
})
)
}