mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 00:41:39 +08:00
26 lines
839 B
TypeScript
26 lines
839 B
TypeScript
import '@blocksuite/affine-block-embed/effects';
|
|
|
|
import { insertEmbedCard } from '@blocksuite/affine-block-embed';
|
|
import type { EmbedCardStyle } from '@blocksuite/affine-model';
|
|
import { EmbedOptionProvider } from '@blocksuite/affine-shared/services';
|
|
import type { Command } from '@blocksuite/block-std';
|
|
|
|
export const insertBookmarkCommand: Command<
|
|
never,
|
|
'insertedLinkType',
|
|
{ url: string }
|
|
> = (ctx, next) => {
|
|
const { url, std } = ctx;
|
|
const embedOptions = std.get(EmbedOptionProvider).getEmbedBlockOptions(url);
|
|
|
|
let flavour = 'affine:bookmark';
|
|
let targetStyle: EmbedCardStyle = 'vertical';
|
|
const props: Record<string, unknown> = { url };
|
|
if (embedOptions) {
|
|
flavour = embedOptions.flavour;
|
|
targetStyle = embedOptions.styles[0];
|
|
}
|
|
insertEmbedCard(std, { flavour, targetStyle, props });
|
|
next();
|
|
};
|