Files
Hermes 88d618b58a htmlviewer-directediting: HTML rendering in Nextcloud iOS app
- 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
2026-09-11 12:19:44 +00:00

44 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 HtmlViewer / patch by Hermes Agent
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* Bridge called from OCA\Text\DirectEditing\TextDirectEditor::open()
* for text/html files. Reuses the htmlviewer DirectEditing template
* so the mobile apps (hard-coded editor registry) render HTML in a
* sandboxed iframe instead of showing source via QuickLook.
*/
namespace OCA\HtmlViewer\DirectEditing;
use OCA\HtmlViewer\AppInfo\Application;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\DirectEditing\IToken;
use OCP\Server;
class HtmlDirectEditorBridge {
public static function openHtml(IToken $token): Response {
try {
$file = $token->getFile();
return new TemplateResponse(
Application::APP_ID,
'directEditing',
[
'fileId' => $file->getId(),
'fileName' => $file->getName(),
'fileContent' => $file->getContent(),
],
'base'
);
} catch (\Throwable) {
return new NotFoundResponse();
}
}
}