Hi,
You can do this:
const editor = document.querySelector(‘smart-editor’);
let timeout;
editor.addEventListener('change', () => {
clearTimeout(timeout);
// debounce (wait 1s after user stops typing)
timeout = setTimeout(() => {
const content = editor.getValue();
// save somewhere (API or localStorage)
saveContent(content);
}, 1000);
});
function saveContent(data) {
console.log('Autosaving...', data);
// Example: send to backend
// fetch('/save', {
// method: 'POST',
// body: JSON.stringify({ content: data })
// });
}
Best regards,
Markov
Smart UI Team
https://www.htmlelements.com/