lwazi 1.9.4 → 1.9.6
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/package.json
CHANGED
|
@@ -111,7 +111,7 @@ let lwaziContextId=@json($contextId ?? null);
|
|
|
111
111
|
let lwaziApiUrl=@json($lwaziApiUrl);
|
|
112
112
|
function toggleLwazi(){lwaziOpen=!lwaziOpen;document.getElementById('lwazi-window').classList.toggle('open',lwaziOpen);document.getElementById('lwazi-toggle').classList.toggle('open',lwaziOpen);if(lwaziOpen)setTimeout(()=>document.getElementById('lwazi-input').focus(),300)}
|
|
113
113
|
function sendLwazi(){let i=document.getElementById('lwazi-input'),m=i.value.trim();if(!m)return;addLwazi(m,'user');i.value='';document.getElementById('lwazi-typing').classList.add('active');let c=document.getElementById('lwazi-messages');c.scrollTop=c.scrollHeight;let p={message:m};if(lwaziContextId!==null&&lwaziContextId!==''){p[lwaziContextKey]=lwaziContextId;}fetch(lwaziApiUrl+'/chat',{method:'POST',headers:{'Content-Type':'application/json','X-CSRF-TOKEN':'{{ csrf_token() }}'},body:JSON.stringify(p)}).then(r=>{if(!r.ok){return r.text().then(t=>{try{const e=JSON.parse(t);throw new Error(e.error||'HTTP '+r.status)}catch(e){throw new Error('HTTP '+r.status+': '+t.substring(0,100))}})}return r.json()}).then(d=>{document.getElementById('lwazi-typing').classList.remove('active');d.success?addLwazi(d.response,'assistant'):addLwazi('Error: '+d.error,'assistant')}).catch(e=>{document.getElementById('lwazi-typing').classList.remove('active');console.error('Lwazi error:',e);addLwazi('Error: '+e.message,'assistant')})}
|
|
114
|
-
function linkify(text){let escaped=text.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");let urlRegex=/((https?:\/\/[^\s]+)|(\B\/[a-zA-Z0-9\-._~!$&'()*+,;=:@\/%?#]+))/g;return escaped.replace(urlRegex,function(url){let trailing="";while(/[).,!?;:]+$/.test(url)){trailing=url.slice(-1)+trailing;url=url.slice(0,-1);}return '<a href="'+url+'" target="_blank" rel="noopener noreferrer">'+url+"</a>"+trailing;});}
|
|
114
|
+
function linkify(text){let escaped=text.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");escaped=escaped.replace(/\*\*([^*]+)\*\*/g,'<strong>$1</strong>');let urlRegex=/((https?:\/\/[^\s]+)|(\B\/[a-zA-Z0-9\-._~!$&'()*+,;=:@\/%?#]+))/g;return escaped.replace(urlRegex,function(url){let trailing="";while(/[).,!?;:]+$/.test(url)){trailing=url.slice(-1)+trailing;url=url.slice(0,-1);}return '<a href="'+url+'" target="_blank" rel="noopener noreferrer" style="color:var(--lwazi-blue)">'+url+"</a>"+trailing;});}
|
|
115
115
|
function addLwazi(t,r){let c=document.getElementById('lwazi-messages'),d=document.createElement('div');d.className='lwazi-msg lwazi-msg-'+r;d.innerHTML=linkify(t);c.appendChild(d);c.scrollTop=c.scrollHeight}
|
|
116
116
|
</script>
|
|
117
117
|
</div>
|