Added editor to raw code paragraph
authorThierry Florac <tflorac@ulthar.net>
Fri, 21 Dec 2018 20:21:21 +0100
changeset 1194 d4ae54d8fe17
parent 1193 7601e1471970
child 1195 9870e7467087
Added editor to raw code paragraph
src/pyams_content/component/paragraph/zmi/html.py
--- a/src/pyams_content/component/paragraph/zmi/html.py	Fri Dec 21 13:56:34 2018 +0100
+++ b/src/pyams_content/component/paragraph/zmi/html.py	Fri Dec 21 20:21:21 2018 +0100
@@ -14,8 +14,9 @@
 
 from z3c.form import button, field
 from z3c.form.interfaces import INPUT_MODE
-from zope.interface import implementer
+from zope.interface import alsoProvides, implementer
 
+from pyams_content import _
 from pyams_content.component.association.interfaces import IAssociationContainerTarget
 from pyams_content.component.association.zmi import AssociationsTable
 from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm
@@ -41,14 +42,13 @@
 from pyams_skin.viewlet.menu import MenuDivider
 from pyams_utils.adapter import adapter_config
 from pyams_utils.html import html_to_text
+from pyams_utils.interfaces.data import IObjectData
 from pyams_utils.text import get_text_start
 from pyams_utils.traversing import get_parent
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.form import AdminDialogAddForm
 from pyams_zmi.interfaces import IPropertiesEditForm
 
-from pyams_content import _
-
 
 #
 # Raw HTML paragraph
@@ -96,7 +96,12 @@
     def updateWidgets(self, prefix=None):
         super(RawParagraphAddForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
-            self.widgets['body'].widget_css_class = 'monospace input height-200'
+            widget = self.widgets['body']
+            widget.widget_css_class = 'monospace input height-400 text-editor'
+            widget.object_data = {
+                'ams-editor-mode': 'ace/mode/html'
+            }
+            alsoProvides(widget, IObjectData)
 
     def create(self, data):
         return RawParagraph()
@@ -125,7 +130,12 @@
     def updateWidgets(self, prefix=None):
         super(RawParagraphPropertiesEditForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
-            self.widgets['body'].widget_css_class = 'monospace input height-200'
+            widget = self.widgets['body']
+            widget.widget_css_class = 'monospace input height-400 text-editor'
+            widget.object_data = {
+                'ams-editor-mode': 'ace/mode/html'
+            }
+            alsoProvides(widget, IObjectData)
 
 
 @adapter_config(context=(IRawParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)