fix: unique container ID per editor session + 1.5s settle delay on close

This commit is contained in:
root
2026-07-16 11:19:44 +00:00
parent 046e8be14b
commit ec97256e17
4 changed files with 12 additions and 8 deletions

View File

@@ -6,6 +6,6 @@
"originalName": "master_cv_template.docx", "originalName": "master_cv_template.docx",
"path": "/root/workspace/cv-app/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx", "path": "/root/workspace/cv-app/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx",
"uploadedAt": "2026-07-16T09:03:29.601Z", "uploadedAt": "2026-07-16T09:03:29.601Z",
"updatedAt": "2026-07-16T11:15:01.909Z" "updatedAt": "2026-07-16T11:17:19.354Z"
} }
] ]

View File

@@ -275,7 +275,9 @@ async function openOnlyofficeEditor(templateId, templateName) {
const config = data.config; const config = data.config;
const onlyofficeUrl = data.onlyofficeUrl; const onlyofficeUrl = data.onlyofficeUrl;
// Build the editor modal // Build the editor modal with a unique container ID each time
// so ONLYOFFICE never reuses a cached DOM element
const containerId = 'oo-editor-' + Date.now();
const body = ` const body = `
<div class="flex-between mb-16"> <div class="flex-between mb-16">
<h3>Editing: ${templateName}</h3> <h3>Editing: ${templateName}</h3>
@@ -284,7 +286,7 @@ async function openOnlyofficeEditor(templateId, templateName) {
<button class="btn btn-sm btn-danger" onclick="closeOnlyofficeEditor()">Close Editor</button> <button class="btn btn-sm btn-danger" onclick="closeOnlyofficeEditor()">Close Editor</button>
</div> </div>
</div> </div>
<div id="onlyoffice-editor-container" style="width:100%;height:800px;border:1px solid var(--border);border-radius:8px;overflow:hidden"></div> <div id="${containerId}" style="width:100%;height:800px;border:1px solid var(--border);border-radius:8px;overflow:hidden"></div>
<p class="text-muted text-sm mt-8">Changes are saved automatically. Click "Save" to force-save, or "Close Editor" to return to the template list.</p> <p class="text-muted text-sm mt-8">Changes are saved automatically. Click "Save" to force-save, or "Close Editor" to return to the template list.</p>
`; `;
showModal(body, '', 'xlarge'); showModal(body, '', 'xlarge');
@@ -307,7 +309,7 @@ async function openOnlyofficeEditor(templateId, templateName) {
throw new Error('ONLYOFFICE API not loaded. Check that the server is running at ' + onlyofficeUrl); throw new Error('ONLYOFFICE API not loaded. Check that the server is running at ' + onlyofficeUrl);
} }
onlyofficeEditorInstance = new DocsAPI.DocEditor('onlyoffice-editor-container', { onlyofficeEditorInstance = new DocsAPI.DocEditor(containerId, {
...config, ...config,
width: '100%', width: '100%',
height: '800px', height: '800px',
@@ -354,8 +356,10 @@ function closeOnlyofficeEditor() {
onlyofficeEditorInstance = null; onlyofficeEditorInstance = null;
} }
closeModal(); closeModal();
// Refresh the templates list to show any changes // Wait 1.5s for ONLYOFFICE save callbacks to settle, then refresh
loadOnlyofficeTemplates(); setTimeout(() => {
loadOnlyofficeTemplates();
}, 1500);
} }
// Call status check when templates page becomes active // Call status check when templates page becomes active

View File

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