Files
AFFiNE/blocksuite/affine/model/src/blocks/embed/github/github-model.ts
L-Sun 10da3ad28e fix(editor): update card style after dragging it to note (#12660)
Close [BS-3148](https://linear.app/affine-design/issue/BS-3148/拖拽到note后,更新card样式)

### What Changes
- fix the style of card not updated after draggin it from canvas to note
- narrow type of specific card style by using `as const satisfies EmbedCardStyle[]`
- add type hint to the `props`, the second parameter  of `store.updateBlock`

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added middleware to automatically update card styles when dragging blocks into notes.
- **Bug Fixes**
  - Ensured that dragging a bookmark card into a note preserves its style.
- **Tests**
  - Introduced an end-to-end test to verify bookmark card style is retained after drag-and-drop.
- **Refactor**
  - Enhanced type safety and clarity for card style configurations and block properties.
- **Chores**
  - Refined type annotations and assertions across multiple block style constants and toolbar configurations.
  - Improved generic typing for block update methods to increase type precision.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-30 10:55:29 +00:00

36 lines
868 B
TypeScript

import { BlockModel } from '@blocksuite/store';
import type { EmbedCardStyle } from '../../../utils/index.js';
import { defineEmbedModel } from '../../../utils/index.js';
export type EmbedGithubBlockUrlData = {
image: string | null;
status: string | null;
statusReason: string | null;
title: string | null;
description: string | null;
createdAt: string | null;
assignees: string[] | null;
};
export const EmbedGithubStyles = [
'vertical',
'horizontal',
'list',
'cube',
] as const satisfies EmbedCardStyle[];
export type EmbedGithubBlockProps = {
style: (typeof EmbedGithubStyles)[number];
owner: string;
repo: string;
githubType: 'issue' | 'pr';
githubId: string;
url: string;
caption: string | null;
} & EmbedGithubBlockUrlData;
export class EmbedGithubModel extends defineEmbedModel<EmbedGithubBlockProps>(
BlockModel
) {}