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 { type Query, type Store } from '@blocksuite/store';
|
||||||
import { css, html, nothing, type PropertyValues } from 'lit';
|
import { css, html, nothing, type PropertyValues } from 'lit';
|
||||||
import { property, query, state } from 'lit/decorators.js';
|
import { property, query, state } from 'lit/decorators.js';
|
||||||
|
import { guard } from 'lit/directives/guard.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
import debounce from 'lodash-es/debounce';
|
import debounce from 'lodash-es/debounce';
|
||||||
|
|
||||||
@@ -151,7 +152,6 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _renderSurfaceContent() {
|
private _renderSurfaceContent() {
|
||||||
if (!this._previewDoc || !this.frame) return nothing;
|
|
||||||
const { width, height } = this.frameViewportWH;
|
const { width, height } = this.frameViewportWH;
|
||||||
|
|
||||||
const _previewSpec = this._previewSpec.value;
|
const _previewSpec = this._previewSpec.value;
|
||||||
@@ -169,10 +169,13 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {
|
|||||||
height: `${height}px`,
|
height: `${height}px`,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
${new BlockStdScope({
|
${guard([this._previewDoc, this.frame], () => {
|
||||||
store: this._previewDoc,
|
if (!this._previewDoc || !this.frame) return nothing;
|
||||||
extensions: _previewSpec,
|
return new BlockStdScope({
|
||||||
}).render()}
|
store: this._previewDoc,
|
||||||
|
extensions: _previewSpec,
|
||||||
|
}).render();
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user