Keep staff item previews working during the menu transition

This commit is contained in:
unimatrixgit 2026-11-28 19:40:56 +01:00
commit 5bf16d4b58

View file

@ -16,7 +16,7 @@ export function mountItemDesigner(host,{fetcher=fetch,initialDesign=null,onApply
const saved=select([['','Choose a saved draft']]),load=button('Load draft',()=>{const row=definitions.find(row=>row.id===saved.value);if(row){id=row.id;revision=row.revision;lastSaved=JSON.stringify(validateItemDesign(row.design));setDesign(row.design);status.textContent='Draft revision '+revision+' loaded.';}}),fresh=button('New item',()=>{id=crypto.randomUUID();revision=0;lastSaved="";setDesign(defaultItemDesign(template.value));status.textContent='New local draft. Save to record it in J.A.R.V.I.S.';}),refresh=button('Refresh drafts',()=>void readDefinitions());
const tools=el('div',undefined,'item-designer-tools');tools.append(field('Saved definitions',saved),load,fresh,refresh);
const form=el('form'),fields=el('fieldset'),layout=el('div',undefined,'item-designer-layout'),preview=el('div',undefined,'item-designer-preview');
const copyPreview=button('Copy ingame preview command',async()=>{const command='/dm previewitem '+id+' '+revision;try{await navigator.clipboard.writeText(command);status.textContent='Preview command copied. Paste it in Minecraft: '+command;}catch{status.textContent='Paste this command in Minecraft: '+command;}});copyPreview.disabled=true;
const copyPreview=button('Copy ingame preview command',async()=>{const command='/drgui previewitem '+id+' '+revision;try{await navigator.clipboard.writeText(command);status.textContent='Preview command copied. Paste it in Minecraft: '+command;}catch{status.textContent='Paste this command in Minecraft: '+command;}});copyPreview.disabled=true;
const ids=Object.keys(itemTemplateCatalogue().templates),template=select(ids.map(id=>{const t=itemDesignTemplate(id);return[id,t.name+' · '+itemWords(t.quality)+' · MK '+itemRoman(t.equipmentMark)];}));template.setAttribute('aria-label','Item template');
const name=el('input');name.maxLength=64;name.required=true;const identity=el('p',undefined,'item-designer-identity'),enchants=el('div',undefined,'item-designer-enchantments'),lore=el('div',undefined,'item-designer-lore');
const addLore=button('Add lore line',()=>{if(loreRows.length<6){addLine({text:'',color:'#AAAAAA',bold:false,italic:false});paint();}});