Skip to content

Commit

Permalink
Merge branch 'release/v8.1.0' into feature/open-from-bin
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Mar 18, 2024
2 parents cfbcf19 + 2299157 commit e32050c
Show file tree
Hide file tree
Showing 180 changed files with 26,541 additions and 8,553 deletions.
76 changes: 46 additions & 30 deletions apps/api/documents/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@
}
}

var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(_config.document.fileType);
var type = /^(?:(djvu|xps|oxps))$/.exec(_config.document.fileType);
if (type && typeof type[1] === 'string') {
_config.editorConfig.canUseHistory = false;
}
Expand Down Expand Up @@ -976,46 +976,53 @@
'word': 'documenteditor',
'cell': 'spreadsheeteditor',
'slide': 'presentationeditor',
'pdf': 'pdfeditor'
'pdf': 'pdfeditor',
'common': 'common'
},
appType = 'word';

if (typeof config.documentType === 'string') {
appType = config.documentType.toLowerCase();
if (config.type !== 'mobile' && config.type !== 'embedded' && !!config.document && typeof config.document.fileType === 'string') {
var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(config.document.fileType);
if (type && typeof type[1] === 'string')
appType = 'pdf';
}
} else
if (!!config.document && typeof config.document.fileType === 'string') {
var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp)|(pdf|djvu|xps|oxps))$/
.exec(config.document.fileType);
if (type) {
if (typeof type[1] === 'string') appType = 'cell'; else
if (typeof type[2] === 'string') appType = 'slide'; else
if (typeof type[3] === 'string' && config.type !== 'mobile' && config.type !== 'embedded') appType = 'pdf';
}
appType = 'word',
type,
fillForms = false,
isForm = false;
if (config.document) {
if (typeof config.document.fileType === 'string')
type = /^(?:(pdf)|(djvu|xps|oxps)|(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp))$/
.exec(config.document.fileType);

if (config.document.permissions)
fillForms = (config.document.permissions.fillForms===undefined ? config.document.permissions.edit !== false : config.document.permissions.fillForms) &&
config.editorConfig && (config.editorConfig.mode !== 'view');
}
if (appType === 'pdf' && (config.type === 'mobile' || config.type === 'embedded')) {
appType = 'word';
if (type && typeof type[2] === 'string') { // djvu|xps|oxps
appType = config.type === 'mobile' || config.type === 'embedded' ? 'word' : 'pdf';
} else if (type && typeof type[1] === 'string') { // pdf - need check
isForm = config.document ? config.document.isForm : undefined;
if (config.type === 'embedded')
appType = fillForms && isForm===undefined ? 'common' : 'word';
else if (config.type !== 'mobile')
appType = isForm===undefined ? 'common' : isForm ? 'word' : 'pdf';
} else {
if (typeof config.documentType === 'string')
appType = config.documentType.toLowerCase();
else {
if (type && typeof type[3] === 'string') appType = 'cell'; else
if (type && typeof type[4] === 'string') appType = 'slide';
}
}
path += appMap[appType];

path += appMap[appType] + "/";
const path_type = config.type === "mobile"
? "mobile" : (config.type === "embedded")
? "embed" : "main";
const path_type = config.type === "mobile" ? "mobile" :
config.type === "embedded" ? (fillForms && isForm ? "forms" : "embed") : "main";
if (appType !== 'common')
path += "/" + path_type;

path += path_type;
var index = "/index.html";
if (config.editorConfig && path_type!=="forms") {
if (config.editorConfig && path_type!=="forms" && appType!=='common') {
var customization = config.editorConfig.customization;
if ( typeof(customization) == 'object' && ( customization.toolbarNoTabs ||
(config.editorConfig.targetApp!=='desktop') && (customization.loaderName || customization.loaderLogo))) {
(config.editorConfig.targetApp!=='desktop') && (customization.loaderName || customization.loaderLogo))) {
index = "/index_loader.html";
} else if (config.editorConfig.mode === 'editdiagram' || config.editorConfig.mode === 'editmerge' || config.editorConfig.mode === 'editole')
index = "/index_internal.html";

}
path += index;
return path;
Expand Down Expand Up @@ -1052,6 +1059,9 @@
if (config.editorConfig && (config.editorConfig.mode == 'editdiagram' || config.editorConfig.mode == 'editmerge' || config.editorConfig.mode == 'editole'))
params += "&internal=true";

if (config.type)
params += "&type=" + config.type;

if (config.frameEditorId)
params += "&frameEditorId=" + config.frameEditorId;

Expand Down Expand Up @@ -1080,6 +1090,12 @@
if (config.document && config.document.fileType)
params += "&fileType=" + config.document.fileType;

if (config.editorConfig) {
var customization = config.editorConfig.customization;
if ( customization && typeof(customization) == 'object' && ( customization.toolbarNoTabs || (config.editorConfig.targetApp!=='desktop') && (customization.loaderName || customization.loaderLogo))) {
params += "&indexPostfix=_loader";
}
}
return params;
}

Expand Down
17 changes: 16 additions & 1 deletion apps/api/wopi/editor-wopi.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,19 @@ div {
innerAlert(event.data);
};
var getWopiFileUrl = function(fileInfo, userAuth) {
let url;
if (fileInfo.FileUrl) {
//Requests to the FileUrl can not be signed using proof keys. The FileUrl is used exactly as provided by the host, so it does not necessarily include the access token, which is required to construct the expected proof.
url = fileInfo.FileUrl;
} else if (fileInfo.TemplateSource) {
url = fileInfo.TemplateSource;
} else if (userAuth) {
url = userAuth.wopiSrc + "/contents?access_token=" + userAuth.access_token;
}
return url;
}
var connectEditor = function () {
fileInfo = <%- JSON.stringify(fileInfo) %>;
Expand Down Expand Up @@ -280,7 +293,7 @@ div {
"token": token,
"document": {
"title": fileInfo.BreadcrumbDocName || fileInfo.BaseFileName,
"url": userAuth.wopiSrc,
"url": getWopiFileUrl(fileInfo, userAuth),
"fileType": fileType,
"key": key,
"info": {
Expand Down Expand Up @@ -377,9 +390,11 @@ div {
if (window.addEventListener) {
window.addEventListener("load", connectEditor);
window.addEventListener("resize", fixSize);
window.addEventListener("orientationchange", fixSize);
} else if (window.attachEvent) {
window.attachEvent("onload", connectEditor);
window.attachEvent("onresize", fixSize);
window.attachEvent("orientationchange", fixSize);
}
</script>
</body>
Expand Down
62 changes: 62 additions & 0 deletions apps/common/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>ONLYOFFICE Documents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">

<style type="text/css">
.loadmask {
left: 0;
top: 0;
position: absolute;
height: 100%;
width: 100%;
overflow: hidden;
border: none;
background: #e2e2e2;
background: var(--canvas-background, #e2e2e2);
z-index: 1002;
}

.theme-dark .loadmask, .theme-type-dark .loadmask {
background: #555;
}
</style>
<script>
function getUrlParams() {
var e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1),
urlParams = {};

while (e = r.exec(q))
urlParams[d(e[1])] = d(e[2]);

return urlParams;
}

var params = getUrlParams(),
postfix = params["indexPostfix"] || '',
embed = params["type"]==='embedded';
window.frameEditorId = params["frameEditorId"];
window.parentOrigin = params["parentOrigin"];
</script>
<script src="main/lib/util/themeinit.js"></script>
</head>
<body>
<script src="main/lib/util/htmlutils.js"></script>
<script type="text/javascript" src="checkExtendedPDF.js"></script>
<div id="loading-mask" class="loadmask"></div>
<script>
listenApiMsg(function (isform) {
var match = window.location.href.match(/(.*)common\/index.html/i);
match && window.location.replace(match[1] + (isform || embed ? 'documenteditor' : 'pdfeditor') + '/' + (isform && embed ? 'forms' : embed ? 'embed' : 'main') + '/index' + postfix + '.html' +
window.location.search + ("&isForm=" + !!isform));
});
</script>
</body>
</html>
62 changes: 62 additions & 0 deletions apps/common/index.html.deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>ONLYOFFICE Documents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">

<style type="text/css">
.loadmask {
left: 0;
top: 0;
position: absolute;
height: 100%;
width: 100%;
overflow: hidden;
border: none;
background: #e2e2e2;
background: var(--canvas-background, #e2e2e2);
z-index: 1002;
}

.theme-dark .loadmask, .theme-type-dark .loadmask {
background: #555;
}
</style>
<script>
function getUrlParams() {
var e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1),
urlParams = {};

while (e = r.exec(q))
urlParams[d(e[1])] = d(e[2]);

return urlParams;
}

var params = getUrlParams(),
postfix = params["indexPostfix"] || '',
embed = params["type"]==='embedded';
window.frameEditorId = params["frameEditorId"];
window.parentOrigin = params["parentOrigin"];
</script>
<script src="../../../../apps/common/main/lib/util/themeinit.js?__inline=true"></script>
</head>
<body>
<script src="../../../../apps/common/main/lib/util/htmlutils.js?__inline=true"></script>
<script src="../../../../apps/common/checkExtendedPDF.js?__inline=true"></script>
<div id="loading-mask" class="loadmask"></div>
<script>
listenApiMsg(function (isform) {
var match = window.location.href.match(/(.*)common\/index.html/i);
match && window.location.replace(match[1] + (isform || embed ? 'documenteditor' : 'pdfeditor') + '/' + (isform && embed ? 'forms' : embed ? 'embed' : 'main') + '/index' + postfix + '.html' +
window.location.search + ("&isForm=" + !!isform));
});
</script>
</body>
</html>
Loading

0 comments on commit e32050c

Please sign in to comment.