Skip to content

Kacper/UI customization updates#195

Open
sc0 wants to merge 3 commits into
masterfrom
kacper/ui-customization-updates
Open

Kacper/UI customization updates#195
sc0 wants to merge 3 commits into
masterfrom
kacper/ui-customization-updates

Conversation

@sc0

@sc0 sc0 commented Jun 11, 2026

Copy link
Copy Markdown

Update Web UI customization examples for Nutrient SDK 1.15.1

Refreshes the two web UI-customization examples to run on the latest SDK and adopt the updated UI customization callback API, plus a round of correctness fixes to the document-editor sidebar.

Why

The examples were pinned to @nutrient-sdk/viewer@1.9.1 and used the old UI customization callback signature, where the callback received the instance directly. In current SDK versions the callback receives a getInstance getter instead, so the examples broke when run against a recent SDK. This bumps both examples to 1.15.1 and migrates them to the new API, then fixes several bugs in the document-editor sidebar that surfaced along the way.

Changes

Both examples

  • Bump @nutrient-sdk/viewer 1.9.1 → 1.15.1 (lockfiles regenerated).
  • Migrate custom UI slot callbacks to the new API: the callback now receives getInstance rather than instance, so the instance is resolved via const instance = getInstance() inside onMount.

web/ui-customization

  • Update the commentThread slot callback to the getInstance signature.

web/ui-customization-doc-editor-sidebar

  • Introduce a SIDEBAR_ID constant (customDocumentEditorSidebar) used as both the sidebar slot key and the sidebarMode view-state value, with a typed cast so a custom id type-checks against the published sidebarMode type.
  • Stable page IDs: build IDs from page index + label instead of the label alone (labels aren't guaranteed unique), and use a monotonic counter for temporary (added/duplicated/imported) pages so IDs don't collide when created within the same millisecond.
  • Page sizing: track each page's width/height; new and duplicated pages now match a reference page's dimensions instead of a hardcoded 300×400.
  • Add page works with no selection (appends at the end) instead of requiring a selected page; the button is no longer disabled when nothing is selected.
  • Move left now moves each selected page one slot at a time with individual operations, fixing incorrect results for multi-page selections under a single backward movePages.
  • Import document copies the uploaded file into a fresh File before queuing the operation, so it doesn't depend on an original file handle the browser may invalidate before the operation runs.
  • Button enablement: disable Remove when every page is selected (a document must keep at least one page), and disable Move Left/Move Right when the selection is already at the respective edge.

Original PR: #161
Related guides PR: https://github.com/PSPDFKit/nutrient-website/pull/2541

@sc0 sc0 requested review from a team as code owners June 11, 2026 00:15
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.

2 participants