mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 13:02:21 +08:00
dbf0f9dc20
Closes: [BS-2553](https://linear.app/affine-design/issue/BS-2553/remove-global-types-in-edgeless)
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import type {
|
|
GfxCommonBlockProps,
|
|
GfxElementGeometry,
|
|
} from '@blocksuite/block-std/gfx';
|
|
import { GfxCompatible } from '@blocksuite/block-std/gfx';
|
|
import { BlockModel, defineBlockSchema } from '@blocksuite/store';
|
|
|
|
import type { EmbedCardStyle, LinkPreviewData } from '../../utils/index.js';
|
|
|
|
export const BookmarkStyles: EmbedCardStyle[] = [
|
|
'vertical',
|
|
'horizontal',
|
|
'list',
|
|
'cube',
|
|
] as const;
|
|
|
|
export type BookmarkBlockProps = {
|
|
style: (typeof BookmarkStyles)[number];
|
|
url: string;
|
|
caption: string | null;
|
|
} & LinkPreviewData &
|
|
Omit<GfxCommonBlockProps, 'scale'>;
|
|
|
|
const defaultBookmarkProps: BookmarkBlockProps = {
|
|
style: BookmarkStyles[1],
|
|
url: '',
|
|
caption: null,
|
|
|
|
description: null,
|
|
icon: null,
|
|
image: null,
|
|
title: null,
|
|
|
|
index: 'a0',
|
|
xywh: '[0,0,0,0]',
|
|
lockedBySelf: false,
|
|
rotate: 0,
|
|
};
|
|
|
|
export const BookmarkBlockSchema = defineBlockSchema({
|
|
flavour: 'affine:bookmark',
|
|
props: (): BookmarkBlockProps => defaultBookmarkProps,
|
|
metadata: {
|
|
version: 1,
|
|
role: 'content',
|
|
parent: [
|
|
'affine:note',
|
|
'affine:surface',
|
|
'affine:edgeless-text',
|
|
'affine:paragraph',
|
|
'affine:list',
|
|
],
|
|
},
|
|
toModel: () => new BookmarkBlockModel(),
|
|
});
|
|
|
|
export class BookmarkBlockModel
|
|
extends GfxCompatible<BookmarkBlockProps>(BlockModel)
|
|
implements GfxElementGeometry {}
|