-
Notifications
You must be signed in to change notification settings - Fork 3.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
Allow nodes to be conditionally void #2538
Comments
@brendancarney A side thought about this solution for your specific use case-- one thing I've run into is that In your case, if But, to address the change overall, I think it's a great addition. It would make sense, in my opinion, to update the rules that got similar treatment in #2151 so they take So: type: type => type !== 'list' Becomes: type: node => node.type !== 'list' This is also consistent with |
Hi there! @alanctkc I'd like to add one more use case where I need this dynamically set How it works now: Problem: Preferable solution: |
Fixed by #3093. |
Do you want to request a feature or report a bug?
Feature
What's the current behavior?
Nodes are statically void depending on the schema.
Proposal
Add a way to allow nodes to be conditionally void, determinable by some factor outside of Slate's document structure.
Use Case
One use case I have is an editable HTML node inside the editor. This node has two modes:
edit
andpreview
. Inedit
mode, the editor behaves as it normally would. Inpreview
mode, the node should function like a void node.Possible Solution
This solution was suggested by in Slack by @isubasti, with input from @alanctkc: https://slate-js.slack.com/archives/C1RH7AXSS/p1547614932631900
We could make
isVoid
in the schema allow a function as a value. This function could be passededitor
andnode
as arguments. In my case, I would provide the editor a prop that indicates which HTML nodes are in which modes, and read from that prop to determine whether or not the node is void. Example schema:I'd be happy to help implement something like this, and would also be happy to help with any other solution to this problem. Thanks!
The text was updated successfully, but these errors were encountered: