Plone 4.3 + plone.app.widgets - Dexterity RichText field widget?

I tried developing a Dexterity type TTW with two RichText fields (plus a RelationChoice).

I thought the RichText fields by default would have TinyMCE enabled, but apparently there's something wrong: The Dexterity schema editor & regular Plone UI show just a textarea with "edit without visual editor" link at the bottom.

Enabling the RichText behavior populates the type with a RichText field just fine, but since I need two, that's not an option.

Given the behavior shows TinyMCE just fine and regular (upgraded) pages' RichText fields use the upgraded TinyMCE, I cannot understand why the custom RichText field does not. I guess there's some configuration missing, but where?

A plone.app.widgets 1.9.1 changelog entry (by @seanupton) says it's possible to use Rich Text w/TinyMCE 4 in Dexterity types other than plone.app.contenttypes. How? What's required for that?

My Plone site is 4.3.12 with some upgrades:

  • plone.app.relationfield = 1.3.0
  • plone.app.z3cform = 1.0.1
  • plone.app.widgets = 1.9.1
  • plone.app.contenttypes = 1.1.1
  • z3c.form = 3.2.1

Post your XML?

Could be a JS issue... is there an error in your browser console?

I saw some requirejs-related errors, yes. But those were there also when TinyMCE was working ok. I am trying to find time to investigate this in more detail with a fresh instance to make absolutely sure the live site is not causing this in some way.

@petri Maybe this page will help you: https://play.pixelblaster.ro/blog/2016/06/13/the-case-of-the-strange-richtext-widgets/

The idea is that plone.app.widgets "cheats" and hardcodes that richtext widget, so you need to register the adapter.

You could also take a look at the eea/eea.climateadapt package, is using the same combination: Plone 4.3, dexterity, plone.app.widgets. In our case, we've released a custom egg of plone.app.widgets, to benefit from an updated Mockup.

1 Like

Thanks @tiberiuichim ! But the link does not work :frowning: I tried to find the blog on the site but could not...? UPDATE: Duh, it works with everything but Safari on OSX... weird.

Apologies for the lateness of my reply, but I have not tried this using TTW. You need to use plone.app.widgets.dx.RichTextFieldWidget, IIRC. To do that on an interface that is written in Python looks like this:

from plone.app.widgets.dx import RichTextFieldWidget  # req >= 1.9.1+

class IMyContent(model.Schema):

    directives.widget(foo=RichTextFieldWidget)
    foo = RichText()

    directives.widget(bar=RichTextFieldWidget)
    bar = RichText()

I am not sure how do do this in TTW plone.schemaeditor (1.4.1), as I have not tried assigning widgets using schema editor (though I think you might have to edit this in the supermodel XML of the type's schema using a dotted name to the widget).

Sean

@petri

...which should look like this if you want the XML equivalent to edit TTW:

>>> from plone.app.widgets.dx import RichTextFieldWidget
>>> from plone.autoform import directives
>>> from plone.supermodel import model, serializeSchema
>>> from plone.app.textfield import RichText
>>>
>>>
>>> class IMyThing(model.Schema):
...    directives.widget(foo=RichTextFieldWidget)
...    foo = RichText()
...
>>>
>>> xml = serializeSchema(IMyThing)
>>> print xml
<model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns:security="http://namespaces.plone.org/supermodel/security" xmlns:marshal="http://namespaces.plone.org/supermodel/marshal" xmlns:form="http://namespaces.plone.org/supermodel/form" xmlns="http://namespaces.plone.org/supermodel/schema">
  <schema>
    <field name="foo" type="plone.app.textfield.RichText">
      <form:widget type="plone.app.widgets.dx.RichTextFieldWidget"/>
    </field>
  </schema>
</model>
1 Like

Same problem here. What software are you using for that site, @tiberiuichim ?

Nothing fancy, nginx serving static files. I'll look into this, must be some misconfiguration somewhere.

This is google's cache, for the time being: https://webcache.googleusercontent.com/search?q=cache:137dcjWXzKEJ:https://play.pixelblaster.ro/blog/2016/06/13/the-case-of-the-strange-richtext-widgets/+&cd=1&hl=en&ct=clnk&gl=ro

Thx - the site works fine with Chrome.