Skip to content

Commit

Permalink
fix(bbb-export-annotations): handle missing textbox size in Tldraw (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpetri1 committed Feb 24, 2024
1 parent 95d013d commit 80d4bdb
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions bbb-export-annotations/workers/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
}
}

Expand Down

0 comments on commit 80d4bdb

Please sign in to comment.