Added editor to HTML portlet
authorThierry Florac <tflorac@ulthar.net>
Fri, 21 Dec 2018 20:11:48 +0100
changeset 244 92a8197836dc
parent 243 3f011284253c
child 245 3a76d0bdc3c7
Added editor to HTML portlet
src/pyams_portal/portlets/html/zmi/__init__.py
--- a/src/pyams_portal/portlets/html/zmi/__init__.py	Mon Dec 17 14:40:45 2018 +0100
+++ b/src/pyams_portal/portlets/html/zmi/__init__.py	Fri Dec 21 20:11:48 2018 +0100
@@ -12,25 +12,21 @@
 
 __docformat__ = 'restructuredtext'
 
+from zope.interface import Interface, alsoProvides
 
-# import standard library
-
-# import interfaces
+from pyams_form.form import AJAXEditForm
 from pyams_form.interfaces.form import IInnerTabForm
 from pyams_pagelet.interfaces import IPagelet
+from pyams_pagelet.pagelet import pagelet_config
 from pyams_portal.interfaces import IPortletPreviewer
-from pyams_portal.portlets.html.interfaces import IRawPortletSettings, IHTMLPortletSettings
+from pyams_portal.portlet import PortletPreviewer
+from pyams_portal.portlets.html.interfaces import IHTMLPortletSettings, IRawPortletSettings
+from pyams_portal.zmi.portlet import PortletSettingsEditor, PortletSettingsPropertiesEditor
 from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-
-# import packages
-from pyams_form.form import AJAXEditForm
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_portal.portlet import PortletPreviewer
-from pyams_portal.zmi.portlet import PortletSettingsEditor, PortletSettingsPropertiesEditor
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config
-from zope.interface import Interface
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+from pyams_utils.interfaces.data import IObjectData
 
 
 #
@@ -52,7 +48,12 @@
     def updateWidgets(self, prefix=None):
         super(RawPortletSettingsPropertiesEditor, 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(name='properties.json', context=(IRawPortletSettings, IPyAMSLayer), provides=IPagelet)