@obelism/content 0.27.0 → 0.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -14
- package/dist/bridge.global.js +15 -15
- package/dist/bridge.js +62 -63
- package/dist/bridge.mjs +62 -63
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -252,20 +252,22 @@ await bridge.createCollectionPage() // bridge.collection says which
|
|
|
252
252
|
On the site the prompt box is the **on-site editor** instead
|
|
253
253
|
(`mountSiteEditor`, mounted by `getContentBridge` with the same options): a
|
|
254
254
|
panel docked on the right, the site reflowed beside it (a sheet over the page
|
|
255
|
-
on small screens).
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
at the
|
|
268
|
-
|
|
255
|
+
on small screens). It opens on **Edit fields**, the CMS's own form for the
|
|
256
|
+
page — or for the entry around the selected block — right in the panel: the
|
|
257
|
+
fields, and blocks as cards to open and add, as in the dashboard. Edits apply
|
|
258
|
+
as you make them: they land in the unsaved changes, show on the page, and
|
|
259
|
+
undo a burst of typing at a time. The small **Ask** button in the header
|
|
260
|
+
switches to prompts for the selected block — or the whole page — and shows
|
|
261
|
+
the answer with what it changed, before and after; the change shows on the
|
|
262
|
+
page straight away, outlined as a preview, and needs **Keep it** before it
|
|
263
|
+
can be saved (**Try another** and **Undo** take it back). Hovered blocks
|
|
264
|
+
show their name; Escape — or **Whole page** above the form — goes from a
|
|
265
|
+
block back to the whole page. The header
|
|
266
|
+
names the page and opens every page of the space, drafts included, to go to
|
|
267
|
+
one (at `pagePath`, in the page's language when it has a path there), and
|
|
268
|
+
shows the environment. A launcher at the bottom left minimizes the panel,
|
|
269
|
+
hides the outlines and exits. Its words are `labels`
|
|
270
|
+
(`SiteEditorLabels`, defaults in
|
|
269
271
|
`DEFAULT_SITE_EDITOR_LABELS`).
|
|
270
272
|
|
|
271
273
|
The site makes room for the panel with a margin on `<html>`, which moves
|
package/dist/bridge.global.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
.badge[data-place='beside'] { transform: translateY(-50%); }
|
|
23
23
|
.badge[data-place='above'] { transform: translate(-100%, -100%); }
|
|
24
24
|
.badge:focus-visible { outline: 2px solid rgb(212 130 30); outline-offset: 2px; }
|
|
25
|
-
`,d=(e,t)=>e.height>=64?{place:"inside",top:Math.max(e.top,0)+8,left:e.right-8}:e.right+8+140<=t?{place:"beside",top:e.top+e.height/2,left:e.right+8}:{place:"above",top:e.top-4,left:e.right},p=/(-?\d*\.?\d+)(?:s|l|d)?vh\b/g,c=(e,t)=>(p.lastIndex=0,p.test(e))?e.replace(p,(e,r)=>`${Math.round(Number(r)*t/100*100)/100}px`):null,u=(e,t)=>{for(let r=0;r<e.length;r++){let n=e.item(r),a=c(e.getPropertyValue(n),t);null!==a&&e.setProperty(n,a,e.getPropertyPriority(n))}},g=(e,t)=>{for(let r of Array.from(e)){let{style:e,cssRules:n}=r;e&&u(e,t),n&&g(n,t)}},h="obelism-content-bridge",b="#d58a1f",m=(e="")=>`${e}[${t}]{cursor:pointer;transition:outline-color .15s}${e}[${t}]:hover{outline:2px dashed ${b};outline-offset:2px}${e}[${t}][data-cms-selected]{outline:2px solid ${b};outline-offset:2px}`,f={features:[],selectedUid:null,prompting:!1,canUndo:!1,unsaved:!1,saving:!1,publishing:!1,selecting:!1,stats:{},statsVisible:!1},v=()=>{let e={update:new Set,saved:new Set,published:new Set,change:new Set};return{listeners:e,on:(t,r)=>(e[t].add(r),()=>{e[t].delete(r)}),emit(t,r){for(let n of e[t])try{n(r)}catch(e){console.error("[@obelism/content bridge]",e)}}}},x=()=>Promise.reject(Error("Save and publish in the visual editor itself")),y=()=>Promise.reject(Error("Only while signed in to edit on the site")),w={prompt:()=>Promise.reject(Error("Prompts only work inside the visual editor")),createPage:()=>Promise.reject(Error("New pages are made on the site itself")),createProductPage:()=>Promise.reject(Error("Product pages are made on the site itself")),createCollectionPage:()=>Promise.reject(Error("Collection pages are made on the site itself")),view:y,applyJson:y,openForm:(e,t={})=>(queueMicrotask(()=>t.onError?.("Only while signed in to edit on the site")),{close:()=>{}}),pages:y,openPage:()=>{},undo:()=>{},save:x,publish:x,signOut:()=>{},select:()=>{},setSelecting:()=>{}},k=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0,E=e=>`[${t}="${e.replace(/["\\]/g,"\\$&")}"]`,C=(e,t)=>{let r=v();e.on("saved",()=>r.emit("saved",{})),e.on("published",()=>r.emit("published",{}));let n=!1;return{isEditing:e.isEditing,mode:e.isEditing?"editor":null,entryId:e.entryId,environment:t.get(i),product:null,collection:null,on:(t,a)=>("update"!==t||n||(n=!0,e.on("update",e=>{let t=e?.entry;t&&r.emit("update",{entry:t,selectedUid:null})})),r.on(t,a)),getState:()=>f,...w,destroy:()=>{}}},A=(e,t,r={},...n)=>{let a=e.createElement(t);for(let t of(Object.assign(a,r),n))a.appendChild("string"==typeof t?e.createTextNode(t):t);return a},N='<rect x="10" y="2" width="4" height="20"/><rect x="2" y="10" width="20" height="4"/><circle cx="6" cy="6" r="2.6"/><circle cx="18" cy="6" r="2.6"/><circle cx="6" cy="18" r="2.6"/><circle cx="18" cy="18" r="2.6"/>',L='<circle cx="6" cy="6" r="2.2"/><circle cx="18" cy="6" r="2.2"/><circle cx="12" cy="12" r="2.2" class="accent"/><circle cx="6" cy="18" r="2.2"/><circle cx="18" cy="18" r="2.2"/>',P=(e,t,r)=>{let n=A(e,"span",{className:t});return n.setAttribute("aria-hidden","true"),n.innerHTML=`<svg viewBox="0 0 24 24">${r}</svg>`,n},S=(e,t)=>e.replace(/\{(\w+)\}/g,(e,r)=>r in t?String(t[r]):e),$={page:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>',newPage:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M9 15h6"/><path d="M12 18v-6"/>',block:'<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 8h10"/><path d="M7 12h6"/>',undo:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',minimize:'<path d="m6 9 6 6 6-6"/>',expand:'<path d="m18 15-6-6-6 6"/>',chevrons:'<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>',search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',check:'<path d="M20 6 9 17l-5-5"/>',mark:`<g fill="currentColor" stroke="none">${N}</g>`,send:'<path d="M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z"/><path d="M6 12h16"/>',arrowUp:'<path d="M12 19V5"/><path d="m5 12 7-7 7 7"/>',dash:'<path d="M5 12h14"/>',eye:'<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/>',eyeOff:'<path d="M10.7 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-2.2 3.2"/><path d="M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7a9.7 9.7 0 0 0 5.4-1.6"/><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2"/><path d="m2 2 20 20"/>',plus:'<path d="M5 12h14"/><path d="M12 5v14"/>',scope:'<rect x="3" y="3" width="18" height="18" rx="3" stroke-dasharray="3 3"/>',alert:'<circle cx="12" cy="12" r="10"/><path d="M12 8v4"/><path d="M12 16h.01"/>'},M=(e,t)=>P(e,"icon",$[t]),U=(e,t,r,{onReady:n,onError:a,onEscape:i})=>{let o=null,s=!1,l=null;return{get mounted(){return null!==o},get loading(){return s},get error(){return l},mount(){s=!0,l=null;let d=e.openForm(t,{title:r,onReady:()=>{o===d&&(s=!1,n())},onError:e=>{o===d&&(s=!1,l=e,a(e))},onEscape:()=>{o===d&&i?.()}});o=d},unmount(){o?.close(),o=null,s=!1,l=null}}},z={open:"Edit with a prompt",placeholder:"Describe a change, like “make it warmer”",send:"Apply",undo:"Undo",minimize:"Minimize, to see the page",scopeEntry:"Whole page",working:"Working on it…",publish:"Publish",saving:"Saving…",publishing:"Publishing…",saved:"Saved as a draft",published:"Published",unsaved:"Unsaved changes",signOut:"Exit",viewingDrafts:"Viewing drafts",newPage:"New page",newPageCancel:"Edit this page instead",newPagePlaceholder:"Describe the new page, e.g. “a pricing page for agencies”",path:"Path",pathPlaceholder:"/pricing",creating:"Writing the page…",created:"Opening the new page…",modes:"Edit with",modePrompt:"Ask",form:"Edit fields",formTitle:"The content form",formLoading:"Opening the form…",pages:"Pages",pagesSearch:"Find a page",pagesLoading:"Loading pages…",pagesEmpty:"No pages match",pageCurrent:"This page",pageDraft:"Draft",pageChanged:"Changed",addProductPage:"Add a product page",addingProductPage:"Making the product page…",addedProductPage:"Opening the product page…",productPageHint:"This product has no page yet. Add one for what the store doesn’t say.",addCollectionPage:"Add a collection page",addingCollectionPage:"Making the collection page…",addedCollectionPage:"Opening the collection page…",collectionPageHint:"This collection has no page yet. Add one for what goes around its products."},I={...z,close:"Close",expand:"Expand",scopeNoPage:"Whole page",scopeBlock:"Selected block",clearBlock:"Edit the whole page instead",save:"Save",selectHint:"Click a block to change only that block"},O={...z,editor:"Obelism editor",editing:"Editing",hideOutlines:"Show the page without outlines",environment:"Environment",envProduction:"live",scopeNoteBlock:"Working on {name}. Click another block to switch.",scopeNotePage:"Working on the whole page. Click a block to change only that block.",block:"Block",previewChip:"{name} \xb7 preview",askIntro:"Describe a change and Obelism shows it on the page. Nothing is stored until you keep it and save.",you:"You",obelism:"Obelism",suggested:"Suggested by Obelism",keep:"Keep it",retry:"Try another",retryPrompt:"{prompt}\n\nWrite a different version than the last one.",kept:"Kept",undone:"Undone",before:"Before",after:"After",emptyValue:"Empty",moreChanges:"{count} more changed",keepFirst:"Keep or undo the suggestion to save",keepBeforeFields:"Keep or undo the suggestion before editing fields.",saveDraft:"Save draft",upToDate:"No unsaved changes",saveFailed:"Couldn’t save",publishFailed:"Couldn’t publish",tryAgain:"Try again"},j=(e,t,r,{onLoad:n,onClose:a})=>{let i=A(e,"input",{type:"text",placeholder:r.pagesSearch,autocomplete:"off",spellcheck:!1});i.setAttribute("role","combobox"),i.setAttribute("aria-label",r.pagesSearch),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-controls","obelism-pages");let o=A(e,"label",{className:"search"},M(e,"search"),i),s=A(e,"ul",{className:"options",id:"obelism-pages"});s.setAttribute("role","listbox"),s.setAttribute("aria-label",r.pages);let l=A(e,"p",{className:"empty"}),d=null,p=null,c=null,u=0,g=()=>{let e=i.value.trim().toLowerCase();return(d??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.url.toLowerCase().includes(e)||`/${t.path}`.toLowerCase().includes(e))},h=e=>{if(e.entryId===t.entryId)return a();t.openPage(e)},b=()=>{let n=g();u=Math.max(0,Math.min(u,n.length-1)),s.textContent="",n.forEach((n,a)=>{let i=A(e,"li",{className:`option${a===u?" active":""}`,id:`obelism-page-${a}`},A(e,"span",{className:"option-text"},A(e,"span",{textContent:n.name}),A(e,"span",{className:"option-path",textContent:n.url})));if(i.setAttribute("role","option"),i.setAttribute("aria-selected",String(a===u)),"published"!==n.status&&i.appendChild(A(e,"span",{className:"badge",textContent:"draft"===n.status?r.pageDraft:r.pageChanged})),n.entryId===t.entryId){i.setAttribute("aria-current","page");let t=M(e,"check");t.removeAttribute("aria-hidden"),t.setAttribute("role","img"),t.setAttribute("aria-label",r.pageCurrent),i.appendChild(t)}i.addEventListener("click",()=>h(n)),s.appendChild(i)});let a=s.children[u];a?(i.setAttribute("aria-activedescendant",a.id),a.scrollIntoView?.({block:"nearest"})):i.removeAttribute("aria-activedescendant"),l.textContent=(c??(d?"":r.pagesLoading))||(0===n.length?r.pagesEmpty:""),l.hidden=!l.textContent,l.className=`empty${c?" error":""}`},m=()=>(p??(p=t.pages().then(e=>{d=e,c=null,b(),n()},e=>{p=null,c=e instanceof Error?e.message:String(e),b(),n()})),p);return i.addEventListener("input",()=>{u=0,b()}),i.addEventListener("keydown",e=>{let t=s.children.length;if("ArrowDown"===e.key||"ArrowUp"===e.key){if(e.preventDefault(),0===t)return;u=(u+("ArrowDown"===e.key?1:-1)+t)%t,b()}else if("Enter"!==e.key||e.isComposing)"Escape"===e.key&&(e.preventDefault(),a());else{e.preventDefault();let t=g()[u];t&&h(t)}}),{searchRow:o,search:i,list:s,note:l,get pages(){return d},get error(){return c},current:()=>d?.find(({entryId:e})=>e===t.entryId)??null,fetch:m,forget(){d=null,p=null},reset(){i.value="",u=Math.max(0,(d??[]).findIndex(({entryId:e})=>e===t.entryId)),m(),b()},render:b}},R=e=>e instanceof Error?e.message:String(e),D=(e,t,r)=>{let n="site"===e.mode,a=n&&t.features.includes("create"),i=n&&null===e.entryId,o=i&&a?e.product?"product":e.collection?"collection":null:null;return{site:n,canCreate:a,pageless:i,shopHere:o,onlyNew:i&&a&&!o&&!r}},T=(e,t)=>"collection"===t?{add:e.addCollectionPage,adding:e.addingCollectionPage,hint:e.collectionPageHint}:{add:e.addProductPage,adding:e.addingProductPage,hint:e.productPageHint},q=async(e,t)=>{try{if(e.product)return await e.createProductPage(),{text:t.addedProductPage,error:!1};return await e.createCollectionPage(),{text:t.addedCollectionPage,error:!1}}catch(e){return{text:R(e),error:!0}}},F=async(e,t)=>{try{return await e[t](),null}catch(e){return R(e)}},B="obelism-content-prompt-side",H=`
|
|
25
|
+
`,d=(e,t)=>e.height>=64?{place:"inside",top:Math.max(e.top,0)+8,left:e.right-8}:e.right+8+140<=t?{place:"beside",top:e.top+e.height/2,left:e.right+8}:{place:"above",top:e.top-4,left:e.right},p=/(-?\d*\.?\d+)(?:s|l|d)?vh\b/g,c=(e,t)=>(p.lastIndex=0,p.test(e))?e.replace(p,(e,r)=>`${Math.round(Number(r)*t/100*100)/100}px`):null,u=(e,t)=>{for(let r=0;r<e.length;r++){let n=e.item(r),a=c(e.getPropertyValue(n),t);null!==a&&e.setProperty(n,a,e.getPropertyPriority(n))}},g=(e,t)=>{for(let r of Array.from(e)){let{style:e,cssRules:n}=r;e&&u(e,t),n&&g(n,t)}},h="obelism-content-bridge",b="#d58a1f",m=(e="")=>`${e}[${t}]{cursor:pointer;transition:outline-color .15s}${e}[${t}]:hover{outline:2px dashed ${b};outline-offset:2px}${e}[${t}][data-cms-selected]{outline:2px solid ${b};outline-offset:2px}`,f={features:[],selectedUid:null,prompting:!1,canUndo:!1,unsaved:!1,saving:!1,publishing:!1,selecting:!1,stats:{},statsVisible:!1},v=()=>{let e={update:new Set,saved:new Set,published:new Set,change:new Set};return{listeners:e,on:(t,r)=>(e[t].add(r),()=>{e[t].delete(r)}),emit(t,r){for(let n of e[t])try{n(r)}catch(e){console.error("[@obelism/content bridge]",e)}}}},x=()=>Promise.reject(Error("Save and publish in the visual editor itself")),y=()=>Promise.reject(Error("Only while signed in to edit on the site")),w={prompt:()=>Promise.reject(Error("Prompts only work inside the visual editor")),createPage:()=>Promise.reject(Error("New pages are made on the site itself")),createProductPage:()=>Promise.reject(Error("Product pages are made on the site itself")),createCollectionPage:()=>Promise.reject(Error("Collection pages are made on the site itself")),view:y,applyJson:y,openForm:(e,t={})=>(queueMicrotask(()=>t.onError?.("Only while signed in to edit on the site")),{close:()=>{}}),pages:y,openPage:()=>{},undo:()=>{},save:x,publish:x,signOut:()=>{},select:()=>{},setSelecting:()=>{}},k=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0,E=e=>`[${t}="${e.replace(/["\\]/g,"\\$&")}"]`,C=(e,t)=>{let r=v();e.on("saved",()=>r.emit("saved",{})),e.on("published",()=>r.emit("published",{}));let n=!1;return{isEditing:e.isEditing,mode:e.isEditing?"editor":null,entryId:e.entryId,environment:t.get(i),product:null,collection:null,on:(t,a)=>("update"!==t||n||(n=!0,e.on("update",e=>{let t=e?.entry;t&&r.emit("update",{entry:t,selectedUid:null})})),r.on(t,a)),getState:()=>f,...w,destroy:()=>{}}},N=(e,t,r={},...n)=>{let a=e.createElement(t);for(let t of(Object.assign(a,r),n))a.appendChild("string"==typeof t?e.createTextNode(t):t);return a},A='<rect x="10" y="2" width="4" height="20"/><rect x="2" y="10" width="20" height="4"/><circle cx="6" cy="6" r="2.6"/><circle cx="18" cy="6" r="2.6"/><circle cx="6" cy="18" r="2.6"/><circle cx="18" cy="18" r="2.6"/>',L='<circle cx="6" cy="6" r="2.2"/><circle cx="18" cy="6" r="2.2"/><circle cx="12" cy="12" r="2.2" class="accent"/><circle cx="6" cy="18" r="2.2"/><circle cx="18" cy="18" r="2.2"/>',P=(e,t,r)=>{let n=N(e,"span",{className:t});return n.setAttribute("aria-hidden","true"),n.innerHTML=`<svg viewBox="0 0 24 24">${r}</svg>`,n},S=(e,t)=>e.replace(/\{(\w+)\}/g,(e,r)=>r in t?String(t[r]):e),$={page:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>',newPage:'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M9 15h6"/><path d="M12 18v-6"/>',block:'<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 8h10"/><path d="M7 12h6"/>',undo:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>',close:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',minimize:'<path d="m6 9 6 6 6-6"/>',expand:'<path d="m18 15-6-6-6 6"/>',chevrons:'<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>',search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',check:'<path d="M20 6 9 17l-5-5"/>',mark:`<g fill="currentColor" stroke="none">${A}</g>`,send:'<path d="M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z"/><path d="M6 12h16"/>',arrowUp:'<path d="M12 19V5"/><path d="m5 12 7-7 7 7"/>',dash:'<path d="M5 12h14"/>',eye:'<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/>',eyeOff:'<path d="M10.7 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-2.2 3.2"/><path d="M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7a9.7 9.7 0 0 0 5.4-1.6"/><path d="M9.9 9.9a3 3 0 0 0 4.2 4.2"/><path d="m2 2 20 20"/>',plus:'<path d="M5 12h14"/><path d="M12 5v14"/>',scope:'<rect x="3" y="3" width="18" height="18" rx="3" stroke-dasharray="3 3"/>',alert:'<circle cx="12" cy="12" r="10"/><path d="M12 8v4"/><path d="M12 16h.01"/>'},M=(e,t)=>P(e,"icon",$[t]),U=(e,t,r,{onReady:n,onError:a,onEscape:i})=>{let o=null,s=!1,l=null;return{get mounted(){return null!==o},get loading(){return s},get error(){return l},mount(){s=!0,l=null;let d=e.openForm(t,{title:r,onReady:()=>{o===d&&(s=!1,n())},onError:e=>{o===d&&(s=!1,l=e,a(e))},onEscape:()=>{o===d&&i?.()}});o=d},unmount(){o?.close(),o=null,s=!1,l=null}}},z={open:"Edit with a prompt",placeholder:"Describe a change, like “make it warmer”",send:"Apply",undo:"Undo",minimize:"Minimize, to see the page",scopeEntry:"Whole page",working:"Working on it…",publish:"Publish",saving:"Saving…",publishing:"Publishing…",saved:"Saved as a draft",published:"Published",unsaved:"Unsaved changes",signOut:"Exit",viewingDrafts:"Viewing drafts",newPage:"New page",newPageCancel:"Edit this page instead",newPagePlaceholder:"Describe the new page, e.g. “a pricing page for agencies”",path:"Path",pathPlaceholder:"/pricing",creating:"Writing the page…",created:"Opening the new page…",modes:"Edit with",modePrompt:"Ask",form:"Edit fields",formTitle:"The content form",formLoading:"Opening the form…",pages:"Pages",pagesSearch:"Find a page",pagesLoading:"Loading pages…",pagesEmpty:"No pages match",pageCurrent:"This page",pageDraft:"Draft",pageChanged:"Changed",addProductPage:"Add a product page",addingProductPage:"Making the product page…",addedProductPage:"Opening the product page…",productPageHint:"This product has no page yet. Add one for what the store doesn’t say.",addCollectionPage:"Add a collection page",addingCollectionPage:"Making the collection page…",addedCollectionPage:"Opening the collection page…",collectionPageHint:"This collection has no page yet. Add one for what goes around its products."},I={...z,close:"Close",expand:"Expand",scopeNoPage:"Whole page",scopeBlock:"Selected block",clearBlock:"Edit the whole page instead",save:"Save",selectHint:"Click a block to change only that block"},O={...z,editor:"Obelism editor",editing:"Editing",hideOutlines:"Show the page without outlines",environment:"Environment",envProduction:"live",scopeNoteBlock:"Working on {name}. Click another block to switch.",scopeNotePage:"Working on the whole page. Click a block to change only that block.",block:"Block",previewChip:"{name} \xb7 preview",askIntro:"Describe a change and Obelism shows it on the page. Nothing is stored until you keep it and save.",you:"You",obelism:"Obelism",suggested:"Suggested by Obelism",keep:"Keep it",retry:"Try another",retryPrompt:"{prompt}\n\nWrite a different version than the last one.",kept:"Kept",undone:"Undone",before:"Before",after:"After",emptyValue:"Empty",moreChanges:"{count} more changed",keepFirst:"Keep or undo the suggestion to save",keepBeforeFields:"Keep or undo the suggestion before editing fields.",saveDraft:"Save draft",upToDate:"No unsaved changes",saveFailed:"Couldn’t save",publishFailed:"Couldn’t publish",tryAgain:"Try again"},j=(e,t,r,{onLoad:n,onClose:a})=>{let i=N(e,"input",{type:"text",placeholder:r.pagesSearch,autocomplete:"off",spellcheck:!1});i.setAttribute("role","combobox"),i.setAttribute("aria-label",r.pagesSearch),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-controls","obelism-pages");let o=N(e,"label",{className:"search"},M(e,"search"),i),s=N(e,"ul",{className:"options",id:"obelism-pages"});s.setAttribute("role","listbox"),s.setAttribute("aria-label",r.pages);let l=N(e,"p",{className:"empty"}),d=null,p=null,c=null,u=0,g=()=>{let e=i.value.trim().toLowerCase();return(d??[]).filter(t=>!e||t.name.toLowerCase().includes(e)||t.url.toLowerCase().includes(e)||`/${t.path}`.toLowerCase().includes(e))},h=e=>{if(e.entryId===t.entryId)return a();t.openPage(e)},b=()=>{let n=g();u=Math.max(0,Math.min(u,n.length-1)),s.textContent="",n.forEach((n,a)=>{let i=N(e,"li",{className:`option${a===u?" active":""}`,id:`obelism-page-${a}`},N(e,"span",{className:"option-text"},N(e,"span",{textContent:n.name}),N(e,"span",{className:"option-path",textContent:n.url})));if(i.setAttribute("role","option"),i.setAttribute("aria-selected",String(a===u)),"published"!==n.status&&i.appendChild(N(e,"span",{className:"badge",textContent:"draft"===n.status?r.pageDraft:r.pageChanged})),n.entryId===t.entryId){i.setAttribute("aria-current","page");let t=M(e,"check");t.removeAttribute("aria-hidden"),t.setAttribute("role","img"),t.setAttribute("aria-label",r.pageCurrent),i.appendChild(t)}i.addEventListener("click",()=>h(n)),s.appendChild(i)});let a=s.children[u];a?(i.setAttribute("aria-activedescendant",a.id),a.scrollIntoView?.({block:"nearest"})):i.removeAttribute("aria-activedescendant"),l.textContent=(c??(d?"":r.pagesLoading))||(0===n.length?r.pagesEmpty:""),l.hidden=!l.textContent,l.className=`empty${c?" error":""}`},m=()=>(p??(p=t.pages().then(e=>{d=e,c=null,b(),n()},e=>{p=null,c=e instanceof Error?e.message:String(e),b(),n()})),p);return i.addEventListener("input",()=>{u=0,b()}),i.addEventListener("keydown",e=>{let t=s.children.length;if("ArrowDown"===e.key||"ArrowUp"===e.key){if(e.preventDefault(),0===t)return;u=(u+("ArrowDown"===e.key?1:-1)+t)%t,b()}else if("Enter"!==e.key||e.isComposing)"Escape"===e.key&&(e.preventDefault(),a());else{e.preventDefault();let t=g()[u];t&&h(t)}}),{searchRow:o,search:i,list:s,note:l,get pages(){return d},get error(){return c},current:()=>d?.find(({entryId:e})=>e===t.entryId)??null,fetch:m,forget(){d=null,p=null},reset(){i.value="",u=Math.max(0,(d??[]).findIndex(({entryId:e})=>e===t.entryId)),m(),b()},render:b}},R=e=>e instanceof Error?e.message:String(e),T=(e,t,r)=>{let n="site"===e.mode,a=n&&t.features.includes("create"),i=n&&null===e.entryId,o=i&&a?e.product?"product":e.collection?"collection":null:null;return{site:n,canCreate:a,pageless:i,shopHere:o,onlyNew:i&&a&&!o&&!r}},D=(e,t)=>"collection"===t?{add:e.addCollectionPage,adding:e.addingCollectionPage,hint:e.collectionPageHint}:{add:e.addProductPage,adding:e.addingProductPage,hint:e.productPageHint},q=async(e,t)=>{try{if(e.product)return await e.createProductPage(),{text:t.addedProductPage,error:!1};return await e.createCollectionPage(),{text:t.addedCollectionPage,error:!1}}catch(e){return{text:R(e),error:!0}}},F=async(e,t)=>{try{return await e[t](),null}catch(e){return R(e)}},B="obelism-content-prompt-side",_=`
|
|
26
26
|
:host { all: initial; }
|
|
27
27
|
* { box-sizing: border-box; font: inherit; color: inherit; margin: 0; }
|
|
28
28
|
.root {
|
|
@@ -253,7 +253,7 @@ button.chip:disabled { opacity: .5; }
|
|
|
253
253
|
.empty { padding: 8px 12px; color: rgb(var(--theme-foreground-muted-rgb)); }
|
|
254
254
|
.empty.error { color: var(--theme-error); }
|
|
255
255
|
[hidden] { display: none !important; }
|
|
256
|
-
`,
|
|
256
|
+
`,H=(e,t,r={})=>{let n,a={...I,...r.labels},i=N(e,"div");i.setAttribute("data-obelism-content-prompt","");let o=i.attachShadow({mode:"open"}),s="site"===t.mode,l=N(e,"span",{textContent:a.open}),d=N(e,"button",{className:"pill",type:"button"},l,((n=M(e,"mark")).classList.add("mark"),n)),p=N(e,"span",{className:"pill compact"},`${a.viewingDrafts} \xb7 `),c=N(e,"button",{className:"link",type:"button",textContent:a.signOut});p.appendChild(c);let u=N(e,"p",{className:"status"});u.setAttribute("role","status");let g=N(e,"textarea",{placeholder:a.placeholder,rows:1});g.setAttribute("aria-label",a.open);let h=N(e,"div",{className:"form-loader",textContent:a.formLoading});h.setAttribute("role","status");let b=N(e,"div",{className:"form"},h),m=M(e,"page"),f=M(e,"block"),v=N(e,"span"),x=N(e,"button",{type:"button",title:a.clearBlock});x.setAttribute("aria-label",a.clearBlock),x.appendChild(M(e,"close"));let y=N(e,"span",{className:"chip scope"},m,f,v,x),w=N(e,"button",{className:"action chip",type:"button"},M(e,"undo"),a.undo),k=t=>{let r=N(e,"button",{type:"button",textContent:t});return r.setAttribute("aria-pressed","false"),r},E=k(a.modePrompt),C=k(a.form),A=N(e,"span",{className:"modes"},E,C);A.setAttribute("role","group"),A.setAttribute("aria-label",a.modes);let L=N(e,"button",{className:"action chip",type:"button"},M(e,"newPage"),a.newPage),P=N(e,"button",{className:"action chip product",type:"button"},M(e,"newPage"),a.addProductPage),S=N(e,"button",{type:"button",title:a.newPageCancel});S.setAttribute("aria-label",a.newPageCancel),S.appendChild(M(e,"close"));let $=N(e,"span",{className:"chip scope"},M(e,"newPage"),N(e,"span",{textContent:a.newPage}),S),z=N(e,"input",{type:"text",placeholder:a.pathPlaceholder,autocomplete:"off",spellcheck:!1}),O=N(e,"label",{className:"path"},N(e,"span",{textContent:a.path}),z),H=N(e,"button",{className:"close icon-button",type:"button",title:a.close},M(e,"close"));H.setAttribute("aria-label",a.close);let V=M(e,"minimize"),W=M(e,"expand"),Y=N(e,"button",{className:"icon-button",type:"button"},V,W),X=N(e,"button",{className:"action primary icon-button",type:"submit"},N(e,"span",{className:"visually-hidden",textContent:a.send}),M(e,"send"));X.title=a.send;let K=N(e,"span",{className:"divider"}),J=N(e,"div",{className:"toolbar"},y,$,A,w,P,L,N(e,"span",{className:"spacer"}),Y,H,K,X),Z=N(e,"span",{textContent:a.pages}),G=N(e,"button",{className:"chip page-chip",type:"button",title:a.pages},M(e,"page"),Z,M(e,"chevrons"));G.setAttribute("aria-haspopup","listbox"),G.setAttribute("aria-expanded","false"),G.setAttribute("aria-controls","obelism-pages");let Q=j(e,t,a,{onLoad:()=>eE(),onClose:()=>eL(!1)}),ee=N(e,"div",{className:"pages"},Q.searchRow,Q.list,Q.note),et=N(e,"slot");et.name="actions-footer";let er=N(e,"slot");er.name="actions-bar",r.actions&&(r.actions.slot="actions-bar",i.appendChild(r.actions));let en=N(e,"span",{className:"unsaved"});en.appendChild(N(e,"span",{className:"dot"})),en.appendChild(e.createTextNode(a.unsaved));let ea=N(e,"button",{className:"link",type:"button",textContent:a.signOut}),ei=N(e,"button",{className:"action chip",type:"button",textContent:a.save}),eo=N(e,"button",{className:"action chip",type:"button",textContent:a.publish}),es=N(e,"div",{className:"footer"},G,en,N(e,"span",{className:"spacer"}),et,ea,ei,eo),el=N(e,"form",{className:"panel"},u,O,g,b,J,ee,es),ed=N(e,"div",{className:"root"},N(e,"div",{className:"bar"},d,p,er),el);o.append(N(e,"style",{textContent:_}),ed);let ep=e.defaultView,ec=e=>{"center"===e?delete ed.dataset.side:ed.dataset.side=e};ec((()=>{try{let e=ep?.localStorage.getItem(B);return"left"===e||"right"===e?e:"center"}catch{return"center"}})());let eu=null,eg=!1;ed.addEventListener("pointerdown",e=>{if(eg=!1,0!==e.button||!e.isPrimary)return;let t=e.target.closest("button, input, textarea, select, iframe, a, label, .pages, .form");if(t&&t!==d)return;let{left:r,right:n}=ed.getBoundingClientRect();eu={id:e.pointerId,startX:e.clientX,x:e.clientX,velocity:0,time:e.timeStamp,moved:!1,min:Math.min(0,16-r),max:Math.max(0,(ep?.innerWidth??0)-16-n)}}),ed.addEventListener("pointermove",e=>{if(!eu||e.pointerId!==eu.id)return;let t=e.clientX-eu.startX;if(!eu.moved){if(6>Math.abs(t))return;eu.moved=!0,ed.classList.add("dragging");try{ed.setPointerCapture(e.pointerId)}catch{}}let r=e.timeStamp-eu.time;r>0&&(eu.velocity=(e.clientX-eu.x)/r),eu.x=e.clientX,eu.time=e.timeStamp;let n=Math.min(Math.max(t,eu.min),eu.max);ed.style.translate=`${n+(t-n)/3}px 0`});let eh=e=>{if(!eu||e.pointerId!==eu.id)return;let{moved:t,x:r,velocity:n,time:a}=eu;if(eu=null,!t)return;eg=!0;let i=ed.getBoundingClientRect().left,o=ep?.innerWidth??0,s=r+(e.timeStamp-a>80?0:Math.min(Math.max(150*n,-120),120)),l=s<o/3?"left":s>2*o/3?"right":"center";ec(l),ed.style.translate="";let d=ed.getBoundingClientRect().left;ed.style.translate=`${i-d}px 0`,ed.offsetWidth,ed.classList.remove("dragging"),ed.style.translate="";try{ep?.localStorage.setItem(B,l)}catch{}};ed.addEventListener("pointerup",eh),ed.addEventListener("pointercancel",eh),ed.addEventListener("click",e=>{eg&&(eg=!1,e.preventDefault(),e.stopPropagation())},!0);let eb=!1,em=!1,ef=!1,ev=null,ex=!1,ey=U(t,b,a.formTitle,{onReady:()=>{ev=null,eE()},onError:e=>{ev={text:e,error:!0},eE()}}),ew=!1,ek=e=>{let n=e.features.includes("prompt"),i=e.saving||e.publishing,o=e.prompting||i;ed.hidden=!n&&!s,d.hidden=eb||!n,p.hidden=n||!s,el.hidden=!eb||!n;let{canCreate:k,pageless:N,shopHere:M,onlyNew:U}=T(t,e,r.promptWithoutPage),I=null!==M,j=D(a,M);P.lastChild.textContent=j.add,k||(ef=!1),U&&(ef=!0),(ef||N||!s)&&(ex=!1);let R=eb&&n&&ex;R&&!ey.mounted?ey.mount():!R&&ey.mounted&&ey.unmount();let q=I&&!ef;l.textContent=q?j.add:U?a.newPage:a.open,S.hidden=U,y.hidden=ef||q,$.hidden=!ef,P.hidden=!q,P.disabled=o,L.hidden=ef||ex||!k,L.disabled=o,em&&(ew=!1),O.hidden=!ef||ew||em,z.disabled=o,g.hidden=ex||ew||em||q,b.hidden=!ex||ew||em,b.classList.toggle("loading",ey.loading),h.hidden=!ey.loading,J.hidden=ew,ee.hidden=!ew,g.placeholder=ef?a.newPagePlaceholder:a.placeholder,v.textContent=e.selectedUid?a.scopeBlock:N?a.scopeNoPage:a.scopeEntry,x.hidden=!e.selectedUid,m.hidden=!!e.selectedUid,f.hidden=!e.selectedUid,A.hidden=!s||ef||N||!e.features.includes("form"),E.setAttribute("aria-pressed",String(!ex)),C.setAttribute("aria-pressed",String(ex)),A.querySelectorAll("button").forEach(e=>{e.disabled=o}),w.hidden=ef||!e.canUndo,w.disabled=o,X.hidden=ex||em||q,K.hidden=ex||em||q;let F=em?a.expand:a.minimize;Y.title=F,Y.setAttribute("aria-label",F),Y.setAttribute("aria-expanded",String(!em)),V.hidden=em,W.hidden=!em,X.disabled=o||""===g.value.trim()||ef&&""===z.value.trim(),g.disabled=o,ei.hidden=!e.features.includes("save")||N,ei.disabled=o||!e.unsaved,ei.textContent=e.saving?a.saving:a.save,eo.hidden=!e.features.includes("publish")||N,eo.disabled=o,eo.textContent=e.publishing?a.publishing:a.publish,ea.hidden=!s||!1===r.signOut,c.hidden=!1===r.signOut,r.actions&&(r.actions.slot=eb&&n?"actions-footer":"actions-bar"),es.hidden=!s,en.hidden=!e.unsaved,G.hidden=!s,G.setAttribute("aria-expanded",String(ew)),Z.textContent=Q.current()?.name??a.pages;let B=ex&&ey.loading&&!ew,_=e.prompting,H=e.prompting?ef?a.creating:q?j.adding:a.working:B?"":ev?.text??(q?j.hint:!s||ef||ew||e.selectedUid?"":a.selectHint);u.textContent=H,u.hidden=!H||em,u.className=`status${_?" working":""}${!o&&!B&&ev?.error?" error":""}`},eE=()=>ek(t.getState()),eC=()=>{g.style.height="auto",g.style.height=`${g.scrollHeight}px`},eN=e=>{ex!==e&&(ex=e,ev=null,eE(),ex||g.focus())},eA=async()=>{if(ex)return;let e=g.value.trim();if(e&&!t.getState().prompting){ev=null;try{if(ef){let r=z.value.trim();if(!r)return z.focus();await t.createPage(r,e),Q.forget(),ev={text:a.created,error:!1}}else{let{summary:r}=await t.prompt(e);ev={text:r,error:!1}}g.value="",eC()}catch(e){ev={text:R(e),error:!0}}eE(),g.focus()}},eL=e=>{ev=null,(ew=e)&&Q.reset(),eE(),(ew?Q.search:G).focus()},eP=e=>{(eb=e)||(ew=!1,em=!1),eE(),s&&t.setSelecting(eb&&!ef),eb&&s&&Q.fetch()},eS=e=>{ef=e,ev=null,t.setSelecting(eb&&!ef),ef&&t.select(null),eE(),(ef?z:g).focus()},e$=async e=>{ev=null;let r=await F(t,e);ev=r?{text:r,error:!0}:{text:"save"===e?a.saved:a.published,error:!1},eE()};d.addEventListener("click",()=>{eP(!0),ex||(ef?z:g).focus()}),H.addEventListener("click",()=>eP(!1)),Y.addEventListener("click",()=>{em=!em,eE(),em||(ex?Y:g).focus()}),el.addEventListener("click",e=>{if(!em)return;let t=e.target.closest("button");t&&t!==Y&&t!==H&&(em=!1,eE())},!0),ei.addEventListener("click",()=>void e$("save")),eo.addEventListener("click",()=>void e$("publish")),ea.addEventListener("click",()=>t.signOut()),c.addEventListener("click",()=>t.signOut()),x.addEventListener("click",()=>t.select(null)),L.addEventListener("click",()=>eS(!0)),P.addEventListener("click",async()=>{ev=null,ev=await q(t,a),eE()}),S.addEventListener("click",()=>eS(!1)),E.addEventListener("click",()=>eN(!1)),C.addEventListener("click",()=>eN(!0)),G.addEventListener("click",()=>eL(!ew)),z.addEventListener("input",eE),z.addEventListener("keydown",e=>{"Enter"!==e.key||e.isComposing?"Escape"===e.key&&eP(!1):(e.preventDefault(),g.focus())}),w.addEventListener("click",()=>{ev=null,t.undo()}),el.addEventListener("submit",e=>{e.preventDefault(),eA()}),g.addEventListener("input",()=>{eC(),eE()}),g.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||e.isComposing?"Escape"===e.key&&eP(!1):(e.preventDefault(),eA())});let eM=t.on("change",ek);return eE(),e.body.appendChild(i),()=>{eM(),ey.unmount(),i.remove()}},V="https://content.obelism.studio",W=/^(?:\/[\w.~-]+)+$/,Y=e=>{let{protocol:t}=new URL(e,"https://site.invalid");if("https:"!==t&&"http:"!==t)throw Error(`Not a page address: ${e}`);return e},X=(e,t)=>JSON.stringify(e)===JSON.stringify(t),K="obelism-content-editor",J=`
|
|
257
257
|
:host { all: initial; }
|
|
258
258
|
* { box-sizing: border-box; font: inherit; color: inherit; margin: 0; }
|
|
259
259
|
.root {
|
|
@@ -400,17 +400,15 @@ button:disabled { cursor: not-allowed; }
|
|
|
400
400
|
.empty.error { color: rgb(var(--negative)); }
|
|
401
401
|
.new-page { justify-content: flex-start; }
|
|
402
402
|
|
|
403
|
-
.
|
|
404
|
-
display:
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
.
|
|
412
|
-
.tab[aria-selected='true'] { background: rgb(var(--bg)); color: rgb(var(--fg)); box-shadow: var(--shadow-small); }
|
|
413
|
-
.tab .mark svg { width: 12px; height: 12px; }
|
|
403
|
+
.mode {
|
|
404
|
+
display: inline-flex; align-items: center; gap: 6px; flex: none; height: 32px;
|
|
405
|
+
padding: 0 12px; border-radius: 999px; background: rgb(var(--paper));
|
|
406
|
+
font-size: 13px; font-weight: 500; color: rgb(var(--soft));
|
|
407
|
+
}
|
|
408
|
+
.mode:hover:not(:disabled) { background: rgb(var(--actions)); color: rgb(var(--fg)); }
|
|
409
|
+
.mode[aria-pressed='true'] { background: rgb(var(--coral-wash)); color: rgb(var(--coral-ink)); }
|
|
410
|
+
.mode:disabled { opacity: .5; }
|
|
411
|
+
.mode .mark svg { width: 12px; height: 12px; }
|
|
414
412
|
.ask, .fields { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
415
413
|
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; }
|
|
416
414
|
.note {
|
|
@@ -509,7 +507,9 @@ textarea:disabled, .path input:disabled { opacity: .6; }
|
|
|
509
507
|
.send .icon svg { stroke-width: 2; }
|
|
510
508
|
.send .working svg, .send .working .accent { fill: rgb(var(--ink)); }
|
|
511
509
|
|
|
512
|
-
.
|
|
510
|
+
.fields { padding-top: 12px; }
|
|
511
|
+
.fields .note { margin: 0 14px 14px; }
|
|
512
|
+
.form { position: relative; flex: 1; min-height: 0; margin: 0 14px; }
|
|
513
513
|
.form iframe {
|
|
514
514
|
display: block; width: 100%; height: 100% !important; border: 0; border-radius: 12px; background: rgb(var(--subtle));
|
|
515
515
|
}
|
|
@@ -575,4 +575,4 @@ textarea:disabled, .path input:disabled { opacity: .6; }
|
|
|
575
575
|
.chips .accent-chip .mark { color: rgb(23 22 20); }
|
|
576
576
|
.chips .accent-chip .mark svg { width: 11px; height: 11px; }
|
|
577
577
|
.chips .ink-chip { background: rgb(23 22 20); color: rgb(255 255 255); font-weight: 500; }
|
|
578
|
-
`,Z=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},G=e=>!!e&&"object"==typeof e&&!Array.isArray(e),Q=(e,t,r,n)=>{if(null!=e&&""!==e){if("object"!=typeof e)return void n.set(r,{label:t,text:String(e)});if(Array.isArray(e)){if(e.every(e=>null===e||"object"!=typeof e)){e.length&&n.set(r,{label:t,text:e.join(", ")});return}e.forEach((e,a)=>{let i=G(e)&&"string"==typeof e._uid?e._uid:a,o=G(e)&&"string"==typeof e._type?e._type:null;Q(e,o?Z(o):t,`${r}/${i}`,n)});return}for(let[a,i]of Object.entries(e))"_uid"!==a&&"_type"!==a&&Q(i,t?`${t} \xb7 ${Z(a)}`:Z(a),`${r}/${a}`,n)}},ee=(e,n,a={})=>{let i,o={...O,...a.labels},s=e.defaultView,l=e.documentElement,d=(t,...r)=>A(e,"button",{className:t,type:"button"},...r),p=A(e,"div");p.setAttribute("data-obelism-content-editor","");let c=p.attachShadow({mode:"open"}),u=A(e,"style",{textContent:(i=`[${t}]`,`html[data-obelism-editor]{transition:margin-right .3s cubic-bezier(.2,.8,.2,1)}html[data-obelism-docked]{margin-right:436px!important}html[data-obelism-docked] [data-obelism-dock]{right:436px!important;max-width:calc(100vw - 436px)!important}html[data-obelism-editor][data-cms-selecting] ${i}:hover:not([data-cms-selected]){outline:none}html[data-obelism-editor][data-cms-selecting] ${i}[data-cms-selected]{outline:2px solid rgb(212 130 30);outline-offset:2px}@media (prefers-reduced-motion:reduce){html[data-obelism-editor]{transition:none}}`)}),g=A(e,"span",{className:"tile"},P(e,"mark",N)),h=A(e,"span"),b=d("page-button hit",h,A(e,"span",{className:"visually-hidden",textContent:`, ${o.pages}`}),M(e,"chevrons"));b.setAttribute("aria-haspopup","listbox"),b.setAttribute("aria-expanded","false"),b.setAttribute("aria-controls","obelism-pages");let m=A(e,"span",{className:"page-name"}),f=A(e,"span"),v=A(e,"span",{className:"env"},A(e,"span",{className:"visually-hidden",textContent:`${o.environment}: `}),f),x=d("icon-button hit",M(e,"dash"));x.setAttribute("aria-label",o.minimize),x.title=o.minimize;let y=A(e,"div",{className:"head"},g,b,m,v,A(e,"span",{className:"spacer"}),x),w=j(e,n,o,{onLoad:()=>ti(),onClose:()=>tc(!1)}),k=d("button quiet new-page",M(e,"plus"),o.newPage),C=A(e,"div",{className:"pages"},w.searchRow,w.list,w.note,k),$=(e,t,...r)=>{let n=d("tab",...r);return n.id=e,n.setAttribute("role","tab"),n.setAttribute("aria-controls",t),n},z=$("obelism-tab-ask","obelism-ask",P(e,"mark",N),o.modePrompt),I=$("obelism-tab-fields","obelism-fields",o.form),B=A(e,"div",{className:"tabs"},z,I);B.setAttribute("role","tablist"),B.setAttribute("aria-label",o.modes);let H=d("button primary",o.keep),_=d("button quiet",o.undo),V=A(e,"div",{className:"gate"},A(e,"p",{textContent:o.keepBeforeFields}),A(e,"div",{className:"actions"},H,_));V.setAttribute("role","alert");let W=A(e,"span"),Y=d("",o.scopeEntry),X=d("",o.newPageCancel),ee=A(e,"div",{className:"note"},M(e,"scope"),W,Y,X),et=A(e,"p",{className:"intro",textContent:o.askIntro}),er=A(e,"p",{className:"summary"}),en=A(e,"span"),ea=d("button primary",M(e,"plus"),en),ei=A(e,"div",{className:"shop"},er,ea),eo=A(e,"div",{className:"log"});eo.setAttribute("role","log");let es=A(e,"div",{className:"scroll"},ee,et,ei,eo),el=A(e,"input",{type:"text",placeholder:o.pathPlaceholder,autocomplete:"off",spellcheck:!1}),ed=A(e,"label",{className:"path"},A(e,"span",{textContent:o.path}),el),ep=A(e,"textarea",{rows:1});ep.setAttribute("aria-label",o.open);let ec=M(e,"arrowUp"),eu=P(e,"working",L),eg=A(e,"button",{className:"send",type:"submit",title:o.send},A(e,"span",{className:"visually-hidden",textContent:o.send}),ec,eu),eh=A(e,"div",{className:"bar"},P(e,"mark",N),ep,eg),eb=A(e,"form",{className:"composer"},ed,eh),em=A(e,"div",{className:"ask",id:"obelism-ask"},es,eb);em.setAttribute("role","tabpanel"),em.setAttribute("aria-labelledby",z.id);let ef=A(e,"p",{className:"form-note"});ef.setAttribute("role","status");let ev=A(e,"div",{className:"form"},ef),ex=A(e,"div",{className:"fields",id:"obelism-fields"},ev);ex.setAttribute("role","tabpanel"),ex.setAttribute("aria-labelledby",I.id);let ey=A(e,"p",{className:"save-state"});ey.setAttribute("aria-live","polite");let ew=A(e,"slot");ew.name="actions-footer";let ek=d("button quiet",M(e,"undo"),o.undo),eE=d("button secondary",o.saveDraft),eC=d("button primary",o.publish),eA=A(e,"div",{className:"foot"},ey,ew,ek,eE,eC),eN=A(e,"p",{className:"visually-hidden"});eN.setAttribute("role","status");let eL=A(e,"aside",{className:"panel",id:"obelism-editor"},y,C,B,V,em,ex,eA,eN);eL.setAttribute("aria-label",o.editor);let eP=d("launch",A(e,"span",{className:"launch-tile"},P(e,"mark",N)),o.editing);eP.setAttribute("aria-controls",eL.id);let eS=A(e,"span",{className:"reading"},A(e,"span",{className:"launch-tile"},P(e,"mark",N)),o.viewingDrafts),e$=M(e,"eye"),eM=M(e,"eyeOff"),eU=d("eye",e$,eM);eU.setAttribute("aria-label",o.hideOutlines),eU.title=o.hideOutlines;let ez=A(e,"slot");ez.name="actions-bar";let eI=d("exit",o.signOut),eO=A(e,"div",{className:"launcher"},eP,eS,eU,ez,eI);a.actions&&p.appendChild(a.actions);let ej=A(e,"div",{className:"layer"});ej.setAttribute("aria-hidden","true");let eR=A(e,"div",{className:"wash"});eR.setAttribute("aria-hidden","true");let eD=A(e,"div",{className:"root"},eR,ej,eL,eO);c.append(A(e,"style",{textContent:J}),eD);let eT=(e=>{try{return e?.localStorage.getItem(K)!=="minimised"}catch{return!0}})(s),eq="ask",eF=!1,eB=!1,eH=!0,e_=!1,eV=null,eW=!1,eY=null,eX=[],eK=!0,eJ=null,eZ=new Map,eG="idle",eQ=!1,e0=U(n,ev,o.formTitle,{onReady:()=>ti(),onError:()=>ti(),onEscape:()=>tu()}),e1=()=>eX.filter(({status:e})=>"pending"===e),e2=()=>e1().slice(-1)[0]??null,e4=()=>eX.some(({status:e})=>"working"===e)?null:e2(),e6=e=>(eZ.has(e)||"loading"===eG||(eZ.set(e,null),n.view({uid:e}).then(t=>{"string"==typeof t._type&&eZ.set(e,Z(t._type)),ti()},()=>{})),eZ.get(e)??o.block),e5=e=>{Array.isArray(e)?e.forEach(e5):G(e)&&("string"==typeof e._uid&&"string"==typeof e._type&&eZ.set(e._uid,Z(e._type)),Object.values(e).forEach(e5))},e3=()=>w.current()?.name||e.title.trim(),e8=null,e7=()=>{null===e8&&s&&(e8=s.requestAnimationFrame(()=>{e8=null,(t=>{if(ej.replaceChildren(),eR.replaceChildren(),!te(t))return;let n=t=>{let r=e.querySelector(t),n=r?.getBoundingClientRect();return n&&(n.width||n.height)?n:null},a=(t,r,n=ej)=>{let a=A(e,"div",{className:`box ${r}`});Object.assign(a.style,{top:`${t.top-3}px`,left:`${t.left-3}px`,width:`${t.width+6}px`,height:`${t.height+6}px`}),n.appendChild(a)},i=(t,...r)=>{let n=A(e,"div",{className:"chips"},...r),a=t.top-34<0?t.top+6:t.top-34;Object.assign(n.style,{top:`${a}px`,left:`${t.left-3}px`}),ej.appendChild(n)},s=(t,r)=>{let n=A(e,"span",{className:"accent-chip"});return r&&n.appendChild(P(e,"mark",N)),n.appendChild(e.createTextNode(t)),n},l=e2(),d=l?l.uid?E(l.uid):`[${r}]`:null,p=d?n(d):null;if(p&&a(p,"fill",eR),eJ&&eJ!==t.selectedUid){let t=n(E(eJ));if(t){a(t,"hover");let r=t.top-23<0,n=A(e,"span",{className:`name-tab${r?" inside":""}`,textContent:e6(eJ)});Object.assign(n.style,{top:`${r?t.top-1.5:t.top-23}px`,left:`${t.left-3}px`}),ej.appendChild(n)}}let c=!!l&&l.uid===t.selectedUid;if(t.selectedUid){let r=n(E(t.selectedUid));if(r){let n=e6(t.selectedUid),a=e3();i(r,s(c?S(o.previewChip,{name:n}):n,c),...a?[A(e,"span",{className:"ink-chip",textContent:a})]:[])}}if(p&&!c){a(p,"preview");let e=l.uid?e6(l.uid):e3()||o.pages;i(p,s(S(o.previewChip,{name:e}),!0))}})(n.getState())}))},e9=e=>e.features.includes("prompt")&&eT,te=e=>e9(e)&&eH&&!eB,tt=t=>A(e,"span",{className:`value${t?"":" none"}`,textContent:t||o.emptyValue}),tr=t=>{let r=t.node.querySelector(".card");if(r.querySelector(".status-line")?.remove(),"failed"===t.status)return void r.appendChild(A(e,"p",{className:"failure"},M(e,"alert"),t.summary));for(let n of(r.appendChild(t.eyebrow),t.summary&&r.appendChild(A(e,"p",{className:"summary",textContent:t.summary})),t.diffs.slice(0,3))){let a=A(e,"div",{className:"diff-field"},A(e,"span",{className:"diff-label",textContent:n.label}),A(e,"div",{className:"diff"},A(e,"div",{className:"before"},A(e,"span",{className:"tag",textContent:o.before}),tt(n.before)),A(e,"div",{className:"after"},A(e,"span",{className:"tag",textContent:o.after}),tt(n.after))));t.details.push(a),r.appendChild(a)}if(t.diffs.length>3){let n=A(e,"p",{className:"more",textContent:S(o.moreChanges,{count:t.diffs.length-3})});t.details.push(n),r.appendChild(n)}if("pending"===t.status){let n=d("button primary",o.keep),a=d("button secondary",o.retry),i=d("button quiet",o.undo);n.addEventListener("click",()=>tg()),a.addEventListener("click",()=>void tm(t)),i.addEventListener("click",()=>th(t)),t.actions=A(e,"div",{className:"actions"},n,a,i),r.appendChild(t.actions)}},tn=(t,r)=>{let n=A(e,"div",{className:"card"},A(e,"span",{className:"visually-hidden",textContent:`${o.obelism}: `}),A(e,"p",{className:"status-line"},P(e,"working",L),eB?o.creating:o.working)),a=A(e,"div",{className:"answer"},A(e,"span",{className:"chip"},P(e,"mark",N)),n);a.dataset.status="working";let i={prompt:t,uid:r,status:"working",summary:"",diffs:[],step:null,node:a,eyebrow:A(e,"p",{className:"eyebrow"}),actions:null,details:[]};return eX.push(i),eo.appendChild(a),i},ta=t=>{if(eQ)return;let r=t.features.includes("prompt"),i=t.saving||t.publishing,s=t.prompting||i,p=r&&eT,{site:c,canCreate:u,pageless:g,shopHere:x,onlyNew:y}=D(n,t,a.promptWithoutPage);u||(eB=!1),y&&(eB=!0);let E=c&&!eB&&!g&&t.features.includes("form");E||(eq="ask");let N=e1().length>0;for(let e of(N&&"fields"!==eq||(eF=!1),eX))null!==e.step&&e.step>(t.undoSteps??0)&&(e.step=null);eD.hidden=!r&&!c,eL.toggleAttribute("data-closed",!p),eL.inert=!p,eP.hidden=!r,eP.setAttribute("aria-expanded",String(p)),eS.hidden=r,eU.hidden=!p,eU.setAttribute("aria-pressed",String(!eH)),e$.hidden=!eH,eM.hidden=eH,eI.hidden=!1===a.signOut;let S=p&&eK;l.toggleAttribute("data-obelism-docked",S),l.style.setProperty("--obelism-dock",`${436*!!S}px`);let $=p&&eH&&!eB;t.selecting!==$&&n.setSelecting($);let U=p&&"fields"===eq;U&&!e0.mounted?e0.mount():!U&&e0.mounted&&e0.unmount(),e_&&!p&&(e_=!1),h.textContent=e3()||o.pages,b.hidden=null===w.pages&&null!==w.error,m.hidden=!b.hidden,m.textContent=e3()||o.pages,b.setAttribute("aria-expanded",String(e_)),C.hidden=!e_,k.hidden=!u||eB,k.disabled=s;let O=n.environment;v.hidden=!O,v.dataset.env=O??"",f.textContent="production"===O?o.envProduction:O??"",B.hidden=!E,z.setAttribute("aria-selected",String("ask"===eq)),I.setAttribute("aria-selected",String("fields"===eq)),z.disabled=I.disabled=s,z.tabIndex="ask"===eq?0:-1,I.tabIndex="fields"===eq?0:-1,V.hidden=!eF,H.disabled=_.disabled=s,em.hidden="ask"!==eq,ex.hidden="fields"!==eq;let j=null!==x&&!eB;if(eB)W.textContent=o.newPage;else if(t.selectedUid){let[r,n=""]=o.scopeNoteBlock.split("{name}");W.replaceChildren(r??"",A(e,"strong",{textContent:e6(t.selectedUid)}),n)}else W.textContent=o.scopeNotePage;ee.hidden=j||g&&!eB&&!a.promptWithoutPage,Y.hidden=eB||!t.selectedUid,X.hidden=!eB||y,et.hidden=eX.length>0||j||eB,ei.hidden=!j;let R=T(o,x);en.textContent=t.prompting&&j?R.adding:R.add,ea.disabled=s,er.textContent=eY?.text??R.hint,er.className=eY?.error?"failure":"summary",eb.hidden=j,ed.hidden=!eB,el.disabled=s,ep.placeholder=eB?o.newPagePlaceholder:o.placeholder,ep.disabled=s,eg.disabled=s||""===ep.value.trim()||eB&&""===el.value.trim(),eg.setAttribute("aria-busy",String(t.prompting)),ec.hidden=t.prompting,eu.hidden=!t.prompting,ek.hidden=N||!t.canUndo||eB,ek.disabled=s,eE.hidden=!t.features.includes("save")||g,eE.disabled=s||N||!t.unsaved,eC.hidden=!t.features.includes("publish")||g,eC.disabled=s||N,a.actions&&(a.actions.slot=p?"actions-footer":"actions-bar"),eA.hidden=!c,t.unsaved&&!eW&&(eV=null),eW=t.unsaved;let q=i?P(e,"working",L):eV?.kind==="error"?M(e,"alert"):N||t.unsaved?A(e,"span",{className:"dot"}):M(e,"check"),F=t.saving?o.saving:t.publishing?o.publishing:eV?.kind==="error"?`${"save"===eV.action?o.saveFailed:o.publishFailed}: ${eV.text}`:N?o.keepFirst:t.unsaved?o.unsaved:eV?.kind==="saved"?o.saved:eV?.kind==="published"?o.published:o.upToDate,K=i?"saving":eV?.kind==="error"?"error":N||t.unsaved?"unsaved":"saved";if((ey.dataset.state!==K||ey.dataset.text!==F)&&(ey.dataset.state=K,ey.dataset.text=F,ey.replaceChildren(q,A(e,"span",{textContent:F})),eV?.kind==="error"&&!i)){let e=eV.action,t=d("link",o.tryAgain);t.addEventListener("click",()=>void tv(e)),ey.appendChild(t)}ev.classList.toggle("loading",e0.loading||null!==e0.error),ef.hidden=!e0.loading&&null===e0.error,ef.className=`form-note${null!==e0.error?" error":""}`,ef.textContent=e0.error??o.formLoading;let J=e4();for(let e of eX){if("working"===e.status||"failed"===e.status)continue;e.node.dataset.status=e.status;let t="pending"===e.status?o.suggested:"kept"===e.status?o.kept:o.undone;for(let r of(e.eyebrow.textContent!==t&&(e.eyebrow.textContent=t),e.actions&&(e.actions.hidden=e!==J),e.details))r.hidden="undone"===e.status}p&&((()=>{if("idle"!==eG||null===n.entryId)return;eG="loading";let e=()=>{eG="done",ti()};n.view({uid:null}).then(t=>{e5(t),e()},e)})(),null===w.pages&&null===w.error&&w.fetch()),e7()},ti=()=>ta(n.getState()),to=()=>{ep.style.height="auto",ep.style.height=`${ep.scrollHeight}px`},ts=()=>{es.scrollTop=es.scrollHeight},tl=e=>{eT=e;try{s?.localStorage.setItem(K,eT?"open":"minimised")}catch{}eT||(e_=!1),ti(),eT?("fields"===eq?I:eB?el:ep).focus():eP.focus()},td=e=>{if("fields"===e&&e1().length>0){eF=!0,ti(),H.focus();return}if(eF=!1,eq===e)return ti();eq=e,ti()},tp=e=>{e_=!1,(eB=e)&&n.select(null),ti(),(eB?el:ep).focus()},tc=e=>{(e_=e)&&w.reset(),ti(),(e_?w.search:b).focus()},tu=()=>{let e=n.getState();if(!e9(e))return!1;if(e_)tc(!1);else{if(!e.selectedUid)return!1;n.select(null)}return!0},tg=(e=!0)=>{let t=e1();t.length&&e4()&&(t.forEach(e=>{e.status="kept"}),ti(),e&&ep.focus())},th=(e,t=!0)=>{e===e4()&&(n.undo(),e.status="undone",ti(),t&&ep.focus())},tb=async(e,t)=>{let r={uid:e.uid},a=await n.view(r).catch(()=>null);try{let{summary:i}=await n.prompt(t,r);e.step=n.getState().undoSteps??null;let o=a?await n.view(r).catch(()=>null):null;e.summary=i,e.diffs=a&&o?((e,t)=>{let r=new Map,n=new Map;Q(e,"","",r),Q(t,"","",n);let a=[];for(let e of new Set([...r.keys(),...n.keys()])){let t=r.get(e),i=n.get(e);t?.text!==i?.text&&a.push({label:(i??t).label,before:t?.text??"",after:i?.text??""})}return a})(a,o):[],e.status="pending"}catch(t){e.summary=R(t),e.status="failed"}tr(e),ti(),ts()},tm=async e=>{if(e!==e4())return;n.undo(),e.status="undone";let t=tn(e.prompt,e.uid);ti(),ts(),ep.focus(),await tb(t,S(o.retryPrompt,{prompt:e.prompt}))},tf=async()=>{let t=ep.value.trim(),r=n.getState();if(!t||r.prompting)return;let a=el.value.trim();if(eB&&!a)return el.focus();let i=eB?null:r.selectedUid,s=eB?`${o.newPage} \xb7 ${a}`:i?e6(i):o.scopeEntry;eo.appendChild(A(e,"p",{className:"bubble"},A(e,"span",{className:"visually-hidden",textContent:`${o.you} (${s}): `}),t)),ep.value="",to();let l=tn(t,i);if(ti(),ts(),eB){try{await n.createPage(a,t),w.forget(),l.summary=o.created,l.status="kept"}catch(e){l.summary=R(e),l.status="failed"}tr(l),ti()}else await tb(l,t);ep.focus()},tv=async e=>{eV=null;let t=await F(n,e);eV=t?{kind:"error",action:e,text:t}:{kind:"save"===e?"saved":"published"},ti()};eP.addEventListener("click",()=>tl(!eT)),x.addEventListener("click",()=>tl(!1)),eU.addEventListener("click",()=>{eH=!eH,ti()}),eI.addEventListener("click",()=>n.signOut()),b.addEventListener("click",()=>tc(!e_)),k.addEventListener("click",()=>tp(!0)),X.addEventListener("click",()=>tp(!1)),Y.addEventListener("click",()=>{n.select(null),ep.focus()}),ea.addEventListener("click",async()=>{eY=null,eY=await q(n,o),ti()}),z.addEventListener("click",()=>td("ask")),I.addEventListener("click",()=>td("fields")),B.addEventListener("keydown",e=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;e.preventDefault();let t=c.activeElement===z;("Home"===e.key?z:"End"===e.key||t?I:z).focus()}),H.addEventListener("click",()=>{tg(!1),td("fields"),I.focus()}),_.addEventListener("click",()=>{for(let e=e4();e;e=e4())th(e,!1);td("fields"),I.focus()}),ek.addEventListener("click",()=>{let e=n.getState().undoSteps,t=void 0===e?void 0:eX.find(t=>"kept"===t.status&&t.step===e);if(n.undo(),t){var r;t.status="undone",ti(),r=`${o.undone}: ${t.summary}`,eN.textContent="",eN.textContent=r}ek.hidden&&ep.focus()}),eE.addEventListener("click",()=>void tv("save")),eC.addEventListener("click",()=>void tv("publish")),eb.addEventListener("submit",e=>{e.preventDefault(),tf()}),ep.addEventListener("input",()=>{to(),ti()}),ep.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||e.isComposing||(e.preventDefault(),tf())}),el.addEventListener("input",ti),el.addEventListener("keydown",e=>{"Enter"!==e.key||e.isComposing||(e.preventDefault(),ep.focus())});let tx=e=>{"Escape"===e.key&&!e.defaultPrevented&&tu()&&e.preventDefault()};e.addEventListener("keydown",tx);let ty=e=>{let r=e.target,n=r?.closest?.(`[${t}]`),a=n?.getAttribute(t)??null;a!==eJ&&(eJ=a,e7())},tw=()=>{eJ=null,e7()};e.addEventListener("pointerover",ty),l.addEventListener("pointerleave",tw),s?.addEventListener("scroll",e7,{capture:!0,passive:!0}),s?.addEventListener("resize",e7);let tk=s?.MutationObserver,tE="function"==typeof tk?new tk(e7):null;tE?.observe(e.body,{childList:!0,subtree:!0});let tC=s?.ResizeObserver,tA="function"==typeof tC?new tC(e7):null;tA?.observe(l);let tN=s?.matchMedia?.("(min-width: 768px)")??null;eK=tN?.matches??!0;let tL=()=>{eK=tN?.matches??!0,ti()};tN?.addEventListener?.("change",tL);let tP=n.on("change",ta);return l.setAttribute("data-obelism-editor",""),e.head.appendChild(u),e.body.appendChild(p),ti(),()=>{eQ=!0,tP(),e0.unmount(),null!==e8&&s?.cancelAnimationFrame?.(e8),e.removeEventListener("keydown",tx),e.removeEventListener("pointerover",ty),l.removeEventListener("pointerleave",tw),s?.removeEventListener("scroll",e7,{capture:!0}),s?.removeEventListener("resize",e7),tN?.removeEventListener?.("change",tL),tE?.disconnect(),tA?.disconnect(),n.setSelecting(!1),l.removeAttribute("data-obelism-editor"),l.removeAttribute("data-obelism-docked"),l.style.removeProperty("--obelism-dock"),u.remove(),p.remove()}},et=Symbol.for("@obelism/content/bridge"),er=C({isEditing:!1,entryId:null,on:()=>{}},new URLSearchParams),en=({url:e,prompt:p=!0,pagePath:c,productPath:b,collectionPath:x}={})=>{let y;if("u"<typeof window)return er;let A=window;if(A[et])return A[et];if(A.ObelismBridge)y=C(A.ObelismBridge,new URLSearchParams(A.location.search));else{let C=(y=((e,r)=>{let n,a,p,c,b,x=new URLSearchParams(e.location.search),y=e.parent!==e&&x.has("cms_preview"),C=v(),A=[],N={...f,selecting:!0},L=e=>{N={...N,...e},C.emit("change",N)},P={isEditing:y,mode:y?"editor":null,entryId:x.get("cms_entry"),environment:x.get(i),product:null,collection:null,on:C.on,getState:()=>N,...w,destroy:()=>{A.splice(0).forEach(e=>e())}};if(!y)return P;let S=e.document,$=(t,n={})=>{e.parent.postMessage({source:h,type:t,...n},r)},M=S.createElement("style");M.textContent=m(),S.head.appendChild(M),A.push(()=>M.remove());let U=(e,t)=>{if(S.querySelectorAll("[data-cms-selected]").forEach(e=>{e.removeAttribute("data-cms-selected")}),N.selectedUid!==(e??null)&&L({selectedUid:e??null}),!e)return;let r=S.querySelector(E(e));r&&(r.setAttribute("data-cms-selected",""),t&&r.scrollIntoView({behavior:"smooth",block:"center"}))},z=e=>{let r=e.target,n=r?.closest?.(`[${t}]`);if(!n)return;e.preventDefault(),e.stopPropagation();let a=n.getAttribute(t);U(a,!1),$("select",{uid:a})};S.addEventListener("click",z,!0),A.push(()=>S.removeEventListener("click",z,!0));let I=()=>Math.ceil(Math.max(S.documentElement.scrollHeight,S.body?.scrollHeight??0)),O=0,j=()=>{O=I(),$("ready",{url:e.location.href,height:O})},R=e.ResizeObserver;if("function"==typeof R){let e=new R(()=>{let e=I();e!==O&&(O=e,$("size",{height:e}))});e.observe(S.documentElement),S.body&&e.observe(S.body),A.push(()=>e.disconnect())}let D=new Map,T=0,q=e=>{let t=D.get(e);return t?(clearTimeout(t.timer),D.delete(e),0===D.size&&L({prompting:!1}),t):null};P.prompt=(e,t={})=>{let r=e.trim();if(!r)return Promise.reject(Error("Say what to change"));if(!N.features.includes("prompt"))return Promise.reject(Error("The editor does not offer prompts here"));let n=`prompt_${++T}`,a=void 0===t.uid?N.selectedUid:t.uid;return new Promise((e,t)=>{let i=setTimeout(()=>{q(n)?.reject(Error("The editor did not answer in time"))},12e4);D.set(n,{resolve:e,reject:t,timer:i}),L({prompting:!0}),$("prompt",{id:n,prompt:r,uid:a})})},P.undo=()=>$("undo"),P.select=e=>{U(e,!1),$("select",{uid:e})};let F=null;A.push(()=>F?.destroy()),A.push(()=>{for(let e of D.keys())q(e)?.reject(Error("The bridge was destroyed"))});let B=(n=new WeakSet,a=null,p=null,c=!1,b=()=>{if(null!==a){for(let e of Array.from(S.styleSheets)){let t;if(!n.has(e)){try{t=e.cssRules}catch{continue}n.add(e),g(t,a)}}S.querySelectorAll('[style*="vh"]').forEach(e=>{u(e.style,a)})}},{freeze(e){if(null!==a||!(e>0))return;a=e,b();let t=S.defaultView?.MutationObserver;t&&(p=new t(()=>{if(c)return;c=!0;let e=()=>{c=!1,b()};S.defaultView?.requestAnimationFrame?S.defaultView.requestAnimationFrame(e):e()})).observe(S.documentElement,{childList:!0,subtree:!0})},destroy(){p?.disconnect()}});A.push(()=>B.destroy());let H=t=>{if(t.origin!==r||t.source!==e.parent)return;let n=t.data;if(n&&"obelism-content-editor"===n.source){if("connect"===n.type)j();else if("update"===n.type&&n.entry)C.emit("update",{entry:n.entry,selectedUid:n.selectedUid??null}),e.requestAnimationFrame(()=>U(n.selectedUid,!1)),F?.refresh();else if("select"===n.type)U(n.uid,!0);else if("saved"===n.type||"published"===n.type)C.emit(n.type,{}),0===C.listeners.update.size&&e.location.reload();else if("features"===n.type&&Array.isArray(n.features))L({features:n.features.filter(e=>"string"==typeof e)});else if("stats"===n.type)L({stats:(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return{};let t={};for(let[r,n]of Object.entries(e)){let{clicks:e,clickers:a,viewers:i,rate:o}=n??{};k(e)&&k(a)&&k(i)&&k(o)&&(t[r]={clicks:e,clickers:a,viewers:i,rate:o})}return t})(n.stats),statsVisible:!1!==n.visible}),(F||Object.keys(N.stats).length)&&(F??(F=((e,{selector:t,onSelect:r,labels:n})=>{let a=e.document,i={...o,...n},p=a.createElement("div");p.setAttribute("data-obelism-stats","");let c=p.attachShadow({mode:"open"}),u=a.createElement("style");u.textContent=l;let g=a.createElement("div");g.className="layer",c.append(u,g),a.body.appendChild(p);let h={},b=!1,m=null,f=()=>{if(m=null,g.replaceChildren(),g.hidden=!b,!b)return;let n=e.innerHeight;for(let[o,l]of Object.entries(h)){let p=a.querySelector(t(o));if(!p)continue;let c=p.getBoundingClientRect();if(!c.width&&!c.height||c.bottom<0||c.top>n)continue;let u=a.createElement("button");u.type="button",u.className="badge",u.dataset.uid=o,u.textContent=s(i.clicked,{rate:Math.round(100*l.rate)}),u.title=s(i.title,{clickers:l.clickers,viewers:l.viewers,clicks:l.clicks});let{place:h,top:b,left:m}=d(c,e.innerWidth);u.dataset.place=h,u.style.top=`${b}px`,u.style.left=`${m}px`,u.addEventListener("click",()=>r(o)),g.appendChild(u)}},v=()=>{null===m&&b&&(m=e.requestAnimationFrame(f))};e.addEventListener("scroll",v,{capture:!0,passive:!0}),e.addEventListener("resize",v);let x=e.MutationObserver,y="function"==typeof x?new x(v):null;return y?.observe(a.body,{childList:!0,subtree:!0}),{update(t,r){h=t,b=r,null!==m&&(e.cancelAnimationFrame?.(m),m=null),f()},refresh:v,destroy(){null!==m&&e.cancelAnimationFrame?.(m),e.removeEventListener("scroll",v,{capture:!0}),e.removeEventListener("resize",v),y?.disconnect(),p.remove()}}})(e,{selector:E,onSelect:e=>P.select(e)})),F.update(N.stats,N.statsVisible));else if("viewport"===n.type&&"number"==typeof n.height)B.freeze(n.height);else if("promptState"===n.type)L({canUndo:!0===n.canUndo});else if("promptResult"===n.type&&"string"==typeof n.id){let e=q(n.id);if(!e)return;!0===n.ok?e.resolve({summary:"string"==typeof n.summary?n.summary:""}):e.reject(Error("string"==typeof n.error?n.error:"The prompt failed"))}}};return e.addEventListener("message",H),A.push(()=>e.removeEventListener("message",H)),"loading"===S.readyState?(S.addEventListener("DOMContentLoaded",j,{once:!0}),A.push(()=>S.removeEventListener("DOMContentLoaded",j))):j(),P})(A,new URL(e||V).origin)).isEditing||A.parent!==A?null:(e=>{for(let t of e.cookie.split(";")){let[e,...r]=t.trim().split("=");if("obelism_content_editing"===e)try{let e=decodeURIComponent(r.join("="));return W.test(e)?e:null}catch{break}}return null})(A.document);if(C&&(y=((e,i,{pagePath:o=e=>`/${e.replace(/^\/+/,"")}`,productPath:s,collectionPath:l}={})=>{let d=e.document,p=v(),c=[],u=new Map,g=[],b=new Set,x=null,y=null,w=-1/0,k=new Map,C=f,A=e=>{C={...C,...e},p.emit("change",C)},N=()=>A({unsaved:[...u.values()].some(({content:e,saved:t})=>!X(e,t)),canUndo:g.length>0,undoSteps:g.length}),L=async(t,r)=>{let n=await e.fetch(`${i}/api/${t}`,void 0===r?{credentials:"same-origin"}:{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","x-obelism-content":"1"},body:JSON.stringify(r)}),a=await n.json().catch(()=>({}));if(401===n.status)throw A({features:[]}),Error("You were signed out. Sign in again to edit.");if(!n.ok)throw Error("string"==typeof a.error?a.error:`Obelism Content answered ${n.status}`);return a},P=()=>d.querySelector(`[${r}]`)?.getAttribute(r)??null,S=()=>{let e=d.querySelector(`[${n}]`),t=e?.getAttribute(n),r=e?.getAttribute("data-cms-product-handle");return t&&r?{id:t,handle:r}:null},$=()=>{let e=d.querySelector(`[${a}]`),t=e?.getAttribute(a),r=e?.getAttribute("data-cms-collection-handle");return t&&r?{id:t,handle:r}:null},M=e=>{let t=e?d.querySelector(E(e)):null;return t?.closest(`[${r}]`)?.getAttribute(r)??P()},U=()=>{if(!x)return;let e=x.space.locales.map(({code:e})=>e),t=d.documentElement.lang;if(e.includes(t))return t;let r=t.split("-")[0]??"";return e.includes(r)?r:x.space.defaultLocale},z=new Map,I=async e=>{let t=u.get(e);if(t)return t;let r=z.get(e);return r||(r=L(`entries/${encodeURIComponent(e)}`).then(t=>{let r=u.get(e)??{content:t.content,saved:t.content,revision:t.draftRevision};return u.set(e,r),r}).finally(()=>z.delete(e)),z.set(e,r)),r},O=e=>{let t=void 0===e?C.selectedUid:e,r=M(t);if(!r)throw Error("Nothing on this page is marked as an entry: add editable(entry)");return{uid:t,entryId:r}},j=e=>{d.querySelectorAll("[data-cms-selected]").forEach(e=>{e.removeAttribute("data-cms-selected")}),C.selectedUid!==e&&A({selectedUid:e}),e&&d.querySelector(E(e))?.setAttribute("data-cms-selected","")},R=async t=>{if(0===p.listeners.update.size)return;let r=u.get(t)?.content,{entry:n}=await L(`entries/${encodeURIComponent(t)}/preview`,{content:r,locale:U()});p.emit("update",{entry:n,selectedUid:C.selectedUid}),e.requestAnimationFrame(()=>j(C.selectedUid))},D=e=>console.error("[@obelism/content bridge]",e),T=t=>{p.emit(t,{}),0===p.listeners.update.size&&e.location.reload()},q=async()=>{for(let[e,t]of u){if(X(t.content,t.saved))continue;let{draftRevision:r}=await L(`entries/${encodeURIComponent(e)}/save`,{content:t.content,baseRevision:t.revision});t.saved=t.content,t.revision=r,b.add(e)}g.length=0,w=-1/0,N()},F={isEditing:!0,mode:"site",get entryId(){return P()},get product(){return S()},get collection(){return $()},get environment(){return x?.environment??null},on:p.on,getState:()=>C,async prompt(e,t={}){let r=e.trim();if(!r)throw Error("Say what to change");if(!C.features.includes("prompt"))throw Error("You may not edit content here");let{uid:n,entryId:a}=O(t.uid);A({prompting:!0});try{let e=await I(a),t=await L(`entries/${encodeURIComponent(a)}/prompt`,{prompt:r,content:e.content,locale:U(),uid:n});return g.push({entryId:a,content:e.content}),w=-1/0,e.content=t.content,N(),await R(a),{summary:t.summary}}finally{A({prompting:!1})}},async createPage(t,r){let n=r.trim();if(!n)throw Error("Say what the page is for");if(!t.trim())throw Error("Say where the page goes, like /pricing");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");A({prompting:!0});try{let r=await L("entries",{path:t,prompt:n,locale:U(),from:P()}),a=o(r.path,U()??"");return e.location.assign(Y(a)),{summary:r.summary,entryId:r.entryId,path:r.path,url:a}}finally{A({prompting:!1})}},async createProductPage(t=S()??void 0){if(!t)throw Error("Nothing on this page is marked as a product: add editableProduct(product)");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");A({prompting:!0});try{let r=await L("product-pages",{product:{id:t.id,handle:t.handle}});return e.location.reload(),r}finally{A({prompting:!1})}},async createCollectionPage(t=$()??void 0){if(!t)throw Error("Nothing on this page is marked as a collection: add editableCollection(collection)");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");A({prompting:!0});try{let r=await L("collection-pages",{collection:{id:t.id,handle:t.handle}});return e.location.reload(),r}finally{A({prompting:!1})}},async view(e={}){let{uid:t,entryId:r}=O(e.uid),n=await I(r),{view:a}=await L(`entries/${encodeURIComponent(r)}/view`,{content:n.content,locale:U(),uid:t});return a},async applyJson(e,t={}){if(!C.features.includes("prompt"))throw Error("You may not edit content here");if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Send the fields to change as an object");let{uid:r,entryId:n}=O(t.uid);A({prompting:!0});try{let t=await I(n),a=await L(`entries/${encodeURIComponent(n)}/apply`,{changes:e,content:t.content,locale:U(),uid:r});return X(a.content,t.content)||(g.push({entryId:n,content:t.content}),w=-1/0,t.content=a.content,N(),await R(n)),{changed:a.changed??[],...a.view&&{view:a.view}}}finally{A({prompting:!1})}},openForm(t,r={}){let{title:n="Content form",onReady:a,onError:i,onEscape:o}=r;y?.();let s=!1,l=null,d=null,c=()=>{},b=e=>{s||i?.(e instanceof Error?e.message:String(e))},m=()=>{s||(s=!0,c(),l?.destroy(),y===m&&(y=null))};y=m;let f=()=>{if(s||!l)return;let e=M(C.selectedUid);if(!e)return;let t=u.get(e);if(!t)return void I(e).then(f,b);let r={entryId:e,content:t.content,locale:U(),selectedUid:C.selectedUid};d&&d.entryId===r.entryId&&d.content===r.content&&d.locale===r.locale&&d.selectedUid===r.selectedUid||(d=r,l.show(r))},v=(e,t)=>{let r=t??d?.entryId,n=void 0===r?void 0:u.get(r);if(s||void 0===r||!n||X(e,n.content))return;let a=Date.now();a-w>=1e3&&g.push({entryId:r,content:n.content}),w=a,n.content=e,d?.entryId===r&&(d={...d,content:e}),N(),clearTimeout(k.get(r)),k.set(r,setTimeout(()=>{k.delete(r),R(r).catch(D)},300))};return(async()=>{if(!C.features.includes("form"))throw Error("You may not edit content here");await I(O(void 0).entryId);let{url:r}=await L("form",{});s||(l=((e,t,r,n,a)=>{let i=null;try{i=new URL(r)}catch{}if(!i||!/^https?:$/.test(i.protocol))throw Error("Obelism Content sent no form to open");let o=i.origin,s=t.ownerDocument.createElement("iframe");s.title=n,s.src=r;let l=!1,d=!1,p=null,c=()=>{l&&p&&s.contentWindow?.postMessage({source:h,type:"content",...p},o)},u=setTimeout(()=>{d||a.onError("The form did not open")},3e4),g=()=>{d=!0,clearTimeout(u),a.onReady()},b=e=>{if(e.origin!==o||!s.contentWindow||e.source!==s.contentWindow)return;let t=e.data;if(t&&"obelism-content-form"===t.source)if("ready"===t.type)l=!0,c(),!0!==t.loading&&g();else if("loaded"===t.type)l&&g();else{let e;if("change"!==t.type||!(e=t.content)||"object"!=typeof e||Array.isArray(e))if("height"===t.type){let e=t.height;if("number"==typeof e&&Number.isFinite(e)){let t=Math.round(Math.min(Math.max(e,80),4e3));s.style.height=`min(${t}px, 60vh)`}}else"escape"===t.type?a.onEscape?.():"error"===t.type&&a.onError("string"==typeof t.message&&t.message?t.message:"The form failed");else a.onChange(t.content,"string"==typeof t.entryId?t.entryId:void 0)}};return e.addEventListener("message",b),t.appendChild(s),{show(e){p=e,c()},destroy(){clearTimeout(u),e.removeEventListener("message",b),s.remove()}}})(e,t,"string"==typeof r?r:"",n,{onReady:()=>a?.(),onChange:v,onError:e=>i?.(e),onEscape:()=>o?.()}),c=p.on("change",f),f())})().catch(b),{close:m}},async pages(){let{pages:e}=await L("pages"),t=[U(),x?.space.defaultLocale];return e.flatMap(e=>{let r,n,a=t.find(t=>void 0!==t&&void 0!==e.paths[t])??Object.keys(e.paths)[0],i=void 0===a?void 0:e.paths[a];return void 0===a||void 0===i?[]:[{entryId:e.entryId,name:e.name,contentType:e.contentType,status:e.status,path:i,url:e.product?(r=e.product.handle,s?s(r,a):(x?.productPath??"/products/{handle}").replaceAll("{handle}",encodeURIComponent(r))):e.collection?(n=e.collection.handle,l?l(n,a):(x?.collectionPath??"/collections/{handle}").replaceAll("{handle}",encodeURIComponent(n))):o(i,a),product:e.product??null,collection:e.collection??null}]})},openPage(t){(!C.unsaved||e.confirm("Leave this page and lose the changes you have not saved?"))&&(u.clear(),g.length=0,N(),e.location.assign(Y(t.url)))},undo(){let e=g.pop(),t=e&&u.get(e.entryId);e&&t&&(w=-1/0,t.content=e.content,N(),R(e.entryId).catch(D))},async save(){if(!C.features.includes("save"))throw Error("You may not edit content here");A({saving:!0});try{await q()}finally{A({saving:!1})}T("saved")},async publish(){if(!C.features.includes("publish"))throw Error("You may not publish here");A({publishing:!0});try{await q();let e=P(),t=b.size>0?[...b]:e?[e]:[];if(0===t.length)throw Error("Nothing on this page is marked as an entry: add editable(entry)");for(let e of t)await L(`entries/${encodeURIComponent(e)}/publish`,{}),b.delete(e)}finally{A({publishing:!1})}T("published")},signOut(){if(C.unsaved&&!e.confirm("Sign out and lose the changes you have not saved?"))return;u.clear(),N();let t=e.location.pathname+e.location.search;e.location.href=`${i}/logout?return_to=${encodeURIComponent(t)}`},select(e){j(e)},setSelecting(e){e?d.documentElement.setAttribute("data-cms-selecting",""):d.documentElement.removeAttribute("data-cms-selecting"),A({selecting:e})},destroy(){y?.(),k.forEach(e=>clearTimeout(e)),k.clear(),c.splice(0).forEach(e=>e())}},B=d.createElement("style");B.textContent=m("html[data-cms-selecting] "),d.head.appendChild(B),c.push(()=>B.remove()),c.push(()=>d.documentElement.removeAttribute("data-cms-selecting"));let H=e=>{if(!C.selecting)return;let r=e.target,n=r?.closest?.(`[${t}]`);n&&(e.preventDefault(),e.stopPropagation(),j(n.getAttribute(t)))};d.addEventListener("click",H,!0),c.push(()=>d.removeEventListener("click",H,!0));let _=e=>{C.unsaved&&(e.preventDefault(),e.returnValue="")};return e.addEventListener("beforeunload",_),c.push(()=>e.removeEventListener("beforeunload",_)),L("session").then(e=>{x=e,A({features:e.features})}).catch(e=>console.error("[@obelism/content bridge]",e)),F})(A,C,{pagePath:c,productPath:b,collectionPath:x})),y.isEditing&&p){let e=A.document,t=()=>{},r=!1,n=C?ee:_,a=()=>{r||(t=n(e,y,!0===p?{}:p))};e.body?a():e.addEventListener("DOMContentLoaded",a,{once:!0});let i=y.destroy;y.destroy=()=>{r=!0,e.removeEventListener("DOMContentLoaded",a),t(),i()}}}return A[et]=y,y};(e=window).ObelismBridge=en((e=>{let t=e?.dataset.url,r=t||V;if(!t&&e?.src){let t=new URL(e.src);"/bridge.js"===t.pathname&&(r=t.origin)}return{url:r,prompt:e?.dataset.prompt!=="false"}})(document.currentScript)),e.ObelismContent={getContentBridge:en,mountPromptBox:_,mountSiteEditor:ee}}();
|
|
578
|
+
`,Z=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)},G=e=>!!e&&"object"==typeof e&&!Array.isArray(e),Q=(e,t,r,n)=>{if(null!=e&&""!==e){if("object"!=typeof e)return void n.set(r,{label:t,text:String(e)});if(Array.isArray(e)){if(e.every(e=>null===e||"object"!=typeof e)){e.length&&n.set(r,{label:t,text:e.join(", ")});return}e.forEach((e,a)=>{let i=G(e)&&"string"==typeof e._uid?e._uid:a,o=G(e)&&"string"==typeof e._type?e._type:null;Q(e,o?Z(o):t,`${r}/${i}`,n)});return}for(let[a,i]of Object.entries(e))"_uid"!==a&&"_type"!==a&&Q(i,t?`${t} \xb7 ${Z(a)}`:Z(a),`${r}/${a}`,n)}},ee=(e,n,a={})=>{let i,o={...O,...a.labels},s=e.defaultView,l=e.documentElement,d=(t,...r)=>N(e,"button",{className:t,type:"button"},...r),p=N(e,"div");p.setAttribute("data-obelism-content-editor","");let c=p.attachShadow({mode:"open"}),u=N(e,"style",{textContent:(i=`[${t}]`,`html[data-obelism-editor]{transition:margin-right .3s cubic-bezier(.2,.8,.2,1)}html[data-obelism-docked]{margin-right:436px!important}html[data-obelism-docked] [data-obelism-dock]{right:436px!important;max-width:calc(100vw - 436px)!important}html[data-obelism-editor][data-cms-selecting] ${i}:hover:not([data-cms-selected]){outline:none}html[data-obelism-editor][data-cms-selecting] ${i}[data-cms-selected]{outline:2px solid rgb(212 130 30);outline-offset:2px}@media (prefers-reduced-motion:reduce){html[data-obelism-editor]{transition:none}}`)}),g=N(e,"span",{className:"tile"},P(e,"mark",A)),h=N(e,"span"),b=d("page-button hit",h,N(e,"span",{className:"visually-hidden",textContent:`, ${o.pages}`}),M(e,"chevrons"));b.setAttribute("aria-haspopup","listbox"),b.setAttribute("aria-expanded","false"),b.setAttribute("aria-controls","obelism-pages");let m=N(e,"span",{className:"page-name"}),f=N(e,"span"),v=N(e,"span",{className:"env"},N(e,"span",{className:"visually-hidden",textContent:`${o.environment}: `}),f),x=d("icon-button hit",M(e,"dash"));x.setAttribute("aria-label",o.minimize),x.title=o.minimize;let y=d("mode hit",P(e,"mark",A),o.modePrompt);y.setAttribute("aria-pressed","false");let w=N(e,"div",{className:"head"},g,b,m,v,N(e,"span",{className:"spacer"}),y,x),k=j(e,n,o,{onLoad:()=>ts(),onClose:()=>tg(!1)}),C=d("button quiet new-page",M(e,"plus"),o.newPage),$=N(e,"div",{className:"pages"},k.searchRow,k.list,k.note,C),z=d("button primary",o.keep),I=d("button quiet",o.undo),B=N(e,"div",{className:"gate"},N(e,"p",{textContent:o.keepBeforeFields}),N(e,"div",{className:"actions"},z,I));B.setAttribute("role","alert");let _=N(e,"span"),H=d("",o.scopeEntry),V=d("",o.newPageCancel),W=N(e,"div",{className:"note"},M(e,"scope"),_,H,V),Y=N(e,"p",{className:"intro",textContent:o.askIntro}),X=N(e,"p",{className:"summary"}),ee=N(e,"span"),et=d("button primary",M(e,"plus"),ee),er=N(e,"div",{className:"shop"},X,et),en=N(e,"div",{className:"log"});en.setAttribute("role","log");let ea=N(e,"div",{className:"scroll"},W,Y,er,en),ei=N(e,"input",{type:"text",placeholder:o.pathPlaceholder,autocomplete:"off",spellcheck:!1}),eo=N(e,"label",{className:"path"},N(e,"span",{textContent:o.path}),ei),es=N(e,"textarea",{rows:1});es.setAttribute("aria-label",o.open);let el=M(e,"arrowUp"),ed=P(e,"working",L),ep=N(e,"button",{className:"send",type:"submit",title:o.send},N(e,"span",{className:"visually-hidden",textContent:o.send}),el,ed),ec=N(e,"div",{className:"bar"},P(e,"mark",A),es,ep),eu=N(e,"form",{className:"composer"},eo,ec),eg=N(e,"div",{className:"ask",id:"obelism-ask"},ea,eu);eg.setAttribute("role","tabpanel"),eg.setAttribute("aria-label",o.modePrompt);let eh=N(e,"p",{className:"form-note"});eh.setAttribute("role","status");let eb=N(e,"div",{className:"form"},eh),em=N(e,"span"),ef=d("",o.scopeEntry),ev=N(e,"div",{className:"note"},M(e,"scope"),em,ef),ex=N(e,"div",{className:"fields",id:"obelism-fields"},ev,eb);ex.setAttribute("role","tabpanel"),ex.setAttribute("aria-label",o.form);let ey=N(e,"p",{className:"save-state"});ey.setAttribute("aria-live","polite");let ew=N(e,"slot");ew.name="actions-footer";let ek=d("button quiet",M(e,"undo"),o.undo),eE=d("button secondary",o.saveDraft),eC=d("button primary",o.publish),eN=N(e,"div",{className:"foot"},ey,ew,ek,eE,eC),eA=N(e,"p",{className:"visually-hidden"});eA.setAttribute("role","status");let eL=N(e,"aside",{className:"panel",id:"obelism-editor"},w,$,B,eg,ex,eN,eA);eL.setAttribute("aria-label",o.editor);let eP=d("launch",N(e,"span",{className:"launch-tile"},P(e,"mark",A)),o.editing);eP.setAttribute("aria-controls",eL.id);let eS=N(e,"span",{className:"reading"},N(e,"span",{className:"launch-tile"},P(e,"mark",A)),o.viewingDrafts),e$=M(e,"eye"),eM=M(e,"eyeOff"),eU=d("eye",e$,eM);eU.setAttribute("aria-label",o.hideOutlines),eU.title=o.hideOutlines;let ez=N(e,"slot");ez.name="actions-bar";let eI=d("exit",o.signOut),eO=N(e,"div",{className:"launcher"},eP,eS,eU,ez,eI);a.actions&&p.appendChild(a.actions);let ej=N(e,"div",{className:"layer"});ej.setAttribute("aria-hidden","true");let eR=N(e,"div",{className:"wash"});eR.setAttribute("aria-hidden","true");let eT=N(e,"div",{className:"root"},eR,ej,eL,eO);c.append(N(e,"style",{textContent:J}),eT);let eD=(e=>{try{return e?.localStorage.getItem(K)!=="minimised"}catch{return!0}})(s),eq="fields",eF="fields",eB=!1,e_=!1,eH=!0,eV=!1,eW=null,eY=!1,eX=null,eK=[],eJ=!0,eZ=null,eG=new Map,eQ="idle",e0=!1,e1=U(n,eb,o.formTitle,{onReady:()=>{ts(),eD&&"fields"===eF&&e2()},onError:()=>ts(),onEscape:()=>th()}),e2=()=>eb.querySelector("iframe")?.focus(),e4=()=>eK.filter(({status:e})=>"pending"===e),e5=()=>e4().slice(-1)[0]??null,e6=()=>eK.some(({status:e})=>"working"===e)?null:e5(),e3=e=>(eG.has(e)||"loading"===eQ||(eG.set(e,null),n.view({uid:e}).then(t=>{"string"==typeof t._type&&eG.set(e,Z(t._type)),ts()},()=>{})),eG.get(e)??o.block),e8=e=>{Array.isArray(e)?e.forEach(e8):G(e)&&("string"==typeof e._uid&&"string"==typeof e._type&&eG.set(e._uid,Z(e._type)),Object.values(e).forEach(e8))},e7=()=>k.current()?.name||e.title.trim(),e9=null,te=()=>{null===e9&&s&&(e9=s.requestAnimationFrame(()=>{e9=null,(t=>{if(ej.replaceChildren(),eR.replaceChildren(),!tr(t))return;let n=t=>{let r=e.querySelector(t),n=r?.getBoundingClientRect();return n&&(n.width||n.height)?n:null},a=(t,r,n=ej)=>{let a=N(e,"div",{className:`box ${r}`});Object.assign(a.style,{top:`${t.top-3}px`,left:`${t.left-3}px`,width:`${t.width+6}px`,height:`${t.height+6}px`}),n.appendChild(a)},i=(t,...r)=>{let n=N(e,"div",{className:"chips"},...r),a=t.top-34<0?t.top+6:t.top-34;Object.assign(n.style,{top:`${a}px`,left:`${t.left-3}px`}),ej.appendChild(n)},s=(t,r)=>{let n=N(e,"span",{className:"accent-chip"});return r&&n.appendChild(P(e,"mark",A)),n.appendChild(e.createTextNode(t)),n},l=e5(),d=l?l.uid?E(l.uid):`[${r}]`:null,p=d?n(d):null;if(p&&a(p,"fill",eR),eZ&&eZ!==t.selectedUid){let t=n(E(eZ));if(t){a(t,"hover");let r=t.top-23<0,n=N(e,"span",{className:`name-tab${r?" inside":""}`,textContent:e3(eZ)});Object.assign(n.style,{top:`${r?t.top-1.5:t.top-23}px`,left:`${t.left-3}px`}),ej.appendChild(n)}}let c=!!l&&l.uid===t.selectedUid;if(t.selectedUid){let r=n(E(t.selectedUid));if(r){let n=e3(t.selectedUid),a=e7();i(r,s(c?S(o.previewChip,{name:n}):n,c),...a?[N(e,"span",{className:"ink-chip",textContent:a})]:[])}}if(p&&!c){a(p,"preview");let e=l.uid?e3(l.uid):e7()||o.pages;i(p,s(S(o.previewChip,{name:e}),!0))}})(n.getState())}))},tt=e=>e.features.includes("prompt")&&eD,tr=e=>tt(e)&&eH&&!e_,tn=t=>N(e,"span",{className:`value${t?"":" none"}`,textContent:t||o.emptyValue}),ta=t=>{let r=t.node.querySelector(".card");if(r.querySelector(".status-line")?.remove(),"failed"===t.status)return void r.appendChild(N(e,"p",{className:"failure"},M(e,"alert"),t.summary));for(let n of(r.appendChild(t.eyebrow),t.summary&&r.appendChild(N(e,"p",{className:"summary",textContent:t.summary})),t.diffs.slice(0,3))){let a=N(e,"div",{className:"diff-field"},N(e,"span",{className:"diff-label",textContent:n.label}),N(e,"div",{className:"diff"},N(e,"div",{className:"before"},N(e,"span",{className:"tag",textContent:o.before}),tn(n.before)),N(e,"div",{className:"after"},N(e,"span",{className:"tag",textContent:o.after}),tn(n.after))));t.details.push(a),r.appendChild(a)}if(t.diffs.length>3){let n=N(e,"p",{className:"more",textContent:S(o.moreChanges,{count:t.diffs.length-3})});t.details.push(n),r.appendChild(n)}if("pending"===t.status){let n=d("button primary",o.keep),a=d("button secondary",o.retry),i=d("button quiet",o.undo);n.addEventListener("click",()=>tb()),a.addEventListener("click",()=>void tv(t)),i.addEventListener("click",()=>tm(t)),t.actions=N(e,"div",{className:"actions"},n,a,i),r.appendChild(t.actions)}},ti=(t,r)=>{let n=N(e,"div",{className:"card"},N(e,"span",{className:"visually-hidden",textContent:`${o.obelism}: `}),N(e,"p",{className:"status-line"},P(e,"working",L),e_?o.creating:o.working)),a=N(e,"div",{className:"answer"},N(e,"span",{className:"chip"},P(e,"mark",A)),n);a.dataset.status="working";let i={prompt:t,uid:r,status:"working",summary:"",diffs:[],step:null,node:a,eyebrow:N(e,"p",{className:"eyebrow"}),actions:null,details:[]};return eK.push(i),en.appendChild(a),i},to=t=>{if(e0)return;let r=t.features.includes("prompt"),i=t.saving||t.publishing,s=t.prompting||i,p=r&&eD,{site:c,canCreate:u,pageless:g,shopHere:x,onlyNew:w}=T(n,t,a.promptWithoutPage);u||(e_=!1),w&&(e_=!0);let E=c&&!e_&&!g&&t.features.includes("form");eF=E?eq:"ask";let A=e4().length>0;for(let e of(A&&"fields"!==eF||(eB=!1),eK))null!==e.step&&e.step>(t.undoSteps??0)&&(e.step=null);eT.hidden=!r&&!c,eL.toggleAttribute("data-closed",!p),eL.inert=!p,eP.hidden=!r,eP.setAttribute("aria-expanded",String(p)),eS.hidden=r,eU.hidden=!p,eU.setAttribute("aria-pressed",String(!eH)),e$.hidden=!eH,eM.hidden=eH,eI.hidden=!1===a.signOut;let S=p&&eJ;l.toggleAttribute("data-obelism-docked",S),l.style.setProperty("--obelism-dock",`${436*!!S}px`);let U=p&&eH&&!e_;t.selecting!==U&&n.setSelecting(U);let O=p&&"fields"===eF;O&&!e1.mounted?e1.mount():!O&&e1.mounted&&e1.unmount(),eV&&!p&&(eV=!1),h.textContent=e7()||o.pages,b.hidden=null===k.pages&&null!==k.error,m.hidden=!b.hidden,m.textContent=e7()||o.pages,b.setAttribute("aria-expanded",String(eV)),$.hidden=!eV,C.hidden=!u||e_,C.disabled=s;let j=n.environment;v.hidden=!j,v.dataset.env=j??"",f.textContent="production"===j?o.envProduction:j??"",y.hidden=!E,y.setAttribute("aria-pressed",String("ask"===eF)),y.disabled=s,B.hidden=!eB,z.disabled=I.disabled=s,eg.hidden="ask"!==eF,ex.hidden="fields"!==eF;let R=null!==x&&!e_;if(e_)_.textContent=o.newPage;else if(t.selectedUid){let[r,n=""]=o.scopeNoteBlock.split("{name}");for(let a of[_,em])a.replaceChildren(r??"",N(e,"strong",{textContent:e3(t.selectedUid)}),n)}else _.textContent=o.scopeNotePage;ev.hidden=e_||!t.selectedUid,W.hidden=R||g&&!e_&&!a.promptWithoutPage,H.hidden=e_||!t.selectedUid,V.hidden=!e_||w,Y.hidden=eK.length>0||R||e_,er.hidden=!R;let q=D(o,x);ee.textContent=t.prompting&&R?q.adding:q.add,et.disabled=s,X.textContent=eX?.text??q.hint,X.className=eX?.error?"failure":"summary",eu.hidden=R,eo.hidden=!e_,ei.disabled=s,es.placeholder=e_?o.newPagePlaceholder:o.placeholder,es.disabled=s,ep.disabled=s||""===es.value.trim()||e_&&""===ei.value.trim(),ep.setAttribute("aria-busy",String(t.prompting)),el.hidden=t.prompting,ed.hidden=!t.prompting,ek.hidden=A||!t.canUndo||e_,ek.disabled=s,eE.hidden=!t.features.includes("save")||g,eE.disabled=s||A||!t.unsaved,eC.hidden=!t.features.includes("publish")||g,eC.disabled=s||A,a.actions&&(a.actions.slot=p?"actions-footer":"actions-bar"),eN.hidden=!c,t.unsaved&&!eY&&(eW=null),eY=t.unsaved;let F=i?P(e,"working",L):eW?.kind==="error"?M(e,"alert"):A||t.unsaved?N(e,"span",{className:"dot"}):M(e,"check"),K=t.saving?o.saving:t.publishing?o.publishing:eW?.kind==="error"?`${"save"===eW.action?o.saveFailed:o.publishFailed}: ${eW.text}`:A?o.keepFirst:t.unsaved?o.unsaved:eW?.kind==="saved"?o.saved:eW?.kind==="published"?o.published:o.upToDate,J=i?"saving":eW?.kind==="error"?"error":A||t.unsaved?"unsaved":"saved";if((ey.dataset.state!==J||ey.dataset.text!==K)&&(ey.dataset.state=J,ey.dataset.text=K,ey.replaceChildren(F,N(e,"span",{textContent:K})),eW?.kind==="error"&&!i)){let e=eW.action,t=d("link",o.tryAgain);t.addEventListener("click",()=>void ty(e)),ey.appendChild(t)}eb.classList.toggle("loading",e1.loading||null!==e1.error),eh.hidden=!e1.loading&&null===e1.error,eh.className=`form-note${null!==e1.error?" error":""}`,eh.textContent=e1.error??o.formLoading;let Z=e6();for(let e of eK){if("working"===e.status||"failed"===e.status)continue;e.node.dataset.status=e.status;let t="pending"===e.status?o.suggested:"kept"===e.status?o.kept:o.undone;for(let r of(e.eyebrow.textContent!==t&&(e.eyebrow.textContent=t),e.actions&&(e.actions.hidden=e!==Z),e.details))r.hidden="undone"===e.status}p&&((()=>{if("idle"!==eQ||null===n.entryId)return;eQ="loading";let e=()=>{eQ="done",ts()};n.view({uid:null}).then(t=>{e8(t),e()},e)})(),null===k.pages&&null===k.error&&k.fetch()),te()},ts=()=>to(n.getState()),tl=()=>{es.style.height="auto",es.style.height=`${es.scrollHeight}px`},td=()=>{ea.scrollTop=ea.scrollHeight},tp=e=>{eD=e;try{s?.localStorage.setItem(K,eD?"open":"minimised")}catch{}eD||(eV=!1),ts(),eD?e_?ei.focus():"fields"===eF?e2():es.focus():eP.focus()},tc=e=>{if("fields"===e&&e4().length>0){eB=!0,ts(),z.focus();return}if(eB=!1,eq===e)return ts();eq=e,ts()},tu=e=>{eV=!1,(e_=e)&&n.select(null),ts(),(e_?ei:es).focus()},tg=e=>{(eV=e)&&k.reset(),ts(),(eV?k.search:b).focus()},th=()=>{let e=n.getState();if(!tt(e))return!1;if(eV)tg(!1);else{if(!e.selectedUid)return!1;n.select(null)}return!0},tb=(e=!0)=>{let t=e4();t.length&&e6()&&(t.forEach(e=>{e.status="kept"}),ts(),e&&es.focus())},tm=(e,t=!0)=>{e===e6()&&(n.undo(),e.status="undone",ts(),t&&es.focus())},tf=async(e,t)=>{let r={uid:e.uid},a=await n.view(r).catch(()=>null);try{let{summary:i}=await n.prompt(t,r);e.step=n.getState().undoSteps??null;let o=a?await n.view(r).catch(()=>null):null;e.summary=i,e.diffs=a&&o?((e,t)=>{let r=new Map,n=new Map;Q(e,"","",r),Q(t,"","",n);let a=[];for(let e of new Set([...r.keys(),...n.keys()])){let t=r.get(e),i=n.get(e);t?.text!==i?.text&&a.push({label:(i??t).label,before:t?.text??"",after:i?.text??""})}return a})(a,o):[],e.status="pending"}catch(t){e.summary=R(t),e.status="failed"}ta(e),ts(),td()},tv=async e=>{if(e!==e6())return;n.undo(),e.status="undone";let t=ti(e.prompt,e.uid);ts(),td(),es.focus(),await tf(t,S(o.retryPrompt,{prompt:e.prompt}))},tx=async()=>{let t=es.value.trim(),r=n.getState();if(!t||r.prompting)return;let a=ei.value.trim();if(e_&&!a)return ei.focus();let i=e_?null:r.selectedUid,s=e_?`${o.newPage} \xb7 ${a}`:i?e3(i):o.scopeEntry;en.appendChild(N(e,"p",{className:"bubble"},N(e,"span",{className:"visually-hidden",textContent:`${o.you} (${s}): `}),t)),es.value="",tl();let l=ti(t,i);if(ts(),td(),e_){try{await n.createPage(a,t),k.forget(),l.summary=o.created,l.status="kept"}catch(e){l.summary=R(e),l.status="failed"}ta(l),ts()}else await tf(l,t);es.focus()},ty=async e=>{eW=null;let t=await F(n,e);eW=t?{kind:"error",action:e,text:t}:{kind:"save"===e?"saved":"published"},ts()};eP.addEventListener("click",()=>tp(!eD)),x.addEventListener("click",()=>tp(!1)),eU.addEventListener("click",()=>{eH=!eH,ts()}),eI.addEventListener("click",()=>n.signOut()),b.addEventListener("click",()=>tg(!eV)),C.addEventListener("click",()=>tu(!0)),V.addEventListener("click",()=>tu(!1)),H.addEventListener("click",()=>{n.select(null),es.focus()}),ef.addEventListener("click",()=>{n.select(null),e2()}),et.addEventListener("click",async()=>{eX=null,eX=await q(n,o),ts()}),y.addEventListener("click",()=>tc("ask"===eq?"fields":"ask")),z.addEventListener("click",()=>{tb(!1),tc("fields"),e2()}),I.addEventListener("click",()=>{for(let e=e6();e;e=e6())tm(e,!1);tc("fields"),e2()}),ek.addEventListener("click",()=>{let e=n.getState().undoSteps,t=void 0===e?void 0:eK.find(t=>"kept"===t.status&&t.step===e);if(n.undo(),t){var r;t.status="undone",ts(),r=`${o.undone}: ${t.summary}`,eA.textContent="",eA.textContent=r}ek.hidden&&es.focus()}),eE.addEventListener("click",()=>void ty("save")),eC.addEventListener("click",()=>void ty("publish")),eu.addEventListener("submit",e=>{e.preventDefault(),tx()}),es.addEventListener("input",()=>{tl(),ts()}),es.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||e.isComposing||(e.preventDefault(),tx())}),ei.addEventListener("input",ts),ei.addEventListener("keydown",e=>{"Enter"!==e.key||e.isComposing||(e.preventDefault(),es.focus())});let tw=e=>{"Escape"===e.key&&!e.defaultPrevented&&th()&&e.preventDefault()};e.addEventListener("keydown",tw);let tk=e=>{let r=e.target,n=r?.closest?.(`[${t}]`),a=n?.getAttribute(t)??null;a!==eZ&&(eZ=a,te())},tE=()=>{eZ=null,te()};e.addEventListener("pointerover",tk),l.addEventListener("pointerleave",tE),s?.addEventListener("scroll",te,{capture:!0,passive:!0}),s?.addEventListener("resize",te);let tC=s?.MutationObserver,tN="function"==typeof tC?new tC(te):null;tN?.observe(e.body,{childList:!0,subtree:!0});let tA=s?.ResizeObserver,tL="function"==typeof tA?new tA(te):null;tL?.observe(l);let tP=s?.matchMedia?.("(min-width: 768px)")??null;eJ=tP?.matches??!0;let tS=()=>{eJ=tP?.matches??!0,ts()};tP?.addEventListener?.("change",tS);let t$=n.on("change",to);return l.setAttribute("data-obelism-editor",""),e.head.appendChild(u),e.body.appendChild(p),ts(),()=>{e0=!0,t$(),e1.unmount(),null!==e9&&s?.cancelAnimationFrame?.(e9),e.removeEventListener("keydown",tw),e.removeEventListener("pointerover",tk),l.removeEventListener("pointerleave",tE),s?.removeEventListener("scroll",te,{capture:!0}),s?.removeEventListener("resize",te),tP?.removeEventListener?.("change",tS),tN?.disconnect(),tL?.disconnect(),n.setSelecting(!1),l.removeAttribute("data-obelism-editor"),l.removeAttribute("data-obelism-docked"),l.style.removeProperty("--obelism-dock"),u.remove(),p.remove()}},et=Symbol.for("@obelism/content/bridge"),er=C({isEditing:!1,entryId:null,on:()=>{}},new URLSearchParams),en=({url:e,prompt:p=!0,pagePath:c,productPath:b,collectionPath:x}={})=>{let y;if("u"<typeof window)return er;let N=window;if(N[et])return N[et];if(N.ObelismBridge)y=C(N.ObelismBridge,new URLSearchParams(N.location.search));else{let C=(y=((e,r)=>{let n,a,p,c,b,x=new URLSearchParams(e.location.search),y=e.parent!==e&&x.has("cms_preview"),C=v(),N=[],A={...f,selecting:!0},L=e=>{A={...A,...e},C.emit("change",A)},P={isEditing:y,mode:y?"editor":null,entryId:x.get("cms_entry"),environment:x.get(i),product:null,collection:null,on:C.on,getState:()=>A,...w,destroy:()=>{N.splice(0).forEach(e=>e())}};if(!y)return P;let S=e.document,$=(t,n={})=>{e.parent.postMessage({source:h,type:t,...n},r)},M=S.createElement("style");M.textContent=m(),S.head.appendChild(M),N.push(()=>M.remove());let U=(e,t)=>{if(S.querySelectorAll("[data-cms-selected]").forEach(e=>{e.removeAttribute("data-cms-selected")}),A.selectedUid!==(e??null)&&L({selectedUid:e??null}),!e)return;let r=S.querySelector(E(e));r&&(r.setAttribute("data-cms-selected",""),t&&r.scrollIntoView({behavior:"smooth",block:"center"}))},z=e=>{let r=e.target,n=r?.closest?.(`[${t}]`);if(!n)return;e.preventDefault(),e.stopPropagation();let a=n.getAttribute(t);U(a,!1),$("select",{uid:a})};S.addEventListener("click",z,!0),N.push(()=>S.removeEventListener("click",z,!0));let I=()=>Math.ceil(Math.max(S.documentElement.scrollHeight,S.body?.scrollHeight??0)),O=0,j=()=>{O=I(),$("ready",{url:e.location.href,height:O})},R=e.ResizeObserver;if("function"==typeof R){let e=new R(()=>{let e=I();e!==O&&(O=e,$("size",{height:e}))});e.observe(S.documentElement),S.body&&e.observe(S.body),N.push(()=>e.disconnect())}let T=new Map,D=0,q=e=>{let t=T.get(e);return t?(clearTimeout(t.timer),T.delete(e),0===T.size&&L({prompting:!1}),t):null};P.prompt=(e,t={})=>{let r=e.trim();if(!r)return Promise.reject(Error("Say what to change"));if(!A.features.includes("prompt"))return Promise.reject(Error("The editor does not offer prompts here"));let n=`prompt_${++D}`,a=void 0===t.uid?A.selectedUid:t.uid;return new Promise((e,t)=>{let i=setTimeout(()=>{q(n)?.reject(Error("The editor did not answer in time"))},12e4);T.set(n,{resolve:e,reject:t,timer:i}),L({prompting:!0}),$("prompt",{id:n,prompt:r,uid:a})})},P.undo=()=>$("undo"),P.select=e=>{U(e,!1),$("select",{uid:e})};let F=null;N.push(()=>F?.destroy()),N.push(()=>{for(let e of T.keys())q(e)?.reject(Error("The bridge was destroyed"))});let B=(n=new WeakSet,a=null,p=null,c=!1,b=()=>{if(null!==a){for(let e of Array.from(S.styleSheets)){let t;if(!n.has(e)){try{t=e.cssRules}catch{continue}n.add(e),g(t,a)}}S.querySelectorAll('[style*="vh"]').forEach(e=>{u(e.style,a)})}},{freeze(e){if(null!==a||!(e>0))return;a=e,b();let t=S.defaultView?.MutationObserver;t&&(p=new t(()=>{if(c)return;c=!0;let e=()=>{c=!1,b()};S.defaultView?.requestAnimationFrame?S.defaultView.requestAnimationFrame(e):e()})).observe(S.documentElement,{childList:!0,subtree:!0})},destroy(){p?.disconnect()}});N.push(()=>B.destroy());let _=t=>{if(t.origin!==r||t.source!==e.parent)return;let n=t.data;if(n&&"obelism-content-editor"===n.source){if("connect"===n.type)j();else if("update"===n.type&&n.entry)C.emit("update",{entry:n.entry,selectedUid:n.selectedUid??null}),e.requestAnimationFrame(()=>U(n.selectedUid,!1)),F?.refresh();else if("select"===n.type)U(n.uid,!0);else if("saved"===n.type||"published"===n.type)C.emit(n.type,{}),0===C.listeners.update.size&&e.location.reload();else if("features"===n.type&&Array.isArray(n.features))L({features:n.features.filter(e=>"string"==typeof e)});else if("stats"===n.type)L({stats:(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return{};let t={};for(let[r,n]of Object.entries(e)){let{clicks:e,clickers:a,viewers:i,rate:o}=n??{};k(e)&&k(a)&&k(i)&&k(o)&&(t[r]={clicks:e,clickers:a,viewers:i,rate:o})}return t})(n.stats),statsVisible:!1!==n.visible}),(F||Object.keys(A.stats).length)&&(F??(F=((e,{selector:t,onSelect:r,labels:n})=>{let a=e.document,i={...o,...n},p=a.createElement("div");p.setAttribute("data-obelism-stats","");let c=p.attachShadow({mode:"open"}),u=a.createElement("style");u.textContent=l;let g=a.createElement("div");g.className="layer",c.append(u,g),a.body.appendChild(p);let h={},b=!1,m=null,f=()=>{if(m=null,g.replaceChildren(),g.hidden=!b,!b)return;let n=e.innerHeight;for(let[o,l]of Object.entries(h)){let p=a.querySelector(t(o));if(!p)continue;let c=p.getBoundingClientRect();if(!c.width&&!c.height||c.bottom<0||c.top>n)continue;let u=a.createElement("button");u.type="button",u.className="badge",u.dataset.uid=o,u.textContent=s(i.clicked,{rate:Math.round(100*l.rate)}),u.title=s(i.title,{clickers:l.clickers,viewers:l.viewers,clicks:l.clicks});let{place:h,top:b,left:m}=d(c,e.innerWidth);u.dataset.place=h,u.style.top=`${b}px`,u.style.left=`${m}px`,u.addEventListener("click",()=>r(o)),g.appendChild(u)}},v=()=>{null===m&&b&&(m=e.requestAnimationFrame(f))};e.addEventListener("scroll",v,{capture:!0,passive:!0}),e.addEventListener("resize",v);let x=e.MutationObserver,y="function"==typeof x?new x(v):null;return y?.observe(a.body,{childList:!0,subtree:!0}),{update(t,r){h=t,b=r,null!==m&&(e.cancelAnimationFrame?.(m),m=null),f()},refresh:v,destroy(){null!==m&&e.cancelAnimationFrame?.(m),e.removeEventListener("scroll",v,{capture:!0}),e.removeEventListener("resize",v),y?.disconnect(),p.remove()}}})(e,{selector:E,onSelect:e=>P.select(e)})),F.update(A.stats,A.statsVisible));else if("viewport"===n.type&&"number"==typeof n.height)B.freeze(n.height);else if("promptState"===n.type)L({canUndo:!0===n.canUndo});else if("promptResult"===n.type&&"string"==typeof n.id){let e=q(n.id);if(!e)return;!0===n.ok?e.resolve({summary:"string"==typeof n.summary?n.summary:""}):e.reject(Error("string"==typeof n.error?n.error:"The prompt failed"))}}};return e.addEventListener("message",_),N.push(()=>e.removeEventListener("message",_)),"loading"===S.readyState?(S.addEventListener("DOMContentLoaded",j,{once:!0}),N.push(()=>S.removeEventListener("DOMContentLoaded",j))):j(),P})(N,new URL(e||V).origin)).isEditing||N.parent!==N?null:(e=>{for(let t of e.cookie.split(";")){let[e,...r]=t.trim().split("=");if("obelism_content_editing"===e)try{let e=decodeURIComponent(r.join("="));return W.test(e)?e:null}catch{break}}return null})(N.document);if(C&&(y=((e,i,{pagePath:o=e=>`/${e.replace(/^\/+/,"")}`,productPath:s,collectionPath:l}={})=>{let d=e.document,p=v(),c=[],u=new Map,g=[],b=new Set,x=null,y=null,w=-1/0,k=new Map,C=f,N=e=>{C={...C,...e},p.emit("change",C)},A=()=>N({unsaved:[...u.values()].some(({content:e,saved:t})=>!X(e,t)),canUndo:g.length>0,undoSteps:g.length}),L=async(t,r)=>{let n=await e.fetch(`${i}/api/${t}`,void 0===r?{credentials:"same-origin"}:{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","x-obelism-content":"1"},body:JSON.stringify(r)}),a=await n.json().catch(()=>({}));if(401===n.status)throw N({features:[]}),Error("You were signed out. Sign in again to edit.");if(!n.ok)throw Error("string"==typeof a.error?a.error:`Obelism Content answered ${n.status}`);return a},P=()=>d.querySelector(`[${r}]`)?.getAttribute(r)??null,S=()=>{let e=d.querySelector(`[${n}]`),t=e?.getAttribute(n),r=e?.getAttribute("data-cms-product-handle");return t&&r?{id:t,handle:r}:null},$=()=>{let e=d.querySelector(`[${a}]`),t=e?.getAttribute(a),r=e?.getAttribute("data-cms-collection-handle");return t&&r?{id:t,handle:r}:null},M=e=>{let t=e?d.querySelector(E(e)):null;return t?.closest(`[${r}]`)?.getAttribute(r)??P()},U=()=>{if(!x)return;let e=x.space.locales.map(({code:e})=>e),t=d.documentElement.lang;if(e.includes(t))return t;let r=t.split("-")[0]??"";return e.includes(r)?r:x.space.defaultLocale},z=new Map,I=async e=>{let t=u.get(e);if(t)return t;let r=z.get(e);return r||(r=L(`entries/${encodeURIComponent(e)}`).then(t=>{let r=u.get(e)??{content:t.content,saved:t.content,revision:t.draftRevision};return u.set(e,r),r}).finally(()=>z.delete(e)),z.set(e,r)),r},O=e=>{let t=void 0===e?C.selectedUid:e,r=M(t);if(!r)throw Error("Nothing on this page is marked as an entry: add editable(entry)");return{uid:t,entryId:r}},j=e=>{d.querySelectorAll("[data-cms-selected]").forEach(e=>{e.removeAttribute("data-cms-selected")}),C.selectedUid!==e&&N({selectedUid:e}),e&&d.querySelector(E(e))?.setAttribute("data-cms-selected","")},R=async t=>{if(0===p.listeners.update.size)return;let r=u.get(t)?.content,{entry:n}=await L(`entries/${encodeURIComponent(t)}/preview`,{content:r,locale:U()});p.emit("update",{entry:n,selectedUid:C.selectedUid}),e.requestAnimationFrame(()=>j(C.selectedUid))},T=e=>console.error("[@obelism/content bridge]",e),D=t=>{p.emit(t,{}),0===p.listeners.update.size&&e.location.reload()},q=async()=>{for(let[e,t]of u){if(X(t.content,t.saved))continue;let{draftRevision:r}=await L(`entries/${encodeURIComponent(e)}/save`,{content:t.content,baseRevision:t.revision});t.saved=t.content,t.revision=r,b.add(e)}g.length=0,w=-1/0,A()},F={isEditing:!0,mode:"site",get entryId(){return P()},get product(){return S()},get collection(){return $()},get environment(){return x?.environment??null},on:p.on,getState:()=>C,async prompt(e,t={}){let r=e.trim();if(!r)throw Error("Say what to change");if(!C.features.includes("prompt"))throw Error("You may not edit content here");let{uid:n,entryId:a}=O(t.uid);N({prompting:!0});try{let e=await I(a),t=await L(`entries/${encodeURIComponent(a)}/prompt`,{prompt:r,content:e.content,locale:U(),uid:n});return g.push({entryId:a,content:e.content}),w=-1/0,e.content=t.content,A(),await R(a),{summary:t.summary}}finally{N({prompting:!1})}},async createPage(t,r){let n=r.trim();if(!n)throw Error("Say what the page is for");if(!t.trim())throw Error("Say where the page goes, like /pricing");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");N({prompting:!0});try{let r=await L("entries",{path:t,prompt:n,locale:U(),from:P()}),a=o(r.path,U()??"");return e.location.assign(Y(a)),{summary:r.summary,entryId:r.entryId,path:r.path,url:a}}finally{N({prompting:!1})}},async createProductPage(t=S()??void 0){if(!t)throw Error("Nothing on this page is marked as a product: add editableProduct(product)");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");N({prompting:!0});try{let r=await L("product-pages",{product:{id:t.id,handle:t.handle}});return e.location.reload(),r}finally{N({prompting:!1})}},async createCollectionPage(t=$()??void 0){if(!t)throw Error("Nothing on this page is marked as a collection: add editableCollection(collection)");if(!C.features.includes("create"))throw Error("You may not add pages here");if(C.unsaved)throw Error("Save or undo your changes before adding a page");N({prompting:!0});try{let r=await L("collection-pages",{collection:{id:t.id,handle:t.handle}});return e.location.reload(),r}finally{N({prompting:!1})}},async view(e={}){let{uid:t,entryId:r}=O(e.uid),n=await I(r),{view:a}=await L(`entries/${encodeURIComponent(r)}/view`,{content:n.content,locale:U(),uid:t});return a},async applyJson(e,t={}){if(!C.features.includes("prompt"))throw Error("You may not edit content here");if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Send the fields to change as an object");let{uid:r,entryId:n}=O(t.uid);N({prompting:!0});try{let t=await I(n),a=await L(`entries/${encodeURIComponent(n)}/apply`,{changes:e,content:t.content,locale:U(),uid:r});return X(a.content,t.content)||(g.push({entryId:n,content:t.content}),w=-1/0,t.content=a.content,A(),await R(n)),{changed:a.changed??[],...a.view&&{view:a.view}}}finally{N({prompting:!1})}},openForm(t,r={}){let{title:n="Content form",onReady:a,onError:i,onEscape:o}=r;y?.();let s=!1,l=null,d=null,c=()=>{},b=e=>{s||i?.(e instanceof Error?e.message:String(e))},m=()=>{s||(s=!0,c(),l?.destroy(),y===m&&(y=null))};y=m;let f=()=>{if(s||!l)return;let e=M(C.selectedUid);if(!e)return;let t=u.get(e);if(!t)return void I(e).then(f,b);let r={entryId:e,content:t.content,locale:U(),selectedUid:C.selectedUid};d&&d.entryId===r.entryId&&d.content===r.content&&d.locale===r.locale&&d.selectedUid===r.selectedUid||(d=r,l.show(r))},v=(e,t)=>{let r=t??d?.entryId,n=void 0===r?void 0:u.get(r);if(s||void 0===r||!n||X(e,n.content))return;let a=Date.now();a-w>=1e3&&g.push({entryId:r,content:n.content}),w=a,n.content=e,d?.entryId===r&&(d={...d,content:e}),A(),clearTimeout(k.get(r)),k.set(r,setTimeout(()=>{k.delete(r),R(r).catch(T)},300))};return(async()=>{if(!C.features.includes("form"))throw Error("You may not edit content here");await I(O(void 0).entryId);let{url:r}=await L("form",{});s||(l=((e,t,r,n,a)=>{let i=null;try{i=new URL(r)}catch{}if(!i||!/^https?:$/.test(i.protocol))throw Error("Obelism Content sent no form to open");let o=i.origin,s=t.ownerDocument.createElement("iframe");s.title=n,s.src=r;let l=!1,d=!1,p=null,c=()=>{l&&p&&s.contentWindow?.postMessage({source:h,type:"content",...p},o)},u=setTimeout(()=>{d||a.onError("The form did not open")},3e4),g=()=>{d=!0,clearTimeout(u),a.onReady()},b=e=>{if(e.origin!==o||!s.contentWindow||e.source!==s.contentWindow)return;let t=e.data;if(t&&"obelism-content-form"===t.source)if("ready"===t.type)l=!0,c(),!0!==t.loading&&g();else if("loaded"===t.type)l&&g();else{let e;if("change"!==t.type||!(e=t.content)||"object"!=typeof e||Array.isArray(e))if("height"===t.type){let e=t.height;if("number"==typeof e&&Number.isFinite(e)){let t=Math.round(Math.min(Math.max(e,80),4e3));s.style.height=`min(${t}px, 60vh)`}}else"escape"===t.type?a.onEscape?.():"error"===t.type&&a.onError("string"==typeof t.message&&t.message?t.message:"The form failed");else a.onChange(t.content,"string"==typeof t.entryId?t.entryId:void 0)}};return e.addEventListener("message",b),t.appendChild(s),{show(e){p=e,c()},destroy(){clearTimeout(u),e.removeEventListener("message",b),s.remove()}}})(e,t,"string"==typeof r?r:"",n,{onReady:()=>a?.(),onChange:v,onError:e=>i?.(e),onEscape:()=>o?.()}),c=p.on("change",f),f())})().catch(b),{close:m}},async pages(){let{pages:e}=await L("pages"),t=[U(),x?.space.defaultLocale];return e.flatMap(e=>{let r,n,a=t.find(t=>void 0!==t&&void 0!==e.paths[t])??Object.keys(e.paths)[0],i=void 0===a?void 0:e.paths[a];return void 0===a||void 0===i?[]:[{entryId:e.entryId,name:e.name,contentType:e.contentType,status:e.status,path:i,url:e.product?(r=e.product.handle,s?s(r,a):(x?.productPath??"/products/{handle}").replaceAll("{handle}",encodeURIComponent(r))):e.collection?(n=e.collection.handle,l?l(n,a):(x?.collectionPath??"/collections/{handle}").replaceAll("{handle}",encodeURIComponent(n))):o(i,a),product:e.product??null,collection:e.collection??null}]})},openPage(t){(!C.unsaved||e.confirm("Leave this page and lose the changes you have not saved?"))&&(u.clear(),g.length=0,A(),e.location.assign(Y(t.url)))},undo(){let e=g.pop(),t=e&&u.get(e.entryId);e&&t&&(w=-1/0,t.content=e.content,A(),R(e.entryId).catch(T))},async save(){if(!C.features.includes("save"))throw Error("You may not edit content here");N({saving:!0});try{await q()}finally{N({saving:!1})}D("saved")},async publish(){if(!C.features.includes("publish"))throw Error("You may not publish here");N({publishing:!0});try{await q();let e=P(),t=b.size>0?[...b]:e?[e]:[];if(0===t.length)throw Error("Nothing on this page is marked as an entry: add editable(entry)");for(let e of t)await L(`entries/${encodeURIComponent(e)}/publish`,{}),b.delete(e)}finally{N({publishing:!1})}D("published")},signOut(){if(C.unsaved&&!e.confirm("Sign out and lose the changes you have not saved?"))return;u.clear(),A();let t=e.location.pathname+e.location.search;e.location.href=`${i}/logout?return_to=${encodeURIComponent(t)}`},select(e){j(e)},setSelecting(e){e?d.documentElement.setAttribute("data-cms-selecting",""):d.documentElement.removeAttribute("data-cms-selecting"),N({selecting:e})},destroy(){y?.(),k.forEach(e=>clearTimeout(e)),k.clear(),c.splice(0).forEach(e=>e())}},B=d.createElement("style");B.textContent=m("html[data-cms-selecting] "),d.head.appendChild(B),c.push(()=>B.remove()),c.push(()=>d.documentElement.removeAttribute("data-cms-selecting"));let _=e=>{if(!C.selecting)return;let r=e.target,n=r?.closest?.(`[${t}]`);n&&(e.preventDefault(),e.stopPropagation(),j(n.getAttribute(t)))};d.addEventListener("click",_,!0),c.push(()=>d.removeEventListener("click",_,!0));let H=e=>{C.unsaved&&(e.preventDefault(),e.returnValue="")};return e.addEventListener("beforeunload",H),c.push(()=>e.removeEventListener("beforeunload",H)),L("session").then(e=>{x=e,N({features:e.features})}).catch(e=>console.error("[@obelism/content bridge]",e)),F})(N,C,{pagePath:c,productPath:b,collectionPath:x})),y.isEditing&&p){let e=N.document,t=()=>{},r=!1,n=C?ee:H,a=()=>{r||(t=n(e,y,!0===p?{}:p))};e.body?a():e.addEventListener("DOMContentLoaded",a,{once:!0});let i=y.destroy;y.destroy=()=>{r=!0,e.removeEventListener("DOMContentLoaded",a),t(),i()}}}return N[et]=y,y};(e=window).ObelismBridge=en((e=>{let t=e?.dataset.url,r=t||V;if(!t&&e?.src){let t=new URL(e.src);"/bridge.js"===t.pathname&&(r=t.origin)}return{url:r,prompt:e?.dataset.prompt!=="false"}})(document.currentScript)),e.ObelismContent={getContentBridge:en,mountPromptBox:H,mountSiteEditor:ee}}();
|
package/dist/bridge.js
CHANGED
|
@@ -2738,17 +2738,15 @@ button:disabled { cursor: not-allowed; }
|
|
|
2738
2738
|
.empty.error { color: rgb(var(--negative)); }
|
|
2739
2739
|
.new-page { justify-content: flex-start; }
|
|
2740
2740
|
|
|
2741
|
-
.
|
|
2742
|
-
display:
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
}
|
|
2749
|
-
.
|
|
2750
|
-
.tab[aria-selected='true'] { background: rgb(var(--bg)); color: rgb(var(--fg)); box-shadow: var(--shadow-small); }
|
|
2751
|
-
.tab .mark svg { width: 12px; height: 12px; }
|
|
2741
|
+
.mode {
|
|
2742
|
+
display: inline-flex; align-items: center; gap: 6px; flex: none; height: 32px;
|
|
2743
|
+
padding: 0 12px; border-radius: 999px; background: rgb(var(--paper));
|
|
2744
|
+
font-size: 13px; font-weight: 500; color: rgb(var(--soft));
|
|
2745
|
+
}
|
|
2746
|
+
.mode:hover:not(:disabled) { background: rgb(var(--actions)); color: rgb(var(--fg)); }
|
|
2747
|
+
.mode[aria-pressed='true'] { background: rgb(var(--coral-wash)); color: rgb(var(--coral-ink)); }
|
|
2748
|
+
.mode:disabled { opacity: .5; }
|
|
2749
|
+
.mode .mark svg { width: 12px; height: 12px; }
|
|
2752
2750
|
.ask, .fields { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
2753
2751
|
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; }
|
|
2754
2752
|
.note {
|
|
@@ -2847,7 +2845,9 @@ textarea:disabled, .path input:disabled { opacity: .6; }
|
|
|
2847
2845
|
.send .icon svg { stroke-width: 2; }
|
|
2848
2846
|
.send .working svg, .send .working .accent { fill: rgb(var(--ink)); }
|
|
2849
2847
|
|
|
2850
|
-
.
|
|
2848
|
+
.fields { padding-top: 12px; }
|
|
2849
|
+
.fields .note { margin: 0 14px 14px; }
|
|
2850
|
+
.form { position: relative; flex: 1; min-height: 0; margin: 0 14px; }
|
|
2851
2851
|
.form iframe {
|
|
2852
2852
|
display: block; width: 100%; height: 100% !important; border: 0; border-radius: 12px; background: rgb(var(--subtle));
|
|
2853
2853
|
}
|
|
@@ -3037,11 +3037,15 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3037
3037
|
const minimise = button('icon-button hit', icon('dash'));
|
|
3038
3038
|
minimise.setAttribute('aria-label', labels.minimize);
|
|
3039
3039
|
minimise.title = labels.minimize;
|
|
3040
|
+
// The fields are the editor's first view; Ask is this small button beside
|
|
3041
|
+
// the minimise one, pressed while the ask view shows.
|
|
3042
|
+
const askMode = button('mode hit', mark(), labels.modePrompt);
|
|
3043
|
+
askMode.setAttribute('aria-pressed', 'false');
|
|
3040
3044
|
const head = element(doc, 'div', {
|
|
3041
3045
|
className: 'head'
|
|
3042
3046
|
}, tile, pageButton, pageName, env, element(doc, 'span', {
|
|
3043
3047
|
className: 'spacer'
|
|
3044
|
-
}), minimise);
|
|
3048
|
+
}), askMode, minimise);
|
|
3045
3049
|
const picker = createPagesPicker(doc, bridge, labels, {
|
|
3046
3050
|
onLoad: ()=>refresh(),
|
|
3047
3051
|
onClose: ()=>setPicking(false)
|
|
@@ -3050,20 +3054,6 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3050
3054
|
const pagesBox = element(doc, 'div', {
|
|
3051
3055
|
className: 'pages'
|
|
3052
3056
|
}, picker.searchRow, picker.list, picker.note, newPage);
|
|
3053
|
-
const tab = (id, controls, ...children)=>{
|
|
3054
|
-
const node = button('tab', ...children);
|
|
3055
|
-
node.id = id;
|
|
3056
|
-
node.setAttribute('role', 'tab');
|
|
3057
|
-
node.setAttribute('aria-controls', controls);
|
|
3058
|
-
return node;
|
|
3059
|
-
};
|
|
3060
|
-
const askTab = tab('obelism-tab-ask', 'obelism-ask', mark(), labels.modePrompt);
|
|
3061
|
-
const fieldsTab = tab('obelism-tab-fields', 'obelism-fields', labels.form);
|
|
3062
|
-
const tabs = element(doc, 'div', {
|
|
3063
|
-
className: 'tabs'
|
|
3064
|
-
}, askTab, fieldsTab);
|
|
3065
|
-
tabs.setAttribute('role', 'tablist');
|
|
3066
|
-
tabs.setAttribute('aria-label', labels.modes);
|
|
3067
3057
|
// Edit fields asked for while a suggestion waits: it's kept or undone
|
|
3068
3058
|
// first, never by the switch itself.
|
|
3069
3059
|
const gateKeep = button('button primary', labels.keep);
|
|
@@ -3137,7 +3127,7 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3137
3127
|
id: 'obelism-ask'
|
|
3138
3128
|
}, scroll, composer);
|
|
3139
3129
|
ask.setAttribute('role', 'tabpanel');
|
|
3140
|
-
ask.setAttribute('aria-
|
|
3130
|
+
ask.setAttribute('aria-label', labels.modePrompt);
|
|
3141
3131
|
const formNote = element(doc, 'p', {
|
|
3142
3132
|
className: 'form-note'
|
|
3143
3133
|
});
|
|
@@ -3145,12 +3135,18 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3145
3135
|
const formBox = element(doc, 'div', {
|
|
3146
3136
|
className: 'form'
|
|
3147
3137
|
}, formNote);
|
|
3138
|
+
// The same way back as the ask view's note, above the form it changes.
|
|
3139
|
+
const fieldsNoteText = element(doc, 'span');
|
|
3140
|
+
const wholePageFields = button('', labels.scopeEntry);
|
|
3141
|
+
const fieldsNote = element(doc, 'div', {
|
|
3142
|
+
className: 'note'
|
|
3143
|
+
}, icon('scope'), fieldsNoteText, wholePageFields);
|
|
3148
3144
|
const fields = element(doc, 'div', {
|
|
3149
3145
|
className: 'fields',
|
|
3150
3146
|
id: 'obelism-fields'
|
|
3151
|
-
}, formBox);
|
|
3147
|
+
}, fieldsNote, formBox);
|
|
3152
3148
|
fields.setAttribute('role', 'tabpanel');
|
|
3153
|
-
fields.setAttribute('aria-
|
|
3149
|
+
fields.setAttribute('aria-label', labels.form);
|
|
3154
3150
|
const saveState = element(doc, 'p', {
|
|
3155
3151
|
className: 'save-state'
|
|
3156
3152
|
});
|
|
@@ -3170,7 +3166,7 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3170
3166
|
const panel = element(doc, 'aside', {
|
|
3171
3167
|
className: 'panel',
|
|
3172
3168
|
id: 'obelism-editor'
|
|
3173
|
-
}, head, pagesBox,
|
|
3169
|
+
}, head, pagesBox, gate, ask, fields, foot, announcer);
|
|
3174
3170
|
panel.setAttribute('aria-label', labels.editor);
|
|
3175
3171
|
const launch = button('launch', element(doc, 'span', {
|
|
3176
3172
|
className: 'launch-tile'
|
|
@@ -3208,7 +3204,10 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3208
3204
|
textContent: CSS
|
|
3209
3205
|
}), root);
|
|
3210
3206
|
let open = readOpen(win);
|
|
3211
|
-
|
|
3207
|
+
// The fields are the first view (mode); without the form the ask view
|
|
3208
|
+
// shows instead (view), and back once the form is there.
|
|
3209
|
+
let mode = 'fields';
|
|
3210
|
+
let view = 'fields';
|
|
3212
3211
|
let gated = false;
|
|
3213
3212
|
let creating = false;
|
|
3214
3213
|
let outlines = true;
|
|
@@ -3224,10 +3223,17 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3224
3223
|
let pageNames = 'idle';
|
|
3225
3224
|
let destroyed = false;
|
|
3226
3225
|
const formSlot = createFormSlot(bridge, formBox, labels.formTitle, {
|
|
3227
|
-
onReady: ()=>
|
|
3226
|
+
onReady: ()=>{
|
|
3227
|
+
refresh();
|
|
3228
|
+
// The form came while the fields show: straight into it.
|
|
3229
|
+
if (open && view === 'fields') focusForm();
|
|
3230
|
+
},
|
|
3228
3231
|
onError: ()=>refresh(),
|
|
3229
3232
|
onEscape: ()=>stepBack()
|
|
3230
3233
|
});
|
|
3234
|
+
// The form's iframe, once the slot has one; the fields view's focus
|
|
3235
|
+
// target (the slot mounts it only while shown, so it may not be there).
|
|
3236
|
+
const focusForm = ()=>formBox.querySelector('iframe')?.focus();
|
|
3231
3237
|
const pending = ()=>answers.filter(({ status })=>status === 'pending');
|
|
3232
3238
|
const latestPending = ()=>pending().slice(-1)[0] ?? null;
|
|
3233
3239
|
// Decided on while nothing else runs: undo would take the running one's
|
|
@@ -3490,9 +3496,9 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3490
3496
|
if (!canCreate) creating = false;
|
|
3491
3497
|
if (onlyNew) creating = true;
|
|
3492
3498
|
const hasForm = site && !creating && !pageless && state.features.includes('form');
|
|
3493
|
-
|
|
3499
|
+
view = hasForm ? mode : 'ask';
|
|
3494
3500
|
const waiting = pending().length > 0;
|
|
3495
|
-
if (!waiting ||
|
|
3501
|
+
if (!waiting || view === 'fields') gated = false;
|
|
3496
3502
|
// Steps undone elsewhere (or saved away) aren't any answer's any more.
|
|
3497
3503
|
for (const answer of answers)if (answer.step !== null && answer.step > (state.undoSteps ?? 0)) answer.step = null;
|
|
3498
3504
|
root.hidden = !available && !site;
|
|
@@ -3512,7 +3518,7 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3512
3518
|
html.style.setProperty('--obelism-dock', `${docked ? DOCK_WIDTH_PX : 0}px`);
|
|
3513
3519
|
const selecting = shown && outlines && !creating;
|
|
3514
3520
|
if (state.selecting !== selecting) bridge.setSelecting(selecting);
|
|
3515
|
-
const showForm = shown &&
|
|
3521
|
+
const showForm = shown && view === 'fields';
|
|
3516
3522
|
if (showForm && !formSlot.mounted) formSlot.mount();
|
|
3517
3523
|
else if (!showForm && formSlot.mounted) formSlot.unmount();
|
|
3518
3524
|
if (picking && !shown) picking = false;
|
|
@@ -3528,27 +3534,28 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3528
3534
|
env.hidden = !environment;
|
|
3529
3535
|
env.dataset.env = environment ?? '';
|
|
3530
3536
|
envText.textContent = environment === 'production' ? labels.envProduction : environment ?? '';
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
askTab.disabled = fieldsTab.disabled = busy;
|
|
3535
|
-
askTab.tabIndex = mode === 'ask' ? 0 : -1;
|
|
3536
|
-
fieldsTab.tabIndex = mode === 'fields' ? 0 : -1;
|
|
3537
|
+
askMode.hidden = !hasForm;
|
|
3538
|
+
askMode.setAttribute('aria-pressed', String(view === 'ask'));
|
|
3539
|
+
askMode.disabled = busy;
|
|
3537
3540
|
gate.hidden = !gated;
|
|
3538
3541
|
gateKeep.disabled = gateUndo.disabled = busy;
|
|
3539
|
-
ask.hidden =
|
|
3540
|
-
fields.hidden =
|
|
3542
|
+
ask.hidden = view !== 'ask';
|
|
3543
|
+
fields.hidden = view !== 'fields';
|
|
3541
3544
|
const offerShop = shopHere !== null && !creating;
|
|
3542
3545
|
if (creating) {
|
|
3543
3546
|
noteText.textContent = labels.newPage;
|
|
3544
3547
|
} else if (state.selectedUid) {
|
|
3545
3548
|
const [beforeName, afterName = ''] = labels.scopeNoteBlock.split('{name}');
|
|
3546
|
-
|
|
3549
|
+
for (const text of [
|
|
3550
|
+
noteText,
|
|
3551
|
+
fieldsNoteText
|
|
3552
|
+
])text.replaceChildren(beforeName ?? '', element(doc, 'strong', {
|
|
3547
3553
|
textContent: nameOf(state.selectedUid)
|
|
3548
3554
|
}), afterName);
|
|
3549
3555
|
} else {
|
|
3550
3556
|
noteText.textContent = labels.scopeNotePage;
|
|
3551
3557
|
}
|
|
3558
|
+
fieldsNote.hidden = creating || !state.selectedUid;
|
|
3552
3559
|
note.hidden = offerShop || pageless && !creating && !options.promptWithoutPage;
|
|
3553
3560
|
wholePage.hidden = creating || !state.selectedUid;
|
|
3554
3561
|
cancelNew.hidden = !creating || onlyNew;
|
|
@@ -3628,7 +3635,9 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3628
3635
|
if (!open) picking = false;
|
|
3629
3636
|
refresh();
|
|
3630
3637
|
if (open) {
|
|
3631
|
-
(
|
|
3638
|
+
if (creating) pathInput.focus();
|
|
3639
|
+
else if (view === 'fields') focusForm();
|
|
3640
|
+
else input.focus();
|
|
3632
3641
|
} else {
|
|
3633
3642
|
launch.focus();
|
|
3634
3643
|
}
|
|
@@ -3782,35 +3791,25 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3782
3791
|
bridge.select(null);
|
|
3783
3792
|
input.focus();
|
|
3784
3793
|
});
|
|
3794
|
+
wholePageFields.addEventListener('click', ()=>{
|
|
3795
|
+
bridge.select(null);
|
|
3796
|
+
focusForm();
|
|
3797
|
+
});
|
|
3785
3798
|
shopButton.addEventListener('click', async ()=>{
|
|
3786
3799
|
shopMessage = null;
|
|
3787
3800
|
shopMessage = await addShopPage(bridge, labels);
|
|
3788
3801
|
refresh();
|
|
3789
3802
|
});
|
|
3790
|
-
|
|
3791
|
-
fieldsTab.addEventListener('click', ()=>setMode('fields'));
|
|
3792
|
-
// Arrows move focus between the tabs; Enter or Space (a click) opens one.
|
|
3793
|
-
tabs.addEventListener('keydown', (event)=>{
|
|
3794
|
-
if (![
|
|
3795
|
-
'ArrowLeft',
|
|
3796
|
-
'ArrowRight',
|
|
3797
|
-
'Home',
|
|
3798
|
-
'End'
|
|
3799
|
-
].includes(event.key)) return;
|
|
3800
|
-
event.preventDefault();
|
|
3801
|
-
const onAsk = shadow.activeElement === askTab;
|
|
3802
|
-
const target = event.key === 'Home' ? askTab : event.key === 'End' ? fieldsTab : onAsk ? fieldsTab : askTab;
|
|
3803
|
-
target.focus();
|
|
3804
|
-
});
|
|
3803
|
+
askMode.addEventListener('click', ()=>setMode(mode === 'ask' ? 'fields' : 'ask'));
|
|
3805
3804
|
gateKeep.addEventListener('click', ()=>{
|
|
3806
3805
|
keepAll(false);
|
|
3807
3806
|
setMode('fields');
|
|
3808
|
-
|
|
3807
|
+
focusForm();
|
|
3809
3808
|
});
|
|
3810
3809
|
gateUndo.addEventListener('click', ()=>{
|
|
3811
3810
|
for(let answer = decidable(); answer; answer = decidable())undoAnswer(answer, false);
|
|
3812
3811
|
setMode('fields');
|
|
3813
|
-
|
|
3812
|
+
focusForm();
|
|
3814
3813
|
});
|
|
3815
3814
|
undo.addEventListener('click', ()=>{
|
|
3816
3815
|
const step = bridge.getState().undoSteps;
|
package/dist/bridge.mjs
CHANGED
|
@@ -2736,17 +2736,15 @@ button:disabled { cursor: not-allowed; }
|
|
|
2736
2736
|
.empty.error { color: rgb(var(--negative)); }
|
|
2737
2737
|
.new-page { justify-content: flex-start; }
|
|
2738
2738
|
|
|
2739
|
-
.
|
|
2740
|
-
display:
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
}
|
|
2747
|
-
.
|
|
2748
|
-
.tab[aria-selected='true'] { background: rgb(var(--bg)); color: rgb(var(--fg)); box-shadow: var(--shadow-small); }
|
|
2749
|
-
.tab .mark svg { width: 12px; height: 12px; }
|
|
2739
|
+
.mode {
|
|
2740
|
+
display: inline-flex; align-items: center; gap: 6px; flex: none; height: 32px;
|
|
2741
|
+
padding: 0 12px; border-radius: 999px; background: rgb(var(--paper));
|
|
2742
|
+
font-size: 13px; font-weight: 500; color: rgb(var(--soft));
|
|
2743
|
+
}
|
|
2744
|
+
.mode:hover:not(:disabled) { background: rgb(var(--actions)); color: rgb(var(--fg)); }
|
|
2745
|
+
.mode[aria-pressed='true'] { background: rgb(var(--coral-wash)); color: rgb(var(--coral-ink)); }
|
|
2746
|
+
.mode:disabled { opacity: .5; }
|
|
2747
|
+
.mode .mark svg { width: 12px; height: 12px; }
|
|
2750
2748
|
.ask, .fields { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
2751
2749
|
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; }
|
|
2752
2750
|
.note {
|
|
@@ -2845,7 +2843,9 @@ textarea:disabled, .path input:disabled { opacity: .6; }
|
|
|
2845
2843
|
.send .icon svg { stroke-width: 2; }
|
|
2846
2844
|
.send .working svg, .send .working .accent { fill: rgb(var(--ink)); }
|
|
2847
2845
|
|
|
2848
|
-
.
|
|
2846
|
+
.fields { padding-top: 12px; }
|
|
2847
|
+
.fields .note { margin: 0 14px 14px; }
|
|
2848
|
+
.form { position: relative; flex: 1; min-height: 0; margin: 0 14px; }
|
|
2849
2849
|
.form iframe {
|
|
2850
2850
|
display: block; width: 100%; height: 100% !important; border: 0; border-radius: 12px; background: rgb(var(--subtle));
|
|
2851
2851
|
}
|
|
@@ -3035,11 +3035,15 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3035
3035
|
const minimise = button('icon-button hit', icon('dash'));
|
|
3036
3036
|
minimise.setAttribute('aria-label', labels.minimize);
|
|
3037
3037
|
minimise.title = labels.minimize;
|
|
3038
|
+
// The fields are the editor's first view; Ask is this small button beside
|
|
3039
|
+
// the minimise one, pressed while the ask view shows.
|
|
3040
|
+
const askMode = button('mode hit', mark(), labels.modePrompt);
|
|
3041
|
+
askMode.setAttribute('aria-pressed', 'false');
|
|
3038
3042
|
const head = element(doc, 'div', {
|
|
3039
3043
|
className: 'head'
|
|
3040
3044
|
}, tile, pageButton, pageName, env, element(doc, 'span', {
|
|
3041
3045
|
className: 'spacer'
|
|
3042
|
-
}), minimise);
|
|
3046
|
+
}), askMode, minimise);
|
|
3043
3047
|
const picker = createPagesPicker(doc, bridge, labels, {
|
|
3044
3048
|
onLoad: ()=>refresh(),
|
|
3045
3049
|
onClose: ()=>setPicking(false)
|
|
@@ -3048,20 +3052,6 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3048
3052
|
const pagesBox = element(doc, 'div', {
|
|
3049
3053
|
className: 'pages'
|
|
3050
3054
|
}, picker.searchRow, picker.list, picker.note, newPage);
|
|
3051
|
-
const tab = (id, controls, ...children)=>{
|
|
3052
|
-
const node = button('tab', ...children);
|
|
3053
|
-
node.id = id;
|
|
3054
|
-
node.setAttribute('role', 'tab');
|
|
3055
|
-
node.setAttribute('aria-controls', controls);
|
|
3056
|
-
return node;
|
|
3057
|
-
};
|
|
3058
|
-
const askTab = tab('obelism-tab-ask', 'obelism-ask', mark(), labels.modePrompt);
|
|
3059
|
-
const fieldsTab = tab('obelism-tab-fields', 'obelism-fields', labels.form);
|
|
3060
|
-
const tabs = element(doc, 'div', {
|
|
3061
|
-
className: 'tabs'
|
|
3062
|
-
}, askTab, fieldsTab);
|
|
3063
|
-
tabs.setAttribute('role', 'tablist');
|
|
3064
|
-
tabs.setAttribute('aria-label', labels.modes);
|
|
3065
3055
|
// Edit fields asked for while a suggestion waits: it's kept or undone
|
|
3066
3056
|
// first, never by the switch itself.
|
|
3067
3057
|
const gateKeep = button('button primary', labels.keep);
|
|
@@ -3135,7 +3125,7 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3135
3125
|
id: 'obelism-ask'
|
|
3136
3126
|
}, scroll, composer);
|
|
3137
3127
|
ask.setAttribute('role', 'tabpanel');
|
|
3138
|
-
ask.setAttribute('aria-
|
|
3128
|
+
ask.setAttribute('aria-label', labels.modePrompt);
|
|
3139
3129
|
const formNote = element(doc, 'p', {
|
|
3140
3130
|
className: 'form-note'
|
|
3141
3131
|
});
|
|
@@ -3143,12 +3133,18 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3143
3133
|
const formBox = element(doc, 'div', {
|
|
3144
3134
|
className: 'form'
|
|
3145
3135
|
}, formNote);
|
|
3136
|
+
// The same way back as the ask view's note, above the form it changes.
|
|
3137
|
+
const fieldsNoteText = element(doc, 'span');
|
|
3138
|
+
const wholePageFields = button('', labels.scopeEntry);
|
|
3139
|
+
const fieldsNote = element(doc, 'div', {
|
|
3140
|
+
className: 'note'
|
|
3141
|
+
}, icon('scope'), fieldsNoteText, wholePageFields);
|
|
3146
3142
|
const fields = element(doc, 'div', {
|
|
3147
3143
|
className: 'fields',
|
|
3148
3144
|
id: 'obelism-fields'
|
|
3149
|
-
}, formBox);
|
|
3145
|
+
}, fieldsNote, formBox);
|
|
3150
3146
|
fields.setAttribute('role', 'tabpanel');
|
|
3151
|
-
fields.setAttribute('aria-
|
|
3147
|
+
fields.setAttribute('aria-label', labels.form);
|
|
3152
3148
|
const saveState = element(doc, 'p', {
|
|
3153
3149
|
className: 'save-state'
|
|
3154
3150
|
});
|
|
@@ -3168,7 +3164,7 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3168
3164
|
const panel = element(doc, 'aside', {
|
|
3169
3165
|
className: 'panel',
|
|
3170
3166
|
id: 'obelism-editor'
|
|
3171
|
-
}, head, pagesBox,
|
|
3167
|
+
}, head, pagesBox, gate, ask, fields, foot, announcer);
|
|
3172
3168
|
panel.setAttribute('aria-label', labels.editor);
|
|
3173
3169
|
const launch = button('launch', element(doc, 'span', {
|
|
3174
3170
|
className: 'launch-tile'
|
|
@@ -3206,7 +3202,10 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3206
3202
|
textContent: CSS
|
|
3207
3203
|
}), root);
|
|
3208
3204
|
let open = readOpen(win);
|
|
3209
|
-
|
|
3205
|
+
// The fields are the first view (mode); without the form the ask view
|
|
3206
|
+
// shows instead (view), and back once the form is there.
|
|
3207
|
+
let mode = 'fields';
|
|
3208
|
+
let view = 'fields';
|
|
3210
3209
|
let gated = false;
|
|
3211
3210
|
let creating = false;
|
|
3212
3211
|
let outlines = true;
|
|
@@ -3222,10 +3221,17 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3222
3221
|
let pageNames = 'idle';
|
|
3223
3222
|
let destroyed = false;
|
|
3224
3223
|
const formSlot = createFormSlot(bridge, formBox, labels.formTitle, {
|
|
3225
|
-
onReady: ()=>
|
|
3224
|
+
onReady: ()=>{
|
|
3225
|
+
refresh();
|
|
3226
|
+
// The form came while the fields show: straight into it.
|
|
3227
|
+
if (open && view === 'fields') focusForm();
|
|
3228
|
+
},
|
|
3226
3229
|
onError: ()=>refresh(),
|
|
3227
3230
|
onEscape: ()=>stepBack()
|
|
3228
3231
|
});
|
|
3232
|
+
// The form's iframe, once the slot has one; the fields view's focus
|
|
3233
|
+
// target (the slot mounts it only while shown, so it may not be there).
|
|
3234
|
+
const focusForm = ()=>formBox.querySelector('iframe')?.focus();
|
|
3229
3235
|
const pending = ()=>answers.filter(({ status })=>status === 'pending');
|
|
3230
3236
|
const latestPending = ()=>pending().slice(-1)[0] ?? null;
|
|
3231
3237
|
// Decided on while nothing else runs: undo would take the running one's
|
|
@@ -3488,9 +3494,9 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3488
3494
|
if (!canCreate) creating = false;
|
|
3489
3495
|
if (onlyNew) creating = true;
|
|
3490
3496
|
const hasForm = site && !creating && !pageless && state.features.includes('form');
|
|
3491
|
-
|
|
3497
|
+
view = hasForm ? mode : 'ask';
|
|
3492
3498
|
const waiting = pending().length > 0;
|
|
3493
|
-
if (!waiting ||
|
|
3499
|
+
if (!waiting || view === 'fields') gated = false;
|
|
3494
3500
|
// Steps undone elsewhere (or saved away) aren't any answer's any more.
|
|
3495
3501
|
for (const answer of answers)if (answer.step !== null && answer.step > (state.undoSteps ?? 0)) answer.step = null;
|
|
3496
3502
|
root.hidden = !available && !site;
|
|
@@ -3510,7 +3516,7 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3510
3516
|
html.style.setProperty('--obelism-dock', `${docked ? DOCK_WIDTH_PX : 0}px`);
|
|
3511
3517
|
const selecting = shown && outlines && !creating;
|
|
3512
3518
|
if (state.selecting !== selecting) bridge.setSelecting(selecting);
|
|
3513
|
-
const showForm = shown &&
|
|
3519
|
+
const showForm = shown && view === 'fields';
|
|
3514
3520
|
if (showForm && !formSlot.mounted) formSlot.mount();
|
|
3515
3521
|
else if (!showForm && formSlot.mounted) formSlot.unmount();
|
|
3516
3522
|
if (picking && !shown) picking = false;
|
|
@@ -3526,27 +3532,28 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3526
3532
|
env.hidden = !environment;
|
|
3527
3533
|
env.dataset.env = environment ?? '';
|
|
3528
3534
|
envText.textContent = environment === 'production' ? labels.envProduction : environment ?? '';
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
askTab.disabled = fieldsTab.disabled = busy;
|
|
3533
|
-
askTab.tabIndex = mode === 'ask' ? 0 : -1;
|
|
3534
|
-
fieldsTab.tabIndex = mode === 'fields' ? 0 : -1;
|
|
3535
|
+
askMode.hidden = !hasForm;
|
|
3536
|
+
askMode.setAttribute('aria-pressed', String(view === 'ask'));
|
|
3537
|
+
askMode.disabled = busy;
|
|
3535
3538
|
gate.hidden = !gated;
|
|
3536
3539
|
gateKeep.disabled = gateUndo.disabled = busy;
|
|
3537
|
-
ask.hidden =
|
|
3538
|
-
fields.hidden =
|
|
3540
|
+
ask.hidden = view !== 'ask';
|
|
3541
|
+
fields.hidden = view !== 'fields';
|
|
3539
3542
|
const offerShop = shopHere !== null && !creating;
|
|
3540
3543
|
if (creating) {
|
|
3541
3544
|
noteText.textContent = labels.newPage;
|
|
3542
3545
|
} else if (state.selectedUid) {
|
|
3543
3546
|
const [beforeName, afterName = ''] = labels.scopeNoteBlock.split('{name}');
|
|
3544
|
-
|
|
3547
|
+
for (const text of [
|
|
3548
|
+
noteText,
|
|
3549
|
+
fieldsNoteText
|
|
3550
|
+
])text.replaceChildren(beforeName ?? '', element(doc, 'strong', {
|
|
3545
3551
|
textContent: nameOf(state.selectedUid)
|
|
3546
3552
|
}), afterName);
|
|
3547
3553
|
} else {
|
|
3548
3554
|
noteText.textContent = labels.scopeNotePage;
|
|
3549
3555
|
}
|
|
3556
|
+
fieldsNote.hidden = creating || !state.selectedUid;
|
|
3550
3557
|
note.hidden = offerShop || pageless && !creating && !options.promptWithoutPage;
|
|
3551
3558
|
wholePage.hidden = creating || !state.selectedUid;
|
|
3552
3559
|
cancelNew.hidden = !creating || onlyNew;
|
|
@@ -3626,7 +3633,9 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3626
3633
|
if (!open) picking = false;
|
|
3627
3634
|
refresh();
|
|
3628
3635
|
if (open) {
|
|
3629
|
-
(
|
|
3636
|
+
if (creating) pathInput.focus();
|
|
3637
|
+
else if (view === 'fields') focusForm();
|
|
3638
|
+
else input.focus();
|
|
3630
3639
|
} else {
|
|
3631
3640
|
launch.focus();
|
|
3632
3641
|
}
|
|
@@ -3780,35 +3789,25 @@ const mountSiteEditor = (doc, bridge, options = {})=>{
|
|
|
3780
3789
|
bridge.select(null);
|
|
3781
3790
|
input.focus();
|
|
3782
3791
|
});
|
|
3792
|
+
wholePageFields.addEventListener('click', ()=>{
|
|
3793
|
+
bridge.select(null);
|
|
3794
|
+
focusForm();
|
|
3795
|
+
});
|
|
3783
3796
|
shopButton.addEventListener('click', async ()=>{
|
|
3784
3797
|
shopMessage = null;
|
|
3785
3798
|
shopMessage = await addShopPage(bridge, labels);
|
|
3786
3799
|
refresh();
|
|
3787
3800
|
});
|
|
3788
|
-
|
|
3789
|
-
fieldsTab.addEventListener('click', ()=>setMode('fields'));
|
|
3790
|
-
// Arrows move focus between the tabs; Enter or Space (a click) opens one.
|
|
3791
|
-
tabs.addEventListener('keydown', (event)=>{
|
|
3792
|
-
if (![
|
|
3793
|
-
'ArrowLeft',
|
|
3794
|
-
'ArrowRight',
|
|
3795
|
-
'Home',
|
|
3796
|
-
'End'
|
|
3797
|
-
].includes(event.key)) return;
|
|
3798
|
-
event.preventDefault();
|
|
3799
|
-
const onAsk = shadow.activeElement === askTab;
|
|
3800
|
-
const target = event.key === 'Home' ? askTab : event.key === 'End' ? fieldsTab : onAsk ? fieldsTab : askTab;
|
|
3801
|
-
target.focus();
|
|
3802
|
-
});
|
|
3801
|
+
askMode.addEventListener('click', ()=>setMode(mode === 'ask' ? 'fields' : 'ask'));
|
|
3803
3802
|
gateKeep.addEventListener('click', ()=>{
|
|
3804
3803
|
keepAll(false);
|
|
3805
3804
|
setMode('fields');
|
|
3806
|
-
|
|
3805
|
+
focusForm();
|
|
3807
3806
|
});
|
|
3808
3807
|
gateUndo.addEventListener('click', ()=>{
|
|
3809
3808
|
for(let answer = decidable(); answer; answer = decidable())undoAnswer(answer, false);
|
|
3810
3809
|
setMode('fields');
|
|
3811
|
-
|
|
3810
|
+
focusForm();
|
|
3812
3811
|
});
|
|
3813
3812
|
undo.addEventListener('click', ()=>{
|
|
3814
3813
|
const step = bridge.getState().undoSteps;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obelism/content",
|
|
3
3
|
"description": "Obelism Content SDK: the delivery API client, the visual editor bridge with prompt editing, editing on your own site, webhook verification, and the content model CLI",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
7
7
|
"headless-cms",
|