chore(backend): Aanpassingen Dwengo Learning-Object-Repository

Processing uit Dwengo Learning-Object-Repository geconverteerd naar TypeScript en aangepast aan onze app.

Functionaliteit van Dwengo Learning-Object-Repository in ons project gekopiëerd en deels aanBestanden die enkel types of interfaces exporteren hernoemd naar *.d.tsgepast aan TypeScript en ons project.
This commit is contained in:
Gerald Schmittinger 2025-03-07 23:20:57 +01:00
parent ba3da01d2d
commit 463c8c9fc0
45 changed files with 1258 additions and 3747 deletions

View file

@ -0,0 +1,24 @@
/**
* Based on https://github.com/dwengovzw/Learning-Object-Repository/blob/main/app/processors/image/inline_image_processor.js
*/
import Processor from "../processor.js";
import DOMPurify from 'isomorphic-dompurify';
import {DwengoContentType} from "../content-type.js";
import {ProcessingError} from "../processing-error.js";
import {isValidHttpUrl} from "../../../../util/links";
class InlineImageProcessor extends Processor<string> {
constructor(contentType: DwengoContentType = DwengoContentType.IMAGE_INLINE) {
super(contentType);
}
override renderFn(imageUrl: string) {
if (!isValidHttpUrl(imageUrl)) {
throw new ProcessingError(`Image URL is invalid: ${imageUrl}`);
}
return DOMPurify.sanitize(`<img src="${imageUrl}" alt="">`);
}
}
export default InlineImageProcessor;