@microsoft/omnichannel-chat-widget 1.0.5-main.d908c85 → 1.0.6-main.0c19ff3
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/lib/cjs/common/Constants.js +1 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +19 -17
- package/lib/cjs/common/utils.js +17 -2
- package/lib/cjs/components/footerstateful/FooterStateful.js +2 -2
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +21 -12
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/interfaces/IWebChatTranscriptConfig.js +1 -0
- package/lib/cjs/components/livechatwidget/common/createDownloadTranscriptProps.js +27 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -1
- package/lib/cjs/components/livechatwidget/common/startChat.js +27 -12
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +36 -28
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +6 -0
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +5 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +21 -11
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles.js +10 -0
- package/lib/cjs/plugins/createChatTranscript.js +548 -0
- package/lib/esm/common/Constants.js +1 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +19 -17
- package/lib/esm/common/utils.js +15 -1
- package/lib/esm/components/footerstateful/FooterStateful.js +2 -2
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +22 -13
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/interfaces/IWebChatTranscriptConfig.js +1 -0
- package/lib/esm/components/livechatwidget/common/createDownloadTranscriptProps.js +20 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -1
- package/lib/esm/components/livechatwidget/common/startChat.js +27 -12
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +36 -28
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +6 -0
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +5 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +21 -11
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles.js +3 -0
- package/lib/esm/plugins/createChatTranscript.js +543 -0
- package/lib/types/common/Constants.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +3 -3
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +2 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/interfaces/IDownloadTranscriptProps.d.ts +5 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/interfaces/IWebChatTranscriptConfig.d.ts +13 -0
- package/lib/types/components/livechatwidget/common/createDownloadTranscriptProps.d.ts +24 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles.d.ts +2 -0
- package/lib/types/plugins/createChatTranscript.d.ts +2 -0
- package/package.json +3 -3
|
@@ -7,22 +7,23 @@ exports.default = exports.WebChatContainerStateful = void 0;
|
|
|
7
7
|
var _react = require("@fluentui/react");
|
|
8
8
|
var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
10
|
-
var
|
|
10
|
+
var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
|
|
11
11
|
var _broadcastChannel = require("broadcast-channel");
|
|
12
|
+
var _botframeworkWebchat = require("botframework-webchat");
|
|
13
|
+
var _Constants = require("../../common/Constants");
|
|
12
14
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
13
15
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
14
|
-
var _defaultMiddlewareLocalizedTexts = require("./common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
15
|
-
var _defaultWebChatContainerStatefulProps = require("./common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
16
|
-
var _utils = require("../../common/utils");
|
|
17
|
-
var _ = require("../..");
|
|
18
16
|
var _WebChatActionType = require("./webchatcontroller/enums/WebChatActionType");
|
|
19
17
|
var _WebChatStoreLoader = require("./webchatcontroller/WebChatStoreLoader");
|
|
20
|
-
var _Constants = require("../../common/Constants");
|
|
21
|
-
var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
|
|
22
18
|
var _defaultAdaptiveCardStyles = require("./common/defaultStyles/defaultAdaptiveCardStyles");
|
|
19
|
+
var _defaultMiddlewareLocalizedTexts = require("./common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
23
20
|
var _defaultReceivedMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles");
|
|
24
|
-
var _defaultUserMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles");
|
|
25
21
|
var _defaultSystemMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles");
|
|
22
|
+
var _defaultUserMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles");
|
|
23
|
+
var _defaultWebChatContainerStatefulProps = require("./common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
24
|
+
var _utils = require("../../common/utils");
|
|
25
|
+
var _ = require("../..");
|
|
26
|
+
var _defaultSentMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles");
|
|
26
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
29
|
const broadcastChannelMessageEvent = "message";
|
|
@@ -51,7 +52,7 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
51
52
|
};
|
|
52
53
|
};
|
|
53
54
|
const WebChatContainerStateful = props => {
|
|
54
|
-
var _props$adaptiveCardSt, _props$renderingMiddl, _props$renderingMiddl2, _props$renderingMiddl3, _props$renderingMiddl4, _props$adaptiveCardSt2, _props$renderingMiddl5, _props$renderingMiddl6, _props$renderingMiddl7, _props$renderingMiddl8;
|
|
55
|
+
var _props$adaptiveCardSt, _props$renderingMiddl, _props$renderingMiddl2, _props$renderingMiddl3, _props$renderingMiddl4, _props$adaptiveCardSt2, _props$adaptiveCardSt3, _props$adaptiveCardSt4, _props$renderingMiddl5, _props$renderingMiddl6, _props$renderingMiddl7, _props$renderingMiddl8, _props$renderingMiddl9, _props$renderingMiddl10;
|
|
55
56
|
const {
|
|
56
57
|
BasicWebChat
|
|
57
58
|
} = _botframeworkWebchat.Components;
|
|
@@ -132,7 +133,9 @@ const WebChatContainerStateful = props => {
|
|
|
132
133
|
max-width: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl3 = props.renderingMiddlewareProps) === null || _props$renderingMiddl3 === void 0 ? void 0 : (_props$renderingMiddl4 = _props$renderingMiddl3.systemMessageBoxStyles) === null || _props$renderingMiddl4 === void 0 ? void 0 : _props$renderingMiddl4.maxWidth) ?? (_defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles === null || _defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles === void 0 ? void 0 : _defaultSystemMessageBoxStyles.defaultSystemMessageBoxStyles.maxWidth)}
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
div[class="ac-textBlock"]>p{color:${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt2 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt2 === void 0 ? void 0 : _props$adaptiveCardSt2.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color};}
|
|
136
|
+
div[class="ac-textBlock"]>p{color:${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt2 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt2 === void 0 ? void 0 : _props$adaptiveCardSt2.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color}; white-space:${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt3 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt3 === void 0 ? void 0 : _props$adaptiveCardSt3.textWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.textWhiteSpace}}
|
|
137
|
+
|
|
138
|
+
.webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt4 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt4 === void 0 ? void 0 : _props$adaptiveCardSt4.buttonWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.buttonWhiteSpace} !important;}
|
|
136
139
|
|
|
137
140
|
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
138
141
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
@@ -152,7 +155,14 @@ const WebChatContainerStateful = props => {
|
|
|
152
155
|
.ms_lcw_webchat_received_message a:hover,
|
|
153
156
|
.ms_lcw_webchat_received_message a:active {
|
|
154
157
|
color: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl7 = props.renderingMiddlewareProps) === null || _props$renderingMiddl7 === void 0 ? void 0 : (_props$renderingMiddl8 = _props$renderingMiddl7.receivedMessageAnchorStyles) === null || _props$renderingMiddl8 === void 0 ? void 0 : _props$renderingMiddl8.color) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.color)};
|
|
155
|
-
}
|
|
158
|
+
}
|
|
159
|
+
.ms_lcw_webchat_sent_message a:link,
|
|
160
|
+
.ms_lcw_webchat_sent_message a:visited,
|
|
161
|
+
.ms_lcw_webchat_sent_message a:hover,
|
|
162
|
+
.ms_lcw_webchat_sent_message a:active {
|
|
163
|
+
color: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl9 = props.renderingMiddlewareProps) === null || _props$renderingMiddl9 === void 0 ? void 0 : (_props$renderingMiddl10 = _props$renderingMiddl9.sentMessageAnchorStyles) === null || _props$renderingMiddl10 === void 0 ? void 0 : _props$renderingMiddl10.color) ?? (_defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles === null || _defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles === void 0 ? void 0 : _defaultSentMessageAnchorStyles.defaultSentMessageAnchorStyles.color)};
|
|
164
|
+
}
|
|
165
|
+
`), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
156
166
|
styles: containerStyles
|
|
157
167
|
}, /*#__PURE__*/_react2.default.createElement(BasicWebChat, null)));
|
|
158
168
|
};
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.defaultAdaptiveCardStyles = void 0;
|
|
7
7
|
const defaultAdaptiveCardStyles = {
|
|
8
8
|
background: "white",
|
|
9
|
-
color: "black"
|
|
9
|
+
color: "black",
|
|
10
|
+
textWhiteSpace: "normal",
|
|
11
|
+
buttonWhiteSpace: "normal"
|
|
10
12
|
};
|
|
11
13
|
exports.defaultAdaptiveCardStyles = defaultAdaptiveCardStyles;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultSentMessageAnchorStyles = void 0;
|
|
7
|
+
const defaultSentMessageAnchorStyles = {
|
|
8
|
+
color: "blue"
|
|
9
|
+
};
|
|
10
|
+
exports.defaultSentMessageAnchorStyles = defaultSentMessageAnchorStyles;
|
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _utils = require("../common/utils");
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
|
+
class TranscriptHTMLBuilder {
|
|
12
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
13
|
+
|
|
14
|
+
constructor(options) {
|
|
15
|
+
var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6, _this$options7, _this$options8, _this$options9, _this$options10, _this$options11;
|
|
16
|
+
_defineProperty(this, "options", void 0);
|
|
17
|
+
_defineProperty(this, "pageTitle", "Customer Transcript");
|
|
18
|
+
_defineProperty(this, "attachmentMessage", "The following attachment was uploaded during the conversation: ");
|
|
19
|
+
_defineProperty(this, "networkOnlineMessage", "Connection restored. Please refresh the page");
|
|
20
|
+
_defineProperty(this, "networkOfflineMessage", "Network Error. Please make sure you are connected to the internet.");
|
|
21
|
+
_defineProperty(this, "transcriptBackgroundColor", "#FFF");
|
|
22
|
+
_defineProperty(this, "agentAvatarBackgroundColor", "#E8E8E8");
|
|
23
|
+
_defineProperty(this, "agentAvatarFontColor", "#000");
|
|
24
|
+
_defineProperty(this, "customerAvatarBackgroundColor", "#2266E3");
|
|
25
|
+
_defineProperty(this, "customerAvatarFontColor", "#FFF");
|
|
26
|
+
_defineProperty(this, "disableMarkdownMessageFormatting", false);
|
|
27
|
+
_defineProperty(this, "disableNewLineMarkdownSupport", false);
|
|
28
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
29
|
+
this.options = options;
|
|
30
|
+
if (!this.options || !this.options.messages) {
|
|
31
|
+
this.options.messages = [];
|
|
32
|
+
}
|
|
33
|
+
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.pageTitle) {
|
|
34
|
+
this.pageTitle = this.options.pageTitle;
|
|
35
|
+
}
|
|
36
|
+
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.attachmentMessage) {
|
|
37
|
+
this.attachmentMessage = this.options.attachmentMessage;
|
|
38
|
+
}
|
|
39
|
+
if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.networkOnlineMessage) {
|
|
40
|
+
this.networkOnlineMessage = this.options.networkOnlineMessage;
|
|
41
|
+
}
|
|
42
|
+
if ((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.networkOfflineMessage) {
|
|
43
|
+
this.networkOfflineMessage = this.options.networkOfflineMessage;
|
|
44
|
+
}
|
|
45
|
+
if ((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.transcriptBackgroundColor) {
|
|
46
|
+
this.transcriptBackgroundColor = this.options.transcriptBackgroundColor;
|
|
47
|
+
}
|
|
48
|
+
if ((_this$options6 = this.options) !== null && _this$options6 !== void 0 && _this$options6.agentAvatarBackgroundColor) {
|
|
49
|
+
this.agentAvatarBackgroundColor = this.options.agentAvatarBackgroundColor;
|
|
50
|
+
}
|
|
51
|
+
if ((_this$options7 = this.options) !== null && _this$options7 !== void 0 && _this$options7.agentAvatarFontColor) {
|
|
52
|
+
this.agentAvatarFontColor = this.options.agentAvatarFontColor;
|
|
53
|
+
}
|
|
54
|
+
if ((_this$options8 = this.options) !== null && _this$options8 !== void 0 && _this$options8.customerAvatarBackgroundColor) {
|
|
55
|
+
this.customerAvatarBackgroundColor = this.options.customerAvatarBackgroundColor;
|
|
56
|
+
}
|
|
57
|
+
if ((_this$options9 = this.options) !== null && _this$options9 !== void 0 && _this$options9.customerAvatarFontColor) {
|
|
58
|
+
this.customerAvatarFontColor = this.options.customerAvatarFontColor;
|
|
59
|
+
}
|
|
60
|
+
if ((_this$options10 = this.options) !== null && _this$options10 !== void 0 && _this$options10.disableMarkdownMessageFormatting) {
|
|
61
|
+
this.disableMarkdownMessageFormatting = this.options.disableMarkdownMessageFormatting;
|
|
62
|
+
}
|
|
63
|
+
if ((_this$options11 = this.options) !== null && _this$options11 !== void 0 && _this$options11.disableNewLineMarkdownSupport) {
|
|
64
|
+
this.disableNewLineMarkdownSupport = this.options.disableNewLineMarkdownSupport;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
createTitleElement() {
|
|
68
|
+
const htmlData = `<title> ${this.pageTitle} </title>`;
|
|
69
|
+
return htmlData;
|
|
70
|
+
}
|
|
71
|
+
createExternalScriptElements() {
|
|
72
|
+
const htmlData = `
|
|
73
|
+
<script src="https://cdn.botframework.com/botframework-webchat/4.15.7/webchat.js"><\/script>
|
|
74
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/7.8.0/rxjs.umd.min.js" integrity="sha512-v0/YVjBcbjLN6scjmmJN+h86koeB7JhY4/2YeyA5l+rTdtKLv0VbDBNJ32rxJpsaW1QGMd1Z16lsLOSGI38Rbg==" crossorigin="anonymous" referrerpolicy="no-referrer"><\/script>
|
|
75
|
+
<script src="https://unpkg.com/react@18.2.0/umd/react.production.min.js"><\/script>
|
|
76
|
+
<script src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js"><\/script>
|
|
77
|
+
<script src="https://cdn.jsdelivr.net/npm/markdown-it@13.0.1/dist/markdown-it.min.js" integrity="sha256-hNyljag6giCsjv/yKmxK8/VeHzvMDvc5u8AzmRvm1BI=" crossorigin="anonymous"><\/script>
|
|
78
|
+
`;
|
|
79
|
+
return htmlData;
|
|
80
|
+
}
|
|
81
|
+
createHeadElement() {
|
|
82
|
+
const htmlData = `
|
|
83
|
+
<head>
|
|
84
|
+
${this.createTitleElement()}
|
|
85
|
+
${this.createExternalScriptElements()}
|
|
86
|
+
<script>
|
|
87
|
+
function shareObservable(observable) {
|
|
88
|
+
let observers = [];
|
|
89
|
+
let subscription;
|
|
90
|
+
|
|
91
|
+
return new Observable(observer => {
|
|
92
|
+
if (!subscription) {
|
|
93
|
+
subscription = observable.subscribe({
|
|
94
|
+
complete() {
|
|
95
|
+
observers.forEach(observer => observer.complete());
|
|
96
|
+
},
|
|
97
|
+
error(err) {
|
|
98
|
+
observers.forEach(observer => observer.error(err));
|
|
99
|
+
},
|
|
100
|
+
next(value) {
|
|
101
|
+
observers.forEach(observer => observer.next(value));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
observers.push(observer);
|
|
107
|
+
|
|
108
|
+
return () => {
|
|
109
|
+
observers = observers.filter(o => o !== observer);
|
|
110
|
+
|
|
111
|
+
if (!observers.length) {
|
|
112
|
+
subscription.unsubscribe();
|
|
113
|
+
subscription = null;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
<\/script>
|
|
119
|
+
<script>
|
|
120
|
+
const messages = ${JSON.stringify(this.options.messages)};
|
|
121
|
+
const disableMarkdownMessageFormatting = ${this.disableMarkdownMessageFormatting};
|
|
122
|
+
const disableNewLineMarkdownSupport = ${this.disableNewLineMarkdownSupport};
|
|
123
|
+
<\/script>
|
|
124
|
+
<script>
|
|
125
|
+
class Translator {
|
|
126
|
+
static convertTranscriptMessageToActivity(message) {
|
|
127
|
+
const {created, isControlMessage, content, tags, from, attachments, amsMetadata, amsReferences} = message;
|
|
128
|
+
const activity = {
|
|
129
|
+
from: {
|
|
130
|
+
role: 'bot'
|
|
131
|
+
},
|
|
132
|
+
type: 'message'
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// Ignore control messages
|
|
136
|
+
if (isControlMessage) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (tags) {
|
|
141
|
+
const formattedTags = tags.split(',');
|
|
142
|
+
|
|
143
|
+
// Ignore system message
|
|
144
|
+
if (formattedTags.includes('system')) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Ignore hidden message
|
|
149
|
+
if (formattedTags.includes('Hidden')) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Add C1 user display name
|
|
155
|
+
if (from && from.user && from.user.displayName) {
|
|
156
|
+
activity.from.name = from.user.displayName;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Add C2 user display name
|
|
160
|
+
if (from && from.application && from.application.displayName && from.application.displayName === 'Customer') {
|
|
161
|
+
activity.from = {
|
|
162
|
+
role: 'user',
|
|
163
|
+
name: from.application.displayName
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Attachments
|
|
168
|
+
if (amsReferences && amsMetadata) {
|
|
169
|
+
const metadata = JSON.parse(amsMetadata);
|
|
170
|
+
const { fileName } = metadata[0];
|
|
171
|
+
const text = \`${this.attachmentMessage}\${fileName}\`;
|
|
172
|
+
|
|
173
|
+
if (message.attachments && message.attachments.length > 0 && message.contentUrl) {
|
|
174
|
+
activity.attachments = message.attachments;
|
|
175
|
+
activity.attachments[0].contentUrl = message.contentUrl;
|
|
176
|
+
activity.attachments[0].thumbnailUrl = message.contentUrl;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
...activity,
|
|
181
|
+
text,
|
|
182
|
+
timestamp: created
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Message
|
|
187
|
+
if (content) {
|
|
188
|
+
// Adaptive card formatting
|
|
189
|
+
if (content.includes('"text"') && content.includes('"attachments"') && content.includes('"suggestedActions"')) {
|
|
190
|
+
try {
|
|
191
|
+
const partialActivity = JSON.parse(content);
|
|
192
|
+
return {
|
|
193
|
+
...activity,
|
|
194
|
+
...partialActivity,
|
|
195
|
+
timestamp: created
|
|
196
|
+
};
|
|
197
|
+
} catch {
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
...activity,
|
|
205
|
+
text: content,
|
|
206
|
+
timestamp: created
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
<\/script>
|
|
211
|
+
<script>
|
|
212
|
+
class TranscriptAdapter {
|
|
213
|
+
constructor() {
|
|
214
|
+
this.connectionStatus$ = new window.rxjs.BehaviorSubject(0); // Uninitialized
|
|
215
|
+
this.activity$ = shareObservable(new Observable((observer) => {
|
|
216
|
+
this.activityObserver = observer;
|
|
217
|
+
|
|
218
|
+
this.connectionStatus$.next(1); // Connecting
|
|
219
|
+
this.connectionStatus$.next(2); // Online
|
|
220
|
+
|
|
221
|
+
// Retrieve messages
|
|
222
|
+
if (messages) {
|
|
223
|
+
setTimeout(() => { // setTimeout is needed due to some WebChat issues
|
|
224
|
+
messages.map((message) => {
|
|
225
|
+
this.activityObserver.next({
|
|
226
|
+
...Translator.convertTranscriptMessageToActivity(message),
|
|
227
|
+
type: 'message'
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
}, 1);
|
|
231
|
+
}
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
<\/script>
|
|
236
|
+
<style>
|
|
237
|
+
body {
|
|
238
|
+
margin: 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.message-name {
|
|
242
|
+
font-family: Segoe UI,SegoeUI,Helvetica Neue,Helvetica,Arial,sans-serif;
|
|
243
|
+
font-weight: 700;
|
|
244
|
+
font-size: 10px;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.message-timestamp {
|
|
248
|
+
font-family: Segoe UI,SegoeUI,Helvetica Neue,Helvetica,Arial,sans-serif;
|
|
249
|
+
font-weight: 500;
|
|
250
|
+
font-size: 10px;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.avatar {
|
|
254
|
+
width: 40px;
|
|
255
|
+
height: 40px;
|
|
256
|
+
border-radius: 50%;
|
|
257
|
+
text-align: center;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.avatar--bot {
|
|
261
|
+
background-color: ${this.agentAvatarBackgroundColor};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.avatar--user {
|
|
265
|
+
background-color: ${this.customerAvatarBackgroundColor};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.avatar > p {
|
|
269
|
+
font-weight: 600;
|
|
270
|
+
text-align: center;
|
|
271
|
+
line-height: 0.5;
|
|
272
|
+
font-family: "Segoe UI", Arial, sans-serif;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.avatar--bot > p {
|
|
276
|
+
color: ${this.agentAvatarFontColor};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.avatar--user > p {
|
|
280
|
+
color: ${this.customerAvatarFontColor};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.webchat__bubble__content>div.ms_lcw_webchat_adaptive_card {
|
|
284
|
+
background-color: #FFF;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
div[class="ac-textBlock"] {
|
|
288
|
+
color: #000 !important;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.ms_lcw_webchat_received_message a:link, .ms_lcw_webchat_received_message a:visited, .ms_lcw_webchat_received_message a:hover, .ms_lcw_webchat_received_message a:active {
|
|
292
|
+
color: #FFF;
|
|
293
|
+
}
|
|
294
|
+
<\/style>
|
|
295
|
+
</head>
|
|
296
|
+
`;
|
|
297
|
+
return htmlData;
|
|
298
|
+
}
|
|
299
|
+
createBodyElement() {
|
|
300
|
+
const htmlData = `
|
|
301
|
+
<body>
|
|
302
|
+
<script>
|
|
303
|
+
if (!navigator.onLine) {
|
|
304
|
+
const offlineText = \`${this.networkOfflineMessage}\`;
|
|
305
|
+
document.body.innerHTML = offlineText;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
window.addEventListener("online", () => {
|
|
309
|
+
document.body.innerHTML = \`${this.networkOnlineMessage} <button onclick="window.location.reload()"> Refresh </button>\`;
|
|
310
|
+
});
|
|
311
|
+
<\/script>
|
|
312
|
+
<div id="transcript"></div>
|
|
313
|
+
<script>
|
|
314
|
+
const getIconText = (text) => {
|
|
315
|
+
if (text) {
|
|
316
|
+
const initials = text.split(/\\s/).reduce((response, word) => response += word.slice(0, 1), '');
|
|
317
|
+
if (initials.length > 1) {
|
|
318
|
+
return initials.substring(0, 2).toUpperCase();
|
|
319
|
+
} else {
|
|
320
|
+
return text.substring(0, 2).toUpperCase();
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return "";
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const activityMiddleware = () => (next) => (...args) => {
|
|
328
|
+
const [card] = args;
|
|
329
|
+
|
|
330
|
+
if (card.activity) {
|
|
331
|
+
if (card.activity.from && card.activity.from.role === "channel") {
|
|
332
|
+
return () => false;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Incoming text message
|
|
336
|
+
if (card.activity.text && card.activity.from && card.activity.from.role !== "user") {
|
|
337
|
+
return (...renderArgs) => (React.createElement(
|
|
338
|
+
'div',
|
|
339
|
+
{className: 'ms_lcw_webchat_received_message'},
|
|
340
|
+
next(...args)(...renderArgs)
|
|
341
|
+
))
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return next(...args);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const activityStatusMiddleware = () => (next) => (...args) => {
|
|
349
|
+
const [card] = args;
|
|
350
|
+
const {activity} = card;
|
|
351
|
+
|
|
352
|
+
if (activity) {
|
|
353
|
+
const {from, timestamp} = activity;
|
|
354
|
+
|
|
355
|
+
const nameElement = React.createElement(
|
|
356
|
+
'span',
|
|
357
|
+
{className: 'message-name'},
|
|
358
|
+
from.name
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
const formattedDate = new Date(timestamp);
|
|
362
|
+
const formattedTimeString = formattedDate.toLocaleTimeString("en-us", { year: "numeric", month:"numeric", day:"numeric", hour: "2-digit", minute: "2-digit"});
|
|
363
|
+
|
|
364
|
+
const timestampElement = React.createElement(
|
|
365
|
+
'span',
|
|
366
|
+
{className: 'message-timestamp'},
|
|
367
|
+
formattedTimeString
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
return from.name && timestamp && React.createElement('span', null, nameElement, ' - ', timestampElement)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return next(...args);
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
const avatarMiddleware = () => (next) => (...args) => {
|
|
377
|
+
const [card] = args;
|
|
378
|
+
const {fromUser, activity} = card;
|
|
379
|
+
const initials = getIconText(activity.from.name);
|
|
380
|
+
|
|
381
|
+
const avatarElement = React.createElement(
|
|
382
|
+
"div",
|
|
383
|
+
{className: fromUser? "avatar avatar--user": "avatar avatar--bot"},
|
|
384
|
+
React.createElement(
|
|
385
|
+
"p",
|
|
386
|
+
null,
|
|
387
|
+
\`\${initials}\`
|
|
388
|
+
)
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
return avatarElement;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const attachmentMiddleware = () => (next) => (...args) => {
|
|
395
|
+
const [card] = args;
|
|
396
|
+
const {activity} = card;
|
|
397
|
+
|
|
398
|
+
if (activity) {
|
|
399
|
+
const { activity: { attachments }, attachment } = card;
|
|
400
|
+
|
|
401
|
+
// No attachment
|
|
402
|
+
if (!attachments || !attachments.length || !attachment) {
|
|
403
|
+
return next(...args);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
let { content, contentType } = attachment || { content: "", contentType: "" };
|
|
407
|
+
|
|
408
|
+
// Adaptive card
|
|
409
|
+
if (contentType.startsWith("application/vnd.microsoft.card")) {
|
|
410
|
+
const adaptiveCardElement = React.createElement(
|
|
411
|
+
"div",
|
|
412
|
+
{className: 'ms_lcw_webchat_adaptive_card'},
|
|
413
|
+
next(...args)
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
return adaptiveCardElement;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return next(...args);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport) => {
|
|
424
|
+
let markdown;
|
|
425
|
+
if (!disableMarkdownMessageFormatting) {
|
|
426
|
+
markdown = new window.markdownit(
|
|
427
|
+
"default",
|
|
428
|
+
{
|
|
429
|
+
html: true,
|
|
430
|
+
linkify: true,
|
|
431
|
+
breaks: (!disableNewLineMarkdownSupport)
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
} else {
|
|
435
|
+
markdown = new window.markdownit(
|
|
436
|
+
"zero",
|
|
437
|
+
{
|
|
438
|
+
html: true,
|
|
439
|
+
linkify: true,
|
|
440
|
+
breaks: (!disableNewLineMarkdownSupport)
|
|
441
|
+
}
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
markdown.enable([
|
|
445
|
+
"entity",
|
|
446
|
+
"linkify",
|
|
447
|
+
"html_block",
|
|
448
|
+
"html_inline",
|
|
449
|
+
"newline"
|
|
450
|
+
]);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return markdown;
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
const markdown = createMarkdown(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
457
|
+
const renderMarkdown = (text) => {
|
|
458
|
+
const render = disableNewLineMarkdownSupport? markdown.renderInline.bind(markdown): markdown.render.bind(markdown);
|
|
459
|
+
text = render(text);
|
|
460
|
+
return text;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
const adapter = new TranscriptAdapter();
|
|
464
|
+
const styleOptions = {
|
|
465
|
+
hideSendBox: true,
|
|
466
|
+
backgroundColor: '${this.transcriptBackgroundColor}',
|
|
467
|
+
bubbleBackground: '${this.agentAvatarBackgroundColor}',
|
|
468
|
+
bubbleTextColor: '${this.agentAvatarFontColor}',
|
|
469
|
+
bubbleBorderRadius: 12,
|
|
470
|
+
bubbleNubSize: 1,
|
|
471
|
+
bubbleFromUserBackground: '${this.customerAvatarBackgroundColor}',
|
|
472
|
+
bubbleFromUserTextColor: '${this.customerAvatarFontColor}',
|
|
473
|
+
bubbleFromUserBorderRadius: 12,
|
|
474
|
+
bubbleFromUserNubSize: 1,
|
|
475
|
+
botAvatarInitials: 'C1',
|
|
476
|
+
userAvatarInitials: 'C2'
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
window.WebChat.renderWebChat({
|
|
480
|
+
directLine: adapter,
|
|
481
|
+
styleOptions,
|
|
482
|
+
activityMiddleware,
|
|
483
|
+
activityStatusMiddleware,
|
|
484
|
+
avatarMiddleware,
|
|
485
|
+
attachmentMiddleware,
|
|
486
|
+
renderMarkdown
|
|
487
|
+
},
|
|
488
|
+
document.getElementById('transcript'));
|
|
489
|
+
<\/script>
|
|
490
|
+
</body>
|
|
491
|
+
`;
|
|
492
|
+
return htmlData;
|
|
493
|
+
}
|
|
494
|
+
createHTML() {
|
|
495
|
+
const htmlData = `
|
|
496
|
+
<html>
|
|
497
|
+
${this.createHeadElement()}
|
|
498
|
+
${this.createBodyElement()}
|
|
499
|
+
</html>
|
|
500
|
+
`;
|
|
501
|
+
return htmlData;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const createChatTranscript = async function (transcript, chatSDK) {
|
|
505
|
+
let renderAttachments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
506
|
+
let transcriptOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
507
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
508
|
+
const transcriptMessages = JSON.parse(transcript);
|
|
509
|
+
const convertBlobToBase64 = async blob => {
|
|
510
|
+
return new Promise(resolve => {
|
|
511
|
+
const reader = new FileReader();
|
|
512
|
+
reader.onloadend = () => resolve(reader.result);
|
|
513
|
+
reader.readAsDataURL(blob);
|
|
514
|
+
});
|
|
515
|
+
};
|
|
516
|
+
let messages = transcriptMessages;
|
|
517
|
+
if (renderAttachments) {
|
|
518
|
+
messages = await Promise.all(transcriptMessages.map(async message => {
|
|
519
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
520
|
+
const {
|
|
521
|
+
amsReferences,
|
|
522
|
+
amsMetadata
|
|
523
|
+
} = message;
|
|
524
|
+
if (amsReferences && amsMetadata) {
|
|
525
|
+
const references = JSON.parse(amsReferences);
|
|
526
|
+
const metadata = JSON.parse(amsMetadata);
|
|
527
|
+
const fileMetadata = {
|
|
528
|
+
id: references[0],
|
|
529
|
+
type: metadata[0].contentType
|
|
530
|
+
};
|
|
531
|
+
const blob = await chatSDK.downloadFileAttachment(fileMetadata);
|
|
532
|
+
const base64 = await convertBlobToBase64(blob);
|
|
533
|
+
message.contentUrl = base64;
|
|
534
|
+
}
|
|
535
|
+
return message;
|
|
536
|
+
}));
|
|
537
|
+
}
|
|
538
|
+
const options = {
|
|
539
|
+
...transcriptOptions,
|
|
540
|
+
messages
|
|
541
|
+
};
|
|
542
|
+
const htmlBuilder = new TranscriptHTMLBuilder(options);
|
|
543
|
+
const text = htmlBuilder.createHTML();
|
|
544
|
+
const fileName = `${transcriptOptions.fileName || "transcript"}.html`;
|
|
545
|
+
(0, _utils.createFileAndDownload)(fileName, text, "text/html");
|
|
546
|
+
};
|
|
547
|
+
var _default = createChatTranscript;
|
|
548
|
+
exports.default = _default;
|
|
@@ -143,6 +143,7 @@ _defineProperty(HtmlAttributeNames, "listItem", "LI");
|
|
|
143
143
|
_defineProperty(HtmlAttributeNames, "unorderedList", "UL");
|
|
144
144
|
_defineProperty(HtmlAttributeNames, "div", "div");
|
|
145
145
|
_defineProperty(HtmlAttributeNames, "aTagName", "a");
|
|
146
|
+
_defineProperty(HtmlAttributeNames, "pTagName", "p");
|
|
146
147
|
_defineProperty(HtmlAttributeNames, "noopenerTag", "noopener");
|
|
147
148
|
_defineProperty(HtmlAttributeNames, "noreferrerTag", "noreferrer");
|
|
148
149
|
_defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
|