mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
**Directory Structure Changes** - Renamed multiple block-related directories by removing the "block-" prefix: - `block-attachment` → `attachment` - `block-bookmark` → `bookmark` - `block-callout` → `callout` - `block-code` → `code` - `block-data-view` → `data-view` - `block-database` → `database` - `block-divider` → `divider` - `block-edgeless-text` → `edgeless-text` - `block-embed` → `embed`
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
|
|
import { AttachmentBlockStyles } from '@blocksuite/affine-model';
|
|
import {
|
|
EMBED_CARD_HEIGHT,
|
|
EMBED_CARD_WIDTH,
|
|
} from '@blocksuite/affine-shared/consts';
|
|
import { toGfxBlockComponent } from '@blocksuite/std';
|
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
|
|
import { AttachmentBlockComponent } from './attachment-block.js';
|
|
|
|
export class AttachmentEdgelessBlockComponent extends toGfxBlockComponent(
|
|
AttachmentBlockComponent
|
|
) {
|
|
override blockDraggable = false;
|
|
|
|
get slots() {
|
|
return this.std.get(EdgelessLegacySlotIdentifier);
|
|
}
|
|
|
|
override onClick(_: MouseEvent) {
|
|
return;
|
|
}
|
|
|
|
override renderGfxBlock() {
|
|
const { style$ } = this.model.props;
|
|
const cardStyle = style$.value ?? AttachmentBlockStyles[1];
|
|
const width = EMBED_CARD_WIDTH[cardStyle];
|
|
const height = EMBED_CARD_HEIGHT[cardStyle];
|
|
const bound = this.model.elementBound;
|
|
const scaleX = bound.w / width;
|
|
const scaleY = bound.h / height;
|
|
|
|
this.containerStyleMap = styleMap({
|
|
width: `${width}px`,
|
|
height: `${height}px`,
|
|
transform: `scale(${scaleX}, ${scaleY})`,
|
|
transformOrigin: '0 0',
|
|
overflow: 'hidden',
|
|
});
|
|
|
|
return this.renderPageContent();
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
'affine-edgeless-attachment': AttachmentEdgelessBlockComponent;
|
|
}
|
|
}
|