feat(editor): adjust attachment block UI (#11763)

Closes: [BS-3143](https://linear.app/affine-design/issue/BS-3143/更新-attachment-错误样式)
Closes: [BS-3341](https://linear.app/affine-design/issue/BS-3341/attachment-select状态ui调整)

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

- **New Features**
  - Improved attachment block with unified reactive state handling for loading, errors, and downloads.
  - Enhanced card layouts with modular rendering and dynamic buttons based on state.

- **Bug Fixes**
  - Fixed UI state for "Embed view" action, now correctly disabled when not embedded.
  - Resolved attachment card styling issues and text overflow with new utility classes.

- **Refactor**
  - Streamlined attachment block rendering and state management for better performance and maintainability.
  - Updated toolbar configuration for consistent parameter naming.
  - Simplified embedded and open methods for improved clarity.
  - Made internal functions private to reduce exported API surface.

- **Chores**
  - Removed unused icon export and legacy upload tracking functions.
  - Updated attachment utilities to use reactive state, added data refresh, and improved error handling.
  - Refined image dimension handling for consistent resizing behavior.
  - Improved test selectors to target focused attachment containers for better reliability.
  - Refactored CSS to separate container and card styling and adopt theme-based colors consistently.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fundon
2025-04-29 01:00:56 +00:00
parent df565f2fbf
commit 362f89b669
9 changed files with 336 additions and 272 deletions
@@ -306,7 +306,9 @@ test('should enable pointer event in pdf viewer', async ({ page }) => {
const attachment = page.locator('affine-attachment');
await attachment.click();
const attachmentSelection = attachment.locator('affine-block-selection');
const attachmentSelection = attachment.locator(
'.affine-attachment-container.focused'
);
const toolbar = locateToolbar(page);
+1 -1
View File
@@ -322,7 +322,7 @@ test(`support dragging attachment block directly`, async ({
await page.mouse.move(rect.x + 40, rect.y + rect.height + 80, { steps: 20 });
await page.mouse.up();
const rects = page.locator('affine-block-selection').locator('visible=true');
const rects = page.locator('.affine-attachment-container.focused');
await expect(rects).toHaveCount(1);
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
`${testInfo.title}_3.json`