UNPKG

@wordpress/core-data

Version:
28 lines (27 loc) 783 B
// packages/core-data/src/footnotes/get-footnotes-order.js import getRichTextValuesCached from "./get-rich-text-values-cached.mjs"; var cache = /* @__PURE__ */ new WeakMap(); function getBlockFootnotesOrder(block) { if (!cache.has(block)) { const order = []; for (const value of getRichTextValuesCached(block)) { if (!value) { continue; } value.replacements.forEach(({ type, attributes }) => { if (type === "core/footnote") { order.push(attributes["data-fn"]); } }); } cache.set(block, order); } return cache.get(block); } function getFootnotesOrder(blocks) { return blocks.flatMap(getBlockFootnotesOrder); } export { getFootnotesOrder as default }; //# sourceMappingURL=get-footnotes-order.mjs.map