feat(core): add context menu to card view (#13258)

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

## Summary by CodeRabbit

* **New Features**
* Added a context menu to document cards, allowing additional actions
when enabled.

* **Improvements**
* The context menu is now conditionally enabled based on live data,
ensuring it only appears when relevant.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
EYHN
2025-07-25 18:07:17 +08:00
committed by GitHub
parent 0d43350afd
commit 7409940cc6

View File

@@ -371,12 +371,18 @@ export const CardViewDoc = ({ docId }: DocListItemProps) => {
const selectMode = useLiveData(contextValue.selectMode$); const selectMode = useLiveData(contextValue.selectMode$);
const docsService = useService(DocsService); const docsService = useService(DocsService);
const doc = useLiveData(docsService.list.doc$(docId)); const doc = useLiveData(docsService.list.doc$(docId));
const showMoreOperation = useLiveData(contextValue.showMoreOperation$);
if (!doc) { if (!doc) {
return null; return null;
} }
return ( return (
<ContextMenu
asChild
disabled={!showMoreOperation}
items={<MoreMenuContent docId={docId} />}
>
<li className={styles.cardViewRoot}> <li className={styles.cardViewRoot}>
<DragHandle id={docId} className={styles.cardDragHandle} /> <DragHandle id={docId} className={styles.cardDragHandle} />
<header className={styles.cardViewHeader}> <header className={styles.cardViewHeader}>
@@ -406,5 +412,6 @@ export const CardViewDoc = ({ docId }: DocListItemProps) => {
<DocPreview id={docId} className={styles.cardPreviewContainer} /> <DocPreview id={docId} className={styles.cardPreviewContainer} />
<CardViewProperties docId={docId} /> <CardViewProperties docId={docId} />
</li> </li>
</ContextMenu>
); );
}; };