Skip to content

feat: add React image change callback bridge - #89

Draft
Anand-240 wants to merge 2 commits into
unlayer:mainfrom
Anand-240:feat/image-change-callback
Draft

Anand-240 wants to merge 2 commits into
unlayer:mainfrom
Anand-240:feat/image-change-callback

Conversation

@Anand-240

Copy link
Copy Markdown

Live previews currently have to poll hasChanges() and getImage() to detect edits. This draft proposes the React side of an image change callback for #87.

The component forwards MountOptions.onChange to the latest onChange prop without remounting, polling, or exporting an image. Notifications from a cancelled mount are ignored. The callback is excluded from options, consistent with the other component callbacks.

Core dependency

The default CDN editor, version 2.13.0, does not emit this callback. This draft needs a corresponding change in the underlying editor before it can replace polling or be released. It does not close #87.

The proposed contract is a notification when the visible image changes. Consumers control snapshot timing and throttling. The core implementation needs to define notifications during brush strokes, undo, redo, adjustments, and resets, and ensure the current image can be read when the callback runs. Tool selection and viewport changes should not trigger it.

Validation

  • 76 tests pass with 100% coverage.
  • Typecheck and package build pass.
  • Lint passes in an isolated copy because a local nested checkout interferes with ESLint configuration discovery in the working folder.
  • Demo typecheck and build pass.
  • Tests cover callback replacement and removal, no automatic export, and notifications after cancellation or unmount. These use a mocked embed contract; the default CDN cannot verify the event end to end yet.

@vercel

vercel Bot commented Oct 1, 2026

Copy link
Copy Markdown

@Anand-240 is attempting to deploy a commit to the Unlayer Team on Vercel.

A member of the Team first needs to authorize it.

@ivoIturrieta

Copy link
Copy Markdown
Collaborator

Thanks for this, and for the clear write-up in #87.

The image editor doesn't have a change event today, so this onChange prop wouldn't fire yet. The wrapper change itself looks good, but we can't merge it until the editor supports the event.

We'll discuss whether to add a change event to the editor and update you here. In the meantime, let's keep this PR open as a draft. Until then, polling hasChanges() and getImage() is the supported approach.

This branch has not been deployed

No deployments
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.

Feature request: expose an onChange callback for image edits

2 participants