File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,25 @@ const { getRichTextValues } = unlock( blockEditorPrivateApis );
1212
1313let oldFootnotes = { } ;
1414
15+ const cache = new WeakMap ( ) ;
16+
17+ function getRichTextValuesCached ( block ) {
18+ if ( ! cache . has ( block ) ) {
19+ const values = getRichTextValues ( [ block ] ) ;
20+ cache . set ( block , values ) ;
21+ }
22+ return cache . get ( block ) ;
23+ }
24+
1525export function updateFootnotesFromMeta ( blocks , meta ) {
1626 const output = { blocks } ;
1727 if ( ! meta ) return output ;
28+
1829 // If meta.footnotes is empty, it means the meta is not registered.
1930 if ( meta . footnotes === undefined ) return output ;
2031
21- const _content = getRichTextValues ( blocks ) . join ( '' ) || '' ;
32+ const _content = blocks . map ( getRichTextValuesCached ) . join ( '' ) ;
33+
2234 const newOrder = [ ] ;
2335
2436 // This can be avoided when
You can’t perform that action at this time.
0 commit comments