rtf.js icon indicating copy to clipboard operation
rtf.js copied to clipboard

Required control words for RTF Table

Open SheetJSDev opened this issue 8 years ago • 9 comments

First off, awesome work! Glad to see our codepage library was helpful :)

https://jsfiddle.net/omyjg5a9/ generates an RTF table that Word 2016 and OSX TextEdit recognize as a borderless table. rtf.js doesn't seem to recognize this as a table :(

The generator is extremely simple, using a handful of control words for the table block. Here's an example with some comments prefixed by #:

{\rtf1\ansi
  \trowd\trautofit1 # start of row
  \cellx1\cellx2    # Word seems to need this, even though the widths are not used
  \pard\intbl       # mark before cells
    a\cell          # each cell is terminated with the \cell control word
    b\cell
  \pard\intbl\row   # end of row

  \trowd\trautofit1
  \cellx1\cellx2
  \pard\intbl
    1\cell
    2\cell
  \pard\intbl\row
}

A request for table support was already raised in #15 . Based on your understanding of the specification, do those control words suffice to represent a table? If so, would you accept a PR for table support based on those words?

SheetJSDev avatar Feb 24 '18 20:02 SheetJSDev

The rtf example you provide seems sufficient for a minimal table (cellx is a required part of the table definition tbldef according to the spec).

We would certainly appreciate a PR for (minimal) table support, we can always later expand it to include all the additional formatting that is possible. @tbluemel originally started implementing this in the branch table-support (including some major rearchitecting to make it work), but that never reached the stability or feature completeness of the current version, none the less it might be interesting to look at that branch for some pointers on implementing it.

zoehneto avatar Feb 24 '18 20:02 zoehneto

If you are still interested, I have just ported the table-support branch to the current master so it is now all typescript and has the test suite, which should make understanding and development a lot easier. You can find it in the branch table-support-typescript.

zoehneto avatar Mar 13 '18 18:03 zoehneto

Nice. I'm still interested, I just don't have the time to work on it currently.

tbluemel avatar Mar 14 '18 16:03 tbluemel

Just wondering if you had time to look into this pr ? I just came across this awesome piece of work and was wondering if/when table support will be included

didiergm avatar Aug 01 '18 03:08 didiergm

Unfortunately, I haven't really had time to work on this project recently.

tbluemel avatar Aug 03 '18 17:08 tbluemel

Is there a plan to rebase again table-support-typescript on master in order to have minimal support for tables?

The lib is great and works well for most of my use cases but the lack of table support is kind of a deal breaker atm

andyr-doctolib avatar Jun 07 '21 07:06 andyr-doctolib

Is there any reason why this as never added to master?

I ask because we use 3.0.7 and no table support has become an issue.

I am attempting to get the table-support-typescript branch updated to the latest and changes around RtfDestination.ts and Renderer.ts become unclear which are made as a consequence of the table support and which are updates from the simple fact that the branch is 4 years old @zoehneto @tbluemel

Some validation for myself are needed on the below:

  • Seems like Renderer.ts needs to change to use RenderElement | RenderContainer and not the IContainer element
  • There seems to be a few references to using Chp and Pap directly and not use RenderChp.ts and RenderPap.ts in RtfDestination.ts
  • Also in RtfDestination.ts it seems that _addFormatIns is swapped out for _updateFormatIns, which uses some propertyChanged stuff and a flush method
  • RenderElements.ts used JQuery I've changed for HtmlElements and added Helper.addStyle in place of JQuery#css()

Is all the above still needed for Table support or could some stuff be made easier?

Any help will be appreciated!

davidkroukamp avatar Apr 06 '22 14:04 davidkroukamp

As stated above the branch never got to a state where it could actually parse anything but simple examples (and not in the 'some things arent't handled yet' but in the 'it crashes randomly' way). That is why it was never merged.

zoehneto avatar Apr 09 '22 05:04 zoehneto