fix: force-reload ONLYOFFICE API.js each session + Date.now for truly unique doc key

This commit is contained in:
root
2026-07-16 12:02:45 +00:00
parent 46d2bf4931
commit 8b6b083d3d
5 changed files with 15 additions and 10 deletions

View File

@@ -324,10 +324,15 @@ async function openOnlyofficeEditor(templateId, templateName) {
`;
showModal(body, '', 'xlarge');
// Load ONLYOFFICE API script dynamically
const scriptUrl = onlyofficeUrl + '/web-apps/apps/api/documents/api.js';
if (!document.getElementById('onlyoffice-api-script')) {
await new Promise((resolve, reject) => {
// Load ONLYOFFICE API script - force fresh load each time
// Remove old script to force ONLYOFFICE to reload API.js from server
const oldScript = document.getElementById('onlyoffice-api-script');
if (oldScript) oldScript.remove();
// Reload with cache-buster so ONLYOFFICE gets fresh API state
const scriptBuster = Date.now();
const scriptUrl = onlyofficeUrl + '/web-apps/apps/api/documents/api.js?cb=' + scriptBuster;
await new Promise((resolve, reject) => {
const script = document.createElement('script');
script.id = 'onlyoffice-api-script';
script.src = scriptUrl;
@@ -335,8 +340,7 @@ async function openOnlyofficeEditor(templateId, templateName) {
script.onerror = () => reject(new Error('Failed to load ONLYOFFICE API from ' + scriptUrl));
document.head.appendChild(script);
});
}
// Initialize the ONLYOFFICE editor
if (typeof DocsAPI === 'undefined' || !DocsAPI.DocEditor) {
throw new Error('ONLYOFFICE API not loaded. Check that the server is running at ' + onlyofficeUrl);

View File

@@ -139,7 +139,7 @@
<!-- Modals -->
<div class="modal-overlay" id="modal-overlay"></div>
<script src="/static/app.js?v=5"></script>
<script src="/static/carbone.js?v=5"></script>
<script src="/static/app.js?v=6"></script>
<script src="/static/carbone.js?v=6"></script>
</body>
</html>