mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
fix(core): optimize at menu config loading 2 (#9366)
fix AF-2028
<div class='graphite__hidden'>
<div>🎥 Video uploaded on Graphite:</div>
<a href="https://app.graphite.dev/media/video/T2klNLEk0wxLh4NRDzhk/7931ddc8-3721-4b7d-b4cb-065f923f295c.mp4">
<img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/T2klNLEk0wxLh4NRDzhk/7931ddc8-3721-4b7d-b4cb-065f923f295c.mp4">
</a>
</div>
<video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/T2klNLEk0wxLh4NRDzhk/7931ddc8-3721-4b7d-b4cb-065f923f295c.mp4">Recording at 2024-12-27 11.50.54.mp4</video>
This commit is contained in:
@@ -77,8 +77,12 @@ export type LinkedMenuGroup = {
|
||||
styles?: string;
|
||||
// maximum quantity displayed by default
|
||||
maxDisplay?: number;
|
||||
// if the menu is loading
|
||||
loading?: boolean | Signal<boolean>;
|
||||
// copywriting when display quantity exceeds
|
||||
overflowText?: string;
|
||||
overflowText?: string | Signal<string>;
|
||||
// loading text
|
||||
loadingText?: string | Signal<string>;
|
||||
};
|
||||
|
||||
export type LinkedDocContext = {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { LoadingIcon } from '@blocksuite/affine-block-image';
|
||||
import type { IconButton } from '@blocksuite/affine-components/icon-button';
|
||||
import { MoreHorizontalIcon } from '@blocksuite/affine-components/icons';
|
||||
import {
|
||||
@@ -90,15 +91,26 @@ export class LinkedDocPopover extends SignalWatcher(
|
||||
|
||||
private _getActionItems(group: LinkedMenuGroup) {
|
||||
const isExpanded = !!this._expanded.get(group.name);
|
||||
const items = resolveSignal(group.items);
|
||||
if (isExpanded) {
|
||||
return items;
|
||||
}
|
||||
let items = resolveSignal(group.items);
|
||||
|
||||
const isOverflow = !!group.maxDisplay && items.length > group.maxDisplay;
|
||||
if (isOverflow) {
|
||||
return items.slice(0, group.maxDisplay).concat({
|
||||
const isLoading = resolveSignal(group.loading);
|
||||
|
||||
items = isExpanded ? items : items.slice(0, group.maxDisplay);
|
||||
|
||||
if (isLoading) {
|
||||
items = items.concat({
|
||||
key: 'loading',
|
||||
name: resolveSignal(group.loadingText) || 'loading',
|
||||
icon: LoadingIcon,
|
||||
action: () => {},
|
||||
});
|
||||
}
|
||||
|
||||
if (isOverflow && !isExpanded && group.maxDisplay) {
|
||||
items = items.concat({
|
||||
key: `${group.name} More`,
|
||||
name: group.overflowText || 'more',
|
||||
name: resolveSignal(group.overflowText) || 'more',
|
||||
icon: MoreHorizontalIcon,
|
||||
action: () => {
|
||||
this._expanded.set(group.name, true);
|
||||
@@ -106,6 +118,7 @@ export class LinkedDocPopover extends SignalWatcher(
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user