📝(frontend) Add some docstrings

Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
This commit is contained in:
Mathieu Agopian
2026-09-04 10:07:25 +02:00
parent 0c477d5380
commit 08ff4a96e8
2 changed files with 20 additions and 0 deletions
@@ -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<DefaultProps & { caption: string; previewWidth: number }>,
) {
@@ -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<DefaultProps>,
colors: typeof COLORS_DEFAULT,