@meetelise/chat 1.20.215 → 1.20.217

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.20.215",
3
+ "version": "1.20.217",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -3506,7 +3506,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3506
3506
  target="_blank"
3507
3507
  rel="noopener noreferrer"
3508
3508
  >${t}
3509
- </a>`}return U`${e} `}))}<br />`:U``}))}`,this.imagesToDisplay=o,Promise.all(r).then((e=>{this.websitePreviewInfo=e}))}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="https?:\/\/[^"]+"(?: target="[^"]*")?>[^<]+<\/a>/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};{const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Cr().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
3509
+ </a>`}return U`${e} `}))}<br />`:U``}))}`,this.imagesToDisplay=o,Promise.all(r).then((e=>{this.websitePreviewInfo=e}))}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\(http[s]?:\/\/.*?\)/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Cr().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
3510
3510
  ${this.isMessageStillStreamingChunks()?U`<div class="message-loader"><mini-loader></mini-loader></div>`:""}
3511
3511
  <p
3512
3512
  class=${fe({"message-text":!0,"webchat-font__desktop":!ln(),"webchat-font__mobile":ln()})}
@@ -144,9 +144,9 @@ export class PubnubMessage extends LitElement {
144
144
  }[];
145
145
  markedText: string;
146
146
  } {
147
- // Updated regex to match both formats (EliseAI and embedded links)
147
+ // Updated regex to match all formats (EliseAI, embedded links, and markdown).
148
148
  const regex =
149
- /<https?:\/\/[^|]+\|[^>]+>|<a href="https?:\/\/[^"]+"(?: target="[^"]*")?>[^<]+<\/a>/g;
149
+ /<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\(http[s]?:\/\/.*?\)/g;
150
150
 
151
151
  const matches = Array.from(text.matchAll(regex));
152
152
  const listHyperlinks: {
@@ -171,7 +171,7 @@ export class PubnubMessage extends LitElement {
171
171
  addSpaceBefore: !!(charBefore && charBefore !== " "),
172
172
  addSpaceAfter: !!(charAfter && charAfter !== " "),
173
173
  };
174
- } else {
174
+ } else if (matchedLink.startsWith("<a href=")) {
175
175
  // Handle for embedded links (<a>...</a>)
176
176
  const linkMatch = matchedLink.match(/href="([^"]+)"/);
177
177
  const hyperlinkMatch = matchedLink.match(/>[^<]+</);
@@ -182,6 +182,16 @@ export class PubnubMessage extends LitElement {
182
182
  addSpaceBefore: !!(charBefore && charBefore !== " "),
183
183
  addSpaceAfter: !!(charAfter && charAfter !== " "),
184
184
  };
185
+ } else {
186
+ // Handle for markdown links
187
+ const [hyperlinkMatch, linkMatch] = matchedLink.split("](");
188
+ return {
189
+ matchedLink,
190
+ link: linkMatch ? linkMatch.slice(0, -1) : "",
191
+ hyperlink: hyperlinkMatch ? hyperlinkMatch.slice(1) : "",
192
+ addSpaceBefore: !!(charBefore && charBefore !== " "),
193
+ addSpaceAfter: !!(charAfter && charAfter !== " "),
194
+ };
185
195
  }
186
196
  });
187
197