The case of the strange RichText widgets

On a Plone 4.3 with 1.8.0 and 1.1b5 installed, there's one weird bit of inconsistency:

The TinyMCE widget rendered by the's IRichText behaviour is different from any other RichText field added in the dexterity model. Even on the same page, for example, if I edit the Document dexterity type and add a rich text field, the resulting widget is different. How do I know? Try inserting an image by selecting it, in the popup dialog, from the site content browser. In the case of the IRichText text field, it will work, but it will not work for the default text field. So why is that? The IRichText schema could be nothing simpler:

from import RichText as RichTextField

class IRichText(model.Schema):

    text = RichTextField(

The answer is: it's a different widget, not the one coming from replaces the widget for the IRichText.text field:


from import RichTextWidget

    from import ICollection
    from import IRichText
    HAS_PAC = True
except ImportError:
    HAS_PAC = False
    @adapter(getSpecification(IRichText['text']), IWidgetsLayer)
    def RichTextFieldWidget(field, request):
        return FieldWidget(field, RichTextWidget(request))

And this is the code that actually fixes the relatedItems popup widget that enables embeding images in the text (from ):

        args['pattern_options'] = {
            'relatedItems': {
                'vocabularyUrl': '{0}/{1}'.format(
                'mode': 'browse',
                'basePath': folder_path,
                'folderTypes': utility.containsobjects.split('\n')
            'upload': {
                'initialFolder': initial,
                'currentPath': folder_url_relative,
                'baseUrl': config['document_base_url'],
                'relativePath': '@@fileUpload',
                'uploadMultiple': False,
                'maxFiles': 1,
                'showTitle': False
            'tiny': config,
            # This is for loading the languages on tinymce
            'loadingBaseUrl': '',
            'prependToUrl': 'resolveuid/',
            'linkAttribute': 'UID',
            'prependToScalePart': '/@@images/image/',
            'folderTypes': utility.containsobjects.split('\n'),
            'imageTypes': utility.imageobjects.split('\n'),
            'anchorSelector': utility.anchor_selector,
            'linkableTypes': utility.linkable.split('\n')
The relatedItems options is not filled in in the TinyMCE widget rendered directly by 
So, in my case, the fix is to register an adapter:
    Fix RichText widget: the provided one has proper relatedItems configuration
        for=" mypackage.IMyLayer"
Which only exposes a bug in collective.cover /, due to the way get_tinymce_options works. Oh well, moving on...