onPresetSelected
API reference for the "onPresetSelected" method.
Registers a callback that runs when the user selects a preset.
If a user opens an extension by selecting a preset, the
onReady
callback runs immediately before the onPresetSelected
callback.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,
},
];
});
canva.onPresetSelected(async (opts) => {
console.log(opts);
});
Name | Type | Required | Description |
---|---|---|---|
handler | Yes | The callback that runs when the user selects a preset. |
void
The callback that runs when the user selects a preset.
Signature
(opts) => void
Parameters
Name | Type | Required | Description |
---|---|---|---|
opts | object | Yes | Information about the event. |
opts.presetId | string | Yes | The id of the selected preset. |
Returns
void
Last modified 1yr ago