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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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}>`;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user