mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
ace351035a
* chore: Move SuggestionsMenu to Radix * Restore bounce anim * fix: Clear query on button open * Sub-menu support * fix bugs * PR feedback
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { useCallback } from "react";
|
|
import useDictionary from "~/hooks/useDictionary";
|
|
import getMenuItems from "../menus/block";
|
|
import { useEditor } from "./EditorContext";
|
|
import type { Props as SuggestionsMenuProps } from "./SuggestionsMenu";
|
|
import SuggestionsMenu from "./SuggestionsMenu";
|
|
import SuggestionsMenuItem from "./SuggestionsMenuItem";
|
|
|
|
type Props = Omit<SuggestionsMenuProps, "renderMenuItem" | "items"> &
|
|
Required<Pick<SuggestionsMenuProps, "embeds">>;
|
|
|
|
function BlockMenu(props: Props) {
|
|
const dictionary = useDictionary();
|
|
const { elementRef } = useEditor();
|
|
|
|
const renderMenuItem = useCallback(
|
|
(item, _index, options) => (
|
|
<SuggestionsMenuItem
|
|
{...options}
|
|
icon={item.icon}
|
|
title={item.title}
|
|
shortcut={item.shortcut}
|
|
disclosure={options.disclosure}
|
|
/>
|
|
),
|
|
[]
|
|
);
|
|
|
|
return (
|
|
<SuggestionsMenu
|
|
{...props}
|
|
filterable
|
|
trigger="/"
|
|
renderMenuItem={renderMenuItem}
|
|
items={getMenuItems(dictionary, elementRef)}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default BlockMenu;
|