feat: enhance image handling and UI adjustments in document components

- Added `hydrateProtectedFileImages` utility to improve the rendering of protected images in `doc-content.vue`.
- Updated the image query logic to utilize the new rendering root for better image management.
- Adjusted CSS properties in `ListSpaceSidebar.vue` for the resize handle and line, improving the user interface with better dimensions and visibility.

These changes enhance the functionality and user experience of document handling and sidebar interactions.
This commit is contained in:
wizardchen
2026-03-04 00:04:53 +08:00
committed by lyingbug
parent 58783ec96c
commit eb6f04b4ba
3 changed files with 10 additions and 7 deletions
+4 -4
View File
@@ -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;
}
+4 -2
View File
@@ -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);
+2 -1
View File
@@ -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}>`;
},
);
}