Skip to content

feat: customize formatting toolbar and sidemenu #142

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

Merged
merged 30 commits into from
Apr 19, 2023

Conversation

YousefED
Copy link
Collaborator

@YousefED YousefED commented Mar 17, 2023

Work in progress: I think FormattingToolbar can be really simple. If so, we could then expose ToolbarButton to consumers, and they can just use JSX to create a custom formattingtoolbar. I think this is a more extensible approach than for example asking for a custom array defining which buttons to show in what order

  • simplify logic of FormattingToolbar
  • Expose ToolbarButton / LinkToolbarButton
  • Make it possible to pass a custom FormattingToolbar
  • Docs & demo
  • Does the API FormattingToolbarProps still make sense? or should we (partially) move this to BlockNoteEditor?

Merge update: this includes custom sidemenu #143

@matthewlipski
Copy link
Collaborator

matthewlipski commented Mar 24, 2023

Work in progress: I think FormattingToolbar can be really simple. If so, we could then expose ToolbarButton to consumers, and they can just use JSX to create a custom formattingtoolbar. I think this is a more extensible approach than for example asking for a custom array defining which buttons to show in what order

  • simplify logic of FormattingToolbar
  • Expose ToolbarButton / LinkToolbarButton
  • Make it possible to pass a custom FormattingToolbar
  • Docs & demo
  • Does the API FormattingToolbarProps still make sense? or should we (partially) move this to BlockNoteEditor?

I'm not sure about letting consumers just pass JSX directly into the formatting toolbar, mainly because it seems to be the opposite approach to the slash menu. I agree it makes it more extensible, but idk if extensibility is something we want to focus on for the premade menu, moreso consistency. Might need to have a longer discussion about this since it's relevant for all menus.

Alternative:

type FormattingToolbarButton = {
  name: string;
  execute: (editor: BlockNoteEditor => void);
  icon: JSX.Element;
  shortcut?: string;
}

type FormattingToolbarDropdownItem = {
  name: string;
  execute: (editor: BlockNoteEditor => void);
  active: (editor: BlockNoteEditor => boolean);
  icon: JSX.Element;
}

type FormattingToolbarDropdown = {
  items: FormattingToolbarDropdownItem[];
}

type FormattingToolbarItem = FormattingToolbarButton | FormattingToolbarDropdown;

And pass a FormattingToolbarItem[] as an editor option.

@matthewlipski matthewlipski marked this pull request as ready for review March 29, 2023 16:03
@vercel
Copy link

vercel bot commented Mar 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocknote-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 19, 2023 7:29pm

Copy link
Collaborator Author

@YousefED YousefED left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see inline + double check useCallbacks

* simplify colorpicker

* Added basic mouse cursor position

* Added drag handle menu customization API

* Copied changes from PR and minor improvements

* Small changes

* Added `DragHandleMenuItem` component

* Fixed side menu unnecessary updates

* Removed unnecessary state

* Cleaned up code

* Changed how the side menu gets the hovered block

* Added side menu image

* Added docs

* Fixed comments in demo

* Made all menus/toolbars scroll with page

* Revert "Made all menus/toolbars scroll with page"

This reverts commit ee61bd0.

* Removed `editor` from dynamic props

* Documentation changes

* Small cleanup

* Vanilla example fix

---------

Co-authored-by: Matthew Lipski <[email protected]>
Co-authored-by: Matthew Lipski <[email protected]>
@YousefED YousefED merged commit 88a09a4 into main Apr 19, 2023
@YousefED YousefED changed the title feat: customize formatting toolbar feat: customize formatting toolbar and sidemenu Apr 19, 2023
fogle pushed a commit to fogle/BlockNote that referenced this pull request May 20, 2023
* simplify formattingtoolbar

* Fixed React component types and added customizable formatting toolbar factory

* Finished formatting toolbar customization with old props

* Changed formatting toolbar props to use BlockNoteEditor

* Fixed text alignment with basic selection object

* Fixed block nesting tests

* Removed multiple block shorthand for updateBlock

* Added comments

* Removed redundant useCallback hooks

* Split `getActiveLink` to get text & url separately

* Removed unnecessary functions and `useCallback` hooks

* removed unnecessary `focus` calls

* Small fix

* Inline code style fix

* Added docs

* Small update

* Made selection undefined if nothing is selected

* Added selection docs

* Added styling docs

* Added nesting & un-nesting docs

* Small fix

* Added selection demo

* Minor fixes

* fix: hyperlink creation menu losing focus on click (TypeCellOS#168)

* Doc changes & cleanup

* feat: customizable sidemenu (TypeCellOS#143)

* simplify colorpicker

* Added basic mouse cursor position

* Added drag handle menu customization API

* Copied changes from PR and minor improvements

* Small changes

* Added `DragHandleMenuItem` component

* Fixed side menu unnecessary updates

* Removed unnecessary state

* Cleaned up code

* Changed how the side menu gets the hovered block

* Added side menu image

* Added docs

* Fixed comments in demo

* Made all menus/toolbars scroll with page

* Revert "Made all menus/toolbars scroll with page"

This reverts commit ee61bd0.

* Removed `editor` from dynamic props

* Documentation changes

* Small cleanup

* Vanilla example fix

---------

Co-authored-by: Matthew Lipski <[email protected]>
Co-authored-by: Matthew Lipski <[email protected]>

---------

Co-authored-by: Matthew Lipski <[email protected]>
Co-authored-by: Matthew Lipski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants