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

@@ -275,7 +275,9 @@ async function openOnlyofficeEditor(templateId, templateName) {
const config = data.config;
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 = `
<div class="flex-between mb-16">
<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>
</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>
`;
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);
}
onlyofficeEditorInstance = new DocsAPI.DocEditor('onlyoffice-editor-container', {
onlyofficeEditorInstance = new DocsAPI.DocEditor(containerId, {
...config,
width: '100%',
height: '800px',
@@ -354,8 +356,10 @@ function closeOnlyofficeEditor() {
onlyofficeEditorInstance = null;
}
closeModal();
// Refresh the templates list to show any changes
loadOnlyofficeTemplates();
// Wait 1.5s for ONLYOFFICE save callbacks to settle, then refresh
setTimeout(() => {
loadOnlyofficeTemplates();
}, 1500);
}
// Call status check when templates page becomes active