Web: Added new editor.requestClose param to client config

(cherry picked from commit 70a18018c3104f9d400fa53a57f37eb9bdbc6d71)
This commit is contained in:
Alexey Safronov 2023-07-11 11:53:33 +04:00 committed by Sergey Linnik
parent b911f0aa19
commit f40940f73c
2 changed files with 40 additions and 15 deletions

View File

@ -594,6 +594,28 @@ function Editor({
}
};
const onSDKRequestClose = () => {
const backUrl = getBackUrl();
window.location.replace(backUrl);
};
const getBackUrl = () => {
if (!fileInfo) return;
let backUrl = "";
if (fileInfo.rootFolderType === FolderType.Rooms) {
backUrl = `/rooms/shared/${fileInfo.folderId}/filter?folder=${fileInfo.folderId}`;
} else {
backUrl = `/rooms/personal/filter?folder=${fileInfo.folderId}`;
}
const url = window.location.href;
const origin = url.substring(0, url.indexOf("/doceditor"));
return `${combineUrl(origin, backUrl)}`;
};
const init = () => {
try {
if (isMobile) {
@ -601,20 +623,9 @@ function Editor({
}
let goBack;
const url = window.location.href;
const search = window.location.search;
if (fileInfo) {
let backUrl = "";
if (fileInfo.rootFolderType === FolderType.Rooms) {
backUrl = `/rooms/shared/${fileInfo.folderId}/filter?folder=${fileInfo.folderId}`;
} else {
backUrl = `/rooms/personal/filter?folder=${fileInfo.folderId}`;
}
const origin = url.substring(0, url.indexOf("/doceditor"));
const editorGoBack = new URLSearchParams(search).get("editorGoBack");
goBack =
@ -622,10 +633,15 @@ function Editor({
? {}
: {
blank: window.DocSpaceConfig?.editor?.openOnNewPage ?? true,
requestClose: false,
requestClose:
window.DocSpaceConfig?.editor?.requestClose ?? false,
text: t("FileLocation"),
url: `${combineUrl(origin, backUrl)}`,
};
if (!window.DocSpaceConfig?.editor?.requestClose) {
goBack.blank = window.DocSpaceConfig?.editor?.openOnNewPage ?? true;
goBack.url = getBackUrl();
}
}
config.editorConfig.customization = {
@ -642,6 +658,8 @@ function Editor({
// config.document.info.favorite = null;
// }
const url = window.location.href;
if (url.indexOf("anchor") !== -1) {
const splitUrl = url.split("anchor=");
const decodeURI = decodeURIComponent(splitUrl[1]);
@ -663,7 +681,8 @@ function Editor({
onRequestReferenceData,
onRequestUsers,
onRequestSendNotify,
onRequestCreateNew;
onRequestCreateNew,
onRequestClose;
if (successAuth && !user.isVisitor) {
if (
@ -726,6 +745,10 @@ function Editor({
onRequestSendNotify = onSDKRequestSendNotify;
}
if (window.DocSpaceConfig?.editor?.requestClose) {
onRequestClose = onSDKRequestClose;
}
const events = {
events: {
onRequestReferenceData,
@ -751,6 +774,7 @@ function Editor({
onRequestUsers,
onRequestSendNotify,
onRequestCreateNew,
onRequestClose,
},
};

View File

@ -10,6 +10,7 @@
"wrongPortalNameUrl": "https://teamlab.info/wrongportalname.aspx?Site_Testing=4testing",
"thumbnails1280x720": false,
"editor": {
"openOnNewPage": false
"openOnNewPage": false,
"requestClose": true
}
}