domma-cms 0.6.20 → 0.6.21
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function
|
|
2
|
-
`,
|
|
3
|
-
`,c),l
|
|
1
|
+
function ne(){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("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("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"})}export function wrapSelection(t,e,b){const l=t.selectionStart,c=t.selectionEnd,o=t.value,r=o.substring(l,c);r?(t.value=o.substring(0,l)+e+r+b+o.substring(c),t.selectionStart=l+e.length,t.selectionEnd=c+e.length):(t.value=o.substring(0,l)+e+b+o.substring(l),t.selectionStart=t.selectionEnd=l+e.length),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}export function insertAtCursor(t,e){const b=t.selectionStart,l=t.value;t.value=l.substring(0,b)+e+l.substring(b),t.selectionStart=t.selectionEnd=b+e.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}export function insertLine(t,e){const b=t.selectionStart,l=t.value,c=l.lastIndexOf(`
|
|
2
|
+
`,b-1)+1,o=l.indexOf(`
|
|
3
|
+
`,c),r=l.substring(c,o===-1?l.length:o);if(r.startsWith(e)){const i=o===-1?"":l.substring(o);t.value=l.substring(0,c)+r.substring(e.length)+i,t.selectionStart=t.selectionEnd=Math.max(c,b-e.length)}else t.value=l.substring(0,c)+e+l.substring(c),t.selectionStart=t.selectionEnd=b+e.length;t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}const oe=[{category:"Entrance"},{label:"Reveal (fade)",snippet:t=>`[reveal animation="fade"]
|
|
4
4
|
${t||"Content"}
|
|
5
5
|
[/reveal]`},{label:"Reveal (slide up)",snippet:t=>`[reveal animation="slide-up"]
|
|
6
6
|
${t||"Content"}
|
|
@@ -29,12 +29,12 @@ ${t||"Content"}
|
|
|
29
29
|
[/firework]`},{label:"Fireworks show",snippet:()=>`[fireworks]
|
|
30
30
|
[firework type="burst" colour="rainbow" /]
|
|
31
31
|
[firework type="sparkle" colour="primary" /]
|
|
32
|
-
[/fireworks]`,insert:!0},{label:"Celebrate",snippet:()=>'[celebrate theme="auto" intensity="medium" /]',insert:!0}];function
|
|
33
|
-
`)});const n=e.getBoundingClientRect(),s=e.closest(".editor-toolbar").getBoundingClientRect();c.style.top=n.bottom-s.top+4+"px";const
|
|
34
|
-
${e.value.substring(
|
|
35
|
-
[/card]`;e.value=e.value.substring(0,
|
|
36
|
-
${e.value.substring(
|
|
37
|
-
[/hero]`;e.value=e.value.substring(0,
|
|
32
|
+
[/fireworks]`,insert:!0},{label:"Celebrate",snippet:()=>'[celebrate theme="auto" intensity="medium" /]',insert:!0}];function ie(t,e){const b=document.querySelector(".editor-effects-dropdown-menu");if(b){b.remove();return}const l=document.createElement("div");l.className="editor-effects-dropdown-menu",oe.forEach(function(i){if(i.category){const u=document.createElement("div");u.className="editor-effects-category",u.textContent=i.category,l.appendChild(u)}else{const u=document.createElement("button");u.type="button",u.className="editor-effects-item",u.textContent=i.label,u.addEventListener("click",function(){if(l.remove(),i.insert)insertAtCursor(t,i.snippet(""));else{const a=t.selectionStart,f=t.selectionEnd,n=t.value.substring(a,f),s=i.snippet(n);t.value=t.value.substring(0,a)+s+t.value.substring(f),t.selectionStart=a,t.selectionEnd=a+s.length,t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()}}),l.appendChild(u)}});const c=e.getBoundingClientRect(),o=e.closest(".editor-toolbar").getBoundingClientRect();l.style.top=c.bottom-o.top+4+"px",l.style.left=c.left-o.left+"px",e.closest(".editor-toolbar").appendChild(l);function r(i){!l.contains(i.target)&&i.target!==e&&(l.remove(),document.removeEventListener("click",r,!0))}setTimeout(function(){document.addEventListener("click",r,!0)},0)}const G=["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,b){const l=document.querySelector(".editor-spacer-picker");if(l){l.remove();return}const c=document.createElement("div");c.className="editor-spacer-picker";const o=document.createElement("div");o.className="editor-spacer-picker-label",o.textContent="Spacer height",c.appendChild(o);const r=document.createElement("div");r.className="editor-spacer-picker-row";const i=document.createElement("input");i.type="range",i.className="editor-spacer-slider",i.min="4",i.max="200",i.step="4",i.value=b;const u=document.createElement("span");u.className="editor-spacer-slider-value",u.textContent=b+"px",i.addEventListener("input",function(){u.textContent=this.value+"px"}),r.appendChild(i),r.appendChild(u),c.appendChild(r);const a=document.createElement("button");a.type="button",a.className="btn btn-primary btn-sm editor-spacer-insert-btn",a.textContent="Insert",c.appendChild(a);function f(g){!c.contains(g.target)&&g.target!==e&&(c.remove(),document.removeEventListener("click",f,!0))}a.addEventListener("click",function(){c.remove(),document.removeEventListener("click",f,!0),insertAtCursor(t,`[spacer size="${i.value}" /]
|
|
33
|
+
`)});const n=e.getBoundingClientRect(),s=e.closest(".editor-toolbar").getBoundingClientRect();c.style.top=n.bottom-s.top+4+"px";const d=n.left-s.left;c.style.left=Math.min(d,s.width-240-8)+"px",e.closest(".editor-toolbar").appendChild(c),setTimeout(function(){document.addEventListener("click",f,!0)},0)}function re(t,e){const b=document.querySelector(".editor-icon-picker");if(b){b.remove();return}const l=document.createElement("div");l.className="editor-icon-picker";const c=document.createElement("input");c.type="text",c.className="form-input editor-icon-picker-search",c.placeholder="Search icons\u2026",l.appendChild(c);const o=document.createElement("div");o.className="editor-icon-picker-size-row";const r=document.createElement("label");r.textContent="Size (px)";const i=document.createElement("input");i.type="number",i.className="form-input editor-icon-picker-size",i.placeholder="default",i.min="8",i.max="256",o.appendChild(r),o.appendChild(i),l.appendChild(o);const u=document.createElement("div");u.className="editor-icon-picker-grid",l.appendChild(u);function a(y){!l.contains(y.target)&&y.target!==e&&(l.remove(),document.removeEventListener("click",a,!0))}function f(y){u.textContent="";const C=y?G.filter(w=>w.includes(y.toLowerCase())):G;if(C.length===0){const w=document.createElement("div");w.className="editor-icon-picker-empty",w.textContent="No icons found",u.appendChild(w);return}C.forEach(function(w){const k=document.createElement("button");k.type="button",k.className="editor-icon-picker-item";const P=document.createElement("span");P.setAttribute("data-icon",w);const L=document.createElement("span");L.textContent=w,k.appendChild(P),k.appendChild(L),k.addEventListener("click",function(){l.remove(),document.removeEventListener("click",a,!0);const V=i.value.trim(),A=V?`[icon name="${w}" size="${V}" /]`:`[icon name="${w}" /]`;insertAtCursor(t,A)}),u.appendChild(k)}),Domma.icons.scan(u)}f(""),c.addEventListener("input",function(){f(this.value.trim())});const n=e.getBoundingClientRect(),s=e.closest(".editor-toolbar").getBoundingClientRect();l.style.top=n.bottom-s.top+4+"px";const d=n.left-s.left,g=320,m=s.width;l.style.left=Math.min(d,m-g-8)+"px",e.closest(".editor-toolbar").appendChild(l),requestAnimationFrame(function(){c.focus()}),setTimeout(function(){document.addEventListener("click",a,!0)},0)}function se(t,e,b,l){const c=document.querySelector(".editor-toolbar-dropdown");if(c){c.remove();return}const o=document.createElement("div");o.className="editor-toolbar-dropdown",b.forEach(function(f){const n=document.createElement("button");if(n.type="button",n.className="editor-toolbar-dropdown-item",f.icon){const d=document.createElement("span");d.setAttribute("data-icon",f.icon),n.appendChild(d)}const s=document.createElement("span");s.textContent=f.label,n.appendChild(s),n.addEventListener("click",function(){o.remove(),document.removeEventListener("click",a,!0),K(f.action,t,e,l)}),o.appendChild(n)});const r=e.getBoundingClientRect(),i=e.closest(".editor-toolbar").getBoundingClientRect();o.style.top=r.bottom-i.top+4+"px";const u=r.left-i.left;o.style.left=Math.min(u,i.width-180-8)+"px",e.closest(".editor-toolbar").appendChild(o),Domma.icons.scan(o);function a(f){!o.contains(f.target)&&f.target!==e&&(o.remove(),document.removeEventListener("click",a,!0))}setTimeout(function(){document.addEventListener("click",a,!0)},0)}function K(t,e,b,l){const{spacerDefault:c,handlers:o}=l;if(typeof t=="function")t(e);else if(t==="block")if(o.block)o.block(e);else{const r=e.selectionStart,i='[block template="" /]';e.value=e.value.substring(0,r)+i+e.value.substring(r),e.selectionStart=e.selectionEnd=r+17,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="button")if(o.button)o.button(e);else{const r=e.selectionStart,i=e.selectionEnd,a=`[button href="" variant="primary"]${e.value.substring(r,i)||"Click me"}[/button]`;e.value=e.value.substring(0,r)+a+e.value.substring(i),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,i=e.selectionEnd,a=`[link href=""]${e.value.substring(r,i)||"Link text"}[/link]`;e.value=e.value.substring(0,r)+a+e.value.substring(i),e.selectionStart=e.selectionEnd=r+12,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}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,i=e.selectionEnd,a=`[card title="Card Title"]
|
|
34
|
+
${e.value.substring(r,i)||"Content here"}
|
|
35
|
+
[/card]`;e.value=e.value.substring(0,r)+a+e.value.substring(i),e.selectionStart=r+13,e.selectionEnd=r+23,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="hero"){const r=e.selectionStart,i=e.selectionEnd,a=`[hero title="Hero Title" tagline="A short tagline" size="lg" variant="gradient-blue"]
|
|
36
|
+
${e.value.substring(r,i)||"Optional body content here."}
|
|
37
|
+
[/hero]`;e.value=e.value.substring(0,r)+a+e.value.substring(i),e.selectionStart=e.selectionEnd=r+a.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,i=`[grid cols="2" gap="4"]
|
|
38
38
|
[col]
|
|
39
39
|
Column 1
|
|
40
40
|
[/col]
|
|
@@ -42,7 +42,7 @@ Column 1
|
|
|
42
42
|
Column 2
|
|
43
43
|
[/col]
|
|
44
44
|
[/grid]
|
|
45
|
-
`;e.value=e.value.substring(0,
|
|
45
|
+
`;e.value=e.value.substring(0,r)+i+e.value.substring(r),e.selectionStart=e.selectionEnd=r+i.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="badge"){const r=e.selectionStart,i=e.selectionEnd,a=`[badge variant="primary"]${e.value.substring(r,i)||"New"}[/badge]`;e.value=e.value.substring(0,r)+a+e.value.substring(i),e.selectionStart=r+16,e.selectionEnd=r+23,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="timeline"){const r=e.selectionStart,i=`[timeline layout="vertical"]
|
|
46
46
|
[event title="First Event" date="${new Date().toISOString().slice(0,10)}" status="completed"]
|
|
47
47
|
Describe this event.
|
|
48
48
|
[/event]
|
|
@@ -50,11 +50,11 @@ Describe this event.
|
|
|
50
50
|
Describe this event.
|
|
51
51
|
[/event]
|
|
52
52
|
[/timeline]
|
|
53
|
-
`;e.value=e.value.substring(0,
|
|
53
|
+
`;e.value=e.value.substring(0,r)+i+e.value.substring(r),e.selectionStart=e.selectionEnd=r+i.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="effects")o.effects?o.effects(e):ie(e,b);else if(t==="spacerpick")le(e,b,c);else if(t==="iconpick")re(e,b);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==="accordion")if(o.accordion)o.accordion(e);else{const r=e.selectionStart,i=`[accordion]
|
|
54
54
|
[item title="Item 1"]Content here.[/item]
|
|
55
55
|
[item title="Item 2"]Content here.[/item]
|
|
56
56
|
[/accordion]
|
|
57
|
-
`;e.value=e.value.substring(0,
|
|
57
|
+
`;e.value=e.value.substring(0,r)+i+e.value.substring(r),e.selectionStart=e.selectionEnd=r+i.length,e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()}else if(t==="text"){let n=function(h,p){const v=document.createElement("div"),x=document.createElement("label");return x.style.cssText=a,x.textContent=h,v.appendChild(x),v.appendChild(p),v},s=function(h){const p=document.createElement("select");return p.style.cssText=f,[["","\u2014 default \u2014"],...h].forEach(([v,x])=>{const W=document.createElement("option");W.value=v,W.textContent=x,p.appendChild(W)}),p},d=function(h,p){const v=document.createElement("input");return v.type="text",v.placeholder=h||"",v.value=p||"",v.style.cssText=f,v},g=function(h){const p=document.createElement("label");p.style.cssText="display:flex;align-items:center;gap:.5rem;cursor:pointer;";const v=document.createElement("input");v.type="checkbox";const x=document.createElement("span");return x.style.cssText="font-size:.85em;color:var(--dm-text,#eee);",x.textContent=h,p.appendChild(v),p.appendChild(x),{wrap:p,cb:v}},q=function(){const h=[];C.value&&h.push(`font-size:${J[C.value]||C.value}`);const p=parseFloat(w.value);!isNaN(p)&&p>0&&h.push(`font-size:${p}pt`),L.checked?h.push("font-weight:700"):k.value&&h.push(`font-weight:${Q[k.value]||k.value}`),A.checked&&h.push("font-style:italic");const v=R.value.trim();v&&h.push(`color:${U[v]||v}`),S.value&&h.push(`font-family:${Y[S.value]}`),M.value&&h.push(`text-transform:${ee[M.value]}`),z.value&&h.push(`text-decoration:${te[z.value]}`),N.value&&h.push(`letter-spacing:${X[N.value]}`),T.value&&(h.push("display:block"),h.push(`text-align:${T.value}`)),B.value.trim()&&h.push(B.value.trim()),j.style.cssText=h.join(";"),j.textContent=y.value||"Preview text"};const r=e.selectionStart,i=e.selectionEnd,u=e.value.substring(r,i)||"",a="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;",m=document.createElement("div");m.style.cssText="padding:1rem;display:flex;flex-direction:column;gap:.75rem;";const y=d("Text to style\u2026",u);m.appendChild(n("Content",y));const C=s([["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"]]);m.appendChild(n("Size",C));const w=d("e.g. 14 (overrides Size above)");m.appendChild(n("Point Size (pt)",w));const k=s([["thin","Thin (100)"],["light","Light (300)"],["normal","Normal (400)"],["medium","Medium (500)"],["semibold","Semibold (600)"],["bold","Bold (700)"],["extrabold","Extrabold (800)"],["black","Black (900)"]]);m.appendChild(n("Weight",k));const{wrap:P,cb:L}=g("Bold (shorthand \u2014 overrides Weight)");m.appendChild(P);const{wrap:V,cb:A}=g("Italic");m.appendChild(V);const R=d("e.g. primary, #ff0000, rgb(255,0,0)");m.appendChild(n("Colour",R));const S=s([["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)"]]);m.appendChild(n("Font",S));const M=s([["upper","Uppercase"],["lower","Lowercase"],["capitalize","Capitalise"],["none","None"]]);m.appendChild(n("Transform",M));const z=s([["underline","Underline"],["line-through","Line-through"],["none","None"]]);m.appendChild(n("Decoration",z));const N=s([["tight","Tight"],["normal","Normal"],["wide","Wide"],["wider","Wider"]]);m.appendChild(n("Spacing",N));const T=s([["left","Left"],["center","Centre"],["right","Right"],["justify","Justify"]]);m.appendChild(n("Align",T));const B=d("e.g. margin-top:1rem;display:block");m.appendChild(n("Style",B));const D=d("Optional CSS class");m.appendChild(n("CSS Class",D));const O=d("Optional ID");m.appendChild(n("ID",O));const _=document.createElement("div");_.style.cssText="padding:.75rem;background:var(--dm-surface-subtle,#111);border-radius:4px;min-height:2.5rem;display:flex;align-items:center;";const j=document.createElement("span");j.textContent=u||"Preview text",_.appendChild(j),m.appendChild(n("Preview",_));const U={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)"},J={xs:".75rem",sm:".875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},Q={thin:"100",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},X={tight:"-0.05em",normal:"0em",wide:"0.05em",wider:"0.1em"},Y={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"},ee={upper:"uppercase",lower:"lowercase",capitalize:"capitalize",none:"none"},te={underline:"underline","line-through":"line-through",none:"none"};L.addEventListener("change",()=>{k.disabled=L.checked,L.checked&&(k.value=""),q()}),[C,k,S,M,z,N,T].forEach(h=>{h.addEventListener("change",q)}),[R,y,B,w].forEach(h=>{h.addEventListener("input",q)}),A.addEventListener("change",q);const H=document.createElement("button");H.type="button",H.className="btn btn-primary",H.textContent="Insert",m.appendChild(H);const F=E.modal({title:"Style Text",size:"sm"});F.element.appendChild(m),F.open(),H.addEventListener("click",()=>{const h=y.value;if(!h.trim())return;const p=[];C.value&&p.push(`size="${C.value}"`);const v=parseFloat(w.value);!isNaN(v)&&v>0&&p.push(`point-size="${v}"`),L.checked?p.push("bold"):k.value&&p.push(`weight="${k.value}"`),A.checked&&p.push("italic"),R.value.trim()&&p.push(`color="${R.value.trim()}"`),S.value&&p.push(`font="${S.value}"`),M.value&&p.push(`transform="${M.value}"`),z.value&&p.push(`decoration="${z.value}"`),N.value&&p.push(`spacing="${N.value}"`),T.value&&p.push(`align="${T.value}"`),B.value.trim()&&p.push(`style="${B.value.trim().replace(/"/g,""")}"`),D.value.trim()&&p.push(`class="${D.value.trim()}"`),O.value.trim()&&p.push(`id="${O.value.trim()}"`);const W=`[text${p.length?" "+p.join(" "):""}]${h}[/text]`;F.close(),insertAtCursor(e,W),e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus()})}else t==="help"&&o.help&&o.help(e)}const Z=[{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,`
|
|
58
58
|
---
|
|
59
|
-
`)}]},"|",{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:"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:"Collection",icon:"database",action:"collection"},{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:"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,
|
|
60
|
-
`,o.selectionStart-1)+1,g=o.value.substring(
|
|
59
|
+
`)}]},"|",{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:"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:"Collection",icon:"database",action:"collection"},{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:"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,b={}){ne();const l={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},c=b.spacerDefault??40,o=t.get(0),r=e.get(0);r.textContent="",Z.forEach((n,s)=>{if(n==="|"){const d=document.createElement("span");d.className="editor-toolbar-sep",r.appendChild(d)}else{const d=document.createElement("button");d.className=n.type==="dropdown"?"editor-toolbar-btn editor-toolbar-dropdown-trigger":"editor-toolbar-btn",d.setAttribute("data-tooltip",n.title),d.setAttribute("data-idx",String(s)),d.type="button";const g=document.createElement("span");if(g.setAttribute("data-icon",n.icon),d.appendChild(g),n.type==="dropdown"){const m=document.createElement("span");m.className="editor-toolbar-caret",m.textContent="\u25BE",d.appendChild(m)}r.appendChild(d)}});const i=document.createElement("div");i.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 s=document.createElement("button");s.className="editor-view-btn"+(n.active?" active":""),s.setAttribute("data-mode",n.mode),s.setAttribute("data-tooltip",n.label),s.type="button";const d=document.createElement("span");d.setAttribute("data-icon",n.icon),s.appendChild(d),i.appendChild(s)});const u=document.createElement("span");u.className="editor-toolbar-sep",i.appendChild(u);const a=document.createElement("button");a.id="fullscreen-btn",a.className="editor-toolbar-btn",a.setAttribute("data-tooltip","Toggle fullscreen"),a.type="button";const f=document.createElement("span");return f.setAttribute("data-icon","expand"),a.appendChild(f),i.appendChild(a),r.appendChild(i),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),s=Z[n];if(!s||s==="|")return;const d=e.get(0).querySelector(`[data-idx="${n}"]`),g={spacerDefault:c,handlers:l};s.type==="dropdown"?se(o,d,s.items,g):K(s.action,o,d,g)}),t.on("keydown",function(n){const s=n.key.toLowerCase();if(n.ctrlKey||n.metaKey)s==="b"?(n.preventDefault(),wrapSelection(o,"**","**")):s==="i"?(n.preventDefault(),wrapSelection(o,"_","_")):s==="k"&&(n.preventDefault(),l.link&&l.link(o));else if(n.key==="Tab")if(n.preventDefault(),n.shiftKey){const d=o.value.lastIndexOf(`
|
|
60
|
+
`,o.selectionStart-1)+1,g=o.value.substring(d),m=g.match(/^ {1,4}/);if(m){const y=o.value.substring(0,d),C=o.value.substring(d+m[0].length);o.value=y+g.substring(m[0].length),o.selectionStart=o.selectionEnd=Math.max(d,o.selectionStart-m[0].length),o.dispatchEvent(new Event("input",{bubbles:!0}))}}else insertAtCursor(o," ")}),{$toolbar:e,onLink(n){l.link=n},onImage(n){l.image=n},onCard(n){l.card=n},onGrid(n){l.grid=n},onHelp(n){l.help=n},onEffects(n){l.effects=n},onCollection(n){l.collection=n},onBlock(n){l.block=n},onView(n){l.view=n},onCta(n){l.cta=n},onForm(n){l.form=n},onButton(n){l.button=n},onLinkShortcode(n){l.linksc=n},onTabs(n){l.tabs=n},onAccordion(n){l.accordion=n}}}
|
package/package.json
CHANGED
|
@@ -1120,6 +1120,11 @@ function processTextBlocks(markdown) {
|
|
|
1120
1120
|
styles.push(`font-size:${SIZE_MAP[attrs.size] || attrs.size}`);
|
|
1121
1121
|
}
|
|
1122
1122
|
|
|
1123
|
+
if (attrs['point-size']) {
|
|
1124
|
+
const pt = parseFloat(attrs['point-size']);
|
|
1125
|
+
if (!isNaN(pt) && pt > 0) styles.push(`font-size:${pt}pt`);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1123
1128
|
// bold flag takes precedence over weight attr
|
|
1124
1129
|
const isBold = /\bbold\b/i.test(attrStr);
|
|
1125
1130
|
if (isBold) {
|
|
@@ -1152,6 +1157,15 @@ function processTextBlocks(markdown) {
|
|
|
1152
1157
|
styles.push(`letter-spacing:${SPACING_MAP[attrs.spacing] || attrs.spacing}`);
|
|
1153
1158
|
}
|
|
1154
1159
|
|
|
1160
|
+
if (attrs.align) {
|
|
1161
|
+
styles.push('display:block');
|
|
1162
|
+
styles.push(`text-align:${escapeAttr(attrs.align)}`);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
if (attrs.style) {
|
|
1166
|
+
styles.push(attrs.style.trim().replace(/;+$/, ''));
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1155
1169
|
const styleAttr = styles.length ? ` style="${styles.join(';')}"` : '';
|
|
1156
1170
|
const classAttr = attrs.class ? ` class="${escapeAttr(attrs.class)}"` : '';
|
|
1157
1171
|
const idAttr = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|