verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

Align Command pallet options with config.json #206

Closed jan-dh closed 1 year ago

jan-dh commented 1 year ago

Describe the bug

The command pallet shows me some options (headings for example) that were disabled in my JSON config file. This is the command pallet:

image

And my config file:

{
  "buttons": [
    "formatting",
    "bold",
    "italic",
    "underline",
    "strikethrough",
    "unordered-list",
    "ordered-list",
    "highlight",
    "code",
    "undo",
    "redo",
    "link"
  ],
  "toolbarFixed": true,
  "formatting": [
    "h2",
    "h3",
    "h4",
    "paragraph"
  ]
}

I would expect the command pallet to respect the heading restrictions I made in the config file. Otherwise it's very hard for me to prevent people from picking an H1 for example.

Steps to reproduce

  1. Install the latest version of the plugin
  2. create a custom config
  3. enable the command pallet.

Craft CMS version

Craft CMS 4.4.7.1

Plugin version

2.1.0

Multi-site?

"yes"

Additional context

Love the command pallet btw, gives a very Notion kind of vibe, really like it.

engram-design commented 1 year ago

Yep, this is a little tricky in practice, and we'll likely add a commands setting to the config. That's because you can include h1, etc either in the formatting setting, or at the top level buttons, and just makes it annoying to trawl through those options. In addition, maybe some people only want the heading option available in the command palette, but not a button (so in that case, it's not disabled per-se, just not available). That starts to get into more the https://github.com/verbb/vizy/issues/183 territory when you actually disable extensions altogether (so people can't paste in headings).

And there was a reason to not include all the available nodes as commands, so being able to tailor that a little easier will be the other goal here.

For now, you can modify the available commands following this user guide

engram-design commented 1 year ago

Updated in 2.1.1. Vizy will now filter out any options you set in the command palette if the button isn't enabled.

You can now also provide a commands option in editor config to manage options.