diff --git a/appinfo/routes.php b/appinfo/routes.php index 7fe971659b..145af75a70 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -32,6 +32,7 @@ ['name' => 'document#remote', 'url' => 'remote', 'verb' => 'GET'], ['name' => 'document#createFromTemplate', 'url' => 'indexTemplate', 'verb' => 'GET'], ['name' => 'document#publicPage', 'url' => '/public', 'verb' => 'GET'], + ['name' => 'document#token', 'url' => '/token', 'verb' => 'POST'], ['name' => 'document#editOnline', 'url' => 'editonline', 'verb' => 'GET'], ['name' => 'document#editOnlineTarget', 'url' => 'editonline/{fileId}/{target}', 'verb' => 'GET'], diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index 783707c61e..eca057ba7d 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -148,7 +148,7 @@ public function extAppGetData(int $fileId) { * @param string|null $path * @return RedirectResponse|TemplateResponse */ - public function index($fileId, ?string $path = null) { + public function index($fileId, ?string $path = null, ?int $version = null) { try { $folder = $this->rootFolder->getUserFolder($this->uid); @@ -184,7 +184,7 @@ public function index($fileId, ?string $path = null) { $params = [ 'permissions' => $item->getPermissions(), 'title' => $item->getName(), - 'fileId' => $item->getId() . '_' . $this->config->getSystemValue('instanceid'), + 'fileId' => $item->getId() . '_' . $this->config->getSystemValue('instanceid') . ($version !== null ? '_' . $version : ''), 'token' => $token, 'token_ttl' => $wopi->getExpiry(), 'urlsrc' => $urlSrc, @@ -489,4 +489,17 @@ public function editOnlineTarget(int $fileId, ?string $target = null) { return $this->renderErrorPage('File not found', Http::STATUS_NOT_FOUND); } + + + + #[Http\Attribute\NoAdminRequired] + #[Http\Attribute\NoCSRFRequired] + public function token(int $fileId, ?string $shareToken = null) { + [$urlSrc, $token, $wopi] = $this->tokenManager->getToken((string)$fileId, $shareToken, $this->uid, false); + + return new Http\DataResponse([ + 'urlSrc' => $urlSrc, + ...$wopi->jsonSerialize(), + ]); + } } diff --git a/src/files.js b/src/files.js index 8833465dd2..0a526a5e97 100644 --- a/src/files.js +++ b/src/files.js @@ -111,7 +111,6 @@ const odfViewer = { $iframe.addClass('full') $('#content').addClass('full-height') $('footer').addClass('hidden') - $('#imgframe').addClass('hidden') $('#controls').addClass('hidden') $('#content').addClass('loading') } else { @@ -162,7 +161,6 @@ const odfViewer = { if (isPublic) { $('#content').removeClass('full-height') $('footer').removeClass('hidden') - $('#imgframe').removeClass('hidden') $('.directLink').removeClass('hidden') $('.directDownload').removeClass('hidden') } diff --git a/src/helpers/coolParameters.js b/src/helpers/coolParameters.js index f8fdba8a5d..ecbd46c148 100644 --- a/src/helpers/coolParameters.js +++ b/src/helpers/coolParameters.js @@ -47,7 +47,7 @@ const getUIDefaults = () => { } const getCollaboraTheme = () => { - return loadState('richdocuments', 'theme', '') + return loadState('richdocuments', 'theme', 'nextcloud') } const generateCSSVarTokens = () => { diff --git a/src/helpers/index.js b/src/helpers/index.js index 4a687cc937..ee740b4569 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -76,8 +76,17 @@ const splitPath = (path) => { return [directory, fileName] } +const getRandomId = (length = 5) => { + return Math.random() + .toString(36) + .replace(/[^a-z]+/g, '') + .slice(0, length || 5) + +} + export { languageToBCP47, getNextcloudVersion, splitPath, + getRandomId, } diff --git a/src/services/LoggedInPostMessageHandler.js b/src/services/LoggedInPostMessageHandler.js new file mode 100644 index 0000000000..a3e6cf3e0a --- /dev/null +++ b/src/services/LoggedInPostMessageHandler.js @@ -0,0 +1,40 @@ +import PostMessageHandler from './PostMessageHandler.js' + +export default class LoggedInPostMessageHandler extends PostMessageHandler { + + #context = null + + constructor(context) { + super() + this.#context = context + } + + Frame_Ready() {} + App_LoadingStatus() {} + Action_Load_Resp() {} + Clicked_Button() {} + UI_Share() { + this.#context.share() + } + + UI_Mention() {} + UI_Close() {} + UI_SaveAs() {} + Download_As() {} + Views_List() {} + Get_Views_Resp() {} + UI_ZoteroKeyMissing() {} + Action_loadRevViewer() {} + Action_Save_Resp() {} + File_Rename() {} + Action_GetLinkPreview() {} + UI_InsertGraphic() {} + UI_CreateFile() {} + UI_Paste() {} + UI_Hyperlink() {} + UI_FileVersions() {} + UI_PickLink() {} + App_VersionRestore() {} + Host_VersionRestore() {} + +} diff --git a/src/services/PostMessageHandler.js b/src/services/PostMessageHandler.js new file mode 100644 index 0000000000..703588e255 --- /dev/null +++ b/src/services/PostMessageHandler.js @@ -0,0 +1,35 @@ + +export default class PostMessageHandler { + + #context = null + + constructor(context) { + this.#context = context + } + + Frame_Ready() {} + App_LoadingStatus() {} + Action_Load_Resp() {} + Clicked_Button() {} + UI_Share() {} + UI_Mention() {} + UI_Close() {} + UI_SaveAs() {} + Download_As() {} + Views_List() {} + Get_Views_Resp() {} + UI_ZoteroKeyMissing() {} + Action_loadRevViewer() {} + Action_Save_Resp() {} + File_Rename() {} + Action_GetLinkPreview() {} + UI_InsertGraphic() {} + UI_CreateFile() {} + UI_Paste() {} + UI_Hyperlink() {} + UI_FileVersions() {} + UI_PickLink() {} + App_VersionRestore() {} + Host_VersionRestore() {} + +} diff --git a/src/view/Office.vue b/src/view/Office.vue index 3659d84abc..441ee1a050 100644 --- a/src/view/Office.vue +++ b/src/view/Office.vue @@ -21,78 +21,88 @@ -->