From e513ce9c5d390936e2dcd44d0b77a5be55c22dfe Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Tue, 12 May 2026 14:30:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(workspace):=20=E4=BF=AE=E5=A4=8D=20Markdown?= =?UTF-8?q?=20=E9=A2=84=E8=A7=88=E5=92=8C=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Taskr: 2026-05-12-fix-workspace-preview-markdown-editing --- web/src/components/AgentFilePreview.vue | 10 ++++++---- web/src/utils/markdown_preview.js | 8 +++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/web/src/components/AgentFilePreview.vue b/web/src/components/AgentFilePreview.vue index 9da2651a..daa5fd9f 100644 --- a/web/src/components/AgentFilePreview.vue +++ b/web/src/components/AgentFilePreview.vue @@ -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( diff --git a/web/src/utils/markdown_preview.js b/web/src/utils/markdown_preview.js index e048c93d..e80e829a 100644 --- a/web/src/utils/markdown_preview.js +++ b/web/src/utils/markdown_preview.js @@ -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 + } + }) ) }