From 80d4bdbfefc44f30040026821d0cb13480532d86 Mon Sep 17 00:00:00 2001 From: Daniel Petri Rocha <33319791+danielpetri1@users.noreply.github.com> Date: Sat, 24 Feb 2024 02:20:16 +0100 Subject: [PATCH] fix(bbb-export-annotations): handle missing textbox size in Tldraw (#19672) --- bbb-export-annotations/workers/process.js | 56 +++++++++++++---------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/bbb-export-annotations/workers/process.js b/bbb-export-annotations/workers/process.js index 9f61d22050..f8ce932c46 100644 --- a/bbb-export-annotations/workers/process.js +++ b/bbb-export-annotations/workers/process.js @@ -703,6 +703,10 @@ function overlay_triangle(svg, annotation) { } function overlay_text(svg, annotation) { + if (annotation.size == null || annotation.size.length < 2) { + return + } + const [textBoxWidth, textBoxHeight] = annotation.size; const fontColor = color_to_hex(annotation.style.color); const font = determine_font_from_family(annotation.style.font); @@ -731,30 +735,34 @@ function overlay_text(svg, annotation) { } function overlay_annotation(svg, currentAnnotation) { - switch (currentAnnotation.type) { - case 'arrow': - overlay_arrow(svg, currentAnnotation); - break; - case 'draw': - overlay_draw(svg, currentAnnotation); - break; - case 'ellipse': - overlay_ellipse(svg, currentAnnotation); - break; - case 'rectangle': - overlay_rectangle(svg, currentAnnotation); - break; - case 'sticky': - overlay_sticky(svg, currentAnnotation); - break; - case 'triangle': - overlay_triangle(svg, currentAnnotation); - break; - case 'text': - overlay_text(svg, currentAnnotation); - break; - default: - logger.info(`Unknown annotation type ${currentAnnotation.type}.`); + try { + switch (currentAnnotation.type) { + case 'arrow': + overlay_arrow(svg, currentAnnotation); + break; + case 'draw': + overlay_draw(svg, currentAnnotation); + break; + case 'ellipse': + overlay_ellipse(svg, currentAnnotation); + break; + case 'rectangle': + overlay_rectangle(svg, currentAnnotation); + break; + case 'sticky': + overlay_sticky(svg, currentAnnotation); + break; + case 'triangle': + overlay_triangle(svg, currentAnnotation); + break; + case 'text': + overlay_text(svg, currentAnnotation); + break; + default: + logger.info(`Unknown annotation type ${currentAnnotation.type}.`); + } + } catch (error) { + logger.warn("Failed to overlay annotation", { failedAnnotation: currentAnnotation, error: error }); } }