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(
9595 body : `${ plainPrefix } * ${ body } ` ,
9696 } ;
9797
98- const formattedBody = htmlSerializeIfNeeded ( model , { forceHTML : isReply } ) ;
98+ const formattedBody = htmlSerializeIfNeeded ( model , {
99+ forceHTML : isReply ,
100+ useMarkdown : SettingsStore . getValue ( "MessageComposerInput.useMarkdown" ) ,
101+ } ) ;
99102 if ( formattedBody ) {
100103 newContent . format = "org.matrix.custom.html" ;
101104 newContent . formatted_body = formattedBody ;
Original file line number Diff line number Diff line change @@ -91,7 +91,10 @@ export function createMessageContent(
9191 msgtype : isEmote ? "m.emote" : "m.text" ,
9292 body : body ,
9393 } ;
94- const formattedBody = htmlSerializeIfNeeded ( model , { forceHTML : ! ! replyToEvent } ) ;
94+ const formattedBody = htmlSerializeIfNeeded ( model , {
95+ forceHTML : ! ! replyToEvent ,
96+ useMarkdown : SettingsStore . getValue ( "MessageComposerInput.useMarkdown" ) ,
97+ } ) ;
9598 if ( formattedBody ) {
9699 content . format = "org.matrix.custom.html" ;
97100 content . formatted_body = formattedBody ;
Original file line number Diff line number Diff line change @@ -49,8 +49,16 @@ export function mdSerialize(model: EditorModel): string {
4949 } , "" ) ;
5050}
5151
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 ) {
5462 return escapeHtml ( textSerialize ( model ) ) . replace ( / \n / g, '<br/>' ) ;
5563 }
5664
You can’t perform that action at this time.
0 commit comments