deps in plugins #506
Replies: 2 comments
-
ok so we can pass deps to the editable, but this seems a bit awkward to use with the existing api. Here's a proposal. Could we add decorateDeps to the plugin type. Then in EditablePlugin we add a function export const decorateDepsPlugins = (plugins: SlatePlugin[], decorateDeps?: any[]) => {
return [...plugins.flatMap(p => p.decorateDeps ?? []), ...(decorateDeps ?? [])];
} We can memoize the result of combining all the deps and then pass the memoized result as the dependency array to useCallback for calculating the decorator? (not sure if thats allowed but I think it would be?) This seems relatively straight forward to implement and its not clear to me if there are downsides. If you want I can try to put together a pull request. |
Beta Was this translation helpful? Give feedback.
-
This looks good to me, PR is welcome 🙂 |
Beta Was this translation helpful? Give feedback.
-
Thanks for the amazing library. I have a question though. How can we express deps for plugin properties? For example decorate deps are allowed on the EditablePlugin here.
https://github.com/udecode/slate-plugins/blob/2af5e8e411741c68f3b2ef9da8a5294fbf5b69db/packages/core/src/components/EditablePlugins.tsx#L51
But on individual plugins there are no deps.
https://github.com/udecode/slate-plugins/blob/2af5e8e411741c68f3b2ef9da8a5294fbf5b69db/packages/core/src/types.ts#L84
I have a decorator which is created using async data, without deps the decorator is always stale.
Happy to help make changes for this to happen if it is not possible currently.
Beta Was this translation helpful? Give feedback.
All reactions