Add browser upload and viewer HTML resolution for HTML/Markdown
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 3s

ingestHtmlFromFile and ingestMarkdownFromFile store session bytes with
correct content types. resolveDomViewerHtml renders sanitized HTML or
markdown paragraphs for HtmlViewerAdapter (EANCH-WP-0004).
This commit is contained in:
tegwick 2026-07-09 09:58:41 +02:00
parent 4999ea31f2
commit d605bf64be
5 changed files with 112 additions and 4 deletions

View file

@ -25,7 +25,11 @@ export interface PdfByteRecord {
}
export interface PdfByteStore {
put(documentId: DocumentId, bytes: Uint8Array): PdfByteRecord;
put(
documentId: DocumentId,
bytes: Uint8Array,
contentType?: string,
): PdfByteRecord;
get(documentId: DocumentId): PdfByteRecord | null;
has(documentId: DocumentId): boolean;
delete(documentId: DocumentId): boolean;
@ -70,7 +74,7 @@ export function createPdfByteStore(
const records = new Map<DocumentId, PdfByteRecord>();
return {
put(documentId, bytes) {
put(documentId, bytes, contentType = "application/pdf") {
// Replace previous record (revoking the prior URL) if any.
const prior = records.get(documentId);
if (prior) revokeUrl(prior.blobUrl);
@ -79,7 +83,7 @@ export function createPdfByteStore(
// refuses without help. The bytes here always come from a fresh
// arrayBuffer() call, so a regular ArrayBuffer is guaranteed.
const blob = new Blob([bytes as unknown as ArrayBuffer], {
type: "application/pdf",
type: contentType,
});
const blobUrl = createUrl(blob);
const record: PdfByteRecord = { bytes, blobUrl };