mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 23:37:15 +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`
35 lines
987 B
TypeScript
35 lines
987 B
TypeScript
import type { EmbedCardStyle, ReferenceParams } from '@blocksuite/affine-model';
|
|
import type { Command } from '@blocksuite/std';
|
|
|
|
import { insertEmbedCard } from '../../common/insert-embed-card.js';
|
|
|
|
export type LinkableFlavour =
|
|
| 'affine:bookmark'
|
|
| 'affine:embed-linked-doc'
|
|
| 'affine:embed-iframe'
|
|
| 'affine:embed-figma'
|
|
| 'affine:embed-github'
|
|
| 'affine:embed-loom'
|
|
| 'affine:embed-youtube';
|
|
|
|
export type InsertedLinkType = {
|
|
flavour: LinkableFlavour;
|
|
} | null;
|
|
|
|
export const insertEmbedLinkedDocCommand: Command<
|
|
{
|
|
docId: string;
|
|
params?: ReferenceParams;
|
|
},
|
|
{ blockId: string }
|
|
> = (ctx, next) => {
|
|
const { docId, params, std } = ctx;
|
|
const flavour = 'affine:embed-linked-doc';
|
|
const targetStyle: EmbedCardStyle = 'vertical';
|
|
const props: Record<string, unknown> = { pageId: docId };
|
|
if (params) props.params = params;
|
|
const blockId = insertEmbedCard(std, { flavour, targetStyle, props });
|
|
if (!blockId) return;
|
|
next({ blockId });
|
|
};
|