@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/ai-chat.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
var defaultConfig = {
|
|
20
20
|
generatedImageAltText: "Generated Image",
|
|
21
21
|
generatedImageMaxWidth: 400,
|
|
22
|
+
allowedImageHosts: [],
|
|
22
23
|
downloadImageTitle: "Download image",
|
|
23
24
|
downloadChartTitle: "Download chart as image",
|
|
24
25
|
downloadChartButtonText: "Download",
|
|
@@ -480,6 +481,7 @@
|
|
|
480
481
|
renderer.image = function(data) {
|
|
481
482
|
const src = sanitizeUrl(data.href);
|
|
482
483
|
if (!src) return "";
|
|
484
|
+
if (!window.CoreAIImages.isAllowedSource(src, { allowedHosts: defaultConfig.allowedImageHosts })) return window.CoreAIImages.linkHtml(src, data.text);
|
|
483
485
|
const alt = data.text || defaultConfig.generatedImageAltText;
|
|
484
486
|
return `<span class="generated-image-container">
|
|
485
487
|
<img src="${src}" alt="${alt}" class="img-thumbnail" style="max-width: ${defaultConfig.generatedImageMaxWidth}px; height: auto;" />
|
|
@@ -603,10 +605,10 @@
|
|
|
603
605
|
_pendingCharts = [];
|
|
604
606
|
const html = styleMarkdownTables(marked.parse(content, { renderer }));
|
|
605
607
|
message._pendingCharts = _pendingCharts.length > 0 ? [..._pendingCharts] : [];
|
|
606
|
-
const sanitizedHtml =
|
|
608
|
+
const sanitizedHtml = window.CoreAIImages.sanitize(DOMPurify, html, {
|
|
607
609
|
ADD_TAGS: ["canvas"],
|
|
608
610
|
ADD_ATTR: ["target"]
|
|
609
|
-
});
|
|
611
|
+
}, { allowedHosts: defaultConfig.allowedImageHosts });
|
|
610
612
|
return window.CoreAIChatImageCarousel ? window.CoreAIChatImageCarousel.stackAdjacentImages(sanitizedHtml) : sanitizedHtml;
|
|
611
613
|
}
|
|
612
614
|
function compactObject(source) {
|
|
@@ -817,6 +819,7 @@
|
|
|
817
819
|
for (var i = 0; i < filesToUpload.length; i++) formData.append("files", filesToUpload[i]);
|
|
818
820
|
var response = await fetch(config.uploadDocumentUrl, {
|
|
819
821
|
method: "POST",
|
|
822
|
+
headers: window.CoreAIAntiforgery.headers(config, void 0, config.uploadDocumentUrl),
|
|
820
823
|
body: formData
|
|
821
824
|
});
|
|
822
825
|
if (!response.ok) {
|
|
@@ -866,7 +869,7 @@
|
|
|
866
869
|
var sessionId = this.getSessionId();
|
|
867
870
|
var response = await fetch(config.removeDocumentUrl, {
|
|
868
871
|
method: "POST",
|
|
869
|
-
headers: { "Content-Type": "application/json" },
|
|
872
|
+
headers: window.CoreAIAntiforgery.headers(config, { "Content-Type": "application/json" }, config.removeDocumentUrl),
|
|
870
873
|
body: JSON.stringify({
|
|
871
874
|
itemId: sessionId,
|
|
872
875
|
documentId: doc.documentId
|
|
@@ -2797,6 +2800,7 @@
|
|
|
2797
2800
|
},
|
|
2798
2801
|
template: config.messageTemplate
|
|
2799
2802
|
};
|
|
2803
|
+
window.CoreAIChatSurface.registerRoot(document.querySelector(config.appElementSelector));
|
|
2800
2804
|
const app = Vue.createApp(appDefinition).mount(config.appElementSelector);
|
|
2801
2805
|
if (widgetBehavior && typeof widgetBehavior.attach === "function") widgetBehavior.attach(app, config);
|
|
2802
2806
|
return app;
|
|
@@ -2889,8 +2893,11 @@
|
|
|
2889
2893
|
}
|
|
2890
2894
|
function scanForAutoInitialization(root) {
|
|
2891
2895
|
if (!root || typeof root.querySelectorAll !== "function") return;
|
|
2892
|
-
|
|
2893
|
-
root.
|
|
2896
|
+
const isPageMarkup = (element) => !window.CoreAIChatSurface.isInsideRenderedMessage(element);
|
|
2897
|
+
if (typeof root.matches === "function" && root.matches(autoInitializeSelector) && isPageMarkup(root)) initializeFromElement(root);
|
|
2898
|
+
root.querySelectorAll(autoInitializeSelector).forEach((element) => {
|
|
2899
|
+
if (isPageMarkup(element)) initializeFromElement(element);
|
|
2900
|
+
});
|
|
2894
2901
|
}
|
|
2895
2902
|
function startAutoInitialization() {
|
|
2896
2903
|
scanForAutoInitialization(document);
|