From aedb7131b38c6b8e7b3804493419b9f8f0f4b771 Mon Sep 17 00:00:00 2001 From: frozenhelium Date: Mon, 5 Aug 2024 15:33:13 +0545 Subject: [PATCH] Fix captions in export --- .../scripts/components/documents/pdf-preview/index.js | 2 +- .../scripts/utils/apply-number-captions-to-document.js | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/assets/scripts/components/documents/pdf-preview/index.js b/app/assets/scripts/components/documents/pdf-preview/index.js index 8c621910..007c8777 100644 --- a/app/assets/scripts/components/documents/pdf-preview/index.js +++ b/app/assets/scripts/components/documents/pdf-preview/index.js @@ -243,7 +243,7 @@ function PdfPreview() { setDocument(applyNumberCaptionsToDocument(atbd.data.document)); waitForImages(); } - }, [atbd.status]); + }, [atbd.status, atbd.data]); // This useEffect is responsible for generating the ToC and numbering // after the document is transformed diff --git a/app/assets/scripts/utils/apply-number-captions-to-document.js b/app/assets/scripts/utils/apply-number-captions-to-document.js index 26cd4eec..0a7d5d16 100644 --- a/app/assets/scripts/utils/apply-number-captions-to-document.js +++ b/app/assets/scripts/utils/apply-number-captions-to-document.js @@ -1,4 +1,3 @@ -import get from 'lodash.get'; import { IMAGE_BLOCK, TABLE_BLOCK @@ -80,16 +79,9 @@ export function applyNumberCaptionsToDocument(document) { return c; } - const currentCaption = get(c, 'children[0].text'); - return { ...c, - children: [ - { - ...c.children[0], - text: `${captionPrefix}${currentCaption}` - } - ] + children: [{ text: captionPrefix }, ...c.children] }; });