feat: improve edra editor and toolbar functionality#31
Conversation
SoRobby
commented
Mar 22, 2025
- Fix editor focus to correctly handle text selection, ensuring the bubble menu displays on double-click and drag.
- Set cursor to the clicked text position, defaulting to the end of the document if needed.
- Update toolbar logic: allow optional children, support ordered commands, and simplify the internal implementation.
- Add allowedBubbleMenuCommands parameter to customize bubble menu behavior.
- Introduce new editor props (showSlashCommands, allowedCommands) for additional configuration.
- Improve parameter naming to align with tiptap conventions.
- Fix QuickColor behavior to close upon color selection.
- Update documentation and examples to reflect these changes.
- For both shadcn and headless, user can define a list of allowed menubar commands to be visible. - Fixed typo of headless component.
- Added feature to allow enabling/disabling of the slash command menu by adding property to the Edra component.
- Minor improvements to parameter naming convention to match tiptap docs.
- Toolbar commands are displayed in the order they appear in the list `allowedCommands` list.
- This allows special commands to components to be passed to the toolbar.
…ng to end of document - Set editor focus and move cursor to click position, defaulting to document end if no text is found.
Tsuzat
left a comment
There was a problem hiding this comment.
QuickColor, by default, should not close on select. The reason is that, in this way, the user can try multiple options and change them instantaneously. Otherwise, the user might have to do multiple clicks for changing 2-3 colors.
What can be done, is introduce an optional prop, shouldCloseOnSelect which should be "false" by default.
Tsuzat
left a comment
There was a problem hiding this comment.
Can we try to move this getOrderedToolbarItems function in utils.ts if the implementation is same??
|
I have a mixed feeling with |
Tsuzat
left a comment
There was a problem hiding this comment.
I think focusEditor can be moved to utils.ts and then can be utilized in editor.svelte.
I see your perspective, and that makes sense; my goal was to mimic how Microsoft Word works to create an expected user experience. I removed this change from the codebase and the QuickColor will now stay open.
Agreed, moved to
Agreed, moved to
Yes, the code does become more difficult to modify. While adding these features (the If no children exist all commands can be displayed by default I personally prefer the children approach (as shown above), where each child command (e.g., What is your thought on this? |
Tsuzat
left a comment
There was a problem hiding this comment.
This is an amazing feature. Thanks for the contribution.
This makes more sense. One can also use EdraToolBarIcon for consistency along with commands. But again, if the developer wants to change the toolbar or bubble-menu, they can do it right in the code base itself. This is why |
|
In my opinion, following changes are amazing and really add amazing features.
Whereas this needs an attention,
What do you think @SoRobby ? |
|
Hi @SoRobby, following changesets is amazing and I'd like to merge them ASAP.
For rest of the changes, we need to have some discussions. Can you please create a separate pull request with these changesets? Also do change the cursor as the div will now have a role of button. You can make change in .edra-editor, .tiptap {
cursor: text;
} |
|
I'll make another PR within the next day or so that address the feedback. To continue the discussion of commands:
While editing the Edra component directly works well for certain cases, especially when you want a single, predefined editor setup. I’ve found that in some projects, I need multiple editors with different sets of commands. In those scenarios, having a way to configure the toolbar externally (e.g., via children or props) is really helpful for maintaining flexibility and reducing duplication. This was the main motivation behind configuring the toolbar and other components to accept a set of commands. With the children command approach: I believe with this approach devs can still easily customize the editor to fit their specific use cases, while being easily extendable and modifiable to fit multiple editors that have different command sets. This would also allow for some really neat functionality such as devs can potentially extend So here is what I propose:
What are your thoughts regarding this structure and these changes? |
|
That's make perfect sense to me. I think we need to do following things here.
I'll try to implement these features. |
…ntions - Merged latest changes from main branch and refactored code - Renamed `showBubbleMenus` to `showBubbleMenu` for consistency with tiptap terminology - Renamed `showSlashCommand` to `showSlashCommands` to accurately reflect its behavior - Corrected typo in `SearcnAndReplace`, changed to `SearchAndReplace` - Removed `getOrderedToolbarItems` utility as a new child-component approach is now used
|
@Tsuzat The changes look great! I've merged them into my branch. Please hold off on merging this PR, I'm still working on docs and parameter naming. I'll let you know when it's ready. |
- added `showLinkBubbleMenu` and `showTableBubbleMenu` properties to the Edra editor, both default to true - updated documentation and examples extensively to reflect recent feature additions and configuration changes - improved demo settings with more descriptive text for each option - added <meta name="robots" content="index,follow"> for SEO improvements - applied minor styling changes to the demo interface and toolbar components
|
@Tsuzat The PR is now ready to be merged. Thanks for your updates, they were great! Recent pushes include: updated docs, corrected parameter and file misspellings, added meta robot tag for search engines, removed unused utils (that I had previously added). |