Skip to content

Commit

Permalink
Fill forms in embed mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaRadzhabova committed Mar 7, 2024
1 parent 7623f49 commit 5c40bd7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 49 deletions.
72 changes: 39 additions & 33 deletions apps/api/documents/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,49 +961,52 @@
'cell': 'spreadsheeteditor',
'slide': 'presentationeditor',
'pdf': 'pdfeditor',
'checker': config.document && config.document.isForm ? 'documenteditor' :
config.document && config.document.isForm===false ? 'pdfeditor' : 'common'
'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[2] === 'string')
appType = 'pdf';
if (type && typeof type[1] === 'string')
appType = 'checker';
}
} 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[4] === 'string' && config.type !== 'mobile' && config.type !== 'embedded') appType = 'pdf'; else
if (typeof type[3] === 'string' && config.type !== 'mobile' && config.type !== 'embedded') appType = 'checker';
}
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 ( appType!=='checker' && typeof(customization) == 'object' && ( customization.toolbarNoTabs ||
(config.editorConfig.targetApp!=='desktop') && (customization.loaderName || customization.loaderLogo))) {
if ( typeof(customization) == 'object' && ( customization.toolbarNoTabs ||
(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 @@ -1040,6 +1043,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
15 changes: 8 additions & 7 deletions apps/common/main/index.html → apps/common/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<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">
<link rel="icon" href="resources/img/favicon.ico" type="image/x-icon">

<style type="text/css">
.loadmask {
Expand Down Expand Up @@ -41,20 +40,22 @@
}

var params = getUrlParams(),
postfix = params["indexPostfix"] || '';
postfix = params["indexPostfix"] || '',
embed = params["type"]==='embedded';
window.frameEditorId = params["frameEditorId"];
window.parentOrigin = params["parentOrigin"];
</script>
<script src="lib/util/themeinit.js"></script>
<script src="main/lib/util/themeinit.js"></script>
</head>
<body>
<script src="lib/util/htmlutils.js"></script>
<script type="text/javascript" src="../checkExtendedPDF.js"></script>
<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\/main\/index.html/i);
match && window.location.replace(match[1] + (!!isform ? 'documenteditor' : 'pdfeditor') + '/main/index' + postfix + '.html' + window.location.search + ("&isForm=" + !!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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<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">
<link rel="icon" href="resources/img/favicon.ico" type="image/x-icon">

<style type="text/css">
.loadmask {
Expand Down Expand Up @@ -41,20 +40,22 @@
}

var params = getUrlParams(),
postfix = params["indexPostfix"] || '';
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>
<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>
<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\/main\/index.html/i);
match && window.location.replace(match[1] + (!!isform ? 'documenteditor' : 'pdfeditor') + '/main/index' + postfix + '.html' + window.location.search + ("&isForm=" + !!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>
Expand Down
4 changes: 2 additions & 2 deletions build/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
},
"indexhtml": {
"expand": true,
"cwd": "../apps/common/main",
"cwd": "../apps/common",
"src": "*.html.deploy",
"ext": ".html",
"dest": "../deploy/web-apps/apps/common/main"
"dest": "../deploy/web-apps/apps/common"
}
},
"imagemin": {
Expand Down

0 comments on commit 5c40bd7

Please sign in to comment.