onPresetsRequest
API reference for the "onPresetsRequest" method.
Registers a callback that runs when Canva requests presets from an editing extension.
You can't call the remoteProcess method from the onPresetsRequest callback.

Usage

1
const { imageHelpers } = window.canva;
2
const canva = window.canva.init();
3
4
canva.onReady(async (opts) => {
5
// This callback must exist for the extension to load
6
});
7
8
canva.onPresetsRequest(async (opts) => {
9
return [
10
{
11
id: "myPreset",
12
label: "My Preset",
13
image: opts.image,
14
},
15
];
16
});
Copied!

Parameters

Name
Type
Required
Description
handler
Yes
The callback that runs when Canva requests presets.

Returns

void

PresetsRequestHandler

The callback that runs when Canva requests presets.
Signature
1
(opts) => Promise<Preset[]> | Preset[]
Copied!
Parameters
Name
Type
Required
Description
opts
object
Yes
Information about the event.
opts.image
Yes
The user's image.
opts.minDimensions
object
Yes
The minimum dimensions of a preset's thumbnail.
opts.minDimensions.height
number
Yes
The minimum height of a preset's thumbnail, in pixels.
opts.minDimensions.width
number
Yes
The minimum width of a preset's thumbnail, in pixels.
Returns

Types

Preset

Represents an individual preset.
Signature
1
export type Preset = {
2
id: string;
3
label: string;
4
image: CanvaImageBlob;
5
kind?: "customizable" | "simple";
6
categoryId?: string;
7
};
Copied!
Properties
Name
Type
Required
Description
id
string
Yes
A unique ID for the preset.
image
Yes
A thumbnail for the preset.
label
string
Yes
A human readable label for the preset.
kind
No
The type of preset. The default value is "customizable".
categoryId
string
No
The ID of a preset category.