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:
@@ -21,6 +21,7 @@
|
|||||||
"@blocksuite/icons": "^2.2.12",
|
"@blocksuite/icons": "^2.2.12",
|
||||||
"@blocksuite/std": "workspace:*",
|
"@blocksuite/std": "workspace:*",
|
||||||
"@blocksuite/store": "workspace:*",
|
"@blocksuite/store": "workspace:*",
|
||||||
|
"@blocksuite/sync": "workspace:*",
|
||||||
"@floating-ui/dom": "^1.6.13",
|
"@floating-ui/dom": "^1.6.13",
|
||||||
"@lit/context": "^1.1.2",
|
"@lit/context": "^1.1.2",
|
||||||
"@preact/signals-core": "^1.8.0",
|
"@preact/signals-core": "^1.8.0",
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ import { when } from 'lit/directives/when.js';
|
|||||||
import { AttachmentEmbedProvider } from './embed';
|
import { AttachmentEmbedProvider } from './embed';
|
||||||
import { styles } from './styles';
|
import { styles } from './styles';
|
||||||
import { downloadAttachmentBlob, refreshData } from './utils';
|
import { downloadAttachmentBlob, refreshData } from './utils';
|
||||||
|
|
||||||
type State = 'loading' | 'uploading' | 'warning' | 'oversize' | 'none';
|
type State = 'loading' | 'uploading' | 'warning' | 'oversize' | 'none';
|
||||||
|
|
||||||
@Peekable({
|
@Peekable({
|
||||||
enableOn: ({ model }: AttachmentBlockComponent) => {
|
enableOn: ({ model }: AttachmentBlockComponent) => {
|
||||||
return !model.doc.readonly && model.props.type.endsWith('pdf');
|
return !model.doc.readonly && model.props.type.endsWith('pdf');
|
||||||
@@ -102,7 +104,7 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
|
|||||||
}
|
}
|
||||||
|
|
||||||
determineState = (
|
determineState = (
|
||||||
loading: boolean,
|
downloading: boolean,
|
||||||
uploading: boolean,
|
uploading: boolean,
|
||||||
overSize: boolean,
|
overSize: boolean,
|
||||||
error: boolean
|
error: boolean
|
||||||
@@ -110,7 +112,7 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
|
|||||||
if (overSize) return 'oversize';
|
if (overSize) return 'oversize';
|
||||||
if (error) return 'warning';
|
if (error) return 'warning';
|
||||||
if (uploading) return 'uploading';
|
if (uploading) return 'uploading';
|
||||||
if (loading) return 'loading';
|
if (downloading) return 'loading';
|
||||||
return 'none';
|
return 'none';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -306,8 +308,8 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
|
|||||||
} = blobState;
|
} = blobState;
|
||||||
const warning = !overSize && Boolean(errorMessage);
|
const warning = !overSize && Boolean(errorMessage);
|
||||||
const error = overSize || warning;
|
const error = overSize || warning;
|
||||||
const loading = !error && downloading;
|
const state = this.determineState(downloading, uploading, overSize, error);
|
||||||
const state = this.determineState(loading, uploading, overSize, error);
|
const loading = state === 'loading' || state === 'uploading';
|
||||||
|
|
||||||
const classInfo = {
|
const classInfo = {
|
||||||
'affine-attachment-card': true,
|
'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 {
|
.affine-attachment-card.cubeThick {
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
{ "path": "../../widgets/slash-menu" },
|
{ "path": "../../widgets/slash-menu" },
|
||||||
{ "path": "../../../framework/global" },
|
{ "path": "../../../framework/global" },
|
||||||
{ "path": "../../../framework/std" },
|
{ "path": "../../../framework/std" },
|
||||||
{ "path": "../../../framework/store" }
|
{ "path": "../../../framework/store" },
|
||||||
|
{ "path": "../../../framework/sync" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ export const PackageList = [
|
|||||||
'blocksuite/framework/global',
|
'blocksuite/framework/global',
|
||||||
'blocksuite/framework/std',
|
'blocksuite/framework/std',
|
||||||
'blocksuite/framework/store',
|
'blocksuite/framework/store',
|
||||||
|
'blocksuite/framework/sync',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2417,6 +2417,7 @@ __metadata:
|
|||||||
"@blocksuite/icons": "npm:^2.2.12"
|
"@blocksuite/icons": "npm:^2.2.12"
|
||||||
"@blocksuite/std": "workspace:*"
|
"@blocksuite/std": "workspace:*"
|
||||||
"@blocksuite/store": "workspace:*"
|
"@blocksuite/store": "workspace:*"
|
||||||
|
"@blocksuite/sync": "workspace:*"
|
||||||
"@floating-ui/dom": "npm:^1.6.13"
|
"@floating-ui/dom": "npm:^1.6.13"
|
||||||
"@lit/context": "npm:^1.1.2"
|
"@lit/context": "npm:^1.1.2"
|
||||||
"@preact/signals-core": "npm:^1.8.0"
|
"@preact/signals-core": "npm:^1.8.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user