-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[WIP] Check if a block can be inserted when finding raw transforms #12799
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This creates a circular dependency between editor and blocks. The blocks module should not be aware of editor.
Can this be enforced from the editor module instead?
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.
If we could introduce a filter, something like:
then the editor module could register a filter to remove any transforms to blocks that weren't allowed. How does that sound? It seems that this filtering does need to happen here, because if the editor gets a block type that isn't allowed, it doesn't have any information about what to do with it, because the content of the paragraph block that should be created instead could live in any attribute of the block that isn't allowed.
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.
As an alternative to a filter, could we pass as an additional argument an array of "available" block names which can be applied as a filter for the block type? I could see this might be made more difficult by the fact there are other functions within the blocks module which call
getBlockTransforms
, it's not just called by the editor module.My worry with a filter might be that in mind of a refactor like proposed in #7119, there may be multiple editors present which each have their own set of limited blocks, which seems difficult/impossible to manage from a single filter.
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.
Passing in an argument would work for cases where
editor
needs a list of valid transforms, butpasteHandler
fromblocks
is used in theRichText
component to handle incoming pastes, and neither of these have a dependency oneditor
, and I figure that we don't want to introduce that either. So we'd have to have a new prop onRichText
that was the list of allowed, or denied, block types, so that theRichText
instances for the editor instance would have the right list. Does that seem right to you? It would mean altering every instantiation of aRichText
component, wouldn't it?