4

We need to be able to add super and sub-text to a rich text field without having the client dive into the markup. Has anyone successfully added this as a redactor or Craft plugin?

4

There are keyboard shortcuts that can accomplish super and subscript.

From the Redactor changelog:

  1. Superscript shortcut now crtl+h (high, super) instead of old ctrl+l

  2. Subscript shortcut now crtl+l (low, sub) instead of old ctrl+h

  • Those definitely worked. Now I'm wondering if we can trust the client with the keyboard shortcuts! Thank you! – Bill Columbia Sep 24 '14 at 15:23
1

Check out the example over at the Redactor documentation: Add Sup and Sub Buttons - As an aside, also check out this article over at Straightupcraft.com: How to add custom Redactor toolbars to the default Rich Text field.

  1. Save the example as a plugin file in craft/app/resources/lib/redactor/plugins, for example subsup.js (I don't know how to customize this so you can safely add custom plugins, or how to tell redactor to look for more than one place. An alternative way is to make a custom Craft plugin that add the plugin JS to the entry page).
  2. Make a custom redactor configuration file and add it to craft/config/redactor. This is the standard.json

    { buttons: ['html','formatting','bold','italic','unorderedlist','orderedlist','link','image','video'], plugins: ['fullscreen'], toolbarFixedBox: true }

  3. Add your plugin name to the plugins array:

    plugins: ['fullscreen', 'subsup'],

  4. In your field settings, under Config, select the custom config.json file.

Now, since we added the plugins file within the redactor/plugins folder, we risk it being overwritten. The best way is to add it via a plugin, but the mentioned process might be a quick way for you to add it now.

  • Ah ok. We are considering making a plugin, but haven't had a chance to take a stab at adding to control panel yet. This might be a good first go at it. Thanks for the tips! – Bill Columbia Sep 24 '14 at 15:22
1

Another option is a plugin I've built. Redactor Extras: https://github.com/elliotlewis/Redactor-Extras

Includes the plugin from Redactors site for Superscript and Subscript. Has other extras as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.