pdfme / pdfme

A TypeScript based PDF generator library, made with React.
https://pdfme.com
MIT License
2.16k stars 192 forks source link

Exposed page cursor from Designer #445

Closed hlin-neo4j closed 2 months ago

hlin-neo4j commented 2 months ago

Thought it might be helpful to be to add an api to the Designer to get the current page.

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **pdfme-playground** | ⬜️ Ignored ([Inspect](https://vercel.com/labelmake/pdfme-playground/6JNzzxC8RuoxYgJjqkx2mSS2nZ9P)) | [Visit Preview](https://pdfme-playground-git-fork-hlin-neo4j-hlin-page-cursor-labelmake.vercel.app) | | Mar 14, 2024 5:42pm | | **pdfme-playground-v4** | ⬜️ Ignored ([Inspect](https://vercel.com/labelmake/pdfme-playground-v4/G96rW9ssiRhFPJkuCawtPreRS7vA)) | [Visit Preview](https://pdfme-playground-v4-git-fork-hlin-neo4j-hlin-p-41fc2f-labelmake.vercel.app) | | Mar 14, 2024 5:42pm |
hand-dot commented 2 months ago

Hey @hlin-neo4j ! Thank you for creating PR!

I've checked the code and behavior; it looks good. However, I don't quite understand the use case.

The same goes for the issue below. https://github.com/pdfme/pdfme/issues/442

Could you explain a bit more why we should add this feature?

hlin-neo4j commented 2 months ago

Ah I didn't see the #442 issue, but it sounds like there's at least two of us that needs it. For my use case, I have an external component (a sidebar) that displays and tracks the Schemas on the Designer. I store metadata about the Schemas as well, and all of this is stored in my application's Redux. I have users interact with this external Sidebar, so it is calling designer.current.updateTemplate, getTemplate, etc to make changes to the Designer. Now when the user creates multiple pages and scrolls between them, my Sidebar does not get any events that say a different page is displayed. designer.getTemplate is the only call that I know of that gives back information of the Template Schemas, but there is no "currentPage."

hand-dot commented 2 months ago

@hlin-neo4j Thank you, I understand. This feature is very effective, so I want to release it soon.

Could you switch the base branch to main? 🙏

hlin-neo4j commented 2 months ago

@hand-dot I can pull back this pull request and make a new one off of base branch if that works for you

hand-dot commented 2 months ago

Can you make new PR?🙇‍♂️

hlin-neo4j commented 2 months ago

@hand-dot Just created #446

hand-dot commented 2 months ago

Thank you, I'll handle in https://github.com/pdfme/pdfme/pull/446