Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

feat: enhance image handling and UI adjustments in document components

wizardcheneb6f04b4ba47
diff --git a/frontend/src/components/ListSpaceSidebar.vue b/frontend/src/components/ListSpaceSidebar.vue
index 964d13eef..3eef94c85 100644
--- a/frontend/src/components/ListSpaceSidebar.vue
+++ b/frontend/src/components/ListSpaceSidebar.vue
@@ -289,9 +289,9 @@ onBeforeUnmount(() => {
.resize-handle {
position: absolute;
top: 0;
- right: -4px;
+ right: -6px;
bottom: 0;
- width: 8px;
+ width: 12px;
cursor: col-resize;
z-index: 12;
display: flex;
@@ -307,10 +307,10 @@ onBeforeUnmount(() => {
.resize-handle-line {
width: 2px;
- height: 32px;
+ height: 40px;
border-radius: 1px;
background: #c5cad1;
- opacity: 0;
+ opacity: 0.45;
transition: opacity 0.2s ease, background 0.2s ease;
}
diff --git a/frontend/src/components/doc-content.vue b/frontend/src/components/doc-content.vue
index c5a1944ff..b8e040a4f 100644
--- a/frontend/src/components/doc-content.vue
+++ b/frontend/src/components/doc-content.vue
@@ -7,7 +7,7 @@ import mermaid from "mermaid";
import { onMounted, ref, nextTick, onUnmounted, onUpdated, watch } from "vue";
import { downKnowledgeDetails, deleteGeneratedQuestion } from "@/api/knowledge-base/index";
import { MessagePlugin, DialogPlugin } from "tdesign-vue-next";
-import { sanitizeHTML, safeMarkdownToHTML, createSafeImage, isValidImageURL } from '@/utils/security';
+import { sanitizeHTML, safeMarkdownToHTML, createSafeImage, isValidImageURL, hydrateProtectedFileImages } from '@/utils/security';
import { openMermaidFullscreen } from '@/utils/mermaidViewer';
import { useI18n } from 'vue-i18n';
import DocumentPreview from '@/components/document-preview.vue';
@@ -269,7 +269,9 @@ const isMarkdownFile = (fileType?: string): boolean => {
};
watch(() => props.details.md, (newVal) => {
nextTick(async () => {
- const images = mdContentWrap.value.querySelectorAll('img.markdown-image');
+ const renderRoot = (doc as ParentNode) || mdContentWrap.value;
+ await hydrateProtectedFileImages(renderRoot);
+ const images = renderRoot?.querySelectorAll?.('img.markdown-image') as NodeListOf<HTMLImageElement> | undefined;
if (images) {
images.forEach(async item => {
const isValid = await checkImage(item.src);
diff --git a/frontend/src/utils/security.ts b/frontend/src/utils/security.ts
index ef6dd815c..a446539ba 100644
--- a/frontend/src/utils/security.ts
+++ b/frontend/src/utils/security.ts
@@ -123,7 +123,8 @@ function protectProviderImageSrcInHTML(html: string): string {
(_m, before, quote, provider, restPathRaw, after) => {
const restPath = decodeProviderURL(restPathRaw);
const protectedSrc = `${provider}://${restPath}`;
- return `<img${before} src=${quote}${PROVIDER_IMAGE_PLACEHOLDER}${quote} data-protected-src=${quote}${protectedSrc}${quote}${after}>`;
+ const fileProxyURL = `/files?${new URLSearchParams({ file_path: protectedSrc }).toString()}`;
+ return `<img${before} src=${quote}${fileProxyURL}${quote} data-protected-src=${quote}${protectedSrc}${quote}${after}>`;
},
);
}