File tree Expand file tree Collapse file tree 6 files changed +32
-7
lines changed
Expand file tree Collapse file tree 6 files changed +32
-7
lines changed Original file line number Diff line number Diff line change 20212021 "example" : 25
20222022 },
20232023 "message" : {
2024- "description" : " The actual message." ,
2024+ "description" : " The message. Markdown (excluding html) is allowed ." ,
20252025 "type" : " string" ,
20262026 "x-go-name" : " Message" ,
2027- "example" : " Backup was successfully finished."
2027+ "example" : " ** Backup** was successfully finished."
20282028 },
20292029 "priority" : {
20302030 "description" : " The priority of the message." ,
Original file line number Diff line number Diff line change @@ -33,10 +33,10 @@ type MessageExternal struct {
3333 // required: true
3434 // example: 5
3535 ApplicationID uint `json:"appid"`
36- // The actual message.
36+ // The message. Markdown (excluding html) is allowed .
3737 //
3838 // required: true
39- // example: Backup was successfully finished.
39+ // example: ** Backup** was successfully finished.
4040 Message string `form:"message" query:"message" json:"message" binding:"required"`
4141 // The title of the message.
4242 //
Original file line number Diff line number Diff line change 2323 "react-router" : " ^4.3.1" ,
2424 "react-router-dom" : " ^4.3.1" ,
2525 "react-timeago" : " ^4.1.9" ,
26+ "remove-markdown" : " ^0.3.0" ,
2627 "typeface-roboto" : " 0.0.54"
2728 },
2829 "scripts" : {
4950 "@types/react-dom" : " ^16.0.7" ,
5051 "@types/react-infinite" : " 0.0.33" ,
5152 "@types/react-router-dom" : " ^4.3.0" ,
53+ "@types/remove-markdown" : " ^0.1.1" ,
5254 "@types/rimraf" : " ^2.0.2" ,
5355 "get-port" : " ^4.0.0" ,
5456 "prettier" : " ^1.14.2" ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import TimeAgo from 'react-timeago';
77import Container from '../common/Container' ;
88import * as config from '../config' ;
99import { StyleRulesCallback } from '@material-ui/core/styles/withStyles' ;
10+ import ReactMarkdown from 'react-markdown' ;
1011
1112const styles : StyleRulesCallback = ( ) => ( {
1213 header : {
@@ -24,6 +25,7 @@ const styles: StyleRulesCallback = () => ({
2425 } ,
2526 messageContentWrapper : {
2627 width : '100%' ,
28+ maxWidth : 585 ,
2729 } ,
2830 image : {
2931 marginRight : 15 ,
@@ -33,6 +35,15 @@ const styles: StyleRulesCallback = () => ({
3335 } ,
3436 content : {
3537 whiteSpace : 'pre-wrap' ,
38+ '& p' : {
39+ margin : 0 ,
40+ } ,
41+ '& a' : {
42+ color : '#ff7f50' ,
43+ } ,
44+ '& pre' : {
45+ overflow : 'auto' ,
46+ } ,
3647 } ,
3748} ) ;
3849
@@ -81,8 +92,8 @@ class Message extends React.PureComponent<IProps & WithStyles<typeof styles>> {
8192 < Delete />
8293 </ IconButton >
8394 </ div >
84- < Typography component = "p " className = { `${ classes . content } content` } >
85- { content }
95+ < Typography component = "div " className = { `${ classes . content } content` } >
96+ < ReactMarkdown source = { content } escapeHtml = { true } />
8697 </ Typography >
8798 </ div >
8899 </ Container >
Original file line number Diff line number Diff line change 11import Notify from 'notifyjs' ;
2+ import removeMarkdown from 'remove-markdown' ;
23
34export function requestPermission ( ) {
45 if ( Notify . needsPermission && Notify . isSupported ( ) ) {
@@ -11,7 +12,7 @@ export function requestPermission() {
1112
1213export function notifyNewMessage ( msg : IMessage ) {
1314 const notify = new Notify ( msg . title , {
14- body : msg . message ,
15+ body : removeMarkdown ( msg . message ) ,
1516 icon : msg . image ,
1617 notifyClick : closeAndFocus ,
1718 notifyShow : closeAfterTimeout ,
You can’t perform that action at this time.
0 commit comments