Search code examples
apostrophe-cms

Apostrophe CMS Rich Text Global Toolbar


I'm wondering if it's possible to define a global default toolbar and global default styles that will be displayed by every rich-text-widget in the site, unless overridden on a per-widget basis.

e.g. I'd like to use something like:

{{ apos.area(data.widget, 'content', {
  widgets: {
    'apostrophe-rich-text': {}
  }
}) }}

and still have it display the toolbar with the Styles dropdown and some pre-defined styling options.

Is this possible?


Solution

  • Often the Apostrophe team will write a wrapper macro for areas/singletons with the default configuration baked in.

    A simple example would be like:

    In views/area.html

    {% macro defaultArea(context, name) %}
      {{ apos.area(context, name, {
        'apostrophe-rich-text': {},
        'apostrophe-images': {}
      }) }}
    {% endmacro %}
    

    Then in your template

    {% import 'apostrophe-templates:areas.html' as areas %}
    
    <div>
      {{ areas.defaultArea(data.page, 'body') }}
    </div>