Internal file paths are now Markdown image paths
In the last commit, file paths were implemented to be the full path for the API, however that is not necessary. Before this change: /data/assets/filename.svg After: assets/filename.svg The new method is what SiYuan uses for Markdown images, like 
This commit is contained in:
parent
a2503d5def
commit
5e51589ffa
8 changed files with 66 additions and 14 deletions
|
@ -74,15 +74,20 @@ export function findImgSrc(element: HTMLElement): string | null {
|
|||
return null;
|
||||
}
|
||||
|
||||
export function imgSrcToAbsolutePath(imgSrc: string | null): string | null {
|
||||
export function imgSrcToPath(imgSrc: string | null): string | null {
|
||||
if (!imgSrc) return null;
|
||||
|
||||
const url = new URL(imgSrc);
|
||||
imgSrc = decodeURIComponent(url.pathname);
|
||||
|
||||
if(imgSrc.startsWith('/assets/')) {
|
||||
return "/data" + imgSrc;
|
||||
return imgSrc.substring(1);
|
||||
}
|
||||
return null
|
||||
|
||||
}
|
||||
|
||||
// Helper to safely escape regex special characters
|
||||
export function escapeRegExp(string: string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue