@microsoft/omnichannel-chat-widget 1.7.6 → 1.7.7-main.37d9c4a
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 +3 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +62 -19
- package/lib/cjs/common/utils.js +14 -2
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +4 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +27 -22
- package/lib/cjs/components/livechatwidget/interfaces/ISendBox.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +17 -13
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +10 -5
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +13 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +15 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +8 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +3 -1
- package/lib/esm/common/Constants.js +3 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +62 -19
- package/lib/esm/common/utils.js +11 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +4 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +28 -22
- package/lib/esm/components/livechatwidget/interfaces/ISendBox.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +17 -13
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +10 -5
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +15 -3
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +15 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +8 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +3 -1
- package/lib/types/common/Constants.d.ts +3 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +2 -0
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/createMarkdown.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/ISendBox.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.d.ts +1 -1
- package/package.json +2 -2
|
@@ -99,6 +99,8 @@ _defineProperty(Constants, "Zero", "zero");
|
|
|
99
99
|
_defineProperty(Constants, "Title", "title");
|
|
100
100
|
_defineProperty(Constants, "Target", "target");
|
|
101
101
|
_defineProperty(Constants, "Blank", "_blank");
|
|
102
|
+
_defineProperty(Constants, "TargetSelf", "_self");
|
|
103
|
+
_defineProperty(Constants, "TargetTop", "_top");
|
|
102
104
|
_defineProperty(Constants, "TargetRelationship", "rel");
|
|
103
105
|
_defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer");
|
|
104
106
|
// Markdown icons
|
|
@@ -130,6 +132,7 @@ class HtmlClassNames {}
|
|
|
130
132
|
exports.HtmlClassNames = HtmlClassNames;
|
|
131
133
|
_defineProperty(HtmlClassNames, "webChatBannerCloseButton", "webchat__toast__dismissButton");
|
|
132
134
|
_defineProperty(HtmlClassNames, "webChatBannerExpandButton", "webchat__toaster__expandIcon");
|
|
135
|
+
_defineProperty(HtmlClassNames, "webChatHistoryContainer", "webchat__basic-transcript");
|
|
133
136
|
class HtmlElementSelectors {}
|
|
134
137
|
exports.HtmlElementSelectors = HtmlElementSelectors;
|
|
135
138
|
_defineProperty(HtmlElementSelectors, "sendBoxSelector", "textarea[data-id=\"webchat-sendbox-input\"]");
|
|
@@ -64,32 +64,75 @@ class FacadeChatSDK {
|
|
|
64
64
|
|
|
65
65
|
// compare expiration time with current time
|
|
66
66
|
if (now > this.expiration) {
|
|
67
|
-
console.
|
|
67
|
+
console.error("Token is expired", now, this.expiration, now > this.expiration);
|
|
68
68
|
return true;
|
|
69
69
|
}
|
|
70
70
|
return false;
|
|
71
71
|
}
|
|
72
|
+
enforceBase64Encoding(payload) {
|
|
73
|
+
//base64url when present, switches the "-" and "_" characters with "+" and "/"
|
|
74
|
+
const base64Payload = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
75
|
+
// since base64 encoding requires padding, we need to add padding to the payload
|
|
76
|
+
return base64Payload.padEnd(base64Payload.length + (4 - base64Payload.length % 4) % 4, "=");
|
|
77
|
+
}
|
|
78
|
+
extractExpFromToken(token) {
|
|
79
|
+
const tokenParts = token.split(".");
|
|
80
|
+
const last3digits = token.slice(-3);
|
|
81
|
+
|
|
82
|
+
// token must have 3 parts as JWT format
|
|
83
|
+
if (tokenParts.length !== 3) {
|
|
84
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
85
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
86
|
+
Description: "Invalid token format",
|
|
87
|
+
ExceptionDetails: {
|
|
88
|
+
message: "Invalid token format, must be in JWT format",
|
|
89
|
+
token: last3digits
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
throw new Error("Invalid token format, must be in JWT format");
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const payload = this.enforceBase64Encoding(tokenParts[1]);
|
|
96
|
+
// decode payload
|
|
97
|
+
const decodedPayload = atob(payload);
|
|
98
|
+
const jsonPayload = JSON.parse(decodedPayload);
|
|
99
|
+
// check if exp is present in payload
|
|
100
|
+
if (jsonPayload) {
|
|
101
|
+
if (jsonPayload.exp) {
|
|
102
|
+
return jsonPayload.exp;
|
|
103
|
+
}
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
107
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
108
|
+
Description: "Invalid token payload",
|
|
109
|
+
ExceptionDetails: {
|
|
110
|
+
message: "Token payload is not valid JSON",
|
|
111
|
+
token: last3digits
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
throw new Error("Invalid token payload, payload is not valid JSON");
|
|
115
|
+
} catch (e) {
|
|
116
|
+
console.error("Failed to decode token", e);
|
|
117
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
118
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
119
|
+
Description: "Failed to decode token",
|
|
120
|
+
ExceptionDetails: {
|
|
121
|
+
message: "Failed to decode token",
|
|
122
|
+
token: last3digits
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
throw new Error("Failed to decode token");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
72
128
|
async setToken(token) {
|
|
73
129
|
// token must be not null, and must be new
|
|
74
130
|
if (!(0, _utils.isNullOrEmptyString)(token) && token !== this.token) {
|
|
75
|
-
|
|
131
|
+
const last3digits = token.slice(-3);
|
|
76
132
|
const instant = Math.floor(Date.now() / 1000);
|
|
77
133
|
this.token = token;
|
|
78
|
-
// decompose token
|
|
79
|
-
const tokenParts = (_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.split(".");
|
|
80
|
-
if (!tokenParts || tokenParts.length <= 1) {
|
|
81
|
-
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
82
|
-
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
83
|
-
Description: "Invalid token format",
|
|
84
|
-
ExceptionDetails: "Token must be in JWT format"
|
|
85
|
-
});
|
|
86
|
-
throw new Error("Invalid token format, must be in JWT format");
|
|
87
|
-
}
|
|
88
|
-
// decode token
|
|
89
|
-
const tokenDecoded = JSON.parse(atob(tokenParts[1]));
|
|
90
134
|
// calculate expiration time
|
|
91
|
-
this.expiration = this.convertExpiration(
|
|
92
|
-
|
|
135
|
+
this.expiration = this.convertExpiration(this.extractExpFromToken(token) || 0);
|
|
93
136
|
// this is a control , in case the getAuthToken function returns same token
|
|
94
137
|
if (this.expiration > 0 && this.expiration < instant) {
|
|
95
138
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -97,10 +140,11 @@ class FacadeChatSDK {
|
|
|
97
140
|
Description: "New token is already expired",
|
|
98
141
|
ExceptionDetails: {
|
|
99
142
|
"Instant": instant,
|
|
100
|
-
"Expiration": this.expiration
|
|
143
|
+
"Expiration": this.expiration,
|
|
144
|
+
"Token": last3digits
|
|
101
145
|
}
|
|
102
146
|
});
|
|
103
|
-
throw new Error(
|
|
147
|
+
throw new Error(`New token is already expired, with epoch time ${this.expiration} , last 3 digits of token: ${last3digits}`);
|
|
104
148
|
}
|
|
105
149
|
}
|
|
106
150
|
}
|
|
@@ -164,7 +208,6 @@ class FacadeChatSDK {
|
|
|
164
208
|
};
|
|
165
209
|
} else {
|
|
166
210
|
var _ring$error, _ring$error2;
|
|
167
|
-
console.error("Failed to get token", ring);
|
|
168
211
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
169
212
|
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
170
213
|
Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
|
+
exports.getDeviceType = getDeviceType;
|
|
8
|
+
exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = void 0;
|
|
7
9
|
var _Constants = require("./Constants");
|
|
8
10
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
9
11
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -479,4 +481,14 @@ const setOcUserAgent = chatSDK => {
|
|
|
479
481
|
}
|
|
480
482
|
}
|
|
481
483
|
};
|
|
482
|
-
exports.setOcUserAgent = setOcUserAgent;
|
|
484
|
+
exports.setOcUserAgent = setOcUserAgent;
|
|
485
|
+
function getDeviceType() {
|
|
486
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
487
|
+
if (/android/.test(userAgent)) {
|
|
488
|
+
return "android";
|
|
489
|
+
} else if (/iphone|ipad|ipod/.test(userAgent)) {
|
|
490
|
+
return "ios";
|
|
491
|
+
} else {
|
|
492
|
+
return "standard";
|
|
493
|
+
}
|
|
494
|
+
}
|
package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -14,6 +14,8 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
|
|
|
14
14
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
15
15
|
var _createChatTranscript = _interopRequireDefault(require("../../../plugins/createChatTranscript"));
|
|
16
16
|
var _createReducer = require("../../../contexts/createReducer");
|
|
17
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
18
|
+
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
17
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
20
|
const processDisplayName = displayName => {
|
|
19
21
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
@@ -168,11 +170,24 @@ const downloadTranscript = async (facadeChatSDK, downloadTranscriptProps, state)
|
|
|
168
170
|
// Need to keep existing live chat context for scenarios when transcript is downloaded after endchat
|
|
169
171
|
let liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
|
|
170
172
|
if (!liveChatContext) {
|
|
173
|
+
var _inMemoryState$appSta;
|
|
171
174
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
172
175
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
173
176
|
payload: null
|
|
174
177
|
});
|
|
175
178
|
liveChatContext = inMemoryState.domainStates.liveChatContext;
|
|
179
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) !== _ConversationState.ConversationState.Active && !liveChatContext) {
|
|
180
|
+
var _state$domainStates2;
|
|
181
|
+
const chatToken = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.chatToken) || inMemoryState.domainStates.chatToken;
|
|
182
|
+
if (chatToken && Object.keys(chatToken).length > 0) {
|
|
183
|
+
liveChatContext = {
|
|
184
|
+
chatToken: chatToken,
|
|
185
|
+
requestId: chatToken.requestId || (0, _omnichannelChatSdk.uuidv4)()
|
|
186
|
+
};
|
|
187
|
+
} else {
|
|
188
|
+
liveChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getCurrentLiveChatContext());
|
|
189
|
+
}
|
|
190
|
+
}
|
|
176
191
|
}
|
|
177
192
|
let data = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getLiveChatTranscript({
|
|
178
193
|
liveChatContext
|
|
@@ -11,7 +11,7 @@ var _defaultMarkdownLocalizedTexts = require("../../webchatcontainerstateful/com
|
|
|
11
11
|
var _markdownHelper = require("./helpers/markdownHelper");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport) => {
|
|
14
|
+
const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport, opensMarkdownLinksInSameTab) => {
|
|
15
15
|
let markdown;
|
|
16
16
|
if (!disableMarkdownMessageFormatting) {
|
|
17
17
|
markdown = new _markdownIt.default(_Constants.Constants.Default, {
|
|
@@ -45,10 +45,11 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
|
|
|
45
45
|
const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target);
|
|
46
46
|
// Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
47
47
|
const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
48
|
+
const targetValue = opensMarkdownLinksInSameTab ? _Constants.Constants.TargetTop : _Constants.Constants.Blank;
|
|
48
49
|
if (~targetAttrIndex) {
|
|
49
|
-
tokens[idx].attrs[targetAttrIndex][1] =
|
|
50
|
+
tokens[idx].attrs[targetAttrIndex][1] = targetValue;
|
|
50
51
|
} else {
|
|
51
|
-
tokens[idx].attrPush([_Constants.Constants.Target,
|
|
52
|
+
tokens[idx].attrPush([_Constants.Constants.Target, targetValue]);
|
|
52
53
|
}
|
|
53
54
|
const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
|
|
54
55
|
if (~relAttrIndex) {
|
|
@@ -40,7 +40,7 @@ var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatconta
|
|
|
40
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
42
|
const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
|
|
43
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$
|
|
43
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _defaultWebChatContai, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai2, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai3, _props$webChatContain25, _props$webChatContain26;
|
|
44
44
|
// Add a hook to make all links open a new window
|
|
45
45
|
postDomPurifyActivities();
|
|
46
46
|
const localizedTexts = {
|
|
@@ -50,12 +50,14 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
50
50
|
const hyperlinkTextOverride = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hyperlinkTextOverride) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.hyperlinkTextOverride;
|
|
51
51
|
const disableNewLineMarkdownSupport = ((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableNewLineMarkdownSupport) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
|
|
52
52
|
const disableMarkdownMessageFormatting = ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.disableMarkdownMessageFormatting) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting;
|
|
53
|
+
const opensMarkdownLinksInSameTab = (_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.opensMarkdownLinksInSameTab;
|
|
54
|
+
const honorsTargetInHTMLLinks = (_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.honorsTargetInHTMLLinks;
|
|
53
55
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
54
|
-
const markdown = (0, _createMarkdown.createMarkdown)(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
56
|
+
const markdown = (0, _createMarkdown.createMarkdown)(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport, opensMarkdownLinksInSameTab);
|
|
55
57
|
// Initialize Web Chat's redux store
|
|
56
58
|
let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
|
|
57
59
|
if (!webChatStore) {
|
|
58
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$
|
|
60
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
|
|
59
61
|
const conversationEndCallback = async () => {
|
|
60
62
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
63
|
const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
|
|
@@ -87,18 +89,18 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
87
89
|
};
|
|
88
90
|
webChatStore = (0, _botframeworkWebchat.createStore)({},
|
|
89
91
|
//initial state
|
|
90
|
-
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
|
|
92
|
+
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
|
|
91
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
...(((_props$
|
|
94
|
+
...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
|
|
93
95
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
94
96
|
}
|
|
95
97
|
const hyperlinkTextOverrideRenderer = new _HyperlinkTextOverrideRenderer.default(hyperlinkTextOverride);
|
|
96
98
|
const markdownRenderers = [hyperlinkTextOverrideRenderer];
|
|
97
99
|
const renderMarkdown = text => {
|
|
98
|
-
var _props$
|
|
99
|
-
if ((_props$
|
|
100
|
-
var _props$
|
|
101
|
-
text = (_props$
|
|
100
|
+
var _props$webChatContain8, _props$webChatContain9;
|
|
101
|
+
if ((_props$webChatContain8 = props.webChatContainerProps) !== null && _props$webChatContain8 !== void 0 && (_props$webChatContain9 = _props$webChatContain8.webChatProps) !== null && _props$webChatContain9 !== void 0 && _props$webChatContain9.renderMarkdown) {
|
|
102
|
+
var _props$webChatContain10;
|
|
103
|
+
text = (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatProps.renderMarkdown(text);
|
|
102
104
|
} else {
|
|
103
105
|
const render = disableMarkdownMessageFormatting ? markdown.renderInline.bind(markdown) : markdown.render.bind(markdown);
|
|
104
106
|
text = render(text);
|
|
@@ -108,16 +110,19 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
108
110
|
});
|
|
109
111
|
const config = {
|
|
110
112
|
FORBID_TAGS: ["form", "button", "script", "div", "input"],
|
|
111
|
-
FORBID_ATTR: ["action"]
|
|
113
|
+
FORBID_ATTR: ["action"],
|
|
114
|
+
ADD_ATTR: ["target"]
|
|
112
115
|
};
|
|
113
116
|
text = _dompurify.default.sanitize(text, config);
|
|
114
117
|
return text;
|
|
115
118
|
};
|
|
116
119
|
function postDomPurifyActivities() {
|
|
117
120
|
_dompurify.default.addHook("afterSanitizeAttributes", function (node) {
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
node.setAttribute(
|
|
121
|
+
const target = node.getAttribute(_Constants.Constants.Target);
|
|
122
|
+
if (target === _Constants.Constants.TargetSelf) {
|
|
123
|
+
node.setAttribute(_Constants.Constants.Target, _Constants.Constants.TargetTop);
|
|
124
|
+
} else if (!target) {
|
|
125
|
+
node.setAttribute(_Constants.Constants.Target, _Constants.Constants.Blank);
|
|
121
126
|
}
|
|
122
127
|
});
|
|
123
128
|
}
|
|
@@ -127,18 +132,18 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
127
132
|
dir: state.domainStates.globalDir,
|
|
128
133
|
locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
|
|
129
134
|
store: webChatStore,
|
|
130
|
-
activityMiddleware: (_props$
|
|
131
|
-
attachmentMiddleware: (_props$
|
|
132
|
-
activityStatusMiddleware: (_props$
|
|
133
|
-
toastMiddleware: (_props$
|
|
135
|
+
activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : (0, _activityMiddleware.createActivityMiddleware)(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
|
|
136
|
+
attachmentMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableAttachmentMiddleware ? undefined : (0, _attachmentMiddleware.createAttachmentMiddleware)(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? _defaultAttachmentProps.defaultAttachmentProps.enableInlinePlaying),
|
|
137
|
+
activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
|
|
138
|
+
toastMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableToastMiddleware ? undefined : (0, _toastMiddleware.createToastMiddleware)(props.notificationPaneProps, endChat),
|
|
134
139
|
renderMarkdown,
|
|
135
|
-
avatarMiddleware: (_props$
|
|
136
|
-
groupActivitiesMiddleware: (_props$
|
|
137
|
-
typingIndicatorMiddleware: (_props$
|
|
140
|
+
avatarMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableAvatarMiddleware ? undefined : (0, _avatarMiddleware.createAvatarMiddleware)((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
|
|
141
|
+
groupActivitiesMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
142
|
+
typingIndicatorMiddleware: (_props$webChatContain23 = props.webChatContainerProps) !== null && _props$webChatContain23 !== void 0 && (_props$webChatContain24 = _props$webChatContain23.renderingMiddlewareProps) !== null && _props$webChatContain24 !== void 0 && _props$webChatContain24.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
138
143
|
onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
|
|
139
|
-
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$
|
|
144
|
+
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain25 = props.webChatContainerProps) === null || _props$webChatContain25 === void 0 ? void 0 : _props$webChatContain25.botMagicCode) || undefined),
|
|
140
145
|
sendTypingIndicator: true,
|
|
141
|
-
...((_props$
|
|
146
|
+
...((_props$webChatContain26 = props.webChatContainerProps) === null || _props$webChatContain26 === void 0 ? void 0 : _props$webChatContain26.webChatProps)
|
|
142
147
|
};
|
|
143
148
|
return webChatProps;
|
|
144
149
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -64,7 +64,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
64
64
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
65
65
|
let uiTimer;
|
|
66
66
|
const LiveChatWidgetStateful = props => {
|
|
67
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$
|
|
67
|
+
var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
68
68
|
(0, _react2.useEffect)(() => {
|
|
69
69
|
uiTimer = (0, _utils.createTimer)();
|
|
70
70
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -94,6 +94,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
94
94
|
|
|
95
95
|
//Scrollbar styles
|
|
96
96
|
const scrollbarProps = Object.assign({}, _defaultScrollBarProps.defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
|
|
97
|
+
const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.sendBoxTextBox) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.textarea;
|
|
97
98
|
|
|
98
99
|
// In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
|
|
99
100
|
if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
|
|
@@ -613,8 +614,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
613
614
|
});
|
|
614
615
|
}
|
|
615
616
|
if (state.appStates.conversationState === _ConversationState.ConversationState.InActive) {
|
|
616
|
-
var _props$
|
|
617
|
-
if ((props === null || props === void 0 ? void 0 : (_props$
|
|
617
|
+
var _props$webChatContain4, _props$webChatContain5;
|
|
618
|
+
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
|
|
618
619
|
setWebChatStyles(styles => {
|
|
619
620
|
return {
|
|
620
621
|
...styles,
|
|
@@ -658,12 +659,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
658
659
|
}
|
|
659
660
|
}, [state.appStates.unreadMessageCount]);
|
|
660
661
|
(0, _react2.useEffect)(() => {
|
|
661
|
-
var _props$
|
|
662
|
+
var _props$webChatContain6;
|
|
662
663
|
setWebChatStyles({
|
|
663
664
|
...webChatStyles,
|
|
664
|
-
...((_props$
|
|
665
|
+
...((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.webChatStyles)
|
|
665
666
|
});
|
|
666
|
-
}, [(_props$
|
|
667
|
+
}, [(_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.webChatStyles]);
|
|
667
668
|
(0, _react2.useEffect)(() => {
|
|
668
669
|
//Confirmation pane dismissing through OK option, so proceed with end chat
|
|
669
670
|
if (state.domainStates.confirmationState === _Constants.ConfirmationState.Ok) {
|
|
@@ -762,12 +763,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
762
763
|
|
|
763
764
|
// if props state gets updates we need to update the renderingMiddlewareProps in the state
|
|
764
765
|
(0, _react2.useEffect)(() => {
|
|
765
|
-
var _props$
|
|
766
|
+
var _props$webChatContain8;
|
|
766
767
|
dispatch({
|
|
767
768
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
|
|
768
|
-
payload: (_props$
|
|
769
|
+
payload: (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.renderingMiddlewareProps
|
|
769
770
|
});
|
|
770
|
-
}, [(_props$
|
|
771
|
+
}, [(_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.renderingMiddlewareProps]);
|
|
771
772
|
(0, _react2.useEffect)(() => {
|
|
772
773
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
773
774
|
Event: _TelemetryConstants.TelemetryEvent.UXLivechatwidgetCompleted,
|
|
@@ -809,7 +810,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
809
810
|
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, state, dispatch, facadeChatSDK, endChatRelay);
|
|
810
811
|
const downloadTranscriptProps = (0, _createDownloadTranscriptProps.default)(props.downloadTranscriptProps, {
|
|
811
812
|
...(_defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === null || _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === void 0 ? void 0 : _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles),
|
|
812
|
-
...((_props$
|
|
813
|
+
...((_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatStyles)
|
|
813
814
|
}, props.webChatContainerProps);
|
|
814
815
|
const livechatProps = {
|
|
815
816
|
...props,
|
|
@@ -867,13 +868,16 @@ const LiveChatWidgetStateful = props => {
|
|
|
867
868
|
height: .75em;
|
|
868
869
|
margin-left: .25em;
|
|
869
870
|
}
|
|
870
|
-
|
|
871
|
+
${(sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight) && `
|
|
872
|
+
textarea.webchat__send-box-text-box__html-text-area {
|
|
873
|
+
min-height: ${sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight};
|
|
874
|
+
}`}
|
|
871
875
|
`), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
872
876
|
userID: userID,
|
|
873
877
|
styleOptions: {
|
|
874
878
|
...webChatStyles,
|
|
875
|
-
bubbleBackground: ((_props$
|
|
876
|
-
bubbleTextColor: ((_props$
|
|
879
|
+
bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.adaptiveCardStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background,
|
|
880
|
+
bubbleTextColor: ((_props$webChatContain13 = props.webChatContainerProps) === null || _props$webChatContain13 === void 0 ? void 0 : (_props$webChatContain14 = _props$webChatContain13.adaptiveCardStyles) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color
|
|
877
881
|
},
|
|
878
882
|
directLine: directLine
|
|
879
883
|
}), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
@@ -145,11 +145,6 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
// Move focus to the first button
|
|
149
|
-
const firstElement = (0, _utils.findAllFocusableElement)(`#${controlProps.id}`);
|
|
150
|
-
if (firstElement && firstElement[0]) {
|
|
151
|
-
firstElement[0].focus();
|
|
152
|
-
}
|
|
153
148
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
154
149
|
Event: _TelemetryConstants.TelemetryEvent.PrechatSurveyLoaded
|
|
155
150
|
});
|
|
@@ -158,6 +153,16 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
158
153
|
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
159
154
|
});
|
|
160
155
|
}, []);
|
|
156
|
+
|
|
157
|
+
// Set focus to the first element
|
|
158
|
+
(0, _react.useEffect)(() => {
|
|
159
|
+
if (!state.appStates.isMinimized) {
|
|
160
|
+
const firstElement = (0, _utils.findAllFocusableElement)(`#${controlProps.id}`);
|
|
161
|
+
if (firstElement && firstElement[0]) {
|
|
162
|
+
firstElement[0].focus();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, [state.appStates.isMinimized]);
|
|
161
166
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.PreChatSurveyPane, {
|
|
162
167
|
controlProps: controlProps,
|
|
163
168
|
styleProps: styleProps
|
|
@@ -83,7 +83,12 @@ const WebChatContainerStateful = props => {
|
|
|
83
83
|
};
|
|
84
84
|
(0, _react2.useEffect)(() => {
|
|
85
85
|
var _props$webChatContain, _props$webChatContain2;
|
|
86
|
-
(0, _utils.
|
|
86
|
+
if ((0, _utils.getDeviceType)() !== "standard" && (webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.webChatHistoryMobileAccessibilityLabel) !== undefined) {
|
|
87
|
+
const chatHistoryElement = document.querySelector(`.${_Constants.HtmlClassNames.webChatHistoryContainer}`);
|
|
88
|
+
if (chatHistoryElement) {
|
|
89
|
+
chatHistoryElement.setAttribute(_Constants.HtmlAttributeNames.ariaLabel, webChatContainerProps.webChatHistoryMobileAccessibilityLabel);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
87
92
|
dispatch({
|
|
88
93
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
|
|
89
94
|
payload: webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : webChatContainerProps.renderingMiddlewareProps
|
|
@@ -164,6 +169,13 @@ const WebChatContainerStateful = props => {
|
|
|
164
169
|
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
165
170
|
});
|
|
166
171
|
}, []);
|
|
172
|
+
|
|
173
|
+
// Set focus to the sendbox
|
|
174
|
+
(0, _react2.useEffect)(() => {
|
|
175
|
+
if (!state.appStates.isMinimized) {
|
|
176
|
+
(0, _utils.setFocusOnSendBox)();
|
|
177
|
+
}
|
|
178
|
+
}, [state.appStates.isMinimized]);
|
|
167
179
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
168
180
|
.webchat__stacked-layout__content .ac-pushButton {
|
|
169
181
|
cursor: pointer;
|
|
@@ -16,6 +16,8 @@ const defaultWebChatContainerStatefulProps = {
|
|
|
16
16
|
containerStyles: _defaultWebChatStatefulContainerStyles.defaultWebChatStatefulContainerStyles,
|
|
17
17
|
disableNewLineMarkdownSupport: false,
|
|
18
18
|
disableMarkdownMessageFormatting: false,
|
|
19
|
+
opensMarkdownLinksInSameTab: false,
|
|
20
|
+
honorsTargetInHTMLLinks: false,
|
|
19
21
|
hyperlinkTextOverride: false,
|
|
20
22
|
directLine: new _mockadapter.default(),
|
|
21
23
|
adaptiveCardStyles: _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles
|
|
@@ -18,7 +18,9 @@ class HyperlinkTextOverrideRenderer {
|
|
|
18
18
|
convertTextToHtmlNode(text) {
|
|
19
19
|
const htmlNode = document.createElement(_Constants.HtmlAttributeNames.div);
|
|
20
20
|
try {
|
|
21
|
-
text = _dompurify.default.sanitize(text
|
|
21
|
+
text = _dompurify.default.sanitize(text, {
|
|
22
|
+
ADD_ATTR: ["target"]
|
|
23
|
+
});
|
|
22
24
|
htmlNode.innerHTML = text;
|
|
23
25
|
} catch {
|
|
24
26
|
return htmlNode;
|
|
@@ -31,15 +31,28 @@ const DeliveredTimestamp = _ref => {
|
|
|
31
31
|
timestamp
|
|
32
32
|
}
|
|
33
33
|
} = args;
|
|
34
|
+
const getTimeElement = timestamp => {
|
|
35
|
+
const timeString = (0, _utils.getTimestampHourMinute)(timestamp);
|
|
36
|
+
const isAmPmFormat = timeString.toLowerCase().includes("am") || timeString.toLowerCase().includes("pm");
|
|
37
|
+
|
|
38
|
+
// For clients that use languages that are written right-to-left, but still use AM/PM time format, we need to
|
|
39
|
+
// make sure the "rtl" direction doesn't produce "PM 1:23", but remains "1:23 PM"
|
|
40
|
+
if (dir === "rtl" && isAmPmFormat) {
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
42
|
+
dir: "ltr"
|
|
43
|
+
}, (0, _utils.getTimestampHourMinute)(timestamp));
|
|
44
|
+
}
|
|
45
|
+
return timeString;
|
|
46
|
+
};
|
|
34
47
|
return /*#__PURE__*/_react.default.createElement(_react2.Stack, {
|
|
35
48
|
style: contentStyles,
|
|
36
49
|
dir: dir
|
|
37
50
|
}, role === _DirectLineSenderRole.DirectLineSenderRole.Bot && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
38
51
|
dir: dir,
|
|
39
52
|
"aria-hidden": "false"
|
|
40
|
-
}, name, " - ", (
|
|
53
|
+
}, name, " - ", getTimeElement(timestamp))), role === _DirectLineSenderRole.DirectLineSenderRole.User && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
41
54
|
"aria-hidden": "false",
|
|
42
55
|
dir: dir
|
|
43
|
-
}, " ", (
|
|
56
|
+
}, " ", getTimeElement(timestamp), " - ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_DELIVERED) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_DELIVERED)));
|
|
44
57
|
};
|
|
45
58
|
exports.DeliveredTimestamp = DeliveredTimestamp;
|
|
@@ -22,8 +22,9 @@ const convertTextToHtmlNode = text => {
|
|
|
22
22
|
if (!text) return "";
|
|
23
23
|
const element = document.createElement(_Constants.HtmlAttributeNames.div);
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
text = _dompurify.default.sanitize(text, {
|
|
26
|
+
ADD_ATTR: ["target"]
|
|
27
|
+
});
|
|
27
28
|
element.innerHTML = text;
|
|
28
29
|
} catch (e) {
|
|
29
30
|
const errorMessage = `Failed to purify and set innertHTML with text: ${text}`;
|
|
@@ -39,7 +40,7 @@ const convertTextToHtmlNode = text => {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
const processHTMLText = (action, text) => {
|
|
43
|
+
const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
43
44
|
const htmlNode = convertTextToHtmlNode(text);
|
|
44
45
|
const aNodes = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
|
|
45
46
|
if ((aNodes === null || aNodes === void 0 ? void 0 : aNodes.length) > 0) {
|
|
@@ -52,8 +53,8 @@ const processHTMLText = (action, text) => {
|
|
|
52
53
|
continue;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
// Add target to 'a' node if target is missing or
|
|
56
|
-
if (!aNode.target ||
|
|
56
|
+
// Add target to 'a' node if target is missing or if honorsTargetInHTMLLinks is false
|
|
57
|
+
if (!aNode.target || !honorsTargetInHTMLLinks) {
|
|
57
58
|
aNode.target = _Constants.Constants.blank;
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -92,7 +93,7 @@ const processHTMLText = (action, text) => {
|
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
95
|
-
const htmlTextMiddleware = _ref => {
|
|
96
|
+
const htmlTextMiddleware = honorsTargetInHTMLLinks => _ref => {
|
|
96
97
|
let {
|
|
97
98
|
dispatch
|
|
98
99
|
} = _ref;
|
|
@@ -102,7 +103,7 @@ const htmlTextMiddleware = _ref => {
|
|
|
102
103
|
var _action$payload, _action$payload$activ;
|
|
103
104
|
const text = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$activ = _action$payload.activity) === null || _action$payload$activ === void 0 ? void 0 : _action$payload$activ.text;
|
|
104
105
|
if (text) {
|
|
105
|
-
action = processHTMLText(action, text);
|
|
106
|
+
action = processHTMLText(action, text, honorsTargetInHTMLLinks ?? false);
|
|
106
107
|
}
|
|
107
108
|
} catch (e) {
|
|
108
109
|
let errorMessage = "Failed to validate action.";
|
|
@@ -26,7 +26,9 @@ const sanitizationMiddleware = _ref => {
|
|
|
26
26
|
var _action$payload;
|
|
27
27
|
let text = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.text;
|
|
28
28
|
if (text) {
|
|
29
|
-
text = _dompurify.default.sanitize(text
|
|
29
|
+
text = _dompurify.default.sanitize(text, {
|
|
30
|
+
ADD_ATTR: ["target"]
|
|
31
|
+
}) ?? " ";
|
|
30
32
|
}
|
|
31
33
|
} catch (e) {
|
|
32
34
|
const copyDataForTelemetry = {
|