Search code examples
sap-commerce-cloud

How to configure an attribute to be edited with a RichTextBox editor in SmartEdit?


I noticed that CMSParagraphComponent's content attribute can be edited using a RichTextBox like depicted in below image: enter image description here

I want to edit my custom attribute in the same way(with the depicted RichTextBox). How can I do that ?

I tried configuring the backoffice-config.xml to use the wysiwyg:

<context merge-by="type" type="MyType" component="editor-area" module="moduleBackoffice">
    <editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
        <editorArea:tab merge-mode="replace" name="hmc.properties">
            <editorArea:section  name="hmc.properties">
                <editorArea:attribute
                        editor="com.hybris.cockpitng.editor.localized(com.hybris.cockpitng.editor.wysiwyg)"
                        qualifier="customStringAttribute"/>
            </editorArea:section>
        </editorArea:tab>
    </editorArea:editorArea>
</context>

But this only reflects in backoffice and has no effect on SmartEdit.

How can I use the RichTextBox in smartEdit ?

Hybris version: 6.7.0.3


Solution

  • This can be resolved by creating below Spring bean:

    <bean class="de.hybris.platform.cmsfacades.types.service.impl.DefaultComponentTypeAttributeStructure" p:typecode="MyType" p:qualifier="customStringAttribute">
        <property name="populators">
            <set>
                <ref bean="richTextComponentTypeAttributePopulator" />
                <ref bean="requiredComponentTypeAttributePopulator" />
            </set>
        </property>
    </bean>
    

    I added above defined bean in my ${extensionname}-spring.xml, restarted the server and everything worked as expected. The MyType's customStringAttribute is now configurable from smartedit in the exact same way as CMSParagraphComponent's content is.