mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
02bdb2e464
* fix: Render-per-model type, 4x improvement on perf * fix: Sidebar CollectionLinkChildren render when @mention changes
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { useCallback } from "react";
|
|
import useDictionary from "~/hooks/useDictionary";
|
|
import getMenuItems from "../menus/block";
|
|
import { useEditor } from "./EditorContext";
|
|
import SuggestionsMenu, {
|
|
Props as SuggestionsMenuProps,
|
|
} 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
|
|
onClick={options.onClick}
|
|
selected={options.selected}
|
|
icon={item.icon}
|
|
title={item.title}
|
|
shortcut={item.shortcut}
|
|
/>
|
|
),
|
|
[]
|
|
);
|
|
|
|
return (
|
|
<SuggestionsMenu
|
|
{...props}
|
|
filterable
|
|
trigger="/"
|
|
renderMenuItem={renderMenuItem}
|
|
items={getMenuItems(dictionary, elementRef)}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default BlockMenu;
|