{ "info": { "author": "Souheil Chelfouh", "author_email": "trollfot@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Zope3", "Intended Audience :: Other Audience", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "=====================\ndolmen.widget.tinymce\n=====================\n\n`dolmen.widget.tinymce` is a package that provides a useable and\npluggable way to render a text field as a WYSIWG editor in a\n`zeam.form` Form.\n\nExample\n=======\n\nWe are going to develop here a small example, to demonstrate the use\nof `dolmen.widget.tinymce`. First, we need to create a model content with\na text field::\n\n >>> import grokcore.component as grok\n >>> from zope.interface import Interface\n >>> from zope.schema import Text\n >>> from zope.schema.fieldproperty import FieldProperty\n\n >>> class ICave(Interface):\n ... paintings = Text(title=u'Description of the cave paintings')\n\n >>> class Grotto(grok.Context):\n ... paintings = FieldProperty(ICave['paintings'])\n\nWe have now a model that defines a text field. We want to edit/view\nthis content, using a rich editor, allowing to input rich text and to\ndisplay it as valid HTML. To do so, we define a form:\n\n >>> from zeam.form.ztk import Form, Fields\n\n >>> class EditCave(Form):\n ... grok.name('edit')\n ... grok.context(ICave)\n ... ignoreContent = False\n ... fields = Fields(ICave)\n\n >>> grok.testing.grok_component('edit', EditCave)\n True\n\nAt this point, if we instanciate the form, we have a normal\nrendering::\n\n >>> from zope.publisher.browser import TestRequest\n\n >>> homecave = Grotto()\n >>> request = TestRequest()\n\n >>> form = EditCave(homecave, request)\n >>> form.updateWidgets()\n \n >>> print form.fieldWidgets.get('form.field.paintings').render() \n \n\nTo get the tinyMCE widget, you simply need to use the \"mode\" of the\nfield, to indicate what you want to render::\n\n >>> from dolmen.widget.tinymce import TINYMCE_INPUT\n\n >>> form = EditCave(homecave, request)\n >>> form.fields['paintings'].mode = TINYMCE_INPUT\n >>> form.updateWidgets()\n\n >>> print form.fieldWidgets.get('form.field.paintings').render()\n \n \n\nThe modes can be 'tinymce.input' for an input widget and\n'tinymce.display' to display the value as valid html::\n\n >>> from dolmen.widget.tinymce import TINYMCE_DISPLAY\n >>> homecave.paintings = u\"
Mammoth
\"\n \n >>> form = EditCave(homecave, request)\n >>> form.fields['paintings'].mode = TINYMCE_DISPLAY\n >>> form.updateWidgets()\n\n >>> print form.fieldWidgets.get('form.field.paintings').render()\nMammoth