From f21b4146ac307e04083eb7065fd4c5818fd23df8 Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Tue, 30 Jan 2018 15:58:13 +0200 Subject: [PATCH] Move "default features" section out of Hallo-only docs --- .../customisation/page_editing_interface.rst | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/docs/advanced_topics/customisation/page_editing_interface.rst b/docs/advanced_topics/customisation/page_editing_interface.rst index 938aa8db84..10769f415d 100644 --- a/docs/advanced_topics/customisation/page_editing_interface.rst +++ b/docs/advanced_topics/customisation/page_editing_interface.rst @@ -93,7 +93,15 @@ Adding new features to this list is generally a two step process: Both of these steps are performed through the ``register_rich_text_features`` hook (see :ref:`admin_hooks`). The hook function is triggered on startup, and receives a *feature registry* object as its argument; this object keeps track of the behaviours associated with each feature identifier. -This process for adding new features is described in the following sections. +To have a feature active by default (i.e. on ``RichTextFields`` that do not define an explicit ``features`` list), add it to the ``default_features`` list on the ``features`` object: + +.. code-block:: python + + @hooks.register('register_rich_text_features') + def register_blockquote_feature(features): + features.default_features.append('strikethrough') + +The process for creating new features is described in the following sections. .. _extending_wysiwyg: @@ -148,20 +156,6 @@ The constructor for ``HalloPlugin`` accepts the following keyword arguments: * ``css`` - a dictionary of CSS files to be imported for this plugin, defined in the same way as a `Django form media `_ definition * ``order`` - an index number (default 100) specifying the order in which plugins should be listed, which in turn determines the order buttons will appear in the toolbar -To have a feature active by default (i.e. on ``RichTextFields`` that do not define an explicit ``features`` list), add it to the ``default_features`` list on the ``features`` object: - -.. code-block:: python - - from django.utils.html import format_html - - @hooks.register('register_rich_text_features') - def register_blockquote_feature(features): - features.register_editor_plugin( - 'hallo', 'block-quote', - # ... - ) - features.default_features.append('block-quote') - .. _whitelisting_rich_text_elements: