-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 1.12 KB
/
index.js
1
(function(){"use strict";const o="volkmann-design-code/kirby-layout-attributes";window[o]=window[o]??{},window[o].functions=window[o].functions??{},window[o].functions.isLayoutField=n=>Array.isArray(n)&&n.length>0&&n.every(t=>typeof t=="object"&&t!==null&&"attrs"in t&&"columns"in t&&"id"in t&&typeof t.attrs=="object"&&Array.isArray(t.columns)),window[o].functions.addLayoutAttrs=n=>{const t=n.columns[0].id;let e=document.querySelector(`.k-layout:has(.k-layout-column[id="${t}"])`);if(!e)return;const a=Object.keys(n.attrs);for(const s of a){const i=n.attrs[s];e.setAttribute(`data-attr-${s}`,i),e.style.setProperty(`--attr-${s}`,i)}},window.panel.plugin("volkmann-design-code/kirby-layout-attributes",{created(n){n.$store.subscribeAction({after:(t,e)=>{var a;if(t.type==="content/create"&&setTimeout(()=>{for(const s in t.payload.content){const i=t.payload.content[s];if(window[o].functions.isLayoutField(i))for(const u of i)window[o].functions.addLayoutAttrs(u)}},100),t.type==="content/update"){const s=(a=t.payload)==null?void 0:a[1];if(window[o].functions.isLayoutField(s))for(const i of s)window[o].functions.addLayoutAttrs(i)}}})}})})();