fix(editor): invalidate turbo renderer on selection update (#10499)

This commit is contained in:
doodlewind
2025-02-28 08:08:28 +00:00
parent 90b37ce65c
commit f1df774188
2 changed files with 18 additions and 8 deletions

View File

@@ -27,6 +27,8 @@ const font = new FontFace(
// @ts-expect-error worker env
self.fonts && self.fonts.add(font);
const debugSentenceBoarder = false;
function getBaseline() {
const fontSize = 15;
const lineHeight = 1.2 * fontSize;
@@ -60,8 +62,6 @@ class LayoutPainter {
private clearBackground() {
if (!this.canvas || !this.ctx) return;
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.ctx.fillStyle = 'white';
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
}
paint(layout: ViewportLayout, version: number) {
@@ -94,7 +94,9 @@ class LayoutPainter {
// Only render if we haven't rendered at this position before
if (renderedPositions.has(posKey)) return;
ctx.strokeRect(x, y, textRect.rect.w, textRect.rect.h);
if (debugSentenceBoarder) {
ctx.strokeRect(x, y, textRect.rect.w, textRect.rect.h);
}
ctx.fillStyle = 'black';
ctx.fillText(textRect.text, x, y + baselineY);

View File

@@ -78,10 +78,10 @@ export class ViewportTurboRendererExtension extends LifeCycleWatcher {
});
this.disposables.add(
this.std.store.slots.blockUpdated.on(() => {
this.invalidate();
this.debouncedRefresh();
})
this.selection.slots.updated.on(() => this.invalidate())
);
this.disposables.add(
this.std.store.slots.blockUpdated.on(() => this.invalidate())
);
}
@@ -95,8 +95,16 @@ export class ViewportTurboRendererExtension extends LifeCycleWatcher {
this.setState('inactive');
}
get gfx() {
return this.std.get(GfxControllerIdentifier);
}
get viewport() {
return this.std.get(GfxControllerIdentifier).viewport;
return this.gfx.viewport;
}
get selection() {
return this.gfx.selection;
}
get layoutCache() {