// (C) 2021-2026 GoodData Corporation
import { useMemo } from "react";
import { useIntl } from "react-intl";
import { useDashboardDispatch, useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
import { useDashboardEventDispatch } from "../../../model/react/useDashboardEventDispatch.js";
import { selectEnableRichTextWidgetFilterConfiguration } from "../../../model/store/config/configSelectors.js";
import { useDashboardCustomizationsContext } from "../../dashboardContexts/DashboardCustomizationsContext.js";
import { getDefaultRichTextEditMode } from "../richTextMenu/DefaultDashboardRichTextMenu/getDefaultRichTextEditMenuItems.js";
export const useEditableRichTextMenu = (config) => {
    const { widget, closeMenu } = config;
    const intl = useIntl();
    const dispatch = useDashboardDispatch();
    const eventDispatch = useDashboardEventDispatch();
    const enableRichTextWidgetFilterConfiguration = useDashboardSelector(selectEnableRichTextWidgetFilterConfiguration);
    const { richTextMenuItemsProvider } = useDashboardCustomizationsContext();
    const defaultMenuItems = useMemo(() => {
        return getDefaultRichTextEditMode(widget, {
            intl,
            dispatch,
            eventDispatch,
            enableRichTextWidgetFilterConfiguration,
        });
    }, [dispatch, eventDispatch, intl, widget, enableRichTextWidgetFilterConfiguration]);
    const menuItems = useMemo(() => {
        return richTextMenuItemsProvider
            ? richTextMenuItemsProvider(widget, defaultMenuItems, closeMenu, "edit")
            : defaultMenuItems;
    }, [richTextMenuItemsProvider, widget, defaultMenuItems, closeMenu]);
    return { menuItems };
};
//# sourceMappingURL=useEditableRichTextMenu.js.map