Skip to content

Commit

Permalink
closing direct editor
Browse files Browse the repository at this point in the history
  • Loading branch information
LinneyS committed Jan 14, 2020
1 parent d43cd61 commit 1ed0923
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
7 changes: 2 additions & 5 deletions controller/editorcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,18 +677,15 @@ public function config($fileId, $filePath = NULL, $shareToken = NULL, $directTok
}
}

if ($folderLink !== NULL
&& $inframe !== 2
&& empty($directToken) //todo: fix in ds 5.5
) {
if ($folderLink !== NULL && $inframe !== 2) {
$params["editorConfig"]["customization"]["goback"] = [
"url" => $folderLink
];

if (!$desktop) {
if ($this->config->GetSameTab()) {
$params["editorConfig"]["customization"]["goback"]["blank"] = false;
if ($inframe === 1) {
if ($inframe === 1 || !empty($directToken)) {
$params["editorConfig"]["customization"]["goback"]["requestClose"] = true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions js/directeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
}

OCA.Onlyoffice.directEditor = {
close: function() {
callMobileMessage("close");
},
loaded: function() {
callMobileMessage("loaded");
}
Expand Down
28 changes: 16 additions & 12 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@
params.push("directToken=" + encodeURIComponent(directToken));
}

if (OCA.Onlyoffice.inframe) {
var dsVersion = DocsAPI.DocEditor.version();
var versionArray = dsVersion.split(".");
if (versionArray[0] < 5 || versionArray[1] < 5) {
params.push("inframe=2");
} else {
params.push("inframe=1");
}
var dsVersion = DocsAPI.DocEditor.version();
var versionArray = dsVersion.split(".");
if (versionArray[0] < 5 || versionArray[1] < 5) {
params.push("inframe=2");
} else if (OCA.Onlyoffice.inframe) {
params.push("inframe=1");
}

if (OCA.Onlyoffice.Desktop) {
Expand Down Expand Up @@ -138,11 +136,12 @@
config.events.onAppReady = OCA.Onlyoffice.directEditor.loaded;
}

if (OCA.Onlyoffice.inframe) {
if (OCA.Onlyoffice.directEditor || OCA.Onlyoffice.inframe) {
config.events.onRequestClose = OCA.Onlyoffice.onRequestClose;
if (config._files_sharing) {
config.events.onRequestSharingSettings = OCA.Onlyoffice.onRequestSharingSettings;
}
}

if (OCA.Onlyoffice.inframe && config._files_sharing) {
config.events.onRequestSharingSettings = OCA.Onlyoffice.onRequestSharingSettings;
}

OCA.Onlyoffice.docEditor = new DocsAPI.DocEditor("iframeEditor", config);
Expand Down Expand Up @@ -266,6 +265,11 @@
};

OCA.Onlyoffice.onRequestClose = function () {
if (OCA.Onlyoffice.directEditor) {
OCA.Onlyoffice.directEditor.close();
return;
}

window.parent.postMessage({
method: "editorRequestClose"
});
Expand Down

0 comments on commit 1ed0923

Please sign in to comment.