fix(workspace): 修复 Markdown 预览和编辑
Taskr: 2026-05-12-fix-workspace-preview-markdown-editing
This commit is contained in:
parent
6315f9ccae
commit
e513ce9c5d
@ -327,14 +327,16 @@ const fullscreenPreviewVisible = ref(false)
|
|||||||
const htmlPreviewRenderKey = ref(0)
|
const htmlPreviewRenderKey = ref(0)
|
||||||
|
|
||||||
const isMarkdown = computed(() => isMarkdownPreview(props.filePath, props.file?.previewType))
|
const isMarkdown = computed(() => isMarkdownPreview(props.filePath, props.file?.previewType))
|
||||||
const canEdit = computed(
|
const canEdit = computed(() => {
|
||||||
() =>
|
const previewType = props.file?.previewType
|
||||||
|
return (
|
||||||
props.editable &&
|
props.editable &&
|
||||||
props.file?.supported !== false &&
|
props.file?.supported !== false &&
|
||||||
typeof props.file?.content === 'string' &&
|
typeof props.file?.content === 'string' &&
|
||||||
props.file?.previewType === 'text' &&
|
(previewType === 'text' || previewType === 'markdown') &&
|
||||||
(props.editAllText || EDITABLE_EXTENSIONS.has(getPreviewFileExtension(props.filePath)))
|
(props.editAllText || EDITABLE_EXTENSIONS.has(getPreviewFileExtension(props.filePath)))
|
||||||
)
|
)
|
||||||
|
})
|
||||||
const savedContent = computed(() => formatContent(props.file?.content))
|
const savedContent = computed(() => formatContent(props.file?.content))
|
||||||
const draftChanged = computed(() => draftContent.value !== savedContent.value)
|
const draftChanged = computed(() => draftContent.value !== savedContent.value)
|
||||||
const isHtmlFile = computed(
|
const isHtmlFile = computed(
|
||||||
|
|||||||
@ -145,7 +145,13 @@ const ensureLanguages = async (highlighter, languages) => {
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
languages
|
languages
|
||||||
.filter((language) => !loaded.has(language))
|
.filter((language) => !loaded.has(language))
|
||||||
.map((language) => highlighter.loadLanguage(language).catch(() => null))
|
.map((language) => {
|
||||||
|
try {
|
||||||
|
return highlighter.loadLanguage(language).catch(() => null)
|
||||||
|
} catch {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user