Change wopi config parameters

This commit is contained in:
Julia Radzhabova 2021-04-28 01:41:36 +03:00
parent 77a6da1e2b
commit 9bbf9e9c22

View file

@ -62,6 +62,8 @@ div {
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
var docEditor; var docEditor;
var closeUrl;
var hostEditUrl;
var innerAlert = function (message) { var innerAlert = function (message) {
if (console && console.log) if (console && console.log)
@ -77,25 +79,8 @@ div {
document.title = title + (event.data ? "*" : ""); document.title = title + (event.data ? "*" : "");
}; };
var onMetaChange = function (event) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite);
};
var onRequestEditRights = function () { var onRequestEditRights = function () {
location.href = location.href.replace(RegExp("mode=view\&?", "i"), ""); hostEditUrl && (location.href = hostEditUrl);
};
var onRequestHistory = function (event) {
};
var onRequestHistoryData = function (data) {
};
var onRequestHistoryClose = function (event){
document.location.reload();
}; };
var onError = function (event) { var onError = function (event) {
@ -107,35 +92,8 @@ div {
location.reload(true); location.reload(true);
}; };
var replaceActionLink = function(href, linkParam) { var onRequestClose = function (event) {
var link; closeUrl && (location.href = closeUrl);
var actionIndex = href.indexOf("&action=");
if (actionIndex != -1) {
var endIndex = href.indexOf("&", actionIndex + "&action=".length);
if (endIndex != -1) {
link = href.substring(0, actionIndex) + href.substring(endIndex) + "&action=" + encodeURIComponent(linkParam);
} else {
link = href.substring(0, actionIndex) + "&action=" + encodeURIComponent(linkParam);
}
} else {
link = href + "&action=" + encodeURIComponent(linkParam);
}
return link;
}
var onMakeActionLink = function (event) {
var actionData = event.data;
var linkParam = JSON.stringify(actionData);
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
};
var onRequestInsertImage = function(event) {
};
var onRequestCompareFile = function() {
};
var onRequestMailMergeRecipients = function (event) {
}; };
var connectEditor = function () { var connectEditor = function () {
@ -154,73 +112,52 @@ div {
"documentType": queryParams.documenttype, "documentType": queryParams.documenttype,
"token": token, "token": token,
"document": { "document": {
"title": fileInfo.BaseFileName, "title": fileInfo.BreadcrumbDocName || fileInfo.BaseFileName,
"url": userAuth.wopiSrc, "url": userAuth.wopiSrc,
"fileType": fileType, "fileType": fileInfo.FileExtension ? fileInfo.BaseFileName.substr(1) : fileType,
"key": key, "key": key,
"info": { "info": {
"owner": "Me", "folder": fileInfo.BreadcrumbFolderName
"uploaded": "Thu Nov 05 2020", },
"favorite": "null"
},
"permissions": { "permissions": {
"comment": true, "edit": !fileInfo.ReadOnly && fileInfo.UserCanWrite,
"download": true, "copy": fileInfo.CopyPasteRestrictions!=="CurrentDocumentOnly" && fileInfo.CopyPasteRestrictions!=="BlockAll",
"edit": true, "print": !fileInfo.DisablePrint
"fillForms": true,
"modifyFilter": true,
"modifyContentControl": true,
"review": true,
"reviewGroups": true
} }
}, },
"editorConfig": { "editorConfig": {
"actionLink": "null",
"mode": queryParams.mode, "mode": queryParams.mode,
"lang": "en", "lang": queryParams.lang || "en",
"callbackUrl": JSON.stringify(userAuth), "callbackUrl": JSON.stringify(userAuth),
"sharingSettingsUrl": fileInfo.FileSharingUrl,
"user": { "user": {
"group": "", "id": fileInfo.IsAnonymousUser ? "" : fileInfo.UserId,
"id": fileInfo.UserId,
"name": fileInfo.UserFriendlyName "name": fileInfo.UserFriendlyName
}, },
"embedded": {
"saveUrl": "",
"embedUrl": "",
"shareUrl": "",
"toolbarDocked": "top"
},
"customization": { "customization": {
"about": true, "about": true,
"chat": true,
"comments": true,
"feedback": true,
"forcesave": true,
"goback": { "goback": {
"url": "http://localhost/" "url": fileInfo.BreadcrumbFolderUrl
}, },
"submitForm": false "customer": {
}, "name": fileInfo.BreadcrumbBrandName,
"fileChoiceUrl": "", "www": fileInfo.BreadcrumbBrandUrl
"plugins": {"pluginsData":[]} }
}
}, },
events: { events: {
"onAppReady": onAppReady, "onAppReady": onAppReady,
"onDocumentStateChange": onDocumentStateChange, "onDocumentStateChange": onDocumentStateChange,
'onRequestEditRights': onRequestEditRights, 'onRequestEditRights': onRequestEditRights,
"onError": onError, "onError": onError,
"onRequestHistory": onRequestHistory,
"onRequestHistoryData": onRequestHistoryData,
"onRequestHistoryClose": onRequestHistoryClose,
"onOutdatedVersion": onOutdatedVersion, "onOutdatedVersion": onOutdatedVersion,
"onMakeActionLink": onMakeActionLink, "onRequestClose": onRequestClose
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
} }
}; };
closeUrl = fileInfo.CloseUrl;
hostEditUrl = fileInfo.HostEditUrl;
docEditor = new DocsAPI.DocEditor("iframeEditor", config); docEditor = new DocsAPI.DocEditor("iframeEditor", config);
fixSize(); fixSize();