-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add TableCellImproved, TableHeaderImproved extensions and MenuSelectTableBorderStyle control #185
Conversation
The MenuSelectTableBorderStyle component has been added to the controls folder. This component is necessary to implement a specific table border style in the application.
The MenuSelect and Extension work as expected. Recording.2023-12-30.105935.mp4I have a small problem with the table bubble menu, It keeps closing when I open the menu select control. Any idea on how to fix it? @sjdemartini Recording.2023-12-30.110149.mp4 |
- Add BorderStyleDashed icon sourced from https://www.svgrepo.com/svg/361694/border-dashed - Add BorderStyleDotted icon sourced from https://www.svgrepo.com/svg/361691/border-dotted - Add BorderStyleSolid icon sourced from https://www.svgrepo.com/svg/361697/border-solid These icons are added to provide different border style options for UI elements.
@bryanjtc Nice work getting what you have together so far! That's a tricky issue. As you've probably seen, the logic for the controlling the table bubble menu mui-tiptap/src/TableBubbleMenu.tsx Line 149 in 8767227
In this case, the editor is losing focus due to the |
Side note: if the table bubble menu is appearing near the bottom of the page currently, and the border style select is opened, it overlaps in an awkward way that can make it tricky to interact with (though maybe partially because of the MenuSelect's tooltip logic): I'm not sure what the right UI/UX should be since this is leading to "nested" menus. 🤔 |
- Refactored the following components: ControlledBubbleMenu, MenuControlsContainer, MenuSelectTableBorderStyle, TableMenuControls, and EditorMenuControls. - Made changes to improve code readability and maintainability. - No functional changes were made, only code restructuring and organization.
I refactored the code and created another bubble menu inside the table bubble menu. It works better. Recording.2023-12-30.185222.mp4 |
This commit adds a new extension called TableHeaderImproved.ts to the src/extensions directory. The extension enhances the functionality of the table header in the demo application. The package.json file and src/demo/useExtensions.ts file were also modified as part of this feature implementation.
…ectTableBorderStyle.tsx.
This commit adds new icons for different border styles such as dashed, dotted, double, groove, inset, none, outset, ridge, and solid. These icons will be used in the application to represent different border styles in a visual and intuitive way.
@sjdemartini Can you review the pr? I now that it doesn't have comments, i'm waiting for review to add the comments. Just in case there is something else that needs to be moved or changed. |
@bryanjtc Cool, wasn't sure if you'd settled in a place where you thought it was ready for review again. Things have been super busy on my end unfortunately, but I'll try to review some time soon (hopefully next week). Sorry for the delay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work getting this to its current state despite some of the nuances with Tiptap and mui-tiptap! I think for us to be able to merge it, the main criteria would be
- This doesn't break anything for users who are using the regular Table, TableCell, and/or TableHeader extensions
- This has a good UI/UX that feels consistent with other mui-tiptap features
- The code is well structured and offers consistent APIs with other parts of mui-tipap
- Documented in the README and in code
I think (2) is nearly there, with the caveat around the default table styles seemingly making some of the border styles have no visual effect (so perhaps we'd want to change the default options
for table border style). And (4) is obviously straightforward, and as you said can be done once the rest is figured out.
(1) needs a bit of tweaking per TableMenuControls including the new option even if the user doesn't have the new extensions. (3) has the caveat around the new "icons" not actually being icons. These are likely resolvable, but curious about your thoughts given where things stand. (If it seems tricky to achieve consistency and all, another option could conceivably be your own package for these new extensions and table-extending functionality, which could play nicely with mui-tiptap 😄)
Thanks again @bryanjtc!
@@ -88,6 +89,8 @@ | |||
"@tiptap/extension-heading": "^2.0.0-beta.210", | |||
"@tiptap/extension-image": "^2.0.0-beta.210", | |||
"@tiptap/extension-table": "^2.0.0-beta.210", | |||
"@tiptap/extension-table-cell": "^2.0.0-beta.210", | |||
"@tiptap/extension-table-header": "^2.0.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is pinned with 2.0.4 minimum instead of 2.0.0-beta.210 like the other dependencies? Would this not work if the end user only has 2.0.0 installed for instance?
const tableNode = findParentNodeOfType(editor.state.schema.nodes.table)( | ||
editor.state.selection | ||
); | ||
|
||
const shouldOpen = Boolean(tableNode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the rationale behind this vs editor.isActive("table")
? Particularly since this brings in a whole new dependency (prosemirror-utils
).
I imagine Tiptap may have a util equivalent to findParentNodeOfType
, if for some reason we do need that sort of functionality, so ideally we can avoid the new dep.
// Because the user interactions with the table menu bar buttons unfocus the | ||
// editor (since it's not part of the editor content), we'll debounce our | ||
// visual focused state so that we keep the bubble menu open during those | ||
// interactions. That way we don't close it upon menu bar button click | ||
// immediately, which can prevent menu button callbacks from working and | ||
// also undesirably will close the bubble menu rather than keeping it open for | ||
// future menu interaction. | ||
const isEditorFocusedDebounced = useDebouncedFocus({ editor }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this condition does make it easier to ensure the "nested" menu logic works if editor focus inadvertently gets removed, but this has the downside that even if a user clicks out of the editor and is no longer interacting with it, the bubble menu stays open. Perhaps that's a worthwhile tradeoff. (as mentioned in #185 (comment))
@@ -18,6 +18,7 @@ export interface MenuButtonProps | |||
* included. | |||
*/ | |||
tooltipLabel: MenuButtonTooltipProps["label"]; | |||
tooltipPlacement?: MenuButtonTooltipProps["placement"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a doc comment like we have for the other props
@@ -23,14 +23,18 @@ export type MenuControlsContainerProps = { | |||
* interval, if `debounced` is true. | |||
*/ | |||
DebounceProps?: Except<DebounceRenderProps, "children">; | |||
direction?: "horizontal" | "vertical"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a doc comment
|
||
function BorderStyleDashed() { | ||
return ( | ||
<Box |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creative use of Box
to achieve more useful icons for these border styles. One caveat unfortunately is that these border "icons" won't have the same props as the other icons which are stand MUI SvgIcon
s. For instance, won't support the color
or fontSize
props. That might be okay, but it's a quirk that could be confusing to users.
}) | ||
); | ||
|
||
const DEFAULT_BORDER_STYLE_OPTIONS: BorderStyleSelectOption[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct that many of these options don't display differently than "solid" with the default mui-tiptap styles that have borderWidth set to 1px, and they'd require >1px borders to be visually distinct?
@@ -87,6 +87,7 @@ export type ControlledBubbleMenuProps = { | |||
* content. | |||
*/ | |||
PaperProps?: Partial<PaperProps>; | |||
onMouseLeave?: (event: React.MouseEvent<HTMLElement>) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this new prop is no longer needed? Not seeing it referenced elsewhere
@@ -0,0 +1,26 @@ | |||
import { TableHeader } from "@tiptap/extension-table-header"; | |||
|
|||
const TableHeaderImproved = TableHeader.extend({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd want to document the new extensions and whatnot in the README if we're going to merge this
width: MENU_BUTTON_FONT_SIZE_DEFAULT, | ||
height: MENU_BUTTON_FONT_SIZE_DEFAULT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like these new border style icons appear a bit larger than the rest of the standard MUI icons. Should these be smaller?
Nice that you took the time to review everything. I will try to push the fixes/changes today and reply/resolve each conversatioon. |
As mentioned in #185 (comment)
As mentioned in #185 (comment)
Since there hasn't been activity in a while, I'm going to close this out. Thanks again for looking into it, since it can be a useful model if folks want to add their own implementation of these bubble menus to use elsewhere. |
Adds two new extensions and one control to modify the table border style.
Relates to #184