mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-22 04:21:40 +08:00
1f45cc5dec
**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`
82 lines
2.1 KiB
TypeScript
82 lines
2.1 KiB
TypeScript
import { EdgelessLegacySlotIdentifier } from '@blocksuite/affine-block-surface';
|
|
import { Bound } from '@blocksuite/global/gfx';
|
|
import {
|
|
blockComponentSymbol,
|
|
type BlockService,
|
|
type GfxBlockComponent,
|
|
GfxElementSymbol,
|
|
toGfxBlockComponent,
|
|
} from '@blocksuite/std';
|
|
import type {
|
|
GfxBlockElementModel,
|
|
GfxCompatibleProps,
|
|
} from '@blocksuite/std/gfx';
|
|
import type { StyleInfo } from 'lit/directives/style-map.js';
|
|
|
|
import type { EmbedBlockComponent } from './embed-block-element.js';
|
|
|
|
export function toEdgelessEmbedBlock<
|
|
Model extends GfxBlockElementModel<GfxCompatibleProps>,
|
|
Service extends BlockService,
|
|
WidgetName extends string,
|
|
B extends typeof EmbedBlockComponent<Model, Service, WidgetName>,
|
|
>(block: B) {
|
|
return class extends toGfxBlockComponent(block) {
|
|
override selectedStyle$ = null;
|
|
|
|
override [blockComponentSymbol] = true;
|
|
|
|
override blockDraggable = false;
|
|
|
|
protected override embedContainerStyle: StyleInfo = {};
|
|
|
|
override [GfxElementSymbol] = true;
|
|
|
|
get bound(): Bound {
|
|
return Bound.deserialize(this.model.xywh);
|
|
}
|
|
|
|
_handleClick(_: MouseEvent): void {
|
|
return;
|
|
}
|
|
|
|
get edgelessSlots() {
|
|
return this.std.get(EdgelessLegacySlotIdentifier);
|
|
}
|
|
|
|
override connectedCallback(): void {
|
|
super.connectedCallback();
|
|
|
|
this._disposables.add(
|
|
this.edgelessSlots.elementResizeStart.subscribe(() => {
|
|
this.isResizing$.value = true;
|
|
})
|
|
);
|
|
|
|
this._disposables.add(
|
|
this.edgelessSlots.elementResizeEnd.subscribe(() => {
|
|
this.isResizing$.value = false;
|
|
})
|
|
);
|
|
}
|
|
|
|
override renderGfxBlock() {
|
|
const bound = Bound.deserialize(this.model.xywh);
|
|
|
|
this.embedContainerStyle.width = `${bound.w}px`;
|
|
this.embedContainerStyle.height = `${bound.h}px`;
|
|
this.blockContainerStyles = {
|
|
width: `${bound.w}px`,
|
|
};
|
|
this._scale = bound.w / this._cardWidth;
|
|
|
|
return this.renderPageContent();
|
|
}
|
|
|
|
protected override accessor blockContainerStyles: StyleInfo | undefined =
|
|
undefined;
|
|
} as B & {
|
|
new (...args: any[]): GfxBlockComponent;
|
|
};
|
|
}
|