@@ -15,9 +15,9 @@ export function makeHighlightBlocks(
15
15
const items = Children . toArray ( children ) ;
16
16
17
17
let highlightedLineElements : ReactElement [ ] = [ ] ;
18
- const highlightElementGroupCounter = 0 ;
18
+ let highlightElementGroupCounter = 0 ;
19
19
20
- return items . reduce ( ( arr : ChildrenItem [ ] , child ) => {
20
+ return items . reduce ( ( arr : ChildrenItem [ ] , child , index ) => {
21
21
if ( typeof child !== 'object' ) {
22
22
arr . push ( child ) ;
23
23
return arr ;
@@ -30,7 +30,7 @@ export function makeHighlightBlocks(
30
30
if ( ! isCodeLine ) {
31
31
const updatedChild = cloneElement (
32
32
child as ReactElement ,
33
- { } ,
33
+ element . props ,
34
34
makeHighlightBlocks ( ( child as ReactElement ) . props . children , language )
35
35
) ;
36
36
arr . push ( updatedChild ) ;
@@ -44,11 +44,12 @@ export function makeHighlightBlocks(
44
44
} else {
45
45
if ( highlightedLineElements . length > 0 ) {
46
46
arr . push (
47
- < HighlightBlock groupId = { highlightElementGroupCounter } language = { language } >
47
+ < HighlightBlock groupId = { highlightElementGroupCounter } key = { highlightElementGroupCounter } language = { language } >
48
48
{ ...highlightedLineElements }
49
49
</ HighlightBlock >
50
50
) ;
51
51
highlightedLineElements = [ ] ;
52
+ ++ highlightElementGroupCounter ;
52
53
}
53
54
arr . push ( child ) ;
54
55
}
@@ -98,7 +99,7 @@ export function HighlightBlock({
98
99
}
99
100
100
101
return (
101
- < HighlightBlockContainer key = { `highlight-block- ${ groupId } ` } >
102
+ < HighlightBlockContainer >
102
103
< CodeLinesContainer ref = { codeRef } > { children } </ CodeLinesContainer >
103
104
< ClipBoardContainer onClick = { copyCodeOnClick } className = ".clipboard" >
104
105
{ showCopyButton && (
0 commit comments