This commit is contained in:
Zuzanna Ludzik 2026-09-03 22:42:49 +02:00
parent fb61ea341d
commit 3747bf2a18
3 changed files with 75 additions and 2 deletions

View File

@ -127,6 +127,7 @@ define([
var savedModalFocus = null;
var restoreModalFocus = function () {
if (!savedModalFocus) { return; }
console.log("modalfocus", savedModalFocus.nodeName, savedModalFocus.contentWindow)
if (savedModalFocus.nodeName === "IFRAME") {
$(savedModalFocus.contentWindow).focus();
} else {
@ -1506,6 +1507,7 @@ define([
var deletePopup = function () {
$popup.remove();
if (savedFocus) {
console.log("savedfocus", savedFocus.nodeName, savedFocus.contentWindow)
if (savedFocus.nodeName === "IFRAME") {
$(savedFocus.contentWindow).focus();
} else {

View File

@ -163,6 +163,7 @@ define([
//window.frames[0].editor.setViewModeDisconnect(true);
} catch (e) {}
*/
console.log("1", readOnly)
if (!state && (!readOnly || force)) {
$('#cp-app-oo-editor').append(h('div#cp-app-oo-offline'));
}
@ -974,6 +975,8 @@ define([
};
var openVersionHash = function (version) {
console.log("2", readOnly)
readOnly = true;
const hashes = content.hashes || {};
const sortedCp = sortCpIndex(hashes);
@ -1852,6 +1855,8 @@ define([
send({ type: "message" });
break;
case "saveChanges":
console.log("3", readOnly)
if (readOnly) {
return;
}
@ -2066,6 +2071,8 @@ define([
'#left-btn-spellcheck, #left-btn-about { display: none !important; }'+
'div.btn-users.dropdown-toggle { display: none; !important }';
if (readOnly) {
console.log("5", readOnly)
css += '#toolbar { display: none !important; }';
//css += '#app-title { display: none !important; }'; // OnlyOffice logo + doc title
//css += '#file-menu-panel { top: 28px !important; }'; // Position of the "File" menu
@ -2123,6 +2130,8 @@ define([
var onDocUnlock = function () {
// Migration required but read-only: continue...
if (readOnly) {
console.log("6", readOnly)
setEditable(true);
try { getEditor().asc_setRestriction(true); } catch (e) {}
} else {
@ -2147,6 +2156,7 @@ define([
onDocUnlock();
return;
}
console.log("7", readOnly)
if (lock || readOnly) {
try { getEditor().asc_setRestriction(true); } catch (e) {}
@ -2233,6 +2243,7 @@ define([
getEditor().asc_setRestriction(true);
} catch (e) {}
}
console.log("8", readOnly)
if (lock && !readOnly) { // Lock = !history && migrate
onMigrateRdy.fire();
@ -3038,6 +3049,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
APP.onLocal = config.onLocal = function () {
if (initializing) { return; }
console.log("9", readOnly)
if (readOnly) { return; }
if (APP.history) { return; }
@ -3177,6 +3190,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
return void sframeChan.event('EV_OOIFRAME_DONE', '');
}
content = json.content;
console.log("10", readOnly)
readOnly = true;
var version = (!content.version || content.version === 1) ? 'v1/' :
(content.version <= 3 ? 'v2b/' : OOCurrentVersion.currentVersion + '/');
@ -3198,6 +3213,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
config.onInit = function (info) {
var privateData = metadataMgr.getPrivateData();
metadataMgr.setDegraded(false); // FIXME degraded moded unsupported (no cursor channel)
console.log("11", readOnly)
readOnly = privateData.readOnly;
@ -3528,7 +3544,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
};
var firstReady = true;
config.onReady = function (info) {
config.onReady = function (info) {
console.log("pierdol sie")
if (APP.realtime !== info.realtime) {
APP.realtime = info.realtime;
}
@ -3598,6 +3615,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
}
APP.migrate = true;
// Registedred ~~users~~ editors can start the migration
console.log("12", readOnly)
if (common.isLoggedIn() && !readOnly) {
content.migration = true;
APP.onLocal();
@ -3608,6 +3627,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
} else {
$('#cp-app-oo-editor').prepend(msg);
}
console.log("13", readOnly)
readOnly = true;
}
}
@ -3637,6 +3658,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
setMyId();
oldHashes = JSON.parse(JSON.stringify(content.hashes));
initializing = false;
console.log("14", readOnly)
return void setEditable(!readOnly);
}
firstReady = false;
@ -3656,6 +3679,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
var m = metadataMgr.getChannelMembers().filter(function (str) {
return str.length === 32;
}).length;
console.log("15", readOnly)
if ((m - v) === 1 && !readOnly && common.isLoggedIn()) {
var needCp = ooChannel.queue.length > CHECKPOINT_INTERVAL;
APP.initCheckpoint = needCp;
@ -3663,6 +3688,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
common.openPadChat(APP.onLocal);
console.log("16", readOnly)
if (!readOnly) {
var cursors = {};
@ -3712,6 +3738,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
const { blob, file } = cpObj;
startOO(blob, file);
setEditable(!readOnly);
console.log("17", readOnly)
UI.removeLoadingScreen();
};

View File

@ -66,6 +66,24 @@ MessengerUI, Messages, Pages, PadTypes, Icons) {
return 'cp-toolbar-uid-' + String(Math.random()).substring(2);
};
(function () {
var $probe = $('<div>', {
style: 'position:fixed;top:0;left:0;background:black;color:lime;' +
'z-index:2147483647;font:11px monospace;padding:4px;pointer-events:none;white-space:pre;'
}).appendTo('body');
setInterval(function () {
var a = document.activeElement;
$probe.text(
'active:' + (document.activeElement && document.activeElement.nodeName) +
' | lastClick:' + (lastClickTarget ? lastClickTarget.tagName + (lastClickTarget.id?'#'+lastClickTarget.id:'') + (lastClickTarget.className? '.'+String(lastClickTarget.className).split(' ').join('.') : '') : 'none')
);
}, 150);
var lastClickTarget = null;
document.addEventListener('click', function (e) {
lastClickTarget = e.target;
}, true);
})();
var createRealtimeToolbar = function (config) {
if (!config.$container) { return; }
var $container = config.$container;
@ -488,6 +506,15 @@ MessengerUI, Messages, Pages, PadTypes, Icons) {
hide();
});
*/
let focus;
$button.on('mousedown', function (e) {
focus = document.activeElement;
if (focus && focus.nodeName === 'IFRAME') {
e.preventDefault();
}
});
$button.click(function () {
var visible = $content.is(':visible');
if (visible) { hide(); }
@ -495,6 +522,14 @@ MessengerUI, Messages, Pages, PadTypes, Icons) {
visible = !visible;
Common.setAttribute(['toolbar', 'userlist-drawer'], visible);
Feedback.send(visible?'USERLIST_SHOW': 'USERLIST_HIDE');
if (focus.nodeName === "IFRAME") {
console.log(focus, focus.contentWindow, focus.contentWindow.document)
$(focus.contentWindow).focus();
console.log(document.activeElement);
} else {
$(focus).focus();
}
});
show();
Common.getAttribute(['toolbar', 'userlist-drawer'], function (err, val) {
@ -582,7 +617,6 @@ MessengerUI, Messages, Pages, PadTypes, Icons) {
Icons.get('chat'),
h('span.cp-button-name', Messages.chatButton)
])).appendTo($container);
toolbar.$bottomR.prepend($container);
if (config.$contentContainer) {
@ -617,12 +651,21 @@ MessengerUI, Messages, Pages, PadTypes, Icons) {
hide(true);
});
*/
let focus;
$button.on('mousedown', function () {
focus = document.activeElement;
});
$button.click(function () {
var visible = $content.is(':visible');
if (visible) { hide(true); }
else { show(); }
visible = !visible;
Common.setAttribute(['toolbar', 'chat-drawer'], visible);
if (focus.nodeName === "IFRAME") {
$(focus.contentWindow).focus();
} else {
$(focus).focus();
}
});
show();
Common.getAttribute(['toolbar', 'chat-drawer'], function (err, val) {