onPresetsRequest
API reference for the "onPresetsRequest" method.
const { imageHelpers } = window.canva;
const canva = window.canva.init();
canva.onReady(async (opts) => {
// This callback must exist for the extension to load
});
canva.onPresetsRequest(async (opts) => {
return [
{
id: "myPreset",
label: "My Preset",
image: opts.image,
},
];
});
Name | Type | Required | Description |
---|---|---|---|
handler | Yes | The callback that runs when Canva requests presets. |
void
The callback that runs when Canva requests presets.
Signature
(opts) => Promise<Preset[]> | Preset[]
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
Represents an individual preset.
Signature
export type Preset = {
id: string;
label: string;
image: CanvaImageBlob;
kind?: "customizable" | "simple";
categoryId?: string;
};
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 |
Last modified 1yr ago