mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-05 19:40:30 +08:00
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 -->
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import './utils/declare-test-window.js';
|
||||
|
||||
import type { BookmarkBlockComponent } from '@blocksuite/affine/blocks/bookmark';
|
||||
import type { BlockSnapshot } from '@blocksuite/store';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
@@ -8,7 +9,9 @@ import {
|
||||
activeNoteInEdgeless,
|
||||
clickView,
|
||||
copyByKeyboard,
|
||||
createNote,
|
||||
dragBlockToPoint,
|
||||
edgelessCommonSetup,
|
||||
enterPlaygroundRoom,
|
||||
expectConsoleMessage,
|
||||
focusRichText,
|
||||
@@ -500,3 +503,28 @@ test.describe('embed github card', () => {
|
||||
await expect(banner).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test('drag a card from canvas to note should not change the style of the card', async ({
|
||||
page,
|
||||
}) => {
|
||||
const url = 'https://github.com/toeverything/AFFiNE/pull/12660';
|
||||
|
||||
await edgelessCommonSetup(page);
|
||||
await createNote(page, [-100, -300]);
|
||||
await page.locator('edgeless-link-tool-button').click();
|
||||
await page.locator('.embed-card-modal-input').fill(url);
|
||||
await pressEnter(page);
|
||||
|
||||
const edgelessBookmark = page.locator('affine-edgeless-bookmark');
|
||||
await edgelessBookmark.click();
|
||||
await waitNextFrame(page);
|
||||
const dragHandle = page.locator('.affine-drag-handle-container');
|
||||
await dragHandle.dragTo(page.locator('affine-edgeless-note'));
|
||||
|
||||
const noteBookmark = page.locator('affine-bookmark');
|
||||
await expect(noteBookmark).toBeVisible();
|
||||
const style = await noteBookmark.evaluate(
|
||||
(el: BookmarkBlockComponent) => el.model.props.style
|
||||
);
|
||||
expect(style).toBe('horizontal');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user