mirror of
https://github.com/suitenumerique/docs.git
synced 2026-09-10 11:47:52 +02:00
📝(frontend) Add some docstrings
Add docstrings to improve code documentation and clarity. Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user