mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 18:09:58 +08:00
fix(editor): workaround empty content in worker renderer (#10043)
This commit is contained in:
@@ -94,13 +94,15 @@ export class CanvasRenderer {
|
|||||||
sectionMinX,
|
sectionMinX,
|
||||||
sectionMinY,
|
sectionMinY,
|
||||||
]);
|
]);
|
||||||
|
const w = (sectionMaxX - sectionMinX) / zoom / viewport.viewScale;
|
||||||
|
const h = (sectionMaxY - sectionMinY) / zoom / viewport.viewScale;
|
||||||
const section: SectionLayout = {
|
const section: SectionLayout = {
|
||||||
paragraphs,
|
paragraphs,
|
||||||
rect: {
|
rect: {
|
||||||
x: sectionModelCoord[0],
|
x: sectionModelCoord[0],
|
||||||
y: sectionModelCoord[1],
|
y: sectionModelCoord[1],
|
||||||
w: (sectionMaxX - sectionMinX) / zoom / viewport.viewScale,
|
w: Math.max(w, 0),
|
||||||
h: (sectionMaxY - sectionMinY) / zoom / viewport.viewScale,
|
h: Math.max(h, 0),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ class SectionPainter {
|
|||||||
paint(section: SectionLayout) {
|
paint(section: SectionLayout) {
|
||||||
const { canvas, ctx } = this;
|
const { canvas, ctx } = this;
|
||||||
if (!canvas || !ctx) return;
|
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);
|
ctx.scale(this.zoom, this.zoom);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user