mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
fix(editor): background of surface-ref disappeared when it was re-rendered (#10931)
This PR fixed the background of surface-ref dis
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
|||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
import { css, html } from 'lit';
|
import { css, html } from 'lit';
|
||||||
import { query, state } from 'lit/decorators.js';
|
import { query, state } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import type { EdgelessRootBlockWidgetName } from '../types.js';
|
import type { EdgelessRootBlockWidgetName } from '../types.js';
|
||||||
import type { EdgelessRootService } from './edgeless-root-service.js';
|
import type { EdgelessRootService } from './edgeless-root-service.js';
|
||||||
@@ -68,19 +68,15 @@ export class EdgelessRootPreviewBlockComponent extends BlockComponent<
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@query('.edgeless-background')
|
|
||||||
accessor background!: HTMLDivElement;
|
|
||||||
|
|
||||||
private readonly _refreshLayerViewport = requestThrottledConnectedFrame(
|
private readonly _refreshLayerViewport = requestThrottledConnectedFrame(
|
||||||
() => {
|
() => {
|
||||||
const { zoom, translateX, translateY } = this.service.viewport;
|
const { zoom, translateX, translateY } = this.service.viewport;
|
||||||
const gap = getBgGridGap(zoom);
|
const gap = getBgGridGap(zoom);
|
||||||
|
|
||||||
this.background.style.setProperty(
|
this.backgroundStyle = {
|
||||||
'background-position',
|
backgroundPosition: `${translateX}px ${translateY}px`,
|
||||||
`${translateX}px ${translateY}px`
|
backgroundSize: `${gap}px ${gap}px`,
|
||||||
);
|
};
|
||||||
this.background.style.setProperty('background-size', `${gap}px ${gap}px`);
|
|
||||||
},
|
},
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
@@ -229,6 +225,7 @@ export class EdgelessRootPreviewBlockComponent extends BlockComponent<
|
|||||||
|
|
||||||
override renderBlock() {
|
override renderBlock() {
|
||||||
const background = styleMap({
|
const background = styleMap({
|
||||||
|
...this.backgroundStyle,
|
||||||
background: this.overrideBackground,
|
background: this.overrideBackground,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -260,6 +257,9 @@ export class EdgelessRootPreviewBlockComponent extends BlockComponent<
|
|||||||
@state()
|
@state()
|
||||||
accessor overrideBackground: string | undefined = undefined;
|
accessor overrideBackground: string | undefined = undefined;
|
||||||
|
|
||||||
|
@state()
|
||||||
|
accessor backgroundStyle: Readonly<StyleInfo> | null = null;
|
||||||
|
|
||||||
@query('gfx-viewport')
|
@query('gfx-viewport')
|
||||||
accessor gfxViewportElm!: GfxViewportElement;
|
accessor gfxViewportElm!: GfxViewportElement;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user