src/pyams_content/component/paragraph/html.py
changeset 555 8e8a14452567
parent 538 0bd011d47c0b
child 586 28445044f6e3
--- a/src/pyams_content/component/paragraph/html.py	Thu May 24 10:51:45 2018 +0200
+++ b/src/pyams_content/component/paragraph/html.py	Fri May 25 08:03:41 2018 +0200
@@ -9,7 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from pyams_sequence.interfaces import ISequentialIntIds
 
 __docformat__ = 'restructuredtext'
 
@@ -24,19 +23,23 @@
 from pyams_content.component.links.interfaces import ILinkContainerTarget, IInternalLink, IExternalLink, IMailtoLink
 from pyams_content.component.paragraph.interfaces import IParagraphFactory
 from pyams_content.component.paragraph.interfaces.html import RAW_PARAGRAPH_TYPE, IRawParagraph, HTML_PARAGRAPH_TYPE, \
-    IHTMLParagraph
+    IHTMLParagraph, RAW_PARAGRAPH_RENDERERS, HTML_PARAGRAPH_RENDERERS
 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
+from pyams_sequence.interfaces import ISequentialIntIds
 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent
 
 # import packages
 from pyams_content.component.links import InternalLink, ExternalLink, MailtoLink
 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
+from pyams_content.features.renderer import RenderersVocabulary
 from pyams_utils.adapter import adapter_config
+from pyams_utils.factory import factory_config
 from pyams_utils.registry import utility_config, get_utility
 from pyams_utils.request import check_request
 from pyams_utils.traversing import get_parent
 from pyams_utils.url import absolute_url
+from pyams_utils.vocabulary import vocabulary_config
 from pyquery import PyQuery
 from pyramid.events import subscriber
 from pyramid.threadlocal import get_current_registry
@@ -52,6 +55,7 @@
 #
 
 @implementer(IRawParagraph)
+@factory_config(provided=IRawParagraph)
 class RawParagraph(BaseParagraph):
     """Raw HTML paragraph"""
 
@@ -59,6 +63,7 @@
     icon_hint = _("Raw HTML ")
 
     body = FieldProperty(IRawParagraph['body'])
+    renderer = FieldProperty(IRawParagraph['renderer'])
 
 
 @utility_config(name=RAW_PARAGRAPH_TYPE, provides=IParagraphFactory)
@@ -94,11 +99,19 @@
         return output
 
 
+@vocabulary_config(name=RAW_PARAGRAPH_RENDERERS)
+class RawParagraphRendererVocabulary(RenderersVocabulary):
+    """Raw HTML paragraph renderers vocabulary"""
+
+    content_interface = IRawParagraph
+
+
 #
 # HTML paragraph
 #
 
 @implementer(IHTMLParagraph, IIllustrationTarget, IExtFileContainerTarget, ILinkContainerTarget)
+@factory_config(provided=IHTMLParagraph)
 class HTMLParagraph(BaseParagraph):
     """HTML paragraph"""
 
@@ -106,6 +119,7 @@
     icon_hint = _("Rich text")
 
     body = FieldProperty(IHTMLParagraph['body'])
+    renderer = FieldProperty(IHTMLParagraph['renderer'])
 
 
 @utility_config(name=HTML_PARAGRAPH_TYPE, provides=IParagraphFactory)
@@ -223,3 +237,10 @@
                 else:
                     output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
         return output
+
+
+@vocabulary_config(name=HTML_PARAGRAPH_RENDERERS)
+class HTMLParagraphRendererVocabulary(RenderersVocabulary):
+    """HTML paragraph renderers vocabulary"""
+
+    content_interface = IHTMLParagraph