@alan-ai/alan-sdk-web 1.8.47 → 1.8.49
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/AlanButton.d.ts +3 -0
- package/dist/alan_lib.js +204 -23
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
package/dist/AlanButton.d.ts
CHANGED
package/dist/alan_lib.js
CHANGED
|
@@ -3369,7 +3369,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
3369
3369
|
}
|
|
3370
3370
|
// alan_btn/alan_btn.ts
|
|
3371
3371
|
(function (ns) {
|
|
3372
|
-
var alanButtonVersion = "alan-version.1.8.
|
|
3372
|
+
var alanButtonVersion = "alan-version.1.8.49";
|
|
3373
3373
|
alanButtonVersion = alanButtonVersion.replace("alan-version.", "");
|
|
3374
3374
|
if (window.alanBtn) {
|
|
3375
3375
|
console.warn("Alan: the Alan Button source code has already added (v." + alanButtonVersion + ")");
|
|
@@ -3446,6 +3446,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
3446
3446
|
var textChatOptions = null;
|
|
3447
3447
|
var clearChatIsInProcess = false;
|
|
3448
3448
|
var textChatScrollPosition = null;
|
|
3449
|
+
var sentMessageInd = null;
|
|
3450
|
+
var sentMessages = [];
|
|
3449
3451
|
var defaultMinChatHeight = 400;
|
|
3450
3452
|
var defaultChatHeight = 700;
|
|
3451
3453
|
var defaultMinChatWidth = 250;
|
|
@@ -3524,7 +3526,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
3524
3526
|
});
|
|
3525
3527
|
},
|
|
3526
3528
|
activate: function () {
|
|
3527
|
-
return activateAlanButton();
|
|
3529
|
+
return activateAlanButton({ activate: true });
|
|
3528
3530
|
},
|
|
3529
3531
|
deactivate: function () {
|
|
3530
3532
|
deactivateAlanButton();
|
|
@@ -3535,6 +3537,19 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
3535
3537
|
sendText: function (text) {
|
|
3536
3538
|
_sendText(text);
|
|
3537
3539
|
},
|
|
3540
|
+
textChat: {
|
|
3541
|
+
setAudioOutputEnabled: function (value) {
|
|
3542
|
+
if (value === true) {
|
|
3543
|
+
enableAudio(true);
|
|
3544
|
+
}
|
|
3545
|
+
else {
|
|
3546
|
+
disableAudio(true);
|
|
3547
|
+
}
|
|
3548
|
+
},
|
|
3549
|
+
isAudioOutputEnabled: function () {
|
|
3550
|
+
return textToSpeachVoiceEnabled;
|
|
3551
|
+
}
|
|
3552
|
+
},
|
|
3538
3553
|
//deprecated
|
|
3539
3554
|
callClientApi: function (method, data, callback) {
|
|
3540
3555
|
console.error('The "callClientApi" method is deprecated. Please use the "callProjectApi: instead.\n\nSee more info here: https://alan.app/docs/client-api/methods/common-api/?highlight=callprojectapi#callprojectapi');
|
|
@@ -4013,7 +4028,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
4013
4028
|
}
|
|
4014
4029
|
el.style.display = "flex";
|
|
4015
4030
|
setTimeout(function () {
|
|
4016
|
-
var textareaEl =
|
|
4031
|
+
var textareaEl = getChatTextareaEl();
|
|
4017
4032
|
if (textareaEl && state === DEFAULT) {
|
|
4018
4033
|
textareaEl.focus();
|
|
4019
4034
|
}
|
|
@@ -4634,6 +4649,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
4634
4649
|
keyFrames += getStyleSheetMarker() + ".alan-btn__chat-response-img-block {\n overflow: hidden;\n border-radius: 20px 20px 0 0;\n width: 100%;\n display: flex;\n }";
|
|
4635
4650
|
keyFrames += getStyleSheetMarker() + ".alan-btn__chat-response-video {\n width: 100%;\n min-width: 100%;\n min-height: 220px;\n height: 220px;\n max-height: 220px;\n }";
|
|
4636
4651
|
keyFrames += getStyleSheetMarker() + ".alan-btn__chat-response-img {\n cursor: pointer;\n transition: transform 300ms ease-in-out;\n width: 100%;\n min-width: 100%;\n min-height: 220px;\n height: 220px;\n max-height: 220px;\n object-fit: contain;\n pointer-events: initial;\n }";
|
|
4652
|
+
keyFrames += getStyleSheetMarker() + ".alan-btn__chat-response-img.img-vertical {\n object-fit: cover;\n }";
|
|
4637
4653
|
keyFrames += getStyleSheetMarker() + ".alan-btn__chat-response-img.not-found {\n opacity: 0.7;\n }";
|
|
4638
4654
|
if (!isMobile()) {
|
|
4639
4655
|
keyFrames += getStyleSheetMarker() + ".alan-btn__chat-response-imgs-wrapper:hover .alan-btn__chat-response-img {\n transform: scale(1.04);\n transition: transform 300ms ease-in-out;\n }";
|
|
@@ -4730,10 +4746,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
4730
4746
|
"blockquote + * {\n margin-top: 16px!important;\n }",
|
|
4731
4747
|
"audio {\n max-width: 100%!important;\n max-height: 100%!important;\n }",
|
|
4732
4748
|
"video {\n max-width: 100%!important;\n max-height: 100%!important;\n }",
|
|
4733
|
-
"img {\n max-width: 100%!important;\n pointer-events: auto!important;\n cursor: pointer;\n }",
|
|
4749
|
+
"img {\n max-width: 100%!important;\n pointer-events: auto!important;\n cursor: pointer;\n max-height: 500px;\n }",
|
|
4750
|
+
//;iuytfd
|
|
4734
4751
|
"code {\n background-color: #F8F8F8!important;\n border-radius: 3px!important;\n border: 1px solid #DDD!important;\n font-family: Consolas, \"Liberation Mono\", Courier, monospace!important;\n margin: 0 2px!important;\n padding: 0 5px!important;\n white-space: pre-line!important;\n font-size: ".concat(responseBubbleFontSize, "px!important;\n }"),
|
|
4735
4752
|
"pre {\n background-color: #F8F8F8!important;\n border-radius: 3px!important;\n border: 1px solid #DDD!important;\n font-family: Consolas, \"Liberation Mono\", Courier, monospace!important;\n padding: 0 5px!important;\n white-space: pre-line!important;\n font-size: ".concat(responseBubbleFontSize, "px!important;\n }"),
|
|
4736
|
-
"pre code {\n border: none!important;\n margin: 0!important;\n padding: 0!important;\n white-space: pre-
|
|
4753
|
+
"pre code {\n border: none!important;\n margin: 0!important;\n padding: 0!important;\n white-space: pre-wrap!important;\n font-size: ".concat(responseBubbleFontSize, "px!important;\n }"),
|
|
4737
4754
|
"hr {\n display: block!important;\n unicode-bidi: isolate!important;\n margin-block-start: 0.5em!important;\n margin-block-end: 0.5em!important;\n margin-inline-start: auto!important;\n margin-inline-end: auto!important;\n overflow: hidden!important;\n border-style: inset!important;\n border-width: 1px!important;\n }",
|
|
4738
4755
|
"blockquote {\n padding: 5px 20px 0!important;\n border-left: 5px solid #beb7b7!important;\n font-size: ".concat(responseBubbleFontSize, "px!important;\n }"),
|
|
4739
4756
|
"table > tbody > tr > td {\n background-color: #fff!important;\n color: #000!important;\n }",
|
|
@@ -4750,6 +4767,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
4750
4767
|
keyFrames += getStyleSheetMarker(true) + ".hide-alan-btn-when-text-chat-is-opened .alanBtn {\n transform: scale(0);\n opacity: 0;\n animation: text-chat-disappear-anim ".concat(textChatAppearAnimationMs, "ms ease-in-out forwards;\n }");
|
|
4751
4768
|
keyFrames += getStyleSheetMarker(true) + ".text-chat-is-closing .alanBtn {\n transform: scale(0);\n opacity: 0;\n animation: text-chat-appear-anim ".concat(textChatAppearAnimationMs, "ms ease-in-out forwards;\n }");
|
|
4752
4769
|
keyFrames += getStyleSheetMarker(true) + ".hide-alan-btn-when-text-chat-is-opened .alanBtn-recognised-text-holder {\n display: none;\n }";
|
|
4770
|
+
keyFrames += getStyleSheetMarker() + " mjx-container svg {\n max-width: 100%;\n }";
|
|
4753
4771
|
keyFrames += getStyleSheetMarker() + ".alan-overlay {position: fixed;top: 0;left: 0;right: 0;bottom: 0;z-index: 99;background: rgba(0, 0, 0, 0.57);opacity: 0;-webkit-animation: alan-fade-in 0.5s 0.2s forwards;-moz-animation: alan-fade-in 0.5s 0.2s forwards;-o-animation: alan-fade-in 0.5s 0.2s forwards;animation: alan-fade-in 0.5s 0.2s forwards;}";
|
|
4754
4772
|
keyFrames += getStyleSheetMarker() + ".alan-overlay-popup.alan-btn-lib__default-popup {border-radius:10px; box-shadow: 0px 5px 14px rgba(3, 3, 3, 0.25);padding:6px 30px 6px 12px;text-align: left;width: 220px;background: rgb(255 255 255);}";
|
|
4755
4773
|
keyFrames += getStyleSheetMarker() + ".alan-overlay-popup.alan-btn-lib__top.alan-btn-lib__right {border-top-right-radius: 0!important;}";
|
|
@@ -5579,6 +5597,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
5579
5597
|
curDialogId = dialogId;
|
|
5580
5598
|
saveDialogId(dialogId);
|
|
5581
5599
|
restoreMessageList(true);
|
|
5600
|
+
sentMessages = restoreSentMessages();
|
|
5582
5601
|
}
|
|
5583
5602
|
if (options2.onConnectionStatus) {
|
|
5584
5603
|
options2.onConnectionStatus(res);
|
|
@@ -5876,7 +5895,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
5876
5895
|
return resultStr;
|
|
5877
5896
|
}
|
|
5878
5897
|
function renderInterimForTextChat(msg) {
|
|
5879
|
-
var textarea =
|
|
5898
|
+
var textarea = getChatTextareaEl();
|
|
5880
5899
|
if (textarea) {
|
|
5881
5900
|
if (msg.final === true) {
|
|
5882
5901
|
renderMessageInTextChat(msg);
|
|
@@ -5892,8 +5911,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
5892
5911
|
imgPreviewOverlayEl.id = "img-preview-overlay";
|
|
5893
5912
|
imgPreviewOverlayEl.classList.add("alan-btn__image-preview-overlay");
|
|
5894
5913
|
imgPreviewOverlayEl.style.zIndex = btnZIndex + 3;
|
|
5895
|
-
|
|
5896
|
-
|
|
5914
|
+
if (parentEl) {
|
|
5915
|
+
imgPreviewOverlayEl.setAttribute("data-img-index", parentEl.getAttribute("data-img-index"));
|
|
5916
|
+
imgPreviewOverlayEl.setAttribute("data-msg-req-id", parentEl.getAttribute("data-msg-req-id"));
|
|
5917
|
+
}
|
|
5897
5918
|
var imgPreviewOverlayCloseIcon = document.createElement("div");
|
|
5898
5919
|
imgPreviewOverlayCloseIcon.id = "img-preview-overlay__close-icon";
|
|
5899
5920
|
imgPreviewOverlayCloseIcon.innerHTML = "\n <svg width=\"17\" height=\"17\" viewBox=\"0 0 17 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M0.342029 15.0105C-0.113105 15.4658 -0.113035 16.2036 0.34217 16.6587C0.797374 17.1138 1.53533 17.1138 1.99046 16.6586L8.50015 10.1482L15.0104 16.658C15.4655 17.1131 16.2035 17.1131 16.6586 16.658C17.1138 16.2029 17.1138 15.4649 16.6586 15.0098L10.1483 8.49998L16.6582 1.98944C17.1132 1.53427 17.1132 0.796371 16.6579 0.341282C16.2028 -0.113819 15.4648 -0.113749 15.0097 0.341421L8.49991 6.85183L1.98966 0.341981C1.5345 -0.113143 0.796535 -0.113143 0.341377 0.341981C-0.113792 0.797116 -0.113792 1.53502 0.341377 1.99016L6.85187 8.5001L0.342029 15.0105Z\" fill=\"#FFFFFF\"/>\n</svg>\n";
|
|
@@ -6061,7 +6082,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6061
6082
|
}
|
|
6062
6083
|
function getImageHtml(src) {
|
|
6063
6084
|
var imgNotFoundSrc = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACldJREFUeNrs3Wtv03YbwGEoZRyebRLivA22aYhNQki82vf/Apu2Fdi6lh62MppTW0jTloYkz/20kpenFJo4dg72db1AiIMLrn+9/3Yd53yv1zsHTM55EYIIQYSACEGEgAhBhIAIQYSACEGEgAhBhIAIQYSACEGEgAhBhIAIQYSACEGEgAhBhIAIQYSACEGEgAhBhMBsRLi1tbW6umpfM4vu379/8+bNXD/E/Bj+G+12u9ls+nQyi+LozftDzNnLMFkiBB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/BkrMLAeft8AAAAASUVORK5CYII=";
|
|
6064
|
-
return "<img class=\"alan-btn__chat-response-img alan-btn__chat-response-img-el\" src=\"".concat(src, "\" onerror=\"this.src = '").concat(imgNotFoundSrc, "'; this.classList.add('not-found');\"/>");
|
|
6085
|
+
return "<img class=\"alan-btn__chat-response-img alan-btn__chat-response-img-el\" src=\"".concat(src, "\" onerror=\"this.src = '").concat(imgNotFoundSrc, "'; this.classList.add('not-found');\" onload = \"console.info(this.naturalWidth,this.naturalHeight ); if(this.naturalWidth < this.naturalHeight){this.classList.add('img-vertical');}\"/>");
|
|
6065
6086
|
}
|
|
6066
6087
|
function getYoutubeFrameHtml(src) {
|
|
6067
6088
|
return "<iframe class=\"alan-btn__chat-response-video\" width=\"560\" height=\"315\" src=\"".concat(src, "?autoplay=1&mute=1\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe>");
|
|
@@ -6123,8 +6144,77 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6123
6144
|
function buildMsgContent(msg) {
|
|
6124
6145
|
return "".concat(buildImagesContent(msg)).concat(buildMsgTextContent(msg)).concat(buildLinksContent(msg)).concat(buildLikesContent(msg)).concat(buildMsgIncommingLoader(msg));
|
|
6125
6146
|
}
|
|
6147
|
+
function highlightCode() {
|
|
6148
|
+
if (window.hljs) {
|
|
6149
|
+
setTimeout(function () {
|
|
6150
|
+
var msgHolder = document.getElementById("chatMessages");
|
|
6151
|
+
if (msgHolder) {
|
|
6152
|
+
msgHolder.querySelectorAll("pre code:not(.alan-btn__hljs-processed)").forEach(function (el) {
|
|
6153
|
+
window.hljs.highlightElement(el);
|
|
6154
|
+
el.classList.add("alan-btn__hljs-processed");
|
|
6155
|
+
});
|
|
6156
|
+
}
|
|
6157
|
+
});
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
function loadHighlightJs() {
|
|
6161
|
+
var script = document.createElement("script");
|
|
6162
|
+
script.src = "https://studio.alan.app/js/hljs/highlight.min.js?v=1";
|
|
6163
|
+
script.async = true;
|
|
6164
|
+
script.onload = function () {
|
|
6165
|
+
highlightCode();
|
|
6166
|
+
};
|
|
6167
|
+
document.head.appendChild(script);
|
|
6168
|
+
var link = document.createElement("link");
|
|
6169
|
+
link.rel = "stylesheet";
|
|
6170
|
+
link.href = "https://studio.alan.app/js/hljs/github.min.css?v=1";
|
|
6171
|
+
document.getElementsByTagName("head")[0].appendChild(link);
|
|
6172
|
+
}
|
|
6173
|
+
loadHighlightJs();
|
|
6174
|
+
function loadMathJax() {
|
|
6175
|
+
window.MathJax = {
|
|
6176
|
+
startup: {
|
|
6177
|
+
pageReady: function () {
|
|
6178
|
+
return window.MathJax.startup.defaultPageReady();
|
|
6179
|
+
}
|
|
6180
|
+
},
|
|
6181
|
+
tex: {
|
|
6182
|
+
inlineMath: [["$", "$"], ["\\(", "\\)"]],
|
|
6183
|
+
processEscapes: true
|
|
6184
|
+
}
|
|
6185
|
+
};
|
|
6186
|
+
var script = document.createElement("script");
|
|
6187
|
+
script.src = "https://studio.alan.app/js/mathjax/tex-svg.js?v=1";
|
|
6188
|
+
script.async = true;
|
|
6189
|
+
script.setAttribute("id", "MathJax-script");
|
|
6190
|
+
script.onload = function () {
|
|
6191
|
+
processFormulasInMsgs();
|
|
6192
|
+
};
|
|
6193
|
+
document.head.appendChild(script);
|
|
6194
|
+
}
|
|
6195
|
+
loadMathJax();
|
|
6196
|
+
function processFormulas(msgInd) {
|
|
6197
|
+
var MathJax = window.MathJax;
|
|
6198
|
+
if (MathJax) {
|
|
6199
|
+
setTimeout(function () {
|
|
6200
|
+
var output = document.getElementById("msg-" + msgInd).querySelectorAll(".alan-btn__chat-response-text-wrapper")[0];
|
|
6201
|
+
if (output && MathJax.texReset) {
|
|
6202
|
+
MathJax.texReset();
|
|
6203
|
+
MathJax.typesetClear();
|
|
6204
|
+
MathJax.typesetPromise([output])["catch"](function (err) {
|
|
6205
|
+
console.error(err);
|
|
6206
|
+
});
|
|
6207
|
+
}
|
|
6208
|
+
});
|
|
6209
|
+
}
|
|
6210
|
+
}
|
|
6211
|
+
function processFormulasInMsgs() {
|
|
6212
|
+
for (var i2 = 0; i2 < textChatMessages.length; i2++) {
|
|
6213
|
+
processFormulas(i2);
|
|
6214
|
+
}
|
|
6215
|
+
}
|
|
6126
6216
|
function renderMessageInTextChat(msg, noAnimation, immidiateScroll) {
|
|
6127
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
6217
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
6128
6218
|
if (!textChatIsAvailable)
|
|
6129
6219
|
return;
|
|
6130
6220
|
var innerMsgPart = "";
|
|
@@ -6165,7 +6255,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6165
6255
|
}
|
|
6166
6256
|
}
|
|
6167
6257
|
msg = __assign(__assign({}, msg), getMsgReadProp(msg, textChatIsHidden));
|
|
6168
|
-
var
|
|
6258
|
+
var _p = processMessageForChat(msg, textChatMessages), isNew = _p.isNew, msgInd = _p.msgInd, replaceLoader = _p.replaceLoader, updateResponse = _p.updateResponse;
|
|
6169
6259
|
if (isNew) {
|
|
6170
6260
|
var div = document.createElement("div");
|
|
6171
6261
|
div.id = "msg-" + msgInd;
|
|
@@ -6183,6 +6273,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6183
6273
|
else {
|
|
6184
6274
|
scrollTextChat(msgHolder);
|
|
6185
6275
|
}
|
|
6276
|
+
if (((_g = msg.ctx) === null || _g === void 0 ? void 0 : _g.final) !== false) {
|
|
6277
|
+
processFormulas(msgInd);
|
|
6278
|
+
highlightCode();
|
|
6279
|
+
}
|
|
6186
6280
|
}
|
|
6187
6281
|
else {
|
|
6188
6282
|
var msgEl = document.getElementById("msg-" + msgInd);
|
|
@@ -6192,7 +6286,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6192
6286
|
if (innerEl) {
|
|
6193
6287
|
innerEl.innerHTML = innerMsgPart;
|
|
6194
6288
|
innerEl.classList.remove("alan-incoming-msg");
|
|
6195
|
-
if (msg.type !== "chat" && ((
|
|
6289
|
+
if (msg.type !== "chat" && ((_h = msg.images) === null || _h === void 0 ? void 0 : _h.length) > 0) {
|
|
6196
6290
|
innerEl.classList.add("with-images");
|
|
6197
6291
|
}
|
|
6198
6292
|
scrollTextChat(msgHolder, "smooth");
|
|
@@ -6202,18 +6296,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6202
6296
|
var innerEl = msgEl.children[0];
|
|
6203
6297
|
var updatedMsg = textChatMessages[msgInd];
|
|
6204
6298
|
var imagesWrapper = innerEl.querySelector(".alan-btn__chat-response-imgs-wrapper");
|
|
6205
|
-
if (((
|
|
6299
|
+
if (((_j = updatedMsg.images) === null || _j === void 0 ? void 0 : _j.length) > 0 && !imagesWrapper) {
|
|
6206
6300
|
innerEl.insertAdjacentHTML("afterbegin", buildImagesContent(updatedMsg));
|
|
6207
6301
|
innerEl = msgEl.children[0];
|
|
6208
6302
|
}
|
|
6209
|
-
if (((
|
|
6303
|
+
if (((_k = updatedMsg.images) === null || _k === void 0 ? void 0 : _k.length) > 1 && imagesWrapper) {
|
|
6210
6304
|
imagesWrapper.querySelector(".alan-btn__chat-response-imgs-wrapper-right-arrow").classList.remove("invisible");
|
|
6211
6305
|
}
|
|
6212
|
-
if (updatedMsg.type !== "chat" && ((
|
|
6306
|
+
if (updatedMsg.type !== "chat" && ((_l = updatedMsg.images) === null || _l === void 0 ? void 0 : _l.length) > 0) {
|
|
6213
6307
|
innerEl.classList.add("with-images");
|
|
6214
6308
|
}
|
|
6215
6309
|
var msgParts = innerEl.children;
|
|
6216
|
-
var stop_1 = ((
|
|
6310
|
+
var stop_1 = ((_m = updatedMsg.images) === null || _m === void 0 ? void 0 : _m.length) === 0 ? 0 : 1;
|
|
6217
6311
|
while (msgParts.length > stop_1) {
|
|
6218
6312
|
msgParts[msgParts.length - 1].remove();
|
|
6219
6313
|
}
|
|
@@ -6229,6 +6323,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6229
6323
|
msgEl.innerHTML = msgHtml;
|
|
6230
6324
|
}
|
|
6231
6325
|
}
|
|
6326
|
+
if (((_o = msg.ctx) === null || _o === void 0 ? void 0 : _o.final) !== false) {
|
|
6327
|
+
processFormulas(msgInd);
|
|
6328
|
+
highlightCode();
|
|
6329
|
+
}
|
|
6232
6330
|
}
|
|
6233
6331
|
saveMessageHistory();
|
|
6234
6332
|
if (textChatIsAvailable && textChatIsHidden) {
|
|
@@ -6356,6 +6454,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6356
6454
|
case 1:
|
|
6357
6455
|
res = _a.sent();
|
|
6358
6456
|
msg = __assign(__assign({}, msg), { reqId: res.reqId });
|
|
6457
|
+
saveSentMessages(text);
|
|
6359
6458
|
renderMessageInTextChat(msg);
|
|
6360
6459
|
renderMessageInTextChat({
|
|
6361
6460
|
type: "response",
|
|
@@ -6379,7 +6478,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6379
6478
|
return __awaiter(this, void 0, void 0, function () {
|
|
6380
6479
|
var textareaEl, textareaHolderEl, text;
|
|
6381
6480
|
return __generator(this, function (_a) {
|
|
6382
|
-
textareaEl =
|
|
6481
|
+
textareaEl = getChatTextareaEl();
|
|
6383
6482
|
textareaHolderEl = document.getElementById("textarea-holder");
|
|
6384
6483
|
text = textareaEl.value;
|
|
6385
6484
|
if (lastSendMsgTs) {
|
|
@@ -6429,6 +6528,72 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6429
6528
|
}
|
|
6430
6529
|
}
|
|
6431
6530
|
}
|
|
6531
|
+
function getRestoreMsgsLsKey() {
|
|
6532
|
+
var projectId = getProjectId();
|
|
6533
|
+
return "alan-btn-chat-sent-history-".concat(projectId);
|
|
6534
|
+
}
|
|
6535
|
+
function restoreSentMessages() {
|
|
6536
|
+
var messages = [];
|
|
6537
|
+
if (isLocalStorageAvailable) {
|
|
6538
|
+
var key = getRestoreMsgsLsKey();
|
|
6539
|
+
try {
|
|
6540
|
+
messages = JSON.parse(localStorage.getItem(key)) || [];
|
|
6541
|
+
}
|
|
6542
|
+
catch (e) {
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
return messages;
|
|
6546
|
+
}
|
|
6547
|
+
function saveSentMessages(text) {
|
|
6548
|
+
if (isLocalStorageAvailable) {
|
|
6549
|
+
var maxSavedForHistoryMsgCount = 25;
|
|
6550
|
+
var key = getRestoreMsgsLsKey();
|
|
6551
|
+
sentMessages.push(text);
|
|
6552
|
+
if (sentMessages.length > 50) {
|
|
6553
|
+
sentMessages = sentMessages.slice(Math.max(sentMessages.length - maxSavedForHistoryMsgCount, 0));
|
|
6554
|
+
}
|
|
6555
|
+
if (sentMessages.length > 0) {
|
|
6556
|
+
localStorage.setItem(key, JSON.stringify(sentMessages));
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6559
|
+
}
|
|
6560
|
+
function switchMessages(keyCode) {
|
|
6561
|
+
var messages = __spreadArray([], sentMessages, true);
|
|
6562
|
+
messages = messages.reverse();
|
|
6563
|
+
if (messages.length === 0) {
|
|
6564
|
+
return;
|
|
6565
|
+
}
|
|
6566
|
+
if (keyCode === 38) {
|
|
6567
|
+
if (sentMessageInd === null || sentMessageInd + 1 === messages.length) {
|
|
6568
|
+
sentMessageInd = 0;
|
|
6569
|
+
}
|
|
6570
|
+
else {
|
|
6571
|
+
sentMessageInd = sentMessageInd + 1;
|
|
6572
|
+
}
|
|
6573
|
+
}
|
|
6574
|
+
if (keyCode === 40) {
|
|
6575
|
+
if (sentMessageInd === null || sentMessageInd - 1 === -1) {
|
|
6576
|
+
sentMessageInd = messages.length - 1;
|
|
6577
|
+
}
|
|
6578
|
+
else {
|
|
6579
|
+
sentMessageInd = sentMessageInd - 1;
|
|
6580
|
+
}
|
|
6581
|
+
}
|
|
6582
|
+
var textareaEl = getChatTextareaEl();
|
|
6583
|
+
textareaEl.value = messages[sentMessageInd];
|
|
6584
|
+
moveCursorToEnd(textareaEl);
|
|
6585
|
+
}
|
|
6586
|
+
function moveCursorToEnd(el) {
|
|
6587
|
+
el.focus();
|
|
6588
|
+
if (typeof el.selectionStart == "number") {
|
|
6589
|
+
el.selectionStart = el.selectionEnd = el.value.length;
|
|
6590
|
+
}
|
|
6591
|
+
else if (typeof el.createTextRange != "undefined") {
|
|
6592
|
+
var range = el.createTextRange();
|
|
6593
|
+
range.collapse(false);
|
|
6594
|
+
range.select();
|
|
6595
|
+
}
|
|
6596
|
+
}
|
|
6432
6597
|
function onChatTextAreaKeyDown(e) {
|
|
6433
6598
|
var keyCode = e.keyCode || e.which;
|
|
6434
6599
|
if (keyCode === 13 && e.shiftKey) {
|
|
@@ -6443,6 +6608,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6443
6608
|
e.stopPropagation();
|
|
6444
6609
|
e.preventDefault();
|
|
6445
6610
|
}
|
|
6611
|
+
var goToPrev = keyCode === 38;
|
|
6612
|
+
var goToNext = keyCode === 40;
|
|
6613
|
+
if (goToPrev || goToNext) {
|
|
6614
|
+
switchMessages(keyCode);
|
|
6615
|
+
e.stopPropagation();
|
|
6616
|
+
e.preventDefault();
|
|
6617
|
+
return;
|
|
6618
|
+
}
|
|
6446
6619
|
}
|
|
6447
6620
|
function disableVoiceEnabledBtn() {
|
|
6448
6621
|
var muteAlanBtn = document.getElementById("chat-unmute-btn");
|
|
@@ -6486,7 +6659,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6486
6659
|
}
|
|
6487
6660
|
function hideKeyboard() {
|
|
6488
6661
|
if (isMobile()) {
|
|
6489
|
-
var chatTextarea =
|
|
6662
|
+
var chatTextarea = getChatTextareaEl();
|
|
6490
6663
|
if (chatTextarea) {
|
|
6491
6664
|
chatTextarea.blur();
|
|
6492
6665
|
}
|
|
@@ -6505,10 +6678,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6505
6678
|
var clickedEl = e.target;
|
|
6506
6679
|
processClickByButtonInPopup(clickedEl, btnInstance, _sendText);
|
|
6507
6680
|
}
|
|
6681
|
+
function getChatTextareaEl() {
|
|
6682
|
+
return document.getElementById("chatTextarea");
|
|
6683
|
+
}
|
|
6508
6684
|
function initTextChat() {
|
|
6509
6685
|
var _a, _b, _c;
|
|
6510
6686
|
var textareaDiv = document.getElementById("textarea-holder");
|
|
6511
|
-
var chatTextarea =
|
|
6687
|
+
var chatTextarea = getChatTextareaEl();
|
|
6512
6688
|
var chatMicBtn = document.getElementById("chat-mic-btn");
|
|
6513
6689
|
var unmuteAlanBtn = document.getElementById("chat-unmute-btn");
|
|
6514
6690
|
var chatSendBtn = document.getElementById("chat-send-btn");
|
|
@@ -7523,6 +7699,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7523
7699
|
var dndInitMousePos = [0, 0];
|
|
7524
7700
|
var chatHeight, chatWidth, typeBorderHor, typeBorderVert;
|
|
7525
7701
|
var chatInitLeftPos, chatInitRightPos, chatInitTopPos, chatInitBottomPos;
|
|
7702
|
+
var chatTopPosBeforeResize;
|
|
7703
|
+
var chatBottomPosBeforeResize;
|
|
7526
7704
|
var chatRightAligned, chatLeftAligned, chatTopAligned, chatBottomAligned;
|
|
7527
7705
|
if (!isMobile()) {
|
|
7528
7706
|
chatHolderDiv.addEventListener("mousedown", onMouseDownForResizeTextChat);
|
|
@@ -7565,14 +7743,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7565
7743
|
posInfo.clientX,
|
|
7566
7744
|
posInfo.clientY
|
|
7567
7745
|
];
|
|
7568
|
-
|
|
7569
|
-
|
|
7746
|
+
var chatRect = chatHolderDiv.getBoundingClientRect();
|
|
7747
|
+
chatHeight = chatRect.height;
|
|
7748
|
+
chatWidth = chatRect.width;
|
|
7570
7749
|
typeBorderHor = getBorderType(posInfo).typeBorderHor;
|
|
7571
7750
|
typeBorderVert = getBorderType(posInfo).typeBorderVert;
|
|
7572
7751
|
chatInitLeftPos = parseInt(chatHolderDiv.style.left);
|
|
7573
7752
|
chatInitRightPos = parseInt(chatHolderDiv.style.right);
|
|
7574
7753
|
chatInitTopPos = parseInt(chatHolderDiv.style.top);
|
|
7575
7754
|
chatInitBottomPos = parseInt(chatHolderDiv.style.bottom);
|
|
7755
|
+
chatTopPosBeforeResize = chatRect.top;
|
|
7756
|
+
chatBottomPosBeforeResize = chatRect.bottom;
|
|
7576
7757
|
chatRightAligned = chatHolderDiv.style.right;
|
|
7577
7758
|
chatLeftAligned = chatHolderDiv.style.left;
|
|
7578
7759
|
chatTopAligned = chatHolderDiv.style.top;
|
|
@@ -7625,8 +7806,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7625
7806
|
var minChatHeight = ((_a = textChatOptions === null || textChatOptions === void 0 ? void 0 : textChatOptions.popup) === null || _a === void 0 ? void 0 : _a.minHeight) || defaultMinChatHeight;
|
|
7626
7807
|
var expanding = borderType === "bottom" && delta > 0 || borderType === "top" && delta < 0;
|
|
7627
7808
|
var h = borderType === "bottom" ? chatHeight + delta : chatHeight - delta;
|
|
7628
|
-
var newBottomtPos =
|
|
7629
|
-
var newTopPos =
|
|
7809
|
+
var newBottomtPos = chatBottomPosBeforeResize - delta;
|
|
7810
|
+
var newTopPos = chatTopPosBeforeResize + delta;
|
|
7630
7811
|
if (borderType === "bottom" && newBottomtPos <= 0 && h >= chatHeight) {
|
|
7631
7812
|
return false;
|
|
7632
7813
|
}
|