domma-cms 0.14.10 → 0.15.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/admin/js/lib/effect-defs.js +1 -0
- package/admin/js/lib/effects-builder.js +3 -0
- package/admin/js/lib/markdown-toolbar.js +17 -46
- package/admin/js/templates/effects.html +83 -0
- package/admin/js/views/page-editor.js +12 -12
- package/package.json +2 -2
- package/public/js/effects.js +1 -1
- package/server/services/markdown.js +90 -21
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const EFFECTS=[{name:"reveal",label:"Reveal",category:"Entrance",description:"Scroll-triggered entrance animation when the element enters the viewport.",attrs:[{name:"animation",label:"Animation",type:"select",default:"fade",options:[["fade","Fade"],["slide-up","Slide up"],["slide-down","Slide down"],["zoom","Zoom"],["flip","Flip"]]},{name:"duration",label:"Duration (ms)",type:"number",default:600},{name:"delay",label:"Delay (ms)",type:"number",default:0},{name:"threshold",label:"Threshold",type:"number",default:.1,step:.05,min:0,max:1},{name:"once",label:"Animate once",type:"checkbox",default:!0}],hosts:["card","hero","banner","col"],previewable:!0},{name:"breathe",label:"Breathe",category:"Animation",description:"Continuous gentle scaling \u2014 makes elements feel alive.",attrs:[{name:"amplitude",label:"Amplitude (px)",type:"number",default:8},{name:"duration",label:"Duration (ms)",type:"number",default:3e3}],hosts:["card","hero","col","button"],previewable:!0},{name:"pulse",label:"Pulse",category:"Animation",description:"A repeating scale pulse \u2014 stronger than breathe.",attrs:[{name:"scale",label:"Scale",type:"number",default:1.05,step:.01},{name:"duration",label:"Duration (ms)",type:"number",default:1e3}],hosts:["card","hero","banner","button"],previewable:!0},{name:"shake",label:"Shake",category:"Animation",description:"One-shot horizontal or vertical shake.",attrs:[{name:"intensity",label:"Intensity (px)",type:"number",default:5},{name:"duration",label:"Duration (ms)",type:"number",default:500},{name:"direction",label:"Direction",type:"select",default:"horizontal",options:[["horizontal","Horizontal"],["vertical","Vertical"]]}],hosts:["card","banner","button"],previewable:!0},{name:"animate",label:"CSS Animate",category:"Animation",description:"Applies a Domma CSS animation utility class \u2014 no JavaScript.",attrs:[{name:"type",label:"Type",type:"select",default:"fade-in-up",options:[["fade-in","fade-in"],["fade-in-up","fade-in-up"],["fade-in-down","fade-in-down"],["fade-in-left","fade-in-left"],["fade-in-right","fade-in-right"],["slide-in-up","slide-in-up"],["slide-in-down","slide-in-down"],["zoom-in","zoom-in"],["zoom-out","zoom-out"],["bounce","bounce"],["pulse","pulse"],["shake","shake"],["spin","spin"],["flip","flip"]]},{name:"duration",label:"Duration",type:"select",default:"normal",options:[["fast","fast"],["normal","normal"],["slow","slow"],["slower","slower"]]},{name:"delay",label:"Delay (ms)",type:"number",default:0},{name:"repeat",label:"Repeat",type:"select",default:"once",options:[["once","Once"],["infinite","Infinite"]]}],hosts:["card","hero","banner","col","button"],previewable:!0},{name:"scribe",label:"Scribe (typewriter)",category:"Text",description:"Types text character by character. Simple mode only \u2014 for the action-script composer use Insert \u2192 Scribe.",attrs:[{name:"speed",label:"Speed (ms/char)",type:"number",default:50},{name:"cursor",label:"Show cursor",type:"checkbox",default:!0},{name:"loop",label:"Loop",type:"checkbox",default:!1}],hosts:[],previewable:!0},{name:"scramble",label:"Scramble",category:"Text",description:"Reveals text through a character-scramble animation.",attrs:[{name:"speed",label:"Speed (ms/char)",type:"number",default:50},{name:"loop",label:"Loop",type:"checkbox",default:!1}],hosts:[],previewable:!0},{name:"counter",label:"Counter",category:"Text",description:"Animates a number from a starting value to a target. Self-closing shortcode.",attrs:[{name:"to",label:"To",type:"number",default:100},{name:"from",label:"From",type:"number",default:0},{name:"duration",label:"Duration (ms)",type:"number",default:2e3},{name:"prefix",label:"Prefix",type:"text",default:""},{name:"suffix",label:"Suffix",type:"text",default:""},{name:"decimals",label:"Decimal places",type:"number",default:0},{name:"separator",label:"Thousand separator",type:"text",default:""}],hosts:[],previewable:!0,selfClosing:!0},{name:"ripple",label:"Ripple",category:"Visual",description:"Click-triggered ripple effect on the element.",attrs:[{name:"colour",label:"Colour",type:"colour",default:"#7c6af7"},{name:"duration",label:"Duration (ms)",type:"number",default:600},{name:"opacity",label:"Opacity",type:"number",default:.3,step:.05,min:0,max:1}],hosts:["card","col","button"],previewable:!0},{name:"twinkle",label:"Twinkle",category:"Visual",description:"Generates animated particle effects inside the element.",attrs:[{name:"count",label:"Particle count",type:"number",default:80},{name:"shape",label:"Shape",type:"select",default:"star",options:[["star","Star"],["circle","Circle"],["square","Square"]]},{name:"colour",label:"Colour",type:"colour",default:"#ffffff"},{name:"min-size",label:"Min size (px)",type:"number",default:2},{name:"max-size",label:"Max size (px)",type:"number",default:6}],hosts:["card","hero"],previewable:!0},{name:"ambient",label:"Ambient background",category:"Visual",description:"Applies an animated CSS background class to the element.",attrs:[{name:"type",label:"Type",type:"select",default:"float-blobs",options:[["float-blobs","Float blobs"],["float-orbs","Float orbs"],["float-particles","Float particles"],["rotate-glow","Rotate glow"],["rotate-dual","Rotate dual"],["rotate-spotlight","Rotate spotlight"],["wave","Wave"],["ripple","Ripple"],["aurora","Aurora"]]},{name:"speed",label:"Speed",type:"select",default:"normal",options:[["slow","Slow"],["normal","Normal"],["fast","Fast"]]},{name:"intensity",label:"Intensity",type:"select",default:"subtle",options:[["subtle","Subtle"],["intense","Intense"]]}],hosts:["card","hero","banner"],previewable:!0},{name:"firework",label:"Firework",category:"Celebrations",description:"CSS-only firework particle. Self-closing or wrapping form.",attrs:[{name:"type",label:"Type",type:"select",default:"burst",options:[["burst","Burst"],["sparkle","Sparkle"],["trail","Trail"]]},{name:"colour",label:"Colour theme",type:"select",default:"rainbow",options:[["rainbow","Rainbow"],["primary","Primary"],["info","Info"],["success","Success"],["warning","Warning"],["danger","Danger"]]},{name:"size",label:"Size",type:"select",default:"md",options:[["sm","Small"],["md","Medium"],["lg","Large"]]},{name:"continuous",label:"Continuous",type:"checkbox",default:!1},{name:"hover",label:"On hover only",type:"checkbox",default:!1}],hosts:[],previewable:!0},{name:"fireworks",label:"Fireworks show",category:"Celebrations",description:"A container with multiple firework particles inside.",attrs:[],hosts:[],previewable:!1},{name:"celebrate",label:"Celebrate",category:"Celebrations",description:"Canvas-based seasonal particle system. Runs full-page on the published site.",attrs:[{name:"theme",label:"Theme",type:"select",default:"auto",options:[["auto","Auto (date-detected)"],["christmas","Christmas"],["halloween","Halloween"],["valentines","Valentines"],["guy-fawkes","Guy Fawkes"],["st-patricks","St Patrick's"],["st-davids","St David's"],["st-georges","St George's"],["st-andrews","St Andrew's"]]},{name:"intensity",label:"Intensity",type:"select",default:"medium",options:[["light","Light"],["medium","Medium"],["heavy","Heavy"]]}],hosts:[],previewable:!1,selfClosing:!0},{name:"ticker-tape",label:"Ticker tape",category:"Celebrations",description:"Coloured rectangular strips fall from the top, sway, rotate, and fade. Self-closing for full-page; wrapping form for container-scoped.",attrs:[{name:"palette",label:"Palette",type:"select",default:"theme",options:[["theme","Theme"],["rainbow","Rainbow"],["gold","Gold"],["silver","Silver"],["festive","Festive"],["pastel","Pastel"],["mono","Mono"]]},{name:"density",label:"Density",type:"number",default:50},{name:"speed",label:"Speed multiplier",type:"number",default:1,step:.1},{name:"sway",label:"Sway (px)",type:"number",default:60},{name:"burst",label:"Burst mode (one-shot)",type:"checkbox",default:!1},{name:"burst-count",label:"Burst count",type:"number",default:150}],hosts:["hero"],previewable:!0}];export function getEffect(t){return EFFECTS.find(e=>e.name===t)||null}export function effectsByCategory(){return["Entrance","Animation","Text","Visual","Celebrations"].map(e=>({category:e,effects:EFFECTS.filter(a=>a.category===e)}))}export function effectsInjectableInto(t){return EFFECTS.filter(e=>e.hosts.includes(t))}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{EFFECTS as z,effectsByCategory as A,effectsInjectableInto as j,getEffect as g}from"./effect-defs.js?v=1";import{insertAtCursor as R}from"./markdown-toolbar.js?v=13";let h=null;export const EffectsBuilder={open(e){if(h)return;const t={textarea:e,activeEffect:S.get("effects-builder-last")||"reveal",scope:"standalone",host:null,editing:null,fieldValues:{}};if(t.host=P(e),t.host&&j(t.host.name).map(o=>o.name).includes(t.activeEffect)&&!(t.activeEffect in t.host.attrs)&&(t.scope="inject"),t.editing=N(e),t.editing){t.activeEffect=t.editing.name,t.scope="standalone";const l=g(t.editing.name);for(const o of l.attrs)if(o.name in t.editing.attrs){const s=t.editing.attrs[o.name];o.type==="number"?t.fieldValues[o.name]=Number(s):o.type==="checkbox"?t.fieldValues[o.name]=s==="true":t.fieldValues[o.name]=s}}const n=E.slideover({title:"Effects",size:"lg",position:"right"}),c=L(t,n);n.element.appendChild(c),n.open(),I.scan(c),h={state:t,slideover:n}},close(){h&&(h.slideover.close(),h=null)}};function L(e,t){const n=document.createElement("div");n.style.cssText="display:grid;grid-template-columns:170px 1fr;height:100%;min-height:520px;";const c=document.createElement("div");c.className="effects-rail",c.style.cssText="background:var(--dm-surface-subtle,#15152a);border-right:1px solid var(--dm-border,#2a2a40);padding:.5rem .35rem;font-size:.8rem;overflow-y:auto;";const l=document.createElement("div");l.className="effects-pane",l.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;overflow-y:auto;";function o(){D(l,e,t)}return v(c,e,o),o(),n.appendChild(c),n.appendChild(l),n}function v(e,t,n){e.replaceChildren();for(const c of A()){const l=document.createElement("div");l.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;margin:.4rem .35rem .25rem;",l.textContent=c.category,e.appendChild(l);for(const o of c.effects){const s=document.createElement("button");s.type="button",s.dataset.effect=o.name,s.style.cssText="display:block;width:100%;text-align:left;padding:.3rem .5rem;border:none;background:transparent;color:var(--dm-text,#ddd);border-radius:3px;font-size:.8rem;cursor:pointer;margin-bottom:.1rem;",s.textContent=o.label,o.name===t.activeEffect&&(s.style.background="var(--dm-primary,#4338ca)",s.style.color="#fff"),s.addEventListener("click",()=>{t.activeEffect=o.name,S.set("effects-builder-last",o.name),t.fieldValues={},v(e,t,n),n()}),e.appendChild(s)}}}function O(e,t){if(e.type==="select"){const c=document.createElement("select");c.style.cssText="width:100%;padding:.35rem .5rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.85rem;";for(const[l,o]of e.options){const s=document.createElement("option");s.value=l,s.textContent=o,c.appendChild(s)}return c.value=t??e.default??"",c}if(e.type==="checkbox"){const c=document.createElement("input");return c.type="checkbox",c.checked=t??e.default??!1,c}const n=document.createElement("input");return n.type=e.type==="number"?"number":e.type==="colour"?"color":"text",n.value=t??e.default??"",e.placeholder&&(n.placeholder=e.placeholder),e.type==="number"&&(e.min!=null&&(n.min=e.min),e.max!=null&&(n.max=e.max),e.step!=null&&(n.step=e.step)),n.style.cssText="width:100%;padding:.35rem .5rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:3px;color:var(--dm-text,#eee);font-size:.85rem;",n}function y(e,t){return t.type==="checkbox"?e.checked:t.type==="number"?e.value===""?"":Number(e.value):e.value}function V(e,t,n){const c=g(t.activeEffect);if(e.replaceChildren(),c.attrs.length===0){const o=document.createElement("div");o.style.cssText="color:var(--dm-text-muted,#888);font-size:.8rem;font-style:italic;",o.textContent="This effect takes no parameters.",e.appendChild(o);return}const l=document.createElement("div");l.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:.6rem .7rem;";for(const o of c.attrs){const s=document.createElement("div"),i=document.createElement("label");i.style.cssText="display:block;color:var(--dm-text-muted,#888);font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;margin-bottom:.2rem;",i.textContent=o.label,s.appendChild(i);const a=O(o,t.fieldValues[o.name]);if(a.addEventListener("input",()=>{t.fieldValues[o.name]=y(a,o),n()}),a.addEventListener("change",()=>{t.fieldValues[o.name]=y(a,o),n()}),s.appendChild(a),o.hint){const r=document.createElement("div");r.style.cssText="color:var(--dm-text-muted,#666);font-size:.7rem;margin-top:.15rem;",r.textContent=o.hint,s.appendChild(r)}l.appendChild(s)}e.appendChild(l)}function C(e){const t={},n=/(\w[\w-]*)(?:\s*=\s*"([^"]*)"|\s*=\s*'([^']*)'|\s*=\s*(\S+))?/g;for(const c of e.matchAll(n)){const l=c[1],o=c[2]??c[3]??c[4]??"";t[l]=o}return t}const B=z.filter(e=>!e.selfClosing).map(e=>e.name);function N(e){const t=e.value,n=e.selectionStart;for(const c of B){const l=new RegExp(`\\[${c}([^\\]]*)\\]`,"g"),o=new RegExp(`\\[/${c}\\]`,"g"),s=[];for(const r of t.matchAll(l)){if(r.index>=n)break;s.push({type:"open",start:r.index,end:r.index+r[0].length,attrStr:r[1]})}for(const r of t.matchAll(o)){if(r.index>=n)break;s.push({type:"close",start:r.index,end:r.index+r[0].length})}s.sort((r,f)=>r.start-f.start);let i=0,a=null;for(const r of s)r.type==="open"?(i++,a=r):(i--,i<0&&(i=0,a=null));if(i>0&&a){const r=new RegExp(`\\[/${c}\\]`,"g"),f=t.slice(n),d=f.match(r);if(d){const p=n+f.indexOf(d[0]);return{name:c,blockStart:a.start,blockEnd:p+d[0].length,openTagEnd:a.end,attrs:C(a.attrStr)}}}}return null}const q=["card","hero","banner","col","button"];function P(e){const t=e.value,n=e.selectionStart;for(const c of q){const l=new RegExp(`\\[${c}([^\\]]*)\\]`,"g"),o=new RegExp(`\\[/${c}\\]`,"g"),s=[];for(const r of t.matchAll(l)){if(r.index>=n)break;s.push({type:"open",start:r.index,end:r.index+r[0].length,attrStr:r[1]})}for(const r of t.matchAll(o)){if(r.index>=n)break;s.push({type:"close",start:r.index,end:r.index+r[0].length})}s.sort((r,f)=>r.start-f.start);let i=0,a=null;for(const r of s)r.type==="open"?(i++,a=r):(i--,i<0&&(i=0,a=null));if(i>0&&a){const r=new RegExp(`\\[/${c}\\]`,"g"),f=t.slice(n),d=f.match(r);if(d){const p=n+f.indexOf(d[0]);return{name:c,openTagStart:a.start,openTagEnd:a.end,closeTagStart:p,closeTagEnd:p+d[0].length,attrs:C(a.attrStr)}}}}return null}function k(e,t){const n=[];for(const c of t.attrs){const l=e.fieldValues[c.name];l===void 0||l===""||l===null||l!==c.default&&(c.type==="checkbox"?n.push(`${c.name}="${l?"true":"false"}"`):n.push(`${c.name}="${String(l).replace(/"/g,""")}"`))}return n.join(" ")}function $(e){const t=g(e.activeEffect),n=k(e,t),c=n?" ":"";if(e.scope==="inject"&&e.host){const l=e.host.attrs,o=t.name,s=[];for(const i of Object.keys(l)){if(i===o||i.startsWith(o+"-"))continue;const a=l[i];s.push(a===""?i:`${i}="${String(a).replace(/"/g,""")}"`)}s.push(o);for(const i of t.attrs){const a=e.fieldValues[i.name];if(a===void 0||a===""||a===null||a===i.default)continue;const r=i.type==="checkbox"?a?"true":"false":String(a).replace(/"/g,""");s.push(`${o}-${i.name}="${r}"`)}return`[${e.host.name} ${s.join(" ")}]\u2026[/${e.host.name}]`}return t.selfClosing?`[${t.name}${c}${n} /]`:`[${t.name}${c}${n}]
|
|
2
|
+
Content
|
|
3
|
+
[/${t.name}]`}function w(e,t){e.replaceChildren();const n=document.createElement("div");n.style.cssText="color:var(--dm-text-muted,#888);font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;margin-bottom:.25rem;",n.textContent="Shortcode (live)",e.appendChild(n);const c=document.createElement("pre");c.style.cssText="background:var(--dm-surface-deep,#000);border:1px solid var(--dm-border,#333);padding:.5rem .65rem;border-radius:3px;font-family:var(--dm-font-mono,monospace);font-size:.75rem;color:#7c6af7;line-height:1.5;white-space:pre-wrap;word-break:break-all;margin:0;",c.textContent=$(t),e.appendChild(c)}function F(e,t,n){if(e.replaceChildren(),t.editing)return;const c=g(t.activeEffect),l=t.host&&c.hosts.includes(t.host.name),o=document.createElement("div");o.style.cssText="background:var(--dm-surface-subtle,#15152a);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:.5rem .6rem;";const s=document.createElement("div");if(s.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;margin-bottom:.3rem;",s.textContent="Apply as",o.appendChild(s),!l){const r=document.createElement("div");r.style.cssText="color:var(--dm-text-muted,#888);font-size:.75rem;font-style:italic;",t.host?r.textContent=`Inserted as a standalone block (${c.label} cannot be injected into [${t.host.name}]).`:r.textContent="Inserted as a standalone block.",o.appendChild(r),e.appendChild(o),t.scope="standalone";return}const i=document.createElement("div");i.style.cssText="display:flex;gap:.3rem;";function a(r,f){const d=document.createElement("button");return d.type="button",d.style.cssText="flex:1;padding:.35rem;border:1px solid var(--dm-border,#333);border-radius:3px;font-size:.75rem;font-weight:600;cursor:pointer;",t.scope===r?(d.style.background="var(--dm-primary,#4338ca)",d.style.color="#fff",d.style.borderColor="var(--dm-primary,#4338ca)"):(d.style.background="transparent",d.style.color="var(--dm-text-muted,#bbb)"),d.textContent=f,d.addEventListener("click",()=>{t.scope=r,n()}),d}i.appendChild(a("standalone","Standalone block")),i.appendChild(a("inject",`Inject into [${t.host.name}]`)),o.appendChild(i),e.appendChild(o)}let x=0;function T(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function _(e,t){e.replaceChildren();const n=g(t.activeEffect),c=document.createElement("div");c.style.cssText="display:flex;justify-content:space-between;align-items:center;margin-bottom:.25rem;";const l=document.createElement("div");if(l.style.cssText="color:var(--dm-text-muted,#888);text-transform:uppercase;font-size:.65rem;letter-spacing:.05em;",l.textContent="Live preview",c.appendChild(l),!n.previewable){const a=document.createElement("div");a.style.cssText="background:var(--dm-surface-subtle,#15152a);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:.6rem;color:var(--dm-text-muted,#888);font-size:.8rem;font-style:italic;text-align:center;",a.textContent="Runs full-page on the published site \u2014 no inline preview.",e.appendChild(a);return}const o=document.createElement("button");o.type="button",o.style.cssText="background:transparent;border:1px solid var(--dm-border,#333);color:var(--dm-text-muted,#888);font-size:.65rem;padding:.15rem .4rem;border-radius:2px;cursor:pointer;",o.textContent="\u21BB Replay",c.appendChild(o),e.appendChild(c);const s=document.createElement("div");s.style.cssText="background:var(--dm-surface-subtle,#1a1a2e);border:1px solid var(--dm-border,#2a2a40);border-radius:4px;padding:1rem;text-align:center;min-height:80px;position:relative;overflow:hidden;",e.appendChild(s);function i(){x++;const a=x;s.replaceChildren();const r=document.createElement("div");r.style.cssText="background:linear-gradient(135deg,#6366f1,#a855f7);color:#fff;padding:.6rem;border-radius:4px;font-size:.8rem;font-weight:600;",r.textContent="Sample content",s.appendChild(r);const f=window.Domma&&window.Domma.effects;if(!f)return;const d={};for(const p of n.attrs){const m=t.fieldValues[p.name];m===void 0||m===""||m===null||(d[T(p.name)]=m)}try{const p=f[T(n.name)];if(typeof p=="function"){if(a!==x)return;p(r,d)}}catch(p){console.warn("Effects preview failed:",p)}}o.addEventListener("click",i),i()}function D(e,t,n){const c=g(t.activeEffect);e.replaceChildren();const l=document.createElement("h3");l.style.cssText="margin:0;font-size:1rem;color:var(--dm-text,#eee);",l.textContent=c.label,e.appendChild(l);const o=document.createElement("p");o.style.cssText="margin:0;color:var(--dm-text-muted,#999);font-size:.8rem;line-height:1.4;",o.textContent=c.description,e.appendChild(o);const s=document.createElement("div");e.appendChild(s);const i=document.createElement("div");e.appendChild(i);const a=document.createElement("div");e.appendChild(a);const r=document.createElement("div");e.appendChild(r);function f(){F(s,t,f),V(i,t,()=>{w(a,t),_(r,t)}),w(a,t),_(r,t)}f();const d=document.createElement("div");d.style.cssText="display:flex;gap:.5rem;margin-top:auto;padding-top:.75rem;border-top:1px solid var(--dm-border,#2a2a40);";const p=document.createElement("button");p.type="button",p.className="btn btn-ghost",p.textContent="Cancel",p.addEventListener("click",()=>n.close()),d.appendChild(p);const m=document.createElement("button");m.type="button",m.className="btn btn-primary",m.style.flex="2",m.textContent=t.editing?"Update":"Insert effect",m.addEventListener("click",()=>H(t,n)),d.appendChild(m),e.appendChild(d)}function H(e,t){const n=e.textarea,c=$(e);if(e.editing){const l=g(e.editing.name),o=n.value,s=o.substring(0,e.editing.blockStart),i=o.substring(e.editing.blockEnd),a=`[/${l.name}]`.length,r=e.editing.openTagEnd,f=e.editing.blockEnd-a,d=o.substring(r,f),p=k(e,l),m=p?" ":"",u=l.selfClosing?`[${l.name}${m}${p} /]`:`[${l.name}${m}${p}]${d}[/${l.name}]`;n.value=s+u+i;const b=l.selfClosing?s.length+u.length:s.length+u.indexOf("]")+1;n.selectionStart=n.selectionEnd=b,n.dispatchEvent(new Event("input",{bubbles:!0})),t.close();return}if(e.scope==="inject"&&e.host){const l=g(e.activeEffect),o=n.value,s=o.substring(0,e.host.openTagStart),i=o.substring(e.host.openTagEnd),a=e.host.attrs,r=l.name,f=[];for(const m of Object.keys(a)){if(m===r||m.startsWith(r+"-"))continue;const u=a[m];f.push(u===""?m:`${m}="${String(u).replace(/"/g,""")}"`)}f.push(r);for(const m of l.attrs){const u=e.fieldValues[m.name];if(u===void 0||u===""||u===null||u===m.default)continue;const b=m.type==="checkbox"?u?"true":"false":String(u).replace(/"/g,""");f.push(`${r}-${m.name}="${b}"`)}const d=`[${e.host.name} ${f.join(" ")}]`;n.value=s+d+i;const p=s.length+d.length;n.selectionStart=n.selectionEnd=p,n.dispatchEvent(new Event("input",{bubbles:!0})),t.close();return}R(n,c),n.dispatchEvent(new Event("input",{bubbles:!0})),t.close()}
|
|
@@ -1,45 +1,16 @@
|
|
|
1
|
-
function se(){I.register("bold",{viewBox:"0 0 24 24",path:"M7 5H14a3 3 0 0 1 0 6H7V5zM7 11H15a3 3 0 0 1 0 6H7V11z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("italic",{viewBox:"0 0 24 24",path:"M11 5h4M9 19h4M13 5l-2 14",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("strikethrough",{viewBox:"0 0 24 24",path:"M16 4H9a3 3 0 0 0 0 6h6a3 3 0 0 1 0 6H6M3 12h18",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("quote",{viewBox:"0 0 24 24",path:"M3 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1zM15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("eye",{viewBox:"0 0 24 24",path:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("expand",{viewBox:"0 0 24 24",path:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("columns",{viewBox:"0 0 24 24",path:"M3 4h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM12 4v16",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("card",{viewBox:"0 0 24 24",paths:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z","M3 9h18"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("help-circle",{viewBox:"0 0 24 24",path:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10zM12 17h.01M12 13a2 2 0 0 0 2-2 2 2 0 0 0-2-2 2 2 0 0 0-2 2",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("spacer-insert",{viewBox:"0 0 24 24",paths:["M3 8h18","M3 16h18","M12 8v8"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("icon-pick",{viewBox:"0 0 24 24",paths:["M4 4h6v6H4z","M14 4h6v6h-6z","M4 14h6v6H4z","M14 14h6v6h-6z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("colour-picker",{viewBox:"0 0 24 24",paths:["M12 2a5 5 0 0 1 5 5c0 3-5 10-5 10S7 10 7 7a5 5 0 0 1 5-5z","M12 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("btn-insert",{viewBox:"0 0 24 24",paths:["M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z","M8 12h8M12 9v6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("link-shortcode",{viewBox:"0 0 24 24",paths:["M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71","M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("layout-list",{viewBox:"0 0 24 24",paths:["M3 5h18M3 9h18","M3 14h4v6H3zM9 14h12M9 17h8"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("sparkles",{viewBox:"0 0 24 24",paths:["M12 3L13.5 8.5H19L14.5 11.5L16 17L12 14L8 17L9.5 11.5L5 8.5H10.5L12 3Z","M19 3L19.7 5.3H22L20.2 6.6L20.9 9L19 7.7L17.1 9L17.8 6.6L16 5.3H18.3L19 3Z","M5 13L5.5 14.7H7L5.8 15.5L6.3 17.2L5 16.3L3.7 17.2L4.2 15.5L3 14.7H4.5L5 13Z"],stroke:"currentColor",fill:"none",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("accordion-insert",{viewBox:"0 0 24 24",paths:["M3 4h18","M3 8h18","M8 11l4 4 4-4","M3 16h18","M3 20h18"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("banner-insert",{viewBox:"0 0 24 24",paths:["M3 6h18","M3 10h18","M3 14h12"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("hero",{viewBox:"0 0 24 24",paths:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5z","M7 8h10M7 11h6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("text-style",{viewBox:"0 0 24 24",paths:["M4 7V5h16v2","M9 19h6","M12 5v14","M5 12h14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("css-code",{viewBox:"0 0 24 24",paths:["M9 9l-6 3 6 3","M15 9l6 3-6 3","M13 5l-2 14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("scribe-insert",{viewBox:"0 0 24 24",paths:["M4 20h3l10-10-3-3L4 17v3z","M14 7l3 3","M4 4h6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}export function wrapSelection(t,e,
|
|
2
|
-
`,i-1)+1,o=t.value.substring(l).match(/^ {1,2}/);o&&(t.value=t.value.substring(0,l)+t.value.substring(l+o[0].length),t.selectionStart=t.selectionEnd=Math.max(l,i-o[0].length),t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Dedented",{type:"info",duration:800}))}else t.value=t.value.substring(0,i)+" "+t.value.substring(i),t.selectionStart=t.selectionEnd=i+2,t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Indented",{type:"info",duration:800});return}if(!(e.ctrlKey||e.metaKey))return;const
|
|
1
|
+
function se(){I.register("bold",{viewBox:"0 0 24 24",path:"M7 5H14a3 3 0 0 1 0 6H7V5zM7 11H15a3 3 0 0 1 0 6H7V11z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("italic",{viewBox:"0 0 24 24",path:"M11 5h4M9 19h4M13 5l-2 14",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("strikethrough",{viewBox:"0 0 24 24",path:"M16 4H9a3 3 0 0 0 0 6h6a3 3 0 0 1 0 6H6M3 12h18",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("quote",{viewBox:"0 0 24 24",path:"M3 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1zM15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("eye",{viewBox:"0 0 24 24",path:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("expand",{viewBox:"0 0 24 24",path:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("columns",{viewBox:"0 0 24 24",path:"M3 4h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM12 4v16",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("card",{viewBox:"0 0 24 24",paths:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z","M3 9h18"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("help-circle",{viewBox:"0 0 24 24",path:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10zM12 17h.01M12 13a2 2 0 0 0 2-2 2 2 0 0 0-2-2 2 2 0 0 0-2 2",stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("spacer-insert",{viewBox:"0 0 24 24",paths:["M3 8h18","M3 16h18","M12 8v8"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("icon-pick",{viewBox:"0 0 24 24",paths:["M4 4h6v6H4z","M14 4h6v6h-6z","M4 14h6v6H4z","M14 14h6v6h-6z"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("colour-picker",{viewBox:"0 0 24 24",paths:["M12 2a5 5 0 0 1 5 5c0 3-5 10-5 10S7 10 7 7a5 5 0 0 1 5-5z","M12 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("btn-insert",{viewBox:"0 0 24 24",paths:["M3 7a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z","M8 12h8M12 9v6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("link-shortcode",{viewBox:"0 0 24 24",paths:["M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71","M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("layout-list",{viewBox:"0 0 24 24",paths:["M3 5h18M3 9h18","M3 14h4v6H3zM9 14h12M9 17h8"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("sparkles",{viewBox:"0 0 24 24",paths:["M12 3L13.5 8.5H19L14.5 11.5L16 17L12 14L8 17L9.5 11.5L5 8.5H10.5L12 3Z","M19 3L19.7 5.3H22L20.2 6.6L20.9 9L19 7.7L17.1 9L17.8 6.6L16 5.3H18.3L19 3Z","M5 13L5.5 14.7H7L5.8 15.5L6.3 17.2L5 16.3L3.7 17.2L4.2 15.5L3 14.7H4.5L5 13Z"],stroke:"currentColor",fill:"none",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("accordion-insert",{viewBox:"0 0 24 24",paths:["M3 4h18","M3 8h18","M8 11l4 4 4-4","M3 16h18","M3 20h18"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("banner-insert",{viewBox:"0 0 24 24",paths:["M3 6h18","M3 10h18","M3 14h12"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("hero",{viewBox:"0 0 24 24",paths:["M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5z","M7 8h10M7 11h6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("text-style",{viewBox:"0 0 24 24",paths:["M4 7V5h16v2","M9 19h6","M12 5v14","M5 12h14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("css-code",{viewBox:"0 0 24 24",paths:["M9 9l-6 3 6 3","M15 9l6 3-6 3","M13 5l-2 14"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),I.register("scribe-insert",{viewBox:"0 0 24 24",paths:["M4 20h3l10-10-3-3L4 17v3z","M14 7l3 3","M4 4h6"],stroke:"currentColor",fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}export function wrapSelection(t,e,m){const i=t.selectionStart,l=t.selectionEnd,o=t.value,r=o.substring(i,l);r?(t.value=o.substring(0,i)+e+r+m+o.substring(l),t.selectionStart=i+e.length,t.selectionEnd=l+e.length):(t.value=o.substring(0,i)+e+m+o.substring(i),t.selectionStart=t.selectionEnd=i+e.length),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}export function insertAtCursor(t,e){const m=t.selectionStart,i=t.value;t.value=i.substring(0,m)+e+i.substring(m),t.selectionStart=t.selectionEnd=m+e.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}export function attachEditorKeybindings(t){t.addEventListener("keydown",e=>{if(e.key==="Tab"){e.preventDefault();const i=t.selectionStart;if(e.shiftKey){const l=t.value.lastIndexOf(`
|
|
2
|
+
`,i-1)+1,o=t.value.substring(l).match(/^ {1,2}/);o&&(t.value=t.value.substring(0,l)+t.value.substring(l+o[0].length),t.selectionStart=t.selectionEnd=Math.max(l,i-o[0].length),t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Dedented",{type:"info",duration:800}))}else t.value=t.value.substring(0,i)+" "+t.value.substring(i),t.selectionStart=t.selectionEnd=i+2,t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Indented",{type:"info",duration:800});return}if(!(e.ctrlKey||e.metaKey))return;const m=e.key.toLowerCase();if(m==="z")e.preventDefault(),document.execCommand("undo"),E.toast("Undo",{type:"info",duration:1200});else if(m==="y")e.preventDefault(),document.execCommand("redo"),E.toast("Redo",{type:"info",duration:1200});else if(m==="x"&&t.selectionStart===t.selectionEnd){e.preventDefault();const i=t.value.lastIndexOf(`
|
|
3
3
|
`,t.selectionStart-1)+1,l=t.value.indexOf(`
|
|
4
|
-
`,t.selectionStart),o=l===-1?t.value.length:l+1;t.setSelectionRange(i,o),document.execCommand("cut"),t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Line cut",{type:"info",duration:1200})}else if(
|
|
4
|
+
`,t.selectionStart),o=l===-1?t.value.length:l+1;t.setSelectionRange(i,o),document.execCommand("cut"),t.dispatchEvent(new Event("input",{bubbles:!0})),E.toast("Line cut",{type:"info",duration:1200})}else if(m==="c"&&t.selectionStart===t.selectionEnd){e.preventDefault();const i=t.selectionStart,l=t.value.lastIndexOf(`
|
|
5
5
|
`,i-1)+1,o=t.value.indexOf(`
|
|
6
|
-
`,i),
|
|
7
|
-
`,
|
|
8
|
-
`,l),
|
|
9
|
-
${t||"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
[/reveal]`},{category:"Animation"},{label:"Breathe",snippet:t=>`[breathe]
|
|
15
|
-
${t||"Content"}
|
|
16
|
-
[/breathe]`},{label:"Pulse",snippet:t=>`[pulse]
|
|
17
|
-
${t||"Content"}
|
|
18
|
-
[/pulse]`},{label:"Shake",snippet:t=>`[shake]
|
|
19
|
-
${t||"Content"}
|
|
20
|
-
[/shake]`},{label:"CSS Animate",snippet:t=>`[animate type="fade-in-up"]
|
|
21
|
-
${t||"Content"}
|
|
22
|
-
[/animate]`},{category:"Text"},{label:"Typewriter",snippet:t=>`[scribe speed="50" cursor="true"]
|
|
23
|
-
${t||"Content"}
|
|
24
|
-
[/scribe]`},{label:"Scramble",snippet:t=>`[scramble]
|
|
25
|
-
${t||"Content"}
|
|
26
|
-
[/scramble]`},{label:"Counter",snippet:()=>'[counter to="100" /]',insert:!0},{category:"Visual"},{label:"Ripple",snippet:t=>`[ripple]
|
|
27
|
-
${t||"Content"}
|
|
28
|
-
[/ripple]`},{label:"Twinkle",snippet:t=>`[twinkle count="80" shape="star"]
|
|
29
|
-
${t||"Content"}
|
|
30
|
-
[/twinkle]`},{label:"Ambient bg",snippet:t=>`[ambient type="float-blobs" speed="slow"]
|
|
31
|
-
${t||"Content"}
|
|
32
|
-
[/ambient]`},{category:"Celebrations"},{label:"Firework (burst)",snippet:()=>'[firework type="burst" colour="rainbow" /]',insert:!0},{label:"Firework (sparkle)",snippet:()=>'[firework type="sparkle" colour="primary" /]',insert:!0},{label:"Firework (wrap)",snippet:t=>`[firework type="burst" colour="rainbow"]
|
|
33
|
-
${t||"Content"}
|
|
34
|
-
[/firework]`},{label:"Fireworks show",snippet:()=>`[fireworks]
|
|
35
|
-
[firework type="burst" colour="rainbow" /]
|
|
36
|
-
[firework type="sparkle" colour="primary" /]
|
|
37
|
-
[/fireworks]`,insert:!0},{label:"Celebrate",snippet:()=>'[celebrate theme="auto" intensity="medium" /]',insert:!0}];function ce(t,e){const p=document.querySelector(".editor-effects-dropdown-menu");if(p){p.remove();return}const i=document.createElement("div");i.className="editor-effects-dropdown-menu",le.forEach(function(r){if(r.category){const a=document.createElement("div");a.className="editor-effects-category",a.textContent=r.category,i.appendChild(a)}else{const a=document.createElement("button");a.type="button",a.className="editor-effects-item",a.textContent=r.label,a.addEventListener("click",function(){if(i.remove(),r.insert)insertAtCursor(t,r.snippet(""));else{const d=t.selectionStart,h=t.selectionEnd,n=t.value.substring(d,h),c=r.snippet(n);t.value=t.value.substring(0,d)+c+t.value.substring(h),t.selectionStart=d,t.selectionEnd=d+c.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}}),i.appendChild(a)}});const l=e.getBoundingClientRect(),o=e.closest(".editor-toolbar").getBoundingClientRect();i.style.top=l.bottom-o.top+4+"px",i.style.left=l.left-o.left+"px",e.closest(".editor-toolbar").appendChild(i);function s(r){!i.contains(r.target)&&r.target!==e&&(i.remove(),document.removeEventListener("click",s,!0))}setTimeout(function(){document.addEventListener("click",s,!0)},0)}const J=["activity","airpods","airport","alert-circle","alert-warning","ambulance","angry","annoyed","apartment","arch","archive","arrow-down","arrow-down-left","arrow-down-right","arrow-left","arrow-right","arrow-up","arrow-up-left","arrow-up-right","astonished","at-sign","attachment","award","badge","ban","bandage","bank","banknote","barbell","barcode","barn","baseball","basketball","battery","battery-charging","bauble","bell","bell-off","bells","bicycle","bitcoin","blood-drop","blush","bold","bone","book","book-closed","book-open","bookmark","bookmark-filled","bowling","box","boxing-glove","brain","bridge","briefcase","building","bus","cabin","cake","calculator","calendar","camera","camera-off","candy-cane","capsule","car","cart","cart-add","cash","cast","castle","chart-area","chart-bar","chart-bar-horizontal","chart-candlestick","chart-line","chart-pie","chat","chat-alt","check","check-circle","check-circle-filled","check-square","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-down","chevrons-left","chevrons-right","chevrons-up","church","circle","circle-filled","clear-format","clipboard","clipboard-check","clipboard-list","clock","close","cloud","cloud-download","cloud-drizzle","cloud-lightning","cloud-off","cloud-rain","cloud-sun","cloud-upload","code","code-block","code-inline","cog","coins","columns","comment","compass","component","confused","cool","copy","corner-down-left","corner-down-right","corner-up-left","corner-up-right","court","cpu","credit-card","crown","crutch","cry","currency-dollar","currency-euro","currency-pound","cycling","database","dead","desktop","disappointed","dna","document","document-add","document-check","document-remove","document-text","dollar-sign","dome","dot","dots-horizontal","dots-vertical","download","droplet","droplets","dumbbell","edit","embed","emoji-happy","emoji-sad","euro-sign","exclamation","expand","expressionless","external-link","eye","eye-medical","eye-off","factory","fast-forward","feather","file-code","file-text","file-zip","fill","film","filter","fire","first-aid","fishing","flag","fog","folder","folder-add","folder-minus","folder-open","folder-plus","folder-remove","football","fortress","fuel","gamepad","garage","gauge","gift","git-branch","github","globe","golf","grid","grin","growth","hard-drive","hash","haze","heading-1","heading-2","heading-3","headphones","heart","heart-eyes","heart-filled","heart-pulse","heartbeat","help-circle","holly","home","hospital","hotel","house","image","image-add","images","inbox","indent","info","info-filled","investment","invoice","italic","joy","joystick","key","kettlebell","keyboard","laptop","laugh","layers","layout","library","lighthouse","lightning","link","link-2","link-add","linkedin","list","list-bullet","list-numbered","loader","loading","lock","log-in","log-out","lungs","mail","mail-open","map","map-pin","mask","maximize","medal","medical-cross","menu","menu-alt","message-circle","message-square","mic","mic-off","microscope","minimize","minus","minus-circle","minus-square","monitor","monument","moon","moon-star","more-horizontal","more-vertical","mosque","motorcycle","mountain","mouse","mouse-pointer","move","museum","music","nerd","neutral","notification","obelisk","office","outdent","package","palette","panel-bottom","panel-left","panel-right","panel-top","paperclip","parking","pause","pause-filled","percent","phone","phone-call","phone-incoming","phone-off","phone-outgoing","piggy-bank","pill","pill-bottle","pin","play","play-circle","play-filled","plug","plus","plus-circle","plus-square","podium","pound-sign","printer","pulse","pyramid","qrcode","question","quote","racket","radio","rage","rain","rainbow","receipt","redo","refresh","refresh-cw","reindeer","rewind","road","rotate-ccw","rotate-cw","router","rss","running","sad","safe","save","scale","scale-weight","school","search","send","server","settings","share","share-2","share-alt","shield","shield-alert","shield-check","shield-x","shipping","shocked","shopping-bag","shrink","sick","sidebar-left","sidebar-right","silly","skate","ski","skip-back","skip-forward","skyscraper","sleepy","sleigh","sliders","smartphone","smartwatch","smile","snow","snowflake","snowman","sob","soccer","sort","sparkles","speaker","spinner","square","stadium","star","star-decoration","star-eyes","star-filled","stethoscope","stop","stop-filled","stopwatch","store","strikethrough","sun","sunrise","sunset","surfboard","surprised","swimming","sync","syringe","tablet","tablet-smartphone","tag","tags","target","taxi","temple","tennis","tent","terminal","test-tube","text-center","text-left","text-right","thermometer","thermometer-medical","thermometer-sun","thinking","thumb-down","thumb-up","tongue","tool","tooth","tower","train-station","trash","tree","trending-down","trending-neutral","trending-up","trophy","truck","tv","tv-minimal","twitter","type","umbrella","underline","undo","university","unlink","unlock","upload","usb","user","user-add","user-check","user-group","user-plus","user-remove","users","vaccine","van","vault","video","video-off","volleyball","volume","volume-down","volume-mute","volume-off","volume-up","wallet","warehouse","warning","warning-filled","watch","webcam","wheelchair","whistle","wifi","wifi-off","wind","windmill","wink","wreath","x","x-circle","x-circle-filled","yoga","youtube","zany","zap"];function ae(t,e,p){const i=document.querySelector(".editor-spacer-picker");if(i){i.remove();return}const l=document.createElement("div");l.className="editor-spacer-picker";const o=document.createElement("div");o.className="editor-spacer-picker-label",o.textContent="Spacer height",l.appendChild(o);const s=document.createElement("div");s.className="editor-spacer-picker-row";const r=document.createElement("input");r.type="range",r.className="editor-spacer-slider",r.min="4",r.max="200",r.step="4",r.value=p;const a=document.createElement("span");a.className="editor-spacer-slider-value",a.textContent=p+"px",r.addEventListener("input",function(){a.textContent=this.value+"px"}),s.appendChild(r),s.appendChild(a),l.appendChild(s);const d=document.createElement("button");d.type="button",d.className="btn btn-primary btn-sm editor-spacer-insert-btn",d.textContent="Insert",l.appendChild(d);function h(k){!l.contains(k.target)&&k.target!==e&&(l.remove(),document.removeEventListener("click",h,!0))}d.addEventListener("click",function(){l.remove(),document.removeEventListener("click",h,!0),insertAtCursor(t,`[spacer size="${r.value}" /]
|
|
38
|
-
`)});const n=e.getBoundingClientRect(),c=e.closest(".editor-toolbar").getBoundingClientRect();l.style.top=n.bottom-c.top+4+"px";const u=n.left-c.left;l.style.left=Math.min(u,c.width-240-8)+"px",e.closest(".editor-toolbar").appendChild(l),setTimeout(function(){document.addEventListener("click",h,!0)},0)}function de(t,e){const p=document.querySelector(".editor-icon-picker");if(p){p.remove();return}const i=document.createElement("div");i.className="editor-icon-picker";const l=document.createElement("input");l.type="text",l.className="form-input editor-icon-picker-search",l.placeholder="Search icons\u2026",i.appendChild(l);const o=document.createElement("div");o.className="editor-icon-picker-size-row";const s=document.createElement("label");s.textContent="Size (px)";const r=document.createElement("input");r.type="number",r.className="form-input editor-icon-picker-size",r.placeholder="default",r.min="8",r.max="256",o.appendChild(s),o.appendChild(r),i.appendChild(o);const a=document.createElement("div");a.className="editor-icon-picker-grid",i.appendChild(a);function d(C){!i.contains(C.target)&&C.target!==e&&(i.remove(),document.removeEventListener("click",d,!0))}function h(C){a.textContent="";const x=C?J.filter(S=>S.includes(C.toLowerCase())):J;if(x.length===0){const S=document.createElement("div");S.className="editor-icon-picker-empty",S.textContent="No icons found",a.appendChild(S);return}x.forEach(function(S){const M=document.createElement("button");M.type="button",M.className="editor-icon-picker-item";const v=document.createElement("span");v.setAttribute("data-icon",S);const b=document.createElement("span");b.textContent=S,M.appendChild(v),M.appendChild(b),M.addEventListener("click",function(){i.remove(),document.removeEventListener("click",d,!0);const w=r.value.trim(),L=w?`[icon name="${S}" size="${w}" /]`:`[icon name="${S}" /]`;insertAtCursor(t,L)}),a.appendChild(M)}),Domma.icons.scan(a)}h(""),l.addEventListener("input",function(){h(this.value.trim())});const n=e.getBoundingClientRect(),c=e.closest(".editor-toolbar").getBoundingClientRect();i.style.top=n.bottom-c.top+4+"px";const u=n.left-c.left,k=320,y=c.width;i.style.left=Math.min(u,y-k-8)+"px",e.closest(".editor-toolbar").appendChild(i),requestAnimationFrame(function(){l.focus()}),setTimeout(function(){document.addEventListener("click",d,!0)},0)}function ue(t,e,p,i){const l=document.querySelector(".editor-toolbar-dropdown");if(l){l.remove();return}const o=document.createElement("div");o.className="editor-toolbar-dropdown",p.forEach(function(h){const n=document.createElement("button");if(n.type="button",n.className="editor-toolbar-dropdown-item",h.icon){const u=document.createElement("span");u.setAttribute("data-icon",h.icon),n.appendChild(u)}const c=document.createElement("span");c.textContent=h.label,n.appendChild(c),n.addEventListener("click",function(){o.remove(),document.removeEventListener("click",d,!0),U(h.action,t,e,i)}),o.appendChild(n)});const s=e.getBoundingClientRect(),r=e.closest(".editor-toolbar").getBoundingClientRect();o.style.top=s.bottom-r.top+4+"px";const a=s.left-r.left;o.style.left=Math.min(a,r.width-180-8)+"px",e.closest(".editor-toolbar").appendChild(o),Domma.icons.scan(o);function d(h){!o.contains(h.target)&&h.target!==e&&(o.remove(),document.removeEventListener("click",d,!0))}setTimeout(function(){document.addEventListener("click",d,!0)},0)}function U(t,e,p,i){const{spacerDefault:l,handlers:o}=i;if(typeof t=="function")t(e);else if(t==="block")if(o.block)o.block(e);else{const s=e.selectionStart,r='[block template="" /]';e.value=e.value.substring(0,s)+r+e.value.substring(s),e.selectionStart=e.selectionEnd=s+17,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="component")o.component?o.component(e):pe(e);else if(t==="button")if(o.button)o.button(e);else{const s=e.selectionStart,r=e.selectionEnd,d=`[button href="" variant="primary"]${e.value.substring(s,r)||"Click me"}[/button]`;e.value=e.value.substring(0,s)+d+e.value.substring(r),e.selectionStart=e.selectionEnd=s+14,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="linksc")if(o.linksc)o.linksc(e);else{const s=e.selectionStart,r=e.selectionEnd,d=`[link href=""]${e.value.substring(s,r)||"Link text"}[/link]`;e.value=e.value.substring(0,s)+d+e.value.substring(r),e.selectionStart=e.selectionEnd=s+12,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="colourpick"){const s=e.selectionStart;document.getElementById("dm-colour-overlay")?.remove();const r=document.createElement("div");r.id="dm-colour-overlay",r.style.cssText="position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.5);";const a=document.createElement("div");a.style.cssText="background:var(--dm-surface,#1e1e2e);border:1px solid var(--dm-border,#3a3a5c);border-radius:12px;padding:1.75rem 2rem;display:flex;flex-direction:column;align-items:center;gap:1.25rem;min-width:260px;box-shadow:0 16px 48px rgba(0,0,0,.55);";const d=document.createElement("p");d.textContent="Colour Picker",d.style.cssText="margin:0;font-weight:700;font-size:1rem;letter-spacing:.02em;";const h=document.createElement("input");h.type="color",h.value="#000000",h.style.cssText="width:160px;height:110px;cursor:pointer;border:none;background:none;padding:0;border-radius:6px;overflow:hidden;";const n=document.createElement("div");n.style.cssText="display:flex;align-items:center;gap:.5rem;";const c=document.createElement("input");c.type="text",c.value="#000000",c.className="form-input",c.style.cssText="font-family:monospace;width:100px;text-transform:uppercase;letter-spacing:.05em;";const u=document.createElement("button");u.type="button",u.className="btn btn-ghost btn-sm",u.textContent="Copy";const k=document.createElement("button");k.type="button",k.className="btn btn-primary btn-sm",k.textContent="Insert";const y=()=>r.remove();h.addEventListener("input",()=>{c.value=h.value}),c.addEventListener("input",()=>{/^#[0-9a-f]{6}$/i.test(c.value)&&(h.value=c.value)}),u.addEventListener("click",()=>{const C=document.createElement("input");C.value=c.value,document.body.appendChild(C),C.select(),document.execCommand("copy"),C.remove(),u.textContent="Copied!",setTimeout(()=>{u.textContent="Copy"},1500)}),k.addEventListener("click",()=>{e.selectionStart=e.selectionEnd=s,insertAtCursor(e,c.value),y()}),r.addEventListener("click",C=>{C.target===r&&y()}),n.appendChild(c),n.appendChild(u),n.appendChild(k),a.appendChild(d),a.appendChild(h),a.appendChild(n),r.appendChild(a),document.body.appendChild(r)}else if(t==="link")o.link&&o.link(e);else if(t==="image")o.image&&o.image(e);else if(t==="card")if(o.card)o.card(e);else{const s=e.selectionStart,r=e.selectionEnd,d=`[card title="Card Title"]
|
|
39
|
-
${e.value.substring(s,r)||"Content here"}
|
|
40
|
-
[/card]`;e.value=e.value.substring(0,s)+d+e.value.substring(r),e.selectionStart=s+13,e.selectionEnd=s+23,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="hero")if(o.hero)o.hero(e);else{const s=e.selectionStart,r=e.selectionEnd,d=`[hero title="Hero Title" tagline="A short tagline" size="lg"]
|
|
41
|
-
${e.value.substring(s,r)||"Optional body content here."}
|
|
42
|
-
[/hero]`;e.value=e.value.substring(0,s)+d+e.value.substring(r),e.selectionStart=e.selectionEnd=s+d.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="grid")if(o.grid)o.grid(e);else{const s=e.selectionStart,r=`[grid cols="2" gap="4"]
|
|
6
|
+
`,i),r=o===-1?t.value.length:o+1;t.setSelectionRange(l,r),document.execCommand("copy"),t.setSelectionRange(i,i),E.toast("Line copied",{type:"info",duration:1200})}})}export function insertLine(t,e){const m=t.selectionStart,i=t.value,l=i.lastIndexOf(`
|
|
7
|
+
`,m-1)+1,o=i.indexOf(`
|
|
8
|
+
`,l),r=i.substring(l,o===-1?i.length:o);if(r.startsWith(e)){const s=o===-1?"":i.substring(o);t.value=i.substring(0,l)+r.substring(e.length)+s,t.selectionStart=t.selectionEnd=Math.max(l,m-e.length)}else t.value=i.substring(0,l)+e+i.substring(l),t.selectionStart=t.selectionEnd=m+e.length;t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}const J=["activity","airpods","airport","alert-circle","alert-warning","ambulance","angry","annoyed","apartment","arch","archive","arrow-down","arrow-down-left","arrow-down-right","arrow-left","arrow-right","arrow-up","arrow-up-left","arrow-up-right","astonished","at-sign","attachment","award","badge","ban","bandage","bank","banknote","barbell","barcode","barn","baseball","basketball","battery","battery-charging","bauble","bell","bell-off","bells","bicycle","bitcoin","blood-drop","blush","bold","bone","book","book-closed","book-open","bookmark","bookmark-filled","bowling","box","boxing-glove","brain","bridge","briefcase","building","bus","cabin","cake","calculator","calendar","camera","camera-off","candy-cane","capsule","car","cart","cart-add","cash","cast","castle","chart-area","chart-bar","chart-bar-horizontal","chart-candlestick","chart-line","chart-pie","chat","chat-alt","check","check-circle","check-circle-filled","check-square","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-down","chevrons-left","chevrons-right","chevrons-up","church","circle","circle-filled","clear-format","clipboard","clipboard-check","clipboard-list","clock","close","cloud","cloud-download","cloud-drizzle","cloud-lightning","cloud-off","cloud-rain","cloud-sun","cloud-upload","code","code-block","code-inline","cog","coins","columns","comment","compass","component","confused","cool","copy","corner-down-left","corner-down-right","corner-up-left","corner-up-right","court","cpu","credit-card","crown","crutch","cry","currency-dollar","currency-euro","currency-pound","cycling","database","dead","desktop","disappointed","dna","document","document-add","document-check","document-remove","document-text","dollar-sign","dome","dot","dots-horizontal","dots-vertical","download","droplet","droplets","dumbbell","edit","embed","emoji-happy","emoji-sad","euro-sign","exclamation","expand","expressionless","external-link","eye","eye-medical","eye-off","factory","fast-forward","feather","file-code","file-text","file-zip","fill","film","filter","fire","first-aid","fishing","flag","fog","folder","folder-add","folder-minus","folder-open","folder-plus","folder-remove","football","fortress","fuel","gamepad","garage","gauge","gift","git-branch","github","globe","golf","grid","grin","growth","hard-drive","hash","haze","heading-1","heading-2","heading-3","headphones","heart","heart-eyes","heart-filled","heart-pulse","heartbeat","help-circle","holly","home","hospital","hotel","house","image","image-add","images","inbox","indent","info","info-filled","investment","invoice","italic","joy","joystick","key","kettlebell","keyboard","laptop","laugh","layers","layout","library","lighthouse","lightning","link","link-2","link-add","linkedin","list","list-bullet","list-numbered","loader","loading","lock","log-in","log-out","lungs","mail","mail-open","map","map-pin","mask","maximize","medal","medical-cross","menu","menu-alt","message-circle","message-square","mic","mic-off","microscope","minimize","minus","minus-circle","minus-square","monitor","monument","moon","moon-star","more-horizontal","more-vertical","mosque","motorcycle","mountain","mouse","mouse-pointer","move","museum","music","nerd","neutral","notification","obelisk","office","outdent","package","palette","panel-bottom","panel-left","panel-right","panel-top","paperclip","parking","pause","pause-filled","percent","phone","phone-call","phone-incoming","phone-off","phone-outgoing","piggy-bank","pill","pill-bottle","pin","play","play-circle","play-filled","plug","plus","plus-circle","plus-square","podium","pound-sign","printer","pulse","pyramid","qrcode","question","quote","racket","radio","rage","rain","rainbow","receipt","redo","refresh","refresh-cw","reindeer","rewind","road","rotate-ccw","rotate-cw","router","rss","running","sad","safe","save","scale","scale-weight","school","search","send","server","settings","share","share-2","share-alt","shield","shield-alert","shield-check","shield-x","shipping","shocked","shopping-bag","shrink","sick","sidebar-left","sidebar-right","silly","skate","ski","skip-back","skip-forward","skyscraper","sleepy","sleigh","sliders","smartphone","smartwatch","smile","snow","snowflake","snowman","sob","soccer","sort","sparkles","speaker","spinner","square","stadium","star","star-decoration","star-eyes","star-filled","stethoscope","stop","stop-filled","stopwatch","store","strikethrough","sun","sunrise","sunset","surfboard","surprised","swimming","sync","syringe","tablet","tablet-smartphone","tag","tags","target","taxi","temple","tennis","tent","terminal","test-tube","text-center","text-left","text-right","thermometer","thermometer-medical","thermometer-sun","thinking","thumb-down","thumb-up","tongue","tool","tooth","tower","train-station","trash","tree","trending-down","trending-neutral","trending-up","trophy","truck","tv","tv-minimal","twitter","type","umbrella","underline","undo","university","unlink","unlock","upload","usb","user","user-add","user-check","user-group","user-plus","user-remove","users","vaccine","van","vault","video","video-off","volleyball","volume","volume-down","volume-mute","volume-off","volume-up","wallet","warehouse","warning","warning-filled","watch","webcam","wheelchair","whistle","wifi","wifi-off","wind","windmill","wink","wreath","x","x-circle","x-circle-filled","yoga","youtube","zany","zap"];function le(t,e,m){const i=document.querySelector(".editor-spacer-picker");if(i){i.remove();return}const l=document.createElement("div");l.className="editor-spacer-picker";const o=document.createElement("div");o.className="editor-spacer-picker-label",o.textContent="Spacer height",l.appendChild(o);const r=document.createElement("div");r.className="editor-spacer-picker-row";const s=document.createElement("input");s.type="range",s.className="editor-spacer-slider",s.min="4",s.max="200",s.step="4",s.value=m;const p=document.createElement("span");p.className="editor-spacer-slider-value",p.textContent=m+"px",s.addEventListener("input",function(){p.textContent=this.value+"px"}),r.appendChild(s),r.appendChild(p),l.appendChild(r);const d=document.createElement("button");d.type="button",d.className="btn btn-primary btn-sm editor-spacer-insert-btn",d.textContent="Insert",l.appendChild(d);function f(k){!l.contains(k.target)&&k.target!==e&&(l.remove(),document.removeEventListener("click",f,!0))}d.addEventListener("click",function(){l.remove(),document.removeEventListener("click",f,!0),insertAtCursor(t,`[spacer size="${s.value}" /]
|
|
9
|
+
`)});const n=e.getBoundingClientRect(),c=e.closest(".editor-toolbar").getBoundingClientRect();l.style.top=n.bottom-c.top+4+"px";const a=n.left-c.left;l.style.left=Math.min(a,c.width-240-8)+"px",e.closest(".editor-toolbar").appendChild(l),setTimeout(function(){document.addEventListener("click",f,!0)},0)}function ce(t,e){const m=document.querySelector(".editor-icon-picker");if(m){m.remove();return}const i=document.createElement("div");i.className="editor-icon-picker";const l=document.createElement("input");l.type="text",l.className="form-input editor-icon-picker-search",l.placeholder="Search icons\u2026",i.appendChild(l);const o=document.createElement("div");o.className="editor-icon-picker-size-row";const r=document.createElement("label");r.textContent="Size (px)";const s=document.createElement("input");s.type="number",s.className="form-input editor-icon-picker-size",s.placeholder="default",s.min="8",s.max="256",o.appendChild(r),o.appendChild(s),i.appendChild(o);const p=document.createElement("div");p.className="editor-icon-picker-grid",i.appendChild(p);function d(C){!i.contains(C.target)&&C.target!==e&&(i.remove(),document.removeEventListener("click",d,!0))}function f(C){p.textContent="";const x=C?J.filter(S=>S.includes(C.toLowerCase())):J;if(x.length===0){const S=document.createElement("div");S.className="editor-icon-picker-empty",S.textContent="No icons found",p.appendChild(S);return}x.forEach(function(S){const M=document.createElement("button");M.type="button",M.className="editor-icon-picker-item";const v=document.createElement("span");v.setAttribute("data-icon",S);const h=document.createElement("span");h.textContent=S,M.appendChild(v),M.appendChild(h),M.addEventListener("click",function(){i.remove(),document.removeEventListener("click",d,!0);const w=s.value.trim(),L=w?`[icon name="${S}" size="${w}" /]`:`[icon name="${S}" /]`;insertAtCursor(t,L)}),p.appendChild(M)}),Domma.icons.scan(p)}f(""),l.addEventListener("input",function(){f(this.value.trim())});const n=e.getBoundingClientRect(),c=e.closest(".editor-toolbar").getBoundingClientRect();i.style.top=n.bottom-c.top+4+"px";const a=n.left-c.left,k=320,y=c.width;i.style.left=Math.min(a,y-k-8)+"px",e.closest(".editor-toolbar").appendChild(i),requestAnimationFrame(function(){l.focus()}),setTimeout(function(){document.addEventListener("click",d,!0)},0)}function ae(t,e,m,i){const l=document.querySelector(".editor-toolbar-dropdown");if(l){l.remove();return}const o=document.createElement("div");o.className="editor-toolbar-dropdown",m.forEach(function(f){const n=document.createElement("button");if(n.type="button",n.className="editor-toolbar-dropdown-item",f.icon){const a=document.createElement("span");a.setAttribute("data-icon",f.icon),n.appendChild(a)}const c=document.createElement("span");c.textContent=f.label,n.appendChild(c),n.addEventListener("click",function(){o.remove(),document.removeEventListener("click",d,!0),U(f.action,t,e,i)}),o.appendChild(n)});const r=e.getBoundingClientRect(),s=e.closest(".editor-toolbar").getBoundingClientRect();o.style.top=r.bottom-s.top+4+"px";const p=r.left-s.left;o.style.left=Math.min(p,s.width-180-8)+"px",e.closest(".editor-toolbar").appendChild(o),Domma.icons.scan(o);function d(f){!o.contains(f.target)&&f.target!==e&&(o.remove(),document.removeEventListener("click",d,!0))}setTimeout(function(){document.addEventListener("click",d,!0)},0)}function U(t,e,m,i){const{spacerDefault:l,handlers:o}=i;if(typeof t=="function")t(e);else if(t==="block")if(o.block)o.block(e);else{const r=e.selectionStart,s='[block template="" /]';e.value=e.value.substring(0,r)+s+e.value.substring(r),e.selectionStart=e.selectionEnd=r+17,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="component")o.component?o.component(e):de(e);else if(t==="button")if(o.button)o.button(e);else{const r=e.selectionStart,s=e.selectionEnd,d=`[button href="" variant="primary"]${e.value.substring(r,s)||"Click me"}[/button]`;e.value=e.value.substring(0,r)+d+e.value.substring(s),e.selectionStart=e.selectionEnd=r+14,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="linksc")if(o.linksc)o.linksc(e);else{const r=e.selectionStart,s=e.selectionEnd,d=`[link href=""]${e.value.substring(r,s)||"Link text"}[/link]`;e.value=e.value.substring(0,r)+d+e.value.substring(s),e.selectionStart=e.selectionEnd=r+12,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="colourpick"){const r=e.selectionStart;document.getElementById("dm-colour-overlay")?.remove();const s=document.createElement("div");s.id="dm-colour-overlay",s.style.cssText="position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.5);";const p=document.createElement("div");p.style.cssText="background:var(--dm-surface,#1e1e2e);border:1px solid var(--dm-border,#3a3a5c);border-radius:12px;padding:1.75rem 2rem;display:flex;flex-direction:column;align-items:center;gap:1.25rem;min-width:260px;box-shadow:0 16px 48px rgba(0,0,0,.55);";const d=document.createElement("p");d.textContent="Colour Picker",d.style.cssText="margin:0;font-weight:700;font-size:1rem;letter-spacing:.02em;";const f=document.createElement("input");f.type="color",f.value="#000000",f.style.cssText="width:160px;height:110px;cursor:pointer;border:none;background:none;padding:0;border-radius:6px;overflow:hidden;";const n=document.createElement("div");n.style.cssText="display:flex;align-items:center;gap:.5rem;";const c=document.createElement("input");c.type="text",c.value="#000000",c.className="form-input",c.style.cssText="font-family:monospace;width:100px;text-transform:uppercase;letter-spacing:.05em;";const a=document.createElement("button");a.type="button",a.className="btn btn-ghost btn-sm",a.textContent="Copy";const k=document.createElement("button");k.type="button",k.className="btn btn-primary btn-sm",k.textContent="Insert";const y=()=>s.remove();f.addEventListener("input",()=>{c.value=f.value}),c.addEventListener("input",()=>{/^#[0-9a-f]{6}$/i.test(c.value)&&(f.value=c.value)}),a.addEventListener("click",()=>{const C=document.createElement("input");C.value=c.value,document.body.appendChild(C),C.select(),document.execCommand("copy"),C.remove(),a.textContent="Copied!",setTimeout(()=>{a.textContent="Copy"},1500)}),k.addEventListener("click",()=>{e.selectionStart=e.selectionEnd=r,insertAtCursor(e,c.value),y()}),s.addEventListener("click",C=>{C.target===s&&y()}),n.appendChild(c),n.appendChild(a),n.appendChild(k),p.appendChild(d),p.appendChild(f),p.appendChild(n),s.appendChild(p),document.body.appendChild(s)}else if(t==="link")o.link&&o.link(e);else if(t==="image")o.image&&o.image(e);else if(t==="card")if(o.card)o.card(e);else{const r=e.selectionStart,s=e.selectionEnd,d=`[card title="Card Title"]
|
|
10
|
+
${e.value.substring(r,s)||"Content here"}
|
|
11
|
+
[/card]`;e.value=e.value.substring(0,r)+d+e.value.substring(s),e.selectionStart=r+13,e.selectionEnd=r+23,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="hero")if(o.hero)o.hero(e);else{const r=e.selectionStart,s=e.selectionEnd,d=`[hero title="Hero Title" tagline="A short tagline" size="lg"]
|
|
12
|
+
${e.value.substring(r,s)||"Optional body content here."}
|
|
13
|
+
[/hero]`;e.value=e.value.substring(0,r)+d+e.value.substring(s),e.selectionStart=e.selectionEnd=r+d.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="grid")if(o.grid)o.grid(e);else{const r=e.selectionStart,s=`[grid cols="2" gap="4"]
|
|
43
14
|
[col]
|
|
44
15
|
Column 1
|
|
45
16
|
[/col]
|
|
@@ -47,7 +18,7 @@ Column 1
|
|
|
47
18
|
Column 2
|
|
48
19
|
[/col]
|
|
49
20
|
[/grid]
|
|
50
|
-
`;e.value=e.value.substring(0,
|
|
21
|
+
`;e.value=e.value.substring(0,r)+s+e.value.substring(r),e.selectionStart=e.selectionEnd=r+s.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="badge"){const r=e.selectionStart,s=e.selectionEnd,d=`[badge variant="primary"]${e.value.substring(r,s)||"New"}[/badge]`;e.value=e.value.substring(0,r)+d+e.value.substring(s),e.selectionStart=r+16,e.selectionEnd=r+23,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="timeline")if(o.timeline)o.timeline(e);else{const r=e.selectionStart,s=`[timeline layout="vertical"]
|
|
51
22
|
[event title="First Event" date="${new Date().toISOString().slice(0,10)}" status="completed"]
|
|
52
23
|
Describe this event.
|
|
53
24
|
[/event]
|
|
@@ -55,21 +26,21 @@ Describe this event.
|
|
|
55
26
|
Describe this event.
|
|
56
27
|
[/event]
|
|
57
28
|
[/timeline]
|
|
58
|
-
`;e.value=e.value.substring(0,
|
|
29
|
+
`;e.value=e.value.substring(0,r)+s+e.value.substring(r),e.selectionStart=e.selectionEnd=r+s.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="effects")o.effects&&o.effects(e);else if(t==="spacerpick")le(e,m,l);else if(t==="iconpick")ce(e,m);else if(t==="listgroup")o.listgroup?o.listgroup(e):insertAtCursor(e,`[listgroup]
|
|
59
30
|
[item]Item 1[/item]
|
|
60
31
|
[item]Item 2[/item]
|
|
61
32
|
[item]Item 3[/item]
|
|
62
33
|
[/listgroup]
|
|
63
|
-
`);else if(t==="collection")o.collection?o.collection(e):insertAtCursor(e,'[collection slug="" display="table" /]');else if(t==="view")o.view&&o.view(e);else if(t==="cta")o.cta&&o.cta(e);else if(t==="form")o.form?o.form(e):insertAtCursor(e,'[form slug="" /]');else if(t==="tabs")o.tabs&&o.tabs(e);else if(t==="banner")o.banner&&o.banner(e);else if(t==="scribe")if(o.scribe)o.scribe(e);else{const
|
|
34
|
+
`);else if(t==="collection")o.collection?o.collection(e):insertAtCursor(e,'[collection slug="" display="table" /]');else if(t==="view")o.view&&o.view(e);else if(t==="cta")o.cta&&o.cta(e);else if(t==="form")o.form?o.form(e):insertAtCursor(e,'[form slug="" /]');else if(t==="tabs")o.tabs&&o.tabs(e);else if(t==="banner")o.banner&&o.banner(e);else if(t==="scribe")if(o.scribe)o.scribe(e);else{const r=e.selectionStart,s=`[scribe]
|
|
64
35
|
[render]Type text here.[/render]
|
|
65
36
|
[wait]1500[/wait]
|
|
66
37
|
[undo all="true" /]
|
|
67
38
|
[render]More text.[/render]
|
|
68
39
|
[/scribe]
|
|
69
|
-
`;e.value=e.value.substring(0,
|
|
40
|
+
`;e.value=e.value.substring(0,r)+s+e.value.substring(r),e.selectionStart=e.selectionEnd=r+s.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="accordion")if(o.accordion)o.accordion(e);else{const r=e.selectionStart,s=`[accordion]
|
|
70
41
|
[item title="Item 1"]Content here.[/item]
|
|
71
42
|
[item title="Item 2"]Content here.[/item]
|
|
72
43
|
[/accordion]
|
|
73
|
-
`;e.value=e.value.substring(0,
|
|
44
|
+
`;e.value=e.value.substring(0,r)+s+e.value.substring(r),e.selectionStart=e.selectionEnd=r+s.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="text"){let n=function(b,u){const g=document.createElement("div"),z=document.createElement("label");return z.style.cssText=d,z.textContent=b,g.appendChild(z),g.appendChild(u),g},c=function(b){const u=document.createElement("select");return u.style.cssText=f,[["","\u2014 default \u2014"],...b].forEach(([g,z])=>{const O=document.createElement("option");O.value=g,O.textContent=z,u.appendChild(O)}),u},a=function(b,u){const g=document.createElement("input");return g.type="text",g.placeholder=b||"",g.value=u||"",g.style.cssText=f,g},k=function(b){const u=document.createElement("label");u.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;";const g=document.createElement("input");g.type="checkbox";const z=document.createElement("span");return z.style.cssText="font-size:.85em;color:var(--dm-text,#eee);",z.textContent=b,u.appendChild(g),u.appendChild(z),{wrap:u,cb:g}},y=function(b,u){const g=document.createElement("div");return g.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:.5rem;",g.appendChild(b),g.appendChild(u),g},C=function(b){const u=document.createElement("div");return u.style.cssText="border-top:1px solid var(--dm-border,#333);padding-top:.5rem;margin-top:.1rem;font-size:.65rem;font-weight:700;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.08em;",u.textContent=b,u},_=function(){const b=[];M.value&&b.push(`font-size:${ee[M.value]||M.value}`);const u=parseFloat(v.value);!isNaN(u)&&u>0&&b.push(`font-size:${u}pt`),L.checked?b.push("font-weight:700"):h.value&&b.push(`font-weight:${te[h.value]||h.value}`),T.checked&&b.push("font-style:italic");const g=B.value.trim();g&&b.push(`color:${Y[g]||g}`),P.value&&b.push(`font-family:${oe[P.value]}`),A.value&&b.push(`text-transform:${ie[A.value]}`),W.value&&b.push(`text-decoration:${re[W.value]}`),H.value&&b.push(`letter-spacing:${ne[H.value]}`),R.value&&(b.push("display:block"),b.push(`text-align:${R.value}`)),V.value.trim()&&b.push(V.value.trim()),q.style.cssText=b.join(";"),q.textContent=S.value||"Preview text"};const r=e.selectionStart,s=e.selectionEnd,p=e.value.substring(r,s)||"",d="display:block;font-size:.7rem;font-weight:600;color:var(--dm-text-muted,#aaa);text-transform:uppercase;letter-spacing:.05em;",f="width:100%;padding:.4rem .6rem;background:var(--dm-input-bg,#1a1a1a);border:1px solid var(--dm-border,#333);border-radius:4px;color:var(--dm-text,#eee);font-size:.9em;",x=document.createElement("div");x.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.6rem;overflow-y:auto;max-height:75vh;";const S=a("Text to style\u2026",p);x.appendChild(n("Content",S)),x.appendChild(C("Typography"));const M=c([["xs","xs \u2014 0.75rem"],["sm","sm \u2014 0.875rem"],["base","base \u2014 1rem"],["lg","lg \u2014 1.125rem"],["xl","xl \u2014 1.25rem"],["2xl","2xl \u2014 1.5rem"],["3xl","3xl \u2014 1.875rem"],["4xl","4xl \u2014 2.25rem"]]),v=a("pt value (overrides Size)");x.appendChild(y(n("Size",M),n("Point Size (pt)",v)));const h=c([["thin","Thin (100)"],["light","Light (300)"],["normal","Normal (400)"],["medium","Medium (500)"],["semibold","Semibold (600)"],["bold","Bold (700)"],["extrabold","Extrabold (800)"],["black","Black (900)"]]),{wrap:w,cb:L}=k("Bold (overrides Weight)"),{wrap:N,cb:T}=k("Italic"),j=document.createElement("div");j.style.cssText="display:flex;flex-direction:column;gap:.4rem;justify-content:flex-end;",j.appendChild(w),j.appendChild(N),x.appendChild(y(n("Weight",h),j)),x.appendChild(C("Appearance"));const B=a("e.g. primary, #ff0000"),P=c([["Georgia","Georgia (serif)"],["Arial","Arial (sans-serif)"],["Verdana","Verdana (sans-serif)"],["Courier New","Courier New (mono)"],["Times New Roman","Times New Roman (serif)"],["Trebuchet MS","Trebuchet MS"]]);x.appendChild(y(n("Colour",B),n("Font",P))),x.appendChild(C("Formatting"));const A=c([["upper","Uppercase"],["lower","Lowercase"],["capitalize","Capitalise"],["none","None"]]),W=c([["underline","Underline"],["line-through","Line-through"],["none","None"]]);x.appendChild(y(n("Transform",A),n("Decoration",W)));const H=c([["tight","Tight"],["normal","Normal"],["wide","Wide"],["wider","Wider"]]),R=c([["left","Left"],["center","Centre"],["right","Right"],["justify","Justify"]]);x.appendChild(y(n("Spacing",H),n("Align",R))),x.appendChild(C("Advanced"));const V=a("e.g. margin-top:1rem;display:block");x.appendChild(n("Style",V));const F=a("CSS class(es)"),G=a("ID");x.appendChild(y(n("Class",F),n("ID",G)));const K=document.createElement("div");K.style.cssText="padding:.75rem;background:var(--dm-surface-subtle,#111);border-radius:4px;min-height:2.5rem;display:flex;align-items:center;";const q=document.createElement("span");q.textContent=p||"Preview text",K.appendChild(q),x.appendChild(n("Preview",K));const Y={primary:"var(--dm-color-primary)",secondary:"var(--dm-color-secondary)",muted:"var(--dm-text-muted)",danger:"var(--dm-color-danger)",success:"var(--dm-color-success)",warning:"var(--dm-color-warning)",info:"var(--dm-color-info)"},ee={xs:".75rem",sm:".875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},te={thin:"100",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},ne={tight:"-0.05em",normal:"0em",wide:"0.05em",wider:"0.1em"},oe={Georgia:"Georgia,serif",Arial:"Arial,sans-serif",Verdana:"Verdana,sans-serif","Courier New":"'Courier New',monospace","Times New Roman":"'Times New Roman',serif","Trebuchet MS":"'Trebuchet MS',sans-serif"},ie={upper:"uppercase",lower:"lowercase",capitalize:"capitalize",none:"none"},re={underline:"underline","line-through":"line-through",none:"none"};L.addEventListener("change",()=>{h.disabled=L.checked,L.checked&&(h.value=""),_()}),[M,h,P,A,W,H,R].forEach(b=>{b.addEventListener("change",_)}),[B,S,V,v].forEach(b=>{b.addEventListener("input",_)}),T.addEventListener("change",_);const D=document.createElement("button");D.type="button",D.className="btn btn-primary",D.textContent="Insert",x.appendChild(D);const Z=E.slideover({title:"Style Text",size:"md",position:"right",content:x});Z.open(),D.addEventListener("click",()=>{const b=S.value;if(!b.trim())return;const u=[];M.value&&u.push(`size="${M.value}"`);const g=parseFloat(v.value);!isNaN(g)&&g>0&&u.push(`point-size="${g}"`),L.checked?u.push("bold"):h.value&&u.push(`weight="${h.value}"`),T.checked&&u.push("italic"),B.value.trim()&&u.push(`color="${B.value.trim()}"`),P.value&&u.push(`font="${P.value}"`),A.value&&u.push(`transform="${A.value}"`),W.value&&u.push(`decoration="${W.value}"`),H.value&&u.push(`spacing="${H.value}"`),R.value&&u.push(`align="${R.value}"`),V.value.trim()&&u.push(`style="${V.value.trim().replace(/"/g,""")}"`),F.value.trim()&&u.push(`class="${F.value.trim()}"`),G.value.trim()&&u.push(`id="${G.value.trim()}"`);const O=`[text${u.length?" "+u.join(" "):""}]${b}[/text]`;Z.close(),insertAtCursor(e,O),e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()})}else t==="help"&&o.help&&o.help(e)}const Q=[{icon:"bold",title:"Bold (Ctrl+B)",action:t=>wrapSelection(t,"**","**")},{icon:"italic",title:"Italic (Ctrl+I)",action:t=>wrapSelection(t,"_","_")},{icon:"strikethrough",title:"Strikethrough",action:t=>wrapSelection(t,"~~","~~")},"|",{type:"dropdown",icon:"heading-1",title:"Headings",items:[{label:"Heading 1",icon:"heading-1",action:t=>insertLine(t,"# ")},{label:"Heading 2",icon:"heading-2",action:t=>insertLine(t,"## ")},{label:"Heading 3",icon:"heading-3",action:t=>insertLine(t,"### ")}]},"|",{icon:"list-bullet",title:"Bullet list",action:t=>insertLine(t,"- ")},{icon:"list-numbered",title:"Numbered list",action:t=>insertLine(t,"1. ")},"|",{type:"dropdown",icon:"quote",title:"Paragraph",items:[{label:"Blockquote",icon:"quote",action:t=>insertLine(t,"> ")},{label:"Horizontal rule",icon:"minus-circle",action:t=>insertAtCursor(t,`
|
|
74
45
|
---
|
|
75
|
-
`)}]},"|",{type:"dropdown",icon:"code-inline",title:"Code",items:[{label:"Inline code",icon:"code-inline",action:t=>wrapSelection(t,"`","`")},{label:"Code block",icon:"code-block",action:t=>wrapSelection(t,"\n```\n","\n```\n")}]},"|",{type:"dropdown",icon:"plus-circle",title:"Insert",items:[{label:"Accordion",icon:"accordion-insert",action:"accordion"},{label:"Banner",icon:"banner-insert",action:"banner"},{label:"Badge",icon:"badge",action:"badge"},{label:"Block",icon:"layout",action:"block"},{label:"Button",icon:"btn-insert",action:"button"},{label:"Card",icon:"card",action:"card"},{label:"Colour Picker",icon:"colour-picker",action:"colourpick"},{label:"Collection",icon:"database",action:"collection"},{label:"Component",icon:"component",action:"component"},{label:"CTA Button",icon:"mouse-pointer",action:"cta"},{label:"Form",icon:"file-text",action:"form"},{label:"Grid",icon:"columns",action:"grid"},{label:"Hero",icon:"hero",action:"hero"},{label:"Icon",icon:"icon-pick",action:"iconpick"},{label:"Image",icon:"image-add",action:"image"},{label:"Link",icon:"link-shortcode",action:"linksc"},{label:"List Group",icon:"list",action:"listgroup"},{label:"Scribe",icon:"scribe-insert",action:"scribe"},{label:"Spacer",icon:"spacer-insert",action:"spacerpick"},{label:"Tabs",icon:"layout-list",action:"tabs"},{label:"Text",icon:"text-style",action:"text"},{label:"Timeline",icon:"activity",action:"timeline"},{label:"View",icon:"eye",action:"view"}]},"|",{icon:"sparkles",title:"Effects",action:"effects"},{icon:"help-circle",title:"Editor help",action:"help"}];export function createToolbar(t,e,p={}){se();const i={link:null,image:null,card:null,grid:null,help:null,effects:null,collection:null,view:null,cta:null,form:null,button:null,linksc:null,tabs:null,accordion:null,hero:null,banner:null},l=p.spacerDefault??40,o=t.get(0),s=e.get(0);s.textContent="",Q.forEach((n,c)=>{if(n==="|"){const u=document.createElement("span");u.className="editor-toolbar-sep",s.appendChild(u)}else{const u=document.createElement("button");u.className=n.type==="dropdown"?"editor-toolbar-btn editor-toolbar-dropdown-trigger":"editor-toolbar-btn",u.setAttribute("data-tooltip",n.title),u.setAttribute("data-idx",String(c)),u.type="button";const k=document.createElement("span");if(k.setAttribute("data-icon",n.icon),u.appendChild(k),n.type==="dropdown"){const y=document.createElement("span");y.className="editor-toolbar-caret",y.textContent="\u25BE",u.appendChild(y)}s.appendChild(u)}});const r=document.createElement("div");r.className="editor-toolbar-right",[{mode:"split",icon:"columns",label:"Split view",active:!0},{mode:"write",icon:"file-text",label:"Write only",active:!1},{mode:"preview",icon:"eye",label:"Preview only",active:!1}].forEach(n=>{const c=document.createElement("button");c.className="editor-view-btn"+(n.active?" active":""),c.setAttribute("data-mode",n.mode),c.setAttribute("data-tooltip",n.label),c.type="button";const u=document.createElement("span");u.setAttribute("data-icon",n.icon),c.appendChild(u),r.appendChild(c)});const a=document.createElement("span");a.className="editor-toolbar-sep",r.appendChild(a);const d=document.createElement("button");d.id="fullscreen-btn",d.className="editor-toolbar-btn",d.setAttribute("data-tooltip","Toggle fullscreen"),d.type="button";const h=document.createElement("span");return h.setAttribute("data-icon","expand"),d.appendChild(h),r.appendChild(d),s.appendChild(r),Domma.icons.scan(),s.querySelectorAll("[data-tooltip]").forEach(n=>{E.tooltip(n,{content:n.getAttribute("data-tooltip"),position:"top"})}),e.on("click",".editor-toolbar-btn[data-idx]",function(){const n=parseInt($(this).data("idx"),10),c=Q[n];if(!c||c==="|")return;const u=e.get(0).querySelector(`[data-idx="${n}"]`),k={spacerDefault:l,handlers:i};c.type==="dropdown"?ue(o,u,c.items,k):U(c.action,o,u,k)}),attachEditorKeybindings(o),o.addEventListener("keydown",n=>{const c=n.key.toLowerCase();(n.ctrlKey||n.metaKey)&&(c==="b"?(n.preventDefault(),wrapSelection(o,"**","**")):c==="i"?(n.preventDefault(),wrapSelection(o,"_","_")):c==="k"&&(n.preventDefault(),i.link&&i.link(o)))}),{$toolbar:e,onLink(n){i.link=n},onImage(n){i.image=n},onCard(n){i.card=n},onGrid(n){i.grid=n},onHelp(n){i.help=n},onEffects(n){i.effects=n},onCollection(n){i.collection=n},onBlock(n){i.block=n},onView(n){i.view=n},onCta(n){i.cta=n},onForm(n){i.form=n},onButton(n){i.button=n},onLinkShortcode(n){i.linksc=n},onTabs(n){i.tabs=n},onAccordion(n){i.accordion=n},onHero(n){i.hero=n},onBanner(n){i.banner=n},onListGroup(n){i.listgroup=n},onScribe(n){i.scribe=n},onTimeline(n){i.timeline=n}}}async function pe(t){const{api:e}=await import("../api.js");let p;try{p=await e.components.list()}catch(v){E.toast(v.message||"Failed to load components.",{type:"error"});return}if(!p?.length){E.toast("No components yet. Create one in Data \u2192 Components first.",{type:"info"});return}const i=E.slideover({title:"Insert Component",size:"lg",position:"right"}),l=document.createElement("div");l.style.cssText="display:flex;flex-direction:column;gap:1rem;padding:.75rem;min-height:100%;";const o=document.createElement("div");o.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",o.textContent="Gallery";const s=document.createElement("div");s.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:.5rem;";const r=document.createElement("div");r.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",r.textContent="Props";const a=document.createElement("div");a.style.cssText="padding:.6rem;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;min-height:40px;",a.textContent="Select a component from the gallery above.";const d=document.createElement("div");d.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",d.textContent="Preview";const h=document.createElement("iframe");h.src="/admin/preview/component-preview.html",h.style.cssText="width:100%;min-height:180px;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;background:#fff;";const n=document.createElement("div");n.style.cssText="display:flex;justify-content:flex-end;gap:.5rem;margin-top:auto;padding-top:.75rem;border-top:1px solid var(--dm-border,rgba(255,255,255,.08));";const c=document.createElement("button");c.className="btn btn-ghost",c.textContent="Cancel";const u=document.createElement("button");u.className="btn btn-primary",u.textContent="Insert",u.disabled=!0,n.appendChild(c),n.appendChild(u),l.appendChild(o),l.appendChild(s),l.appendChild(r),l.appendChild(a),l.appendChild(d),l.appendChild(h),l.appendChild(n),i.setContent(l),i.open();let k=null,y={};function C(){s.replaceChildren();for(const v of p){const b=document.createElement("button");b.type="button",b.className="btn btn-ghost",b.style.cssText="display:flex;flex-direction:column;align-items:flex-start;gap:.25rem;padding:.6rem;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;text-align:left;";const w=document.createElement("strong");w.style.cssText="font-size:.9rem;",w.textContent=v.name;const L=document.createElement("span");L.style.cssText="font-size:.72rem;color:var(--dm-text-muted,#888);",L.textContent=`${Object.keys(v.props||{}).length} prop(s)`,b.appendChild(w),b.appendChild(L),b.addEventListener("click",()=>x(v)),s.appendChild(b)}}function x(v){k=v,y={};for(const[b,w]of Object.entries(v.props||{}))y[b]=w.default!==void 0?w.default:"";u.disabled=!1,S(),M()}function S(){a.replaceChildren();const v=Object.entries(k.props||{});if(v.length===0){const b=document.createElement("p");b.className="text-muted",b.style.margin="0",b.textContent="This component takes no props.",a.appendChild(b);return}for(const[b,w]of v){const L=document.createElement("div");L.style.cssText="display:flex;align-items:center;gap:.5rem;margin-bottom:.4rem;";const z=document.createElement("label");z.style.cssText="font-size:.8rem;min-width:120px;color:var(--dm-text-muted,#aaa);",z.textContent=w.label||b,L.appendChild(z);const T=me(w);he(T,w,y[b]),T.addEventListener("input",()=>{y[b]=X(T,w),h.contentWindow?.postMessage({type:"update",payload:{props:y}},"*")}),T.addEventListener("change",()=>{y[b]=X(T,w),h.contentWindow?.postMessage({type:"update",payload:{props:y}},"*")}),L.appendChild(T),a.appendChild(L)}}async function M(){if(k)try{const v=await fetch(`/api/components/${encodeURIComponent(k.name)}.js`);if(!v.ok)throw new Error(`Failed to load component (${v.status})`);const b=await v.text();h.contentWindow?.postMessage({type:"remount",payload:{compiledJs:b,tagName:`dm-${k.name}`,props:y}},"*")}catch(v){E.toast(v.message||"Failed to load preview.",{type:"error"})}}c.addEventListener("click",()=>i.close()),u.addEventListener("click",()=>{if(!k)return;const v=t.selectionStart,b=t.selectionEnd,w=Object.entries(y).map(([z,T])=>{const j=z.replace(/([A-Z])/g,"-$1").toLowerCase(),B=String(T??"").replace(/"/g,""");return`${j}="${B}"`}).join(" "),L=`[component name="${k.name}"${w?" "+w:""} /]`;t.value=t.value.substring(0,v)+L+t.value.substring(b),t.selectionStart=t.selectionEnd=v+L.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus(),i.close()}),C()}function me(t){let e;return t.type==="number"?(e=document.createElement("input"),e.type="number",e.className="form-input form-input--sm"):t.type==="boolean"?(e=document.createElement("input"),e.type="checkbox",e.className="form-check"):t.type==="array"||t.type==="object"?(e=document.createElement("textarea"),e.rows=2,e.className="form-input form-input--sm",e.style.fontFamily="var(--dm-font-mono, monospace)"):(e=document.createElement("input"),e.type="text",e.className="form-input form-input--sm"),e.style.flex="1",e}function X(t,e){if(e.type==="number")return t.value===""?null:Number(t.value);if(e.type==="boolean")return!!t.checked;if(e.type==="array"||e.type==="object")try{return JSON.parse(t.value||"null")}catch{return null}return t.value}function he(t,e,p){e.type==="boolean"?t.checked=!!p:e.type==="array"||e.type==="object"?t.value=JSON.stringify(p??null):t.value=p??""}
|
|
46
|
+
`)}]},"|",{type:"dropdown",icon:"code-inline",title:"Code",items:[{label:"Inline code",icon:"code-inline",action:t=>wrapSelection(t,"`","`")},{label:"Code block",icon:"code-block",action:t=>wrapSelection(t,"\n```\n","\n```\n")}]},"|",{type:"dropdown",icon:"plus-circle",title:"Insert",items:[{label:"Accordion",icon:"accordion-insert",action:"accordion"},{label:"Banner",icon:"banner-insert",action:"banner"},{label:"Badge",icon:"badge",action:"badge"},{label:"Block",icon:"layout",action:"block"},{label:"Button",icon:"btn-insert",action:"button"},{label:"Card",icon:"card",action:"card"},{label:"Colour Picker",icon:"colour-picker",action:"colourpick"},{label:"Collection",icon:"database",action:"collection"},{label:"Component",icon:"component",action:"component"},{label:"CTA Button",icon:"mouse-pointer",action:"cta"},{label:"Form",icon:"file-text",action:"form"},{label:"Grid",icon:"columns",action:"grid"},{label:"Hero",icon:"hero",action:"hero"},{label:"Icon",icon:"icon-pick",action:"iconpick"},{label:"Image",icon:"image-add",action:"image"},{label:"Link",icon:"link-shortcode",action:"linksc"},{label:"List Group",icon:"list",action:"listgroup"},{label:"Scribe",icon:"scribe-insert",action:"scribe"},{label:"Spacer",icon:"spacer-insert",action:"spacerpick"},{label:"Tabs",icon:"layout-list",action:"tabs"},{label:"Text",icon:"text-style",action:"text"},{label:"Timeline",icon:"activity",action:"timeline"},{label:"View",icon:"eye",action:"view"}]},"|",{icon:"sparkles",title:"Effects",action:"effects"},{icon:"help-circle",title:"Editor help",action:"help"}];export function createToolbar(t,e,m={}){se();const i={link:null,image:null,card:null,grid:null,help:null,effects:null,collection:null,view:null,cta:null,form:null,button:null,linksc:null,tabs:null,accordion:null,hero:null,banner:null},l=m.spacerDefault??40,o=t.get(0),r=e.get(0);r.textContent="",Q.forEach((n,c)=>{if(n==="|"){const a=document.createElement("span");a.className="editor-toolbar-sep",r.appendChild(a)}else{const a=document.createElement("button");a.className=n.type==="dropdown"?"editor-toolbar-btn editor-toolbar-dropdown-trigger":"editor-toolbar-btn",a.setAttribute("data-tooltip",n.title),a.setAttribute("data-idx",String(c)),a.type="button";const k=document.createElement("span");if(k.setAttribute("data-icon",n.icon),a.appendChild(k),n.type==="dropdown"){const y=document.createElement("span");y.className="editor-toolbar-caret",y.textContent="\u25BE",a.appendChild(y)}r.appendChild(a)}});const s=document.createElement("div");s.className="editor-toolbar-right",[{mode:"split",icon:"columns",label:"Split view",active:!0},{mode:"write",icon:"file-text",label:"Write only",active:!1},{mode:"preview",icon:"eye",label:"Preview only",active:!1}].forEach(n=>{const c=document.createElement("button");c.className="editor-view-btn"+(n.active?" active":""),c.setAttribute("data-mode",n.mode),c.setAttribute("data-tooltip",n.label),c.type="button";const a=document.createElement("span");a.setAttribute("data-icon",n.icon),c.appendChild(a),s.appendChild(c)});const p=document.createElement("span");p.className="editor-toolbar-sep",s.appendChild(p);const d=document.createElement("button");d.id="fullscreen-btn",d.className="editor-toolbar-btn",d.setAttribute("data-tooltip","Toggle fullscreen"),d.type="button";const f=document.createElement("span");return f.setAttribute("data-icon","expand"),d.appendChild(f),s.appendChild(d),r.appendChild(s),Domma.icons.scan(),r.querySelectorAll("[data-tooltip]").forEach(n=>{E.tooltip(n,{content:n.getAttribute("data-tooltip"),position:"top"})}),e.on("click",".editor-toolbar-btn[data-idx]",function(){const n=parseInt($(this).data("idx"),10),c=Q[n];if(!c||c==="|")return;const a=e.get(0).querySelector(`[data-idx="${n}"]`),k={spacerDefault:l,handlers:i};c.type==="dropdown"?ae(o,a,c.items,k):U(c.action,o,a,k)}),attachEditorKeybindings(o),o.addEventListener("keydown",n=>{const c=n.key.toLowerCase();(n.ctrlKey||n.metaKey)&&(c==="b"?(n.preventDefault(),wrapSelection(o,"**","**")):c==="i"?(n.preventDefault(),wrapSelection(o,"_","_")):c==="k"&&(n.preventDefault(),i.link&&i.link(o)))}),{$toolbar:e,onLink(n){i.link=n},onImage(n){i.image=n},onCard(n){i.card=n},onGrid(n){i.grid=n},onHelp(n){i.help=n},onEffects(n){i.effects=n},onCollection(n){i.collection=n},onBlock(n){i.block=n},onView(n){i.view=n},onCta(n){i.cta=n},onForm(n){i.form=n},onButton(n){i.button=n},onLinkShortcode(n){i.linksc=n},onTabs(n){i.tabs=n},onAccordion(n){i.accordion=n},onHero(n){i.hero=n},onBanner(n){i.banner=n},onListGroup(n){i.listgroup=n},onScribe(n){i.scribe=n},onTimeline(n){i.timeline=n}}}async function de(t){const{api:e}=await import("../api.js");let m;try{m=await e.components.list()}catch(v){E.toast(v.message||"Failed to load components.",{type:"error"});return}if(!m?.length){E.toast("No components yet. Create one in Data \u2192 Components first.",{type:"info"});return}const i=E.slideover({title:"Insert Component",size:"lg",position:"right"}),l=document.createElement("div");l.style.cssText="display:flex;flex-direction:column;gap:1rem;padding:.75rem;min-height:100%;";const o=document.createElement("div");o.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",o.textContent="Gallery";const r=document.createElement("div");r.style.cssText="display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:.5rem;";const s=document.createElement("div");s.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",s.textContent="Props";const p=document.createElement("div");p.style.cssText="padding:.6rem;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;min-height:40px;",p.textContent="Select a component from the gallery above.";const d=document.createElement("div");d.style.cssText="font-size:.72rem;letter-spacing:.05em;text-transform:uppercase;color:var(--dm-text-muted,#888);",d.textContent="Preview";const f=document.createElement("iframe");f.src="/admin/preview/component-preview.html",f.style.cssText="width:100%;min-height:180px;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;background:#fff;";const n=document.createElement("div");n.style.cssText="display:flex;justify-content:flex-end;gap:.5rem;margin-top:auto;padding-top:.75rem;border-top:1px solid var(--dm-border,rgba(255,255,255,.08));";const c=document.createElement("button");c.className="btn btn-ghost",c.textContent="Cancel";const a=document.createElement("button");a.className="btn btn-primary",a.textContent="Insert",a.disabled=!0,n.appendChild(c),n.appendChild(a),l.appendChild(o),l.appendChild(r),l.appendChild(s),l.appendChild(p),l.appendChild(d),l.appendChild(f),l.appendChild(n),i.setContent(l),i.open();let k=null,y={};function C(){r.replaceChildren();for(const v of m){const h=document.createElement("button");h.type="button",h.className="btn btn-ghost",h.style.cssText="display:flex;flex-direction:column;align-items:flex-start;gap:.25rem;padding:.6rem;border:1px solid var(--dm-border,rgba(255,255,255,.08));border-radius:4px;text-align:left;";const w=document.createElement("strong");w.style.cssText="font-size:.9rem;",w.textContent=v.name;const L=document.createElement("span");L.style.cssText="font-size:.72rem;color:var(--dm-text-muted,#888);",L.textContent=`${Object.keys(v.props||{}).length} prop(s)`,h.appendChild(w),h.appendChild(L),h.addEventListener("click",()=>x(v)),r.appendChild(h)}}function x(v){k=v,y={};for(const[h,w]of Object.entries(v.props||{}))y[h]=w.default!==void 0?w.default:"";a.disabled=!1,S(),M()}function S(){p.replaceChildren();const v=Object.entries(k.props||{});if(v.length===0){const h=document.createElement("p");h.className="text-muted",h.style.margin="0",h.textContent="This component takes no props.",p.appendChild(h);return}for(const[h,w]of v){const L=document.createElement("div");L.style.cssText="display:flex;align-items:center;gap:.5rem;margin-bottom:.4rem;";const N=document.createElement("label");N.style.cssText="font-size:.8rem;min-width:120px;color:var(--dm-text-muted,#aaa);",N.textContent=w.label||h,L.appendChild(N);const T=ue(w);pe(T,w,y[h]),T.addEventListener("input",()=>{y[h]=X(T,w),f.contentWindow?.postMessage({type:"update",payload:{props:y}},"*")}),T.addEventListener("change",()=>{y[h]=X(T,w),f.contentWindow?.postMessage({type:"update",payload:{props:y}},"*")}),L.appendChild(T),p.appendChild(L)}}async function M(){if(k)try{const v=await fetch(`/api/components/${encodeURIComponent(k.name)}.js`);if(!v.ok)throw new Error(`Failed to load component (${v.status})`);const h=await v.text();f.contentWindow?.postMessage({type:"remount",payload:{compiledJs:h,tagName:`dm-${k.name}`,props:y}},"*")}catch(v){E.toast(v.message||"Failed to load preview.",{type:"error"})}}c.addEventListener("click",()=>i.close()),a.addEventListener("click",()=>{if(!k)return;const v=t.selectionStart,h=t.selectionEnd,w=Object.entries(y).map(([N,T])=>{const j=N.replace(/([A-Z])/g,"-$1").toLowerCase(),B=String(T??"").replace(/"/g,""");return`${j}="${B}"`}).join(" "),L=`[component name="${k.name}"${w?" "+w:""} /]`;t.value=t.value.substring(0,v)+L+t.value.substring(h),t.selectionStart=t.selectionEnd=v+L.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus(),i.close()}),C()}function ue(t){let e;return t.type==="number"?(e=document.createElement("input"),e.type="number",e.className="form-input form-input--sm"):t.type==="boolean"?(e=document.createElement("input"),e.type="checkbox",e.className="form-check"):t.type==="array"||t.type==="object"?(e=document.createElement("textarea"),e.rows=2,e.className="form-input form-input--sm",e.style.fontFamily="var(--dm-font-mono, monospace)"):(e=document.createElement("input"),e.type="text",e.className="form-input form-input--sm"),e.style.flex="1",e}function X(t,e){if(e.type==="number")return t.value===""?null:Number(t.value);if(e.type==="boolean")return!!t.checked;if(e.type==="array"||e.type==="object")try{return JSON.parse(t.value||"null")}catch{return null}return t.value}function pe(t,e,m){e.type==="boolean"?t.checked=!!m:e.type==="array"||e.type==="object"?t.value=JSON.stringify(m??null):t.value=m??""}
|
|
@@ -663,6 +663,89 @@ Click me for a burst!
|
|
|
663
663
|
JS.
|
|
664
664
|
Canvas celebrations (<code>[celebrate]</code>) load the JS module on demand and degrade silently if
|
|
665
665
|
unavailable.</p>
|
|
666
|
+
|
|
667
|
+
<h3 class="mb-2">Ticker Tape <span class="badge badge-info">JS canvas</span></h3>
|
|
668
|
+
<p class="text-muted mb-2">A canvas-based ticker-tape parade. Coloured rectangular strips fall from the top,
|
|
669
|
+
sway, rotate, and fade. Self-closing form gives a full-page overlay; wrapping form scopes the parade
|
|
670
|
+
inside a container. Skipped automatically when <code>prefers-reduced-motion</code> is active.</p>
|
|
671
|
+
<h4 class="mb-1" style="font-size:.9rem;">Full-page overlay</h4>
|
|
672
|
+
<pre class="code-block mb-2">[ticker-tape palette="festive" /]</pre>
|
|
673
|
+
<h4 class="mb-1" style="font-size:.9rem;">Container-scoped</h4>
|
|
674
|
+
<pre class="code-block mb-2">[ticker-tape palette="gold" density="40"]
|
|
675
|
+
## Celebration content
|
|
676
|
+
The strips rain down inside this block only.
|
|
677
|
+
[/ticker-tape]</pre>
|
|
678
|
+
<h4 class="mb-1" style="font-size:.9rem;">One-shot burst</h4>
|
|
679
|
+
<pre class="code-block mb-2">[ticker-tape palette="rainbow" burst="true" burst-count="200" /]</pre>
|
|
680
|
+
<table class="table mb-3">
|
|
681
|
+
<thead>
|
|
682
|
+
<tr>
|
|
683
|
+
<th>Attribute</th>
|
|
684
|
+
<th>Default</th>
|
|
685
|
+
<th>Description</th>
|
|
686
|
+
</tr>
|
|
687
|
+
</thead>
|
|
688
|
+
<tbody>
|
|
689
|
+
<tr>
|
|
690
|
+
<td><code>palette</code></td>
|
|
691
|
+
<td>theme</td>
|
|
692
|
+
<td>theme, rainbow, gold, silver, festive, pastel, mono, sunset</td>
|
|
693
|
+
</tr>
|
|
694
|
+
<tr>
|
|
695
|
+
<td><code>density</code></td>
|
|
696
|
+
<td>50</td>
|
|
697
|
+
<td>Average strips on screen at any moment (continuous mode)</td>
|
|
698
|
+
</tr>
|
|
699
|
+
<tr>
|
|
700
|
+
<td><code>speed</code></td>
|
|
701
|
+
<td>1</td>
|
|
702
|
+
<td>Fall speed multiplier (1 = default)</td>
|
|
703
|
+
</tr>
|
|
704
|
+
<tr>
|
|
705
|
+
<td><code>sway</code></td>
|
|
706
|
+
<td>60</td>
|
|
707
|
+
<td>Horizontal sway amplitude in pixels</td>
|
|
708
|
+
</tr>
|
|
709
|
+
<tr>
|
|
710
|
+
<td><code>rotation-speed</code></td>
|
|
711
|
+
<td>6</td>
|
|
712
|
+
<td>Maximum rotation degrees per frame</td>
|
|
713
|
+
</tr>
|
|
714
|
+
<tr>
|
|
715
|
+
<td><code>min-width</code> / <code>max-width</code></td>
|
|
716
|
+
<td>5 / 9</td>
|
|
717
|
+
<td>Strip width range in pixels</td>
|
|
718
|
+
</tr>
|
|
719
|
+
<tr>
|
|
720
|
+
<td><code>min-height</code> / <code>max-height</code></td>
|
|
721
|
+
<td>12 / 22</td>
|
|
722
|
+
<td>Strip height range in pixels</td>
|
|
723
|
+
</tr>
|
|
724
|
+
<tr>
|
|
725
|
+
<td><code>fade-start</code></td>
|
|
726
|
+
<td>0.55</td>
|
|
727
|
+
<td>Fraction of fall (0–1) before strips begin to fade</td>
|
|
728
|
+
</tr>
|
|
729
|
+
<tr>
|
|
730
|
+
<td><code>burst</code></td>
|
|
731
|
+
<td>false</td>
|
|
732
|
+
<td>Drop a single batch and stop respawning</td>
|
|
733
|
+
</tr>
|
|
734
|
+
<tr>
|
|
735
|
+
<td><code>burst-count</code></td>
|
|
736
|
+
<td>150</td>
|
|
737
|
+
<td>Strips emitted in burst mode</td>
|
|
738
|
+
</tr>
|
|
739
|
+
<tr>
|
|
740
|
+
<td><code>z-index</code></td>
|
|
741
|
+
<td>1</td>
|
|
742
|
+
<td>Canvas z-index</td>
|
|
743
|
+
</tr>
|
|
744
|
+
</tbody>
|
|
745
|
+
</table>
|
|
746
|
+
<p class="text-muted"><strong>Tip:</strong> Self-closing <code>[ticker-tape /]</code> creates a fixed
|
|
747
|
+
full-page overlay (<code>position:fixed</code>); the wrapping form attaches the canvas to the
|
|
748
|
+
wrapping div so the parade is constrained to that block.</p>
|
|
666
749
|
</div>
|
|
667
750
|
</div><!-- /tab-panel shortcodes -->
|
|
668
751
|
</div><!-- /tab-content -->
|