botui/ui/suite/editor.js
Rodrigo Rodriguez (Pragmatismo) 955568c8e4 fix(i18n): fix DOM timing issue in i18n.js
- Wait for document.body before attaching event listeners
- Prevents TypeError when script loads before body exists
2026-01-10 10:54:05 -03:00

28 lines
1 KiB
JavaScript

/* Editor page JavaScript */
// Show save notification
function showSaveNotification(event) {
const notification = document.getElementById('notification');
if (event.detail.successful) {
notification.textContent = '✓ File saved';
notification.className = 'notification success show';
document.getElementById('dirty-indicator').style.display = 'none';
} else {
notification.textContent = '✗ Save failed';
notification.className = 'notification error show';
}
setTimeout(() => notification.classList.remove('show'), 3000);
}
// Mark as dirty on edit
document.getElementById('text-editor')?.addEventListener('input', function() {
document.getElementById('dirty-indicator').style.display = 'inline-block';
});
// Keyboard shortcuts using htmx triggers
document.addEventListener('keydown', function(e) {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
e.preventDefault();
htmx.trigger(document.querySelector('[hx-post="/api/editor/save"]'), 'click');
}
});