This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,10 @@ function createEditContent(
95
95
body : `${ plainPrefix } * ${ body } ` ,
96
96
} ;
97
97
98
- const formattedBody = htmlSerializeIfNeeded ( model , { forceHTML : isReply } ) ;
98
+ const formattedBody = htmlSerializeIfNeeded ( model , {
99
+ forceHTML : isReply ,
100
+ useMarkdown : SettingsStore . getValue ( "MessageComposerInput.useMarkdown" ) ,
101
+ } ) ;
99
102
if ( formattedBody ) {
100
103
newContent . format = "org.matrix.custom.html" ;
101
104
newContent . formatted_body = formattedBody ;
Original file line number Diff line number Diff line change @@ -91,7 +91,10 @@ export function createMessageContent(
91
91
msgtype : isEmote ? "m.emote" : "m.text" ,
92
92
body : body ,
93
93
} ;
94
- const formattedBody = htmlSerializeIfNeeded ( model , { forceHTML : ! ! replyToEvent } ) ;
94
+ const formattedBody = htmlSerializeIfNeeded ( model , {
95
+ forceHTML : ! ! replyToEvent ,
96
+ useMarkdown : SettingsStore . getValue ( "MessageComposerInput.useMarkdown" ) ,
97
+ } ) ;
95
98
if ( formattedBody ) {
96
99
content . format = "org.matrix.custom.html" ;
97
100
content . formatted_body = formattedBody ;
Original file line number Diff line number Diff line change @@ -49,8 +49,16 @@ export function mdSerialize(model: EditorModel): string {
49
49
} , "" ) ;
50
50
}
51
51
52
- export function htmlSerializeIfNeeded ( model : EditorModel , { forceHTML = false } = { } ) : string {
53
- if ( ! SettingsStore . getValue ( "MessageComposerInput.useMarkdown" ) ) {
52
+ interface ISerializeOpts {
53
+ forceHTML ?: boolean ;
54
+ useMarkdown ?: boolean ;
55
+ }
56
+
57
+ export function htmlSerializeIfNeeded (
58
+ model : EditorModel ,
59
+ { forceHTML = false , useMarkdown = true } : ISerializeOpts = { } ,
60
+ ) : string {
61
+ if ( ! useMarkdown ) {
54
62
return escapeHtml ( textSerialize ( model ) ) . replace ( / \n / g, '<br/>' ) ;
55
63
}
56
64
You can’t perform that action at this time.
0 commit comments