@crestapps/ai-chat-ui 2.0.0-preview.259 → 2.0.0-preview.263
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/ai-chat.js +12 -5
- package/dist/ai-chat.js.map +1 -1
- package/dist/ai-chat.min.js +4 -4
- package/dist/ai-chat.min.js.map +1 -1
- package/dist/chat-interaction.js +12 -5
- package/dist/chat-interaction.js.map +1 -1
- package/dist/chat-interaction.min.js +4 -4
- package/dist/chat-interaction.min.js.map +1 -1
- package/dist/chat-markers.js +197 -0
- package/dist/chat-markers.js.map +1 -1
- package/dist/chat-markers.min.js +1 -1
- package/dist/chat-markers.min.js.map +1 -1
- package/package.json +1 -1
package/dist/chat-interaction.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
var defaultConfig = {
|
|
9
9
|
generatedImageAltText: "Generated Image",
|
|
10
10
|
generatedImageMaxWidth: 400,
|
|
11
|
+
allowedImageHosts: [],
|
|
11
12
|
downloadImageTitle: "Download image",
|
|
12
13
|
downloadChartTitle: "Download chart as image",
|
|
13
14
|
downloadChartButtonText: "Download",
|
|
@@ -261,6 +262,7 @@
|
|
|
261
262
|
renderer.image = function(data) {
|
|
262
263
|
const src = sanitizeUrl(data.href);
|
|
263
264
|
if (!src) return "";
|
|
265
|
+
if (!window.CoreAIImages.isAllowedSource(src, { allowedHosts: defaultConfig.allowedImageHosts })) return window.CoreAIImages.linkHtml(src, data.text);
|
|
264
266
|
const alt = data.text || defaultConfig.generatedImageAltText;
|
|
265
267
|
return `<span class="generated-image-container">
|
|
266
268
|
<img src="${src}" alt="${alt}" class="img-thumbnail" style="max-width: ${defaultConfig.generatedImageMaxWidth}px; height: auto;" />
|
|
@@ -372,10 +374,10 @@
|
|
|
372
374
|
_pendingCharts = [];
|
|
373
375
|
const html = styleMarkdownTables(marked.parse(content, { renderer }));
|
|
374
376
|
message._pendingCharts = _pendingCharts.length > 0 ? [..._pendingCharts] : [];
|
|
375
|
-
const sanitizedHtml =
|
|
377
|
+
const sanitizedHtml = window.CoreAIImages.sanitize(DOMPurify, html, {
|
|
376
378
|
ADD_TAGS: ["canvas"],
|
|
377
379
|
ADD_ATTR: ["target"]
|
|
378
|
-
});
|
|
380
|
+
}, { allowedHosts: defaultConfig.allowedImageHosts });
|
|
379
381
|
return window.CoreAIChatImageCarousel ? window.CoreAIChatImageCarousel.stackAdjacentImages(sanitizedHtml) : sanitizedHtml;
|
|
380
382
|
}
|
|
381
383
|
function compactObject(source) {
|
|
@@ -416,6 +418,7 @@
|
|
|
416
418
|
console.error("The sendButtonElementSelector is required.");
|
|
417
419
|
return;
|
|
418
420
|
}
|
|
421
|
+
window.CoreAIChatSurface.registerRoot(document.querySelector(config.appElementSelector));
|
|
419
422
|
return Vue.createApp({
|
|
420
423
|
data() {
|
|
421
424
|
return {
|
|
@@ -1855,8 +1858,11 @@
|
|
|
1855
1858
|
}
|
|
1856
1859
|
function scanForAutoInitialization(root) {
|
|
1857
1860
|
if (!root || typeof root.querySelectorAll !== "function") return;
|
|
1858
|
-
|
|
1859
|
-
root.
|
|
1861
|
+
const isPageMarkup = (element) => !window.CoreAIChatSurface.isInsideRenderedMessage(element);
|
|
1862
|
+
if (typeof root.matches === "function" && root.matches(autoInitializeSelector) && isPageMarkup(root)) initializeFromElement(root);
|
|
1863
|
+
root.querySelectorAll(autoInitializeSelector).forEach((element) => {
|
|
1864
|
+
if (isPageMarkup(element)) initializeFromElement(element);
|
|
1865
|
+
});
|
|
1860
1866
|
}
|
|
1861
1867
|
function startAutoInitialization() {
|
|
1862
1868
|
scanForAutoInitialization(document);
|
|
@@ -2087,6 +2093,7 @@
|
|
|
2087
2093
|
formData.append("files", file);
|
|
2088
2094
|
const xhr = new XMLHttpRequest();
|
|
2089
2095
|
xhr.open("POST", config.uploadDocumentUrl, true);
|
|
2096
|
+
window.CoreAIAntiforgery.apply(xhr, config, config.uploadDocumentUrl);
|
|
2090
2097
|
xhr.upload.addEventListener("progress", (event) => {
|
|
2091
2098
|
if (!event.lengthComputable) return;
|
|
2092
2099
|
updateUploadItem(itemIdToUpdate, {
|
|
@@ -2227,7 +2234,7 @@
|
|
|
2227
2234
|
try {
|
|
2228
2235
|
const response = await fetch(config.removeDocumentUrl, {
|
|
2229
2236
|
method: "POST",
|
|
2230
|
-
headers: { "Content-Type": "application/json" },
|
|
2237
|
+
headers: window.CoreAIAntiforgery.headers(config, { "Content-Type": "application/json" }, config.removeDocumentUrl),
|
|
2231
2238
|
body: JSON.stringify({
|
|
2232
2239
|
itemId: config.itemId,
|
|
2233
2240
|
documentId
|