fix(builder): ordenar layout default restaurante y corregir alto real en free-drag
This commit is contained in:
@@ -1755,17 +1755,26 @@ const state = {
|
||||
if (!state.settings.free_drag && hasSortable()){
|
||||
initCanvasSortable(inner);
|
||||
}
|
||||
let freeDragBottom = 0;
|
||||
if (state.settings.free_drag){
|
||||
let maxBottom = 700;
|
||||
inner.querySelectorAll(".block").forEach((node)=>{
|
||||
const n = node;
|
||||
maxBottom = Math.max(maxBottom, n.offsetTop + n.offsetHeight + 120);
|
||||
});
|
||||
freeDragBottom = maxBottom;
|
||||
canvas.style.minHeight = maxBottom + "px";
|
||||
} else {
|
||||
const minH = Math.max(900, Number(state.settings.canvas_min_height || 1200));
|
||||
canvas.style.minHeight = `${minH}px`;
|
||||
}
|
||||
if (state.settings.free_drag){
|
||||
const spacer = document.createElement("div");
|
||||
spacer.style.height = `${Math.max(0, freeDragBottom)}px`;
|
||||
spacer.style.width = "100%";
|
||||
spacer.style.pointerEvents = "none";
|
||||
inner.appendChild(spacer);
|
||||
}
|
||||
const footer = document.createElement("footer");
|
||||
footer.className = "site-global-footer";
|
||||
const year = new Date().getFullYear();
|
||||
@@ -2964,6 +2973,34 @@ const state = {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
function estimateFreeDragBlockHeight(block){
|
||||
const type = String(block?.type || "").toLowerCase();
|
||||
if (type === "menu") return 92;
|
||||
if (type === "hero") return 430;
|
||||
if (type === "gallery") return 310;
|
||||
if (type === "map") return 330;
|
||||
if (type === "contact") return 300;
|
||||
if (type === "cards") return 250;
|
||||
if (type === "review") return 220;
|
||||
return 220;
|
||||
}
|
||||
function applyStackedFreeDragLayout(blocks){
|
||||
const list = Array.isArray(blocks) ? blocks : [];
|
||||
let y = 20;
|
||||
list.forEach((b)=>{
|
||||
if (!b) return;
|
||||
b.data = (b.data && typeof b.data === "object") ? b.data : {};
|
||||
if (b.type === "menu"){
|
||||
b.data.width = 100;
|
||||
b.pos = { x: 20, y };
|
||||
y += estimateFreeDragBlockHeight(b) + 18;
|
||||
return;
|
||||
}
|
||||
b.data.width = snapBlockWidth(b.type, Number(b.data.width || 92));
|
||||
b.pos = { x: 20, y };
|
||||
y += estimateFreeDragBlockHeight(b) + 22;
|
||||
});
|
||||
}
|
||||
async function saveContent(){
|
||||
if (isSaving) return;
|
||||
isSaving = true;
|
||||
@@ -3046,6 +3083,9 @@ const state = {
|
||||
state.settings.free_drag = hasMeaningfulFreeDragPositions(state.blocks);
|
||||
}
|
||||
if (state.settings.free_drag){
|
||||
if (!hasMeaningfulFreeDragPositions(state.blocks)){
|
||||
applyStackedFreeDragLayout(state.blocks);
|
||||
}
|
||||
normalizeDuplicatedFreeDragPositions(state.blocks);
|
||||
}
|
||||
}
|
||||
@@ -3076,6 +3116,9 @@ const state = {
|
||||
state.settings.free_drag = state.settings.business_rubro === "restaurante";
|
||||
}
|
||||
state.blocks = t.blocks.map(b=>({ ...b, id: makeId(), page: (BUILDER_MODE==="ub24" ? "home" : b.page) }));
|
||||
if (state.settings.free_drag){
|
||||
applyStackedFreeDragLayout(state.blocks);
|
||||
}
|
||||
selectedBlockId = null;
|
||||
renderInspector(); renderPreview();
|
||||
wireSettings();
|
||||
|
||||
Reference in New Issue
Block a user