@creaditor/newsletter-starterkit 1.0.56 → 1.0.57
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/1142.creaditor.bundle.js +1 -1
- package/dist/1142.creaditor.bundle.js.gz +0 -0
- package/dist/1260.creaditor.bundle.js +112 -63
- package/dist/1260.creaditor.bundle.js.gz +0 -0
- package/dist/1271.creaditor.bundle.js +544 -1
- package/dist/1271.creaditor.bundle.js.gz +0 -0
- package/dist/1334.creaditor.bundle.js +3 -3
- package/dist/1334.creaditor.bundle.js.gz +0 -0
- package/dist/170.creaditor.bundle.js +149 -22
- package/dist/170.creaditor.bundle.js.gz +0 -0
- package/dist/211.creaditor.bundle.js +1 -1
- package/dist/211.creaditor.bundle.js.gz +0 -0
- package/dist/2234.creaditor.bundle.js +121 -1
- package/dist/2234.creaditor.bundle.js.gz +0 -0
- package/dist/2590.creaditor.bundle.js +1 -1
- package/dist/2590.creaditor.bundle.js.gz +0 -0
- package/dist/271.creaditor.bundle.js +6 -6
- package/dist/271.creaditor.bundle.js.gz +0 -0
- package/dist/2765.creaditor.bundle.js +1 -1
- package/dist/2765.creaditor.bundle.js.gz +0 -0
- package/dist/2956.creaditor.bundle.js +1 -1
- package/dist/2956.creaditor.bundle.js.gz +0 -0
- package/dist/3521.creaditor.bundle.js +2 -2
- package/dist/3521.creaditor.bundle.js.gz +0 -0
- package/dist/353.creaditor.bundle.js +3 -3
- package/dist/353.creaditor.bundle.js.gz +0 -0
- package/dist/3553.creaditor.bundle.js +1 -1
- package/dist/3553.creaditor.bundle.js.gz +0 -0
- package/dist/3606.creaditor.bundle.js +12 -4
- package/dist/3606.creaditor.bundle.js.gz +0 -0
- package/dist/3932.creaditor.bundle.js +4 -4
- package/dist/3932.creaditor.bundle.js.gz +0 -0
- package/dist/4061.creaditor.bundle.js +177 -0
- package/dist/4061.creaditor.bundle.js.LICENSE.txt +23 -0
- package/dist/4061.creaditor.bundle.js.LICENSE.txt.gz +0 -0
- package/dist/4061.creaditor.bundle.js.gz +0 -0
- package/dist/4186.creaditor.bundle.js +5 -1
- package/dist/4186.creaditor.bundle.js.gz +0 -0
- package/dist/4288.creaditor.bundle.js +10 -10
- package/dist/4288.creaditor.bundle.js.gz +0 -0
- package/dist/4475.creaditor.bundle.js +1 -1
- package/dist/4475.creaditor.bundle.js.gz +0 -0
- package/dist/453.creaditor.bundle.js +8 -7
- package/dist/453.creaditor.bundle.js.gz +0 -0
- package/dist/4639.creaditor.bundle.js +1 -1
- package/dist/4639.creaditor.bundle.js.gz +0 -0
- package/dist/4762.creaditor.bundle.js +4 -4
- package/dist/4762.creaditor.bundle.js.gz +0 -0
- package/dist/4770.creaditor.bundle.js +3 -3
- package/dist/4770.creaditor.bundle.js.gz +0 -0
- package/dist/5133.creaditor.bundle.js +3 -3
- package/dist/5133.creaditor.bundle.js.gz +0 -0
- package/dist/5379.creaditor.bundle.js +70 -0
- package/dist/5379.creaditor.bundle.js.gz +0 -0
- package/dist/5391.creaditor.bundle.js +1 -1
- package/dist/5391.creaditor.bundle.js.gz +0 -0
- package/dist/567.creaditor.bundle.js +469 -364
- package/dist/567.creaditor.bundle.js.gz +0 -0
- package/dist/5849.creaditor.bundle.js +2 -2
- package/dist/5849.creaditor.bundle.js.gz +0 -0
- package/dist/589.creaditor.bundle.js +25 -8
- package/dist/589.creaditor.bundle.js.gz +0 -0
- package/dist/5909.creaditor.bundle.js +651 -0
- package/dist/5909.creaditor.bundle.js.gz +0 -0
- package/dist/5926.creaditor.bundle.js +216 -34
- package/dist/5926.creaditor.bundle.js.gz +0 -0
- package/dist/638.creaditor.bundle.js +49 -20
- package/dist/638.creaditor.bundle.js.gz +0 -0
- package/dist/6814.creaditor.bundle.js +1 -1
- package/dist/6814.creaditor.bundle.js.gz +0 -0
- package/dist/7209.creaditor.bundle.js +98 -56
- package/dist/7209.creaditor.bundle.js.gz +0 -0
- package/dist/752.creaditor.bundle.js +6 -4
- package/dist/752.creaditor.bundle.js.gz +0 -0
- package/dist/7564.creaditor.bundle.js +1 -1
- package/dist/7564.creaditor.bundle.js.gz +0 -0
- package/dist/763.creaditor.bundle.js +9 -9
- package/dist/763.creaditor.bundle.js.gz +0 -0
- package/dist/7654.creaditor.bundle.js +221 -0
- package/dist/7654.creaditor.bundle.js.gz +0 -0
- package/dist/7918.creaditor.bundle.js +1 -0
- package/dist/7918.creaditor.bundle.js.gz +0 -0
- package/dist/7937.creaditor.bundle.js +21 -48
- package/dist/7937.creaditor.bundle.js.gz +0 -0
- package/dist/7997.creaditor.bundle.js +1 -1
- package/dist/7997.creaditor.bundle.js.gz +0 -0
- package/dist/8141.creaditor.bundle.js +2 -3
- package/dist/8141.creaditor.bundle.js.gz +0 -0
- package/dist/8250.creaditor.bundle.js +1 -1
- package/dist/8250.creaditor.bundle.js.gz +0 -0
- package/dist/8443.creaditor.bundle.js +1 -1
- package/dist/8443.creaditor.bundle.js.gz +0 -0
- package/dist/8547.creaditor.bundle.js +1270 -0
- package/dist/8547.creaditor.bundle.js.gz +0 -0
- package/dist/8570.creaditor.bundle.js +3 -3
- package/dist/8570.creaditor.bundle.js.gz +0 -0
- package/dist/8646.creaditor.bundle.js +20 -24
- package/dist/8646.creaditor.bundle.js.gz +0 -0
- package/dist/8654.creaditor.bundle.js +7 -7
- package/dist/8654.creaditor.bundle.js.gz +0 -0
- package/dist/8854.creaditor.bundle.js +4 -4
- package/dist/8854.creaditor.bundle.js.gz +0 -0
- package/dist/8916.creaditor.bundle.js +3 -1
- package/dist/8916.creaditor.bundle.js.gz +0 -0
- package/dist/9041.creaditor.bundle.js +14 -16
- package/dist/9041.creaditor.bundle.js.gz +0 -0
- package/dist/9250.creaditor.bundle.js +1 -1
- package/dist/9250.creaditor.bundle.js.gz +0 -0
- package/dist/9431.creaditor.bundle.js +1 -1
- package/dist/9431.creaditor.bundle.js.gz +0 -0
- package/dist/9694.creaditor.bundle.js +1 -1
- package/dist/9694.creaditor.bundle.js.gz +0 -0
- package/dist/creaditor.bundle.js +2848 -1978
- package/dist/creaditor.bundle.js.LICENSE.txt +6 -0
- package/dist/creaditor.bundle.js.LICENSE.txt.gz +0 -0
- 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 +1,544 @@
|
|
|
1
|
-
"use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[1271],{71271(e,t,n){n.d(t,{default:()=>v});var o=n(53577),i=n(74265),a=n(86319),s=n(20252);const l=[100,300,400,500,600,700,900].map(e=>({value:String(e),label:String(e)})),r=e=>{{const{component:t,commands:n,helpers:r}=e,c=t.tiptap,p=c.state.selection.$anchor.node().attrs,d=c.isActive("heading",{level:1})?"h1":c.isActive("heading",{level:2})?"h2":c.isActive("heading",{level:3})?"h3":c.isActive("heading",{level:4})?"h4":c.isActive("heading",{level:5})?"h5":c.isActive("heading",{level:6})?"h6":"paragraph";let u=e.languageJson;const g=e.language||"he";return u||(u="he"===g?o:i),{select:e=>{let{changeTab:t,tab:n}=e},tabs:e=>{const t=c.isActive("customBulletItem"),n=[{text:"design",selected:!t},...t?[{text:"icons",selected:!0}]:[],{text:"settings"}];return n.forEach(t=>t.selected=t.text===e),n},layout:e=>{let{tab:o,changeTab:i,tabs:r}=e;return[{type:"info",text:"text_micro_copy",active:()=>"design"===o.text},{type:"heading",level:6,text:"typography",active:()=>"design"===o.text},{type:"dropdown",active:()=>"design"===o.text,title:"type",value:d,items:[{value:"H1"},{value:"H2"},{value:"H3"},{value:"H4"},{value:"H5"},{value:"H6"},{value:"paragraph"}],onChange:e=>{const t=e.target.value;switch(t){case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":c.chain().setHeading({level:parseInt(t.slice(1))}).run();break;case"paragraph":c.chain().setParagraph().run()}}},{type:"slider",title:"fontSize",min:8,step:2,max:74,value:parseInt(c.getAttributes("textStyle").fontSize||"16px"),active:()=>"design"===o.text,onInput:e=>{const n=e.target.value,o=t.tiptap,i=o.view.state.selection;i.from===i.to?o.chain().selectAll().setFontSize(n).run():o.chain().setFontSize(n).run()}},{type:"dropdown",title:"fontWeight",active:()=>"design"===o.text&&"web"===a.M.get("config","channel"),value:String(c.getAttributes("textStyle").fontWeight||400),selected:String(c.getAttributes("textStyle").fontWeight||400),items:l,onChange:e=>{const n=e.target.value,o=t.tiptap,i=o.view.state.selection;i.from===i.to?o.chain().selectAll().setFontWeight(n).run():o.chain().setFontWeight(n).run()}},{type:"checkbox",title:"smart_change",active:()=>"design"===o.text,checked:(0,s.z)(),onChange:e=>{(0,s.R)(!!e.target.checked)}},{type:"heading",level:6,text:"spacing",active:()=>"design"===o.text},{type:"slider",title:"lineHeight",min:1,max:3,step:.1,value:parseFloat(p.lineHeight||1),active:()=>"design"===o.text,onInput:e=>{const n=e.target.value,o=t.tiptap,i=o.view.state.selection;i.from===i.to?o.chain().selectAll().setLineHeight(n).run():o.chain().setLineHeight(n).run()}},{type:"slider",title:"letterSpacing",min:1,max:10,step:1,value:parseFloat(p.letterSpacing)||1,active:()=>"design"===o.text,onInput:e=>{const n=e.target.value,o=t.tiptap,i=o.view.state.selection;n<=1?i.from===i.to?o.chain().selectAll().setLetterSpacing("normal").run():o.chain().setLetterSpacing("normal").run():i.from===i.to?o.chain().selectAll().setLetterSpacing(n+"px").run():o.chain().setLetterSpacing(n+"px").run()}},{type:"heading",level:6,text:"colors",active:()=>"design"===o.text},{type:"colorSwatchGroup",active:()=>"design"===o.text,columns:2,items:[{title:"font_color",value:c.getAttributes("textStyle").color||"#000000",onChange:e=>{const n=e.target.value,o=t.tiptap,i=o.view.state.selection;if(i.from===i.to){const{state:e,view:t}=o,i=e.tr,{from:a,to:s}={from:0,to:e.doc.content.size};e.doc.nodesBetween(a,s,(t,o)=>{if(t.isText){t.marks.some(e=>"link"===e.type.name)||i.addMark(o,o+t.nodeSize,e.schema.marks.textStyle.create({color:n}))}}),t.dispatch(i)}else o.chain().setColor(n).focus().run()}},{title:"backgroundColor",allowGradient:!0,value:t.props.style.background||t.props.style.backgroundColor||"#ffffff",onChange:e=>{const t=e.target.value;n.execCommand("style",{background:t,backgroundColor:null})}}]},{type:"heading",level:6,text:"layout",active:()=>"design"===o.text},{type:"slider",active:()=>"design"===o.text,title:"maxWidth",value:parseFloat(t.props.style.width),min:20,max:1e3,onInput:e=>{const t=e.target.value;n.execCommand("style",{width:t+"px"})}},{type:"divider"},{type:"colorpicker",active:()=>"icons"===o.text,title:u.iconColor||"Icon color",alpha:!1,value:c.getAttributes(" textStyle").color||"#0000",onChange:e=>{const t=e.target.value;c.chain().setCustomBulletStyles({fill:t}).run()}},{type:"divider",active:()=>"icons"===o.text},{type:"slider",active:()=>"icons"===o.text,title:u.iconSize||"Icon size",value:parseInt(c.getAttributes("customBulletItem").width)||24,min:10,max:40,onInput:e=>{const t=e.target.value;c.chain().setCustomBulletStyles({width:t+"px",height:t+"px"}).run()}},{type:"icons",active:()=>"icons"===o.text,selectedIcon:t.props.src,useIconsApi:!0,iconColor:t.props.iconColor||"000000",iconSize:parseInt(t.props.style?.width,10)||24,onChange:e=>{const n=e.detail;t.tiptap.chain().focus().setCustomBulletIcon({svgIcon:n.urlPng}).run()}}]}}}};var c=n(52144);const p=e=>{let{helpers:t,tiptap:n,composeId:o,template:i}=e;return{set:(e,a,s)=>{switch(a){case"style":return"object"==typeof s&&(e[a]=(0,c.A)(e[a],s),t.mergeDiff(i,{style:e[a]})),!0;case"text":e[a]=s;const l=n.getJSON();return s&&"object"==typeof s&&JSON.stringify(l)!==JSON.stringify(s.childNodes)&&(s&&s.focusedElement&&s.focusedElement===o?(n.chain().focus().setContent(s.childNodes).run(),s.to&&s.from&&n.commands.setTextSelection({from:s.from,to:s.to})):n.chain().setContent(s.childNodes).run()),delete e?.text?.markdown,!0}}}};var d=n(84488),u=n.n(d);n(70567);const g=[];let h=!1,m=null;const v=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t="text";return{name:t,create:n=>{const{createElement:o,compose:i,helpers:s}=n,{mergeDiff:l}=s,c=document.createElement("div");l(c,{style:i.props.style});const d=a.M.get("config","editor","configure","editorProps","fonts");let v=a.M.get("config","target");"string"==typeof v&&(v=document.querySelector(v)),v||(v=document.body);const y=u()({element:c,container:v||document.body,editable:!0,offsetTop:40,onClickMagic:e=>{let{insertContent:t,getJSON:n,getHTML:o,getText:i,selectAll:s,insertContentHtml:l}=e;const r=a.M.get("injectEditor"),c=document.createElement("cdtr-text-prompt-editor");r(c),c.context=i(),c.addEventListener("text-generation-start",e=>{s()}),c.addEventListener("text-generation-chunk",e=>{t(e.detail.chunk)}),c.addEventListener("text-generation-complete",e=>{s(),l(e.detail.text)}),c.addEventListener("text-generation-error",e=>{console.error("Text generation error:",e.detail.error)})},content:"string"==typeof i.props.text.markdown?i.props.text.markdown:i.props.text.childNodes,defaultDirection:"rtl",onBlur:()=>{m===y&&(m=null),setTimeout(()=>{m!==y&&(h=!1)},150)},onFocus:()=>{if(!h||m===y||null===m){if(h=!0,m=y,g.length>0)for(g.forEach(e=>{e!==y&&e.hideEditor()});g.length>0;)g.pop();g.push(y),setTimeout(()=>{m===y&&h&&y.showEditor()},100)}},onUpdate:e=>{let{editor:t,transaction:n}=e;if(0===n.steps.length)return;const o=n.curSelection.from,a=n.curSelection.to,s={childNodes:t.getJSON(),from:o,to:a,focusedElement:i.id};f.commands.execCommand("text",s)},ignoresBlurByQuerySelectors:[".ignore-events"],builder:[{type:"fontFamily",fonts:d||[],useCloud:!0},{type:"fontSize",sizes:e.fontSize||[8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74]},{type:"horizonRule"},{type:"clearFormat"},{type:"bold"},{type:"strike"},{type:"italic"},{type:"underline"},{type:"table"},{type:"emoji"},{type:"unLink"},{type:"link"},{type:"customList"},{type:"numbered"},{type:"bullet"},{type:"backcolor"},{type:"fontColor"},{type:"direction"},{type:"justify"},{type:"right"},{type:"center"},{type:"left"},{type:"image"},{type:"mergeTags"},{type:"magic"}]}),f=o({name:t,id:i.id,template:c,defaultProps:{text:{},style:{}},draggable:{group:"element"},droppable:{group:"element"},resizeable:()=>c,handleBar:!0,validator:p({template:c,helpers:s,tiptap:y,composeId:i.id}),schema:i.schema,onSelect:e=>{c.classList.add(e)},onDeselect:e=>{c.classList.remove(e)},elementProps:i,remove:()=>{c.remove()},createEditor:r});return i.props.text.markdown&&y.chain().insertContent(" ").run(),f.addProp("tiptap",y),f}}}}}]);
|
|
1
|
+
"use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[567,1271],{70567(e,t,n){n.r(t),n.d(t,{TextPromptEditor:()=>b});var s,i,o=n(86959),a=n(86319),r=n(59929),l=n(49410);const c="/api/text-color",p=()=>{try{const e=a.M.get("app","_id");return"string"==typeof e&&e.length>0?e:null}catch(e){return null}},d="#111827",h="#ffffff",g=e=>{const t=/^#?([0-9a-f]{6})$/i.exec((e||"").trim());if(!t)return null;const n=parseInt(t[1],16);return{r:n>>16&255,g:n>>8&255,b:255&n}},m=e=>{const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)},u=e=>{let{r:t,g:n,b:s}=e;return.2126*m(t)+.7152*m(n)+.0722*m(s)},f=(e,t)=>{const n=g(e),s=g(t);if(!n||!s)return 1;const i=u(n),o=u(s);return(Math.max(i,o)+.05)/(Math.min(i,o)+.05)},x=(e,t,n)=>e&&f(e,t)>=n?e:f(d,t)>=f(h,t)?d:h,y={en:{title:"Edit with AI",placeholder:"Tell me how to change this text…",send:"Send",thinking:"Working…",keepLength:"Keep length",editingSelection:"Selection",editingElement:"Whole text",error:"Something went wrong. Please try again.",empty:"Ask me to improve, shorten, or rewrite this text.",roleHeading:"Headings",roleBody:"Body",colorize:"Colorize",colorizing:"Picking colors…",colorizeDone:"Applied on-brand colors.",actions:{improve:"Improve",shorten:"Shorten",lengthen:"Lengthen",grammar:"Fix grammar",tone:"Warmer tone"},prompts:{improve:"Improve this text — make it clearer and more compelling. Keep the meaning.",shorten:"Make this shorter and more concise, without losing the key point.",lengthen:"Expand this with a little more detail and flow.",grammar:"Fix any spelling and grammar mistakes. Keep the wording and meaning.",tone:"Make the tone warmer and friendlier."}},he:{title:"עריכה עם AI",placeholder:"כתבו לי איך לשנות את הטקסט…",send:"שליחה",thinking:"עובד…",keepLength:"שמור על האורך",editingSelection:"קטע מסומן",editingElement:"כל הטקסט",error:"משהו השתבש. נסו שוב.",empty:"בקשו ממני לשפר, לקצר או לנסח מחדש את הטקסט.",roleHeading:"כותרות",roleBody:"טקסט",colorize:"צביעה חכמה",colorizing:"בוחר צבעים…",colorizeDone:"הוחלו צבעים בהתאמה למותג.",actions:{improve:"שיפור",shorten:"קיצור",lengthen:"הרחבה",grammar:"תיקון שגיאות",tone:"טון חם יותר"},prompts:{improve:"שפר את הטקסט הזה — שיהיה ברור ומשכנע יותר, בלי לשנות את המשמעות.",shorten:"קצר את הטקסט הזה ותהפוך אותו לתמציתי יותר, בלי לאבד את העיקר.",lengthen:"הרחב את הטקסט הזה עם עוד קצת פירוט וזרימה.",grammar:"תקן שגיאות כתיב ודקדוק. שמור על הניסוח והמשמעות.",tone:"הפוך את הטון לחם וידידותי יותר."}}};let b=(0,l.EM)("cdtr-text-prompt-editor")(((i=class extends r.WF{constructor(){super(),this.commands=null,this.elementId=null,this._messages=[],this._input="",this._busy=!1,this._colorizing=!1,this._scope="element",this._error="",this._keepLength=!1,this._lang="he",this._selPreview="",this._streamingIdx=null}connectedCallback(){super.connectedCallback();const e=a.M.get("config","language"),t=this.commands&&this.commands.getText&&this.commands.getText()||"";this._lang="he"===e||"en"===e?e:t?/[\u0590-\u05FF]/.test(t||"")?"he":"en":"rtl"===document?.documentElement?.dir?"he":"en",this._scope=this._currentScope(),this._selPreview=this._readSelPreview(),this._onSelChange=()=>{const e=this._currentScope();e!==this._scope&&(this._scope=e);const t=this._readSelPreview();t!==this._selPreview&&(this._selPreview=t)},this.commands?.onSelectionChange&&(this._unsubSel=this.commands.onSelectionChange(this._onSelChange)),document.addEventListener("selectionchange",this._onSelChange),setTimeout(()=>{const e=this.renderRoot?.querySelector(".composer-input");e&&e.focus()},50),this._hydrate()}async _hydrate(){const e=p();if(!e||!this.elementId)return;const t=await this._resolveToken(!1);if(!t)return;const n=`${o.XW.studio_url}/api/datastore/sessions/by-doc?doc_id=${encodeURIComponent(e)}&surface=text-element&element_id=${encodeURIComponent(this.elementId)}`;try{const e=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${t}`}});if(!e.ok)return;const s=await e.json(),i=Array.isArray(s?.messages)?s.messages:[];if(0===i.length)return;if(this._messages.length>0||this._busy)return;this._messages=i.filter(e=>e&&("user"===e.role||"assistant"===e.role)).map(e=>({role:e.role,content:e.content})).filter(e=>"string"==typeof e.content&&e.content.length>0)}catch(e){}}disconnectedCallback(){super.disconnectedCallback(),this._unsubSel&&(this._unsubSel(),this._unsubSel=null),this._onSelChange&&(document.removeEventListener("selectionchange",this._onSelChange),this._onSelChange=null)}get t(){const e=y[this._lang]||y.en,t=e=>{const t=a.M.get("lang",e);return"string"==typeof t&&t?t:void 0};return{title:t("text_ai_title")??e.title,placeholder:t("text_ai_placeholder")??e.placeholder,send:t("text_ai_send")??e.send,thinking:t("text_ai_thinking")??e.thinking,keepLength:t("text_ai_keep_length")??e.keepLength,editingSelection:t("text_ai_scope_selection")??e.editingSelection,editingElement:t("text_ai_scope_element")??e.editingElement,error:t("text_ai_error")??e.error,empty:t("text_ai_empty")??e.empty,roleHeading:t("text_ai_role_heading")??e.roleHeading,roleBody:t("text_ai_role_body")??e.roleBody,colorize:t("text_ai_action_colorize")??e.colorize,colorizing:t("text_ai_colorizing")??e.colorizing,colorizeDone:t("text_ai_colorize_done")??e.colorizeDone,actions:{improve:t("text_ai_action_improve")??e.actions.improve,shorten:t("text_ai_action_shorten")??e.actions.shorten,lengthen:t("text_ai_action_lengthen")??e.actions.lengthen,grammar:t("text_ai_action_grammar")??e.actions.grammar,tone:t("text_ai_action_tone")??e.actions.tone},prompts:{improve:t("text_ai_prompt_improve")??e.prompts.improve,shorten:t("text_ai_prompt_shorten")??e.prompts.shorten,lengthen:t("text_ai_prompt_lengthen")??e.prompts.lengthen,grammar:t("text_ai_prompt_grammar")??e.prompts.grammar,tone:t("text_ai_prompt_tone")??e.prompts.tone}}}_currentScope(){const e=this.commands;return e&&e.hasSelection&&e.hasSelection()?"selection":"element"}_readSelPreview(){const e=this.commands;if(!e||!e.hasSelection||!e.hasSelection())return"";const t=e.getSelectionText&&e.getSelectionText()||"";return this._truncateMiddle(t.replace(/\s+/g," ").trim(),96)}_truncateMiddle(e,t){if(e.length<=t)return e;const n=Math.ceil(.6*(t-1)),s=t-1-n;return`${e.slice(0,n)}…${e.slice(e.length-s)}`}_dismissSelection(){const e=this.commands,t=e&&e.getSelectionRange&&e.getSelectionRange();t&&e.setSelectionRange&&e.setSelectionRange(t.to,t.to),this._scope="element",this._selPreview=""}_onInput(e){this._input=e.target.value}_onKeydown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this._send(this._input))}_quickAction(e){this._send(this.t.prompts[e])}_toggleKeepLength(e){this._keepLength=!!e.target.checked}async _send(e){const t=(e||"").trim();if(!t||this._busy||!this.commands)return;const n=this._currentScope();this._scope=n;const s="selection"===n?this.commands.getSelectionHTML?.()??this.commands.getSelectionText():this.commands.getHTML?.()??this.commands.getText(),i="heading"===(this.commands.getBlockType?.()||{}).type?"title":"paragraph";this._messages=[...this._messages,{role:"user",content:t}],this._input="",this._error="",this._busy=!0;const o=this._messages.filter(e=>"user"===e.role||"assistant"===e.role).map(e=>({role:e.role,content:(e.content||"").slice(0,8e3)})).filter(e=>e.content.length>0),a=p(),r={messages:o,text:(s||"").slice(0,4e4),scope:n,format:"html",contentType:i,keepLength:this._keepLength,language:this._lang,...a?{doc_id:a}:{},...a&&this.elementId?{element_id:this.elementId}:{}};try{await this._runStream(r,n)}catch(e){console.error("[text-chat] turn failed:",e),this._error=this.t.error,this._messages=[...this._messages,{role:"error",content:this.t.error}]}finally{this._busy=!1,this._streamingIdx=null,this._scope=this._currentScope(),this._selPreview=this._readSelPreview()}}async _resolveToken(e){const t=a.M.get("resolveStudioToken");if("function"!=typeof t)return console.warn("[text-chat] no resolveStudioToken on store; request will likely 401."),null;try{return await t({forceRefresh:!!e})}catch(e){return console.warn("[text-chat] token resolution failed:",e),null}}async _postTo(e,t,n,s){const i=await this._resolveToken(n),a={"Content-Type":"application/json",Accept:s||"application/json"};return i&&(a.Authorization=`Bearer ${i}`),fetch(o.XW.studio_url+e,{method:"POST",headers:a,body:JSON.stringify(t)})}async _post(e,t){return this._postTo("/api/text-chat",e,t,"text/event-stream, application/json")}_gatherPalette(){const e=new Set,t=(n,s)=>{if(!(s>5||null==n))return"string"==typeof n?(t=>{const n=/^#?([0-9a-f]{6})$/i.exec((t||"").trim());n&&e.add(`#${n[1].toLowerCase()}`)})(n):Array.isArray(n)?n.forEach(e=>t(e,s+1)):"object"==typeof n?Object.values(n).forEach(e=>t(e,s+1)):void 0};try{t(a.M.get("colorPalletes"),0)}catch(e){}return Array.from(e).slice(0,48)}async _postColor(e){let t=await this._postTo(c,e,!1);401===t.status&&(t=await this._postTo(c,e,!0));let n=null;try{n=await t.json()}catch(e){}if(!t.ok||!n||!1===n.ok)throw new Error(n&&n.reason||`HTTP ${t.status}`);return n}async _colorize(){if(this._busy||this._colorizing||!this.commands)return;const e=this.commands,t=e.getBlocks&&e.getBlocks()||[];if(!t.length)return;const n=e=>"heading"===e.type?"heading":"body",s=Array.from(new Set(t.map(n))),i=e.getBackgroundColor&&e.getBackgroundColor()||h,o=this._gatherPalette(),a=t.filter(e=>"heading"===n(e)).map(e=>e.text).join(" ").slice(0,500),r=t.filter(e=>"body"===n(e)).map(e=>e.text).join(" ").slice(0,500);this._messages=[...this._messages,{role:"user",content:`🎨 ${this.t.colorize}`}],this._error="",this._colorizing=!0,this._busy=!0;try{const l=await this._postColor({roles:s,background:i,palette:o,...a?{headingText:a}:{},...r?{bodyText:r}:{},language:this._lang}),c=l.heading?x(l.heading,i,3):null,p=l.body?x(l.body,i,4.5):null;t.forEach(t=>{const s="heading"===n(t)?c:p;s&&e.setColorRange&&e.setColorRange(t.from,t.to,s)});const d=[];c&&d.push({label:this.t.roleHeading,color:c}),p&&d.push({label:this.t.roleBody,color:p}),this._messages=[...this._messages,{role:"assistant",content:l.rationale||this.t.colorizeDone,swatches:d}]}catch(e){console.error("[text-color] colorize failed:",e),this._error=this.t.error,this._messages=[...this._messages,{role:"error",content:this.t.error}]}finally{this._colorizing=!1,this._busy=!1}}async _runStream(e,t){let n=await this._post(e,!1);if(401===n.status&&(n=await this._post(e,!0)),!n.ok){let e=`HTTP ${n.status}`;try{const t=await n.json();t&&t.reason&&(e=t.reason)}catch{}throw new Error(e)}const s=this._messages.length;this._messages=[...this._messages,{role:"assistant",content:""}],this._streamingIdx=s;let i="";await this._consumeSse(n.body,(e,t)=>{if("text"===e&&t&&"string"==typeof t.delta)i+=t.delta,this._updateAssistant(s,(e=>{const t=document.createElement("div");return t.innerHTML=e||"",(t.textContent||"").replace(/^[#>\-\s]+/gm,"").replace(/\*\*?|__?|`|~~/g,"").replace(/\|/g," ").replace(/\n{2,}/g,"\n").trim()})(i));else if("error"===e)throw new Error(t&&t.reason||"stream error")}),i.trim()&&("element"===t?(this.commands.selectAll(),this.commands.insertContentHtml(i)):this.commands.insertInlineMarkdown?this.commands.insertInlineMarkdown(i):this.commands.insertContent(i))}_updateAssistant(e,t){const n=this._messages.slice();n[e]&&(n[e]={role:"assistant",content:t}),this._messages=n}async _consumeSse(e,t){const n=e.getReader(),s=new TextDecoder;let i="";try{for(;;){const{done:e,value:o}=await n.read();if(e)break;let a;for(i+=s.decode(o,{stream:!0});-1!==(a=i.indexOf("\n\n"));){const e=i.slice(0,a);i=i.slice(a+2);let n,s="message",o="";for(const t of e.split("\n"))t.startsWith("event:")?s=t.slice(6).trim():t.startsWith("data:")&&(o+=(o?"\n":"")+t.slice(5).replace(/^ /,""));if(o){try{n=JSON.parse(o)}catch{continue}t(s,n)}}}}finally{try{n.releaseLock()}catch{}}}render(){const e=this.t,t="he"===this._lang,n=this._messages.length>0||this._busy,s=!this._busy&&this._input.trim().length>0;return r.qy`
|
|
2
|
+
<cdtr-editor-container>
|
|
3
|
+
<div class="ai" dir=${t?"rtl":"ltr"}>
|
|
4
|
+
<header class="ai-head">
|
|
5
|
+
<span class="brand">
|
|
6
|
+
<span class="spark">✨</span>
|
|
7
|
+
<span class="brand-title">${e.title}</span>
|
|
8
|
+
</span>
|
|
9
|
+
<span class="scope" data-scope=${this._scope}>
|
|
10
|
+
${"selection"===this._scope?e.editingSelection:e.editingElement}
|
|
11
|
+
</span>
|
|
12
|
+
</header>
|
|
13
|
+
|
|
14
|
+
<div class="quick">
|
|
15
|
+
${["improve","shorten","lengthen","grammar","tone"].map(t=>r.qy`
|
|
16
|
+
<button
|
|
17
|
+
class="chip"
|
|
18
|
+
?disabled=${this._busy}
|
|
19
|
+
@click=${()=>this._quickAction(t)}
|
|
20
|
+
>
|
|
21
|
+
${e.actions[t]}
|
|
22
|
+
</button>
|
|
23
|
+
`)}
|
|
24
|
+
<button
|
|
25
|
+
class="chip chip--color"
|
|
26
|
+
?disabled=${this._busy}
|
|
27
|
+
@click=${()=>this._colorize()}
|
|
28
|
+
title=${e.colorize}
|
|
29
|
+
>
|
|
30
|
+
<span class="chip-swatch"></span>
|
|
31
|
+
${this._colorizing?e.colorizing:e.colorize}
|
|
32
|
+
</button>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<label class="keeplen">
|
|
36
|
+
<input
|
|
37
|
+
type="checkbox"
|
|
38
|
+
.checked=${this._keepLength}
|
|
39
|
+
?disabled=${this._busy}
|
|
40
|
+
@change=${this._toggleKeepLength}
|
|
41
|
+
/>
|
|
42
|
+
<span>${e.keepLength}</span>
|
|
43
|
+
</label>
|
|
44
|
+
|
|
45
|
+
${n?r.qy`<div class="log">
|
|
46
|
+
${this._messages.map((e,t)=>{const n="assistant"===e.role&&t===this._streamingIdx,s=n&&!e.content;return r.qy`
|
|
47
|
+
<div class="msg ${e.role}">
|
|
48
|
+
<div
|
|
49
|
+
class="bubble ${n?"streaming":""} ${s?"thinking":""}"
|
|
50
|
+
>
|
|
51
|
+
${s?r.qy`<span class="dot"></span><span class="dot"></span
|
|
52
|
+
><span class="dot"></span>`:r.qy`${e.content}${e.swatches&&e.swatches.length?r.qy`<span class="swatches">
|
|
53
|
+
${e.swatches.map(e=>r.qy`<span
|
|
54
|
+
class="swatch"
|
|
55
|
+
title=${e.label}
|
|
56
|
+
>
|
|
57
|
+
<span
|
|
58
|
+
class="swatch-dot"
|
|
59
|
+
style="background:${e.color}"
|
|
60
|
+
></span>
|
|
61
|
+
<span class="swatch-label"
|
|
62
|
+
>${e.label}</span
|
|
63
|
+
>
|
|
64
|
+
</span>`)}
|
|
65
|
+
</span>`:""}`}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
`})}
|
|
69
|
+
${this._busy&&null===this._streamingIdx?r.qy`<div class="msg assistant">
|
|
70
|
+
<div class="bubble thinking">
|
|
71
|
+
<span class="dot"></span><span class="dot"></span
|
|
72
|
+
><span class="dot"></span>
|
|
73
|
+
</div>
|
|
74
|
+
</div>`:""}
|
|
75
|
+
</div>`:r.qy`<p class="hint">${e.empty}</p>`}
|
|
76
|
+
|
|
77
|
+
${"selection"===this._scope&&this._selPreview?r.qy`<div class="selpill" title=${this._selPreview}>
|
|
78
|
+
<span class="selpill-label">${e.editingSelection}</span>
|
|
79
|
+
<span class="selpill-text">"${this._selPreview}"</span>
|
|
80
|
+
<button
|
|
81
|
+
class="selpill-x"
|
|
82
|
+
title=${e.editingElement}
|
|
83
|
+
aria-label=${e.editingElement}
|
|
84
|
+
?disabled=${this._busy}
|
|
85
|
+
@click=${this._dismissSelection}
|
|
86
|
+
>
|
|
87
|
+
✕
|
|
88
|
+
</button>
|
|
89
|
+
</div>`:""}
|
|
90
|
+
|
|
91
|
+
<div class="composer">
|
|
92
|
+
<textarea
|
|
93
|
+
class="composer-input"
|
|
94
|
+
rows="1"
|
|
95
|
+
.value=${this._input}
|
|
96
|
+
placeholder=${e.placeholder}
|
|
97
|
+
?disabled=${this._busy}
|
|
98
|
+
@input=${this._onInput}
|
|
99
|
+
@keydown=${this._onKeydown}
|
|
100
|
+
></textarea>
|
|
101
|
+
<button
|
|
102
|
+
class="send"
|
|
103
|
+
title=${e.send}
|
|
104
|
+
aria-label=${e.send}
|
|
105
|
+
?disabled=${!s}
|
|
106
|
+
@click=${()=>this._send(this._input)}
|
|
107
|
+
>
|
|
108
|
+
<svg
|
|
109
|
+
class=${t?"flip":""}
|
|
110
|
+
viewBox="0 0 24 24"
|
|
111
|
+
width="18"
|
|
112
|
+
height="18"
|
|
113
|
+
fill="none"
|
|
114
|
+
stroke="currentColor"
|
|
115
|
+
stroke-width="2"
|
|
116
|
+
stroke-linecap="round"
|
|
117
|
+
stroke-linejoin="round"
|
|
118
|
+
>
|
|
119
|
+
<path d="M22 2 11 13" />
|
|
120
|
+
<path d="M22 2 15 22 11 13 2 9z" />
|
|
121
|
+
</svg>
|
|
122
|
+
</button>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</cdtr-editor-container>
|
|
126
|
+
`}}).properties={commands:{attribute:!1},elementId:{attribute:!1},_messages:{state:!0},_input:{state:!0},_busy:{state:!0},_colorizing:{state:!0},_scope:{state:!0},_error:{state:!0},_keepLength:{state:!0},_selPreview:{state:!0},_streamingIdx:{state:!0},_lang:{state:!0}},i.styles=r.AH`
|
|
127
|
+
*,
|
|
128
|
+
*::before,
|
|
129
|
+
*::after {
|
|
130
|
+
box-sizing: border-box;
|
|
131
|
+
}
|
|
132
|
+
:host {
|
|
133
|
+
display: block;
|
|
134
|
+
font-family: inherit;
|
|
135
|
+
--accent: #7c3aed;
|
|
136
|
+
--accent-2: #a855f7;
|
|
137
|
+
--ink: #1f2937;
|
|
138
|
+
--muted: #6b7280;
|
|
139
|
+
--line: #ececf1;
|
|
140
|
+
--surface: #f6f6f9;
|
|
141
|
+
}
|
|
142
|
+
.ai {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
gap: 12px;
|
|
146
|
+
width: 100%;
|
|
147
|
+
min-width: 0;
|
|
148
|
+
padding: 2px;
|
|
149
|
+
color: var(--ink);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* Header */
|
|
153
|
+
.ai-head {
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: space-between;
|
|
157
|
+
gap: 8px;
|
|
158
|
+
min-width: 0;
|
|
159
|
+
}
|
|
160
|
+
.brand {
|
|
161
|
+
display: inline-flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
gap: 7px;
|
|
164
|
+
min-width: 0;
|
|
165
|
+
}
|
|
166
|
+
.spark {
|
|
167
|
+
font-size: 15px;
|
|
168
|
+
line-height: 1;
|
|
169
|
+
}
|
|
170
|
+
.brand-title {
|
|
171
|
+
font-weight: 700;
|
|
172
|
+
font-size: 14px;
|
|
173
|
+
letter-spacing: -0.01em;
|
|
174
|
+
white-space: nowrap;
|
|
175
|
+
overflow: hidden;
|
|
176
|
+
text-overflow: ellipsis;
|
|
177
|
+
}
|
|
178
|
+
.scope {
|
|
179
|
+
flex: none;
|
|
180
|
+
font-size: 11px;
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
color: var(--accent);
|
|
183
|
+
background: #f3ecff;
|
|
184
|
+
border-radius: 999px;
|
|
185
|
+
padding: 3px 9px;
|
|
186
|
+
white-space: nowrap;
|
|
187
|
+
}
|
|
188
|
+
.scope[data-scope="selection"] {
|
|
189
|
+
color: #b45309;
|
|
190
|
+
background: #fdf1dc;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/* Quick actions */
|
|
194
|
+
.quick {
|
|
195
|
+
display: flex;
|
|
196
|
+
flex-wrap: wrap;
|
|
197
|
+
gap: 6px;
|
|
198
|
+
}
|
|
199
|
+
.chip {
|
|
200
|
+
border: 1px solid var(--line);
|
|
201
|
+
background: #fff;
|
|
202
|
+
color: #374151;
|
|
203
|
+
border-radius: 8px;
|
|
204
|
+
padding: 6px 11px;
|
|
205
|
+
font: inherit;
|
|
206
|
+
font-size: 12px;
|
|
207
|
+
font-weight: 500;
|
|
208
|
+
cursor: pointer;
|
|
209
|
+
transition: border-color 0.12s ease, color 0.12s ease,
|
|
210
|
+
background 0.12s ease;
|
|
211
|
+
}
|
|
212
|
+
.chip:hover:not(:disabled) {
|
|
213
|
+
border-color: var(--accent-2);
|
|
214
|
+
color: var(--accent);
|
|
215
|
+
background: #faf6ff;
|
|
216
|
+
}
|
|
217
|
+
.chip:active:not(:disabled) {
|
|
218
|
+
transform: translateY(0.5px);
|
|
219
|
+
}
|
|
220
|
+
.chip:disabled {
|
|
221
|
+
opacity: 0.45;
|
|
222
|
+
cursor: default;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* Colorize chip — accented so it reads as a distinct "smart color" action */
|
|
226
|
+
.chip--color {
|
|
227
|
+
display: inline-flex;
|
|
228
|
+
align-items: center;
|
|
229
|
+
gap: 6px;
|
|
230
|
+
border-color: transparent;
|
|
231
|
+
color: #fff;
|
|
232
|
+
background: linear-gradient(135deg, var(--accent), var(--accent-2));
|
|
233
|
+
}
|
|
234
|
+
.chip--color:hover:not(:disabled) {
|
|
235
|
+
color: #fff;
|
|
236
|
+
background: linear-gradient(135deg, var(--accent-2), var(--accent));
|
|
237
|
+
filter: brightness(1.03);
|
|
238
|
+
}
|
|
239
|
+
.chip-swatch {
|
|
240
|
+
width: 11px;
|
|
241
|
+
height: 11px;
|
|
242
|
+
border-radius: 3px;
|
|
243
|
+
background: conic-gradient(
|
|
244
|
+
from 0deg,
|
|
245
|
+
#f87171,
|
|
246
|
+
#fbbf24,
|
|
247
|
+
#34d399,
|
|
248
|
+
#60a5fa,
|
|
249
|
+
#a855f7,
|
|
250
|
+
#f87171
|
|
251
|
+
);
|
|
252
|
+
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Applied-color swatches shown under a colorize result bubble */
|
|
256
|
+
.swatches {
|
|
257
|
+
display: flex;
|
|
258
|
+
flex-wrap: wrap;
|
|
259
|
+
gap: 6px 12px;
|
|
260
|
+
margin-top: 7px;
|
|
261
|
+
}
|
|
262
|
+
.swatch {
|
|
263
|
+
display: inline-flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
gap: 5px;
|
|
266
|
+
font-size: 11px;
|
|
267
|
+
color: var(--muted);
|
|
268
|
+
}
|
|
269
|
+
.swatch-dot {
|
|
270
|
+
width: 13px;
|
|
271
|
+
height: 13px;
|
|
272
|
+
border-radius: 4px;
|
|
273
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* Keep-length toggle */
|
|
277
|
+
.keeplen {
|
|
278
|
+
display: inline-flex;
|
|
279
|
+
align-items: center;
|
|
280
|
+
gap: 7px;
|
|
281
|
+
font-size: 12px;
|
|
282
|
+
color: var(--muted);
|
|
283
|
+
cursor: pointer;
|
|
284
|
+
user-select: none;
|
|
285
|
+
align-self: flex-start;
|
|
286
|
+
}
|
|
287
|
+
.keeplen input {
|
|
288
|
+
width: 15px;
|
|
289
|
+
height: 15px;
|
|
290
|
+
accent-color: var(--accent);
|
|
291
|
+
cursor: pointer;
|
|
292
|
+
margin: 0;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* Hint (empty state) */
|
|
296
|
+
.hint {
|
|
297
|
+
margin: 0;
|
|
298
|
+
font-size: 12.5px;
|
|
299
|
+
line-height: 1.5;
|
|
300
|
+
color: #9aa1ad;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/* Message log */
|
|
304
|
+
.log {
|
|
305
|
+
display: flex;
|
|
306
|
+
flex-direction: column;
|
|
307
|
+
gap: 8px;
|
|
308
|
+
max-height: 240px;
|
|
309
|
+
overflow-y: auto;
|
|
310
|
+
padding: 2px 1px;
|
|
311
|
+
scrollbar-width: thin;
|
|
312
|
+
}
|
|
313
|
+
.msg {
|
|
314
|
+
display: flex;
|
|
315
|
+
}
|
|
316
|
+
.msg.user {
|
|
317
|
+
justify-content: flex-end;
|
|
318
|
+
}
|
|
319
|
+
.msg.assistant,
|
|
320
|
+
.msg.error {
|
|
321
|
+
justify-content: flex-start;
|
|
322
|
+
}
|
|
323
|
+
.bubble {
|
|
324
|
+
max-width: 88%;
|
|
325
|
+
padding: 8px 11px;
|
|
326
|
+
border-radius: 13px;
|
|
327
|
+
font-size: 13px;
|
|
328
|
+
line-height: 1.45;
|
|
329
|
+
white-space: pre-wrap;
|
|
330
|
+
overflow-wrap: anywhere;
|
|
331
|
+
}
|
|
332
|
+
.msg.user .bubble {
|
|
333
|
+
background: linear-gradient(135deg, var(--accent), var(--accent-2));
|
|
334
|
+
color: #fff;
|
|
335
|
+
border-end-end-radius: 4px;
|
|
336
|
+
}
|
|
337
|
+
.msg.assistant .bubble {
|
|
338
|
+
background: var(--surface);
|
|
339
|
+
color: var(--ink);
|
|
340
|
+
border-end-start-radius: 4px;
|
|
341
|
+
}
|
|
342
|
+
.msg.error .bubble {
|
|
343
|
+
background: #fef2f2;
|
|
344
|
+
color: #b91c1c;
|
|
345
|
+
border: 1px solid #fecaca;
|
|
346
|
+
}
|
|
347
|
+
.bubble.thinking {
|
|
348
|
+
display: inline-flex;
|
|
349
|
+
align-items: center;
|
|
350
|
+
gap: 4px;
|
|
351
|
+
padding: 11px;
|
|
352
|
+
}
|
|
353
|
+
.dot {
|
|
354
|
+
width: 6px;
|
|
355
|
+
height: 6px;
|
|
356
|
+
border-radius: 50%;
|
|
357
|
+
background: var(--accent-2);
|
|
358
|
+
display: inline-block;
|
|
359
|
+
animation: blink 1.2s infinite both;
|
|
360
|
+
}
|
|
361
|
+
.dot:nth-child(2) {
|
|
362
|
+
animation-delay: 0.15s;
|
|
363
|
+
}
|
|
364
|
+
.dot:nth-child(3) {
|
|
365
|
+
animation-delay: 0.3s;
|
|
366
|
+
}
|
|
367
|
+
@keyframes blink {
|
|
368
|
+
0%,
|
|
369
|
+
80%,
|
|
370
|
+
100% {
|
|
371
|
+
opacity: 0.25;
|
|
372
|
+
transform: translateY(0);
|
|
373
|
+
}
|
|
374
|
+
40% {
|
|
375
|
+
opacity: 1;
|
|
376
|
+
transform: translateY(-1px);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/* Streaming shimmer FX — a soft light sweeps across the bubble while the
|
|
381
|
+
model types, plus a gentle purple glow. Text stays fully readable. */
|
|
382
|
+
.msg.assistant .bubble.streaming {
|
|
383
|
+
position: relative;
|
|
384
|
+
overflow: hidden;
|
|
385
|
+
box-shadow: 0 0 0 1px #ece0ff, 0 4px 16px -6px rgba(124, 58, 237, 0.4);
|
|
386
|
+
animation: bubbleGlow 1.8s ease-in-out infinite;
|
|
387
|
+
}
|
|
388
|
+
.msg.assistant .bubble.streaming::after {
|
|
389
|
+
content: "";
|
|
390
|
+
position: absolute;
|
|
391
|
+
inset: 0;
|
|
392
|
+
background: linear-gradient(
|
|
393
|
+
105deg,
|
|
394
|
+
transparent 20%,
|
|
395
|
+
rgba(168, 85, 247, 0.22) 50%,
|
|
396
|
+
transparent 80%
|
|
397
|
+
);
|
|
398
|
+
transform: translateX(-120%);
|
|
399
|
+
animation: sweep 1.5s ease-in-out infinite;
|
|
400
|
+
pointer-events: none;
|
|
401
|
+
}
|
|
402
|
+
@keyframes sweep {
|
|
403
|
+
to {
|
|
404
|
+
transform: translateX(120%);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
@keyframes bubbleGlow {
|
|
408
|
+
0%,
|
|
409
|
+
100% {
|
|
410
|
+
box-shadow: 0 0 0 1px #ece0ff, 0 3px 12px -6px rgba(124, 58, 237, 0.3);
|
|
411
|
+
}
|
|
412
|
+
50% {
|
|
413
|
+
box-shadow: 0 0 0 1px #e3d0ff, 0 6px 20px -6px rgba(168, 85, 247, 0.55);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/* Selection context pill (what a "Selection" edit will target) */
|
|
418
|
+
.selpill {
|
|
419
|
+
display: flex;
|
|
420
|
+
align-items: center;
|
|
421
|
+
gap: 7px;
|
|
422
|
+
min-width: 0;
|
|
423
|
+
padding: 6px 8px 6px 11px;
|
|
424
|
+
border: 1px solid #f0e4d3;
|
|
425
|
+
background: linear-gradient(90deg, #fdf6ea, #fef1dc);
|
|
426
|
+
border-radius: 10px;
|
|
427
|
+
font-size: 12px;
|
|
428
|
+
animation: pillIn 0.18s ease;
|
|
429
|
+
}
|
|
430
|
+
.selpill-label {
|
|
431
|
+
flex: none;
|
|
432
|
+
font-weight: 700;
|
|
433
|
+
color: #b45309;
|
|
434
|
+
white-space: nowrap;
|
|
435
|
+
}
|
|
436
|
+
.selpill-text {
|
|
437
|
+
flex: 1 1 auto;
|
|
438
|
+
min-width: 0;
|
|
439
|
+
color: #7c5a2a;
|
|
440
|
+
white-space: nowrap;
|
|
441
|
+
overflow: hidden;
|
|
442
|
+
text-overflow: ellipsis;
|
|
443
|
+
font-style: italic;
|
|
444
|
+
}
|
|
445
|
+
.selpill-x {
|
|
446
|
+
flex: none;
|
|
447
|
+
width: 20px;
|
|
448
|
+
height: 20px;
|
|
449
|
+
display: inline-flex;
|
|
450
|
+
align-items: center;
|
|
451
|
+
justify-content: center;
|
|
452
|
+
border: none;
|
|
453
|
+
border-radius: 6px;
|
|
454
|
+
background: transparent;
|
|
455
|
+
color: #b08a55;
|
|
456
|
+
font-size: 12px;
|
|
457
|
+
line-height: 1;
|
|
458
|
+
cursor: pointer;
|
|
459
|
+
transition: background 0.12s ease, color 0.12s ease;
|
|
460
|
+
}
|
|
461
|
+
.selpill-x:hover:not(:disabled) {
|
|
462
|
+
background: #f6e6cd;
|
|
463
|
+
color: #92400e;
|
|
464
|
+
}
|
|
465
|
+
.selpill-x:disabled {
|
|
466
|
+
opacity: 0.4;
|
|
467
|
+
cursor: default;
|
|
468
|
+
}
|
|
469
|
+
@keyframes pillIn {
|
|
470
|
+
from {
|
|
471
|
+
opacity: 0;
|
|
472
|
+
transform: translateY(3px);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/* Composer */
|
|
477
|
+
.composer {
|
|
478
|
+
display: flex;
|
|
479
|
+
align-items: flex-end;
|
|
480
|
+
gap: 8px;
|
|
481
|
+
border: 1px solid var(--line);
|
|
482
|
+
border-radius: 14px;
|
|
483
|
+
padding: 6px 6px 6px 10px;
|
|
484
|
+
background: #fff;
|
|
485
|
+
transition: border-color 0.12s ease, box-shadow 0.12s ease;
|
|
486
|
+
}
|
|
487
|
+
.composer:focus-within {
|
|
488
|
+
border-color: var(--accent-2);
|
|
489
|
+
box-shadow: 0 0 0 3px #f1e9ff;
|
|
490
|
+
}
|
|
491
|
+
.composer-input {
|
|
492
|
+
flex: 1 1 auto;
|
|
493
|
+
min-width: 0;
|
|
494
|
+
resize: none;
|
|
495
|
+
border: none;
|
|
496
|
+
outline: none;
|
|
497
|
+
background: transparent;
|
|
498
|
+
padding: 6px 2px;
|
|
499
|
+
font: inherit;
|
|
500
|
+
font-size: 13px;
|
|
501
|
+
line-height: 1.4;
|
|
502
|
+
color: var(--ink);
|
|
503
|
+
max-height: 96px;
|
|
504
|
+
}
|
|
505
|
+
.composer-input::placeholder {
|
|
506
|
+
color: #aab0bb;
|
|
507
|
+
}
|
|
508
|
+
.send {
|
|
509
|
+
flex: none;
|
|
510
|
+
width: 34px;
|
|
511
|
+
height: 34px;
|
|
512
|
+
display: inline-flex;
|
|
513
|
+
align-items: center;
|
|
514
|
+
justify-content: center;
|
|
515
|
+
border: none;
|
|
516
|
+
border-radius: 10px;
|
|
517
|
+
background: linear-gradient(135deg, var(--accent), var(--accent-2));
|
|
518
|
+
color: #fff;
|
|
519
|
+
cursor: pointer;
|
|
520
|
+
transition: opacity 0.12s ease, transform 0.12s ease;
|
|
521
|
+
}
|
|
522
|
+
.send:hover:not(:disabled) {
|
|
523
|
+
transform: translateY(-1px);
|
|
524
|
+
}
|
|
525
|
+
.send:disabled {
|
|
526
|
+
opacity: 0.4;
|
|
527
|
+
cursor: default;
|
|
528
|
+
}
|
|
529
|
+
.send svg.flip {
|
|
530
|
+
transform: scaleX(-1);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
@media (prefers-reduced-motion: reduce) {
|
|
534
|
+
.dot,
|
|
535
|
+
.send,
|
|
536
|
+
.chip,
|
|
537
|
+
.selpill,
|
|
538
|
+
.msg.assistant .bubble.streaming,
|
|
539
|
+
.msg.assistant .bubble.streaming::after {
|
|
540
|
+
animation: none;
|
|
541
|
+
transition: none;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
`,s=i))||s},71271(e,t,n){n.d(t,{default:()=>u});var s=n(53577),i=n(74265),o=n(86319);const a=[100,300,400,500,600,700,900].map(e=>({value:String(e),label:String(e)})),r=e=>{{const{component:t,commands:n,helpers:r}=e,l=t.tiptap,c=l.state.selection.$anchor.node().attrs,p=l.isActive("heading",{level:1})?"h1":l.isActive("heading",{level:2})?"h2":l.isActive("heading",{level:3})?"h3":l.isActive("heading",{level:4})?"h4":l.isActive("heading",{level:5})?"h5":l.isActive("heading",{level:6})?"h6":"paragraph";let d=e.languageJson;const h=e.language||"he";return d||(d="he"===h?s:i),{select:e=>{let{changeTab:t,tab:n}=e},tabs:e=>{const t=l.isActive("customBulletItem"),n=[{text:"style",selected:!t},...t?[{text:"icons",selected:!0}]:[],{text:"settings"}];return n.forEach(t=>t.selected=t.text===e),n},layout:e=>{let{tab:s,changeTab:i,tabs:r}=e;return[{type:"info",text:"text_micro_copy",active:()=>"style"===s.text},{type:"heading",level:6,text:"typography",active:()=>"style"===s.text},{type:"dropdown",active:()=>"style"===s.text,title:"type",value:p,items:[{value:"H1"},{value:"H2"},{value:"H3"},{value:"H4"},{value:"H5"},{value:"H6"},{value:"paragraph"}],onChange:e=>{const t=e.target.value;switch(t){case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":l.chain().setHeading({level:parseInt(t.slice(1))}).run();break;case"paragraph":l.chain().setParagraph().run()}}},{type:"slider",title:"fontSize",min:8,step:2,max:74,value:parseInt(l.getAttributes("textStyle").fontSize||"16px"),active:()=>"style"===s.text,onInput:e=>{const n=e.target.value,s=t.tiptap,i=s.view.state.selection;i.from===i.to?s.chain().selectAll().setFontSize(n).run():s.chain().setFontSize(n).run()}},{type:"dropdown",title:"fontWeight",active:()=>"style"===s.text&&"web"===o.M.get("config","channel"),value:String(l.getAttributes("textStyle").fontWeight||400),selected:String(l.getAttributes("textStyle").fontWeight||400),items:a,onChange:e=>{const n=e.target.value,s=t.tiptap,i=s.view.state.selection;i.from===i.to?s.chain().selectAll().setFontWeight(n).run():s.chain().setFontWeight(n).run()}},{type:"heading",level:6,text:"spacing",active:()=>"style"===s.text},{type:"slider",title:"lineHeight",min:1,max:3,step:.1,value:parseFloat(c.lineHeight||1),active:()=>"style"===s.text,onInput:e=>{const n=e.target.value,s=t.tiptap,i=s.view.state.selection;i.from===i.to?s.chain().selectAll().setLineHeight(n).run():s.chain().setLineHeight(n).run()}},{type:"slider",title:"letterSpacing",min:1,max:10,step:1,value:parseFloat(c.letterSpacing)||1,active:()=>"style"===s.text,onInput:e=>{const n=e.target.value,s=t.tiptap,i=s.view.state.selection;n<=1?i.from===i.to?s.chain().selectAll().setLetterSpacing("normal").run():s.chain().setLetterSpacing("normal").run():i.from===i.to?s.chain().selectAll().setLetterSpacing(n+"px").run():s.chain().setLetterSpacing(n+"px").run()}},{type:"heading",level:6,text:"colors",active:()=>"style"===s.text},{type:"colorSwatchGroup",active:()=>"style"===s.text,columns:2,items:[{title:"font_color",value:l.getAttributes("textStyle").color||"#000000",onChange:e=>{const n=e.target.value,s=t.tiptap,i=s.view.state.selection;if(i.from===i.to){const{state:e,view:t}=s,i=e.tr,{from:o,to:a}={from:0,to:e.doc.content.size};e.doc.nodesBetween(o,a,(t,s)=>{if(t.isText){t.marks.some(e=>"link"===e.type.name)||i.addMark(s,s+t.nodeSize,e.schema.marks.textStyle.create({color:n}))}}),t.dispatch(i)}else s.chain().setColor(n).focus().run()}},{title:"backgroundColor",allowGradient:!0,value:t.props.style.background||t.props.style.backgroundColor||"#ffffff",onChange:e=>{const t=e.target.value;n.execCommand("style",{background:t,backgroundColor:null})}}]},{type:"heading",level:6,text:"layout",active:()=>"style"===s.text},{type:"slider",active:()=>"style"===s.text,title:"maxWidth",value:parseFloat(t.props.style.width),min:20,max:1e3,onInput:e=>{const t=e.target.value;n.execCommand("style",{width:t+"px"})}},{type:"divider"},{type:"colorpicker",active:()=>"icons"===s.text,title:d.iconColor||"Icon color",alpha:!1,value:l.getAttributes(" textStyle").color||"#0000",onChange:e=>{const t=e.target.value;l.chain().setCustomBulletStyles({fill:t}).run()}},{type:"divider",active:()=>"icons"===s.text},{type:"slider",active:()=>"icons"===s.text,title:d.iconSize||"Icon size",value:parseInt(l.getAttributes("customBulletItem").width)||24,min:10,max:40,onInput:e=>{const t=e.target.value;l.chain().setCustomBulletStyles({width:t+"px",height:t+"px"}).run()}},{type:"icons",active:()=>"icons"===s.text,selectedIcon:t.props.src,useIconsApi:!0,iconColor:t.props.iconColor||"000000",iconSize:parseInt(t.props.style?.width,10)||24,onChange:e=>{const n=e.detail;t.tiptap.chain().focus().setCustomBulletIcon({svgIcon:n.urlPng}).run()}}]}}}};var l=n(52144);const c=e=>{let{helpers:t,tiptap:n,composeId:s,template:i}=e;return{set:(e,o,a)=>{switch(o){case"style":return"object"==typeof a&&(e[o]=(0,l.A)(e[o],a),t.mergeDiff(i,{style:e[o]})),!0;case"text":e[o]=a;const r=n.getJSON();return a&&"object"==typeof a&&JSON.stringify(r)!==JSON.stringify(a.childNodes)&&(a&&a.focusedElement&&a.focusedElement===s?(n.chain().focus().setContent(a.childNodes).run(),a.to&&a.from&&n.commands.setTextSelection({from:a.from,to:a.to})):n.chain().setContent(a.childNodes).run()),delete e?.text?.markdown,!0}}}};var p=n(84488),d=n.n(p);n(70567);const h=[];let g=!1,m=null;const u=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t="text";return{name:t,create:n=>{const{createElement:s,compose:i,helpers:a}=n,{mergeDiff:l}=a,p=document.createElement("div");l(p,{style:i.props.style});const u=o.M.get("config","editor","configure","editorProps","fonts");let f=o.M.get("config","target");"string"==typeof f&&(f=document.querySelector(f)),f||(f=document.body);const x=d()({element:p,container:f||document.body,editable:!0,offsetTop:40,onClickMagic:e=>{const t=o.M.get("injectEditor"),n=document.createElement("cdtr-text-prompt-editor");n.commands=e,n.elementId=i.id,t(n)},content:"string"==typeof i.props.text.markdown?i.props.text.markdown:i.props.text.childNodes,defaultDirection:"rtl",onBlur:()=>{m===x&&(m=null),setTimeout(()=>{m!==x&&(g=!1)},150)},onFocus:()=>{if(!g||m===x||null===m){if(g=!0,m=x,h.length>0)for(h.forEach(e=>{e!==x&&e.hideEditor()});h.length>0;)h.pop();h.push(x),setTimeout(()=>{m===x&&g&&x.showEditor()},100)}},onUpdate:e=>{let{editor:t,transaction:n}=e;if(0===n.steps.length)return;const s=n.curSelection.from,o=n.curSelection.to,a={childNodes:t.getJSON(),from:s,to:o,focusedElement:i.id};y.commands.execCommand("text",a)},ignoresBlurByQuerySelectors:[".ignore-events"],builder:[{type:"fontFamily",fonts:u||[],useCloud:!0},{type:"fontSize",sizes:e.fontSize||[8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74]},{type:"horizonRule"},{type:"clearFormat"},{type:"bold"},{type:"strike"},{type:"italic"},{type:"underline"},{type:"table"},{type:"emoji"},{type:"unLink"},{type:"link"},{type:"customList"},{type:"numbered"},{type:"bullet"},{type:"backcolor"},{type:"fontColor"},{type:"direction"},{type:"justify"},{type:"right"},{type:"center"},{type:"left"},{type:"image"},{type:"mergeTags"},{type:"magic"}]}),y=s({name:t,id:i.id,template:p,defaultProps:{text:{},style:{}},draggable:{group:"element"},droppable:{group:"element"},resizeable:()=>p,handleBar:!0,validator:c({template:p,helpers:a,tiptap:x,composeId:i.id}),schema:i.schema,onSelect:e=>{p.classList.add(e)},onDeselect:e=>{p.classList.remove(e)},elementProps:i,remove:()=>{p.remove()},createEditor:r});return i.props.text.markdown&&x.chain().insertContent(" ").run(),y.addProp("tiptap",x),y}}}}}]);
|
|
Binary file
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
height: 100vh;
|
|
25
25
|
left: 0;
|
|
26
26
|
top: 0;
|
|
27
|
-
z-index:
|
|
27
|
+
z-index: var(--z-blocking, 2147483646);
|
|
28
28
|
background-color: #0000001f;
|
|
29
29
|
}
|
|
30
30
|
.container {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
background: #fff;
|
|
36
36
|
width: auto;
|
|
37
37
|
height: 500px;
|
|
38
|
-
z-index:
|
|
38
|
+
z-index: var(--z-toast, 1100);
|
|
39
39
|
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
|
|
40
40
|
padding: 3rem;
|
|
41
41
|
direction: var(--direction-locale);
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
}
|
|
47
47
|
h1 {
|
|
48
48
|
font-family: Arial;
|
|
49
|
-
color: var(--primary);
|
|
49
|
+
color: var(--color-primary, #6366f1);
|
|
50
50
|
}
|
|
51
51
|
`,customElements.define("cdtr-504",a)}}]);
|
|
Binary file
|