diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php
index 1703e032..c6dd0813 100644
--- a/controller/editorapicontroller.php
+++ b/controller/editorapicontroller.php
@@ -452,6 +452,12 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok
$params["_file_path"] = $userFolder->getRelativePath($file->getPath());
}
+ if ($inframe === true) {
+ $params["_files_sharing"] = \OC::$server->getAppManager()->isInstalled("files_sharing");
+ $params["editorConfig"]["customization"]["goback"]["requestClose"] = true;
+ $params["editorConfig"]["customization"]["goback"]["text"] = "Close";
+ }
+
if ($folderLink !== null
&& $this->config->GetSystemValue($this->config->_customization_goback) !== false) {
$params["editorConfig"]["customization"]["goback"] = [
@@ -469,10 +475,6 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok
}
}
- if ($inframe === true) {
- $params["_files_sharing"] = \OC::$server->getAppManager()->isInstalled("files_sharing");
- }
-
$params = $this->setCustomization($params);
$params = $this->setWatermark($params, !empty($shareToken), $userId, $file);
diff --git a/js/main.js b/js/main.js
index 797a7677..0f656db4 100644
--- a/js/main.js
+++ b/js/main.js
@@ -536,21 +536,10 @@
var editorUrl = OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/s/" + encodeURIComponent($("#sharingToken").val()));
- if (_oc_appswebroots.richdocuments
+ if (! (_oc_appswebroots.richdocuments
|| _oc_appswebroots.files_pdfviewer && extension === "pdf"
- || _oc_appswebroots.text && extension === "txt") {
+ || _oc_appswebroots.text && extension === "txt")) {
- var button = document.createElement("a");
- button.href = editorUrl;
- button.className = "onlyoffice-public-open button";
- button.innerText = t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE")
-
- if (!OCA.Onlyoffice.setting.sameTab) {
- button.target = "_blank";
- }
-
- $("#preview").prepend(button);
- } else {
OCA.Onlyoffice.frameSelector = "#onlyofficeFrame";
var $iframe = $("");
$("#app-content").append($iframe);
diff --git a/js/share.js b/js/share.js
new file mode 100644
index 00000000..f5a67e7c
--- /dev/null
+++ b/js/share.js
@@ -0,0 +1,102 @@
+/**
+ *
+ * (c) Copyright Ascensio System SIA 2022
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+(function (OCA) {
+
+ OCA.Onlyoffice = _.extend({
+ AppName: "onlyoffice",
+ context: null,
+ folderUrl: null,
+ frameSelector: null,
+ }, OCA.Onlyoffice);
+
+ OCA.Onlyoffice.setting = {};
+ OCA.Onlyoffice.mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini|Macintosh/i.test(navigator.userAgent)
+ && navigator.maxTouchPoints && navigator.maxTouchPoints > 1;
+
+ OCA.Onlyoffice.CloseEditor = function () {
+ OCA.Onlyoffice.frameSelector = null;
+
+ $("body").removeClass("onlyoffice-inline");
+
+ OCA.Onlyoffice.context = null;
+
+ var url = OCA.Onlyoffice.folderUrl;
+ if (!!url) {
+ window.history.pushState(null, null, url);
+ OCA.Onlyoffice.folderUrl = null;
+ }
+
+ };
+
+ OCA.Onlyoffice.GetSettings = function (callbackSettings) {
+ if (OCA.Onlyoffice.setting.formats) {
+
+ callbackSettings();
+
+ } else {
+
+ $.get(OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/ajax/settings"),
+ function onSuccess(settings) {
+ OCA.Onlyoffice.setting = settings;
+
+ callbackSettings();
+ }
+ );
+
+ }
+ };
+
+ var getFileExtension = function (fileName) {
+ var extension = fileName.substr(fileName.lastIndexOf(".") + 1).toLowerCase();
+ return extension;
+ }
+
+ var initPage = function () {
+ if ($("#isPublic").val() === "1" && !$("#filestable").length) {
+ //file by shared link
+ var fileName = $("#filename").val();
+ var extension = getFileExtension(fileName);
+
+ var initSharedButton = function () {
+ var formats = OCA.Onlyoffice.setting.formats;
+
+ var config = formats[extension];
+ if (!config) {
+ return;
+ }
+
+ var editorUrl = OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/s/" + encodeURIComponent($("#sharingToken").val()));
+
+ if (! (_oc_appswebroots.richdocuments
+ || _oc_appswebroots.files_pdfviewer && extension === "pdf"
+ || _oc_appswebroots.text && extension === "txt")) {
+
+ OCA.Onlyoffice.frameSelector = "#onlyofficeFrame";
+ var $iframe = $("");
+ $("#app-content").append($iframe);
+ }
+ };
+
+ OCA.Onlyoffice.GetSettings(initSharedButton);
+ }
+ };
+
+ initPage();
+
+})(OCA);
\ No newline at end of file
diff --git a/lib/listeners/filesharinglistener.php b/lib/listeners/filesharinglistener.php
index 3274a460..85043754 100644
--- a/lib/listeners/filesharinglistener.php
+++ b/lib/listeners/filesharinglistener.php
@@ -53,7 +53,7 @@ public function handle(Event $event): void {
if (!empty($this->appConfig->GetDocumentServerUrl())
&& $this->appConfig->SettingsAreSuccessful()) {
- Util::addScript("onlyoffice", "main");
+ Util::addScript("onlyoffice", "share");
if ($this->appConfig->GetSameTab()) {
Util::addScript("onlyoffice", "listener");