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

Why is Redactor trying to order my plugins? #218

Closed
lindseydiloreto opened this issue Apr 11, 2020 · 10 comments
Closed

Why is Redactor trying to order my plugins? #218

lindseydiloreto opened this issue Apr 11, 2020 · 10 comments
Milestone

Comments

@lindseydiloreto
Copy link
Contributor

For a few of the plugins being added automatically, they are telling Redactor to addButtonBefore or addButtonAfter another specific button...

It feels like the Craft plugin shouldn't be making decisions as to what order our Redactor plugins show up. Ideally, they would just appear in whatever order I have them listed in the JSON file.

  "buttons": [
    "bold",
    "italic",
    "underline",
    "link",
    "lists"
  ],
  "plugins": [
    "alignment",
    "table"   <--- Table is at the end
  ],

Ω 2020-04-11 at 3 33 56 PM

Because the Craft plugin is making these decisions, it's leading to strange behavior in my custom toolbar. When I add a plugin (for example table), it automatically places itself in the toolbar in a specific position. It's confusing because the plugin button ends up not where I placed it.

Can we please remove the preset order preferences? Or somehow make them overridable?

@andris-sevcenko
Copy link
Contributor

Those are plugins provided by Redactor, so not sure how smart it would be to tamper with that code.

@lindseydiloreto
Copy link
Contributor Author

Huh, I assumed that was just Craft's implementation of those libraries. It's odd that Redactor would be so strict about where those buttons will appear... isn't the entire point of Redactor its flexibility?

Is there any way to override that? I find it hard to believe that a Table button must go next to a Link button, no exceptions. 😕

@andris-sevcenko
Copy link
Contributor

It's probably possible to override that with some JS code, but, if we're going to tamper with this, let's do it right.

If you wanted to insert the table button in the middle there - how would you expect to define this in the config?

@andris-sevcenko andris-sevcenko added this to the 2.7 milestone May 26, 2020
@lindseydiloreto
Copy link
Contributor Author

Hmm... that's a great question, because Redactor is already squirrely about how you arrange the buttons.

Ideally, we'd be able to use the before and after methods to place them anywhere we want...

https://imperavi.com/redactor/docs/settings/button/#s-buttonsaddafter

But worst case scenario, I'd just expect it to land exactly where I put it in the plugins array...

  "plugins": [
    "alignment",
    "fontcolor",
    "table",   <--- Table should be in the middle
    "fullscreen",
    "clips"
  ]

@andris-sevcenko
Copy link
Contributor

@lindseydiloreto what I meant is how would you insert it between the bold and italic buttons, for example?

@lindseydiloreto
Copy link
Contributor Author

Are you asking "how do I envision it working?" Maybe something like this...

  "buttonsAddAfter": {
    "after": "bold",
    "buttons": ["table"] // Places the plugin button
  },
  "plugins": [
    "table" // Loads the plugin
  ],

... or possibly like this...

  "pluginsAddAfter": {
    "after": "bold",
    "buttons": ["table"] // Loads & places the button
  },

I have no idea how easily that jives with what Redactor and/or the Craft plugin are already doing. Glancing at this commit, it seems that the Craft plugin occasionally needs to use brute force with Redactor anyway.

Let me know your thoughts, or if I completely misunderstood the question! 😄

@brandonkelly brandonkelly modified the milestones: 2.7, 2.8 Aug 9, 2020
@visuallization
Copy link

It is really weird that redactor isn't able to just order the buttons like they are defined in the array. It is the default behaviour I would expect when defining buttons. Considering that redactor is a paid tool I would wish for more flexibility and predictability.

@andris-sevcenko
Copy link
Contributor

Took me a few months, but the solution is finally here in the form of a brand new enforceButtonOrder Redactor config option!

@andris-sevcenko
Copy link
Contributor

(With the next release)

@lindseydiloreto
Copy link
Contributor Author

Ahh, brilliant @andris-sevcenko! Thanks so much for nailing that down, my OCD will be much happier for it. 😄

Can't wait to take it for a spin! 🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants