Compare commits

...

6 Commits

Author SHA1 Message Date
4ba95c88be nodejs: docxf 2021-10-25 16:00:49 +03:00
0102b752b8 nodejs: filling on mobile 2021-10-25 15:35:42 +03:00
af480634f2 nodejs: revert filling in docx 2021-10-25 15:35:36 +03:00
08ba477f6b nodejs: hide submit button 2021-10-22 15:33:04 +03:00
d190f68f90 nodejs: oform 2021-10-22 15:32:56 +03:00
61884c519f nodejs: onRequestSaveAs event 2021-10-21 16:33:37 +03:00
9 changed files with 131 additions and 21 deletions

View File

@ -103,6 +103,7 @@ app.get("/", function (req, res) { // define a handler for default page
preloaderUrl: siteUrl + configServer.get('preloaderUrl'),
convertExts: configServer.get('convertedDocs').join(","),
editedExts: configServer.get('editedDocs').join(","),
fillExts: configServer.get('fillDocs').join(","),
storedFiles: docManager.getStoredFiles(),
params: docManager.getCustomParams(),
users: users,
@ -195,7 +196,7 @@ app.post("/upload", function (req, res) { // define a handler for uploading fil
return;
}
const exts = [].concat(configServer.get('viewedDocs'), configServer.get('editedDocs'), configServer.get('convertedDocs')); // all the supported file extensions
const exts = [].concat(configServer.get('viewedDocs'), configServer.get('editedDocs'), configServer.get('convertedDocs'), configServer.get('fillDocs')); // all the supported file extensions
const curExt = fileUtility.getFileExtension(file.name);
const documentType = fileUtility.getFileType(file.name);
@ -224,6 +225,54 @@ app.post("/upload", function (req, res) { // define a handler for uploading fil
});
});
app.post("/create", function (req, res) {
var title = req.body.title;
var fileUrl = req.body.url;
try {
docManager.init(storageFolder, req, res);
docManager.storagePath(""); // mkdir if not exist
var fileName = docManager.getCorrectName(title);
var userAddress = docManager.curUserHostAddress();
docManager.historyPath(fileName, userAddress, true);
var file = syncRequest("GET", fileUrl);
var fileBody = file.getBody();
if (configServer.get("maxFileSize") < fileBody.length || fileBody.length <= 0) { // check if the file size exceeds the maximum file size
res.writeHead(200, { "Content-Type": "application/json" });
res.write(JSON.stringify({ "error": "File size is incorrect" }));
res.end();
return;
}
const exts = [].concat(configServer.get("viewedDocs"), configServer.get("editedDocs"), configServer.get("convertedDocs"), configServer.get('fillDocs')); // all the supported file extensions
const curExt = fileUtility.getFileExtension(fileName);
if (exts.indexOf(curExt) == -1) { // check if the file extension is supported
res.writeHead(200, { "Content-Type": "application/json" }); // and write the error status and message to the response
res.write(JSON.stringify({ "error": "File type is not supported" }));
res.end();
return;
}
fileSystem.writeFileSync(docManager.storagePath(fileName), fileBody);
res.writeHead(200, { "Content-Type": "application/json" });
res.write(JSON.stringify({ "file" : fileName }));
res.end();
} catch (e) {
res.status(500);
res.write(JSON.stringify({
error: 1,
message: e.message
}));
res.end();
}
});
app.post("/convert", function (req, res) { // define a handler for converting files
var fileName = fileUtility.getFileName(req.body.filename);
@ -682,6 +731,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
res.redirect(redirectPath);
return;
}
fileExt = fileUtility.getFileExtension(fileName);
var userAddress = docManager.curUserHostAddress();
if (!docManager.existsSync(docManager.storagePath(fileName, userAddress))) { // if the file with a given name doesn't exist
@ -698,8 +748,12 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
type = new RegExp(configServer.get("mobileRegEx"), "i").test(req.get('User-Agent')) ? "mobile" : "desktop";
}
var canEdit = configServer.get('editedDocs').indexOf(fileUtility.getFileExtension(fileName)) != -1; // check if this file can be edited
var submitForm = canEdit && (mode == "edit" || mode == "fillForms");
var canEdit = configServer.get('editedDocs').indexOf(fileExt) != -1; // check if this file can be edited
if ((mode == "edit" || mode == "fillForms") && configServer.get('fillDocs').indexOf(fileExt) != -1) {
mode = "fillForms";
canEdit = true;
}
var submitForm = mode == "fillForms" && userid == "uid-1" && !1;
var countVersion = 1;
@ -723,7 +777,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
var historyD = {
version: i,
key: keyVersion,
url: i == countVersion ? url : (docManager.getlocalFileUri(fileName, i, true) + "/prev" + fileUtility.getFileExtension(fileName)),
url: i == countVersion ? url : (docManager.getlocalFileUri(fileName, i, true) + "/prev" + fileExt),
};
if (i > 1 && docManager.existsSync(docManager.diffPath(fileName, userAddress, i-1))) { // check if the path to the file with document versions differences exists

View File

@ -23,7 +23,8 @@
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html",
"exampleUrl": null,
"viewedDocs": [".pdf", ".djvu", ".xps", ".oxps"],
"editedDocs": [".docx", ".xlsx", ".csv", ".pptx", ".txt"],
"editedDocs": [".docx", ".xlsx", ".csv", ".pptx", ".txt", ".docxf"],
"fillDocs": [".docx", ".oform"],
"convertedDocs": [".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt", ".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm", ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".xml", ".epub", ".fb2"],
"storageFolder": "./files",
"storagePath": "/files",

View File

@ -63,7 +63,7 @@ fileUtility.fileType = {
}
// the document extension list
fileUtility.documentExts = [".doc", ".docx", ".docm", ".dot", ".dotx", ".dotm", ".odt", ".fodt", ".ott", ".rtf", ".txt", ".html", ".htm", ".mht", ".xml", ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps"];
fileUtility.documentExts = [".doc", ".docx", ".oform", ".docm", ".dot", ".dotx", ".dotm", ".odt", ".fodt", ".ott", ".rtf", ".txt", ".html", ".htm", ".mht", ".xml", ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps"];
// the spreadsheet extension list
fileUtility.spreadsheetExts = [".xls", ".xlsx", ".xlsm", ".xlt", ".xltx", ".xltm", ".ods", ".fods", ".ots", ".csv"];

View File

@ -22,7 +22,8 @@ var descr_user_1 = [
"Can review all the changes",
"Can perform all actions with comments",
"The file favorite state is undefined",
"Can create files from templates using data from the editor"
"Can create files from templates using data from the editor",
//"Can submit forms"
];
var descr_user_2 = [
@ -30,7 +31,8 @@ var descr_user_2 = [
"Can review only his own changes or changes made by users with no group",
"Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only",
"This file is marked as favorite",
"Can create new files from the editor"
"Can create new files from the editor",
//"Cant submit forms"
];
var descr_user_3 = [
@ -41,7 +43,8 @@ var descr_user_3 = [
"Cant copy data from the file to clipboard",
"Cant download the file",
"Cant print the file",
"Can create new files from the editor"
"Can create new files from the editor",
//"Cant submit forms"
];
var descr_user_0 = [
@ -51,7 +54,8 @@ var descr_user_0 = [
"Can perform all actions with comments",
"The file favorite state is undefined",
"Can't mention others in comments",
"Can't create new files from the editor"
"Can't create new files from the editor",
//"Cant submit forms"
];
var users = [

View File

@ -0,0 +1,10 @@
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 3C0 1.34315 1.34315 0 3 0H22.9167L30 7.08333V37C30 38.6569 28.6569 40 27 40H3C1.34315 40 0 38.6569 0 37V3Z" fill="#007267"/>
<path d="M22.9165 0L29.9998 7.08333H25.9165C24.2597 7.08333 22.9165 5.74019 22.9165 4.08333V0Z" fill="#00524A"/>
<rect x="5.5" y="12.5" width="19" height="14" stroke="white"/>
<path d="M5 19L6 18V27H5V19Z" fill="#007267"/>
<path opacity="0.1" d="M5 12H21.1505H25V14.8125V27H14.9661H12.3817H5V12Z" fill="white"/>
<path d="M12.7574 15.8485C13.226 15.3798 13.9858 15.3798 14.4544 15.8485L16.1515 17.5455C16.6201 18.0141 16.6201 18.7739 16.1515 19.2426L9.36345 26.0306L5.12061 26.8793L5.96934 22.6365L12.7574 15.8485Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.4225 18.7304L11.3012 20.8518C10.7154 21.4375 9.95562 21.6275 9.60415 21.276V21.276L12.7861 18.094L13.4225 18.7304Z" fill="#198076"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.2436 20.7274L11.8494 17.3333L12.4858 16.6969L15.88 20.091L15.2436 20.7274Z" fill="#198076"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -157,6 +157,10 @@ label .checkbox {
background-image: url("../images/file_pptx.svg");
}
.try-editor.form {
background-image: url("../images/file_docxf.svg");
}
.create-sample {
color: #666666;
line-height: 24px;

View File

@ -145,6 +145,25 @@
console.log("Link to comment: " + replaceActionLink(location.href, actionLink));
};
var onRequestSaveAs = function (event) { // the user is trying to save file by clicking Save Copy as... button
var title = event.data.title;
var url = event.data.url;
var data = {
title: title,
url: url
}
fetch("create", {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => console.log(response.json()))
.catch((error) => console.log(error));
}
var config = {<%- include("config") %>,
events: {
"onAppReady": onAppReady,
@ -168,6 +187,10 @@
config.events.onRequestSendNotify = onRequestSendNotify;
}
if (config.editorConfig.createUrl) {
config.events.onRequestSaveAs = onRequestSaveAs;
}
var connectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
fixSize();

View File

@ -56,6 +56,9 @@
<li>
<a class="try-editor slide reload-page" target="_blank" href="editor?fileExt=pptx<%= params %>" title="Create new presentation">Presentation</a>
</li>
<li>
<a class="try-editor form reload-page" target="_blank" href="editor?fileExt=docxf<%= params %>" title="Create new master form">Master form</a>
</li>
</ul>
<label class="create-sample">
<input id="createSample" type="checkbox" class="checkbox" />With sample content
@ -202,23 +205,34 @@
<% } %>
<% if (storedFiles[i].documentType == "word") { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
</td>
<% } else { %>
<td class="contentCells contentCells-icon "></td>
<% } %>
<% if (storedFiles[i].documentType == "word") { %>
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
<a href="editor?type=desktop&mode=blockcontent&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification" /></a>
</td>
<% } else { %>
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift"></td>
<td class="contentCells contentCells-icon"></td>
<% } %>
<% if (storedFiles[i].documentType !== "word" && storedFiles[i].documentType !== "cell") {%>
<td class="contentCells contentCells-icon "></td>
<%}%>
<% } %>
<% if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.')).trim().toLowerCase()) !== -1) { %>
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift"">
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
</td>
<% } %>
<% } else if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.')).trim().toLowerCase()) !== -1) { %>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon">
<a href="editor?type=mobile&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/mobile.svg" alt="Open in editor for filling in forms for mobile devices" title="Open in editor for filling in forms for mobile devices" /></a>
</td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift"">
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<img src="images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
</td>
<% } else { %>
<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>
<% } %>