fix: autoupdate
This commit is contained in:
parent
994a13da52
commit
3e36cfcb39
|
|
@ -13,7 +13,7 @@ module.exports = {
|
||||||
"tasks/index.html",
|
"tasks/index.html",
|
||||||
"tasks/*/index.html",
|
"tasks/*/index.html",
|
||||||
"tasks/*/docs/*.template.html",
|
"tasks/*/docs/*.template.html",
|
||||||
// output.html excluded: generated by save flow, reload would wipe editor state
|
"tasks/*/docs/*.output.html",
|
||||||
"tasks/*/editor.html",
|
"tasks/*/editor.html",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"public/**/*"
|
"public/**/*"
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,10 @@ window.EditorCore = (function () {
|
||||||
_wireButton('btn-reset', () => opts.onReset(_currentPage + 1));
|
_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
|
// Load worksheet, then optionally load data.json
|
||||||
_loadWorksheet(_config.filePath, opts.onReady, opts.onDataLoaded);
|
_loadWorksheet(_config.filePath, opts.onReady, opts.onDataLoaded);
|
||||||
|
|
||||||
|
|
@ -240,6 +244,18 @@ window.EditorCore = (function () {
|
||||||
|
|
||||||
// ---- Helpers ----
|
// ---- 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) {
|
function _wireButton(id, handler) {
|
||||||
const btn = document.getElementById(id);
|
const btn = document.getElementById(id);
|
||||||
if (btn) btn.addEventListener('click', handler);
|
if (btn) btn.addEventListener('click', handler);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"sections": [
|
"sections": [
|
||||||
{
|
{
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"scale": 1.15,
|
"scale": 1.25,
|
||||||
"rotate": 0
|
"rotate": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"index": 2,
|
"index": 2,
|
||||||
"scale": 0.85,
|
"scale": 0.65,
|
||||||
"rotate": 0
|
"rotate": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue