-
Notifications
You must be signed in to change notification settings - Fork 43
feat: add page count to vanilla example #1657
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81c48eb01e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| setTimeout(() => { | ||
| const documents = editor.superdocStore.documents; | ||
| const presentationEditor = documents[0]?.getPresentationEditor(); | ||
|
|
||
| if (presentationEditor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid computing page count before documents finish loading
The onEditorCreate callback runs as soon as the editor instance is created, but document initialization in superdocStore.init is async (it awaits file/URL loading). With the fixed setTimeout(100) here, editor.superdocStore.documents can still be empty for larger files or remote URLs, so presentationEditor stays undefined and the page count is never displayed. This shows up when users load a real document via the file picker: the UI stays blank even though the document eventually renders. Consider waiting for a document-ready signal (e.g., a store-ready flag/event) or recomputing when pages become available rather than using a hard-coded delay.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please assess if this is relevant or not
|
@caio-pizzol Could I get your review on this when you get a chance? This adds page count to the vanilla SuperDoc example. |
caio-pizzol
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's respond to codex comment + example deploy (do we actually need to deploy it?)
| setTimeout(() => { | ||
| const documents = editor.superdocStore.documents; | ||
| const presentationEditor = documents[0]?.getPresentationEditor(); | ||
|
|
||
| if (presentationEditor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please assess if this is relevant or not
| @@ -0,0 +1,21 @@ | |||
| name = "superdoc-page-count" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cloudflare pages? :)
I thought we agreed on Github pages instead
| "superdoc": "1.2.1" | ||
| }, | ||
| "devDependencies": { | ||
| "vite": "^4.4.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's update devDeps as well
npx npm-check-updates -u
No description provided.