fix(editor): workaround empty content in worker renderer (#10043)

This commit is contained in:
doodlewind
2025-02-10 03:35:50 +00:00
parent 92f4f0c2d9
commit 614ae024c2
2 changed files with 8 additions and 2 deletions

View File

@@ -94,13 +94,15 @@ export class CanvasRenderer {
sectionMinX,
sectionMinY,
]);
const w = (sectionMaxX - sectionMinX) / zoom / viewport.viewScale;
const h = (sectionMaxY - sectionMinY) / zoom / viewport.viewScale;
const section: SectionLayout = {
paragraphs,
rect: {
x: sectionModelCoord[0],
y: sectionModelCoord[1],
w: (sectionMaxX - sectionMinX) / zoom / viewport.viewScale,
h: (sectionMaxY - sectionMinY) / zoom / viewport.viewScale,
w: Math.max(w, 0),
h: Math.max(h, 0),
},
};

View File

@@ -65,6 +65,10 @@ class SectionPainter {
paint(section: SectionLayout) {
const { canvas, ctx } = this;
if (!canvas || !ctx) return;
if (section.rect.w === 0 || section.rect.h === 0) {
console.warn('empty section rect');
return;
}
ctx.scale(this.zoom, this.zoom);