Skip to content

Add new page feature#52

Open
Kirit0-00 wants to merge 2 commits into
FBarrca:masterfrom
Kirit0-00:master
Open

Add new page feature#52
Kirit0-00 wants to merge 2 commits into
FBarrca:masterfrom
Kirit0-00:master

Conversation

@Kirit0-00

@Kirit0-00 Kirit0-00 commented May 6, 2026

Copy link
Copy Markdown

I have added a '+' option to add new page to existing hand-written notes pdf.

Summary by CodeRabbit

  • New Features

    • Added ability to append pages to existing PDFs using templates.
    • New UI modals and toolbar buttons for selecting PDFs and choosing templates.
    • Template-based page selection with support for prefilled favorites.
  • Chores

    • Added PDF library dependency for page manipulation.
    • Updated build configuration with JSON plugin support.

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

This PR adds the ability to append pages from template PDFs to existing PDF documents in an Obsidian plugin. It introduces the pdf-lib dependency, configures Rollup to handle JSON, creates two UI modals for user interaction (template and PDF selection), implements PDF manipulation utilities, and integrates the new feature into the plugin's toolbar and commands.

Changes

PDF Page Append Feature

Layer / File(s) Summary
Dependencies & Build Config
package.json, rollup.config.js
Add pdf-lib (production) and @rollup/plugin-json (dev) dependencies; configure Rollup to process JSON via the imported json() plugin in the build pipeline.
UI Modals
src/dialogs/AppendPageModal.ts, src/dialogs/TemplateSelectModal.ts
AppendPageModal provides PDF file selection via PdfFileSuggest helper and template dropdown, returning an AppendPageResult. TemplateSelectModal loads templates from a folder, populates a dropdown with preselection logic, and submits the chosen template.
Core Utilities
src/utils/utils.ts
appendPageToPdf reads existing and template PDFs from vault, loads them with pdf-lib, copies the template's first page, appends it to the existing PDF, and writes the result back. appendAddPageButton appends a styled "Add page" button to toolbars with async click handling.
Plugin Integration
src/main.ts
Register new append-page-to-pdf command and add "Add Page" buttons to PDF toolbars and Markdown embeds; buttons trigger TemplateSelectModal, validate template and PDF existence, then invoke appendPageToPdf with error handling via notices.

Sequence Diagram

sequenceDiagram
    participant User
    participant AddPageButton as "Add Page Button"
    participant TemplateModal as "TemplateSelectModal"
    participant AppendLogic as "appendPageToPdf<br/>(pdf-lib)"
    participant Vault as "Vault Storage"

    User->>AddPageButton: Click "Add Page"
    AddPageButton->>TemplateModal: Open modal
    User->>TemplateModal: Select template
    TemplateModal-->>AddPageButton: Return template path
    AddPageButton->>AppendLogic: Validate & call appendPageToPdf
    AppendLogic->>Vault: Read template PDF
    AppendLogic->>Vault: Read existing PDF
    AppendLogic->>AppendLogic: Load PDFs with pdf-lib
    AppendLogic->>AppendLogic: Copy template's first page
    AppendLogic->>AppendLogic: Append to existing PDF
    AppendLogic->>Vault: Write modified PDF back
    AppendLogic-->>AddPageButton: Complete / Error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit hops through PDFs with glee,
Appending new pages for all to see!
With modals and magic from pdf-lib's might,
Templates blend seamlessly, oh what a sight!
Pages now multiply—hop, skip, and bound! 📄✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add new page feature' accurately reflects the main objective described in the PR - adding the ability to append pages to existing PDFs. It directly aligns with both the PR description and the substantial changes across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant