fix: remove duplicate openOnlyofficeEditor, add destroy check before reopen
This commit is contained in:
Binary file not shown.
@@ -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:21:01.888Z"
|
"updatedAt": "2026-07-16T11:23:15.854Z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -260,8 +260,41 @@ async function loadOnlyofficeTemplates() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force save the document
|
||||||
|
function forceSaveOnlyoffice() {
|
||||||
|
if (onlyofficeEditorInstance) {
|
||||||
|
// The ONLYOFFICE editor's onSave event will trigger the callback
|
||||||
|
// which saves the file to our backend
|
||||||
|
toast('Saving... changes will be stored automatically');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the editor and clean up
|
||||||
|
function closeOnlyofficeEditor() {
|
||||||
|
if (onlyofficeEditorInstance) {
|
||||||
|
try {
|
||||||
|
onlyofficeEditorInstance.destroyEditor();
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error closing editor:', e);
|
||||||
|
}
|
||||||
|
onlyofficeEditorInstance = null;
|
||||||
|
}
|
||||||
|
closeModal();
|
||||||
|
// Force a small delay then reload the template list so the
|
||||||
|
// user sees the updated list with the latest save timestamp
|
||||||
|
setTimeout(() => {
|
||||||
|
loadOnlyofficeTemplates();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
// Open ONLYOFFICE editor in a modal
|
// Open ONLYOFFICE editor in a modal
|
||||||
async function openOnlyofficeEditor(templateId, templateName) {
|
async function openOnlyofficeEditor(templateId, templateName) {
|
||||||
|
// If there's a previous editor instance still lingering, destroy it first
|
||||||
|
if (onlyofficeEditorInstance) {
|
||||||
|
try { onlyofficeEditorInstance.destroyEditor(); } catch (e) {}
|
||||||
|
onlyofficeEditorInstance = null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get the JWT-signed editor config from our backend
|
// Get the JWT-signed editor config from our backend
|
||||||
// Add cache-buster to prevent browser caching the old config
|
// Add cache-buster to prevent browser caching the old config
|
||||||
@@ -335,34 +368,6 @@ async function openOnlyofficeEditor(templateId, templateName) {
|
|||||||
toast('Failed to open editor: ' + e.message, 'error');
|
toast('Failed to open editor: ' + e.message, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force save the document
|
|
||||||
function forceSaveOnlyoffice() {
|
|
||||||
if (onlyofficeEditorInstance) {
|
|
||||||
// The ONLYOFFICE editor's onSave event will trigger the callback
|
|
||||||
// which saves the file to our backend
|
|
||||||
toast('Saving... changes will be stored automatically');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the editor and clean up
|
|
||||||
function closeOnlyofficeEditor() {
|
|
||||||
if (onlyofficeEditorInstance) {
|
|
||||||
try {
|
|
||||||
onlyofficeEditorInstance.destroyEditor();
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Error closing editor:', e);
|
|
||||||
}
|
|
||||||
onlyofficeEditorInstance = null;
|
|
||||||
}
|
|
||||||
closeModal();
|
|
||||||
// Wait 1.5s for ONLYOFFICE save callbacks to settle, then refresh
|
|
||||||
setTimeout(() => {
|
|
||||||
loadOnlyofficeTemplates();
|
|
||||||
}, 1500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call status check when templates page becomes active
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const templatesPage = document.getElementById('page-templates');
|
const templatesPage = document.getElementById('page-templates');
|
||||||
if (templatesPage) {
|
if (templatesPage) {
|
||||||
|
|||||||
@@ -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=4"></script>
|
<script src="/static/app.js?v=5"></script>
|
||||||
<script src="/static/carbone.js?v=4"></script>
|
<script src="/static/carbone.js?v=5"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user