This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 0f3d06777befa8f65a5360bea687cd324e497a7f Author: Marcus Christie <[email protected]> AuthorDate: Tue Jul 13 18:23:12 2021 -0400 AIRAVATA-3488 Enable some additional feature in RichTextBlock --- django_airavata/wagtailapps/base/wagtail_hooks.py | 41 +++++------------------ 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/django_airavata/wagtailapps/base/wagtail_hooks.py b/django_airavata/wagtailapps/base/wagtail_hooks.py index 0f93542..11e211a 100644 --- a/django_airavata/wagtailapps/base/wagtail_hooks.py +++ b/django_airavata/wagtailapps/base/wagtail_hooks.py @@ -1,10 +1,6 @@ import logging -import wagtail.admin.rich_text.editors.draftail.features as draftail_features from django.shortcuts import redirect -from wagtail.admin.rich_text.converters.html_to_contentstate import ( - InlineStyleElementHandler -) from wagtail.core import hooks logger = logging.getLogger(__name__) @@ -13,35 +9,14 @@ logger = logging.getLogger(__name__) @hooks.register('register_rich_text_features') def register_custom_style_feature(features): - feature_name = 'purple' - type_ = feature_name.upper() - tag = 'span' - detection = '{tag}[class="{feature_name}"]'.format( - tag=tag, feature_name=feature_name) - - control = { - 'type': type_, - 'description': 'Purple Color', - # This should be an svg which will occupy a 1024x1024 viewbox - 'icon': ['M100 100 H 900 V 900 H 100 Z'], - 'label': 'purple', - # .purple is the class which is defined in draft-colors.css . It is necessary to get this style working. - 'style': {'color': 'purple'}, - } - - features.register_editor_plugin( - 'draftail', feature_name, draftail_features.InlineStyleFeature(control) - ) - - db_conversion = { - 'from_database_format': {detection: InlineStyleElementHandler(type_)}, - 'to_database_format': {'style_map': {type_: {'element': tag, 'props': {'class': feature_name}}}}, - } - - features.register_converter_rule( - 'contentstate', feature_name, db_conversion) - - features.default_features.append(feature_name) + features.default_features.insert(5, 'h1') + features.default_features.insert(9, 'h5') + features.default_features.insert(10, 'h6') + features.default_features.append('superscript') + features.default_features.append('subscript') + features.default_features.append('code') + features.default_features.append('blockquote') + # logger.debug(f"default_features={features.default_features}") DIRECT_SERVE_FILE_EXTENSIONS = ["pdf"]
