@microsoft/omnichannel-chat-widget 1.6.4-main.5456d1e → 1.6.4-main.ab88589
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +1 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +4 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +9 -0
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +6 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +2 -1
- package/lib/esm/common/Constants.js +1 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +4 -3
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +6 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +2 -1
- package/lib/types/common/Constants.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
- package/package.json +4 -3
|
@@ -22,6 +22,7 @@ _defineProperty(Constants, "sentMessageClassName", "ms_lcw_webchat_sent_message"
|
|
|
22
22
|
_defineProperty(Constants, "webchatChannelId", "webchat");
|
|
23
23
|
_defineProperty(Constants, "markdown", "markdown");
|
|
24
24
|
_defineProperty(Constants, "actionType", "actionType");
|
|
25
|
+
_defineProperty(Constants, "markDownSystemMessageClass", "webchat__basic-transcript__activity-markdown-body");
|
|
25
26
|
_defineProperty(Constants, "String", "string");
|
|
26
27
|
_defineProperty(Constants, "ChatMessagesJson", "chatMessagesJson");
|
|
27
28
|
_defineProperty(Constants, "truePascal", "True");
|
|
@@ -49,8 +49,9 @@ const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
|
|
|
49
49
|
};
|
|
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
|
+
const disableMarkdownMessageFormatting = ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.disableMarkdownMessageFormatting) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting;
|
|
52
53
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
|
-
const markdown = (0, _createMarkdown.createMarkdown)(
|
|
54
|
+
const markdown = (0, _createMarkdown.createMarkdown)(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
54
55
|
// Initialize Web Chat's redux store
|
|
55
56
|
let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
|
|
56
57
|
if (!webChatStore) {
|
|
@@ -99,7 +100,7 @@ const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
|
|
|
99
100
|
var _props$webChatContain8;
|
|
100
101
|
text = (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatProps.renderMarkdown(text);
|
|
101
102
|
} else {
|
|
102
|
-
const render =
|
|
103
|
+
const render = disableMarkdownMessageFormatting ? markdown.renderInline.bind(markdown) : markdown.render.bind(markdown);
|
|
103
104
|
text = render(text);
|
|
104
105
|
}
|
|
105
106
|
markdownRenderers.forEach(renderer => {
|
|
@@ -122,7 +123,7 @@ const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
|
|
|
122
123
|
dir: state.domainStates.globalDir,
|
|
123
124
|
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)),
|
|
124
125
|
store: webChatStore,
|
|
125
|
-
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)((_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),
|
|
126
|
+
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),
|
|
126
127
|
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.default)(((_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),
|
|
127
128
|
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,
|
|
128
129
|
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.default)(props.notificationPaneProps, endChat),
|
|
@@ -726,6 +726,15 @@ const LiveChatWidgetStateful = props => {
|
|
|
726
726
|
::-webkit-scrollbar-thumb:hover {
|
|
727
727
|
background: ${scrollbarProps.thumbHoverColor};
|
|
728
728
|
}
|
|
729
|
+
|
|
730
|
+
.webchat__basic-transcript__activity-markdown-body > :last-child {
|
|
731
|
+
margin-bottom: 0px;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.webchat__basic-transcript__activity-markdown-body > :first-child {
|
|
735
|
+
margin-top: 0px;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
729
738
|
`), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
730
739
|
styleOptions: {
|
|
731
740
|
...webChatStyles,
|
|
@@ -185,10 +185,10 @@ const WebChatContainerStateful = props => {
|
|
|
185
185
|
|
|
186
186
|
.webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp8 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp8 === void 0 ? void 0 : _webChatContainerProp8.buttonWhiteSpace) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.buttonWhiteSpace} !important;}
|
|
187
187
|
|
|
188
|
-
.ms_lcw_webchat_received_message img.webchat__render-markdown__external-link-icon {
|
|
189
|
-
background-image : url(data:image/svg+xml;base64,
|
|
190
|
-
height:
|
|
191
|
-
|
|
188
|
+
.ms_lcw_webchat_received_message img.webchat__render-markdown__external-link-icon, img.webchat__render-markdown__external-link-icon {
|
|
189
|
+
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcuMjUwMSA0LjUwMDE3SDEwLjc0OTVDMTEuMTYzNyA0LjUwMDE3IDExLjQ5OTUgNC44MzU5NiAxMS40OTk1IDUuMjUwMTdDMTEuNDk5NSA1LjYyOTg2IDExLjIxNzMgNS45NDM2NiAxMC44NTEzIDUuOTkzMzJMMTAuNzQ5NSA2LjAwMDE3SDcuMjQ5NzRDNi4wNzA3OSA1Ljk5OTYxIDUuMTAzNDkgNi45MDY1NiA1LjAwNzg2IDguMDYxMTJMNS4wMDAyOCA4LjIyMDAzTDUuMDAzMTIgMTYuNzUw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5NyAxMC4yNTU0QzIwLjk5OTcgMTAuNjY5NiAyMC42NjM5IDExLjAwNTQgMjAuMjQ5NyAxMS4wMDU0QzE5Ljg3IDExLjAwNTQgMTkuNTU2MiAxMC43MjMyIDE5LjUwNjUgMTAuMzU3MUwxOS40OTk3IDEwLjI1NTRMMTkuNDk4OSA1LjU2MTQ3TDEyLjI3OTcgMTIuNzg0N0MxMi4wMTM0IDEzLjA1MSAxMS41OTY4IDEzLjA3NTMgMTEuMzAzMSAxMi44NTc1TDExLjIxOSAxMi43ODQ5QzEwLjk1MjcgMTIuNTE4NyAxMC45Mjg0IDEyLjEwMjEgMTEuMTQ2MiAxMS44MDg0TDExLjIxODggMTEuNzI0M0wxOC40MzY5IDQuNTAxNDZIMTMuNzQ4MUMxMy4zNjg0IDQuNTAxNDYgMTMuMDU0NiA0LjIxOTMxIDEzLjAwNSAzLjg1MzI0TDEyLjk5ODEgMy43NTE0NkMxMi45OTgxIDMuMzcxNzcgMTMuMjgwMyAzLjA1Nzk3IDEzLjY0NjQgMy4wMDgzMUwxMy43NDgxIDMuMDAxNDZaIiBmaWxsPSIjMjEyMTIxIiAvPjwvc3ZnPg==) !important;
|
|
190
|
+
height: .75em;
|
|
191
|
+
margin-left: .25em;
|
|
192
192
|
filter:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp9 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp9 === void 0 ? void 0 : (_webChatContainerProp10 = _webChatContainerProp9.receivedMessageAnchorStyles) === null || _webChatContainerProp10 === void 0 ? void 0 : _webChatContainerProp10.filter) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.filter)};
|
|
193
193
|
}
|
|
194
194
|
pre {
|
|
@@ -24,9 +24,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
24
|
******/
|
|
25
25
|
|
|
26
26
|
const loggedSystemMessages = new Array();
|
|
27
|
-
|
|
28
27
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
28
|
+
const handleSystemMessage = (next, args, card, renderMarkdown, systemMessageStyleProps) => {
|
|
30
29
|
var _card$activity, _card$activity$channe, _card$activity$channe2, _card$activity2, _card$activity2$chann, _card$activity3, _card$activity3$chann, _card$activity3$chann2, _card$activity4, _card$activity4$chann, _card$activity5, _card$activity5$chann, _card$nextVisibleActi, _card$nextVisibleActi2, _card$activity6, _card$activity6$chann, _card$activity7, _card$nextVisibleActi3, _card$activity8;
|
|
31
30
|
const systemMessageStyles = {
|
|
32
31
|
..._defaultSystemMessageStyles.defaultSystemMessageStyles,
|
|
@@ -49,14 +48,15 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
|
49
48
|
if ((_card$activity5 = card.activity) !== null && _card$activity5 !== void 0 && (_card$activity5$chann = _card$activity5.channelData) !== null && _card$activity5$chann !== void 0 && _card$activity5$chann.clientmessageid && ((_card$nextVisibleActi = card.nextVisibleActivity) === null || _card$nextVisibleActi === void 0 ? void 0 : (_card$nextVisibleActi2 = _card$nextVisibleActi.channelData) === null || _card$nextVisibleActi2 === void 0 ? void 0 : _card$nextVisibleActi2.clientmessageid) === ((_card$activity6 = card.activity) === null || _card$activity6 === void 0 ? void 0 : (_card$activity6$chann = _card$activity6.channelData) === null || _card$activity6$chann === void 0 ? void 0 : _card$activity6$chann.clientmessageid) || (_card$activity7 = card.activity) !== null && _card$activity7 !== void 0 && _card$activity7.messageid && ((_card$nextVisibleActi3 = card.nextVisibleActivity) === null || _card$nextVisibleActi3 === void 0 ? void 0 : _card$nextVisibleActi3.messageid) === ((_card$activity8 = card.activity) === null || _card$activity8 === void 0 ? void 0 : _card$activity8.messageid)) {
|
|
50
49
|
return () => false;
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
card.activity.text = renderMarkdown(card.activity.text);
|
|
53
52
|
// eslint-disable-next-line react/display-name
|
|
54
53
|
return () => /*#__PURE__*/_react.default.createElement("div", {
|
|
55
54
|
key: card.activity.id,
|
|
56
55
|
style: systemMessageStyles,
|
|
57
56
|
"aria-hidden": "false",
|
|
57
|
+
className: _Constants.Constants.markDownSystemMessageClass,
|
|
58
58
|
dangerouslySetInnerHTML: {
|
|
59
|
-
__html:
|
|
59
|
+
__html: card.activity.text
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
};
|
|
@@ -72,7 +72,7 @@ const isDataTagsPresent = card => {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
-
const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
|
|
75
|
+
const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
|
|
76
76
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
77
77
|
args[_key] = arguments[_key];
|
|
78
78
|
}
|
|
@@ -86,7 +86,7 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
86
86
|
return () => false;
|
|
87
87
|
}
|
|
88
88
|
if (isTagIncluded(card, _Constants.Constants.systemMessageTag)) {
|
|
89
|
-
return handleSystemMessage(next, args, card, systemMessageStyleProps);
|
|
89
|
+
return handleSystemMessage(next, args, card, renderMarkdown, systemMessageStyleProps);
|
|
90
90
|
} else if (card.activity.text && card.activity.type === _DirectLineActivityType.DirectLineActivityType.Message) {
|
|
91
91
|
if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === _Constants.Constants.webchatChannelId) {
|
|
92
92
|
card.activity.text = (0, _utils.escapeHtml)(card.activity.text);
|
|
@@ -9,6 +9,7 @@ var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
|
9
9
|
var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
10
10
|
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
11
11
|
var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
|
|
12
|
+
var _simpleUpdateIn = _interopRequireDefault(require("simple-update-in"));
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
14
|
/******
|
|
14
15
|
* HTMLTextMiddleware
|
|
@@ -70,7 +71,7 @@ const processHTMLText = (action, text) => {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
-
action =
|
|
74
|
+
action = (0, _simpleUpdateIn.default)(action, [_Constants.Constants.payload, _Constants.Constants.activity, _Constants.Constants.text], () => htmlNode.innerHTML);
|
|
74
75
|
} catch (e) {
|
|
75
76
|
let errorMessage = "Failed to apply action: ";
|
|
76
77
|
try {
|
|
@@ -15,6 +15,7 @@ _defineProperty(Constants, "sentMessageClassName", "ms_lcw_webchat_sent_message"
|
|
|
15
15
|
_defineProperty(Constants, "webchatChannelId", "webchat");
|
|
16
16
|
_defineProperty(Constants, "markdown", "markdown");
|
|
17
17
|
_defineProperty(Constants, "actionType", "actionType");
|
|
18
|
+
_defineProperty(Constants, "markDownSystemMessageClass", "webchat__basic-transcript__activity-markdown-body");
|
|
18
19
|
_defineProperty(Constants, "String", "string");
|
|
19
20
|
_defineProperty(Constants, "ChatMessagesJson", "chatMessagesJson");
|
|
20
21
|
_defineProperty(Constants, "truePascal", "True");
|
|
@@ -43,8 +43,9 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
|
|
|
43
43
|
};
|
|
44
44
|
const hyperlinkTextOverride = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hyperlinkTextOverride) ?? defaultWebChatContainerStatefulProps.hyperlinkTextOverride;
|
|
45
45
|
const disableNewLineMarkdownSupport = ((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableNewLineMarkdownSupport) ?? defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
|
|
46
|
+
const disableMarkdownMessageFormatting = ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.disableMarkdownMessageFormatting) ?? defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting;
|
|
46
47
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
47
|
-
const markdown = createMarkdown(
|
|
48
|
+
const markdown = createMarkdown(disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
48
49
|
// Initialize Web Chat's redux store
|
|
49
50
|
let webChatStore = WebChatStoreLoader.store;
|
|
50
51
|
if (!webChatStore) {
|
|
@@ -93,7 +94,7 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
|
|
|
93
94
|
var _props$webChatContain8;
|
|
94
95
|
text = (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatProps.renderMarkdown(text);
|
|
95
96
|
} else {
|
|
96
|
-
const render =
|
|
97
|
+
const render = disableMarkdownMessageFormatting ? markdown.renderInline.bind(markdown) : markdown.render.bind(markdown);
|
|
97
98
|
text = render(text);
|
|
98
99
|
}
|
|
99
100
|
markdownRenderers.forEach(renderer => {
|
|
@@ -116,7 +117,7 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
|
|
|
116
117
|
dir: state.domainStates.globalDir,
|
|
117
118
|
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)),
|
|
118
119
|
store: webChatStore,
|
|
119
|
-
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((_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),
|
|
120
|
+
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),
|
|
120
121
|
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),
|
|
121
122
|
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,
|
|
122
123
|
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),
|
|
@@ -718,6 +718,15 @@ export const LiveChatWidgetStateful = props => {
|
|
|
718
718
|
::-webkit-scrollbar-thumb:hover {
|
|
719
719
|
background: ${scrollbarProps.thumbHoverColor};
|
|
720
720
|
}
|
|
721
|
+
|
|
722
|
+
.webchat__basic-transcript__activity-markdown-body > :last-child {
|
|
723
|
+
margin-bottom: 0px;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.webchat__basic-transcript__activity-markdown-body > :first-child {
|
|
727
|
+
margin-top: 0px;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
721
730
|
`), /*#__PURE__*/React.createElement(DraggableChatWidget, chatWidgetDraggableConfig, /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
|
|
722
731
|
styleOptions: {
|
|
723
732
|
...webChatStyles,
|
|
@@ -177,10 +177,10 @@ export const WebChatContainerStateful = props => {
|
|
|
177
177
|
|
|
178
178
|
.webchat__stacked-layout__content .ac-actionSet > .ac-pushButton > div {white-space: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp8 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp8 === void 0 ? void 0 : _webChatContainerProp8.buttonWhiteSpace) ?? defaultAdaptiveCardStyles.buttonWhiteSpace} !important;}
|
|
179
179
|
|
|
180
|
-
.ms_lcw_webchat_received_message img.webchat__render-markdown__external-link-icon {
|
|
181
|
-
background-image : url(data:image/svg+xml;base64,
|
|
182
|
-
height:
|
|
183
|
-
|
|
180
|
+
.ms_lcw_webchat_received_message img.webchat__render-markdown__external-link-icon, img.webchat__render-markdown__external-link-icon {
|
|
181
|
+
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcuMjUwMSA0LjUwMDE3SDEwLjc0OTVDMTEuMTYzNyA0LjUwMDE3IDExLjQ5OTUgNC44MzU5NiAxMS40OTk1IDUuMjUwMTdDMTEuNDk5NSA1LjYyOTg2IDExLjIxNzMgNS45NDM2NiAxMC44NTEzIDUuOTkzMzJMMTAuNzQ5NSA2LjAwMDE3SDcuMjQ5NzRDNi4wNzA3OSA1Ljk5OTYxIDUuMTAzNDkgNi45MDY1NiA1LjAwNzg2IDguMDYxMTJMNS4wMDAyOCA4LjIyMDAzTDUuMDAzMTIgMTYuNzUwN0M1LjAwMzQzIDE3Ljk0MTUgNS45Mjg4NSAxOC45MTYxIDcuMDk5NjYgMTguOTk0OUw3LjI1MzcxIDE5LjAwMDFMMTUuNzUxOCAxOC45ODg0QzE2Ljk0MTUgMTguOTg2OCAxNy45MTQ1IDE4LjA2MiAxNy45OTM1IDE2Ljg5MjNMMTcuOTk4NyAxNi43Mzg0VjEzLjIzMjFDMTcuOTk4NyAxMi44MTc5IDE4LjMzNDUgMTIuNDgyMSAxOC43NDg3IDEyLjQ4MjFDMTkuMTI4NCAxMi40ODIxIDE5LjQ0MjIgMTIuNzY0MyAxOS40OTE4IDEzLjEzMDNMMTkuNDk4NyAxMy4yMzIxVjE2LjczODRDMTkuNDk4NyAxOC43NDA3IDE3LjkyOTMgMjAuMzc2OSAxNS45NTI4IDIwLjQ4MjlMMTUuNzUzOCAyMC40ODg0TDcuMjU4MjcgMjAu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0TDEyLjk5ODEgMy43NTE0NkMxMi45OTgxIDMuMzcxNzcgMTMuMjgwMyAzLjA1Nzk3IDEzLjY0NjQgMy4wMDgzMUwxMy43NDgxIDMuMDAxNDZaIiBmaWxsPSIjMjEyMTIxIiAvPjwvc3ZnPg==) !important;
|
|
182
|
+
height: .75em;
|
|
183
|
+
margin-left: .25em;
|
|
184
184
|
filter:${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp9 = webChatContainerProps.renderingMiddlewareProps) === null || _webChatContainerProp9 === void 0 ? void 0 : (_webChatContainerProp10 = _webChatContainerProp9.receivedMessageAnchorStyles) === null || _webChatContainerProp10 === void 0 ? void 0 : _webChatContainerProp10.filter) ?? (defaultReceivedMessageAnchorStyles === null || defaultReceivedMessageAnchorStyles === void 0 ? void 0 : defaultReceivedMessageAnchorStyles.filter)};
|
|
185
185
|
}
|
|
186
186
|
pre {
|
|
@@ -17,9 +17,8 @@ import { defaultSystemMessageStyles } from "./defaultStyles/defaultSystemMessage
|
|
|
17
17
|
import { defaultUserMessageStyles } from "./defaultStyles/defaultUserMessageStyles";
|
|
18
18
|
import { escapeHtml } from "../../../../../common/utils";
|
|
19
19
|
const loggedSystemMessages = new Array();
|
|
20
|
-
|
|
21
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
21
|
+
const handleSystemMessage = (next, args, card, renderMarkdown, systemMessageStyleProps) => {
|
|
23
22
|
var _card$activity, _card$activity$channe, _card$activity$channe2, _card$activity2, _card$activity2$chann, _card$activity3, _card$activity3$chann, _card$activity3$chann2, _card$activity4, _card$activity4$chann, _card$activity5, _card$activity5$chann, _card$nextVisibleActi, _card$nextVisibleActi2, _card$activity6, _card$activity6$chann, _card$activity7, _card$nextVisibleActi3, _card$activity8;
|
|
24
23
|
const systemMessageStyles = {
|
|
25
24
|
...defaultSystemMessageStyles,
|
|
@@ -42,14 +41,15 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
|
42
41
|
if ((_card$activity5 = card.activity) !== null && _card$activity5 !== void 0 && (_card$activity5$chann = _card$activity5.channelData) !== null && _card$activity5$chann !== void 0 && _card$activity5$chann.clientmessageid && ((_card$nextVisibleActi = card.nextVisibleActivity) === null || _card$nextVisibleActi === void 0 ? void 0 : (_card$nextVisibleActi2 = _card$nextVisibleActi.channelData) === null || _card$nextVisibleActi2 === void 0 ? void 0 : _card$nextVisibleActi2.clientmessageid) === ((_card$activity6 = card.activity) === null || _card$activity6 === void 0 ? void 0 : (_card$activity6$chann = _card$activity6.channelData) === null || _card$activity6$chann === void 0 ? void 0 : _card$activity6$chann.clientmessageid) || (_card$activity7 = card.activity) !== null && _card$activity7 !== void 0 && _card$activity7.messageid && ((_card$nextVisibleActi3 = card.nextVisibleActivity) === null || _card$nextVisibleActi3 === void 0 ? void 0 : _card$nextVisibleActi3.messageid) === ((_card$activity8 = card.activity) === null || _card$activity8 === void 0 ? void 0 : _card$activity8.messageid)) {
|
|
43
42
|
return () => false;
|
|
44
43
|
}
|
|
45
|
-
|
|
44
|
+
card.activity.text = renderMarkdown(card.activity.text);
|
|
46
45
|
// eslint-disable-next-line react/display-name
|
|
47
46
|
return () => /*#__PURE__*/React.createElement("div", {
|
|
48
47
|
key: card.activity.id,
|
|
49
48
|
style: systemMessageStyles,
|
|
50
49
|
"aria-hidden": "false",
|
|
50
|
+
className: Constants.markDownSystemMessageClass,
|
|
51
51
|
dangerouslySetInnerHTML: {
|
|
52
|
-
__html:
|
|
52
|
+
__html: card.activity.text
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
};
|
|
@@ -65,7 +65,7 @@ const isDataTagsPresent = card => {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
export const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
|
|
68
|
+
export const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
|
|
69
69
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
70
70
|
args[_key] = arguments[_key];
|
|
71
71
|
}
|
|
@@ -79,7 +79,7 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
|
|
|
79
79
|
return () => false;
|
|
80
80
|
}
|
|
81
81
|
if (isTagIncluded(card, Constants.systemMessageTag)) {
|
|
82
|
-
return handleSystemMessage(next, args, card, systemMessageStyleProps);
|
|
82
|
+
return handleSystemMessage(next, args, card, renderMarkdown, systemMessageStyleProps);
|
|
83
83
|
} else if (card.activity.text && card.activity.type === DirectLineActivityType.Message) {
|
|
84
84
|
if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === Constants.webchatChannelId) {
|
|
85
85
|
card.activity.text = escapeHtml(card.activity.text);
|
|
@@ -9,6 +9,7 @@ import DOMPurify from "dompurify";
|
|
|
9
9
|
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
10
10
|
import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
|
|
11
11
|
import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
|
|
12
|
+
import updateIn from "simple-update-in";
|
|
12
13
|
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
15
|
const convertTextToHtmlNode = text => {
|
|
@@ -64,7 +65,7 @@ const processHTMLText = (action, text) => {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
-
action =
|
|
68
|
+
action = updateIn(action, [Constants.payload, Constants.activity, Constants.text], () => htmlNode.innerHTML);
|
|
68
69
|
} catch (e) {
|
|
69
70
|
let errorMessage = "Failed to apply action: ";
|
|
70
71
|
try {
|
|
@@ -11,6 +11,7 @@ export declare class Constants {
|
|
|
11
11
|
static readonly webchatChannelId = "webchat";
|
|
12
12
|
static readonly markdown = "markdown";
|
|
13
13
|
static readonly actionType = "actionType";
|
|
14
|
+
static readonly markDownSystemMessageClass = "webchat__basic-transcript__activity-markdown-body";
|
|
14
15
|
static readonly String = "string";
|
|
15
16
|
static readonly ChatMessagesJson = "chatMessagesJson";
|
|
16
17
|
static readonly truePascal = "True";
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* 3. Decodes certain html characters that came through from chat services
|
|
8
8
|
******/
|
|
9
9
|
import React from "react";
|
|
10
|
-
export declare const createActivityMiddleware: (systemMessageStyleProps?: React.CSSProperties | undefined, userMessageStyleProps?: React.CSSProperties | undefined) => () => (next: any) => (...args: any) => any;
|
|
10
|
+
export declare const createActivityMiddleware: (renderMarkdown: (text: string) => string, systemMessageStyleProps?: React.CSSProperties | undefined, userMessageStyleProps?: React.CSSProperties | undefined) => () => (next: any) => (...args: any) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.6.4-main.
|
|
3
|
+
"version": "1.6.4-main.ab88589",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"webpack-cli": "^4.9.2"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@microsoft/omnichannel-chat-components": "1.1.
|
|
77
|
+
"@microsoft/omnichannel-chat-components": "1.1.5",
|
|
78
78
|
"@microsoft/omnichannel-chat-sdk": "^1.8.0",
|
|
79
79
|
"abort-controller-es5": "^2.0.1",
|
|
80
80
|
"dompurify": "^2.3.4",
|
|
@@ -85,7 +85,8 @@
|
|
|
85
85
|
"md5-typescript": "^1.0.5",
|
|
86
86
|
"p-defer-es5": "^2.0.1",
|
|
87
87
|
"sanitize-html": "2.12.1",
|
|
88
|
-
"slack-markdown-it": "^1.0.5"
|
|
88
|
+
"slack-markdown-it": "^1.0.5",
|
|
89
|
+
"simple-update-in": "2.2.0"
|
|
89
90
|
},
|
|
90
91
|
"scripts": {
|
|
91
92
|
"storybook": "start-storybook -p 6006",
|