Wide-View Code Editor `;// Tab support
editor.addEventListener('keydown', function(e) {
if (e.key === 'Tab') {
e.preventDefault();
const start = this.selectionStart;
const end = this.selectionEnd;
this.value = this.value.substring(0, start) + " " + this.value.substring(end);
this.selectionStart = this.selectionEnd = start + 2;
}
});function updatePreview() {
status.textContent = "Syncing...";
const html = editor.value;
const dest = preview.contentWindow.document;
dest.open();
dest.write(html);
dest.close();
localStorage.setItem('wideEditorCode', html);
setTimeout(() => { status.textContent = "Saved"; }, 300);
}let timeout;
editor.addEventListener('input', () => {
clearTimeout(timeout);
timeout = setTimeout(updatePreview, 300);
});window.onload = () => {
const saved = localStorage.getItem('wideEditorCode');
editor.value = saved || defaultCode;
updatePreview();
};