mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
fix(editor): repeated instantiation of frame preview editor (#10729)
Close [BS-2774](https://linear.app/affine-design/issue/BS-2774/frame-preview-会重新创建editor)
This commit is contained in:
@@ -14,6 +14,7 @@ import { DisposableGroup } from '@blocksuite/global/slot';
|
||||
import { type Query, type Store } from '@blocksuite/store';
|
||||
import { css, html, nothing, type PropertyValues } from 'lit';
|
||||
import { property, query, state } from 'lit/decorators.js';
|
||||
import { guard } from 'lit/directives/guard.js';
|
||||
import { styleMap } from 'lit/directives/style-map.js';
|
||||
import debounce from 'lodash-es/debounce';
|
||||
|
||||
@@ -151,7 +152,6 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {
|
||||
}
|
||||
|
||||
private _renderSurfaceContent() {
|
||||
if (!this._previewDoc || !this.frame) return nothing;
|
||||
const { width, height } = this.frameViewportWH;
|
||||
|
||||
const _previewSpec = this._previewSpec.value;
|
||||
@@ -169,10 +169,13 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {
|
||||
height: `${height}px`,
|
||||
})}
|
||||
>
|
||||
${new BlockStdScope({
|
||||
store: this._previewDoc,
|
||||
extensions: _previewSpec,
|
||||
}).render()}
|
||||
${guard([this._previewDoc, this.frame], () => {
|
||||
if (!this._previewDoc || !this.frame) return nothing;
|
||||
return new BlockStdScope({
|
||||
store: this._previewDoc,
|
||||
extensions: _previewSpec,
|
||||
}).render();
|
||||
})}
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user