@perkyzz/emvb 1.1.0 → 1.3.0
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/THIRD_PARTY_NOTICES.md +3 -2
- package/package.json +11 -10
- package/src/admin/agents-api.ts +5 -1
- package/src/admin/content-api.ts +29 -0
- package/src/admin/editor/Editor.tsx +6 -1
- package/src/admin/editor/ScheduleDialog.tsx +167 -0
- package/src/admin/editor/TopBar.tsx +33 -1
- package/src/admin/editor/canvas/vnode-react.tsx +3 -0
- package/src/admin/editor/dnd/new-element.ts +106 -0
- package/src/admin/editor/editor-chrome.tsx +9 -0
- package/src/admin/editor/element-chrome.ts +50 -0
- package/src/admin/editor/panels/ElementPanel.tsx +5 -1
- package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
- package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
- package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
- package/src/admin/editor/panels/settings/ItemList.tsx +69 -2
- package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
- package/src/admin/editor/store.ts +7 -1
- package/src/admin/editor/useEditorData.ts +4 -0
- package/src/admin/editor/useSave.ts +47 -3
- package/src/admin/export-api.ts +20 -3
- package/src/admin/menus-api.ts +113 -0
- package/src/admin/pages/ImportElementorDialog.tsx +25 -1
- package/src/astro/EmVBPage.astro +3 -0
- package/src/astro/render.ts +43 -18
- package/src/astro/request-data.ts +9 -0
- package/src/astro/resolve-theme.ts +77 -44
- package/src/astro/resolve.ts +9 -0
- package/src/astro/visitor.ts +23 -4
- package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCountdownRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCounterRuntime.astro +8 -0
- package/src/astro/widgets/EmVBHeadlineRuntime.astro +9 -0
- package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
- package/src/astro/widgets/EmVBMapRuntime.astro +8 -0
- package/src/astro/widgets/EmVBShareRuntime.astro +9 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +29 -0
- package/src/astro/widgets/alerts.ts +37 -0
- package/src/astro/widgets/carousel.ts +167 -0
- package/src/astro/widgets/countdown.ts +80 -0
- package/src/astro/widgets/counter.ts +98 -0
- package/src/astro/widgets/headline.ts +90 -0
- package/src/astro/widgets/index.ts +1 -0
- package/src/astro/widgets/lightbox.ts +123 -0
- package/src/astro/widgets/map.ts +37 -0
- package/src/astro/widgets/share.ts +21 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +127 -5
- package/src/core/arrange.ts +109 -1
- package/src/core/bounded-array.ts +16 -13
- package/src/core/canvas-collections.ts +28 -0
- package/src/core/contract.ts +4 -1
- package/src/core/elements/counter-format.ts +15 -0
- package/src/core/elements/icon-svg.ts +135 -0
- package/src/core/elements/index.ts +63 -127
- package/src/core/elements/marketing.ts +1490 -0
- package/src/core/elements/widgets.ts +932 -0
- package/src/core/export/runtimes.generated.ts +8 -0
- package/src/core/export/site.ts +25 -3
- package/src/core/extensions/schema.ts +2 -1
- package/src/core/geo-trust.ts +18 -0
- package/src/core/icons/social.generated.ts +29 -0
- package/src/core/image-edit/schema.ts +2 -1
- package/src/core/import/elementor/context.ts +18 -0
- package/src/core/import/elementor/index.ts +50 -7
- package/src/core/import/elementor/widgets.ts +783 -385
- package/src/core/issue-cap.ts +19 -0
- package/src/core/limits.ts +12 -0
- package/src/core/loop-collections.ts +33 -0
- package/src/core/proposals.ts +8 -2
- package/src/core/render/index.ts +48 -5
- package/src/core/render/vnode.ts +44 -6
- package/src/core/sanitize/svg-upload.ts +276 -23
- package/src/core/sanitize/svg.ts +3 -3
- package/src/core/schema/descriptors.ts +4 -0
- package/src/core/schema/design.ts +6 -5
- package/src/core/schema/layout.ts +798 -15
- package/src/core/schema/style.ts +2 -1
- package/src/core/shadowing-ids.ts +41 -0
- package/src/core/theme/conditions.ts +2 -1
- package/src/core/theme/dynamic.ts +2 -0
- package/src/core/theme/parse-doc.ts +10 -5
- package/src/core/theme/triggers.ts +3 -2
- package/src/core/validate.ts +3 -2
- package/src/index.ts +23 -2
- package/src/mcp/ports.ts +18 -7
- package/src/mcp/proposals.ts +36 -11
- package/src/mcp/tools.ts +1 -1
- package/src/server/agent-settings.ts +12 -1
- package/src/server/hooks.ts +41 -6
- package/src/server/mcp-routes.ts +11 -5
- package/src/server/plugin.ts +29 -3
- package/src/server/presence.ts +5 -1
- package/src/server/proposals.ts +16 -4
- package/src/server/requests.ts +60 -11
- package/src/server/site-origin.ts +13 -0
- package/src/server/targets.ts +26 -0
|
@@ -6,4 +6,12 @@ export const EXPORT_RUNTIMES = {
|
|
|
6
6
|
tabs: "(()=>{function d(e){let t=(r)=>[...e.querySelectorAll(`:scope > ${r}`)];return{inputs:t(\".emvb-tab-input\"),labels:t(\".emvb-tab-list > .emvb-tab-label\"),panels:t(\".emvb-tab-panels > .emvb-tab-panel\")}}var v={ArrowRight:(e)=>e+1,ArrowLeft:(e)=>e-1,Home:()=>0,End:(e,t)=>t-1},p=(e)=>e.querySelector(\":scope > [role='tab']\")??e;function o(e,t,r=!1){if(e.dataset.emvbTabsActivating===\"1\")return;e.dataset.emvbTabsActivating=\"1\";try{let{inputs:l,labels:i,panels:n}=d(e);if(l.length===0||i.length===0)return;let a=(t%l.length+l.length)%l.length,s=l[a];if(!s)return;if(!s.checked)s.checked=!0;for(let[E,g]of i.entries()){let f=E===a,T=p(g);T.setAttribute(\"aria-selected\",String(f)),T.tabIndex=f?0:-1,n[E]?.setAttribute(\"aria-hidden\",String(!f))}let c=r?i[a]:void 0,b=c?p(c):void 0;if(b&&document.activeElement!==b)try{b.focus({preventScroll:!0})}catch{}}finally{delete e.dataset.emvbTabsActivating}}function u(e){let t=d(e).inputs.findIndex((r)=>r.checked);return t>=0?t:0}function H(e,t,r){let l=e.id||\"emvb-tabs\";for(let[i,n]of t.entries()){let a=p(n),s=r[i],c=s?.id||`${l}-panel-${i}`;if(s&&!s.id)s.id=c;if(a.setAttribute(\"aria-controls\",c),s){if(!a.id)a.id=`${l}-tab-${i}`;s.setAttribute(\"aria-labelledby\",a.id)}}}function y(e){if(e.dataset.emvbTabsReady===\"1\")return;e.dataset.emvbTabsReady=\"1\";let t=e.querySelector(\":scope > .emvb-tab-list\");if(!t)return;t.setAttribute(\"aria-orientation\",\"horizontal\");let{inputs:r,labels:l,panels:i}=d(e);for(let n of r)n.tabIndex=-1,n.setAttribute(\"aria-hidden\",\"true\");H(e,l,i),o(e,u(e)),t.addEventListener(\"keydown\",(n)=>{if(n.altKey||n.ctrlKey||n.metaKey||n.defaultPrevented)return;let a=t.closest(\"[dir]\")?.getAttribute(\"dir\")?.toLowerCase()===\"rtl\",s=a&&n.key===\"ArrowRight\"?\"ArrowLeft\":a&&n.key===\"ArrowLeft\"?\"ArrowRight\":n.key,c=v[s];if(!c)return;if(n.preventDefault(),l.length===0)return;o(e,c(u(e),l.length),!0)}),t.addEventListener(\"click\",(n)=>{let a=n.target?.closest?.(\".emvb-tab-label\"),s=a?l.indexOf(a):-1;if(s<0||n.defaultPrevented)return;n.preventDefault(),o(e,s,!0)}),e.addEventListener(\"change\",(n)=>{let a=n.target;if(!a||!a.classList.contains(\"emvb-tab-input\"))return;o(e,u(e))})}function A(e){let t=[],r=e.closest(\".emvb-tab-panel\");while(r){let i=r.parentElement?.parentElement;if(i?.classList.contains(\"emvb-tabs\")){let n=d(i).panels.indexOf(r);if(n>=0)t.unshift({root:i,index:n})}r=i?.parentElement?.closest(\".emvb-tab-panel\")??null}let l=!1;for(let{root:i,index:n}of t){if(u(i)===n)continue;o(i,n),l=!0}return l}function M(e){if(!e||e===\"#\")return null;try{return document.getElementById(decodeURIComponent(e.slice(1)))}catch{return null}}function m(e){let t=M(e);if(!t||!A(t))return;t.scrollIntoView?.({block:\"start\"})}var h=!1;function L(e=document){let t=e.querySelectorAll(\".emvb-tabs\");for(let r of t)y(r);if(h||typeof window>\"u\")return;h=!0,document.addEventListener(\"click\",(r)=>{let l=r.target?.closest?.('a[href^=\"#\"]');if(l)m(l.getAttribute(\"href\")??\"\")}),window.addEventListener(\"hashchange\",()=>m(window.location.hash)),m(window.location.hash)}L();})();",
|
|
7
7
|
menu: "(()=>{var l=null;function r(e){let t=[],n=e?.closest(\".emvb-menu .emvb-menu-item\")??null;while(n)t.push(n),n=n.parentElement?.closest(\".emvb-menu .emvb-menu-item\")??null;return t}function m(e){for(let t of document.querySelectorAll(\"[data-emvb-menu-dismissed]\")){if(e&&t.contains(e))continue;delete t.dataset.emvbMenuDismissed}}function d(e){if(e.key!==\"Escape\"||e.defaultPrevented)return;let t=document.activeElement,o=(t instanceof Element?t.closest(\"details.emvb-menu-item__disclosure[open]\"):null)??document.querySelector(\".emvb-menu details.emvb-menu-item__disclosure[open]\"),s=r(l);for(let c of s)c.dataset.emvbMenuDismissed=\"1\";if(!o){if(s.length>0)e.preventDefault();return}o.open=!1,o.querySelector(\":scope > summary\")?.focus({preventScroll:!0}),e.preventDefault()}function i(e){let t=e.target instanceof Node?e.target:null;m(t);for(let n of document.querySelectorAll(\".emvb-menu details.emvb-menu-item__disclosure[open]\")){let o=n.closest(\".emvb-menu-item\")??n;if(t&&o.contains(t))continue;n.open=!1}}function u(e=document){let t=e.documentElement;if(t.dataset.emvbMenuReady===\"1\")return;t.dataset.emvbMenuReady=\"1\",e.addEventListener(\"keydown\",d),e.addEventListener(\"focusin\",i),e.addEventListener(\"pointerdown\",i),e.addEventListener(\"pointerover\",(n)=>{l=n.target instanceof Element?n.target:null,m(l)})}u();})();",
|
|
8
8
|
floats: "(()=>{function d(t){try{return sessionStorage.getItem(\"emvb-float-closed:\"+t)===\"1\"}catch{return!1}}function c(t){try{sessionStorage.setItem(\"emvb-float-closed:\"+t,\"1\")}catch{}}function a(){return[...document.querySelectorAll(\"[data-emvb-float]\")]}function s(){let t=0,e=0;for(let n of a()){if(n.hidden)continue;let i=n.getAttribute(\"data-emvb-float-edge\");if(i===\"top\")n.style.top=`${t}px`,t+=n.getBoundingClientRect().height;else if(i===\"bottom\")n.style.bottom=`${e}px`,e+=n.getBoundingClientRect().height}let o=document.documentElement;o.style.setProperty(\"--emvb-float-top\",`${t}px`),o.style.setProperty(\"--emvb-float-bottom\",`${e}px`)}var l='a[href],button:not([disabled]),input:not([disabled]):not([type=\"hidden\"]),select:not([disabled]),textarea:not([disabled]),summary,[tabindex]:not([tabindex=\"-1\"])';function f(t){if(!t.contains(document.activeElement))return;let e=[...document.querySelectorAll(l)].filter((i)=>!t.contains(i)&&!i.closest(\"[hidden],[inert]\"));(e.find((i)=>(t.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING)!==0)??e.at(-1))?.focus()}function m(t){let e=t.getAttribute(\"data-emvb-float\");if(f(t),t.hidden=!0,e)c(e);s()}function r(){let t=document.documentElement;if(t.dataset.emvbFloatsReady===\"1\")return;t.dataset.emvbFloatsReady=\"1\";for(let e of a()){let o=e.getAttribute(\"data-emvb-float\");if(o&&d(o))e.hidden=!0}if(s(),document.addEventListener(\"click\",(e)=>{let o=e.target;if(!(o instanceof Element))return;let n=o.closest(\"[data-emvb-float-dismiss]\");if(!n)return;let i=n.closest(\"[data-emvb-float]\");if(!i)return;e.preventDefault(),m(i)}),window.addEventListener(\"resize\",s),typeof ResizeObserver===\"function\"){let e=new ResizeObserver(()=>s());for(let o of a())e.observe(o)}}r();})();",
|
|
9
|
+
alerts: "(()=>{function d(n){let t=[...n.ownerDocument.querySelectorAll(\"a[href], button:not([disabled]), input:not([disabled]):not([type=hidden]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1']), summary, iframe\")].filter((e)=>!n.contains(e)&&!e.closest(\"[hidden]\"));return t.find((e)=>n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)??t.findLast((e)=>n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)??null}function i(n=document){for(let t of n.querySelectorAll(\"[data-emvb-alert-dismiss]\")){if(t.dataset.emvbReady!==void 0)continue;t.dataset.emvbReady=\"\",t.addEventListener(\"click\",()=>{let o=t.closest(\".emvb-alert\");if(!o)return;let e=d(o);o.hidden=!0,e?.focus()})}}i();})();",
|
|
10
|
+
lightbox: "(()=>{var a,l,f=(e)=>e.closest(\"figure\")?.querySelector(\"figcaption\")?.textContent?.trim()??\"\";function v(e,t,n){return e.alt.trim()||f(e)||`Picture ${t+1} of ${n}`}function m(e,t){let n=document.createElement(\"button\");return n.type=\"button\",n.setAttribute(\"aria-label\",e),n.textContent=t,n}function L(e){let t=e.createElement(\"dialog\");t.className=\"emvb-lightbox\",t.setAttribute(\"aria-label\",\"Picture viewer\");let n=e.createElement(\"figure\");n.className=\"emvb-lightbox-figure\";let i=e.createElement(\"img\"),o=e.createElement(\"div\");o.className=\"emvb-lightbox-bar\";let r=m(\"Previous picture\",\"‹\"),u=m(\"Next picture\",\"›\"),g=m(\"Close\",\"×\"),c=e.createElement(\"figcaption\");c.className=\"emvb-lightbox-caption\";let d=e.createElement(\"span\");return d.setAttribute(\"aria-live\",\"polite\"),c.append(d),o.append(r,c,u,g),n.append(i,o),t.append(n),e.body.append(t),r.addEventListener(\"click\",()=>s(-1)),u.addEventListener(\"click\",()=>s(1)),g.addEventListener(\"click\",()=>t.close()),t.addEventListener(\"keydown\",(p)=>{if(p.key===\"ArrowLeft\")s(document.dir===\"rtl\"?1:-1);else if(p.key===\"ArrowRight\")s(document.dir===\"rtl\"?-1:1)}),t.addEventListener(\"close\",()=>{l?.opener.focus(),l=void 0}),{dialog:t,image:i,caption:c,count:d,prev:r,next:u}}function b(){if(!a||!l)return;let{images:e,index:t}=l,n=e[t];if(!n)return;a.image.src=n.currentSrc||n.src,a.image.alt=n.alt;let i=f(n);a.count.textContent=`${i?`${i} · `:\"\"}${t+1} of ${e.length}`;let o=e.length<2;a.prev.hidden=o,a.next.hidden=o}function s(e){if(!l)return;let t=l.images.length;l.index=(l.index+e+t)%t,b()}function h(e,t,n){if(a??=L(n.ownerDocument),l={images:e,index:t,opener:n},b(),!a.dialog.open)a.dialog.showModal()}function E(e=document){for(let t of e.querySelectorAll(\"[data-emvb-lightbox]\")){if(t.dataset.emvbLightboxReady!==void 0)continue;t.dataset.emvbLightboxReady=\"\";let n=[...t.querySelectorAll(\":scope > .emvb-gallery-image > figure > img\")];n.forEach((i,o)=>{let r=m(`View larger: ${v(i,o,n.length)}`,\"\");r.className=\"emvb-gallery-open\",i.replaceWith(r),r.append(i),r.addEventListener(\"click\",()=>h(n,o,r))})}}E();})();",
|
|
11
|
+
carousel: "(()=>{function d(e,n,t=\"\"){let o=document.createElement(\"button\");if(o.type=\"button\",o.setAttribute(\"aria-label\",e),o.textContent=n,t)o.className=t;return o}function v(e){let n=e.slides[0];if(!n||n.offsetWidth===0)return 1;return Math.max(1,Math.round(e.track.clientWidth/n.offsetWidth))}var m=(e)=>Math.max(0,e.slides.length-v(e));function f(e){let n=m(e);if(e.prev)e.prev.disabled=!e.loop&&e.index<=0;if(e.next)e.next.disabled=!e.loop&&e.index>=n;e.dots.forEach((t,o)=>{if(o===e.index)t.setAttribute(\"aria-current\",\"true\");else t.removeAttribute(\"aria-current\")})}function u(e,n,t=e.loop){let o=m(e);e.index=t?n>o?0:n<0?o:n:Math.min(Math.max(n,0),o);let a=e.slides[e.index],l=e.slides[0];if(a&&l)e.track.scrollTo({left:a.offsetLeft-l.offsetLeft});f(e)}var c=(e)=>e.filter((n)=>n!==void 0);function b(e){let n=e.querySelector(\":scope > .emvb-carousel-track\");if(!n)return;let t={root:e,track:n,slides:[...n.children].filter((r)=>r instanceof HTMLElement),loop:e.hasAttribute(\"data-emvb-loop\"),index:0,dots:[],stopped:!1,held:!1};if(t.slides.length<2)return;let o=document.createElement(\"div\");if(o.className=\"emvb-carousel-controls\",e.hasAttribute(\"data-emvb-arrows\"))t.prev=d(\"Previous slide\",\"‹\"),t.next=d(\"Next slide\",\"›\"),t.prev.addEventListener(\"click\",()=>u(t,t.index-1)),t.next.addEventListener(\"click\",()=>u(t,t.index+1));if(e.hasAttribute(\"data-emvb-dots\")){let r=document.createElement(\"div\");r.className=\"emvb-carousel-dots\";for(let s=0;s<=m(t);s++){let i=d(`Go to slide ${s+1}`,\"\");i.addEventListener(\"click\",()=>u(t,s,!1)),t.dots.push(i),r.append(i)}o.append(...c([t.prev,r,t.next]))}else o.append(...c([t.prev,t.next]));if(o.childElementCount>0)n.after(o);let a=Number(e.dataset.emvbAutoplay);if(Number.isFinite(a)&&a>0)E(t,a);let l=0;n.addEventListener(\"scroll\",()=>{cancelAnimationFrame(l),l=requestAnimationFrame(()=>{let s=t.slides[0]?.offsetWidth??0;if(s<=0)return;t.index=Math.min(Math.round(n.scrollLeft/s),m(t)),f(t)})}),f(t)}function E(e,n){let t=globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches===!0;e.stopped=t;let o=d(\"\",\"\",\"emvb-carousel-play\"),a=()=>{o.textContent=e.stopped?\"Play\":\"Pause\",o.setAttribute(\"aria-label\",e.stopped?\"Play slides\":\"Pause slides\")},l=()=>{if(!e.stopped&&!e.held)u(e,e.index+1,!0)};o.addEventListener(\"click\",()=>{e.stopped=!e.stopped,a()}),a();let r=document.createElement(\"div\");r.className=\"emvb-carousel-controls emvb-carousel-autoplay\",r.append(o),e.track.before(r);let s=(i)=>()=>{e.held=i};e.root.addEventListener(\"pointerenter\",s(!0)),e.root.addEventListener(\"pointerleave\",s(!1)),e.root.addEventListener(\"focusin\",s(!0)),e.root.addEventListener(\"focusout\",(i)=>{if(!e.root.contains(i.relatedTarget))e.held=!1}),e.timer=setInterval(l,n*1000)}function p(e=document){for(let n of e.querySelectorAll(\"section.emvb-carousel\")){if(n.dataset.emvbCarouselReady!==void 0)continue;n.dataset.emvbCarouselReady=\"\",b(n)}}p();})();",
|
|
12
|
+
counter: "(()=>{function a(e,r=0,o=\"\"){let i=Math.abs(e).toFixed(r),[n=\"0\",t]=i.split(\".\"),s=o?n.replace(/\\B(?=(\\d{3})+(?!\\d))/g,o):n,m=o===\".\"?\",\":\".\";return`${e<0&&Number(i)!==0?\"-\":\"\"}${s}${t===void 0?\"\":`${m}${t}`}`}var d=(e)=>1-(1-e)**3;function f(e){let r=(i,n)=>{let t=Number(e.dataset[i]??n);return Number.isFinite(t)?t:n},o=Number(e.dataset.to);if(!Number.isFinite(o))return;return{el:e,from:r(\"from\",0),to:o,decimals:Math.min(3,Math.max(0,Math.round(r(\"decimals\",0)))),separator:e.dataset.separator??\"\",duration:Math.min(5000,Math.max(0,r(\"duration\",2000))),final:e.textContent??\"\"}}function c(e){e.el.setAttribute(\"aria-hidden\",\"true\");let r=e.el.ownerDocument.createElement(\"span\");r.className=\"emvb-counter-sr\",r.textContent=e.final,e.el.after(r),e.el.textContent=a(e.from,e.decimals,e.separator)}function l(e){e.el.textContent=e.final,e.el.removeAttribute(\"aria-hidden\");let r=e.el.nextElementSibling;if(r?.classList.contains(\"emvb-counter-sr\"))r.remove()}function b(e){let r=performance.now(),o=(i)=>{let n=e.duration>0?Math.min(1,(i-r)/e.duration):1;if(n>=1){l(e);return}let t=e.from+(e.to-e.from)*d(n);e.el.textContent=a(t,e.decimals,e.separator),requestAnimationFrame(o)};requestAnimationFrame(o)}function u(e=document){if(globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches===!0||typeof IntersectionObserver>\"u\")return;let o=new Map;for(let n of e.querySelectorAll(\"[data-emvb-counter]\")){if(n.dataset.emvbReady!==void 0)continue;n.dataset.emvbReady=\"\";let t=f(n);if(!t||t.from===t.to)continue;c(t),o.set(n,t)}if(o.size===0)return;let i=new IntersectionObserver((n)=>{for(let t of n){let s=o.get(t.target);if(!t.isIntersecting||!s)continue;i.unobserve(t.target),o.delete(t.target),b(s)}},{threshold:0.5});for(let n of o.keys())i.observe(n)}u();})();",
|
|
13
|
+
countdown: "(()=>{var b=(e)=>String(e).padStart(2,\"0\");function c(e,o){let t=Math.max(0,Math.floor((e-o)/1000));return{total:t,days:Math.floor(t/86400),hours:Math.floor(t%86400/3600),minutes:Math.floor(t%3600/60),seconds:t%60}}function h(e,o){let t=new Map;for(let n of e.querySelectorAll(\".emvb-countdown-num[data-unit]\"))t.set(n.dataset.unit??\"\",n);let d=e.querySelector(\".emvb-countdown-pause\"),s,f=()=>{if(s!==void 0)clearInterval(s);if(s=void 0,e.dataset.expired===\"hide\"){e.hidden=!0;return}let n=e.querySelector(\".emvb-countdown-clock\");if(n)n.hidden=!0;e.querySelector(\".emvb-countdown-expired\")?.setAttribute(\"data-emvb-shown\",\"\")},r=()=>{let n=c(o,Date.now()),m=t.has(\"seconds\")?n:c(o+59000,Date.now());for(let i of[\"days\",\"hours\",\"minutes\",\"seconds\"]){let u=t.get(i);if(u)u.textContent=b(m[i])}if(n.total===0)f()},a=()=>{if(r(),e.hidden||e.querySelector(\".emvb-countdown-clock[hidden]\"))return;s=setInterval(r,1000)};d?.addEventListener(\"click\",()=>{let n=d.getAttribute(\"aria-pressed\")===\"true\";if(d.setAttribute(\"aria-pressed\",String(!n)),n)a();else if(s!==void 0)clearInterval(s),s=void 0}),a()}function l(e=document){for(let o of e.querySelectorAll(\"[data-emvb-countdown]\")){if(o.dataset.emvbReady!==void 0)continue;let t=Date.parse(o.dataset.target??\"\");if(Number.isNaN(t))continue;o.dataset.emvbReady=\"\",h(o,t)}}l();})();",
|
|
14
|
+
map: "(()=>{var r=/^https:\\/\\/www\\.(?:openstreetmap\\.org\\/export\\/embed\\.html|google\\.com\\/maps)\\?/;function s(t){let o=t.dataset.src??\"\";if(!r.test(o))return;let e=t.ownerDocument.createElement(\"iframe\");e.setAttribute(\"sandbox\",\"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox\"),e.src=o,e.title=t.dataset.title||\"Map\",e.height=t.dataset.height||\"360\",e.loading=\"lazy\",e.referrerPolicy=\"no-referrer-when-downgrade\",t.replaceChildren(e),e.focus()}function a(t=document){for(let o of t.querySelectorAll(\"[data-emvb-map]\")){if(o.dataset.emvbReady!==void 0)continue;let e=o.querySelector(\".emvb-map-frame\"),n=e?.querySelector(\".emvb-map-load\");if(!e||!n)continue;o.dataset.emvbReady=\"\",n.addEventListener(\"click\",()=>s(e))}}a();})();",
|
|
15
|
+
headline: "(()=>{function h(e){let t;try{t=JSON.parse(e.dataset.emvbRotate??\"\")}catch{return}if(!Array.isArray(t))return;let n=t.filter((r)=>typeof r===\"string\"&&r.trim()!==\"\");if(n.length<2)return;let o=Number(e.dataset.interval),s=Number(e.dataset.turns);return{words:n,interval:Number.isFinite(o)?Math.min(10,Math.max(1.5,o)):2.5,turns:Number.isFinite(s)?Math.min(5,Math.max(1,Math.round(s))):2}}function b(e,t){let n=e.ownerDocument,o=e.closest(\"h1, h2, h3, h4, h5, h6\")??e,s=[...e.childNodes].find((a)=>a.nodeType===Node.TEXT_NODE);if(!s)return;let r=s,d=n.createElement(\"span\");d.className=\"emvb-headline-sr\",d.textContent=t.words[0]??\"\",e.before(d),e.setAttribute(\"aria-hidden\",\"true\");let i=n.createElement(\"button\");i.type=\"button\",i.className=\"emvb-headline-pause\",i.setAttribute(\"aria-pressed\",\"false\"),i.textContent=\"Pause\",o.after(i);let u=0,f=t.words.length*t.turns,m=setInterval(()=>{if(u++,r.textContent=t.words[u%t.words.length]??\"\",u>=f)c()},t.interval*1000);function c(){clearInterval(m),r.textContent=t.words[0]??\"\",e.removeAttribute(\"aria-hidden\"),d.remove(),i.remove()}i.addEventListener(\"click\",()=>{let a=i.nextElementSibling;if(c(),a instanceof HTMLElement&&a.matches(\"a[href], button, input, select, textarea, [tabindex]\"))a.focus();else if(o instanceof HTMLElement)o.tabIndex=-1,o.focus()})}function l(e=document){if(globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches===!0)return;for(let n of e.querySelectorAll(\"[data-emvb-rotate]\")){if(n.dataset.emvbReady!==void 0)continue;n.dataset.emvbReady=\"\";let o=h(n);if(o)b(n,o)}}l();})();",
|
|
16
|
+
share: "(()=>{function o(a=document){let e=globalThis.navigator;if(typeof e?.share!==\"function\")return;for(let t of a.querySelectorAll(\"[data-emvb-share-list]\")){if(t.dataset.emvbReady!==void 0)continue;t.dataset.emvbReady=\"\",t.querySelector(\"[data-emvb-share]\")?.addEventListener(\"click\",()=>{let n=t.ownerDocument;e.share({title:n.title,url:n.location.href.split(\"#\")[0]}).catch(()=>{})})}}o();})();",
|
|
9
17
|
} as const;
|
package/src/core/export/site.ts
CHANGED
|
@@ -209,10 +209,21 @@ function snapshotNotes(layouts: Layout[]): string[] {
|
|
|
209
209
|
return notes;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
// S-06 (W-996): only attributes that load media; a link's href is a page the visitor may open,
|
|
213
|
+
// and copying it fetched any same-origin URL (admin API answers included) into the zip.
|
|
214
|
+
const ATTR_URL = /\s(?:src|poster)="([^"]+)"/g;
|
|
213
215
|
const SRCSET = /\ssrcset="([^"]+)"/g;
|
|
214
216
|
const CSS_URL = /url\(\s*(?:"([^"]+)"|'([^']+)'|([^)'"\s]+))\s*\)/g;
|
|
215
|
-
const MEDIA_EXT = /\.(?:avif|webp|png|jpe?g|gif|svg|ico|mp4|webm|ogg|mp3|pdf|woff2?)
|
|
217
|
+
const MEDIA_EXT = /\.(?:avif|webp|png|jpe?g|gif|svg|ico|mp4|webm|ogg|mp3|pdf|woff2?)$/i;
|
|
218
|
+
|
|
219
|
+
/** S-06: the URL's path alone, so `?x=.png` can't make an API URL look like a media file. */
|
|
220
|
+
function pathOf(url: string): string {
|
|
221
|
+
try {
|
|
222
|
+
return new URL(url, "https://export.invalid/").pathname;
|
|
223
|
+
} catch {
|
|
224
|
+
return "";
|
|
225
|
+
}
|
|
226
|
+
}
|
|
216
227
|
|
|
217
228
|
const unescapeAttr = (value: string) =>
|
|
218
229
|
value
|
|
@@ -229,7 +240,8 @@ export function mediaUrls(html: string, css: string): string[] {
|
|
|
229
240
|
const url = raw?.trim();
|
|
230
241
|
if (!url || url.startsWith("#") || url.startsWith("data:")) return;
|
|
231
242
|
if (/^(?:mailto|tel|javascript):/i.test(url)) return;
|
|
232
|
-
const
|
|
243
|
+
const path = pathOf(url);
|
|
244
|
+
const isMediaPath = path.startsWith("/_emdash/api/media/") || MEDIA_EXT.test(path);
|
|
233
245
|
if (isMediaPath) found.add(url);
|
|
234
246
|
};
|
|
235
247
|
for (const m of html.matchAll(ATTR_URL)) add(unescapeAttr(m[1] ?? ""));
|
|
@@ -245,6 +257,14 @@ const RUNTIME_FILES = {
|
|
|
245
257
|
floats: "assets/emvb-floats.js",
|
|
246
258
|
tabs: "assets/emvb-tabs.js",
|
|
247
259
|
menu: "assets/emvb-menu.js",
|
|
260
|
+
alerts: "assets/emvb-alerts.js",
|
|
261
|
+
lightbox: "assets/emvb-lightbox.js",
|
|
262
|
+
carousel: "assets/emvb-carousel.js",
|
|
263
|
+
counter: "assets/emvb-counter.js",
|
|
264
|
+
countdown: "assets/emvb-countdown.js",
|
|
265
|
+
map: "assets/emvb-map.js",
|
|
266
|
+
headline: "assets/emvb-headline.js",
|
|
267
|
+
share: "assets/emvb-share.js",
|
|
248
268
|
} as const;
|
|
249
269
|
|
|
250
270
|
function documentHtml(opts: {
|
|
@@ -402,6 +422,8 @@ export function buildSiteExport(input: {
|
|
|
402
422
|
if (floatRenders.length > 0) used.push("floats");
|
|
403
423
|
if (all.some((r) => r.needsTabsRuntime)) used.push("tabs");
|
|
404
424
|
if (all.some((r) => r.needsMenuRuntime)) used.push("menu");
|
|
425
|
+
// W-1025: the widget runtimes a page asked for.
|
|
426
|
+
for (const name of new Set(all.flatMap((r) => r.runtimes))) used.push(name);
|
|
405
427
|
for (const name of used) runtimes.add(name);
|
|
406
428
|
|
|
407
429
|
files.push(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { boundedArray } from "../bounded-array.ts";
|
|
1
2
|
/**
|
|
2
3
|
* Compile an extension's declarative prop schema into Zod, with EmVB limits on top
|
|
3
4
|
* (W-927). Extensions never pass us a Zod instance — only ExtensionPropSchema.
|
|
@@ -55,7 +56,7 @@ function compileAt(schema: ExtensionPropSchema, depth: number): z.ZodType {
|
|
|
55
56
|
}
|
|
56
57
|
case "array": {
|
|
57
58
|
const maxItems = Math.min(schema.maxItems ?? EXT_MAX_ARRAY, EXT_MAX_ARRAY);
|
|
58
|
-
const a =
|
|
59
|
+
const a = boundedArray(compileAt(schema.items, depth + 1), maxItems);
|
|
59
60
|
return schema.default !== undefined ? a.default([...schema.default]) : a;
|
|
60
61
|
}
|
|
61
62
|
case "object": {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S-10 (W-999): whether country headers are the edge's or could be the visitor's own. Set from
|
|
3
|
+
* `emvb({ trustGeoHeaders })` when the plugin starts; read when a page with Visitors rules
|
|
4
|
+
* renders. Kept on globalThis because the plugin and the page renderer can load this module
|
|
5
|
+
* twice (EmDash's runtime and Astro's SSR graph).
|
|
6
|
+
*/
|
|
7
|
+
const KEY = Symbol.for("emvb.trustGeoHeaders");
|
|
8
|
+
|
|
9
|
+
type Holder = { [KEY]?: boolean };
|
|
10
|
+
|
|
11
|
+
/** `true` trusts every country header, `false` none; anything else means "detect the edge". */
|
|
12
|
+
export function setGeoTrust(value: unknown): void {
|
|
13
|
+
(globalThis as Holder)[KEY] = typeof value === "boolean" ? value : undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function geoTrust(): boolean | undefined {
|
|
17
|
+
return (globalThis as Holder)[KEY];
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Generated by scripts/build-social-icons.ts (W-1024). Do not edit; run the script.
|
|
2
|
+
// Font Awesome Free by Fonticons, Inc., CC BY 4.0 (THIRD_PARTY_NOTICES.md). Brand icons are
|
|
3
|
+
// trademarks of their owners.
|
|
4
|
+
|
|
5
|
+
/** Each Social icons preset's SVG: its viewBox and the shapes inside. */
|
|
6
|
+
export const SOCIAL_ICONS = {
|
|
7
|
+
facebook: { viewBox: "0 0 512 512", body: "<path d=\"M512 256C512 114.6 397.4 0 256 0S0 114.6 0 256C0 376 82.7 476.8 194.2 504.5l0-170.3-52.8 0 0-78.2 52.8 0 0-33.7c0-87.1 39.4-127.5 125-127.5 16.2 0 44.2 3.2 55.7 6.4l0 70.8c-6-.6-16.5-1-29.6-1-42 0-58.2 15.9-58.2 57.2l0 27.8 83.6 0-14.4 78.2-69.3 0 0 175.9C413.8 494.8 512 386.9 512 256z\"/>" },
|
|
8
|
+
instagram: { viewBox: "0 0 448 512", body: "<path d=\"M224.3 141a115 115 0 1 0 -.6 230 115 115 0 1 0 .6-230zm-.6 40.4a74.6 74.6 0 1 1 .6 149.2 74.6 74.6 0 1 1 -.6-149.2zm93.4-45.1a26.8 26.8 0 1 1 53.6 0 26.8 26.8 0 1 1 -53.6 0zm129.7 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM399 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z\"/>" },
|
|
9
|
+
x: { viewBox: "0 0 448 512", body: "<path d=\"M357.2 48L427.8 48 273.6 224.2 455 464 313 464 201.7 318.6 74.5 464 3.8 464 168.7 275.5-5.2 48 140.4 48 240.9 180.9 357.2 48zM332.4 421.8l39.1 0-252.4-333.8-42 0 255.3 333.8z\"/>" },
|
|
10
|
+
linkedin: { viewBox: "0 0 448 512", body: "<path d=\"M416 32L31.9 32C14.3 32 0 46.5 0 64.3L0 447.7C0 465.5 14.3 480 31.9 480L416 480c17.6 0 32-14.5 32-32.3l0-383.4C448 46.5 433.6 32 416 32zM135.4 416l-66.4 0 0-213.8 66.5 0 0 213.8-.1 0zM102.2 96a38.5 38.5 0 1 1 0 77 38.5 38.5 0 1 1 0-77zM384.3 416l-66.4 0 0-104c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9l0 105.8-66.4 0 0-213.8 63.7 0 0 29.2 .9 0c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9l0 117.2z\"/>" },
|
|
11
|
+
youtube: { viewBox: "0 0 576 512", body: "<path d=\"M549.7 124.1C543.5 100.4 524.9 81.8 501.4 75.5 458.9 64 288.1 64 288.1 64S117.3 64 74.7 75.5C51.2 81.8 32.7 100.4 26.4 124.1 15 167 15 256.4 15 256.4s0 89.4 11.4 132.3c6.3 23.6 24.8 41.5 48.3 47.8 42.6 11.5 213.4 11.5 213.4 11.5s170.8 0 213.4-11.5c23.5-6.3 42-24.2 48.3-47.8 11.4-42.9 11.4-132.3 11.4-132.3s0-89.4-11.4-132.3zM232.2 337.6l0-162.4 142.7 81.2-142.7 81.2z\"/>" },
|
|
12
|
+
tiktok: { viewBox: "0 0 448 512", body: "<path d=\"M448.5 209.9c-44 .1-87-13.6-122.8-39.2l0 178.7c0 33.1-10.1 65.4-29 92.6s-45.6 48-76.6 59.6-64.8 13.5-96.9 5.3-60.9-25.9-82.7-50.8-35.3-56-39-88.9 2.9-66.1 18.6-95.2 40-52.7 69.6-67.7 62.9-20.5 95.7-16l0 89.9c-15-4.7-31.1-4.6-46 .4s-27.9 14.6-37 27.3-14 28.1-13.9 43.9 5.2 31 14.5 43.7 22.4 22.1 37.4 26.9 31.1 4.8 46-.1 28-14.4 37.2-27.1 14.2-28.1 14.2-43.8l0-349.4 88 0c-.1 7.4 .6 14.9 1.9 22.2 3.1 16.3 9.4 31.9 18.7 45.7s21.3 25.6 35.2 34.6c19.9 13.1 43.2 20.1 67 20.1l0 87.4z\"/>" },
|
|
13
|
+
bluesky: { viewBox: "0 0 576 512", body: "<path d=\"M407.8 294.7c-3.3-.4-6.7-.8-10-1.3 3.4 .4 6.7 .9 10 1.3zM288 227.1C261.9 176.4 190.9 81.9 124.9 35.3 61.6-9.4 37.5-1.7 21.6 5.5 3.3 13.8 0 41.9 0 58.4S9.1 194 15 213.9c19.5 65.7 89.1 87.9 153.2 80.7 3.3-.5 6.6-.9 10-1.4-3.3 .5-6.6 1-10 1.4-93.9 14-177.3 48.2-67.9 169.9 120.3 124.6 164.8-26.7 187.7-103.4 22.9 76.7 49.2 222.5 185.6 103.4 102.4-103.4 28.1-156-65.8-169.9-3.3-.4-6.7-.8-10-1.3 3.4 .4 6.7 .9 10 1.3 64.1 7.1 133.6-15.1 153.2-80.7 5.9-19.9 15-138.9 15-155.5s-3.3-44.7-21.6-52.9c-15.8-7.1-40-14.9-103.2 29.8-66.1 46.6-137.1 141.1-163.2 191.8z\"/>" },
|
|
14
|
+
mastodon: { viewBox: "0 0 448 512", body: "<path d=\"M433 179.1c0-97.2-63.7-125.7-63.7-125.7-62.5-28.7-228.6-28.4-290.5 0 0 0-63.7 28.5-63.7 125.7 0 115.7-6.6 259.4 105.6 289.1 40.5 10.7 75.3 13 103.3 11.4 50.8-2.8 79.3-18.1 79.3-18.1l-1.7-36.9s-36.3 11.4-77.1 10.1c-40.4-1.4-83-4.4-89.6-54-.6-4.6-.9-9.3-.9-13.9 85.6 20.9 158.7 9.1 178.7 6.7 56.1-6.7 105-41.3 111.2-72.9 9.8-49.8 9-121.5 9-121.5zM357.9 304.3l-46.6 0 0-114.2c0-49.7-64-51.6-64 6.9l0 62.5-46.3 0 0-62.5c0-58.5-64-56.6-64-6.9l0 114.2-46.7 0c0-122.1-5.2-147.9 18.4-175 25.9-28.9 79.8-30.8 103.8 6.1l11.6 19.5 11.6-19.5c24.1-37.1 78.1-34.8 103.8-6.1 23.7 27.3 18.4 53 18.4 175l0 0z\"/>" },
|
|
15
|
+
threads: { viewBox: "0 0 448 512", body: "<path d=\"M340.8 238c-.6-69.6-38.3-111.5-102-111.5-42.5 0-78.3 19.2-97.1 49.9l41.2 28.7c10.7-16.8 25.4-30.8 52.4-30.8 30.5 0 46.3 17 50.8 48.5-14.7-2.3-29.5-3.5-44.6-3.5-82.4 0-121.1 37.3-121.1 86.6s38.8 79.7 95.9 79.7c62.7 0 100.1-42.2 115.4-94.5 15.9 7.2 26.9 24 26.9 49.3 0 67.6-78 104.5-144.1 104.5-97.5 0-161.3-64-161.3-168.2 0-127.6 84.3-209.4 197.6-209.4 76 0 113.6 33.4 139.2 78.1L432 115.9c-27.8-58-89.9-99.5-183.1-99.5-148.5 0-249.5 105.4-249.5 258.2 0 139.8 98.9 220.9 216.7 220.9 97.4 0 195.8-56.8 195.8-154 0-50.8-29.2-84.5-71.2-103.5zM214.4 334.9c-21.5 0-40.4-10.2-40.4-29 0-29.6 36.4-38.6 72-38.6 13.5 0 26.8 .9 38.5 3.5-8.4 38.5-33.4 64.2-70 64.2l0 0z\"/>" },
|
|
16
|
+
github: { viewBox: "0 0 512 512", body: "<path d=\"M216.5 362.5c-66-8-112.5-55.5-112.5-117 0-25 9-52 24-70-6.5-16.5-5.5-51.5 2-66 20-2.5 47 8 63 22.5 19-6 39-9 63.5-9s44.5 3 62.5 8.5c15.5-14 43-24.5 63-22 7 13.5 8 48.5 1.5 65.5 16 19 24.5 44.5 24.5 70.5 0 61.5-46.5 108-113.5 116.5 17 11 28.5 35 28.5 62.5l0 52C323 491.5 335.5 500 350.5 494 441 459.5 512 369 512 257 512 115.5 397 0 255.5 0S0 115.5 0 257c0 111 70.5 203 165.5 237.5 13.5 5 26.5-4 26.5-17.5l0-40c-7 3-16 5-24 5-33 0-52.5-18-66.5-51.5-5.5-13.5-11.5-21.5-23-23-6-.5-8-3-8-6 0-6 10-10.5 20-10.5 14.5 0 27 9 40 27.5 10 14.5 20.5 21 33 21s20.5-4.5 32-16c8.5-8.5 15-16 21-21z\"/>" },
|
|
17
|
+
pinterest: { viewBox: "0 0 512 512", body: "<path d=\"M504 256c0 137-111 248-248 248-25.6 0-50.2-3.9-73.4-11.1 10.1-16.5 25.2-43.5 30.8-65 3-11.6 15.4-59 15.4-59 8.1 15.4 31.7 28.5 56.8 28.5 74.8 0 128.7-68.8 128.7-154.3 0-81.9-66.9-143.2-152.9-143.2-107 0-163.9 71.8-163.9 150.1 0 36.4 19.4 81.7 50.3 96.1 4.7 2.2 7.2 1.2 8.3-3.3 .8-3.4 5-20.3 6.9-28.1 .6-2.5 .3-4.7-1.7-7.1-10.1-12.5-18.3-35.3-18.3-56.6 0-54.7 41.4-107.6 112-107.6 60.9 0 103.6 41.5 103.6 100.9 0 67.1-33.9 113.6-78 113.6-24.3 0-42.6-20.1-36.7-44.8 7-29.5 20.5-61.3 20.5-82.6 0-19-10.2-34.9-31.4-34.9-24.9 0-44.9 25.7-44.9 60.2 0 22 7.4 36.8 7.4 36.8s-24.5 103.8-29 123.2C161.5 437.2 163.5 467.4 165.6 487 73.4 450.9 8 361.1 8 256 8 119 119 8 256 8S504 119 504 256z\"/>" },
|
|
18
|
+
whatsapp: { viewBox: "0 0 448 512", body: "<path d=\"M380.9 97.1c-41.9-42-97.7-65.1-157-65.1-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480 117.7 449.1c32.4 17.7 68.9 27 106.1 27l.1 0c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3 18.6-68.1-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1s56.2 81.2 56.1 130.5c0 101.8-84.9 184.6-186.6 184.6zM325.1 300.5c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8s-14.3 18-17.6 21.8c-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7 .9-6.9-.5-9.7s-12.5-30.1-17.1-41.2c-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2s-9.7 1.4-14.8 6.9c-5.1 5.6-19.4 19-19.4 46.3s19.9 53.7 22.6 57.4c2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4s4.6-24.1 3.2-26.4c-1.3-2.5-5-3.9-10.5-6.6z\"/>" },
|
|
19
|
+
discord: { viewBox: "0 0 576 512", body: "<path d=\"M492.5 69.8c-.2-.3-.4-.6-.8-.7-38.1-17.5-78.4-30-119.7-37.1-.4-.1-.8 0-1.1 .1s-.6 .4-.8 .8c-5.5 9.9-10.5 20.2-14.9 30.6-44.6-6.8-89.9-6.8-134.4 0-4.5-10.5-9.5-20.7-15.1-30.6-.2-.3-.5-.6-.8-.8s-.7-.2-1.1-.2c-41.3 7.1-81.6 19.6-119.7 37.1-.3 .1-.6 .4-.8 .7-76.2 113.8-97.1 224.9-86.9 334.5 0 .3 .1 .5 .2 .8s.3 .4 .5 .6c44.4 32.9 94 58 146.8 74.2 .4 .1 .8 .1 1.1 0s.7-.4 .9-.7c11.3-15.4 21.4-31.8 30-48.8 .1-.2 .2-.5 .2-.8s0-.5-.1-.8-.2-.5-.4-.6-.4-.3-.7-.4c-15.8-6.1-31.2-13.4-45.9-21.9-.3-.2-.5-.4-.7-.6s-.3-.6-.3-.9 0-.6 .2-.9 .3-.5 .6-.7c3.1-2.3 6.2-4.7 9.1-7.1 .3-.2 .6-.4 .9-.4s.7 0 1 .1c96.2 43.9 200.4 43.9 295.5 0 .3-.1 .7-.2 1-.2s.7 .2 .9 .4c2.9 2.4 6 4.9 9.1 7.2 .2 .2 .4 .4 .6 .7s.2 .6 .2 .9-.1 .6-.3 .9-.4 .5-.6 .6c-14.7 8.6-30 15.9-45.9 21.8-.2 .1-.5 .2-.7 .4s-.3 .4-.4 .7-.1 .5-.1 .8 .1 .5 .2 .8c8.8 17 18.8 33.3 30 48.8 .2 .3 .6 .6 .9 .7s.8 .1 1.1 0c52.9-16.2 102.6-41.3 147.1-74.2 .2-.2 .4-.4 .5-.6s.2-.5 .2-.8c12.3-126.8-20.5-236.9-86.9-334.5zm-302 267.7c-29 0-52.8-26.6-52.8-59.2s23.4-59.2 52.8-59.2c29.7 0 53.3 26.8 52.8 59.2 0 32.7-23.4 59.2-52.8 59.2zm195.4 0c-29 0-52.8-26.6-52.8-59.2s23.4-59.2 52.8-59.2c29.7 0 53.3 26.8 52.8 59.2 0 32.7-23.2 59.2-52.8 59.2z\"/>" },
|
|
20
|
+
twitch: { viewBox: "0 0 448 512", body: "<path d=\"M359.4 103.5l-38.6 0 0 109.7 38.6 0 0-109.7zM253.2 103l-38.6 0 0 109.8 38.6 0 0-109.8zM89 0l-96.5 91.4 0 329.2 115.8 0 0 91.4 96.5-91.4 77.3 0 173.8-164.6 0-256-366.9 0zM417.3 237.8l-77.2 73.1-77.2 0-67.6 64 0-64-86.9 0 0-274.3 308.9 0 0 201.2z\"/>" },
|
|
21
|
+
reddit: { viewBox: "0 0 512 512", body: "<path d=\"M0 256C0 114.6 114.6 0 256 0S512 114.6 512 256 397.4 512 256 512L37.1 512c-13.7 0-20.5-16.5-10.9-26.2L75 437C28.7 390.7 0 326.7 0 256zM349.6 153.6c23.6 0 42.7-19.1 42.7-42.7s-19.1-42.7-42.7-42.7c-20.6 0-37.8 14.6-41.8 34-34.5 3.7-61.4 33-61.4 68.4l0 .2c-37.5 1.6-71.8 12.3-99 29.1-10.1-7.8-22.8-12.5-36.5-12.5-33 0-59.8 26.8-59.8 59.8 0 24 14.1 44.6 34.4 54.1 2 69.4 77.6 125.2 170.6 125.2s168.7-55.9 170.6-125.3c20.2-9.6 34.1-30.2 34.1-54 0-33-26.8-59.8-59.8-59.8-13.7 0-26.3 4.6-36.4 12.4-27.4-17-62.1-27.7-100-29.1l0-.2c0-25.4 18.9-46.5 43.4-49.9 4.4 18.8 21.3 32.8 41.5 32.8l.1 .2zM177.1 246.9c16.7 0 29.5 17.6 28.5 39.3s-13.5 29.6-30.3 29.6-31.4-8.8-30.4-30.5 15.4-38.3 32.1-38.3l.1-.1zm190.1 38.3c1 21.7-13.7 30.5-30.4 30.5s-29.3-7.9-30.3-29.6 11.8-39.3 28.5-39.3 31.2 16.6 32.1 38.3l.1 .1zm-48.1 56.7c-10.3 24.6-34.6 41.9-63 41.9s-52.7-17.3-63-41.9c-1.2-2.9 .8-6.2 3.9-6.5 18.4-1.9 38.3-2.9 59.1-2.9s40.7 1 59.1 2.9c3.1 .3 5.1 3.6 3.9 6.5z\"/>" },
|
|
22
|
+
dribbble: { viewBox: "0 0 512 512", body: "<path d=\"M256 8a248 248 0 1 0 0 496 248 248 0 1 0 0-496zM420 122.4c29.5 36 47.4 82 47.8 132-7-1.5-77-15.7-147.5-6.8-5.8-14-11.2-26.4-18.6-41.6 78.3-32 113.8-77.5 118.3-83.5zM396.4 97.9c-3.8 5.4-35.7 48.3-111 76.5-34.7-63.8-73.2-116.2-79-124 67.2-16.2 138 1.3 190.1 47.5zM165.9 64.6c5.6 7.7 43.4 60.1 78.5 122.5-99.1 26.3-186.4 25.9-195.8 25.8 13.7-65.7 58-120.4 117.3-148.3zM44.2 256.3c0-2.2 0-4.3 .1-6.5 9.3 .2 111.9 1.5 217.7-30.1 6.1 11.9 11.9 23.9 17.2 35.9-76.6 21.6-146.2 83.5-180.5 142.3-33.8-37.6-54.5-87.2-54.5-141.6zM126 423.4c22.1-45.2 82.2-103.6 167.6-132.8 29.7 77.3 42 142.1 45.2 160.6-68.1 29-150 21.1-212.8-27.9zm248.4 8.5c-2.2-12.9-13.4-74.9-41.2-151 66.4-10.6 124.7 6.8 131.9 9.1-9.4 58.9-43.3 109.8-90.8 142z\"/>" },
|
|
23
|
+
behance: { viewBox: "0 0 576 512", body: "<path d=\"M232 237.2c31.8-15.2 48.4-38.2 48.4-74 0-70.6-52.6-87.8-113.3-87.8l-167.1 0 0 354.4 171.8 0c64.4 0 124.9-30.9 124.9-102.9 0-44.5-21.1-77.4-64.7-89.7zM77.9 135.9l73.1 0c28.1 0 53.4 7.9 53.4 40.5 0 30.1-19.7 42.2-47.5 42.2l-79 0 0-82.7zm83.3 233.7l-83.3 0 0-97.6 84.9 0c34.3 0 56 14.3 56 50.6 0 35.8-25.9 47-57.6 47zM519.7 128.9l-143.7 0 0-34.9 143.7 0 0 34.9zM576 305.2c0-75.9-44.4-139.2-124.9-139.2-78.2 0-131.3 58.8-131.3 135.8 0 79.9 50.3 134.7 131.3 134.7 61.3 0 101-27.6 120.1-86.3l-62.2 0c-6.7 21.9-34.3 33.5-55.7 33.5-41.3 0-63-24.2-63-65.3l185.1 0c.3-4.2 .6-8.7 .6-13.2zM390.4 274c2.3-33.7 24.7-54.8 58.5-54.8 35.4 0 53.2 20.8 56.2 54.8l-114.7 0z\"/>" },
|
|
24
|
+
telegram: { viewBox: "0 0 512 512", body: "<path d=\"M256 8a248 248 0 1 0 0 496 248 248 0 1 0 0-496zM371 176.7c-3.7 39.2-19.9 134.4-28.1 178.3-3.5 18.6-10.3 24.8-16.9 25.4-14.4 1.3-25.3-9.5-39.3-18.7-21.8-14.3-34.2-23.2-55.3-37.2-24.5-16.1-8.6-25 5.3-39.5 3.7-3.8 67.1-61.5 68.3-66.7 .2-.7 .3-3.1-1.2-4.4s-3.6-.8-5.1-.5c-2.2 .5-37.1 23.5-104.6 69.1-9.9 6.8-18.9 10.1-26.9 9.9-8.9-.2-25.9-5-38.6-9.1-15.5-5-27.9-7.7-26.8-16.3 .6-4.5 6.7-9 18.4-13.7 72.3-31.5 120.5-52.3 144.6-62.3 68.9-28.6 83.2-33.6 92.5-33.8 2.1 0 6.6 .5 9.6 2.9 2 1.7 3.2 4.1 3.5 6.7 .5 3.2 .6 6.5 .4 9.8z\"/>" },
|
|
25
|
+
spotify: { viewBox: "0 0 512 512", body: "<path d=\"M256 8a248 248 0 1 0 0 496 248 248 0 1 0 0-496zM356.7 372.9c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4zm26.9-65.6c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm31-76.2c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3z\"/>" },
|
|
26
|
+
email: { viewBox: "0 0 512 512", body: "<path d=\"M48 64c-26.5 0-48 21.5-48 48 0 15.1 7.1 29.3 19.2 38.4l208 156c17.1 12.8 40.5 12.8 57.6 0l208-156c12.1-9.1 19.2-23.3 19.2-38.4 0-26.5-21.5-48-48-48L48 64zM0 196L0 384c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-188-198.4 148.8c-34.1 25.6-81.1 25.6-115.2 0L0 196z\"/>" },
|
|
27
|
+
rss: { viewBox: "0 0 448 512", body: "<path d=\"M0 64c0-17.7 14.3-32 32-32 229.8 0 416 186.2 416 416 0 17.7-14.3 32-32 32s-32-14.3-32-32C384 253.6 226.4 96 32 96 14.3 96 0 81.7 0 64zM0 416a64 64 0 1 1 128 0 64 64 0 1 1 -128 0zM32 160c159.1 0 288 128.9 288 288 0 17.7-14.3 32-32 32s-32-14.3-32-32c0-123.7-100.3-224-224-224-17.7 0-32-14.3-32-32s14.3-32 32-32z\"/>" },
|
|
28
|
+
website: { viewBox: "0 0 512 512", body: "<path d=\"M351.9 280l-190.9 0c2.9 64.5 17.2 123.9 37.5 167.4 11.4 24.5 23.7 41.8 35.1 52.4 11.2 10.5 18.9 12.2 22.9 12.2s11.7-1.7 22.9-12.2c11.4-10.6 23.7-28 35.1-52.4 20.3-43.5 34.6-102.9 37.5-167.4zM160.9 232l190.9 0C349 167.5 334.7 108.1 314.4 64.6 303 40.2 290.7 22.8 279.3 12.2 268.1 1.7 260.4 0 256.4 0s-11.7 1.7-22.9 12.2c-11.4 10.6-23.7 28-35.1 52.4-20.3 43.5-34.6 102.9-37.5 167.4zm-48 0C116.4 146.4 138.5 66.9 170.8 14.7 78.7 47.3 10.9 131.2 1.5 232l111.4 0zM1.5 280c9.4 100.8 77.2 184.7 169.3 217.3-32.3-52.2-54.4-131.7-57.9-217.3L1.5 280zm398.4 0c-3.5 85.6-25.6 165.1-57.9 217.3 92.1-32.7 159.9-116.5 169.3-217.3l-111.4 0zm111.4-48C501.9 131.2 434.1 47.3 342 14.7 374.3 66.9 396.4 146.4 399.9 232l111.4 0z\"/>" },
|
|
29
|
+
} as const;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { boundedArray } from "../bounded-array.ts";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -50,7 +51,7 @@ const Blur = z
|
|
|
50
51
|
.partial();
|
|
51
52
|
|
|
52
53
|
const CurvePoint = z.tuple([Unit, Unit]);
|
|
53
|
-
const CurveChannel =
|
|
54
|
+
const CurveChannel = boundedArray(CurvePoint, IMAGE_EDIT_CURVE_POINTS_MAX, 2).nullable();
|
|
54
55
|
const Curves = z.tuple([CurveChannel, CurveChannel, CurveChannel, CurveChannel]);
|
|
55
56
|
|
|
56
57
|
/** Corner targets may sit a little outside the frame (perspective pulls). */
|
|
@@ -53,10 +53,23 @@ export type ImportOptions = {
|
|
|
53
53
|
* `classes` for the dialog to add to the site), instead of copying the classes' styles in.
|
|
54
54
|
*/
|
|
55
55
|
classes?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* W-1026: the links of a site menu by the name an Elementor Nav Menu points at (the WordPress
|
|
58
|
+
* menu's slug), as EmDash's WordPress import brings them over; fetched by the dialog.
|
|
59
|
+
*/
|
|
60
|
+
menu?: (name: string) => readonly MenuLink[] | undefined;
|
|
56
61
|
/** Random source for node ids (tests). */
|
|
57
62
|
random?: () => number;
|
|
58
63
|
};
|
|
59
64
|
|
|
65
|
+
/** W-1026: one link of a site menu, with the links under it. */
|
|
66
|
+
export type MenuLink = {
|
|
67
|
+
text: string;
|
|
68
|
+
href?: string;
|
|
69
|
+
newTab?: boolean;
|
|
70
|
+
children?: readonly MenuLink[];
|
|
71
|
+
};
|
|
72
|
+
|
|
60
73
|
/** Elementor's stock kit: what an unstyled site shows. */
|
|
61
74
|
const DEFAULT_COLORS: Record<string, string> = {
|
|
62
75
|
primary: "#6ec1e4",
|
|
@@ -93,6 +106,10 @@ export class ImportContext {
|
|
|
93
106
|
private readonly svg: ImportOptions["svg"];
|
|
94
107
|
private readonly pageLinkOf: ImportOptions["pageLink"];
|
|
95
108
|
private readonly mediaOf: ImportOptions["media"];
|
|
109
|
+
/** W-1026: the site menu a Nav Menu points at, by its name. */
|
|
110
|
+
readonly menuOf: ImportOptions["menu"];
|
|
111
|
+
/** W-1026: the menu names the export's Nav Menus point at, so the dialog can fetch them. */
|
|
112
|
+
readonly menus = new Set<string>();
|
|
96
113
|
/** W-958: Elementor class id → its EmVB class, or undefined when it can't be one. */
|
|
97
114
|
readonly imported = new Map<string, ImportedClass | undefined>();
|
|
98
115
|
readonly useClasses: boolean;
|
|
@@ -121,6 +138,7 @@ export class ImportContext {
|
|
|
121
138
|
this.svg = options.svg;
|
|
122
139
|
this.pageLinkOf = options.pageLink;
|
|
123
140
|
this.mediaOf = options.media;
|
|
141
|
+
this.menuOf = options.menu;
|
|
124
142
|
this.useClasses = options.classes === true;
|
|
125
143
|
this.useDefaults = options.defaults ?? true;
|
|
126
144
|
this.kitGiven = this.readKit(options.kit);
|
|
@@ -69,6 +69,8 @@ export type ElementorImport =
|
|
|
69
69
|
svgFiles: string[];
|
|
70
70
|
/** W-958: WordPress page ids the page links to (their address comes from `pageLink`). */
|
|
71
71
|
pageLinks: number[];
|
|
72
|
+
/** W-1026: the site menus the page's Nav Menus point at (their links come from `menu`). */
|
|
73
|
+
menus: string[];
|
|
72
74
|
/** W-958: images on the old site the page uses (`media` gives their library copies). */
|
|
73
75
|
images: string[];
|
|
74
76
|
/** W-958: with `classes`, the EmVB classes the page's elements point at, to add to the site. */
|
|
@@ -378,8 +380,17 @@ class Walker {
|
|
|
378
380
|
"Scrolling and mouse motion effects weren't imported; add scroll motion in the editor.",
|
|
379
381
|
);
|
|
380
382
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
+
// W-1026: Elementor's Sticky (top or bottom, its offset and devices) as CSS sticky.
|
|
384
|
+
const sticky = stickyStyles(s);
|
|
385
|
+
if (sticky) {
|
|
386
|
+
target["style"] = { ...(target["style"] as Style | undefined), ...sticky.style };
|
|
387
|
+
if (sticky.devices) {
|
|
388
|
+
const devices = { ...(target["devices"] as Record<string, Style> | undefined) };
|
|
389
|
+
for (const [device, style] of Object.entries(sticky.devices))
|
|
390
|
+
devices[device] = { ...devices[device], ...style };
|
|
391
|
+
target["devices"] = devices;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
383
394
|
return nodes;
|
|
384
395
|
}
|
|
385
396
|
|
|
@@ -899,7 +910,7 @@ export function importElementor(input: unknown, options: ImportOptions = {}): El
|
|
|
899
910
|
...(pageCss ? customCss(pageCss, ctx, "Page") : {}),
|
|
900
911
|
});
|
|
901
912
|
if (pageStyle.devices) root["devices"] = pageStyle.devices;
|
|
902
|
-
if (options.media)
|
|
913
|
+
if (options.media) pointAtCopies(root, ctx);
|
|
903
914
|
const candidate: Record<string, unknown> = { schemaVersion: LAYOUT_SCHEMA_VERSION, root };
|
|
904
915
|
const tried = new Set<string>();
|
|
905
916
|
for (let attempt = 0; attempt < 500; attempt++) {
|
|
@@ -919,9 +930,10 @@ export function importElementor(input: unknown, options: ImportOptions = {}): El
|
|
|
919
930
|
fonts: [...ctx.fonts].toSorted(),
|
|
920
931
|
svgFiles: [...ctx.svgFiles],
|
|
921
932
|
pageLinks: [...ctx.pageLinks].toSorted((a, b) => a - b),
|
|
933
|
+
menus: [...ctx.menus].toSorted(),
|
|
922
934
|
images: [...ctx.images],
|
|
923
935
|
classes: usedClasses(checked.layout, ctx).map((cls) =>
|
|
924
|
-
options.media ? (
|
|
936
|
+
options.media ? (pointAtCopies(structuredClone(cls), ctx) as StyleClass) : cls,
|
|
925
937
|
),
|
|
926
938
|
};
|
|
927
939
|
}
|
|
@@ -940,17 +952,17 @@ export function importElementor(input: unknown, options: ImportOptions = {}): El
|
|
|
940
952
|
* W-958: points every use of an old-site image at its media library copy: image sources (which
|
|
941
953
|
* also get the library id), backgrounds and any other stored address equal to it.
|
|
942
954
|
*/
|
|
943
|
-
function
|
|
955
|
+
function pointAtCopies(value: unknown, ctx: ImportContext): unknown {
|
|
944
956
|
if (typeof value === "string")
|
|
945
957
|
return /^https?:\/\//i.test(value) ? (ctx.copied(value)?.url ?? value) : value;
|
|
946
958
|
if (Array.isArray(value)) {
|
|
947
|
-
for (let i = 0; i < value.length; i++) value[i] =
|
|
959
|
+
for (let i = 0; i < value.length; i++) value[i] = pointAtCopies(value[i], ctx);
|
|
948
960
|
return value;
|
|
949
961
|
}
|
|
950
962
|
if (!isRecord(value)) return value;
|
|
951
963
|
const props = value["type"] === "image" && isRecord(value["props"]) ? value["props"] : undefined;
|
|
952
964
|
const copy = props && typeof props["src"] === "string" ? ctx.copied(props["src"]) : undefined;
|
|
953
|
-
for (const [key, inner] of Object.entries(value)) value[key] =
|
|
965
|
+
for (const [key, inner] of Object.entries(value)) value[key] = pointAtCopies(inner, ctx);
|
|
954
966
|
if (props && copy?.id) props["mediaId"] = copy.id;
|
|
955
967
|
return value;
|
|
956
968
|
}
|
|
@@ -965,3 +977,34 @@ function usedClasses(layout: Layout, ctx: ImportContext): StyleClass[] {
|
|
|
965
977
|
visit(layout.root);
|
|
966
978
|
return [...ctx.imported.values()].flatMap((c) => (c && used.has(c.id) ? [c.cls] : []));
|
|
967
979
|
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* W-1026: Elementor's Sticky settings (`sticky`: top or bottom, `sticky_offset` in px,
|
|
983
|
+
* `sticky_on`: the devices) as `position: sticky` with that edge, above the content around it,
|
|
984
|
+
* and `static` on the devices it is off for.
|
|
985
|
+
*/
|
|
986
|
+
function stickyStyles(
|
|
987
|
+
s: Record<string, unknown>,
|
|
988
|
+
): { style: Style; devices?: Record<string, Style> } | undefined {
|
|
989
|
+
const edge = s["sticky"];
|
|
990
|
+
if (edge !== "top" && edge !== "bottom") return undefined;
|
|
991
|
+
const offset =
|
|
992
|
+
typeof s["sticky_offset"] === "number" ? s["sticky_offset"] : Number(s["sticky_offset"] ?? 0);
|
|
993
|
+
const at = {
|
|
994
|
+
value: Number.isFinite(offset) ? Math.min(10_000, Math.max(0, Math.round(offset))) : 0,
|
|
995
|
+
unit: "px" as const,
|
|
996
|
+
};
|
|
997
|
+
const on = Array.isArray(s["sticky_on"])
|
|
998
|
+
? s["sticky_on"].filter((d): d is string => typeof d === "string")
|
|
999
|
+
: ["desktop", "tablet", "mobile"];
|
|
1000
|
+
const sticky: Style = { position: "sticky", [edge]: at, zIndex: 99 };
|
|
1001
|
+
const flat: Style = { position: "static" };
|
|
1002
|
+
const style = on.includes("desktop") ? sticky : flat;
|
|
1003
|
+
const devices: Record<string, Style> = {};
|
|
1004
|
+
const desktop = on.includes("desktop");
|
|
1005
|
+
const tablet = on.includes("tablet");
|
|
1006
|
+
const mobile = on.includes("mobile");
|
|
1007
|
+
if (tablet !== desktop) devices["tablet"] = tablet ? sticky : flat;
|
|
1008
|
+
if (mobile !== tablet) devices["mobile"] = mobile ? sticky : flat;
|
|
1009
|
+
return Object.keys(devices).length > 0 ? { style, devices } : { style };
|
|
1010
|
+
}
|