-
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
Added functionality for setNode to take a function as props argument #4207
Conversation
|
@BrentFarese check here. The NodeProps type you asked me to adjust didn't work. |
Hey @adisen there's an issue with the TypeScript linting here. Are you able to fix it? If not, can you make your branch editable so that I can make changes to the PR? Thanks! |
It's the change from Hence the error that 'link' is not assignable to 'image'. Switching |
If there is any way to preserve the generic type, that might be preferred. What we want is for the callback to |
Perhaps it could be Specifying a concrete |
I think going without the generic for now is best, because I found that there were some weird gotchas in converting to generics in my other PR. Especially in cases like this where the generic was trying to be used for |
Is the scope of this issue limited to still returning the same node type - ie. I'm just coming back to a side-project that uses Slate and I've written an F# wrapper for (most of) the Slate API, but one of the things that causes me no end of issues is that I find myself often having to mutate the object and manually juggle types, but realistically - for use in TypeScript or F# - I'd want to completely transform from EDIT: Or maybe I'm just handling this wrong and should be using another pattern ( |
Oh interesting! My team have created bindings in ReScript. Is yours open source? Might be fun to compare notes 🤔
Possibly. Wrap and unwrap will work, it's just a little more effort. |
@adisen are you still interested in this PR? If so, it needs a rebase and there's some feedback to address. Thanks! |
Closing due to inactivity. Feel free to reopen or re-raise if there's interest. |
Description
This PR allows Transforms.setNodes to take either a Partial as it second argument to props (which we have before) which overrides the props on the node or a function that takes the existing props for the relevant node and returns a new set of props to attach to the node.
Issue
Fixes: #3808
Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)