mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix(editor): invalidate turbo renderer on selection update (#10499)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user