fix(bbb-export-annotations): handle missing textbox size in Tldraw (#19672)

This commit is contained in:
Daniel Petri Rocha 2024-02-24 02:20:16 +01:00 committed by GitHub
parent 95d013d645
commit 80d4bdbfef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -703,6 +703,10 @@ function overlay_triangle(svg, annotation) {
} }
function overlay_text(svg, annotation) { function overlay_text(svg, annotation) {
if (annotation.size == null || annotation.size.length < 2) {
return
}
const [textBoxWidth, textBoxHeight] = annotation.size; const [textBoxWidth, textBoxHeight] = annotation.size;
const fontColor = color_to_hex(annotation.style.color); const fontColor = color_to_hex(annotation.style.color);
const font = determine_font_from_family(annotation.style.font); const font = determine_font_from_family(annotation.style.font);
@ -731,30 +735,34 @@ function overlay_text(svg, annotation) {
} }
function overlay_annotation(svg, currentAnnotation) { function overlay_annotation(svg, currentAnnotation) {
switch (currentAnnotation.type) { try {
case 'arrow': switch (currentAnnotation.type) {
overlay_arrow(svg, currentAnnotation); case 'arrow':
break; overlay_arrow(svg, currentAnnotation);
case 'draw': break;
overlay_draw(svg, currentAnnotation); case 'draw':
break; overlay_draw(svg, currentAnnotation);
case 'ellipse': break;
overlay_ellipse(svg, currentAnnotation); case 'ellipse':
break; overlay_ellipse(svg, currentAnnotation);
case 'rectangle': break;
overlay_rectangle(svg, currentAnnotation); case 'rectangle':
break; overlay_rectangle(svg, currentAnnotation);
case 'sticky': break;
overlay_sticky(svg, currentAnnotation); case 'sticky':
break; overlay_sticky(svg, currentAnnotation);
case 'triangle': break;
overlay_triangle(svg, currentAnnotation); case 'triangle':
break; overlay_triangle(svg, currentAnnotation);
case 'text': break;
overlay_text(svg, currentAnnotation); case 'text':
break; overlay_text(svg, currentAnnotation);
default: break;
logger.info(`Unknown annotation type ${currentAnnotation.type}.`); default:
logger.info(`Unknown annotation type ${currentAnnotation.type}.`);
}
} catch (error) {
logger.warn("Failed to overlay annotation", { failedAnnotation: currentAnnotation, error: error });
} }
} }