From fa2757f2824cdced7ecf6d2d7c0d7eae4e8604ea Mon Sep 17 00:00:00 2001 From: Mathieu Agopian Date: Wed, 2 Sep 2026 14:55:05 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D(frontend)=20Add=20some=20docstring?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add docstrings to improve code documentation and clarity. Signed-off-by: Mathieu Agopian --- .../docs/doc-export/blocks-mapping/imagePDF.tsx | 6 ++++++ .../impress/src/features/docs/doc-export/utils.ts | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imagePDF.tsx b/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imagePDF.tsx index 9db1237a3..b17d18747 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imagePDF.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imagePDF.tsx @@ -70,6 +70,12 @@ export const blockMappingImagePDF: DocsExporterPDF['mappings']['blockMapping'][' ); }; +/** + * Renders an optional caption below an image in the PDF. + * + * @param props - Block props that may include a caption string and previewWidth. + * @returns A react-pdf Text element, or undefined when no caption is set. + */ function caption( props: Partial, ) { diff --git a/src/frontend/apps/impress/src/features/docs/doc-export/utils.ts b/src/frontend/apps/impress/src/features/docs/doc-export/utils.ts index 92685ae7c..af2b5ede6 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-export/utils.ts +++ b/src/frontend/apps/impress/src/features/docs/doc-export/utils.ts @@ -7,6 +7,12 @@ import { Canvg } from 'canvg'; import { IParagraphOptions, ShadingType } from 'docx'; import React from 'react'; +/** + * Triggers a browser download of a Blob with the given filename. + * + * @param blob - The data to download. + * @param filename - The name the downloaded file should have. + */ export function downloadFile(blob: Blob, filename: string) { const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); @@ -142,6 +148,14 @@ export async function convertBlobToPng( } } +/** + * Converts BlockNote block props (background color, text color, alignment) + * into a docx IParagraphOptions object for use with the docx exporter. + * + * @param props - Partial BlockNote default props. + * @param colors - The color palette to resolve named colors. + * @returns A docx paragraph options object with shading, run color, and alignment. + */ export function docxBlockPropsToStyles( props: Partial, colors: typeof COLORS_DEFAULT,