Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tables support #520

Open
wyozi opened this issue Oct 4, 2021 · 11 comments
Open

Add tables support #520

wyozi opened this issue Oct 4, 2021 · 11 comments
Labels
enhancement New feature or request Hacktoberfest

Comments

@wyozi
Copy link
Owner

wyozi commented Oct 4, 2021

https://gitbrent.github.io/PptxGenJS/docs/api-tables/

Could probably use similar DOM structure as HTML tables, <Table><TableRow><TableCell>Aaa</TableCell><TableCell>BBB</TableCell></TableRow></Table>

@wyozi wyozi added enhancement New feature or request Hacktoberfest labels Oct 4, 2021
@juan-quintero-otl
Copy link

@wyozi Could you please give me some alternatives? or suggest a slide with an editable table structure?

@wyozi
Copy link
Owner Author

wyozi commented Aug 15, 2023

@juanmako unfortunately cannot be achieved as is currently. However, implementing the <Table> nodes yourself as a PR shouldn't be too difficult. Feel free to ask if there's any questions

@juanesquintero
Copy link
Contributor

@wyozi Thanks! Is there any way to get the raw PPTXGenJS object and modified before download??

@wyozi
Copy link
Owner Author

wyozi commented Aug 16, 2023

@juanesquintero

I'll try to explain the way I would do it :)

  1. Add required node types at https://github.com/wyozi/react-pptx/blob/master/src/nodes.ts#L12. Probably TABLE for now and accompanying component type (https://github.com/wyozi/react-pptx/blob/master/src/nodes.ts#L147-L162 here's an example for )
  2. Add an internal slide object for at https://github.com/wyozi/react-pptx/blob/master/src/normalizer.ts#L128.
  3. Add normalization behavior at https://github.com/wyozi/react-pptx/blob/master/src/normalizer.ts#L356 to convert react node into InternalTable. You can just copy the rows prop here
  4. Add renderer. Again you can just copy existing behavior. E.g. https://github.com/wyozi/react-pptx/blob/master/src/renderer.ts#L108
  5. Preview might be a bit annoying, but you should be able to add a table at https://github.com/wyozi/react-pptx/blob/master/src/preview/Preview.tsx#L348
  6. The normalized internal slide type might look something like this:

    export type InternalTable = ObjectBase & {
      kind: "table";
      rows: Array<Array<string>>
    };

@wyozi
Copy link
Owner Author

wyozi commented Aug 16, 2023

@wyozi Thanks! Is there any way to get the raw PPTXGenJS object and modified before download??

These are essentially the steps you have to take. There's no any "easier" way to access the raw PPTXGenJS object right now and I'm not sure if there even should be.

@wyozi
Copy link
Owner Author

wyozi commented Aug 16, 2023

@juanesquintero I'll take a closer look actually and see if I can implement this. There's some interesting challenges involved

@juanesquintero
Copy link
Contributor

juanesquintero commented Aug 16, 2023

@wyozi Great! with thoose instructions I will work on the PR soon!

@wyozi
Copy link
Owner Author

wyozi commented Aug 16, 2023

@juanesquintero see e0a9558

It's not quite where I want to be, but should cover at least basic table operations. See index.spec for how it can be used

@juanesquintero
Copy link
Contributor

@wyozi Already have a work in progress PR #674 let me know any feedback or comment you have please

@wyozi
Copy link
Owner Author

wyozi commented Aug 16, 2023

@juanesquintero the commit I linked has a full Table implementation, so I'd suggest trying it out or at least basing your work on top of it :)

@juanesquintero
Copy link
Contributor

juanesquintero commented Aug 16, 2023

@wyozi Thanks a million! already test it and the table generation is great! I will try to work on the preview part, since is only previewing the text and not the other styles...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants