kopia lustrzana https://github.com/wagtail/wagtail
Define bold and italic as rich text features
rodzic
7de7130f9f
commit
c043049bb6
|
@ -28,6 +28,19 @@ class HalloPlugin(object):
|
|||
return Media(js=self.js, css=self.css)
|
||||
|
||||
|
||||
class HalloFormatPlugin(HalloPlugin):
|
||||
def __init__(self, **kwargs):
|
||||
kwargs.setdefault('name', 'halloformat')
|
||||
self.format_name = kwargs['format_name']
|
||||
super(HalloFormatPlugin, self).__init__(**kwargs)
|
||||
|
||||
def construct_plugins_list(self, plugins):
|
||||
plugins.setdefault(self.name, {'formattings': {
|
||||
'bold': False, 'italic': False, 'strikeThrough': False, 'underline': False
|
||||
}})
|
||||
plugins[self.name]['formattings'][self.format_name] = True
|
||||
|
||||
|
||||
# Plugins which are always imported, and cannot be enabled/disabled via 'features'
|
||||
CORE_HALLO_PLUGINS = [
|
||||
HalloPlugin(name='halloreundo'),
|
||||
|
|
|
@ -7,7 +7,7 @@ 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 HalloPlugin
|
||||
from wagtail.wagtailadmin.rich_text import HalloFormatPlugin, HalloPlugin
|
||||
from wagtail.wagtailadmin.search import SearchArea
|
||||
from wagtail.wagtailadmin.utils import user_has_any_page_permission
|
||||
from wagtail.wagtailadmin.viewsets import viewsets
|
||||
|
@ -200,3 +200,13 @@ def register_core_features(features):
|
|||
)
|
||||
)
|
||||
features.default_features.append('link')
|
||||
|
||||
features.register_editor_plugin(
|
||||
'hallo', 'bold', HalloFormatPlugin(format_name='bold')
|
||||
)
|
||||
features.default_features.append('bold')
|
||||
|
||||
features.register_editor_plugin(
|
||||
'hallo', 'italic', HalloFormatPlugin(format_name='italic')
|
||||
)
|
||||
features.default_features.append('italic')
|
||||
|
|
Ładowanie…
Reference in New Issue