0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Define ol/ul as rich text features

This commit is contained in:
Matt Westcott 2017-07-15 18:47:23 +02:00
parent c7f612a7fd
commit 61149a72a7
2 changed files with 27 additions and 1 deletions

View File

@ -56,6 +56,20 @@ class HalloHeadingPlugin(HalloPlugin):
plugins[self.name]['formatBlocks'].append(self.element)
class HalloListPlugin(HalloPlugin):
def __init__(self, **kwargs):
kwargs.setdefault('name', 'hallolists')
kwargs.setdefault('order', 40)
self.list_type = kwargs['list_type']
super(HalloListPlugin, self).__init__(**kwargs)
def construct_plugins_list(self, plugins):
plugins.setdefault(self.name, {'lists': {
'ordered': False, 'unordered': False
}})
plugins[self.name]['lists'][self.list_type] = True
# Plugins which are always imported, and cannot be enabled/disabled via 'features'
CORE_HALLO_PLUGINS = [
HalloPlugin(name='halloreundo', order=50),

View File

@ -7,7 +7,9 @@ from django.utils.translation import ugettext_lazy as _
from wagtail.wagtailadmin.menu import MenuItem, SubmenuMenuItem, settings_menu
from wagtail.wagtailadmin.navigation import get_explorable_root_page
from wagtail.wagtailadmin.rich_text import HalloFormatPlugin, HalloHeadingPlugin, HalloPlugin
from wagtail.wagtailadmin.rich_text import (
HalloFormatPlugin, HalloHeadingPlugin, HalloListPlugin, HalloPlugin
)
from wagtail.wagtailadmin.search import SearchArea
from wagtail.wagtailadmin.utils import user_has_any_page_permission
from wagtail.wagtailadmin.viewsets import viewsets
@ -217,3 +219,13 @@ def register_core_features(features):
'hallo', element, HalloHeadingPlugin(element=element)
)
features.default_features.extend(['p', 'h2', 'h3', 'h4'])
features.register_editor_plugin(
'hallo', 'ol', HalloListPlugin(list_type='ordered')
)
features.default_features.append('ol')
features.register_editor_plugin(
'hallo', 'ul', HalloListPlugin(list_type='unordered')
)
features.default_features.append('ul')