Skip to content

Add Context Menu to Insert Menu #10

@AlexKempen

Description

@AlexKempen

We should add a context menu to the part insertion menu (defined in insert-menu.tsx). This can probably follow the same pattern we have with MenuButton in card-components.tsx today. We can also probably lift the MenuButton component out into app-component-menu.tsx and then add it to the insert menu.

The existing item menu contents are defined in insertable-card.tsx. We don't need QuickInsert options in the admin menu, so you can probably add an inInsertMenu option to InsertableMenuItemsProps and use that to decide whether to show QuickInsertOptions.

interface InsertableMenuItemsProps {
    favorite: Favorite | undefined;
    insertable: InsertableOut;
}

export function InsertableMenuItems(
    props: InsertableMenuItemsProps
): ReactNode {
    const { favorite, insertable } = props;

    return (
        <>
            <QuickInsertItems
                insertable={insertable}
                isFavorite={favorite !== undefined}
            />
            <Menu.Divider />
            <FavoriteInsertableItem
                favorite={favorite}
                insertable={insertable}
            />
            <Menu.Divider />
            <OpenDocumentItems path={insertable.path} />
            <AdminOptionsSubmenu>
                <InsertableAdminContextMenu insertable={insertable} />
            </AdminOptionsSubmenu>
        </>
    );
}

As a bonus, it would be neat if the OpenDocument/Copy URL links included the current configuration. That could probably be implemented by adding an optional Configuration prop to InsertableMenuItems and OpenDocumentItems and passing the configuration in to makeUrl (which is something it already supports).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions