@@ -34,7 +34,7 @@ window.openAIChatManager = function () {
3434 thumbsUpTitle : 'Thumbs up' ,
3535 thumbsDownTitle : 'Thumbs down' ,
3636 copyTitle : 'Click here to copy response to clipboard.' ,
37- messageTemplate : "\n <div class=\"ai-chat-messages\">\n <div v-for=\"(message, index) in messages\" :key=\"index\" class=\"ai-chat-message-item\">\n <div>\n <div v-if=\"message.role === 'user'\" class=\"ai-chat-msg-role ai-chat-msg-role-user\">{{ userLabel }}</div>\n <div v-else-if=\"message.role !== 'indicator'\" class=\"ai-chat-msg-role ai-chat-msg-role-assistant\">\n <i :class=\"'fa fa-robot' + (message.isStreaming ? ' ai-streaming-icon' : ' ai-bot-icon')\"></i>\n {{ assistantLabel }}\n </div>\n <div class=\"lh-base\">\n <h4 v-if=\"message.title\">{{ message.title }}</h4>\n <div v-html=\"message.htmlContent || message.content\"></div>\n <span class=\"message-buttons-container\" v-if=\"!isIndicator(message)\">\n <template v-if=\"metricsEnabled && message.role === 'assistant'\">\n <span class=\"ai-chat-message-assistant-feedback\" :data-message-id=\"message.id\">\n <button class=\"btn btn-sm btn-link text-success p-0 me-2 button-message-toolbox rate-up-btn\" @click=\"rateMessage(message, true, $event)\" :title=\"thumbsUpTitle\">\n <i class=\"fa-regular fa-thumbs-up\"></i>\n </button>\n <button class=\"btn btn-sm btn-link text-danger p-0 me-2 button-message-toolbox rate-down-btn\" @click=\"rateMessage(message, false, $event)\" :title=\"thumbsDownTitle\">\n <i class=\"fa-regular fa-thumbs-down\"></i>\n </button>\n </span>\n </template>\n <button class=\"btn btn-sm btn-link text-secondary p-0 button-message-toolbox\" @click=\"copyResponse(message.content)\" :title=\"copyTitle\">\n <i class=\"fa-solid fa-copy\"></i>\n </button>\n </span>\n </div>\n </div>\n </div>\n </div>\n " ,
37+ messageTemplate : "\n <div class=\"ai-chat-messages\">\n <div v-for=\"(message, index) in messages\" :key=\"index\" class=\"ai-chat-message-item\">\n <div>\n <div v-if=\"message.role === 'user'\" class=\"ai-chat-msg-role ai-chat-msg-role-user\">{{ userLabel }}</div>\n <div v-else-if=\"message.role !== 'indicator'\" class=\"ai-chat-msg-role ai-chat-msg-role-assistant\">\n <i :class=\"'fa fa-robot' + (message.isStreaming ? ' ai-streaming-icon' : ' ai-bot-icon')\"></i>\n {{ assistantLabel }}\n </div>\n <div class=\"lh-base\">\n <h4 v-if=\"message.title\">{{ message.title }}</h4>\n <div v-html=\"message.htmlContent\"></div>\n <span class=\"message-buttons-container\" v-if=\"!isIndicator(message)\">\n <template v-if=\"metricsEnabled && message.role === 'assistant'\">\n <span class=\"ai-chat-message-assistant-feedback\" :data-message-id=\"message.id\">\n <button class=\"btn btn-sm btn-link text-success p-0 me-2 button-message-toolbox rate-up-btn\" @click=\"rateMessage(message, true, $event)\" :title=\"thumbsUpTitle\">\n <i class=\"fa-regular fa-thumbs-up\"></i>\n </button>\n <button class=\"btn btn-sm btn-link text-danger p-0 me-2 button-message-toolbox rate-down-btn\" @click=\"rateMessage(message, false, $event)\" :title=\"thumbsDownTitle\">\n <i class=\"fa-regular fa-thumbs-down\"></i>\n </button>\n </span>\n </template>\n <button class=\"btn btn-sm btn-link text-secondary p-0 button-message-toolbox\" @click=\"copyResponse(message.content)\" :title=\"copyTitle\">\n <i class=\"fa-solid fa-copy\"></i>\n </button>\n </span>\n </div>\n </div>\n </div>\n </div>\n " ,
3838 indicatorTemplate : "\n <div class=\"ai-chat-msg-role ai-chat-msg-role-assistant\">\n <i class=\"fa fa-robot ai-streaming-icon\" style=\"display: inline-block;\"></i>\n Assistant\n </div>\n "
3939 } ;
4040
@@ -528,7 +528,9 @@ window.openAIChatManager = function () {
528528 }
529529 html += '</button>' ;
530530 html += '</div>' ;
531- this . documentBar . innerHTML = DOMPurify . sanitize ( html ) ;
531+ this . documentBar . replaceChildren ( DOMPurify . sanitize ( html , {
532+ RETURN_DOM_FRAGMENT : true
533+ } ) ) ;
532534
533535 // Bind remove handlers
534536 var self = this ;
@@ -631,6 +633,9 @@ window.openAIChatManager = function () {
631633 } ,
632634 addMessageInternal : function addMessageInternal ( message ) {
633635 var _this4 = this ;
636+ if ( message . content && ! message . htmlContent ) {
637+ message . htmlContent = parseMarkdownContent ( message . content , message ) ;
638+ }
634639 this . fireEvent ( new CustomEvent ( "addingOpenAIPromotMessage" , {
635640 detail : {
636641 message : message
@@ -977,7 +982,9 @@ window.openAIChatManager = function () {
977982 streamingStarted : function streamingStarted ( ) {
978983 var stopIcon = this . buttonElement . getAttribute ( 'data-stop-icon' ) ;
979984 if ( stopIcon ) {
980- this . buttonElement . innerHTML = DOMPurify . sanitize ( stopIcon ) ;
985+ this . buttonElement . replaceChildren ( DOMPurify . sanitize ( stopIcon , {
986+ RETURN_DOM_FRAGMENT : true
987+ } ) ) ;
981988 }
982989 if ( this . inputElement ) {
983990 this . inputElement . setAttribute ( 'disabled' , 'disabled' ) ;
@@ -986,7 +993,9 @@ window.openAIChatManager = function () {
986993 streamingFinished : function streamingFinished ( ) {
987994 var startIcon = this . buttonElement . getAttribute ( 'data-start-icon' ) ;
988995 if ( startIcon ) {
989- this . buttonElement . innerHTML = DOMPurify . sanitize ( startIcon ) ;
996+ this . buttonElement . replaceChildren ( DOMPurify . sanitize ( startIcon , {
997+ RETURN_DOM_FRAGMENT : true
998+ } ) ) ;
990999 }
9911000 if ( this . inputElement ) {
9921001 this . inputElement . removeAttribute ( 'disabled' ) ;
0 commit comments