@@ -16,30 +16,23 @@ const voidTypes = ['image'];
16
16
*/
17
17
const augmentProps = ( content : Node ) => {
18
18
const { children : childrenNodes , type, ...props } = content ;
19
- const getPlainText = ( children : typeof childrenNodes ) : string => {
20
- return children . reduce ( ( currentPlainText , node ) => {
21
- if ( node . type === 'text' ) {
22
- return currentPlainText . concat ( node . text ) ;
23
- }
24
19
25
- if ( node . type === 'link' ) {
26
- return currentPlainText . concat ( getPlainText ( node . children ) ) ;
27
- }
28
-
29
- return currentPlainText ;
30
- } , '' ) ;
31
- } ;
32
-
33
- if ( type === 'code' ) {
20
+ if ( type === 'code' || type === 'heading' ) {
34
21
// Builds a plain text string from an array of nodes, regardless of links or modifiers
22
+ const getPlainText = ( children : typeof childrenNodes ) : string => {
23
+ return children . reduce ( ( currentPlainText , node ) => {
24
+ if ( node . type === 'text' ) {
25
+ return currentPlainText . concat ( node . text ) ;
26
+ }
35
27
36
- return {
37
- ...props ,
38
- plainText : getPlainText ( content . children ) ,
28
+ if ( node . type === 'link' ) {
29
+ return currentPlainText . concat ( getPlainText ( node . children ) ) ;
30
+ }
31
+
32
+ return currentPlainText ;
33
+ } , '' ) ;
39
34
} ;
40
- }
41
35
42
- if ( type === 'heading' ) {
43
36
return {
44
37
...props ,
45
38
plainText : getPlainText ( content . children ) ,
0 commit comments