diff --git a/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx b/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx index 4f1f73a..2ba4ff5 100644 Binary files a/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx and b/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx differ diff --git a/renderer/carbone-templates/registry.json b/renderer/carbone-templates/registry.json index acfa156..7d48d87 100644 --- a/renderer/carbone-templates/registry.json +++ b/renderer/carbone-templates/registry.json @@ -6,6 +6,6 @@ "originalName": "master_cv_template.docx", "path": "/root/workspace/cv-app/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx", "uploadedAt": "2026-07-16T09:03:29.601Z", - "updatedAt": "2026-07-16T18:59:36.503Z" + "updatedAt": "2026-07-17T08:58:13.712Z" } ] \ No newline at end of file diff --git a/static/carbone.js b/static/carbone.js index ea9eb03..7a60077 100644 --- a/static/carbone.js +++ b/static/carbone.js @@ -267,13 +267,24 @@ function forceSaveOnlyoffice() { } } -// Close the editor — standard ONLYOFFICE teardown +// Close the editor — full teardown so the next open is completely fresh function closeOnlyofficeEditor() { if (onlyofficeEditorInstance) { try { onlyofficeEditorInstance.destroyEditor(); } catch (e) {} onlyofficeEditorInstance = null; } closeModal(); + + // Delete the DocsAPI global and remove the script tag so the next + // openOnlyofficeEditor call loads a completely fresh ONLYOFFICE API. + // This is the key: destroyEditor() cleans the editor instance, but + // the DocsAPI object itself retains internal state (websocket pools, + // document session references) that causes the next editor to load + // a stale document. Removing the script + global forces a fresh init. + delete window.DocsAPI; + const oldScript = document.querySelector('script[src*="api/documents/api.js"]'); + if (oldScript) oldScript.remove(); + loadOnlyofficeTemplates(); } @@ -305,16 +316,16 @@ async function openOnlyofficeEditor(templateId, templateName) { `; showModal(body, '', 'xlarge'); - // Load ONLYOFFICE API script (once) - if (typeof DocsAPI === 'undefined') { - await new Promise((resolve, reject) => { - const s = document.createElement('script'); - s.src = onlyofficeUrl + '/web-apps/apps/api/documents/api.js'; - s.onload = resolve; - s.onerror = () => reject(new Error('Failed to load ONLYOFFICE API')); - document.head.appendChild(s); - }); - } + // Load ONLYOFFICE API script fresh each time with cache-buster. + // This ensures a completely new DocsAPI instance with no stale state. + const scriptUrl = onlyofficeUrl + '/web-apps/apps/api/documents/api.js?cb=' + Date.now(); + await new Promise((resolve, reject) => { + const s = document.createElement('script'); + s.src = scriptUrl; + s.onload = resolve; + s.onerror = () => reject(new Error('Failed to load ONLYOFFICE API')); + document.head.appendChild(s); + }); if (typeof DocsAPI === 'undefined' || !DocsAPI.DocEditor) { throw new Error('ONLYOFFICE API not loaded'); diff --git a/static/index.html b/static/index.html index 4ee8571..f06ab67 100644 --- a/static/index.html +++ b/static/index.html @@ -139,7 +139,7 @@ - - + + \ No newline at end of file