mirror of
https://github.com/outline/outline.git
synced 2026-11-27 16:08:58 +03:00
* feat: Unpin and context menu controls on pinned documents - Adds an unpin control to document chips in the collapsed pinned view - Adds the collapse toggle to collections, matching home - Makes the Pin menu items toggles with a selected state - Adds a document context menu to pinned cards and chips - Stops the drag sensor swallowing clicks on the card unpin button Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: Hide the collection pin toggle for a mixed selection Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import type * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import type Document from "~/models/Document";
|
|
import { ContextMenu } from "~/components/Menu/ContextMenu";
|
|
import { ActionContextProvider } from "~/hooks/useActionContext";
|
|
import { useDocumentActiveModels } from "~/hooks/useDocumentActiveModels";
|
|
import { useDocumentMenuAction } from "~/hooks/useDocumentMenuAction";
|
|
|
|
type Props = {
|
|
/** Document for which the menu is to be shown */
|
|
document: Document;
|
|
/** The element that opens the menu when right clicked */
|
|
children: React.ReactNode;
|
|
/** Invoked when menu is opened */
|
|
onOpen?: () => void;
|
|
/** Invoked when menu is closed */
|
|
onClose?: () => void;
|
|
};
|
|
|
|
/**
|
|
* Wraps its children in a right click context menu offering the standard
|
|
* document actions.
|
|
*/
|
|
export const DocumentContextMenu = observer(function DocumentContextMenu_({
|
|
document,
|
|
children,
|
|
onOpen,
|
|
onClose,
|
|
}: Props) {
|
|
const { t } = useTranslation();
|
|
const action = useDocumentMenuAction({ documentId: document.id });
|
|
const activeModels = useDocumentActiveModels(document);
|
|
|
|
return (
|
|
<ActionContextProvider value={{ activeModels }}>
|
|
<ContextMenu
|
|
action={action}
|
|
ariaLabel={t("Document options")}
|
|
onOpen={onOpen}
|
|
onClose={onClose}
|
|
>
|
|
{children}
|
|
</ContextMenu>
|
|
</ActionContextProvider>
|
|
);
|
|
});
|