@@ -18,16 +18,16 @@ import { useSetState } from "@mantine/hooks";
1818import { Trans , useTranslation } from "react-i18next" ;
1919
2020const useStyles = createStyles ( ( theme ) => ( {
21- link :{
22- '&:hover' :{
23- color :theme . colors . merico [ 6 ]
24- }
21+ link : {
22+ "&:hover" : {
23+ color : theme . colors . merico [ 6 ] ,
2524 } ,
26- codeOverride :{
27- code :{
28- padding : "1px 0px !important" ,
29- }
30- }
25+ } ,
26+ codeOverride : {
27+ code : {
28+ padding : "1px 0px !important" ,
29+ } ,
30+ } ,
3131} ) ) ;
3232interface MessageMarkdownProps
3333 extends React . ComponentProps < typeof ReactMarkdown > {
@@ -280,87 +280,109 @@ Generate a professionally written and formatted release note in markdown with th
280280 wrapLongLines = true ;
281281 }
282282
283- if ( lanugage === 'step' || lanugage === 'Step' ) {
284- let done = Number ( index ) < codes . length ? true : lastNode . type !== 'code' ;
285- return < Step language = { lanugage } done = { temp ?done :true } index = { index } > { value } </ Step > ;
286- }
283+ if ( lanugage === "step" || lanugage === "Step" ) {
284+ let done =
285+ Number ( index ) < codes . length ? true : lastNode . type !== "code" ;
286+ return (
287+ < Step language = { lanugage } done = { temp ? done : true } index = { index } >
288+ { value }
289+ </ Step >
290+ ) ;
291+ }
287292
288- if ( lanugage === 'chatmark' || lanugage === 'ChatMark' ) {
289- const chatmarkValue = chatmarkValues [ `chatmark-${ index } ` ] ;
290- return < ChatMark value = { chatmarkValue } messageDone = { messageDone } > { value } </ ChatMark > ;
291- }
293+ if ( lanugage === "chatmark" || lanugage === "ChatMark" ) {
294+ const chatmarkValue = chatmarkValues [ `chatmark-${ index } ` ] ;
295+ return (
296+ < ChatMark value = { chatmarkValue } messageDone = { messageDone } >
297+ { value }
298+ </ ChatMark >
299+ ) ;
300+ }
292301
293302 if ( ( lanugage === "yaml" || lanugage === "YAML" ) && props . hidden ) {
294303 return < > </ > ;
295304 }
296305
297- return ! inline && lanugage ? (
298- < div style = { { position : 'relative' } } className = { classes . codeOverride } >
299- < LanguageCorner language = { lanugage } />
300- < CodeButtons language = { lanugage } code = { value } />
301- < SyntaxHighlighter { ...props }
302- language = { lanugage }
303- customStyle = { { padding : '35px 10px 10px 10px' } }
304- style = { okaidia }
305- wrapLongLines = { wrapLongLines }
306- PreTag = "div" >
307- { value }
308- </ SyntaxHighlighter >
309- </ div >
310- ) : (
311- < code { ...props } className = { className } >
312- { children }
313- </ code >
314- ) ;
315- } ,
316- button ( { node, className, children, value, ...props } ) {
317- return (
318- < Button
319- size = "compact-xs"
320- sx = { {
321- backgroundColor :"#ED6A45" ,
322- fontFamily : 'var(--vscode-editor-font-familyy)' ,
323- fontSize : 'var(--vscode-editor-font-size)' ,
324- color :"#fff" ,
325- "&:hover" :{
326- backgroundColor :"#ED6A45" ,
327- opacity : 0.8 ,
328- } ,
329- "&:focus" :{
330- backgroundColor :"#ED6A45" ,
331- opacity : 0.8 ,
332- }
333- } }
334- onClick = { ( ) => {
335- handleButton ( value ) ;
336- } } >
337- { children }
338- </ Button >
339- ) ;
340- } ,
341- a ( { node, className, children, href, ...props } ) {
342- const customAnchors = [ "#code" ,
343- "#commit_message" ,
344- "#release_note" ,
345- "#ask_code" ,
346- "#extension" ,
347- "#settings" ] . filter ( ( item ) => item === href ) ;
348- return customAnchors . length > 0
349- ? < Anchor
350- className = { classes . link }
351- href = { href } onClick = { ( ) => {
352- handleExplain ( href ) ;
353- } } >
354- { children }
355- </ Anchor >
356- : < a { ...props } href = { href } className = { className } >
357- { children }
358- </ a > ;
359- }
360- }
361- } >
362- { children }
363- </ ReactMarkdown > ;
306+ return ! inline && lanugage ? (
307+ < div
308+ style = { { position : "relative" } }
309+ className = { classes . codeOverride }
310+ >
311+ < LanguageCorner language = { lanugage } />
312+ < CodeButtons language = { lanugage } code = { value } />
313+ < SyntaxHighlighter
314+ { ...props }
315+ language = { lanugage }
316+ customStyle = { { padding : "35px 10px 10px 10px" } }
317+ style = { okaidia }
318+ wrapLongLines = { wrapLongLines }
319+ PreTag = "div"
320+ >
321+ { value }
322+ </ SyntaxHighlighter >
323+ </ div >
324+ ) : (
325+ < code { ...props } className = { className } >
326+ { children }
327+ </ code >
328+ ) ;
329+ } ,
330+ button ( { node, className, children, value, ...props } ) {
331+ return (
332+ < Button
333+ size = "compact-xs"
334+ sx = { {
335+ backgroundColor : "#ED6A45" ,
336+ fontFamily : "var(--vscode-editor-font-familyy)" ,
337+ fontSize : "var(--vscode-editor-font-size)" ,
338+ color : "#fff" ,
339+ "&:hover" : {
340+ backgroundColor : "#ED6A45" ,
341+ opacity : 0.8 ,
342+ } ,
343+ "&:focus" : {
344+ backgroundColor : "#ED6A45" ,
345+ opacity : 0.8 ,
346+ } ,
347+ } }
348+ onClick = { ( ) => {
349+ handleButton ( value ) ;
350+ } }
351+ >
352+ { children }
353+ </ Button >
354+ ) ;
355+ } ,
356+ a ( { node, className, children, href, ...props } ) {
357+ const customAnchors = [
358+ "#code" ,
359+ "#commit_message" ,
360+ "#release_note" ,
361+ "#ask_code" ,
362+ "#extension" ,
363+ "#settings" ,
364+ ] . filter ( ( item ) => item === href ) ;
365+ return customAnchors . length > 0 ? (
366+ < Anchor
367+ className = { classes . link }
368+ href = { href }
369+ onClick = { ( ) => {
370+ handleExplain ( href ) ;
371+ } }
372+ >
373+ { children }
374+ </ Anchor >
375+ ) : (
376+ < a { ...props } href = { href } className = { className } >
377+ { children }
378+ </ a >
379+ ) ;
380+ } ,
381+ } }
382+ >
383+ { children }
384+ </ ReactMarkdown >
385+ ) ;
364386} ) ;
365387
366388export default MessageMarkdown ;
0 commit comments