diff --git a/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx b/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx index 2db4c18..b1dddaa 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 28652d7..d6955b4 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-17T09:01:35.526Z" + "updatedAt": "2026-07-17T09:04:41.170Z" } ] \ No newline at end of file diff --git a/static/carbone.js b/static/carbone.js index 69a4d98..d4c0143 100644 --- a/static/carbone.js +++ b/static/carbone.js @@ -267,6 +267,9 @@ function forceSaveOnlyoffice() { } } +// Track whether the editor is cleaning up (disable Edit buttons during this) +let editorCleaningUp = false; + // Close the editor — full teardown so the next open is completely fresh function closeOnlyofficeEditor() { if (onlyofficeEditorInstance) { @@ -281,19 +284,44 @@ function closeOnlyofficeEditor() { const oldScript = document.querySelector('script[src*="api/documents/api.js"]'); if (oldScript) oldScript.remove(); - loadOnlyofficeTemplates(); + // Disable all "Edit Online" buttons for 2 seconds while ONLYOFFICE + // tears down its server-side session, then re-enable them. + editorCleaningUp = true; + disableEditButtons('Cleaning up...'); + setTimeout(() => { + editorCleaningUp = false; + enableEditButtons(); + loadOnlyofficeTemplates(); + }, 2000); +} + +// Disable/enable all "Edit Online" buttons with a status label +function disableEditButtons(label) { + document.querySelectorAll('button[onclick^="openOnlyofficeEditor"]').forEach(btn => { + btn.disabled = true; + btn.style.opacity = '0.5'; + btn.style.cursor = 'not-allowed'; + btn.dataset.originalText = btn.textContent; + btn.textContent = label || 'Please wait...'; + }); +} +function enableEditButtons() { + document.querySelectorAll('button[onclick^="openOnlyofficeEditor"]').forEach(btn => { + btn.disabled = false; + btn.style.opacity = ''; + btn.style.cursor = ''; + if (btn.dataset.originalText) btn.textContent = btn.dataset.originalText; + }); } // Open ONLYOFFICE editor in a modal async function openOnlyofficeEditor(templateId, templateName) { - // Block reopening if a previous editor is still tearing down. - // destroyEditor() is async — the ONLYOFFICE websocket/session needs - // time to close before a new editor can be created cleanly. + // Don't open if cleanup is in progress + if (editorCleaningUp) return; + if (onlyofficeEditorInstance) { try { onlyofficeEditorInstance.destroyEditor(); } catch (e) {} onlyofficeEditorInstance = null; - // Give ONLYOFFICE's internal session 2 seconds to fully close - await new Promise(r => setTimeout(r, 2000)); } try { diff --git a/static/index.html b/static/index.html index 90fe4cd..e62ca04 100644 --- a/static/index.html +++ b/static/index.html @@ -139,7 +139,7 @@ - - + + \ No newline at end of file