File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -108,28 +108,28 @@ function _cleanDoc(doc: JSONContent) {
108108 }
109109
110110 // Trim leading/trailing hardBreaks within first and last paragraphs
111- const trimHardBreaks = ( paragraph : JSONContent ) => {
111+ const trimHardBreaks = ( paragraph : JSONContent , start : boolean , end : boolean ) => {
112112 if ( ! paragraph . content ) return paragraph ;
113113
114114 let nodes = [ ...paragraph . content ] ;
115115
116116 // Remove hardBreaks at the start
117- while ( nodes . length > 0 && nodes [ 0 ] . type === "hardBreak" ) {
117+ while ( start && nodes . length > 0 && nodes [ 0 ] . type === "hardBreak" ) {
118118 nodes . shift ( ) ;
119119 }
120120
121121 // Remove hardBreaks at the end
122- while ( nodes . length > 0 && nodes [ nodes . length - 1 ] . type === "hardBreak" ) {
122+ while ( end && nodes . length > 0 && nodes [ nodes . length - 1 ] . type === "hardBreak" ) {
123123 nodes . pop ( ) ;
124124 }
125125
126126 return { ...paragraph , content : nodes } ;
127127 } ;
128128
129129 if ( content . length > 0 ) {
130- content [ 0 ] = trimHardBreaks ( content [ 0 ] ) ;
130+ content [ 0 ] = trimHardBreaks ( content [ 0 ] , true , false ) ;
131131 if ( content . length > 1 ) {
132- content [ content . length - 1 ] = trimHardBreaks ( content [ content . length - 1 ] ) ;
132+ content [ content . length - 1 ] = trimHardBreaks ( content [ content . length - 1 ] , false , true ) ;
133133 }
134134 }
135135
Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ export const PrivateChat = (props: {
185185
186186 try {
187187 const content = cleanDoc ( editor . getJSON ( ) )
188- // console.log('submitting message' , JSON.stringify(content))
188+ // console.log('submitting message\n', JSON.stringify(editor.getJSON()) , JSON.stringify(content))
189189 if ( editingMessage ) {
190190 // console.log('editingMessage edit-message', editingMessage)
191191 setMessages ( ( prevMessages ) =>
You can’t perform that action at this time.
0 commit comments