<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://www.xmlmind.com/xmleditor/schema/configuration"
  xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration"
  xmlns:s="http://www.xmlmind.com/ns/sect">

  <!-- CSS stylesheets =================================================== -->

  <css location="section.css" name="Normal" />

  <!-- Toolbar =========================================================== -->

  <toolBar>
    <button toolTip="Toggle bold" 
            icon="xxe-config:common/icons/bold.png">
      <class>com.xmlmind.xmleditapp.kit.part.toolbar.TextStyleToggle</class>

      <command name="pass"
        parameter="{http://www.xmlmind.com/ns/sect}bold" />
    </button>

    <button toolTip="Toggle italic" 
            icon="xxe-config:common/icons/italic.png">
      <class>com.xmlmind.xmleditapp.kit.part.toolbar.TextStyleToggle</class>

      <command name="pass" 
        parameter="{http://www.xmlmind.com/ns/sect}italic" />
    </button>

    <button toolTip="Toggle literal" 
            icon="xxe-config:common/icons/typewriter.png">
      <class>com.xmlmind.xmleditapp.kit.part.toolbar.TextStyleToggle</class>

      <command name="pass" 
        parameter="{http://www.xmlmind.com/ns/sect}literal" />
    </button>

    <separator />

    <button toolTip="Add paragraph [Enter]" 
            icon="xxe-config:common/icons/paragraph.png">
      <command name="add" 
        parameter="after[implicitElement] {http://www.xmlmind.com/ns/sect}paragraph" />
    </button>

    <button toolTip="Add image" icon="xxe-config:common/icons/figure_menu.png">
      <menu>
        <item label="image" command="insert"
          parameter="into {http://www.xmlmind.com/ns/sect}image" />
        <item label="paragraph containing image" command="add"
          parameter="after[implicitElement] #template({http://www.xmlmind.com/ns/sect}paragraph,image)" />
      </menu>
    </button>

    <button toolTip="Add table" icon="xxe-config:common/icons/table_menu.png">
      <menu>
        <item label="table" command="add"
          parameter="after[implicitElement] {http://www.xmlmind.com/ns/sect}table" />
        <item label="table(header)" command="add"
          parameter="after[implicitElement] #template({http://www.xmlmind.com/ns/sect}table,header)" />
      </menu>
    </button>

    <button toolTip="Add section" icon="xxe-config:common/icons/section.png">
      <command name="add" 
        parameter="after[implicitElement] {http://www.xmlmind.com/ns/sect}section" />
    </button>
  </toolBar>

  <!-- Element templates ================================================= -->

  <elementTemplate name="rows2" selectable="override">
    <table xmlns="http://www.xmlmind.com/ns/sect">
      <tableRow>
        <tableCell><paragraph></paragraph></tableCell>
        <tableCell><paragraph></paragraph></tableCell>
      </tableRow>
      <tableRow>
        <tableCell><paragraph></paragraph></tableCell>
        <tableCell><paragraph></paragraph></tableCell>
      </tableRow>
    </table>
  </elementTemplate>

  <elementTemplate name="header">
    <table xmlns="http://www.xmlmind.com/ns/sect">
      <tableHeader>
        <tableCell><paragraph></paragraph></tableCell>
        <tableCell><paragraph></paragraph></tableCell>
      </tableHeader>
      <tableRow>
        <tableCell><paragraph></paragraph></tableCell>
        <tableCell><paragraph></paragraph></tableCell>
      </tableRow>
      <tableRow>
        <tableCell><paragraph></paragraph></tableCell>
        <tableCell><paragraph></paragraph></tableCell>
      </tableRow>
    </table>
  </elementTemplate>

  <elementTemplate name="image" selectable="false">
    <paragraph xmlns="http://www.xmlmind.com/ns/sect"><image source="???"/></paragraph>
  </elementTemplate>

  <!-- Menu ============================================================== -->

  <menu label="Se_ction">
    <menu label="C_olumn" name="tableColumnMenu">
      <item label="_Insert Before"
            icon="xxe-config:common/icons/insertColumnBefore.png"
            command="sect.tableEdit" parameter="insertColumnBefore"/>
      <item label="I_nsert After"
            icon="xxe-config:common/icons/insertColumnAfter.png"
            command="sect.tableEdit" parameter="insertColumnAfter"/>
      <separator />
      <item label="_Cut"
            icon="xxe-config:common/icons/cut.png"
            command="sect.tableEdit" parameter="cutColumn"/>
      <item label="C_opy"
            icon="xxe-config:common/icons/copy.png"
            command="sect.tableEdit" parameter="copyColumn"/>
      <item label="_Paste Before"
            icon="xxe-config:common/icons/pasteBefore.png"
            command="sect.tableEdit" parameter="pasteColumnBefore"/>
      <item label="P_aste After"
            icon="xxe-config:common/icons/pasteAfter.png"
            command="sect.tableEdit" parameter="pasteColumnAfter"/>
      <item label="_Delete"
            icon="xxe-config:common/icons/deleteColumn.png"
            command="sect.tableEdit" parameter="deleteColumn"/>
      <separator />
      <item label="_Sort Rows..."
            icon="xxe-config:common/icons/sortRows.png"
            command="sect.tableEdit" parameter="sortRows"/>
    </menu>
    <menu label="_Row" name="tableRowMenu">
      <item label="_Insert Before"
            icon="xxe-config:common/icons/insertRowBefore.png"
            command="sect.tableEdit" parameter="insertRowBefore"/>
      <item label="I_nsert After"
            icon="xxe-config:common/icons/insertRowAfter.png"
            command="sect.tableEdit" parameter="insertRowAfter"/>
      <separator />
      <item label="_Cut"
            icon="xxe-config:common/icons/cut.png"
            command="sect.tableEdit" parameter="cutRow"/>
      <item label="C_opy"
            icon="xxe-config:common/icons/copy.png"
            command="sect.tableEdit" parameter="copyRow"/>
      <item label="_Paste Before"
            icon="xxe-config:common/icons/pasteBefore.png"
            command="sect.tableEdit" parameter="pasteRowBefore"/>
      <item label="P_aste After"
            icon="xxe-config:common/icons/pasteAfter.png"
            command="sect.tableEdit" parameter="pasteRowAfter"/>
      <item label="_Delete"
            icon="xxe-config:common/icons/deleteRow.png"
            command="sect.tableEdit" parameter="deleteRow"/>
    </menu>
    <menu label="C_ell">
      <item label="_Increment Column Span"
            icon="xxe-config:common/icons/incrementColumnSpan.png"
            command="sect.tableEdit" parameter="incrColumnSpan"/>
      <item label="_Decrement Column Span"
            icon="xxe-config:common/icons/decrementColumnSpan.png"
            command="sect.tableEdit" parameter="decrColumnSpan"/>
    </menu>
    <separator />
    <item label="_Convert to HTML"
          icon="xxe-config:common/mime_types/html.png"
          command="sect.convertToHTML" />
  </menu>

  <!-- Generic table edit command configured for our kind of tables. -->

  <command name="sect.tableEdit">
    <class>com.xmlmind.xmledit.cmd.table.GenericTableEdit</class>
  </command>

  <property name="sect.tableEdit.tableSpecification">
    table={http://www.xmlmind.com/ns/sect}table
    row={http://www.xmlmind.com/ns/sect}tableRow {http://www.xmlmind.com/ns/sect}tableHeader:header
    cell={http://www.xmlmind.com/ns/sect}tableCell
    columnSpan=columns
  </property>

  <!-- Command allowing to convert a section document to an HTML page. -->

  <command name="sect.convertToHTML">
    <macro>
      <sequence>
        <command name="selectConvertedFile" 
                 parameter="saveFileURLWithExtension=html" />
        <command name="sect.toHTML" parameter='"%_"' />
	<command name="preview" parameter="[lastConverted]" />
      </sequence>
    </macro>
  </command>

  <command name="sect.toHTML">
    <process>
      <!-- Create a folder for the images which are ``attached'' 
           to the section document. -->
      <mkdir dir="images" />

      <copyDocument to="__doc.xml">
        <!-- Ignore images having absolute source URLs. -->
        <resources match="^[a-zA-Z][a-zA-Z0-9.+-]*:/.+" />

        <!-- Copy images having relative source URLs to the images/ folder. -->
        <resources match=".+\.(png|jpg|jpeg|gif)" copyTo="images" />
      </copyDocument>

      <transform stylesheet="html.xsl" file="__doc.xml" to="__doc.html" />

      <upload base="%0">
        <copyFile file="__doc.html" to="%0" />
        <copyFiles files="images/*" toDir="images" />
      </upload>
    </process>
  </command>

  <!-- Bindings ========================================================== -->

  <!-- Let's pressing ENTER, DELETE and BACK_SPACE behave in a
       paragraph element like in a word-processor. -->

  <property name="$c blockList">
    {http://www.xmlmind.com/ns/sect}paragraph=paragraph
  </property>

  <binding>
    <keyPressed code="ENTER" />
    <command name="insertNewlineOrSplitBlock" />
  </binding>

  <binding>
    <keyPressed code="ENTER" modifiers="mod" />
    <command name="insertSameBlock" parameter="after" />
  </binding>

  <binding>
    <keyPressed code="ENTER" modifiers="mod shift" />
    <command name="insertSameBlock" parameter="before" />
  </binding>

  <binding>
    <keyPressed code="DELETE" />
    <command name="deleteSelectionOrJoinBlockOrDeleteChar" />
  </binding>

  <binding>
    <keyPressed code="BACK_SPACE" />
    <command name="deleteSelectionOrJoinBlockOrDeleteChar" 
             parameter="backwards" />
  </binding>

  <!-- An easy way to insert a break element. -->

  <binding>
    <keyPressed code="ENTER" modifiers="shift" />
    <command name="sect.insertBreak" />
  </binding>

  <command name="sect.insertBreak">
    <macro undoable="true">
      <sequence>
        <command name="insert" 
          parameter="into {http://www.xmlmind.com/ns/sect}break" />
	<!-- harmless if macro fails starting from here -->
        <command name="insertNode" parameter="textAfter" />
        <command name="cancelSelection" />
      </sequence>
    </macro>
  </command>

  <!-- Interactively resize an image by dragging a handle. -->

  <binding>
    <appEvent name="resize-image" />
    <command name="resizeImage" parameter="height=%{height} width=%{width}" />
  </binding>

  <binding>
    <appEvent name="rescale-image" />
    <command name="resizeImage" parameter="height width=%{width}" />
  </binding>

  <!-- Miscellaneous ===================================================== -->

  <documentResources>
    <resource path="//s:image/@source" />
  </documentResources>

  <spellCheckOptions useAutomaticSpellChecker="true" 
                     languageAttribute="xml:lang"
                     skippedElements="s:literal" />

</configuration>
