Enable onlyoffice reconnection

pull/1/head
yflory 5 years ago
parent e32398b308
commit 0a543ae6ea

@ -62,6 +62,15 @@ body.cp-app-sheet, body.cp-app-oodoc, body.cp-app-ooslide {
background-color: lightgrey; background-color: lightgrey;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
position: relative;
}
#cp-app-oo-offline {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
background-color: rgba(255,255,255,0.5);
} }
#ooframe { #ooframe {
flex: 1; flex: 1;

@ -601,12 +601,6 @@ define([
}); });
}; };
var handleChanges = function (obj, send) { var handleChanges = function (obj, send) {
// Allow the changes
send({
type: "unSaveLock",
index: ooChannel.cpIndex,
time: +new Date()
});
// Send the changes // Send the changes
rtChannel.sendMsg({ rtChannel.sendMsg({
type: "saveChanges", type: "saveChanges",
@ -616,6 +610,15 @@ define([
excelAdditionalInfo: null excelAdditionalInfo: null
}, null, function (err, hash) { }, null, function (err, hash) {
if (err) { return void console.error(err); } if (err) { return void console.error(err); }
// Call unSaveLock to tell onlyoffice that the patch was sent.
// It will allow you to make changes to another cell.
// If there is an error and unSaveLock is not called, onlyoffice
// will try to send the patch again
send({
type: "unSaveLock",
index: ooChannel.cpIndex,
time: +new Date()
});
// Increment index and update latest hash // Increment index and update latest hash
ooChannel.cpIndex++; ooChannel.cpIndex++;
ooChannel.lastHash = hash; ooChannel.lastHash = hash;
@ -748,7 +751,9 @@ define([
}, },
"events": { "events": {
"onAppReady": function(/*evt*/) { "onAppReady": function(/*evt*/) {
var $tb = $('iframe[name="frameEditor"]').contents().find('head'); var $iframe = $('iframe[name="frameEditor"]').contents();
$iframe.prop('tabindex', '-1');
var $tb = $iframe.find('head');
var css = // Old OO var css = // Old OO
'#id-toolbar-full .toolbar-group:nth-child(2), #id-toolbar-full .separator:nth-child(3) { display: none; }' + '#id-toolbar-full .toolbar-group:nth-child(2), #id-toolbar-full .separator:nth-child(3) { display: none; }' +
'#fm-btn-save { display: none !important; }' + '#fm-btn-save { display: none !important; }' +
@ -1301,10 +1306,13 @@ define([
}; };
var setEditable = function (state) { var setEditable = function (state) {
$('#cp-app-oo-editor').find('#cp-app-oo-offline').remove();;
try {
window.frames[0].editor.asc_setViewMode(!state);
//window.frames[0].editor.setViewModeDisconnect(true);
} catch (e) {}
if (!state) { if (!state) {
try { $('#cp-app-oo-editor').append(h('div#cp-app-oo-offline'));
window.frames[0].editor.setViewModeDisconnect(true);
} catch (e) {}
} }
debug(state); debug(state);
}; };
@ -1569,10 +1577,11 @@ define([
setEditable(info.state); setEditable(info.state);
if (info.state) { if (info.state) {
UI.findOKButton().click(); UI.findOKButton().click();
UI.confirm(Messages.oo_reconnect, function (yes) { offline = false;
/*UI.confirm(Messages.oo_reconnect, function (yes) {
if (!yes) { return; } if (!yes) { return; }
common.gotoURL(); common.gotoURL();
}); });*/
} else { } else {
offline = true; offline = true;
UI.findOKButton().click(); UI.findOKButton().click();

@ -53,7 +53,7 @@ define([
// all our client IDs. // all our client IDs.
if (chan.clients) { if (chan.clients) {
chan.clients.forEach(function (cl) { chan.clients.forEach(function (cl) {
if (ctx.clients[cl] && !ctx.clients[cl].id) { if (ctx.clients[cl]) {
ctx.clients[cl].id = wc.myID + '-' + cl; ctx.clients[cl].id = wc.myID + '-' + cl;
} }
}); });
@ -189,15 +189,22 @@ define([
if (!c) { return void cb({ error: 'NOT_IN_CHANNEL' }); } if (!c) { return void cb({ error: 'NOT_IN_CHANNEL' }); }
var chan = ctx.channels[c.channel]; var chan = ctx.channels[c.channel];
if (!chan) { return void cb({ error: 'INVALID_CHANNEL' }); } if (!chan) { return void cb({ error: 'INVALID_CHANNEL' }); }
// Prepare the callback: broadcast the message to the other local tabs
// if the message is sent
var _cb = function (obj) {
if (obj && obj.error) { return void cb(obj); }
ctx.emit('MESSAGE', {
msg: data.msg
}, chan.clients.filter(function (cl) {
return cl !== clientId;
}));
cb();
};
// Send the message
if (data.isCp) { if (data.isCp) {
return void chan.sendMsg(data.isCp, cb); return void chan.sendMsg(data.isCp, _cb);
} }
chan.sendMsg(data.msg, cb); chan.sendMsg(data.msg, _cb);
ctx.emit('MESSAGE', {
msg: data.msg
}, chan.clients.filter(function (cl) {
return cl !== clientId;
}));
}; };
var reencrypt = function (ctx, data, cId, cb) { var reencrypt = function (ctx, data, cId, cb) {

Loading…
Cancel
Save