File tree Expand file tree Collapse file tree
packages/serializer-md/src/serializer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @udecode/plate-serializer-md " : patch
3+ ---
4+
5+ Replace potentially inefficient RegExp with String.trim()
Original file line number Diff line number Diff line change @@ -11,8 +11,6 @@ import {
1111 serializeMdNode ,
1212} from './serializeMdNode' ;
1313
14- const trimNewlines = ( str ?: string ) => str ?. replace ( / ^ \s + | \s + $ / g, '' ) ?? '' ;
15-
1614/** Convert Slate nodes to Markdown. */
1715export const serializeMdNodes = (
1816 nodes : TDescendant [ ] ,
@@ -51,15 +49,14 @@ export const serializeMdNodes = (
5149 return '' ;
5250 }
5351
54- return trimNewlines (
55- nodes
56- ?. map ( ( v ) =>
57- serializeMdNode ( v , {
58- ...options ,
59- customNodes : options . customNodes as any ,
60- nodes : optionsNodes ,
61- } )
62- )
63- . join ( '' )
64- ) ;
52+ return nodes
53+ ?. map ( ( v ) =>
54+ serializeMdNode ( v , {
55+ ...options ,
56+ customNodes : options . customNodes as any ,
57+ nodes : optionsNodes ,
58+ } )
59+ )
60+ . join ( '' )
61+ . trim ( ) ;
6562} ;
You can’t perform that action at this time.
0 commit comments