@creaditor/newsletter-starterkit 1.0.60 → 1.0.62
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/dist/5909.creaditor.bundle.js +19 -19
- package/dist/5909.creaditor.bundle.js.gz +0 -0
- package/dist/823.creaditor.bundle.js +1 -0
- package/dist/823.creaditor.bundle.js.gz +0 -0
- package/dist/creaditor.bundle.js +4 -4
- package/dist/creaditor.bundle.js.gz +0 -0
- package/dist/service-worker.js +1 -1
- package/dist/service-worker.js.gz +0 -0
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[5909],{65909(e,t,i){i.r(t),i.d(t,{NextButton:()=>g,PUBLISH_ERROR_EVENT:()=>f,PUBLISH_EVENT:()=>u});var
|
|
1
|
+
"use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[5909],{65909(e,t,i){i.r(t),i.d(t,{NextButton:()=>g,PUBLISH_ERROR_EVENT:()=>f,PUBLISH_EVENT:()=>u});var o=i(59929),s=i(86319),r=i(93432),n=i(90090),a=i(86959),l=i(15604);const c=`${(0,a.Ay)()?"http://127.0.0.1:8000":"https://studio.creaditor.ai"}/api/seo-generate`;const d=o.qy`
|
|
2
2
|
<svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16" aria-hidden="true">
|
|
3
3
|
<path
|
|
4
4
|
d="M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z"
|
|
5
5
|
/>
|
|
6
6
|
</svg>
|
|
7
|
-
`;class h extends
|
|
7
|
+
`;class h extends o.WF{constructor(){super(),this.resolver=null,this.dismiss=()=>{this.isConnected&&this.remove()},this.onCancel=()=>{this.loading||(this.settle(null),this.dismiss())},this.onKeywordKeydown=e=>{"Enter"===e.key||","===e.key?(e.preventDefault(),this.commitDraftKeyword()):"Backspace"===e.key&&""===this.keywordDraft&&this.keywordList.length&&(this.keywordList=this.keywordList.slice(0,-1))},this.generateField=async e=>{if(this.loading||this.generatingField)return;const t=function(){const e=document.getElementById("main-page-wrapper");return(e?.innerText||"").trim()}();if(t){this.generatingField=e;try{const i="rtl"===this.direction?"he":"en",o=await this.requestSeo(e,t,i);if("keywords"===e){const e=(Array.isArray(o)?o:String(o).split(",")).map(e=>e.trim()).filter(Boolean),t=[...this.keywordList];for(const i of e)t.includes(i)||t.push(i);this.keywordList=t}else"title"===e?this.title=String(o).slice(0,100):this.description=String(o).slice(0,255)}catch(e){console.error("[seo-generate] failed:",e),this.snackbar(this.t("seo_generate_failed","Couldn't generate. Please try again."))}finally{this.generatingField=""}}else this.snackbar(this.t("seo_generate_empty","Add some content to the page first."))},this.onPublish=()=>{this.loading||(this.commitDraftKeyword(),this.loading=!0,this.settle({seo:{title:this.title.trim(),description:this.description.trim(),keywords:[...this.keywordList]},busy:e=>{this.isConnected&&(this.loading=e)},done:this.dismiss}))},this.loading=!1,this.title="",this.description="",this.keywordList=[],this.keywordDraft="",this.keywordsFocused=!1,this.generatingField=""}static open(){const e=document.createElement("cdtr-publish-seo"),t=s.M.get("app","seo")||{};return e.title=t.title||"",e.description=t.description||"",e.keywordList=(Array.isArray(t.keywords)?t.keywords:String(t.keywords||"").split(",")).map(e=>String(e).trim()).filter(Boolean),document.body.appendChild(e),e.waitForChoice()}waitForChoice(){return new Promise(e=>{this.resolver=e})}t(e,t){return s.M.get("lang",e)||t}get direction(){const e=s.M.get("theme");return e?.direction||"rtl"}settle(e){this.resolver&&(this.resolver(e),this.resolver=null)}commitDraftKeyword(){const e=this.keywordDraft.split(",").map(e=>e.trim()).filter(Boolean);if(!e.length)return;const t=[...this.keywordList];for(const i of e)t.includes(i)||t.push(i);this.keywordList=t,this.keywordDraft=""}removeKeyword(e){this.keywordList=this.keywordList.filter((t,i)=>i!==e)}snackbar(e){const t=s.M.get("commands");t?.snackbar?.(e)}async requestSeo(e,t,i){const o=async o=>{const s=await async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=l.Ay;if("function"==typeof t.studioTokenProvider)try{const i=await t.studioTokenProvider({forceRefresh:e});if("string"==typeof i&&i.length>0)return i}catch{}return"string"==typeof t.studioToken&&t.studioToken.length>0?t.studioToken:null}(o),r={"Content-Type":"application/json",Accept:"application/json"};return s&&(r.Authorization=`Bearer ${s}`),fetch(c,{method:"POST",headers:r,body:JSON.stringify({content:t,field:e,language:i})})};let s=await o(!1);if(401===s.status&&(s=await o(!0)),!s.ok)throw new Error(`HTTP ${s.status}`);const r=await s.json();if(!r.ok||void 0===r.value)throw new Error("bad response");return r.value}magicButton(e){const t=this.generatingField===e;return o.qy`
|
|
8
8
|
<button
|
|
9
9
|
class="magic"
|
|
10
10
|
type="button"
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
?disabled=${this.loading||!!this.generatingField}
|
|
14
14
|
@click=${()=>this.generateField(e)}
|
|
15
15
|
>
|
|
16
|
-
${t?
|
|
16
|
+
${t?o.qy`<span class="mini-spinner"></span>`:d}
|
|
17
17
|
</button>
|
|
18
|
-
`}render(){const e=this.direction;return
|
|
18
|
+
`}render(){const e=this.direction;return o.qy`
|
|
19
19
|
<div class="backdrop" @click=${this.onCancel}></div>
|
|
20
20
|
<div class="card" dir=${e}>
|
|
21
21
|
<h2 class="heading">${this.t("ready_to_publish","Ready to publish")}</h2>
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
class="chips ${this.keywordsFocused?"focused":""}"
|
|
64
64
|
@click=${e=>{const t=e.currentTarget.querySelector("input");t?.focus()}}
|
|
65
65
|
>
|
|
66
|
-
${this.keywordList.map((e,t)=>
|
|
66
|
+
${this.keywordList.map((e,t)=>o.qy`
|
|
67
67
|
<span class="chip">
|
|
68
68
|
${e}
|
|
69
69
|
<button
|
|
@@ -90,14 +90,14 @@
|
|
|
90
90
|
|
|
91
91
|
<div class="actions">
|
|
92
92
|
<button class="publish" ?disabled=${this.loading} @click=${this.onPublish}>
|
|
93
|
-
${this.loading?
|
|
93
|
+
${this.loading?o.qy`<span class="spinner"></span>`:this.t("publish","Publish")}
|
|
94
94
|
</button>
|
|
95
95
|
<button class="cancel" ?disabled=${this.loading} @click=${this.onCancel}>
|
|
96
96
|
${this.t("cancel","Cancel")}
|
|
97
97
|
</button>
|
|
98
98
|
</div>
|
|
99
99
|
</div>
|
|
100
|
-
`}}h.styles=
|
|
100
|
+
`}}h.styles=o.AH`
|
|
101
101
|
:host {
|
|
102
102
|
position: fixed;
|
|
103
103
|
inset: 0;
|
|
@@ -343,20 +343,20 @@
|
|
|
343
343
|
@keyframes spin {
|
|
344
344
|
to { transform: rotate(360deg); }
|
|
345
345
|
}
|
|
346
|
-
`,h.properties={loading:{type:Boolean},title:{type:String},description:{type:String},keywordList:{type:Array},keywordDraft:{type:String},keywordsFocused:{type:Boolean},generatingField:{type:String}},customElements.define("cdtr-publish-seo",h);class p extends
|
|
346
|
+
`,h.properties={loading:{type:Boolean},title:{type:String},description:{type:String},keywordList:{type:Array},keywordDraft:{type:String},keywordsFocused:{type:Boolean},generatingField:{type:String}},customElements.define("cdtr-publish-seo",h);class p extends o.WF{constructor(){super(),this.raf=0,this.dismissTimer=null,this.onKeyDown=e=>{"Escape"===e.key&&this.dismiss()},this.dismiss=()=>{this.isConnected&&this.remove()},this.copyLink=async()=>{if(this.url)try{await navigator.clipboard.writeText(this.url),this.copied=!0,setTimeout(()=>this.copied=!1,2e3)}catch{}},this.message="",this.sub="",this.url="",this.seoTitle="",this.seoDescription="",this.copied=!1}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.onKeyDown)}firstUpdated(){this.launchConfetti(),this.dismissTimer=setTimeout(()=>this.dismiss(),6500)}disconnectedCallback(){super.disconnectedCallback(),cancelAnimationFrame(this.raf),this.dismissTimer&&clearTimeout(this.dismissTimer),document.removeEventListener("keydown",this.onKeyDown)}t(e,t){return s.M.get("lang",e)||t}get direction(){const e=s.M.get("theme");return e?.direction||"rtl"}get host(){return this.url?this.url.replace(/^https?:\/\//,"").replace(/\/+$/,""):""}launchConfetti(){const e=this.renderRoot.querySelector("canvas");if(!e)return;const t=e.getContext("2d");if(!t)return;const i=window.devicePixelRatio||1,o=window.innerWidth,s=window.innerHeight;e.width=o*i,e.height=s*i,t.scale(i,i);const r=["#e94560","#1a1a2e","#f6c945","#2ec7a9","#4d7cfe","#ffffff"],n=o/2,a=.42*s,l=Math.min(220,Math.round(o/6)),c=Array.from({length:l},(e,t)=>{const i=2*Math.PI*t/l+t%3*.4,o=4+t%9;return{x:n,y:a,vx:Math.cos(i)*o,vy:Math.sin(i)*o-3,size:5+t%5,color:r[t%r.length],rot:t,vrot:(t%2?1:-1)*(.1+t%5*.03),life:1}}),d=performance.now(),h=e=>{const i=e-d;t.clearRect(0,0,o,s);let r=!1;for(const e of c)e.vy+=.16,e.x+=e.vx,e.y+=e.vy,e.rot+=e.vrot,i>2600*.55&&(e.life=Math.max(0,e.life-.02)),e.life>0&&e.y<s+40&&(r=!0),t.save(),t.globalAlpha=e.life,t.translate(e.x,e.y),t.rotate(e.rot),t.fillStyle=e.color,t.fillRect(-e.size/2,-e.size/2,e.size,.6*e.size),t.restore();r&&i<3e3?this.raf=requestAnimationFrame(h):t.clearRect(0,0,o,s)};this.raf=requestAnimationFrame(h)}renderPreview(){const e=this.host;if(!e)return o.s6;const t=(this.seoTitle||"").trim()||(this.seoDescription?"":e),i=(this.seoDescription||"").trim(),s=(t||e).charAt(0);return o.qy`
|
|
347
347
|
<div class="preview">
|
|
348
348
|
<p class="preview-caption">${this.t("search_preview_label","How your page will look on Google")}</p>
|
|
349
349
|
<div class="result-head">
|
|
350
|
-
<span class="favicon">${
|
|
350
|
+
<span class="favicon">${s}</span>
|
|
351
351
|
<div class="result-url">
|
|
352
352
|
<div class="result-host">${e.split("/")[0]}</div>
|
|
353
353
|
<div class="result-crumb">${e}</div>
|
|
354
354
|
</div>
|
|
355
355
|
</div>
|
|
356
|
-
${t?
|
|
357
|
-
${i?
|
|
356
|
+
${t?o.qy`<p class="result-title">${t}</p>`:o.s6}
|
|
357
|
+
${i?o.qy`<p class="result-desc">${i}</p>`:o.s6}
|
|
358
358
|
</div>
|
|
359
|
-
`}render(){const e=this.direction,t=this.copied?
|
|
359
|
+
`}render(){const e=this.direction,t=this.copied?o.qy`<svg viewBox="0 0 24 24" fill="none"><path d="M5 13l4 4L19 7" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" /></svg>`:o.qy`<svg viewBox="0 0 24 24" fill="none"><rect x="9" y="9" width="11" height="11" rx="2" stroke="currentColor" stroke-width="2" /><path d="M5 15V5a2 2 0 0 1 2-2h10" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></svg>`;return o.qy`
|
|
360
360
|
<canvas @click=${this.dismiss}></canvas>
|
|
361
361
|
<div class="card" dir=${e}>
|
|
362
362
|
<button
|
|
@@ -378,7 +378,7 @@
|
|
|
378
378
|
|
|
379
379
|
${this.renderPreview()}
|
|
380
380
|
|
|
381
|
-
${this.url?
|
|
381
|
+
${this.url?o.qy`
|
|
382
382
|
<div class="actions">
|
|
383
383
|
<a class="view" href=${this.url} target="_blank" rel="noopener">
|
|
384
384
|
<svg viewBox="0 0 24 24" fill="none"><path d="M14 4h6v6M20 4l-9 9M18 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /></svg>
|
|
@@ -389,9 +389,9 @@
|
|
|
389
389
|
${this.copied?this.t("link_copied","Link copied"):this.t("copy_link","Copy link")}
|
|
390
390
|
</button>
|
|
391
391
|
</div>
|
|
392
|
-
`:
|
|
392
|
+
`:o.s6}
|
|
393
393
|
</div>
|
|
394
|
-
`}}p.styles=
|
|
394
|
+
`}}p.styles=o.AH`
|
|
395
395
|
:host {
|
|
396
396
|
position: fixed;
|
|
397
397
|
inset: 0;
|
|
@@ -624,21 +624,21 @@
|
|
|
624
624
|
width: 15px;
|
|
625
625
|
height: 15px;
|
|
626
626
|
}
|
|
627
|
-
`,p.properties={message:{type:String},sub:{type:String},url:{type:String},seoTitle:{type:String},seoDescription:{type:String},copied:{type:Boolean}},customElements.define("cdtr-publish-success",p);const u="creaditor:publish",f="creaditor:publish-error";class g extends
|
|
627
|
+
`,p.properties={message:{type:String},sub:{type:String},url:{type:String},seoTitle:{type:String},seoDescription:{type:String},copied:{type:Boolean}},customElements.define("cdtr-publish-success",p);const u="creaditor:publish",f="creaditor:publish-error";class g extends o.WF{constructor(){super(),this.channel="",this.isLoading=!1,this.isLocked=!1,this.lockTimer=null}connectedCallback(){super.connectedCallback(),this.onNextStep||(this.onNextStep=s.M.get("config","onNextStep")),this.onPublish||(this.onPublish=s.M.get("config","onPublish")),this.channel||(this.channel=s.M.get("config","channel")||"")}disconnectedCallback(){super.disconnectedCallback(),this.clearTimers()}clearTimers(){this.lockTimer&&(clearTimeout(this.lockTimer),this.lockTimer=null)}async handleClick(){if(this.isLocked||this.isLoading)return;const e=!!s.M.get("config","access"),t="web"===this.channel,i=e&&t;let o=null;if(t&&(o=await h.open(),!o))return;const a=o?o.seo:null;this.isLoading=!0,this.isLocked=!0;const l=Date.now();this.lockTimer=setTimeout(()=>{this.clearTimers(),this.isLoading=!1,this.isLocked=!1},1e4);try{if(t&&o){let e=!1;try{i&&a&&(await(0,n.YE)({seo:a}),await(0,n.bK)({})),"function"==typeof this.onPublish?e=await this.runHostPublish(this.onPublish,a,i,o):"function"==typeof this.onNextStep&&await this.onNextStep({toHTML:r.FE,toJSON:r.U2,seo:a??void 0})}finally{o.done()}return void(e||(this.emitPublished(i,a),this.celebratePublish(a)))}const e=s.M.get("config","editor","props","onSave");"function"==typeof e&&await e({transactions:[],toJson:r.U2,toJSON:r.U2,toHTML:r.FE}),"function"==typeof this.onNextStep&&await this.onNextStep({toHTML:r.FE,toJSON:r.U2}),this.emitPublished(i,a)}catch(e){console.error("Error in publish/onNextStep:",e),this.emitPublishError(i,a,e),this.snackbar(s.M.get("lang","publishError")||"Publish failed")}finally{const e=Date.now()-l;e<400&&await new Promise(t=>setTimeout(t,400-e)),this.clearTimers(),this.isLoading=!1,this.isLocked=!1}}runHostPublish(e,t,i,o){return new Promise(a=>{let l=!1;const c=(e,r,n)=>{l||(l=!0,clearTimeout(d),o.done(),e?(this.celebratePublish(t),this.emitPublished(i,t)):(this.snackbar(n||s.M.get("lang","publishError")||"Publish failed"),this.emitPublishError(i,t,r)),a(!0))},d=setTimeout(()=>{l||(console.warn("config.onPublish never signalled completion — finishing the publish without it. Call success() or error() (or return a promise) so the modal can come down."),l=!0,o.done(),a(!1))},6e4),h={title:t.title,description:t.description,keywords:t.keywords},p={loading:function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return o.busy(e)},success:()=>c(!0),confetti:()=>c(!0),error:e=>c(!1,new Error(e||"host publish failed"),e),commands:{patchSite:e=>(0,n.YE)(e??{}),publishSite:e=>(0,n.bK)(e??{}),toHTML:r.FE,toJSON:r.U2}};let u;try{u=e(h,p)}catch(e){return console.error("Error in config.onPublish:",e),void c(!1,e)}u&&"function"==typeof u.then&&Promise.resolve(u).then(()=>c(!0),e=>{console.error("Error in config.onPublish:",e),c(!1,e)})})}snackbar(e){const t=s.M.get("commands");t?.snackbar?.(e)}siteUrl(){const e=s.M.get("app","domains"),t=e?.[0]?.name;if(t)return/^https?:\/\//.test(t)?t:`https://${t}`}emitPublished(e,t){const i={channel:this.channel,selfPublish:e,seo:t??void 0,url:this.siteUrl(),toHTML:r.FE,toJSON:r.U2};window.dispatchEvent(new CustomEvent(u,{detail:i}))}emitPublishError(e,t,i){const o={channel:this.channel,selfPublish:e,seo:t??void 0,error:i};window.dispatchEvent(new CustomEvent(f,{detail:o}))}celebratePublish(e){const t=document.createElement("cdtr-publish-success");e&&(t.seoTitle=e.title,t.seoDescription=e.description);const i=this.siteUrl();i&&(t.url=i),document.body.appendChild(t)}render(){const e=!!s.M.get("config","access");if(!(this.onNextStep||"function"==typeof this.onPublish||"web"===this.channel&&e))return null;const t="web"===this.channel?"publish":"next";return o.qy`
|
|
628
628
|
<paper-button
|
|
629
629
|
@click=${this.handleClick}
|
|
630
630
|
class="next-button"
|
|
631
631
|
?disabled=${this.isLocked}
|
|
632
632
|
>
|
|
633
|
-
${this.isLoading?
|
|
633
|
+
${this.isLoading?o.qy`
|
|
634
634
|
<div class="loading-spinner"></div>
|
|
635
|
-
`:
|
|
635
|
+
`:o.qy`
|
|
636
636
|
<div class="button-content ${this.isLoading?"loading":""}">
|
|
637
637
|
<lang-text text=${t}></lang-text>
|
|
638
638
|
</div>
|
|
639
639
|
`}
|
|
640
640
|
</paper-button>
|
|
641
|
-
`}}g.styles=
|
|
641
|
+
`}}g.styles=o.AH`
|
|
642
642
|
:host {
|
|
643
643
|
display: block;
|
|
644
644
|
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[823],{30823(e,t,n){n.d(t,{default:()=>B});var a=n(61919),i=n(79795),o=n(29180);const l=[{value:"dot",label:"ask_ai_variant_dot"},{value:"pill",label:"ask_ai_variant_pill"},{value:"plain",label:"ask_ai_variant_plain"}],r=e=>{const{component:t,commands:n}=e;return{select:e=>{let{changeTab:t,tab:n}=e;n.text||t("content")},tabs:e=>{const t=[{text:"content",selected:!0},{text:"engines"},{text:"style"},{text:"settings"}];return e?(t.forEach(t=>t.selected=t.text===e),t):t},layout:e=>{let{tab:r}=e;const s=()=>"content"===r.text,p=()=>"engines"===r.text,c=()=>"style"===r.text,d=t.props.prompt||"",A=t.props.variant||"dot",m=(0,o.x8)(t.props);var u,g;return[{type:"info",active:s,text:"ask_ai_external_notice"},{type:"heading",level:6,text:"ask_ai_prompt",active:s},{type:"info",active:s,text:"ask_ai_placeholders_hint"},{type:"input",title:"ask_ai_prompt",multiline:!0,row:16,active:s,value:d,onDebounce:e=>{n.execCommand("prompt",e.target.value)}},{type:"info",active:()=>s()&&(0,o.Jq)(d,m).length>o.Ep,text:"ask_ai_prompt_too_long"},{type:"heading",level:6,text:"ask_ai_engines",active:p},...i.ug.map(e=>({type:"checkbox",title:e.label,active:p,checked:(t.props.engines||[]).includes(e.key),onChange:a=>((e,a)=>{const o=t.props.engines||[],l=i.ug.map(e=>e.key).filter(t=>t===e?a:o.includes(t));l.length&&n.execCommand("engines",l)})(e.key,!!a.target.checked)})),{type:"dropdown",title:"ask_ai_variant",active:c,value:l.find(e=>e.value===A)?.label,selected:A,items:l,onChange:e=>n.execCommand("variant",e.target.value)},{type:"input",title:"ask_ai_leading_text",active:c,value:t.props.leadingText||"",onDebounce:e=>n.execCommand("leadingText",e.target.value)},{type:"slider",title:"size",min:16,max:96,active:c,value:parseInt(t.props.iconSize,10)||34,onInput:e=>n.execCommand("iconSize",e.target.value)},{type:"slider",title:"spacing",min:0,max:60,active:c,value:parseFloat(t.props.style?.gap)||0,onInput:e=>n.execCommand("style",{gap:e.target.value+"px"})},{type:"justifyContent",active:c,value:t.props.style?.justifyContent||"flex-start",onChange:e=>n.execCommand("style",{justifyContent:e.target.value})},{type:"divider",active:c},{type:"checkbox",title:"ask_ai_brand_colors",active:c,checked:!t.props.iconColor,onChange:e=>n.execCommand("iconColor",e.target.checked?"":"000000")},{type:"colorpicker",title:"icon_color",alpha:!1,active:()=>c()&&!!t.props.iconColor,value:(u=t.props.iconColor,g="#000000",u?u.startsWith("#")?u:"#"+u:g),onChange:e=>{const t=(0,a.A)(e.target.value).toHex();n.execCommand("iconColor",t)}},{type:"colorpicker",title:"backgroundColor",active:()=>c()&&"plain"!==t.props.variant,value:t.props.bgColor||"#f2f2f2",onChange:e=>n.execCommand("bgColor",e.target.value)},{type:"colorpicker",title:"color",active:()=>c()&&("pill"===t.props.variant||!!t.props.leadingText),value:t.props.textColor||"#000000",onChange:e=>n.execCommand("textColor",e.target.value)}]}}},s=e=>{let{helpers:t}=e;return{set:(e,n,a)=>{switch(n){case"style":return e[n]=t.deepMerge(e[n],a),!0;case"engines":return!!Array.isArray(a)&&(e[n]=a.filter(e=>"string"==typeof e),!0);case"items":return!!Array.isArray(a)&&(e[n]=a,!0);case"iconSize":return e[n]=Math.min(128,Math.max(12,parseInt(a,10)||34)),!0;case"variant":return!!["dot","pill","plain"].includes(a)&&(e[n]=a,!0);case"prompt":case"leadingText":case"itemAriaLabel":case"iconColor":case"bgColor":case"textColor":case"pageUrl":case"pageTitle":case"pageDescription":case"businessName":return e[n]=a,!0}return!1}}};var p=n(72591),c=n.n(p),d=n(88639),A=n.n(d),m=n(88128),u=n.n(m),g=n(30855),C=n.n(g),h=n(93051),x=n.n(h),v=n(49606),y={};y.setAttributes=C(),y.insert=u().bind(null,"head"),y.domAPI=A(),y.insertStyleElement=x();c()(v.A,y);const f=v.A&&v.A.locals?v.A.locals:void 0;var E=n(40856);const b="ask-ai",B=()=>({name:b,create:e=>{let{createElement:t,compose:n,helpers:a}=e;const l=document.createElement("div"),p=document.createElement("div");p.classList.add(f.root),l.appendChild(p);return t({name:b,id:n.id,template:l,defaultProps:{style:{gap:"10px",justifyContent:"flex-start"},variant:"dot",engines:i.up,prompt:(0,o.Mc)(),iconSize:34,iconColor:"",bgColor:"#f2f2f2",textColor:"",leadingText:"",itemAriaLabel:"Ask {{engine}} about this page",items:[]},draggable:{group:"element"},droppable:{group:"element"},render:()=>{const e=n.props,t=(0,E.z)(e);for((0,E.S)(t,e.items)||setTimeout(()=>{n.editor?.updateComponent?.(n.id,"items",t)},0);p.firstChild;)p.removeChild(p.firstChild);if(a.mergeDiff(p,{style:e.style}),e.leadingText){const t=document.createElement("span");t.classList.add(f.leading),t.textContent=e.leadingText,e.textColor&&(t.style.color=e.textColor),p.appendChild(t)}t.forEach(t=>p.appendChild(((e,t)=>{const n=document.createElement("a");n.classList.add(f.item),"dot"===t.variant&&n.classList.add(f.dot),"pill"===t.variant&&n.classList.add(f.pill),n.setAttribute("data-id",e.id),n.href=e.href,n.target="_blank",n.rel="noopener noreferrer",n.setAttribute("aria-label",(t.itemAriaLabel||"Ask {{engine}} about this page").replace("{{engine}}",e.label)),n.title=e.label,"plain"!==t.variant&&t.bgColor&&(n.style.backgroundColor=t.bgColor),t.textColor&&(n.style.color=t.textColor);const a=document.createElement("img");a.src=e.src,a.alt="",a.setAttribute("aria-hidden","true");const i=(parseInt(t.iconSize,10)||34)+"px";if(a.style.width=i,a.style.height=i,n.appendChild(a),"pill"===t.variant){const t=document.createElement("span");t.classList.add(f.label),t.textContent=e.label,n.appendChild(t)}return n.addEventListener("click",e=>e.preventDefault()),n})(t,e)))},handleBar:!0,validator:s({helpers:a}),schema:n.schema,onSelect:e=>{l.classList.add(e)},onDeselect:e=>{l.classList.remove(e)},elementProps:n,remove:()=>{l.remove()},createEditor:r})}})},49606(e,t,n){n.d(t,{A:()=>r});var a=n(82001),i=n.n(a),o=n(40935),l=n.n(o)()(i());l.push([e.id,'.icTm1UFc5X5A8tag7W_Q {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 10px;\n}\n\n.WiVzPdjkN11lPSsmSGBB {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n text-decoration: none;\n line-height: 0;\n transition: transform 0.15s ease, opacity 0.15s ease;\n}\n\n.WiVzPdjkN11lPSsmSGBB:hover {\n transform: translateY(-1px);\n opacity: 0.85;\n}\n\n/* "dot" variant — the circular chip the pattern is usually seen as. */\n._lQONL1oIiZTe42CyXuB {\n border-radius: 999px;\n padding: 8px;\n line-height: 0;\n}\n\n/* "pill" variant — icon plus the engine name. */\n.bTqTp8uamOPSh67_0QtJ {\n border-radius: 999px;\n padding: 6px 14px 6px 10px;\n line-height: 1;\n font-size: 14px;\n}\n\n.fY4pheZcfQxg8DP_HYgE {\n /* Inherits the block\'s font; only the icon is sized by iconSize. */\n white-space: nowrap;\n}\n\n.cnAwK9OBcEyRXbAuQ14D {\n white-space: nowrap;\n}\n\n.SCB1TtYJtUVEle7tVBiu {\n outline: 2px solid #1a73e8;\n outline-offset: 2px;\n}\n',"",{version:3,sources:["webpack://./../web-editors/ask-ai-editor-component/lib/style.module.css"],names:[],mappings:"AAAA;EACE,aAAa;EACb,mBAAmB;EACnB,eAAe;EACf,SAAS;AACX;;AAEA;EACE,oBAAoB;EACpB,mBAAmB;EACnB,uBAAuB;EACvB,QAAQ;EACR,qBAAqB;EACrB,cAAc;EACd,oDAAoD;AACtD;;AAEA;EACE,2BAA2B;EAC3B,aAAa;AACf;;AAEA,sEAAsE;AACtE;EACE,oBAAoB;EACpB,YAAY;EACZ,cAAc;AAChB;;AAEA,gDAAgD;AAChD;EACE,oBAAoB;EACpB,0BAA0B;EAC1B,cAAc;EACd,eAAe;AACjB;;AAEA;EACE,mEAAmE;EACnE,mBAAmB;AACrB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,0BAA0B;EAC1B,mBAAmB;AACrB",sourcesContent:['.root {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 10px;\n}\n\n.item {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n text-decoration: none;\n line-height: 0;\n transition: transform 0.15s ease, opacity 0.15s ease;\n}\n\n.item:hover {\n transform: translateY(-1px);\n opacity: 0.85;\n}\n\n/* "dot" variant — the circular chip the pattern is usually seen as. */\n.dot {\n border-radius: 999px;\n padding: 8px;\n line-height: 0;\n}\n\n/* "pill" variant — icon plus the engine name. */\n.pill {\n border-radius: 999px;\n padding: 6px 14px 6px 10px;\n line-height: 1;\n font-size: 14px;\n}\n\n.label {\n /* Inherits the block\'s font; only the icon is sized by iconSize. */\n white-space: nowrap;\n}\n\n.leading {\n white-space: nowrap;\n}\n\n.selected {\n outline: 2px solid #1a73e8;\n outline-offset: 2px;\n}\n'],sourceRoot:""}]),l.locals={root:"icTm1UFc5X5A8tag7W_Q",item:"WiVzPdjkN11lPSsmSGBB",dot:"_lQONL1oIiZTe42CyXuB",pill:"bTqTp8uamOPSh67_0QtJ",label:"fY4pheZcfQxg8DP_HYgE",leading:"cnAwK9OBcEyRXbAuQ14D",selected:"SCB1TtYJtUVEle7tVBiu"};const r=l}}]);
|
|
Binary file
|