@microsoft/omnichannel-chat-widget 1.7.7-main.65ecd48 → 1.7.7-main.863787d
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 +0 -2
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +22 -27
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +0 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -15
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +7 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +1 -3
- package/lib/esm/common/Constants.js +0 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -4
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +22 -28
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +0 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -15
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +7 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +1 -3
- package/lib/types/common/Constants.d.ts +0 -2
- package/lib/types/components/livechatwidget/common/createMarkdown.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +0 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.d.ts +1 -1
- package/package.json +1 -1
|
@@ -99,8 +99,6 @@ _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");
|
|
104
102
|
_defineProperty(Constants, "TargetRelationship", "rel");
|
|
105
103
|
_defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer");
|
|
106
104
|
// Markdown icons
|
|
@@ -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) => {
|
|
15
15
|
let markdown;
|
|
16
16
|
if (!disableMarkdownMessageFormatting) {
|
|
17
17
|
markdown = new _markdownIt.default(_Constants.Constants.Default, {
|
|
@@ -45,11 +45,10 @@ 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;
|
|
49
48
|
if (~targetAttrIndex) {
|
|
50
|
-
tokens[idx].attrs[targetAttrIndex][1] =
|
|
49
|
+
tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
|
|
51
50
|
} else {
|
|
52
|
-
tokens[idx].attrPush([_Constants.Constants.Target,
|
|
51
|
+
tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
|
|
53
52
|
}
|
|
54
53
|
const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
|
|
55
54
|
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,
|
|
43
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai2, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai3, _props$webChatContain23, _props$webChatContain24;
|
|
44
44
|
// Add a hook to make all links open a new window
|
|
45
45
|
postDomPurifyActivities();
|
|
46
46
|
const localizedTexts = {
|
|
@@ -50,14 +50,12 @@ 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;
|
|
55
53
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
56
|
-
const markdown = (0, _createMarkdown.createMarkdown)(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport
|
|
54
|
+
const markdown = (0, _createMarkdown.createMarkdown)(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
57
55
|
// Initialize Web Chat's redux store
|
|
58
56
|
let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
|
|
59
57
|
if (!webChatStore) {
|
|
60
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$
|
|
58
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
61
59
|
const conversationEndCallback = async () => {
|
|
62
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
61
|
const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
|
|
@@ -89,18 +87,18 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
89
87
|
};
|
|
90
88
|
webChatStore = (0, _botframeworkWebchat.createStore)({},
|
|
91
89
|
//initial state
|
|
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,
|
|
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,
|
|
93
91
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
-
...(((_props$
|
|
92
|
+
...(((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.storeMiddlewares) ?? []));
|
|
95
93
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
96
94
|
}
|
|
97
95
|
const hyperlinkTextOverrideRenderer = new _HyperlinkTextOverrideRenderer.default(hyperlinkTextOverride);
|
|
98
96
|
const markdownRenderers = [hyperlinkTextOverrideRenderer];
|
|
99
97
|
const renderMarkdown = text => {
|
|
100
|
-
var _props$
|
|
101
|
-
if ((_props$
|
|
102
|
-
var _props$
|
|
103
|
-
text = (_props$
|
|
98
|
+
var _props$webChatContain6, _props$webChatContain7;
|
|
99
|
+
if ((_props$webChatContain6 = props.webChatContainerProps) !== null && _props$webChatContain6 !== void 0 && (_props$webChatContain7 = _props$webChatContain6.webChatProps) !== null && _props$webChatContain7 !== void 0 && _props$webChatContain7.renderMarkdown) {
|
|
100
|
+
var _props$webChatContain8;
|
|
101
|
+
text = (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatProps.renderMarkdown(text);
|
|
104
102
|
} else {
|
|
105
103
|
const render = disableMarkdownMessageFormatting ? markdown.renderInline.bind(markdown) : markdown.render.bind(markdown);
|
|
106
104
|
text = render(text);
|
|
@@ -110,19 +108,16 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
110
108
|
});
|
|
111
109
|
const config = {
|
|
112
110
|
FORBID_TAGS: ["form", "button", "script", "div", "input"],
|
|
113
|
-
FORBID_ATTR: ["action"]
|
|
114
|
-
ADD_ATTR: ["target"]
|
|
111
|
+
FORBID_ATTR: ["action"]
|
|
115
112
|
};
|
|
116
113
|
text = _dompurify.default.sanitize(text, config);
|
|
117
114
|
return text;
|
|
118
115
|
};
|
|
119
116
|
function postDomPurifyActivities() {
|
|
120
117
|
_dompurify.default.addHook("afterSanitizeAttributes", function (node) {
|
|
121
|
-
|
|
122
|
-
if (target
|
|
123
|
-
node.setAttribute(
|
|
124
|
-
} else if (!target) {
|
|
125
|
-
node.setAttribute(_Constants.Constants.Target, _Constants.Constants.Blank);
|
|
118
|
+
// set all elements owning target to target=_blank
|
|
119
|
+
if ("target" in node) {
|
|
120
|
+
node.setAttribute("target", "_blank");
|
|
126
121
|
}
|
|
127
122
|
});
|
|
128
123
|
}
|
|
@@ -132,18 +127,18 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
132
127
|
dir: state.domainStates.globalDir,
|
|
133
128
|
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)),
|
|
134
129
|
store: webChatStore,
|
|
135
|
-
activityMiddleware: (_props$
|
|
136
|
-
attachmentMiddleware: (_props$
|
|
137
|
-
activityStatusMiddleware: (_props$
|
|
138
|
-
toastMiddleware: (_props$
|
|
130
|
+
activityMiddleware: (_props$webChatContain9 = props.webChatContainerProps) !== null && _props$webChatContain9 !== void 0 && (_props$webChatContain10 = _props$webChatContain9.renderingMiddlewareProps) !== null && _props$webChatContain10 !== void 0 && _props$webChatContain10.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),
|
|
131
|
+
attachmentMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.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),
|
|
132
|
+
activityStatusMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
|
|
133
|
+
toastMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableToastMiddleware ? undefined : (0, _toastMiddleware.createToastMiddleware)(props.notificationPaneProps, endChat),
|
|
139
134
|
renderMarkdown,
|
|
140
|
-
avatarMiddleware: (_props$
|
|
141
|
-
groupActivitiesMiddleware: (_props$
|
|
142
|
-
typingIndicatorMiddleware: (_props$
|
|
135
|
+
avatarMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.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),
|
|
136
|
+
groupActivitiesMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
137
|
+
typingIndicatorMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
143
138
|
onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
|
|
144
|
-
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$
|
|
139
|
+
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain23 = props.webChatContainerProps) === null || _props$webChatContain23 === void 0 ? void 0 : _props$webChatContain23.botMagicCode) || undefined),
|
|
145
140
|
sendTypingIndicator: true,
|
|
146
|
-
...((_props$
|
|
141
|
+
...((_props$webChatContain24 = props.webChatContainerProps) === null || _props$webChatContain24 === void 0 ? void 0 : _props$webChatContain24.webChatProps)
|
|
147
142
|
};
|
|
148
143
|
return webChatProps;
|
|
149
144
|
};
|
|
@@ -16,8 +16,6 @@ const defaultWebChatContainerStatefulProps = {
|
|
|
16
16
|
containerStyles: _defaultWebChatStatefulContainerStyles.defaultWebChatStatefulContainerStyles,
|
|
17
17
|
disableNewLineMarkdownSupport: false,
|
|
18
18
|
disableMarkdownMessageFormatting: false,
|
|
19
|
-
opensMarkdownLinksInSameTab: false,
|
|
20
|
-
honorsTargetInHTMLLinks: false,
|
|
21
19
|
hyperlinkTextOverride: false,
|
|
22
20
|
directLine: new _mockadapter.default(),
|
|
23
21
|
adaptiveCardStyles: _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles
|
|
@@ -18,9 +18,7 @@ class HyperlinkTextOverrideRenderer {
|
|
|
18
18
|
convertTextToHtmlNode(text) {
|
|
19
19
|
const htmlNode = document.createElement(_Constants.HtmlAttributeNames.div);
|
|
20
20
|
try {
|
|
21
|
-
text = _dompurify.default.sanitize(text
|
|
22
|
-
ADD_ATTR: ["target"]
|
|
23
|
-
});
|
|
21
|
+
text = _dompurify.default.sanitize(text); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
24
22
|
htmlNode.innerHTML = text;
|
|
25
23
|
} catch {
|
|
26
24
|
return htmlNode;
|
|
@@ -31,28 +31,15 @@ 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
|
-
};
|
|
47
34
|
return /*#__PURE__*/_react.default.createElement(_react2.Stack, {
|
|
48
35
|
style: contentStyles,
|
|
49
36
|
dir: dir
|
|
50
37
|
}, role === _DirectLineSenderRole.DirectLineSenderRole.Bot && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
51
38
|
dir: dir,
|
|
52
39
|
"aria-hidden": "false"
|
|
53
|
-
}, name, " - ",
|
|
40
|
+
}, name, " - ", (0, _utils.getTimestampHourMinute)(timestamp))), role === _DirectLineSenderRole.DirectLineSenderRole.User && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
54
41
|
"aria-hidden": "false",
|
|
55
42
|
dir: dir
|
|
56
|
-
}, " ",
|
|
43
|
+
}, " ", (0, _utils.getTimestampHourMinute)(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)));
|
|
57
44
|
};
|
|
58
45
|
exports.DeliveredTimestamp = DeliveredTimestamp;
|
|
@@ -22,9 +22,8 @@ const convertTextToHtmlNode = text => {
|
|
|
22
22
|
if (!text) return "";
|
|
23
23
|
const element = document.createElement(_Constants.HtmlAttributeNames.div);
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
text = _dompurify.default.sanitize(text);
|
|
28
27
|
element.innerHTML = text;
|
|
29
28
|
} catch (e) {
|
|
30
29
|
const errorMessage = `Failed to purify and set innertHTML with text: ${text}`;
|
|
@@ -40,7 +39,7 @@ const convertTextToHtmlNode = text => {
|
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
const processHTMLText = (action, text
|
|
42
|
+
const processHTMLText = (action, text) => {
|
|
44
43
|
const htmlNode = convertTextToHtmlNode(text);
|
|
45
44
|
const aNodes = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
|
|
46
45
|
if ((aNodes === null || aNodes === void 0 ? void 0 : aNodes.length) > 0) {
|
|
@@ -53,8 +52,8 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
|
53
52
|
continue;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
// Add target to 'a' node if target is missing or
|
|
57
|
-
if (!aNode.target ||
|
|
55
|
+
// Add target to 'a' node if target is missing or does not equal to blank
|
|
56
|
+
if (!aNode.target || aNode.target !== _Constants.Constants.blank) {
|
|
58
57
|
aNode.target = _Constants.Constants.blank;
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -93,7 +92,7 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
|
93
92
|
};
|
|
94
93
|
|
|
95
94
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
96
|
-
const htmlTextMiddleware =
|
|
95
|
+
const htmlTextMiddleware = _ref => {
|
|
97
96
|
let {
|
|
98
97
|
dispatch
|
|
99
98
|
} = _ref;
|
|
@@ -103,7 +102,7 @@ const htmlTextMiddleware = honorsTargetInHTMLLinks => _ref => {
|
|
|
103
102
|
var _action$payload, _action$payload$activ;
|
|
104
103
|
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;
|
|
105
104
|
if (text) {
|
|
106
|
-
action = processHTMLText(action, text
|
|
105
|
+
action = processHTMLText(action, text);
|
|
107
106
|
}
|
|
108
107
|
} catch (e) {
|
|
109
108
|
let errorMessage = "Failed to validate action.";
|
|
@@ -26,9 +26,7 @@ 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
|
|
30
|
-
ADD_ATTR: ["target"]
|
|
31
|
-
}) ?? " ";
|
|
29
|
+
text = _dompurify.default.sanitize(text) ?? " ";
|
|
32
30
|
}
|
|
33
31
|
} catch (e) {
|
|
34
32
|
const copyDataForTelemetry = {
|
|
@@ -92,8 +92,6 @@ _defineProperty(Constants, "Zero", "zero");
|
|
|
92
92
|
_defineProperty(Constants, "Title", "title");
|
|
93
93
|
_defineProperty(Constants, "Target", "target");
|
|
94
94
|
_defineProperty(Constants, "Blank", "_blank");
|
|
95
|
-
_defineProperty(Constants, "TargetSelf", "_self");
|
|
96
|
-
_defineProperty(Constants, "TargetTop", "_top");
|
|
97
95
|
_defineProperty(Constants, "TargetRelationship", "rel");
|
|
98
96
|
_defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer");
|
|
99
97
|
// Markdown icons
|
|
@@ -5,7 +5,7 @@ import { defaultMarkdownLocalizedTexts } from "../../webchatcontainerstateful/co
|
|
|
5
5
|
import { addSlackMarkdownIt } from "./helpers/markdownHelper";
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport
|
|
8
|
+
export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport) => {
|
|
9
9
|
let markdown;
|
|
10
10
|
if (!disableMarkdownMessageFormatting) {
|
|
11
11
|
markdown = new MarkdownIt(Constants.Default, {
|
|
@@ -39,11 +39,10 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
|
|
|
39
39
|
const targetAttrIndex = tokens[idx].attrIndex(Constants.Target);
|
|
40
40
|
// Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
41
41
|
const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
42
|
-
const targetValue = opensMarkdownLinksInSameTab ? Constants.TargetTop : Constants.Blank;
|
|
43
42
|
if (~targetAttrIndex) {
|
|
44
|
-
tokens[idx].attrs[targetAttrIndex][1] =
|
|
43
|
+
tokens[idx].attrs[targetAttrIndex][1] = Constants.Blank;
|
|
45
44
|
} else {
|
|
46
|
-
tokens[idx].attrPush([Constants.Target,
|
|
45
|
+
tokens[idx].attrPush([Constants.Target, Constants.Blank]);
|
|
47
46
|
}
|
|
48
47
|
const relAttrIndex = tokens[idx].attrIndex(Constants.TargetRelationship);
|
|
49
48
|
if (~relAttrIndex) {
|
|
@@ -31,11 +31,10 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
|
|
|
31
31
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
32
32
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
33
33
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
34
|
-
import { Constants } from "../../../common/Constants";
|
|
35
34
|
|
|
36
35
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
36
|
export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
|
|
38
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4,
|
|
37
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai2, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai3, _props$webChatContain23, _props$webChatContain24;
|
|
39
38
|
// Add a hook to make all links open a new window
|
|
40
39
|
postDomPurifyActivities();
|
|
41
40
|
const localizedTexts = {
|
|
@@ -45,14 +44,12 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
45
44
|
const hyperlinkTextOverride = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hyperlinkTextOverride) ?? defaultWebChatContainerStatefulProps.hyperlinkTextOverride;
|
|
46
45
|
const disableNewLineMarkdownSupport = ((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableNewLineMarkdownSupport) ?? defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
|
|
47
46
|
const disableMarkdownMessageFormatting = ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.disableMarkdownMessageFormatting) ?? defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting;
|
|
48
|
-
const opensMarkdownLinksInSameTab = (_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.opensMarkdownLinksInSameTab;
|
|
49
|
-
const honorsTargetInHTMLLinks = (_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.honorsTargetInHTMLLinks;
|
|
50
47
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
51
|
-
const markdown = createMarkdown(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport
|
|
48
|
+
const markdown = createMarkdown(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
52
49
|
// Initialize Web Chat's redux store
|
|
53
50
|
let webChatStore = WebChatStoreLoader.store;
|
|
54
51
|
if (!webChatStore) {
|
|
55
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$
|
|
52
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
56
53
|
const conversationEndCallback = async () => {
|
|
57
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
55
|
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
@@ -84,18 +81,18 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
84
81
|
};
|
|
85
82
|
webChatStore = createStore({},
|
|
86
83
|
//initial state
|
|
87
|
-
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_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, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware
|
|
84
|
+
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_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, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware,
|
|
88
85
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
-
...(((_props$
|
|
86
|
+
...(((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.storeMiddlewares) ?? []));
|
|
90
87
|
WebChatStoreLoader.store = webChatStore;
|
|
91
88
|
}
|
|
92
89
|
const hyperlinkTextOverrideRenderer = new HyperlinkTextOverrideRenderer(hyperlinkTextOverride);
|
|
93
90
|
const markdownRenderers = [hyperlinkTextOverrideRenderer];
|
|
94
91
|
const renderMarkdown = text => {
|
|
95
|
-
var _props$
|
|
96
|
-
if ((_props$
|
|
97
|
-
var _props$
|
|
98
|
-
text = (_props$
|
|
92
|
+
var _props$webChatContain6, _props$webChatContain7;
|
|
93
|
+
if ((_props$webChatContain6 = props.webChatContainerProps) !== null && _props$webChatContain6 !== void 0 && (_props$webChatContain7 = _props$webChatContain6.webChatProps) !== null && _props$webChatContain7 !== void 0 && _props$webChatContain7.renderMarkdown) {
|
|
94
|
+
var _props$webChatContain8;
|
|
95
|
+
text = (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatProps.renderMarkdown(text);
|
|
99
96
|
} else {
|
|
100
97
|
const render = disableMarkdownMessageFormatting ? markdown.renderInline.bind(markdown) : markdown.render.bind(markdown);
|
|
101
98
|
text = render(text);
|
|
@@ -105,19 +102,16 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
105
102
|
});
|
|
106
103
|
const config = {
|
|
107
104
|
FORBID_TAGS: ["form", "button", "script", "div", "input"],
|
|
108
|
-
FORBID_ATTR: ["action"]
|
|
109
|
-
ADD_ATTR: ["target"]
|
|
105
|
+
FORBID_ATTR: ["action"]
|
|
110
106
|
};
|
|
111
107
|
text = DOMPurify.sanitize(text, config);
|
|
112
108
|
return text;
|
|
113
109
|
};
|
|
114
110
|
function postDomPurifyActivities() {
|
|
115
111
|
DOMPurify.addHook("afterSanitizeAttributes", function (node) {
|
|
116
|
-
|
|
117
|
-
if (target
|
|
118
|
-
node.setAttribute(
|
|
119
|
-
} else if (!target) {
|
|
120
|
-
node.setAttribute(Constants.Target, Constants.Blank);
|
|
112
|
+
// set all elements owning target to target=_blank
|
|
113
|
+
if ("target" in node) {
|
|
114
|
+
node.setAttribute("target", "_blank");
|
|
121
115
|
}
|
|
122
116
|
});
|
|
123
117
|
}
|
|
@@ -127,18 +121,18 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
127
121
|
dir: state.domainStates.globalDir,
|
|
128
122
|
locale: changeLanguageCodeFormatForWebChat(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
123
|
store: webChatStore,
|
|
130
|
-
activityMiddleware: (_props$
|
|
131
|
-
attachmentMiddleware: (_props$
|
|
132
|
-
activityStatusMiddleware: (_props$
|
|
133
|
-
toastMiddleware: (_props$
|
|
124
|
+
activityMiddleware: (_props$webChatContain9 = props.webChatContainerProps) !== null && _props$webChatContain9 !== void 0 && (_props$webChatContain10 = _props$webChatContain9.renderingMiddlewareProps) !== null && _props$webChatContain10 !== void 0 && _props$webChatContain10.disableActivityMiddleware ? undefined : 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),
|
|
125
|
+
attachmentMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableAttachmentMiddleware ? undefined : 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.enableInlinePlaying),
|
|
126
|
+
activityStatusMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
|
|
127
|
+
toastMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableToastMiddleware ? undefined : createToastMiddleware(props.notificationPaneProps, endChat),
|
|
134
128
|
renderMarkdown,
|
|
135
|
-
avatarMiddleware: (_props$
|
|
136
|
-
groupActivitiesMiddleware: (_props$
|
|
137
|
-
typingIndicatorMiddleware: (_props$
|
|
129
|
+
avatarMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableAvatarMiddleware ? undefined : 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),
|
|
130
|
+
groupActivitiesMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
131
|
+
typingIndicatorMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
138
132
|
onTelemetry: createWebChatTelemetry(),
|
|
139
|
-
cardActionMiddleware: createCardActionMiddleware(((_props$
|
|
133
|
+
cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain23 = props.webChatContainerProps) === null || _props$webChatContain23 === void 0 ? void 0 : _props$webChatContain23.botMagicCode) || undefined),
|
|
140
134
|
sendTypingIndicator: true,
|
|
141
|
-
...((_props$
|
|
135
|
+
...((_props$webChatContain24 = props.webChatContainerProps) === null || _props$webChatContain24 === void 0 ? void 0 : _props$webChatContain24.webChatProps)
|
|
142
136
|
};
|
|
143
137
|
return webChatProps;
|
|
144
138
|
};
|
|
@@ -9,8 +9,6 @@ export const defaultWebChatContainerStatefulProps = {
|
|
|
9
9
|
containerStyles: defaultWebChatStatefulContainerStyles,
|
|
10
10
|
disableNewLineMarkdownSupport: false,
|
|
11
11
|
disableMarkdownMessageFormatting: false,
|
|
12
|
-
opensMarkdownLinksInSameTab: false,
|
|
13
|
-
honorsTargetInHTMLLinks: false,
|
|
14
12
|
hyperlinkTextOverride: false,
|
|
15
13
|
directLine: new MockAdapter(),
|
|
16
14
|
adaptiveCardStyles: defaultAdaptiveCardStyles
|
|
@@ -11,9 +11,7 @@ class HyperlinkTextOverrideRenderer {
|
|
|
11
11
|
convertTextToHtmlNode(text) {
|
|
12
12
|
const htmlNode = document.createElement(HtmlAttributeNames.div);
|
|
13
13
|
try {
|
|
14
|
-
text = DOMPurify.sanitize(text
|
|
15
|
-
ADD_ATTR: ["target"]
|
|
16
|
-
});
|
|
14
|
+
text = DOMPurify.sanitize(text); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
17
15
|
htmlNode.innerHTML = text;
|
|
18
16
|
} catch {
|
|
19
17
|
return htmlNode;
|
|
@@ -25,27 +25,14 @@ export const DeliveredTimestamp = _ref => {
|
|
|
25
25
|
timestamp
|
|
26
26
|
}
|
|
27
27
|
} = args;
|
|
28
|
-
const getTimeElement = timestamp => {
|
|
29
|
-
const timeString = getTimestampHourMinute(timestamp);
|
|
30
|
-
const isAmPmFormat = timeString.toLowerCase().includes("am") || timeString.toLowerCase().includes("pm");
|
|
31
|
-
|
|
32
|
-
// For clients that use languages that are written right-to-left, but still use AM/PM time format, we need to
|
|
33
|
-
// make sure the "rtl" direction doesn't produce "PM 1:23", but remains "1:23 PM"
|
|
34
|
-
if (dir === "rtl" && isAmPmFormat) {
|
|
35
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
36
|
-
dir: "ltr"
|
|
37
|
-
}, getTimestampHourMinute(timestamp));
|
|
38
|
-
}
|
|
39
|
-
return timeString;
|
|
40
|
-
};
|
|
41
28
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
42
29
|
style: contentStyles,
|
|
43
30
|
dir: dir
|
|
44
31
|
}, role === DirectLineSenderRole.Bot && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
45
32
|
dir: dir,
|
|
46
33
|
"aria-hidden": "false"
|
|
47
|
-
}, name, " - ",
|
|
34
|
+
}, name, " - ", getTimestampHourMinute(timestamp))), role === DirectLineSenderRole.User && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
48
35
|
"aria-hidden": "false",
|
|
49
36
|
dir: dir
|
|
50
|
-
}, " ",
|
|
37
|
+
}, " ", getTimestampHourMinute(timestamp), " - ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_DELIVERED) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_DELIVERED)));
|
|
51
38
|
};
|
|
@@ -16,9 +16,8 @@ const convertTextToHtmlNode = text => {
|
|
|
16
16
|
if (!text) return "";
|
|
17
17
|
const element = document.createElement(HtmlAttributeNames.div);
|
|
18
18
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
text = DOMPurify.sanitize(text);
|
|
22
21
|
element.innerHTML = text;
|
|
23
22
|
} catch (e) {
|
|
24
23
|
const errorMessage = `Failed to purify and set innertHTML with text: ${text}`;
|
|
@@ -34,7 +33,7 @@ const convertTextToHtmlNode = text => {
|
|
|
34
33
|
};
|
|
35
34
|
|
|
36
35
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
const processHTMLText = (action, text
|
|
36
|
+
const processHTMLText = (action, text) => {
|
|
38
37
|
const htmlNode = convertTextToHtmlNode(text);
|
|
39
38
|
const aNodes = htmlNode.getElementsByTagName(HtmlAttributeNames.aTagName);
|
|
40
39
|
if ((aNodes === null || aNodes === void 0 ? void 0 : aNodes.length) > 0) {
|
|
@@ -47,8 +46,8 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
|
47
46
|
continue;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
// Add target to 'a' node if target is missing or
|
|
51
|
-
if (!aNode.target ||
|
|
49
|
+
// Add target to 'a' node if target is missing or does not equal to blank
|
|
50
|
+
if (!aNode.target || aNode.target !== Constants.blank) {
|
|
52
51
|
aNode.target = Constants.blank;
|
|
53
52
|
}
|
|
54
53
|
|
|
@@ -87,7 +86,7 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
|
87
86
|
};
|
|
88
87
|
|
|
89
88
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
90
|
-
const htmlTextMiddleware =
|
|
89
|
+
const htmlTextMiddleware = _ref => {
|
|
91
90
|
let {
|
|
92
91
|
dispatch
|
|
93
92
|
} = _ref;
|
|
@@ -97,7 +96,7 @@ const htmlTextMiddleware = honorsTargetInHTMLLinks => _ref => {
|
|
|
97
96
|
var _action$payload, _action$payload$activ;
|
|
98
97
|
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;
|
|
99
98
|
if (text) {
|
|
100
|
-
action = processHTMLText(action, text
|
|
99
|
+
action = processHTMLText(action, text);
|
|
101
100
|
}
|
|
102
101
|
} catch (e) {
|
|
103
102
|
let errorMessage = "Failed to validate action.";
|
|
@@ -20,9 +20,7 @@ const sanitizationMiddleware = _ref => {
|
|
|
20
20
|
var _action$payload;
|
|
21
21
|
let text = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.text;
|
|
22
22
|
if (text) {
|
|
23
|
-
text = DOMPurify.sanitize(text
|
|
24
|
-
ADD_ATTR: ["target"]
|
|
25
|
-
}) ?? " ";
|
|
23
|
+
text = DOMPurify.sanitize(text) ?? " ";
|
|
26
24
|
}
|
|
27
25
|
} catch (e) {
|
|
28
26
|
const copyDataForTelemetry = {
|
|
@@ -74,8 +74,6 @@ export declare class Constants {
|
|
|
74
74
|
static readonly Title = "title";
|
|
75
75
|
static readonly Target = "target";
|
|
76
76
|
static readonly Blank = "_blank";
|
|
77
|
-
static readonly TargetSelf = "_self";
|
|
78
|
-
static readonly TargetTop = "_top";
|
|
79
77
|
static readonly TargetRelationship = "rel";
|
|
80
78
|
static readonly TargetRelationshipAttributes = "noopener noreferrer";
|
|
81
79
|
static readonly OpenLinkIconCssClass = "webchat__render-markdown__external-link-icon";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import MarkdownIt from "markdown-it";
|
|
2
|
-
export declare const createMarkdown: (disableMarkdownMessageFormatting: boolean, disableNewLineMarkdownSupport: boolean
|
|
2
|
+
export declare const createMarkdown: (disableMarkdownMessageFormatting: boolean, disableNewLineMarkdownSupport: boolean) => MarkdownIt;
|
package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts
CHANGED
|
@@ -11,8 +11,6 @@ export interface IWebChatContainerStatefulProps {
|
|
|
11
11
|
containerStyles?: IStyle;
|
|
12
12
|
disableNewLineMarkdownSupport?: boolean;
|
|
13
13
|
disableMarkdownMessageFormatting?: boolean;
|
|
14
|
-
opensMarkdownLinksInSameTab?: boolean;
|
|
15
|
-
honorsTargetInHTMLLinks?: boolean;
|
|
16
14
|
webChatStyles?: StyleOptions;
|
|
17
15
|
webChatProps?: IWebChatProps;
|
|
18
16
|
directLine?: any;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Ensures that links within messages are processed so that the caller website cannot be traced.
|
|
5
5
|
******/
|
|
6
6
|
import { IWebChatAction } from "../../../interfaces/IWebChatAction";
|
|
7
|
-
declare const htmlTextMiddleware: (
|
|
7
|
+
declare const htmlTextMiddleware: ({ dispatch }: {
|
|
8
8
|
dispatch: any;
|
|
9
9
|
}) => (next: any) => (action: IWebChatAction) => any;
|
|
10
10
|
export default htmlTextMiddleware;
|