1 year ago
#342843
Hatim
How to add custom (string based) bullet list into wagtail WYSIWYG
I am looking for a way to register a new editor feature to the wagtail WYSIWYG editor.
The following code adds the bullet list to the editor. (It is also built-in).
@hooks.register('register_rich_text_features')
def register_arrow_styling(features):
""" Add the <arrow> to the ritch text editoe."""
feature_name = "somename"
type_ = "unordered-list-item"
tag = "li"
control = {
'type': type_,
'label': 'arrow',
'description': 'list item',
}
features.register_editor_plugin(
'draftail',
feature_name,
draftail_features.BlockFeature(control)
)
db_conversion = {
'from_database_format': {
"ul": ListElementHandler(type_),
tag: ListItemElementHandler(),
},
'to_database_format': {
'block_map': {type_: {
"element": tag,
"wrapper": "ul",
"props": {
"class": "li-arrow",
}
}}
},
}
features.register_converter_rule(
'contentstate',
feature_name,
db_conversion
)
# This will register this feature with all editors by default
features.default_features.append(feature_name)
What I need is to make the editor adds based list points (say "-") instead of the regular bullet points, so I can style it as a text, e.g. change color.
The main goal actually is to get the freedom of changing the bullet points colors.
Thanks
python-3.x
wysiwyg
wagtail
wagtail-admin
draftail
0 Answers
Your Answer