@@ -5,6 +5,9 @@ import MessageHeader from "./EditMessageHeader.vue";
55import { EditAndRetryConfig } from " @/resources/Configuration" ;
66import type Header from " @/resources/Header" ;
77import { ExtendedFailedMessage } from " @/resources/FailedMessage" ;
8+ import parseContentType from " @/composables/contentTypeParser" ;
9+ import { CodeLanguage } from " @/components/codeEditorTypes" ;
10+ import CodeEditor from " @/components/CodeEditor.vue" ;
811
912interface HeaderWithEditing extends Header {
1013 isLocked: boolean ;
@@ -28,6 +31,7 @@ interface LocalMessageState {
2831 isBodyChanged: boolean ;
2932 isBodyEmpty: boolean ;
3033 isContentTypeSupported: boolean ;
34+ language? : CodeLanguage ;
3135 bodyContentType: string | undefined ;
3236 bodyUnavailable: boolean ;
3337 isEvent: boolean ;
@@ -104,30 +108,6 @@ function getContentType() {
104108 return header ?.value ;
105109}
106110
107- function isContentTypeSupported(contentType : string | undefined ) {
108- if (contentType === undefined ) return false ;
109-
110- if (contentType .startsWith (" text/" )) return true ;
111-
112- const charsetUtf8 = " ; charset=utf-8" ;
113-
114- if (contentType .endsWith (charsetUtf8 )) {
115- contentType = contentType .substring (0 , contentType .length - charsetUtf8 .length );
116- }
117-
118- if (contentType === " application/json" ) return true ;
119-
120- if (contentType .startsWith (" application/" )) {
121- // Some examples:
122- // application/atom+xml
123- // application/ld+json
124- // application/vnd.masstransit+json
125- if (contentType .endsWith (" +json" ) || contentType .endsWith (" +xml" )) return true ;
126- }
127-
128- return false ;
129- }
130-
131111function getMessageIntent() {
132112 const intent = findHeadersByKey (" NServiceBus.MessageIntent" );
133113 return intent ?.value ;
@@ -167,7 +147,9 @@ function initializeMessageBodyAndHeaders() {
167147
168148 const contentType = getContentType ();
169149 localMessage .value .bodyContentType = contentType ;
170- localMessage .value .isContentTypeSupported = isContentTypeSupported (contentType );
150+ const parsedContentType = parseContentType (contentType );
151+ localMessage .value .isContentTypeSupported = parsedContentType .isSupported ;
152+ localMessage .value .language = parsedContentType .language ;
171153
172154 const messageIntent = getMessageIntent ();
173155 localMessage .value .isEvent = messageIntent === " Publish" ;
@@ -248,7 +230,9 @@ onMounted(() => {
248230 </tbody >
249231 </table >
250232 <div role =" tabpanel" v-if =" panel === 2 && !localMessage.bodyUnavailable" style =" height : calc (100% - 260px )" >
251- <textarea aria-label =" message body" class =" form-control" :disabled =" !localMessage.isContentTypeSupported" v-model =" localMessage.messageBody" ></textarea >
233+ <div style =" margin-top : 1.25rem " >
234+ <CodeEditor aria-label =" message body" :read-only =" !localMessage.isContentTypeSupported" v-model =" localMessage.messageBody" :language =" localMessage.language" :show-gutter =" true" ></CodeEditor >
235+ </div >
252236 <span class =" empty-error" v-if =" localMessage.isBodyEmpty" ><i class =" fa fa-exclamation-triangle" ></i > Message body cannot be empty</span >
253237 <span class =" reset-body" v-if =" localMessage.isBodyChanged" ><i class =" fa fa-undo" v-tippy =" `Reset changes`" ></i > <a @click =" resetBodyChanges()" href =" javascript:void(0)" >Reset changes</a ></span >
254238 <div class =" alert alert-info" v-if =" panel === 2 && localMessage.bodyUnavailable" >{{ localMessage.bodyUnavailable }}</div >
@@ -369,9 +353,4 @@ onMounted(() => {
369353 overflow-y : auto ;
370354 padding-right : 15px ;
371355}
372-
373- .modal-msg-editor :deep(textarea ) {
374- height : 100% ;
375- margin-top : 20px ;
376- }
377356 </style >
0 commit comments