mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
To close: [BS-2843](https://linear.app/affine-design/issue/BS-2843/iframe-embed-block-占位态) [BS-2844](https://linear.app/affine-design/issue/BS-2844/iframe-embed-block-create-modal-ui-调整) [BS-2880](https://linear.app/affine-design/issue/BS-2880/spotify-选中时圆角有问题) [BS-2881](https://linear.app/affine-design/issue/BS-2881/miro-圆角有问题-点击-see-the-board-加载之后就好了)
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
|
|
import { toGfxBlockComponent } from '@blocksuite/block-std';
|
|
import { Bound } from '@blocksuite/global/gfx';
|
|
import { nothing } from 'lit';
|
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
import { html } from 'lit/static-html.js';
|
|
|
|
import { EmbedIframeBlockComponent } from './embed-iframe-block';
|
|
|
|
export class EmbedEdgelessIframeBlockComponent extends toGfxBlockComponent(
|
|
EmbedIframeBlockComponent
|
|
) {
|
|
override selectedStyle$ = null;
|
|
|
|
override blockDraggable = false;
|
|
|
|
override accessor blockContainerStyles = {
|
|
margin: '0',
|
|
backgroundColor: 'transparent',
|
|
};
|
|
|
|
get edgelessSlots() {
|
|
return this.std.get(EdgelessLegacySlotIdentifier);
|
|
}
|
|
|
|
override connectedCallback() {
|
|
super.connectedCallback();
|
|
|
|
this.edgelessSlots.elementResizeStart.subscribe(() => {
|
|
this.isResizing$.value = true;
|
|
});
|
|
|
|
this.edgelessSlots.elementResizeEnd.subscribe(() => {
|
|
this.isResizing$.value = false;
|
|
});
|
|
}
|
|
|
|
override renderGfxBlock() {
|
|
if (!this.isEmbedIframeBlockEnabled) {
|
|
return nothing;
|
|
}
|
|
|
|
const bound = Bound.deserialize(this.model.props.xywh$.value);
|
|
const scale = this.model.props.scale$.value;
|
|
const width = bound.w / scale;
|
|
const height = bound.h / scale;
|
|
const style = {
|
|
width: `${width}px`,
|
|
height: `${height}px`,
|
|
transformOrigin: '0 0',
|
|
transform: `scale(${scale})`,
|
|
};
|
|
|
|
return html`
|
|
<div class="edgeless-embed-iframe-block" style=${styleMap(style)}>
|
|
${this.renderPageContent()}
|
|
</div>
|
|
`;
|
|
}
|
|
}
|