mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-31 00:59:57 +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`
26 lines
902 B
TypeScript
26 lines
902 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/std';
|
|
|
|
export const insertBookmarkCommand: Command<
|
|
{ url: string },
|
|
{ blockId: string; flavour: 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];
|
|
}
|
|
const blockId = insertEmbedCard(std, { flavour, targetStyle, props });
|
|
if (!blockId) return;
|
|
next({ blockId, flavour });
|
|
};
|