2026-10-26 09:43:17 +08:00
|
|
|
/* SiteForge V8.29: presentation-only studio helpers. No persisted-schema changes. */
|
|
|
|
|
'use strict';
|
|
|
|
|
(function(root){
|
2026-10-26 14:27:17 +08:00
|
|
|
const themes=new Set(['automotive','industrial','corporate','minimal','trade-pro']);
|
2026-10-26 09:43:17 +08:00
|
|
|
const pages=new Set(['home','listing','product','article','about','contact']);
|
|
|
|
|
const categories={
|
|
|
|
|
visual:new Set(['hero','banner','carousel','gallery','image','image_text','image-grid','video','slider']),
|
|
|
|
|
business:new Set(['collection','products','product_list','brand_wall','brands','features','stats','testimonials','faq','contact','form','cta','map']),
|
|
|
|
|
advanced:new Set(['layout','columns','tabs','accordion','html-embed','embed','spacer','divider'])
|
|
|
|
|
};
|
|
|
|
|
function categoryOf(key){for(const [name,ids] of Object.entries(categories))if(ids.has(key))return name;return 'basic'}
|
|
|
|
|
function groupBlocks(blocks,query=''){
|
|
|
|
|
const result={basic:[],visual:[],business:[],advanced:[]};
|
|
|
|
|
const q=String(query).trim().toLocaleLowerCase().slice(0,70);
|
|
|
|
|
for(const [key,block] of Object.entries(blocks||{})){
|
|
|
|
|
if(!block||typeof block!=='object')continue;
|
|
|
|
|
const text=[key,block.name,block.description].join(' ').toLocaleLowerCase();
|
|
|
|
|
if(q&&!text.includes(q))continue;
|
|
|
|
|
result[categoryOf(key)].push({key,block});
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
function previewUrl(theme,page){
|
|
|
|
|
if(!themes.has(theme)||!pages.has(page))return null;
|
|
|
|
|
return `/api/factory/themes/${theme}/preview?page_type=${page}`;
|
|
|
|
|
}
|
|
|
|
|
/* Only CSS-token values accepted by the existing server-side block validator. */
|
|
|
|
|
const designPalettes={
|
|
|
|
|
automotive:['#ffffff','#14283d','#f3f6f9','#102e47'],
|
|
|
|
|
industrial:['#ffffff','#193f59','#eef5f8','#104a6d'],
|
|
|
|
|
corporate:['#ffffff','#262d58','#f4f3fb','#34397b'],
|
2026-10-26 14:27:17 +08:00
|
|
|
minimal:['#faf9f5','#292924','#f0efe9','#30302c'],
|
|
|
|
|
'trade-pro':['#ffffff','#17365c','#eef4fc','#0b3d91']
|
2026-10-26 09:43:17 +08:00
|
|
|
};
|
|
|
|
|
function stylePreset(theme,preset){
|
|
|
|
|
const [base,ink,soft,dark]=designPalettes[themes.has(theme)?theme:'corporate'];
|
|
|
|
|
switch(preset){
|
|
|
|
|
case 'clean':return {background:base,text_color:ink,padding:72};
|
|
|
|
|
case 'soft':return {background:soft,text_color:ink,padding:58};
|
|
|
|
|
case 'feature':return {background:dark,text_color:'#ffffff',padding:90};
|
|
|
|
|
default:return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const api=Object.freeze({categoryOf,groupBlocks,previewUrl,stylePreset});
|
|
|
|
|
if(typeof module!=='undefined'&&module.exports)module.exports=api;
|
|
|
|
|
if(root)root.SiteForgeStudioExperience=api;
|
|
|
|
|
})(typeof window!=='undefined'?window:null);
|