Carlos Villegas wrote:
In the Web edition,

There should be no difference between Web Edition and the desktop app. See appEvent binding below and non-interactive table column resizing command below.



I'm testing a type of definition list in my schema. The CSS is something like this:
definitionList {
    display: table;
    margin-left: 1ex;
    margin-top: 1ex;
    margin-bottom: 1ex;
}

definitionList > item {
    display: table-row;
}

definitionList > item > term {
    display: table-cell;
    padding: 0.3ex;
    width: 25%;
    font-weight: bold;
}

definitionList > item > definition {
    display: table-cell;
    padding: 0.3ex;
    width: 75%;
}

I noticed that in the web editor client, I can grab the border between term and definition and drag it about, which seems to be trying to interactively resize the columns,

For now, there is no way to prevent this from happening. If it's styled as a table, XXE assumes that it's an actual semantic table and that the user may want to resize its columns. This is clearly an oversight.



similar to the docbook tools for working with tables. It doesn't really work, 
but it looks like it's resizing the columns.

Yes.



Is it possible then to add some command and configuration to make it work interactively. Probably need to add an attribute for the width also.

It's more complicated than this because there is no generic command which, after a proper parameterization, would allow to resize the columns of all kinds of tables. See below.



If it's possible, what do I need to do?

In theory, yes. Here's how it works.

I'll use DITA <simpletable> (because these are quite simple tables; see https://docs.oasis-open.org/dita/dita/v1.3/errata02/os/complete/part2-tech-content/langRef/base/simpletable.html#simpletable and https://docs.oasis-open.org/dita/dita/v1.3/errata02/os/complete/part2-tech-content/langRef/attributes/simpletableAttributes.html) as an example:

Excerpts (simplified) from dita/topic_support.incl:
=============================================================
  <!-- Interactively resize a table column by dragging its separator. -->
  <binding>
    <appEvent name="resize-table-column" />
    <command name="dita.resizeSimpleTableColumn"
             parameter="%{resizedColumn} %{columnCount}
                        %{oldColumnWidths} %{newColumnWidths}" />
  </binding>

  <command name="dita.resizeSimpleTableColumn">
    <class>com.xmlmind.xmleditext.dita.ResizeSimpleTableColumn</class>
  </command>
=============================================================

--> The documentation of <appEvent name="resize-table-column" /> is found here:

https://www.xmlmind.com/xmleditor/_distrib/doc/configure/binding.html#resize_table_column_app_event

ResizeSimpleTableColumn.java:
=============================================================
package com.xmlmind.xmleditext.dita;

import com.xmlmind.xml.name.Namespace;
import com.xmlmind.xml.name.Name;
import com.xmlmind.xml.doc.Element;
import com.xmlmind.xmledit.control.CommandResult;
import com.xmlmind.xmledit.view.DocumentView;
import com.xmlmind.xmledit.cmd.CommandBase;
import com.xmlmind.xmleditapp.cmd.table.ResizeColumnHelper;

public final class ResizeSimpleTableColumn extends CommandBase {
    private Element simpleTable;
    private int[] proportionalColumnWidths;

    private static final Name SIMPLETABLE_NAME =
        Name.get(Namespace.NONE, "simpletable");

// ------------------------------------------------------------------------

    public ResizeSimpleTableColumn() {
        super(/*repeatable*/ false, /*recordable*/ false);
    }

    public boolean prepare(DocumentView docView,
                           String parameter, int x, int y) {
        proportionalColumnWidths = null;
        simpleTable = docView.getSelectedElement(/*implicit*/ false);
        if (simpleTable == null ||
            simpleTable.getName() != SIMPLETABLE_NAME ||
            !simpleTable.isEditable()) {
            simpleTable = null;
            return false;
        }

        if (parameter == null) {
            simpleTable = null;
            return false;
        }

        proportionalColumnWidths =
            ResizeColumnHelper.toProportionalWidths(parameter, 1000);
        if (proportionalColumnWidths == null) {
            simpleTable = null;
            return false;
        }

        return true;
    }

    public CommandResult doExecute(DocumentView docView,
                                   String parameter, int x, int y) {
        //INTERACTIVE: no

        StringBuilder buffer = new StringBuilder();

        final int columnCount = proportionalColumnWidths.length;
        for (int i = 0; i < columnCount; ++i) {
            if (i > 0) {
                buffer.append(' ');
            }
            buffer.append(Integer.toString(proportionalColumnWidths[i]));
            buffer.append('*');
        }

        simpleTable.putAttribute(Name.get(Namespace.NONE, "relcolwidth"),
                                 buffer.toString());

        docView.describeUndo(Msg.msg("RSTC.resizeTableColumn"));

        // Needed to refresh the Undo description in the GUI.
        docView.notifyContextChangeListeners();

        simpleTable = null;
        proportionalColumnWidths = null;
        return CommandResult.DONE;
    }
}
=============================================================


--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to