Re: Interactive column sizing of elements formatted as tables
Carlos Villegas <[email protected]> Fri, 3 Oct 2025 00:48:04 +0900
| Newsgroups | gmane.editors.xxe.general |
|---|---|
| Message-ID | <CAAQ46WbTR2m3p9sjzRffXpCZTDrX-kn1x06JkcZ4WAKqN3ggMg@mail.gmail.com> |
--===============0711231614244500902== Content-Type: multipart/alternative; boundary="000000000000d04e6306402ee94c" --000000000000d04e6306402ee94c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks, I see how it works. So, there's the resize-table-column appEvent that I can bind a custom command to. I'll give it a try, thanks for the docs reference and the example. Carlos On Thu, Oct 2, 2025 at 10:04=E2=80=AFPM Hussein Shafie <[email protected]= > wrote: > 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-tec= h-content/langRef/base/simpletable.html#simpletable > and > > https://docs.oasis-open.org/dita/dita/v1.3/errata02/os/complete/part2-tec= h-content/langRef/attributes/simpletableAttributes.html) > > as an example: > > Excerpts (simplified) from dita/topic_support.incl: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > <!-- Interactively resize a table column by dragging its separator. --= > > <binding> > <appEvent name=3D"resize-table-column" /> > <command name=3D"dita.resizeSimpleTableColumn" > parameter=3D"%{resizedColumn} %{columnCount} > %{oldColumnWidths} %{newColumnWidths}" /> > </binding> > > <command name=3D"dita.resizeSimpleTableColumn"> > <class>com.xmlmind.xmleditext.dita.ResizeSimpleTableColumn</class> > </command> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --> The documentation of <appEvent name=3D"resize-table-column" /> is > found here: > > > https://www.xmlmind.com/xmleditor/_distrib/doc/configure/binding.html#res= ize_table_column_app_event > > ResizeSimpleTableColumn.java: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > 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 =3D > Name.get(Namespace.NONE, "simpletable"); > > // > ------------------------------------------------------------------------ > > public ResizeSimpleTableColumn() { > super(/*repeatable*/ false, /*recordable*/ false); > } > > public boolean prepare(DocumentView docView, > String parameter, int x, int y) { > proportionalColumnWidths =3D null; > simpleTable =3D docView.getSelectedElement(/*implicit*/ false); > if (simpleTable =3D=3D null || > simpleTable.getName() !=3D SIMPLETABLE_NAME || > !simpleTable.isEditable()) { > simpleTable =3D null; > return false; > } > > if (parameter =3D=3D null) { > simpleTable =3D null; > return false; > } > > proportionalColumnWidths =3D > ResizeColumnHelper.toProportionalWidths(parameter, 1000); > if (proportionalColumnWidths =3D=3D null) { > simpleTable =3D null; > return false; > } > > return true; > } > > public CommandResult doExecute(DocumentView docView, > String parameter, int x, int y) { > //INTERACTIVE: no > > StringBuilder buffer =3D new StringBuilder(); > > final int columnCount =3D proportionalColumnWidths.length; > for (int i =3D 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 =3D null; > proportionalColumnWidths =3D null; > return CommandResult.DONE; > } > } > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --000000000000d04e6306402ee94c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Thanks, I see how it works. So, there's the resize-tab= le-column appEvent that I can bind a custom command to.=C2=A0<div><div>I= 9;ll give it a try, thanks for the docs reference and the example.</div><di= v><br></div><div>Carlos</div></div></div><br><div class=3D"gmail_quote gmai= l_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, Oct 2, 202= 5 at 10:04=E2=80=AFPM Hussein Shafie <<a href=3D"mailto:hussein@xmlmind.= com">[email protected]</a>> wrote:<br></div><blockquote class=3D"gmail= _quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204= ,204);padding-left:1ex">Carlos Villegas wrote:<br> > In the Web edition, <br> <br> There should be no difference between Web Edition and the desktop app. <br> See appEvent binding below and non-interactive table column resizing <br> command below.<br> <br> <br> <br> > I'm testing a type of definition list in my schema. <br> > The CSS is something like this: <br> > <br> > definitionList {<br> >=C2=A0 =C2=A0 =C2=A0display: table;<br> >=C2=A0 =C2=A0 =C2=A0margin-left: 1ex;<br> >=C2=A0 =C2=A0 =C2=A0margin-top: 1ex;<br> >=C2=A0 =C2=A0 =C2=A0margin-bottom: 1ex;<br> > }<br> > <br> > definitionList > item {<br> >=C2=A0 =C2=A0 =C2=A0display: table-row;<br> > }<br> > <br> > definitionList > item > term {<br> >=C2=A0 =C2=A0 =C2=A0display: table-cell;<br> >=C2=A0 =C2=A0 =C2=A0padding: 0.3ex;<br> >=C2=A0 =C2=A0 =C2=A0width: 25%;<br> >=C2=A0 =C2=A0 =C2=A0font-weight: bold;<br> > }<br> > <br> > definitionList > item > definition {<br> >=C2=A0 =C2=A0 =C2=A0display: table-cell;<br> >=C2=A0 =C2=A0 =C2=A0padding: 0.3ex;<br> >=C2=A0 =C2=A0 =C2=A0width: 75%;<br> > }<br> > <br> > 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 interac= tively resize the columns, <br> <br> For now, there is no way to prevent this from happening. If it's styled= <br> as a table, XXE assumes that it's an actual semantic table and that the= <br> user may want to resize its columns. This is clearly an oversight.<br> <br> <br> <br> > similar to the docbook tools for working with tables. It doesn't r= eally work, but it looks like it's resizing the columns.<br> <br> Yes.<br> <br> <br> <br> > Is it possible then to add some command and configuration to make it w= ork interactively. Probably need to add an attribute for the width also. <b= r> <br> It's more complicated than this because there is no generic command <br= > which, after a proper parameterization, would allow to resize the <br> columns of all kinds of tables. See below.<br> <br> <br> <br> > If it's possible, what do I need to do?<br> <br> In theory, yes. Here's how it works.<br> <br> I'll use DITA <simpletable> (because these are quite simple table= s; see <br> <a href=3D"https://docs.oasis-open.org/dita/dita/v1.3/errata02/os/complete/= part2-tech-content/langRef/base/simpletable.html#simpletable" rel=3D"norefe= rrer" target=3D"_blank">https://docs.oasis-open.org/dita/dita/v1.3/errata02= /os/complete/part2-tech-content/langRef/base/simpletable.html#simpletable</= a> <br> and <br> <a href=3D"https://docs.oasis-open.org/dita/dita/v1.3/errata02/os/complete/= part2-tech-content/langRef/attributes/simpletableAttributes.html" rel=3D"no= referrer" target=3D"_blank">https://docs.oasis-open.org/dita/dita/v1.3/erra= ta02/os/complete/part2-tech-content/langRef/attributes/simpletableAttribute= s.html</a>) <br> as an example:<br> <br> Excerpts (simplified) from dita/topic_support.incl:<br> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br> =C2=A0 =C2=A0<!-- Interactively resize a table column by dragging its se= parator. --><br> =C2=A0 =C2=A0<binding><br> =C2=A0 =C2=A0 =C2=A0<appEvent name=3D"resize-table-column" /&g= t;<br> =C2=A0 =C2=A0 =C2=A0<command name=3D"dita.resizeSimpleTableColumn&q= uot;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 parameter=3D"%{resize= dColumn} %{columnCount}<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0%{oldColumnWidths} %{newColumnWidths}" /><br> =C2=A0 =C2=A0</binding><br> <br> =C2=A0 =C2=A0<command name=3D"dita.resizeSimpleTableColumn">= ;<br> =C2=A0 =C2=A0 =C2=A0<class>com.xmlmind.xmleditext.dita.ResizeSimpleTa= bleColumn</class><br> =C2=A0 =C2=A0</command><br> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br> <br> --> The documentation of <appEvent name=3D"resize-table-column&q= uot; /> is <br> found here:<br> <br> <a href=3D"https://www.xmlmind.com/xmleditor/_distrib/doc/configure/binding= .html#resize_table_column_app_event" rel=3D"noreferrer" target=3D"_blank">h= ttps://www.xmlmind.com/xmleditor/_distrib/doc/configure/binding.html#resize= _table_column_app_event</a><br> <br> ResizeSimpleTableColumn.java:<br> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br> package com.xmlmind.xmleditext.dita;<br> <br> import <a href=3D"http://com.xmlmind.xml.name" target=3D"_blank">com.xmlmin= d.xml.name</a>.Namespace;<br> import <a href=3D"http://com.xmlmind.xml.name.Name" rel=3D"noreferrer" targ= et=3D"_blank">com.xmlmind.xml.name.Name</a>;<br> import com.xmlmind.xml.doc.Element;<br> import com.xmlmind.xmledit.control.CommandResult;<br> import com.xmlmind.xmledit.view.DocumentView;<br> import com.xmlmind.xmledit.cmd.CommandBase;<br> import com.xmlmind.xmleditapp.cmd.table.ResizeColumnHelper;<br> <br> public final class ResizeSimpleTableColumn extends CommandBase {<br> =C2=A0 =C2=A0 =C2=A0private Element simpleTable;<br> =C2=A0 =C2=A0 =C2=A0private int[] proportionalColumnWidths;<br> <br> =C2=A0 =C2=A0 =C2=A0private static final Name SIMPLETABLE_NAME =3D<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Name.get(Namespace.NONE, "simpletabl= e");<br> <br> =C2=A0 =C2=A0 =C2=A0// <br> ------------------------------------------------------------------------<br= > <br> =C2=A0 =C2=A0 =C2=A0public ResizeSimpleTableColumn() {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0super(/*repeatable*/ false, /*recordable*= / false);<br> =C2=A0 =C2=A0 =C2=A0}<br> <br> =C2=A0 =C2=A0 =C2=A0public boolean prepare(DocumentView docView,<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 String parameter, int x, int y) {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0proportionalColumnWidths =3D null;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0simpleTable =3D docView.getSelectedElemen= t(/*implicit*/ false);<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (simpleTable =3D=3D null ||<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0simpleTable.getName() !=3D = SIMPLETABLE_NAME ||<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0!simpleTable.isEditable()) = {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0simpleTable =3D null;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return false;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (parameter =3D=3D null) {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0simpleTable =3D null;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return false;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0proportionalColumnWidths =3D<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ResizeColumnHelper.toPropor= tionalWidths(parameter, 1000);<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (proportionalColumnWidths =3D=3D null)= {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0simpleTable =3D null;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return false;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return true;<br> =C2=A0 =C2=A0 =C2=A0}<br> <br> =C2=A0 =C2=A0 =C2=A0public CommandResult doExecute(DocumentView docView,<br= > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 String parameter, int = x, int y) {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//INTERACTIVE: no<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0StringBuilder buffer =3D new StringBuilde= r();<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0final int columnCount =3D proportionalCol= umnWidths.length;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for (int i =3D 0; i < columnCount; ++i= ) {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (i > 0) {<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0buffer.append= (' ');<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0buffer.append(Integer.toStr= ing(proportionalColumnWidths[i]));<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0buffer.append('*');= <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0simpleTable.putAttribute(Name.get(Namespa= ce.NONE, "relcolwidth"),<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 buffer.toString());<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0docView.describeUndo(Msg.msg("RSTC.r= esizeTableColumn"));<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0// Needed to refresh the Undo description= in the GUI.<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0docView.notifyContextChangeListeners();<b= r> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0simpleTable =3D null;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0proportionalColumnWidths =3D null;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return CommandResult.DONE;<br> =C2=A0 =C2=A0 =C2=A0}<br> }<br> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br> <br> </blockquote></div> --000000000000d04e6306402ee94c-- --===============0711231614244500902== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- XMLmind XML Editor Support List [email protected] http://www.xmlmind.com/mailman/listinfo/xmleditor-support --===============0711231614244500902==--