diff --git a/gen/__init__.py b/gen/__init__.py
index 54e4897..b5c649e 100644
--- a/gen/__init__.py
+++ b/gen/__init__.py
@@ -1113,8 +1113,16 @@ class String(Type):
specificWritePermission=False, width=None, height=None,
maxChars=None, colspan=1, master=None, masterValue=None,
focus=False, historized=False, mapping=None, label=None,
- transform='none'):
+ transform='none', styles=('p','h1','h2','h3','h4'),
+ allowImageUpload=True):
+ # According to format, the widget will be different: input field,
+ # textarea, inline editor...
self.format = format
+ # When format is XHTML, the list of styles that the user will be able to
+ # select in the styles dropdown is defined hereafter.
+ self.styles = styles
+ # When format is XHTML, do we allow the user to upload images in it ?
+ self.allowImageUpload = allowImageUpload
# The following field has a direct impact on the text entered by the
# user. It applies a transformation on it, exactly as does the CSS
# "text-transform" property. Allowed values are those allowed for the
diff --git a/gen/mixins/__init__.py b/gen/mixins/__init__.py
index e226950..3d1f9b1 100644
--- a/gen/mixins/__init__.py
+++ b/gen/mixins/__init__.py
@@ -1450,8 +1450,18 @@ class BaseMixin:
def getEditorInit(self, name):
'''Gets the Javascript init code for displaying a rich editor for
field named p_name.'''
- return "CKEDITOR.replace('%s', {toolbar: 'Appy', filebrowserUploadUrl:"\
- "'%s/upload'})" % (name, self.absolute_url())
+ # Define the attributes that will initialize the ckeditor instance for
+ # this field.
+ field = self.getAppyType(name)
+ ckAttrs = {'toolbar': 'Appy',
+ 'format_tags': '%s' % ';'.join(field.styles)}
+ if field.allowImageUpload:
+ ckAttrs['filebrowserUploadUrl'] = '%s/upload' % self.absolute_url()
+ ck = ''
+ for k, v in ckAttrs.iteritems():
+ ck += "%s: '%s'," % (k, v)
+ res = "CKEDITOR.replace('%s', {%s})" % (name, ck)
+ return res
def getCalendarInit(self, name, years):
'''Gets the Javascript init code for displaying a calendar popup for
diff --git a/gen/ui/appy.css b/gen/ui/appy.css
index 5b1d468..5f8f150 100644
--- a/gen/ui/appy.css
+++ b/gen/ui/appy.css
@@ -1,4 +1,4 @@
-body { font: 70% Lucida,Helvetica,Arial,sans-serif; background-color: #EAEAEA; }
+body { font: 75% Lucida,Helvetica,Arial,sans-serif; background-color: #EAEAEA; }
pre { font: 100% Lucida,Helvetica,Arial,sans-serif; margin: 0}
h1 { font-size: 11pt; margin:0;}
h2 { font-size: 10pt; margin:0; font-style: italic; font-weight: normal;}
@@ -32,7 +32,8 @@ ul { line-height: 1.2em; margin: 0 0 0.2em 0.6em; padding: 0;
list-style: none outside none;}
li { margin: 0; background-image: url("ui/li.gif"); padding-left: 10px;
background-repeat: no-repeat; background-position: 0 4px;}
-img {border: 0;}
+img {border: 0}
+.xhtml img { margin-right: 5px }
.main { width: 900px; background-color: white; box-shadow: 3px 3px 3px #A9A9A9;
border-style: solid; border-width: 1px; border-color: grey; }
diff --git a/gen/ui/ckeditor/config.js b/gen/ui/ckeditor/config.js
index 90baa51..7f2d17e 100644
--- a/gen/ui/ckeditor/config.js
+++ b/gen/ui/ckeditor/config.js
@@ -23,4 +23,9 @@ CKEDITOR.editorConfig = function( config )
'SpecialChar', 'PageBreak', 'Link', 'Unlink',
'-', 'Maximize']},
];
+ config.format_p = { element:'p', attributes:{'style':'margin:0;padding:0'}};
+ config.format_h1 = { element:'h1', attributes:{'style':'margin:0;padding:0'}};
+ config.format_h2 = { element:'h2', attributes:{'style':'margin:0;padding:0'}};
+ config.format_h3 = { element:'h3', attributes:{'style':'margin:0;padding:0'}};
+ config.format_h4 = { element:'h4', attributes:{'style':'margin:0;padding:0'}};
};
diff --git a/gen/ui/ckeditor/contents.css b/gen/ui/ckeditor/contents.css
index 0c70626..ff10393 100644
--- a/gen/ui/ckeditor/contents.css
+++ b/gen/ui/ckeditor/contents.css
@@ -3,23 +3,12 @@ Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
-body
-{
- /* Font */
- font-family: Arial, Verdana, sans-serif;
- font-size: 12px;
+body { font: 75% Lucida,Helvetica,Arial,sans-serif; background-color: white; }
- /* Text color */
- color: #222;
-
- /* Remove the background color to make it transparent */
- background-color: #fff;
-}
-
-ol,ul,dl
-{
- /* IE7: reset rtl list margin. (#7334) */
- *margin-right:0px;
- /* preserved spaces for list items with text direction other than the list. (#6249,#8049)*/
- padding:0 40px;
+ol,ul,dl {
+ /* IE7: reset rtl list margin. (#7334) */
+ *margin-right:0px;
+ /* preserved spaces for list items with text direction other than the list. (#6249,#8049)*/
+ padding:0 40px;
}
+img { margin-right: 5px}
diff --git a/gen/ui/widgets/string.pt b/gen/ui/widgets/string.pt
index cee7914..f308afb 100644
--- a/gen/ui/widgets/string.pt
+++ b/gen/ui/widgets/string.pt
@@ -10,11 +10,13 @@
********
-