File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed
packages/serializer-md/src/serializer Expand file tree Collapse file tree 2 files changed +15
-13
lines changed 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 {
11
11
serializeMdNode ,
12
12
} from './serializeMdNode' ;
13
13
14
- const trimNewlines = ( str ?: string ) => str ?. replace ( / ^ \s + | \s + $ / g, '' ) ?? '' ;
15
-
16
14
/** Convert Slate nodes to Markdown. */
17
15
export const serializeMdNodes = (
18
16
nodes : TDescendant [ ] ,
@@ -51,15 +49,14 @@ export const serializeMdNodes = (
51
49
return '' ;
52
50
}
53
51
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 ( ) ;
65
62
} ;
You can’t perform that action at this time.
0 commit comments