Enable SafeHTMLViewer to leverage ContentViewer plugins
Open
rtibbles
opened this issue 3 months ago
•
0 comments
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Current behavior
Currently, the Safe HTML viewer can only display static HTML content. When HTML content contains embedded media elements (<video>, <audio>, <object> tags, etc.), these are rendered as basic HTML elements without the rich functionality provided by Kolibri's specialized content viewer plugins (video player controls, progress tracking, subtitles, transcripts, PDF viewer features, etc.).
Desired behavior
Dynamic viewer injection: Allow Safe HTML content to automatically use appropriate Kolibri content viewers (media player, PDF viewer, etc.) when encountering compatible embedded elements
Full feature parity: Embedded media should have all the capabilities of their standalone viewers (progress tracking, interactive controls, captions, etc.) - SafeHTMLViewer should be able to aggregate progress across embedded viewers
Clean separation of concerns: Viewer components should work identically whether instantiated from a contentNode props or a DOM element, without needing to know the difference
Extensibility: New viewer types should automatically work in Safe HTML contexts with only element handling code required
High-Level Technical Implementation
Backend: Viewer Capability Declaration
Extend ContentRendererHook with css_selectors tuple and allow_object_tag flag
Each viewer plugin declares which DOM elements/MIME types it can handle
Auto-generate object[type="mimetype"] selectors from preset formats
Serialize capability data to frontend via hook registration