@coveops/abi 1.0.1 → 1.0.2

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.
@@ -35,7 +35,7 @@ const FaqPopupComponent = class {
35
35
  }
36
36
  }
37
37
  openFAQModal(result) {
38
- var _a, _b, _c, _d;
38
+ var _a, _b, _c, _d, _e, _f, _g;
39
39
  if (this.bindings) {
40
40
  const { logClickEvent } = index$1.Fde(this.bindings.engine);
41
41
  const logClickPayload = {
@@ -62,17 +62,50 @@ const FaqPopupComponent = class {
62
62
  answerElement.appendChild(answerTitleElement);
63
63
  // Create a new element to contain the answer content
64
64
  const answerContentElement = document.createElement('td');
65
- answerContentElement.innerHTML = ((_b = this.result) === null || _b === void 0 ? void 0 : _b.raw.answer) || '';
65
+ debugger;
66
+ if ((_c = (_b = this.result) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.answer) {
67
+ let value = (_e = (_d = this.result) === null || _d === void 0 ? void 0 : _d.raw) === null || _e === void 0 ? void 0 : _e.answer;
68
+ try {
69
+ var els = new DOMParser().parseFromString(value, 'text/html');
70
+ var html = '';
71
+ Array.from(els.children).forEach(el => {
72
+ var _a;
73
+ debugger;
74
+ el.querySelectorAll('a').forEach(a => {
75
+ if (a.href.startsWith(window.location.origin) && a.href.indexOf('/sites/') > -1) {
76
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
77
+ }
78
+ if (a.href.startsWith(window.location.origin) && a.href.match(/:.:\/./)) {
79
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
80
+ }
81
+ });
82
+ el.querySelectorAll('img').forEach(a => {
83
+ if (a.src.startsWith(window.location.origin) && a.src.indexOf('/sites/') > -1) {
84
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
85
+ }
86
+ if (a.src.startsWith(window.location.origin) && a.src.match(/:.:\/./)) {
87
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
88
+ }
89
+ });
90
+ html = html + ((_a = el.querySelector('body')) === null || _a === void 0 ? void 0 : _a.innerHTML);
91
+ });
92
+ answerContentElement.innerHTML = html;
93
+ }
94
+ catch (e) {
95
+ console.log(e);
96
+ answerContentElement.innerHTML = value;
97
+ }
98
+ }
66
99
  // Append the answer content element to the answer element
67
100
  answerElement.appendChild(answerContentElement);
68
101
  // Now, the answer element has the title and the content properly appended
69
102
  tableEl.appendChild(answerElement);
70
- if ((_c = this.result) === null || _c === void 0 ? void 0 : _c.raw.category) {
103
+ if ((_f = this.result) === null || _f === void 0 ? void 0 : _f.raw.category) {
71
104
  const categoryElement = document.createElement("tr");
72
105
  categoryElement.innerHTML = '<td> Category: </td><td>' + this.result.raw.category + '</td>';
73
106
  tableEl.appendChild(categoryElement);
74
107
  }
75
- if ((_d = this.result) === null || _d === void 0 ? void 0 : _d.raw.newmoreinfo) {
108
+ if ((_g = this.result) === null || _g === void 0 ? void 0 : _g.raw.newmoreinfo) {
76
109
  const linkElement = document.createElement("tr");
77
110
  const linkUrl = this.result.raw.newmoreinfo;
78
111
  linkElement.innerHTML = '<td> Link: </td><td> <a href="' + linkUrl + '" target="_blank">' + linkUrl + '</a> </td>';
@@ -8,7 +8,7 @@ async function main() {
8
8
  const searchBox = document.querySelector("#searchbox");
9
9
  const platformUrl = "https://platform.cloud.coveo.com";
10
10
  const organizationId = "anheuserbuschinbevprod";
11
- const accessToken = "x0ae66480-c272-44bf-bb26-0e89dc2c0239";
11
+ const accessToken = "xf75e8727-ecce-4f14-afea-19a62c17334c";
12
12
  await searchInterface.initialize({
13
13
  accessToken,
14
14
  organizationId,
@@ -26,7 +26,7 @@ export class FaqPopupComponent {
26
26
  }
27
27
  }
28
28
  openFAQModal(result) {
29
- var _a, _b, _c, _d;
29
+ var _a, _b, _c, _d, _e, _f, _g;
30
30
  if (this.bindings) {
31
31
  const { logClickEvent } = loadGenericAnalyticsActions(this.bindings.engine);
32
32
  const logClickPayload = {
@@ -53,17 +53,50 @@ export class FaqPopupComponent {
53
53
  answerElement.appendChild(answerTitleElement);
54
54
  // Create a new element to contain the answer content
55
55
  const answerContentElement = document.createElement('td');
56
- answerContentElement.innerHTML = ((_b = this.result) === null || _b === void 0 ? void 0 : _b.raw.answer) || '';
56
+ debugger;
57
+ if ((_c = (_b = this.result) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.answer) {
58
+ let value = (_e = (_d = this.result) === null || _d === void 0 ? void 0 : _d.raw) === null || _e === void 0 ? void 0 : _e.answer;
59
+ try {
60
+ var els = new DOMParser().parseFromString(value, 'text/html');
61
+ var html = '';
62
+ Array.from(els.children).forEach(el => {
63
+ var _a;
64
+ debugger;
65
+ el.querySelectorAll('a').forEach(a => {
66
+ if (a.href.startsWith(window.location.origin) && a.href.indexOf('/sites/') > -1) {
67
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
68
+ }
69
+ if (a.href.startsWith(window.location.origin) && a.href.match(/:.:\/./)) {
70
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
71
+ }
72
+ });
73
+ el.querySelectorAll('img').forEach(a => {
74
+ if (a.src.startsWith(window.location.origin) && a.src.indexOf('/sites/') > -1) {
75
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
76
+ }
77
+ if (a.src.startsWith(window.location.origin) && a.src.match(/:.:\/./)) {
78
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
79
+ }
80
+ });
81
+ html = html + ((_a = el.querySelector('body')) === null || _a === void 0 ? void 0 : _a.innerHTML);
82
+ });
83
+ answerContentElement.innerHTML = html;
84
+ }
85
+ catch (e) {
86
+ console.log(e);
87
+ answerContentElement.innerHTML = value;
88
+ }
89
+ }
57
90
  // Append the answer content element to the answer element
58
91
  answerElement.appendChild(answerContentElement);
59
92
  // Now, the answer element has the title and the content properly appended
60
93
  tableEl.appendChild(answerElement);
61
- if ((_c = this.result) === null || _c === void 0 ? void 0 : _c.raw.category) {
94
+ if ((_f = this.result) === null || _f === void 0 ? void 0 : _f.raw.category) {
62
95
  const categoryElement = document.createElement("tr");
63
96
  categoryElement.innerHTML = '<td> Category: </td><td>' + this.result.raw.category + '</td>';
64
97
  tableEl.appendChild(categoryElement);
65
98
  }
66
- if ((_d = this.result) === null || _d === void 0 ? void 0 : _d.raw.newmoreinfo) {
99
+ if ((_g = this.result) === null || _g === void 0 ? void 0 : _g.raw.newmoreinfo) {
67
100
  const linkElement = document.createElement("tr");
68
101
  const linkUrl = this.result.raw.newmoreinfo;
69
102
  linkElement.innerHTML = '<td> Link: </td><td> <a href="' + linkUrl + '" target="_blank">' + linkUrl + '</a> </td>';
@@ -1048,7 +1048,7 @@ async function main() {
1048
1048
  const searchBox = document.querySelector("#searchbox");
1049
1049
  const platformUrl = "https://platform.cloud.coveo.com";
1050
1050
  const organizationId = "anheuserbuschinbevprod";
1051
- const accessToken = "x0ae66480-c272-44bf-bb26-0e89dc2c0239";
1051
+ const accessToken = "xf75e8727-ecce-4f14-afea-19a62c17334c";
1052
1052
  await searchInterface.initialize({
1053
1053
  accessToken,
1054
1054
  organizationId,
@@ -2959,7 +2959,7 @@ const FaqPopupComponent$1 = class extends H {
2959
2959
  }
2960
2960
  }
2961
2961
  openFAQModal(result) {
2962
- var _a, _b, _c, _d;
2962
+ var _a, _b, _c, _d, _e, _f, _g;
2963
2963
  if (this.bindings) {
2964
2964
  const { logClickEvent } = Fde(this.bindings.engine);
2965
2965
  const logClickPayload = {
@@ -2986,17 +2986,50 @@ const FaqPopupComponent$1 = class extends H {
2986
2986
  answerElement.appendChild(answerTitleElement);
2987
2987
  // Create a new element to contain the answer content
2988
2988
  const answerContentElement = document.createElement('td');
2989
- answerContentElement.innerHTML = ((_b = this.result) === null || _b === void 0 ? void 0 : _b.raw.answer) || '';
2989
+ debugger;
2990
+ if ((_c = (_b = this.result) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.answer) {
2991
+ let value = (_e = (_d = this.result) === null || _d === void 0 ? void 0 : _d.raw) === null || _e === void 0 ? void 0 : _e.answer;
2992
+ try {
2993
+ var els = new DOMParser().parseFromString(value, 'text/html');
2994
+ var html = '';
2995
+ Array.from(els.children).forEach(el => {
2996
+ var _a;
2997
+ debugger;
2998
+ el.querySelectorAll('a').forEach(a => {
2999
+ if (a.href.startsWith(window.location.origin) && a.href.indexOf('/sites/') > -1) {
3000
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
3001
+ }
3002
+ if (a.href.startsWith(window.location.origin) && a.href.match(/:.:\/./)) {
3003
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
3004
+ }
3005
+ });
3006
+ el.querySelectorAll('img').forEach(a => {
3007
+ if (a.src.startsWith(window.location.origin) && a.src.indexOf('/sites/') > -1) {
3008
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
3009
+ }
3010
+ if (a.src.startsWith(window.location.origin) && a.src.match(/:.:\/./)) {
3011
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
3012
+ }
3013
+ });
3014
+ html = html + ((_a = el.querySelector('body')) === null || _a === void 0 ? void 0 : _a.innerHTML);
3015
+ });
3016
+ answerContentElement.innerHTML = html;
3017
+ }
3018
+ catch (e) {
3019
+ console.log(e);
3020
+ answerContentElement.innerHTML = value;
3021
+ }
3022
+ }
2990
3023
  // Append the answer content element to the answer element
2991
3024
  answerElement.appendChild(answerContentElement);
2992
3025
  // Now, the answer element has the title and the content properly appended
2993
3026
  tableEl.appendChild(answerElement);
2994
- if ((_c = this.result) === null || _c === void 0 ? void 0 : _c.raw.category) {
3027
+ if ((_f = this.result) === null || _f === void 0 ? void 0 : _f.raw.category) {
2995
3028
  const categoryElement = document.createElement("tr");
2996
3029
  categoryElement.innerHTML = '<td> Category: </td><td>' + this.result.raw.category + '</td>';
2997
3030
  tableEl.appendChild(categoryElement);
2998
3031
  }
2999
- if ((_d = this.result) === null || _d === void 0 ? void 0 : _d.raw.newmoreinfo) {
3032
+ if ((_g = this.result) === null || _g === void 0 ? void 0 : _g.raw.newmoreinfo) {
3000
3033
  const linkElement = document.createElement("tr");
3001
3034
  const linkUrl = this.result.raw.newmoreinfo;
3002
3035
  linkElement.innerHTML = '<td> Link: </td><td> <a href="' + linkUrl + '" target="_blank">' + linkUrl + '</a> </td>';
@@ -31,7 +31,7 @@ const FaqPopupComponent = class {
31
31
  }
32
32
  }
33
33
  openFAQModal(result) {
34
- var _a, _b, _c, _d;
34
+ var _a, _b, _c, _d, _e, _f, _g;
35
35
  if (this.bindings) {
36
36
  const { logClickEvent } = Fde(this.bindings.engine);
37
37
  const logClickPayload = {
@@ -58,17 +58,50 @@ const FaqPopupComponent = class {
58
58
  answerElement.appendChild(answerTitleElement);
59
59
  // Create a new element to contain the answer content
60
60
  const answerContentElement = document.createElement('td');
61
- answerContentElement.innerHTML = ((_b = this.result) === null || _b === void 0 ? void 0 : _b.raw.answer) || '';
61
+ debugger;
62
+ if ((_c = (_b = this.result) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.answer) {
63
+ let value = (_e = (_d = this.result) === null || _d === void 0 ? void 0 : _d.raw) === null || _e === void 0 ? void 0 : _e.answer;
64
+ try {
65
+ var els = new DOMParser().parseFromString(value, 'text/html');
66
+ var html = '';
67
+ Array.from(els.children).forEach(el => {
68
+ var _a;
69
+ debugger;
70
+ el.querySelectorAll('a').forEach(a => {
71
+ if (a.href.startsWith(window.location.origin) && a.href.indexOf('/sites/') > -1) {
72
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
73
+ }
74
+ if (a.href.startsWith(window.location.origin) && a.href.match(/:.:\/./)) {
75
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
76
+ }
77
+ });
78
+ el.querySelectorAll('img').forEach(a => {
79
+ if (a.src.startsWith(window.location.origin) && a.src.indexOf('/sites/') > -1) {
80
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
81
+ }
82
+ if (a.src.startsWith(window.location.origin) && a.src.match(/:.:\/./)) {
83
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
84
+ }
85
+ });
86
+ html = html + ((_a = el.querySelector('body')) === null || _a === void 0 ? void 0 : _a.innerHTML);
87
+ });
88
+ answerContentElement.innerHTML = html;
89
+ }
90
+ catch (e) {
91
+ console.log(e);
92
+ answerContentElement.innerHTML = value;
93
+ }
94
+ }
62
95
  // Append the answer content element to the answer element
63
96
  answerElement.appendChild(answerContentElement);
64
97
  // Now, the answer element has the title and the content properly appended
65
98
  tableEl.appendChild(answerElement);
66
- if ((_c = this.result) === null || _c === void 0 ? void 0 : _c.raw.category) {
99
+ if ((_f = this.result) === null || _f === void 0 ? void 0 : _f.raw.category) {
67
100
  const categoryElement = document.createElement("tr");
68
101
  categoryElement.innerHTML = '<td> Category: </td><td>' + this.result.raw.category + '</td>';
69
102
  tableEl.appendChild(categoryElement);
70
103
  }
71
- if ((_d = this.result) === null || _d === void 0 ? void 0 : _d.raw.newmoreinfo) {
104
+ if ((_g = this.result) === null || _g === void 0 ? void 0 : _g.raw.newmoreinfo) {
72
105
  const linkElement = document.createElement("tr");
73
106
  const linkUrl = this.result.raw.newmoreinfo;
74
107
  linkElement.innerHTML = '<td> Link: </td><td> <a href="' + linkUrl + '" target="_blank">' + linkUrl + '</a> </td>';
package/dist/esm/index.js CHANGED
@@ -6,7 +6,7 @@ async function main() {
6
6
  const searchBox = document.querySelector("#searchbox");
7
7
  const platformUrl = "https://platform.cloud.coveo.com";
8
8
  const organizationId = "anheuserbuschinbevprod";
9
- const accessToken = "x0ae66480-c272-44bf-bb26-0e89dc2c0239";
9
+ const accessToken = "xf75e8727-ecce-4f14-afea-19a62c17334c";
10
10
  await searchInterface.initialize({
11
11
  accessToken,
12
12
  organizationId,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coveops/abi",
3
3
  "description": "Abi project",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "private": false,
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.js",
@@ -76,7 +76,40 @@ export class FaqPopupComponent {
76
76
 
77
77
  // Create a new element to contain the answer content
78
78
  const answerContentElement = document.createElement('td');
79
- answerContentElement.innerHTML = this.result?.raw.answer as string || '';
79
+ debugger;
80
+ if(this.result?.raw?.answer) {
81
+ let value = this.result?.raw?.answer as string;
82
+ try {
83
+ var els = new DOMParser().parseFromString(value,'text/html');
84
+ var html = '';
85
+ Array.from(els.children).forEach(el => {
86
+ debugger;
87
+ el.querySelectorAll('a').forEach(a => {
88
+ if (a.href.startsWith(window.location.origin) && a.href.indexOf('/sites/') > -1) {
89
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
90
+ }
91
+ if (a.href.startsWith(window.location.origin) && a.href.match(/:.:\/./)) {
92
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
93
+ }
94
+ });
95
+ el.querySelectorAll('img').forEach(a => {
96
+ if (a.src.startsWith(window.location.origin) && a.src.indexOf('/sites/') > -1) {
97
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
98
+ }
99
+ if (a.src.startsWith(window.location.origin) && a.src.match(/:.:\/./)) {
100
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
101
+ }
102
+ });
103
+ html = html + el.querySelector('body')?.innerHTML;
104
+ });
105
+ answerContentElement.innerHTML = html;
106
+ }
107
+ catch (e) {
108
+ console.log(e);
109
+ answerContentElement.innerHTML = value;
110
+ }
111
+ }
112
+
80
113
 
81
114
  // Append the answer content element to the answer element
82
115
  answerElement.appendChild(answerContentElement);
@@ -1 +0,0 @@
1
- import{r as t,h as i,g as s,H as o}from"./p-d6d34d34.js";import{i as e,F as d}from"./p-ddacae1a.js";import{r as h}from"./p-b83bab81.js";import"./p-d20ee37c.js";const l=class{constructor(i){t(this,i),this.closeFAQModal=()=>{this.modalElement.setAttribute("is-open","false"),this.modalElement.querySelector("#btn-done").removeEventListener("click",this.closeFAQModal)}}async connectedCallback(){var t;try{this.bindings=await e(this.host),this.result=await h(this.host),this.modalElement=null===(t=this.bindings)||void 0===t?void 0:t.interfaceElement.querySelector("#faq-modal"),this.result&&localStorage.getItem(`visited-${this.result.title}`)&&this.host.classList.add("visited-title")}catch(t){console.error(t),this.host.remove()}}openFAQModal(t){var i,s,o,e;if(this.bindings){const{logClickEvent:i}=d(this.bindings.engine);this.bindings.engine.dispatch(i({evt:"documentQuickview",result:t}))}this.modalElement.source=this.host;const h=this.modalElement.querySelector("[slot=body]");h.innerHTML="";const l=document.createElement("table"),n=document.createElement("tr");n.className="question-row",n.innerHTML="<td>Question: </td> <td>"+((null===(i=this.result)||void 0===i?void 0:i.title)||"")+'</td><div id="faq-modal-close-button"><svg width="48" height="49" viewBox="0 0 48 49" fill="black" xmlns="http://www.w3.org/2000/svg"><rect y="0.5" width="48" height="48" rx="24" fill="white"/><path fill-rule="evenodd" clip-rule="evenodd" d="M22.5382 24.5L15 16.9618L16.4618 15.5L24 23.0382L31.5382 15.5L33 16.9618L25.4618 24.5L33 32.0382L31.5382 33.5L24 25.9618L16.4618 33.5L15 32.0382L22.5382 24.5Z" fill="#17171A"/></svg></div>',l.appendChild(n);const a=document.createElement("tr"),r=document.createElement("td");r.innerText="Answer:",a.appendChild(r);const c=document.createElement("td");if(c.innerHTML=(null===(s=this.result)||void 0===s?void 0:s.raw.answer)||"",a.appendChild(c),l.appendChild(a),null===(o=this.result)||void 0===o?void 0:o.raw.category){const t=document.createElement("tr");t.innerHTML="<td> Category: </td><td>"+this.result.raw.category+"</td>",l.appendChild(t)}if(null===(e=this.result)||void 0===e?void 0:e.raw.newmoreinfo){const t=document.createElement("tr"),i=this.result.raw.newmoreinfo;t.innerHTML='<td> Link: </td><td> <a href="'+i+'" target="_blank">'+i+"</a> </td>",l.appendChild(t)}h.appendChild(l),this.modalElement.querySelector("#faq-modal-close-button").addEventListener("click",this.closeFAQModal),this.modalElement.setAttribute("is-open","true"),this.result&&localStorage.setItem(`visited-${this.result.title}`,"true"),this.host.classList.add("visited-title")}render(){if(this.result)return i(o,{className:"clickable-host",onClick:()=>this.openFAQModal(this.result)},this.result.title)}get host(){return s(this)}};l.style="b{color:var(--atomic-primary)}:host{color:#CAA144 !important;font-size:1.7rem !important;max-height:unset !important;line-height:normal !important}";export{l as faq_popup_component}