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

Allow tools to be set per-field #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnpuddephatt
Copy link

This allows tool config to be set on an individual field, which is very useful when Editor.js is being used in multiple places within Nova and different tools are desired in each place.

This allows tool config to be set on an individual field, which is very useful when Editor.js is being used in multiple places within Nova and different tools are desired in each place.
@roelofr
Copy link
Collaborator

roelofr commented Sep 25, 2022

This seems like a good start, but the config you'd have to enter for your Nova fields gets enormous with it, as you'd have to repeat all fields' settings.

Maybe we could add a withTools(string[] $tools): self method, that uses Arr::only to slice out the tools that should be enabled from the global config.

This would mean you can define your per-tool settings in your config, and then per-field set which tools are available with their config-based settings.

Let me know what you think.

@johnpuddephatt
Copy link
Author

The problem with the Arr::only approach is that while you can then choose which tools are enabled you can't have different tool configs on different fields (e.g. different fields might require different image sizes)

I agree the settings could/would be big, but couldn't this be easy to mitigate by the developer adding their tool config to the nova-editor-js config file? e.g. if I added:

"myCustomToolSettings" => [ .... ]

to config/nova-editor-js.php, I could then use the tools() method proposed in this PR like so:

->tools(config('nova-editor-js.myCustomToolSettings')

I could then reuse these configs. So I might have a "simple" config that just enables the headings plugin, and I might have an "advanced" config that enables everything. And my nova resource files stay nice and compact.

(Looking back on this I do think the method should probably be ->toolSettings() not ->tools() for consistency)

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

Successfully merging this pull request may close these issues.

2 participants