rago1975が自ら環境を構築して執筆するブログ

テスト

テスト。

$ sudo pacman -Syyu

o0194026013233521669.jpg

import wagtail.admin.rich_text.editors.draftail.features as draftail_features
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler, BlockElementHandler
from wagtail.core import hooks


@hooks.register('register_rich_text_features')
def register_blockquote_feature(features):
    feature_name = 'blockquote'
    type_ = 'blockquote'
    tag = 'blockquote'

    control = {
        'type': type_,
        'label': '❝',
        'description': 'Quote',
        'element': 'blockquote',
    }

    features.register_editor_plugin(
        'draftail',
        feature_name,
        draftail_features.BlockFeature(control)
    )

    features.register_converter_rule(
        'contentstate',
        feature_name,
        {
            'from_database_format': {tag: BlockElementHandler(type_)},
            'to_database_format': {'block_map': {type_: tag}},
        }
    )
    features.default_features.append(feature_name)