fix: autoupdate
This commit is contained in:
@@ -59,6 +59,10 @@ window.EditorCore = (function () {
|
||||
_wireButton('btn-reset', () => opts.onReset(_currentPage + 1));
|
||||
}
|
||||
|
||||
// Disconnect browser-sync to prevent auto-reload.
|
||||
// Editors maintain DOM state — reload would wipe unsaved changes.
|
||||
_disconnectBrowserSync();
|
||||
|
||||
// Load worksheet, then optionally load data.json
|
||||
_loadWorksheet(_config.filePath, opts.onReady, opts.onDataLoaded);
|
||||
|
||||
@@ -240,6 +244,18 @@ window.EditorCore = (function () {
|
||||
|
||||
// ---- Helpers ----
|
||||
|
||||
function _disconnectBrowserSync() {
|
||||
function tryDisconnect() {
|
||||
if (window.___browserSync___) {
|
||||
window.___browserSync___.socket.close();
|
||||
}
|
||||
}
|
||||
// Browser-sync client may connect after our script runs
|
||||
tryDisconnect();
|
||||
setTimeout(tryDisconnect, 500);
|
||||
setTimeout(tryDisconnect, 2000);
|
||||
}
|
||||
|
||||
function _wireButton(id, handler) {
|
||||
const btn = document.getElementById(id);
|
||||
if (btn) btn.addEventListener('click', handler);
|
||||
|
||||
Reference in New Issue
Block a user