fix(editor): revert bg color of attachments when loading or error states (#12061)

Closes: [BS-3379](https://linear.app/affine-design/issue/BS-3379/恢复在-loading-或错误时-attachments-的背景色)

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

- **Style**
  - Updated the background color of attachment cards in loading and error states for a more consistent appearance.
- **Bug Fixes**
  - Improved the handling and display of loading and uploading states for attachment cards to better reflect their current status.
- **Chores**
  - Added new workspace dependencies and project references to enhance synchronization capabilities across related modules.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fundon
2025-04-29 11:41:24 +00:00
parent 638f0b466f
commit 8b2a01d4cf
6 changed files with 16 additions and 5 deletions
@@ -35,7 +35,9 @@ import { when } from 'lit/directives/when.js';
import { AttachmentEmbedProvider } from './embed';
import { styles } from './styles';
import { downloadAttachmentBlob, refreshData } from './utils';
type State = 'loading' | 'uploading' | 'warning' | 'oversize' | 'none';
@Peekable({
enableOn: ({ model }: AttachmentBlockComponent) => {
return !model.doc.readonly && model.props.type.endsWith('pdf');
@@ -102,7 +104,7 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
}
determineState = (
loading: boolean,
downloading: boolean,
uploading: boolean,
overSize: boolean,
error: boolean
@@ -110,7 +112,7 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
if (overSize) return 'oversize';
if (error) return 'warning';
if (uploading) return 'uploading';
if (loading) return 'loading';
if (downloading) return 'loading';
return 'none';
};
@@ -306,8 +308,8 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
} = blobState;
const warning = !overSize && Boolean(errorMessage);
const error = overSize || warning;
const loading = !error && downloading;
const state = this.determineState(loading, uploading, overSize, error);
const state = this.determineState(downloading, uploading, overSize, error);
const loading = state === 'loading' || state === 'uploading';
const classInfo = {
'affine-attachment-card': true,
@@ -117,6 +117,11 @@ export const styles = css`
}
}
.affine-attachment-card.loading,
.affine-attachment-card.error {
background: ${unsafeCSSVarV2('layer/background/secondary')};
}
.affine-attachment-card.cubeThick {
flex-direction: column-reverse;