/**
* Image Reference Handler
*
* Detects and rewrites image references in ADO work item content.
*
* Two source forms are recognised:
* - HTML
(raw HTML, typically pre-conversion)
* - Markdown  (post Turndown conversion or hand-written)
*
* Each
/![] reference is parsed; if the URL points at an ADO work item
* attachment (`_apis/wit/attachments/{guid}`), we extract the GUID, fileName,
* and project GUID. Callers can then download the file and rewrite the source
* to a local relative path — or, on push, walk the manifest and rewrite local
* paths back to the original ADO URL.
*/
export interface AdoAttachmentRef {
/** Attachment GUID extracted from the URL path */
guid: string;
/** Filename inferred from the `fileName` query param or the alt text */
fileName: string;
/** Project GUID from the URL (e.g. e4476c68-75d1-4d4b-...) */
projectGuid?: string;
/** The full original URL */
originalUrl: string;
}
export interface ImageRef {
/** Original src/url string from the markdown or HTML */
originalSrc: string;
/** True when the src is an HTML
tag (vs markdown ![]()) */
isHtmlTag: boolean;
/** Index of the match in the source string (for ordered processing) */
index: number;
/** Length of the matched substring */
length: number;
/** Parsed ADO attachment metadata, when the URL is an ADO attachment */
adoAttachment?: AdoAttachmentRef;
}
/**
* Parse an ADO work item attachment URL.
*
* Recognised patterns:
* https://dev.azure.com/{org}/{projectGuid}/_apis/wit/attachments/{guid}?fileName=image.png&...
* https://dev.azure.com/{org}/_apis/wit/attachments/{guid}?fileName=image.png&...
*
* Returns null when the URL is not an ADO attachment URL.
*/
export declare function parseAdoAttachmentUrl(url: string): AdoAttachmentRef | null;
/**
* Extract every image reference from a string of HTML or markdown content.
*
* Returns refs in source order. Both HTML
tags and markdown ![]() are
* detected. Refs whose URL parses as an ADO attachment have `adoAttachment`
* populated.
*/
export declare function extractImageRefs(content: string): ImageRef[];
/**
* Rewrite image src/url values in content using a mapper function.
*
* The mapper receives the original src and the parsed ADO attachment (if any)
* and returns the new src to substitute. Returning null/undefined leaves the
* original src in place.
*
* Both HTML
and markdown  forms are rewritten.
*/
export declare function rewriteImageSrcs(content: string, mapper: (src: string, ado: AdoAttachmentRef | undefined) => string | null | undefined): string;
//# sourceMappingURL=image-handler.d.ts.map