Skip to content

Add 'resolveImageSource' option to support cid image source for canvas editing#3301

Open
liangdrime wants to merge 3 commits intomicrosoft:masterfrom
liangdrime:support-resolve-image-source
Open

Add 'resolveImageSource' option to support cid image source for canvas editing#3301
liangdrime wants to merge 3 commits intomicrosoft:masterfrom
liangdrime:support-resolve-image-source

Conversation

@liangdrime
Copy link
Contributor

Summary

Fix image editing for content-model scenarios where image src uses cid: protocol by introducing a new resolveImageSource option.

This allows clients to convert cid: URLs to canvas-safe URLs (such as base64 data URLs) before edit operations run.

Background

On the Outlook for iOS/Mac, images are stored as cid: URLs.
Canvas APIs cannot draw cid: images directly, so editing features that depend on canvas regeneration fail.

Before content model, the client could override setEditingImage to convert cid: to base64 before editing.
In content model flow, relying on this approach to override some interface is not reliable.

What changed

  • Added resolveImageSource?: (src: string) => string | undefined to ImageEditOptions.
  • Wired resolveImageSource into ImageEditPlugin.canRegenerateImage(...).
  • Updated canRegenerateImage(...) utility to recognize resolvable image sources as regeneratable.
  • Updated image clone path in createImageWrapper(...) so editing uses resolved, canvas-safe src.

Example usage

new ImageEditPlugin({
    resolveImageSource: src =>
        src.startsWith('cid:') ? getBase64DataFromCid(src) : undefined,
});

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