<kupu:feature
    name="wysiwyg_support"
    implementation="plone"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:kupu="http://kupu.oscom.org/namespaces/dist"
    xmlns:tal="http://xml.zope.org/namespaces/tal"
    xmlns:metal="http://xml.zope.org/namespaces/metal"
    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    >

  <kupu:part name="editorbox">

    <div metal:define-macro="wysiwygEditorBox">
      <tal:block tal:define="wysiwyg python: here.portal_membership.getAuthenticatedMember().getProperty('wysiwyg_editor');">
        <tal:haskupu tal:define="global haskupu python:wysiwyg=='Kupu' and here.browserSupportsKupu();" />
      </tal:block>

      <div tal:condition="haskupu">
        <kupu:define-slot name="has_kupu" />
      </div>

      <div tal:condition="not:haskupu">
        <kupu:define-slot name="not_has_kupu" />
      </div>
    </div>

  </kupu:part>

  <kupu:part name="eventhandler">
    <script type="text/javascript" tal:content="string:
      addEventHandler(window, 'load',  function() {
          window.kupu = initPloneKupu(document.getElementById('kupu-editor'), 'kupu-editor-textarea');
          window.kupuui = window.kupu.getTool('ui');
          window.drawertool = window.kupu.getTool('drawertool');
          window.kupu.initialize();}  , document);">
    </script>
  </kupu:part>

  <kupu:part name="textarea">
    <textarea
        cols="80"
        rows="25"
        tabindex=""
        name="description"
        tal:content="inputvalue"
        tal:attributes="name inputname;
                        id inputname;
                        onfocus onfocus|nothing;
                        onblur onblur|nothing;
                        tabindex tabindex|nothing;
                        rows rows|default;
                        cols cols|default;">
    </textarea>
  </kupu:part>

  <kupu:part name="textformatselector">

<div metal:define-macro="textFormatSelector"
     class="field"
     tal:define="tabindex    tabindex/next;
                 text_format python:request.get('text_format', getattr(here,'text_format','structured-text'))">

  <tal:editor tal:condition="haskupu">
     <input type="hidden" name="text_format" value="html" />
  </tal:editor>                 
  <tal:noeditor  tal:condition="not:haskupu">
    <label for="text_format" i18n:translate="label_format">Format</label>

    <div class="formHelp" i18n:translate="help_format">
      If you are unsure of which format to use, just select Plain
      Text and type the document as you usually do.
    </div>

    <input class="noborder"
           type="radio"
           name="text_format"
           value="structured-text"
           tabindex=""
           id="cb_structuredtext"
           tal:attributes="checked python:test(text_format=='structured-text', 1, None);
                           tabindex tabindex;"
           />
    <label for="cb_structuredtext" i18n:translate="structured_text">Structured Text</label> <br />

    <input class="noborder"
           type="radio"
           name="text_format"
           value="html"
           tabindex=""
           id="cb_html"
           tal:attributes="checked python:test(text_format=='html', 1, None);
                           tabindex tabindex;"
           />
    <label for="cb_html" i18n:translate="html">HTML</label> <br />

    <input class="noborder"
           type="radio"
           name="text_format"
           value="plain"
           tabindex=""
           id="cb_plain"
           tal:attributes="checked python:test(text_format=='plain', 1, None);
                           tabindex tabindex;"
           />
    <label for="cb_plain" i18n:translate="plain_text">Plain Text</label>

  </tal:noeditor>
</div>

  </kupu:part>

</kupu:feature>
