/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.uiextension.internal;

import javax.inject.Named;
import javax.inject.Singleton;

import org.xwiki.component.annotation.Component;
import org.xwiki.rendering.syntax.Syntax;

import com.xpn.xwiki.XWiki;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.internal.mandatory.AbstractMandatoryDocumentInitializer;
import com.xpn.xwiki.objects.classes.BaseClass;

/**
 * Update XWiki.UIExtensionClass document with all required informations.
 *
 * @version $Id$
 * @since 8.1RC1
 */
@Component
@Named("XWiki.UIExtensionClass")
@Singleton
public class UIExtensionClassDocumentInitializer extends AbstractMandatoryDocumentInitializer
    implements WikiUIExtensionConstants
{
    /**
     * Default constructor.
     */
    public UIExtensionClassDocumentInitializer()
    {
        super(XWiki.SYSTEM_SPACE, "UIExtensionClass");
    }

    @Override
    public boolean updateDocument(XWikiDocument document)
    {
        boolean needsUpdate = false;

        BaseClass bclass = document.getXClass();

        // Force the class document to use the 2.1 syntax default syntax, the same syntax used in the custom displayer.
        if (!Syntax.XWIKI_2_1.equals(document.getSyntax())) {
            document.setSyntax(Syntax.XWIKI_2_1);
            needsUpdate = true;
        }

        needsUpdate |= bclass.addTextField(EXTENSION_POINT_ID_PROPERTY, "Extension Point ID", 30);
        needsUpdate |= bclass.addTextField(ID_PROPERTY, "Extension ID", 30);
        needsUpdate |= bclass.addTextAreaField(CONTENT_PROPERTY, "Extension Content", 40, 10);
        needsUpdate |= bclass.addTextAreaField(PARAMETERS_PROPERTY, "Extension Parameters", 40, 10);
        needsUpdate |= bclass.addStaticListField(SCOPE_PROPERTY, "Extension Scope", 1, false,
            "wiki=Current Wiki|user=Current User|global=Global", "select");

        needsUpdate |= setClassDocumentFields(document, "UI Extension Class");

        return needsUpdate;
    }
}

@@ -2354,32 +2354,130 @@
 nsion ID%22, 30);%0A
+        // The content property supports wiki syntax, but it uses script macros most of the time.%0A
         needsUpd
@@ -2544,35 +2544,107 @@
 Content%22, 40, 10
+, %22Text%22
 );%0A
+        // The parameters property doesn't support wiki syntax.%0A
         needsUpd
@@ -2725,16 +2725,28 @@
 , 40, 10
+, %22PureText%22
 );%0A     

Use the right editor for the UIX content and parameters properties (TextArea)