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

Make it so clicking the option on a nested list will convert the root parent list #40196

Open
mwatson opened this issue Nov 14, 2024 · 0 comments

Comments

@mwatson
Copy link
Contributor

mwatson commented Nov 14, 2024

Currently the "turn list into table" menu item is hidden if you click AI assistant on a non-top level list. Users need to navigate to the root list to actually convert it. A slightly better behavior would be to allow the option to appear on any sub-list and then convert the full list to a table. I spent a few hours trying to get this working but there are some issues. Read on for more!

Steps required:

  1. AiAssistantToolbarDropdownContent currently hides the convert option by calling getBlockParents and seeing if there are any parent IDs. If there are then the option won't be shows. This is easy enough to change!
  2. After that the click handler is ultimately handleToolbarButtonClick in AiAssistantExtensionToolbarDropdownContent. Since this function re-fetches the selected blocks, here we will need to fetch the root ID (or otherwise override based on a value in request.options) so the canTransformToAIAssistant returns the correct value.
  3. After that we call transformToAIAssistant which is part of useTransformToAssistant. This method once again calls getSelectedBlockClientIds. So ultimately this method will need to get the root ID from those IDs and replace firstBlock from selectedBlockIds (which is what is replaced by the AI Assistant block). This is the trickiest part as this method relies a lot on the selected blocks and it I was unable to get it to successfully replace the parent block with AI Assistant.

I do think all of this is do-able, but someone might want to scope it out a little. I also worry about how much of transformToAIAssistant needs to be refactored since it's a pretty central part of the AI Assistant stuff. I think someone with better TS/React/Gutenberg chops than myself might be able to figure it out though!

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

No branches or pull requests

1 participant