Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Drag Handle Menu item closeMenuOnClick prop #363

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,38 +59,38 @@ export const BlockColorsButton = <BSchema extends BlockSchema>(
</div>
</Menu.Target>
<div ref={ref}>
<Menu.Dropdown
onMouseLeave={startMenuCloseTimer}
onMouseOver={stopMenuCloseTimer}
style={{ marginLeft: "5px" }}>
<ColorPicker
iconSize={18}
text={
"textColor" in props.block.props &&
typeof props.block.props.textColor === "string"
? {
color: props.block.props.textColor,
setColor: (color) =>
props.editor.updateBlock(props.block, {
props: { textColor: color },
} as PartialBlock<BSchema>),
}
: undefined
}
background={
"backgroundColor" in props.block.props &&
typeof props.block.props.backgroundColor === "string"
? {
color: props.block.props.backgroundColor,
setColor: (color) =>
props.editor.updateBlock(props.block, {
props: { backgroundColor: color },
} as PartialBlock<BSchema>),
}
: undefined
}
/>
</Menu.Dropdown>
<Menu.Dropdown
onMouseLeave={startMenuCloseTimer}
onMouseOver={stopMenuCloseTimer}
style={{ marginLeft: "5px" }}>
<ColorPicker
iconSize={18}
text={
"textColor" in props.block.props &&
typeof props.block.props.textColor === "string"
? {
color: props.block.props.textColor,
setColor: (color) =>
props.editor.updateBlock(props.block, {
props: { textColor: color },
} as PartialBlock<BSchema>),
}
: undefined
}
background={
"backgroundColor" in props.block.props &&
typeof props.block.props.backgroundColor === "string"
? {
color: props.block.props.backgroundColor,
setColor: (color) =>
props.editor.updateBlock(props.block, {
props: { backgroundColor: color },
} as PartialBlock<BSchema>),
}
: undefined
}
/>
</Menu.Dropdown>
</div>
</Menu>
</DragHandleMenuItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Menu } from "@mantine/core";
import { Menu, MenuItemProps } from "@mantine/core";
import { PolymorphicComponentProps } from "@mantine/utils";

export const DragHandleMenuItem = (
props: PolymorphicComponentProps<"button">
props: PolymorphicComponentProps<"button"> & MenuItemProps
) => {
const { children, ...remainingProps } = props;
return <Menu.Item {...remainingProps}>{children}</Menu.Item>;
Expand Down
5 changes: 3 additions & 2 deletions packages/website/docs/docs/side-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ type SideMenuButtonProps = {
}
export const SideMenuButton = (props: SideMenuButtonProps) => ...;

// Takes same props as `button` elements, e.g. onClick.
export const DragHandleMenuItem = (props) => ...;
// Contains all props that a regular button element would take, as well as all props from the Mantine `Menu.Item` component.
type DragHandleMenuItemProps = PolymorphicComponentProps<"button"> & MenuItemProps
export const DragHandleMenuItem = (props: DragHandleMenuItemProps) => ...;
```
Loading