fix: restore embedded wiki images and optimize vector sync
This commit is contained in:
1 parent
30943159bf
commit
0c5e2e8cb0
23 files changed
+609
-136
No files matched your search
@@ -37,6 +37,34 @@ const WIKI_INDEX_TYPE_LABELS: Record<string, string> = {
|
||||
|
||||
const WIKI_INDEX_TYPE_ORDER = ["summary", "entity", "concept"];
|
||||
|
||||
export const WIKI_PROTECTED_IMAGE_MARKER = "/__llmwiki-protected-image__";
|
||||
|
||||
const PROTECTED_WIKI_IMAGE_SOURCE =
|
||||
/(?:storage:\/\/[0-9A-Za-z_-]+\/)?(?:resource|local|minio|cos|tos|s3|oss|ks3|obs):\/\/[^\s"'<>\])]+/gi;
|
||||
|
||||
/**
|
||||
* Browsers cannot load WeKnora's protected resource:// and object-storage
|
||||
* schemes directly. Replace them with a safe marker before Markdown
|
||||
* sanitization; the image component resolves that marker through DeerFlow.
|
||||
*/
|
||||
export function rewriteProtectedWikiImageSources(markdown: string): string {
|
||||
return markdown.replace(
|
||||
PROTECTED_WIKI_IMAGE_SOURCE,
|
||||
(filePath) => `${WIKI_PROTECTED_IMAGE_MARKER}?file_path=${encodeURIComponent(filePath)}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function parseProtectedWikiImageSource(source: string | undefined): string | null {
|
||||
if (!source) return null;
|
||||
try {
|
||||
const url = new URL(source, window.location.origin);
|
||||
if (url.pathname !== WIKI_PROTECTED_IMAGE_MARKER) return null;
|
||||
return url.searchParams.get("file_path")?.trim() || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function stripWikiFrontmatter(value: string) {
|
||||
return value.replace(/^\s*---\s*\n[\s\S]*?\n---\s*(?:\n|$)/, "").trim();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user