- htmlviewer: IEditor + Bridge + srcdoc iframe template + content controller - text app: open() bridges text/html to htmlviewer template - idempotent install.sh for re-deployment after app updates - iPhone-tested 2026-09-11
56 lines
2.6 KiB
Markdown
56 lines
2.6 KiB
Markdown
# htmlviewer-directediting
|
|
|
|
Rendert HTML-Dateien in der **Nextcloud iOS/Android App** statt Quelltext (QuickLook) anzuzeigen.
|
|
|
|
## Warum das existiert
|
|
|
|
Die Mobile-Apps wählen den Editor für eine Datei über die Server-Capabilities
|
|
(`/ocs/v2.php/apps/files/api/v1/directEditing`) und haben eine **hartcodierte
|
|
Editor-Registry** (`NCDirectEditorAdapter` in nextcloud/ios): nur `text`,
|
|
`eurooffice`, `onlyoffice`, `richdocuments`, `whiteboard` sind bekannt. Ein neuer
|
|
Server-Editor mit eigener ID (z.B. `htmlviewer`) wird von der App nicht aufgelöst
|
|
→ Fallback auf QuickLook → HTML-Quelltext.
|
|
|
|
## Lösung (2 Patches)
|
|
|
|
1. **htmlviewer** (custom_apps): registriert einen `IEditor` (`HtmlDirectEditor`)
|
|
mit Mimetype `text/html` + Bridge-Klasse, Template mit sandboxed iframe
|
|
(`srcdoc` — Inhalt direkt eingebettet, kein Cookie-Problem in mobilen
|
|
WebViews) und Content-Controller.
|
|
2. **text** (Core-App, gepatcht):
|
|
- `open()` leitet `text/html` an die htmlviewer-Bridge um
|
|
(`HtmlDirectEditorBridge::openHtml`) — die iOS-App wählt Editor `text`
|
|
(registry-bekannt), der Server liefert aber das HTML-Template.
|
|
- `text/html` bleibt in der Mimetypeliste der Text-App (wichtig!).
|
|
|
|
Bei Nextcloud-Core selbst (lib/, config) wurde **nichts** geändert.
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
./install.sh nextcloud1-app-1
|
|
```
|
|
|
|
Idempotent, kann nach jedem htmlviewer-/Nextcloud-Update neu laufen.
|
|
Backup des Original-TextDirectEditor landet unter `/tmp/TextDirectEditor.php.bak-htmlproject` im Container.
|
|
|
|
## Nach App-Updates neu nötig
|
|
|
|
- htmlviewer-App-Update überschreibt `lib/DirectEditing/`, `templates/`, `Application.php`-Registrierung → `install.sh` erneut
|
|
- Nextcloud-Update überschreibt `apps/text/.../TextDirectEditor.php` → `install.sh` erneut
|
|
|
|
## Dateien
|
|
|
|
- `patches/htmlviewer/HtmlDirectEditor.php` — IEditor-Implementierung (DirectEditing-Registrierung, für Web-Client/Wiederverwendung)
|
|
- `patches/htmlviewer/HtmlDirectEditorBridge.php` — statische Bridge, von TextDirectEditor aufgerufen
|
|
- `patches/htmlviewer/DirectController.php` — `/apps/htmlviewer/direct/{fileId}` Content-Endpoint (NoAdminRequired, Session)
|
|
- `patches/htmlviewer/RegisterDirectEditorListener.php` — RegisterDirectEditorEvent-Listener
|
|
- `patches/htmlviewer/directEditing-template.php` — Template: Fullscreen-iframe mit srcdoc + sandbox
|
|
- `patches/htmlviewer/patch_app.py` — idempotente Registrierung in Application.php + routes.php
|
|
- `patches/text/TextDirectEditor.php` — gepatchte Text-App (open()-Bridge)
|
|
- `install.sh` — Installer
|
|
|
|
## Status (2026-09-11)
|
|
|
|
Auf nextcloud1 (Nextcloud 34.0.2, htmlviewer 33.0.0) deployed und iPhone-getestet:
|
|
HTML rendert in der iOS-App in sandboxed WebView. |