Add wopi template file
This commit is contained in:
parent
2e9d403604
commit
d931e6d37f
249
apps/api/wopi/editor-wopi.ejs
Normal file
249
apps/api/wopi/editor-wopi.ejs
Normal file
|
@ -0,0 +1,249 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head runat="server">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<!--
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2021
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
-->
|
||||
<title>ONLYOFFICE</title>
|
||||
<style type="text/css">
|
||||
html {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #fff;
|
||||
color: #333;
|
||||
font-family: Arial, Tahoma,sans-serif;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
overflow-y: hidden;
|
||||
padding: 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.form {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
div {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="form">
|
||||
<div id="iframeEditor">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="../documents/api.js"></script>
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
||||
var docEditor;
|
||||
|
||||
var innerAlert = function (message) {
|
||||
if (console && console.log)
|
||||
console.log(message);
|
||||
};
|
||||
|
||||
var onAppReady = function () {
|
||||
innerAlert("Document editor ready");
|
||||
};
|
||||
|
||||
var onDocumentStateChange = function (event) {
|
||||
var title = document.title.replace(/\*$/g, "");
|
||||
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 () {
|
||||
location.href = location.href.replace(RegExp("mode=view\&?", "i"), "");
|
||||
};
|
||||
|
||||
var onRequestHistory = function (event) {
|
||||
};
|
||||
|
||||
var onRequestHistoryData = function (data) {
|
||||
};
|
||||
|
||||
var onRequestHistoryClose = function (event){
|
||||
document.location.reload();
|
||||
};
|
||||
|
||||
var onError = function (event) {
|
||||
if (event)
|
||||
innerAlert(event.data);
|
||||
};
|
||||
|
||||
var onOutdatedVersion = function (event) {
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var replaceActionLink = function(href, linkParam) {
|
||||
var link;
|
||||
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 key = "<%- key %>";
|
||||
var fileInfo = <%- JSON.stringify(fileInfo) %>;
|
||||
var userAuth = <%- JSON.stringify(userAuth) %>;
|
||||
var token = "<%- token %>";
|
||||
var documentType = "<%- documentType %>";
|
||||
var mode = "<%- mode %>";
|
||||
|
||||
var fileType = fileInfo.BaseFileName ? fileInfo.BaseFileName.substr(fileInfo.BaseFileName.lastIndexOf('.') + 1) : "";
|
||||
var config = {
|
||||
"width": "100%",
|
||||
"height": "100%",
|
||||
"type": "desktop",
|
||||
"documentType": documentType,
|
||||
"token": token,
|
||||
"document": {
|
||||
"title": fileInfo.BaseFileName,
|
||||
"url": userAuth.wopiSrc,
|
||||
"fileType": fileType,
|
||||
"key": key,
|
||||
"info": {
|
||||
"owner": "Me",
|
||||
"uploaded": "Thu Nov 05 2020",
|
||||
"favorite": "null"
|
||||
},
|
||||
"permissions": {
|
||||
"comment": true,
|
||||
"download": true,
|
||||
"edit": true,
|
||||
"fillForms": true,
|
||||
"modifyFilter": true,
|
||||
"modifyContentControl": true,
|
||||
"review": true,
|
||||
"reviewGroups": true
|
||||
}
|
||||
},
|
||||
"editorConfig": {
|
||||
"actionLink": "null",
|
||||
"mode": mode,
|
||||
"lang": "en",
|
||||
"callbackUrl": JSON.stringify(userAuth),
|
||||
"user": {
|
||||
"group": "",
|
||||
"id": fileInfo.UserId,
|
||||
"name": fileInfo.UserFriendlyName
|
||||
},
|
||||
"embedded": {
|
||||
"saveUrl": "",
|
||||
"embedUrl": "",
|
||||
"shareUrl": "",
|
||||
"toolbarDocked": "top"
|
||||
},
|
||||
"customization": {
|
||||
"about": true,
|
||||
"chat": true,
|
||||
"comments": true,
|
||||
"feedback": true,
|
||||
"forcesave": true,
|
||||
"goback": {
|
||||
"url": "http://localhost/"
|
||||
},
|
||||
"submitForm": false
|
||||
},
|
||||
"fileChoiceUrl": "",
|
||||
"plugins": {"pluginsData":[]}
|
||||
},
|
||||
events: {
|
||||
"onAppReady": onAppReady,
|
||||
"onDocumentStateChange": onDocumentStateChange,
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
"onError": onError,
|
||||
"onRequestHistory": onRequestHistory,
|
||||
"onRequestHistoryData": onRequestHistoryData,
|
||||
"onRequestHistoryClose": onRequestHistoryClose,
|
||||
"onOutdatedVersion": onOutdatedVersion,
|
||||
"onMakeActionLink": onMakeActionLink,
|
||||
"onMetaChange": onMetaChange,
|
||||
"onRequestInsertImage": onRequestInsertImage,
|
||||
"onRequestCompareFile": onRequestCompareFile,
|
||||
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
|
||||
}
|
||||
};
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
|
||||
|
||||
fixSize();
|
||||
};
|
||||
|
||||
var fixSize = function () {
|
||||
var wrapEl = document.getElementsByClassName("form");
|
||||
if (wrapEl.length) {
|
||||
wrapEl[0].style.height = screen.availHeight + "px";
|
||||
window.scrollTo(0, -1);
|
||||
wrapEl[0].style.height = window.innerHeight + "px";
|
||||
}
|
||||
};
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("load", connectEditor);
|
||||
window.addEventListener("resize", fixSize);
|
||||
} else if (window.attachEvent) {
|
||||
window.attachEvent("onload", connectEditor);
|
||||
window.attachEvent("onresize", fixSize);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue