Skip to content

Commit

Permalink
Move getFootnotesOrder computation to the block level
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf committed Jul 12, 2023
1 parent 4909a4c commit 1b49eb6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/core-data/src/footnotes/get-footnotes-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
*/
import getRichTextValuesCached from './get-rich-text-values-cached';

export default function getFootnotesOrder( blocks ) {
const values = blocks.map( getRichTextValuesCached );
const content = values.join( '' );

function getBlockFootnotesOrder( block ) {
const content = getRichTextValuesCached( block ).join( '' );
const newOrder = [];

// This can be avoided when
// https://github.com/WordPress/gutenberg/pull/43204 lands. We can then
// get the order directly from the rich text values.
if ( content.indexOf( 'data-fn' ) !== -1 ) {
Expand All @@ -22,3 +19,7 @@ export default function getFootnotesOrder( blocks ) {

return newOrder;
}

export default function getFootnotesOrder( blocks ) {
return blocks.flatMap( getBlockFootnotesOrder );
}

0 comments on commit 1b49eb6

Please sign in to comment.