Pita/etherpad-lite — Issue #402: Ideas for table support
Author: gedion
Created: 2012-02-05 17:36:44+00:00
State: open

Hello. My partner and I have come up with the following idea for table representation. However we are having difficulties with concurrent modifications(for special table properties like hitting tab key,row/cell highlighting) and are seeking your opinions.

The table is represented using a json string like below.

```javascript
var myJSONString = '{"payload":[["Company","Contact","Country"],["Alfreds Futterkiste","Maria Anders","Germany"],["Berglunds snabbkop","Christina Berglund","Sweden"],["Centro comercial Moctezuma","Francisco Chang","Mexico"],["Ernst Handel","Roland Mendel","Austria"],["Island Trading","Helen Bennett","UK"],["Koniglich Essen","Philip Cramer","Germany"],["Laughing Bacchus Winecellars","Yoshi Tannamuri","Canada"]],"tblId":1,"tblClass":"data-tables","trClass":"alst","tdClass":"hide-el","importTbl":"importTbl","cellAttr":[],"tblProperties":{"cellAttrs":[],"width":"","rowAttrs":{},"colAttrs":[]}}';
```
in domline.js/domlilne_client.js this string object is processed and rendered as shown below.

![eplite Table](http://img689.imageshack.us/img689/1604/eplitetbl.png)

We then use css to hide the unnecessary columns.

Most of our additions in ace2_inner.js and domline.js/domline_client.js are straightforward and harmless.

Here are a minimal change one can do to make this work.

``` javascript
/*in linestylefilter.js/linestylefilter_client.js, the function attribsToClasses, needs to avoid the creation of span within tables when multiple users are modifying
*/
var spanSize;
if(txt.indexOf('data-tables')!=-1){
spanSize = leftInAuthor = txt.length;
}
else{
spanSize = txt.length;
}
```