Merge branch 'develop' into feature/ruby-rubocop

This commit is contained in:
Alexander Salyakhov
2023-11-30 13:31:47 +03:00
committed by GitHub
56 changed files with 930 additions and 312 deletions

View File

@ -27,6 +27,7 @@
var docEditor;
var config;
var versionHistory;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -210,10 +211,31 @@
innerAlert(response.error)
return
}
document.location.reload();
onRequestHistory()
}
}
function onRequestHistory() {
fileData = <%= raw @file.to_json %>;
const req = new XMLHttpRequest()
req.open("POST", '/historyobj')
req.send(JSON.stringify(fileData))
req.onload = function () {
versionHistory = JSON.parse(req.response)
docEditor.refreshHistory(versionHistory.hist)
}
}
function onRequestHistoryData(event){
var ver = event.data;
var histData = versionHistory.histData;
docEditor.setHistoryData(histData[ver - 1]);
}
function onRequestHistoryClose(){
document.location.reload();
}
var сonnectEditor = function () {
config = <%= raw @file.config.to_json %>;
@ -230,30 +252,16 @@
'onRequestInsertImage': onRequestInsertImage,
'onRequestSelectDocument': onRequestSelectDocument,
'onRequestSelectSpreadsheet': onRequestSelectSpreadsheet,
'onRequestRestore': onRequestRestore
'onRequestRestore': onRequestRestore,
'onRequestHistory': onRequestHistory,
'onRequestHistoryData': onRequestHistoryData,
'onRequestHistoryClose': onRequestHistoryClose
};
<%
history = @file.history
usersMentions = @file.users_mentions %>
if (config.editorConfig.user.id) {
<% if history %>
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(<%= raw history[:hist].to_json %>); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= raw history[:histData].to_json %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose'] = function () {
document.location.reload();
};
<% end %>
// add mentions for not anonymous users
config.events['onRequestUsers'] = function (event) {
if (event && event.data){
@ -273,7 +281,7 @@
}
break;
case "protect":
var users = <%= raw @file.get_users_protect.to_json %>;
var users = <%= raw @file.users_protect.to_json %>;
break;
default:
users = <%= raw @file.users_mentions.to_json %>;