From 1061537667fc37e4a0c0500920cc680fe4af92af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 26 Mar 2020 15:06:11 +0100 Subject: Enable Text to be used by Viewer outside Files app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Nextcloud 18.0.4 the Files app triggers the "LoadViewer" event, so that event can be used to register Text with Viewer instead of doing it through the "OCA\Files::loadAdditionalScripts" event. Besides being more correct for the Files app it also makes possible to use Text when opening files through Viewer in other apps, like Talk. Note, however, that in public share pages Text is still opened using the fallback actions instead of through Viewer, as Viewer currently does not provide the share token of the public shared folder that contains the file to be opened. Signed-off-by: Daniel Calviño Sánchez --- lib/AppInfo/Application.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index c93bd28eb..70876a593 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace OCA\Text\AppInfo; use OCA\Text\DirectEditing\TextDirectEditor; +use OCA\Viewer\Event\LoadViewer; use OCP\AppFramework\App; use OCP\DirectEditing\RegisterDirectEditorEvent; use OCP\EventDispatcher\IEventDispatcher; @@ -69,6 +70,11 @@ class Application extends App { $event->register($editor); }); + $eventDispatcher->addListener(LoadViewer::class, function () { + \OCP\Util::addScript('text', 'viewer'); + \OCP\Util::addStyle('text', 'icons'); + }); + if ($this->userSession->isLoggedIn()) { $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function () { \OCP\Util::addScript('text', 'files'); -- cgit v1.2.3