@canva/intents 2.5.1-beta.0 → 2.5.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/beta.d.ts +360 -9
- package/content/beta.d.ts +358 -27
- package/lib/cjs/sdk/intents/content/beta.js +7 -0
- package/lib/cjs/sdk/intents/version.js +1 -1
- package/lib/esm/sdk/intents/content/beta.js +1 -0
- package/lib/esm/sdk/intents/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 2.5.1-beta.2 - 2026-05-28
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Add multi-page document preview support to Content Publisher
|
|
8
|
+
- Add optional `contentNoun` on Content Publisher `OutputType` so apps can describe what kind of content is published (for example post, email, or publication) and Canva can tailor publish-flow UX accordingly. When omitted, behavior defaults to generic `content`.
|
|
9
|
+
- Add `getContentSummary` action to the Content Publisher
|
|
10
|
+
|
|
11
|
+
## 2.5.1-beta.1 - 2026-05-12
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Promote requestAiContent from alpha to beta
|
|
16
|
+
|
|
3
17
|
## 2.5.1-beta.0 - 2026-04-10
|
|
4
18
|
|
|
5
19
|
### Changed
|
package/beta.d.ts
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beta
|
|
3
|
+
* Cancelled response where the generation was not completed.
|
|
4
|
+
* We use only 'cancelled' since we don't expect app developers to handle any statuses further (e.g. blocked, failed).
|
|
5
|
+
* These will be handled on Canva's AI generation surface.
|
|
6
|
+
*/
|
|
7
|
+
declare type AiContentCancelledResponse = {
|
|
8
|
+
status: 'cancelled';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @beta
|
|
13
|
+
* Completed response for AI content generation.
|
|
14
|
+
* The value is the AI content generated for the app.
|
|
15
|
+
*/
|
|
16
|
+
declare type AiContentCompletedResponse = {
|
|
17
|
+
status: 'completed';
|
|
18
|
+
value: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @beta
|
|
23
|
+
* All possible AI content request types.
|
|
24
|
+
*/
|
|
25
|
+
declare type AiContentRequest = SocialCaptionRequest;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @beta
|
|
29
|
+
* All possible AI content response types.
|
|
30
|
+
*/
|
|
31
|
+
declare type AiContentResponse = AiContentCompletedResponse | AiContentCancelledResponse;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @beta
|
|
35
|
+
* All possible statuses for an AI content response.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
declare type AiContentResponseStatus = 'completed' | 'cancelled';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @beta
|
|
42
|
+
* Possible content type for AI content generation.
|
|
43
|
+
* Future types will be added here, e.g. 'hashtags'.
|
|
44
|
+
*/
|
|
45
|
+
declare type AiContentType = 'social_caption';
|
|
46
|
+
|
|
1
47
|
/**
|
|
2
48
|
* @public
|
|
3
49
|
* A disclosure identifying if the app generated this asset using AI.
|
|
@@ -139,6 +185,57 @@ declare type AppErrorInvocationContext = {
|
|
|
139
185
|
message?: string;
|
|
140
186
|
};
|
|
141
187
|
|
|
188
|
+
/**
|
|
189
|
+
* @beta
|
|
190
|
+
* Content summary for file-destination apps (e.g. Google Drive, Dropbox).
|
|
191
|
+
*/
|
|
192
|
+
declare type AssetContentSummary = BaseContentSummary & {
|
|
193
|
+
type: 'asset';
|
|
194
|
+
/** Asset title or filename. */
|
|
195
|
+
title: string;
|
|
196
|
+
/** Folder path (e.g. "/My Projects/Designs"). */
|
|
197
|
+
path?: string;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @beta
|
|
202
|
+
* Base interface for AI content requests.
|
|
203
|
+
*/
|
|
204
|
+
declare type BaseAiContentRequest = {
|
|
205
|
+
/**
|
|
206
|
+
* The type of AI content generation which determines
|
|
207
|
+
* the kind of content the AI will generate.
|
|
208
|
+
*/
|
|
209
|
+
type: AiContentType;
|
|
210
|
+
/**
|
|
211
|
+
* If a current value exists in the field, the AI content generation
|
|
212
|
+
* will be an edit-first experience.
|
|
213
|
+
* i.e. When the user has already entered a value in the field, the AI will
|
|
214
|
+
* generate a new value using the existing value as a starting point.
|
|
215
|
+
*/
|
|
216
|
+
currentValue?: string;
|
|
217
|
+
/**
|
|
218
|
+
* The label chosen by the app developer for the field.
|
|
219
|
+
* It will be used in the UI to customize the copy.
|
|
220
|
+
* Required since it is essential context for the AI to generate the content.
|
|
221
|
+
*/
|
|
222
|
+
fieldLabel: string;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @beta
|
|
227
|
+
* Base fields shared by all content summary variants.
|
|
228
|
+
*/
|
|
229
|
+
declare type BaseContentSummary = {
|
|
230
|
+
/**
|
|
231
|
+
* The account, page, or list this post was published to.
|
|
232
|
+
*
|
|
233
|
+
* For example, a Facebook Page, a mailing list, or a personal profile.
|
|
234
|
+
* Use the connected account's display name and icon when there is no distinct destination.
|
|
235
|
+
*/
|
|
236
|
+
destination: Destination;
|
|
237
|
+
};
|
|
238
|
+
|
|
142
239
|
/**
|
|
143
240
|
* @public
|
|
144
241
|
* Base file requirement interface.
|
|
@@ -281,12 +378,6 @@ declare namespace content {
|
|
|
281
378
|
prepareContentPublisher,
|
|
282
379
|
Disposer,
|
|
283
380
|
PublishContentRequest,
|
|
284
|
-
Preview,
|
|
285
|
-
PreviewMedia,
|
|
286
|
-
RenderPreviewUiInvocationContext,
|
|
287
|
-
PublishPreviewUiInvocationContext,
|
|
288
|
-
RenderPreviewUiRequest,
|
|
289
|
-
ContentPublisherIntent,
|
|
290
381
|
RenderSettingsUiInvocationContext,
|
|
291
382
|
PublishSettingsUiInvocationContext,
|
|
292
383
|
RenderSettingsUiRequest,
|
|
@@ -298,6 +389,7 @@ declare namespace content {
|
|
|
298
389
|
PublishError,
|
|
299
390
|
PublishSettings,
|
|
300
391
|
PublishRefValidityState,
|
|
392
|
+
ContentNoun,
|
|
301
393
|
UpdatePublishSettingsResponse,
|
|
302
394
|
UpdatePublishSettingsCompleted,
|
|
303
395
|
PublishContentResponse,
|
|
@@ -333,9 +425,11 @@ declare namespace content {
|
|
|
333
425
|
MaxValueRange,
|
|
334
426
|
MinMaxValueRange,
|
|
335
427
|
ValueRange,
|
|
336
|
-
DocumentPreview,
|
|
337
428
|
DocumentPreviewLoading,
|
|
338
429
|
DocumentPreviewThumbnail,
|
|
430
|
+
DocumentPreviewUpgrading,
|
|
431
|
+
DocumentPreviewReady,
|
|
432
|
+
DocumentPreviewPage,
|
|
339
433
|
DocumentPreviewError,
|
|
340
434
|
ImagePreview,
|
|
341
435
|
ImagePreviewLoading,
|
|
@@ -364,7 +458,31 @@ declare namespace content {
|
|
|
364
458
|
EmailOutputFile,
|
|
365
459
|
ContentMetadata,
|
|
366
460
|
DesignContentMetadata,
|
|
367
|
-
OutputPageMetadata
|
|
461
|
+
OutputPageMetadata,
|
|
462
|
+
AiContentType,
|
|
463
|
+
SocialCaptionRequest,
|
|
464
|
+
AiContentRequest,
|
|
465
|
+
AiContentResponseStatus,
|
|
466
|
+
AiContentCompletedResponse,
|
|
467
|
+
AiContentCancelledResponse,
|
|
468
|
+
AiContentResponse,
|
|
469
|
+
RequestAiContent,
|
|
470
|
+
Destination,
|
|
471
|
+
PostContentSummary,
|
|
472
|
+
EmailContentSummary,
|
|
473
|
+
AssetContentSummary,
|
|
474
|
+
GenericContentSummary,
|
|
475
|
+
ContentSummary,
|
|
476
|
+
GetContentSummaryCompleted,
|
|
477
|
+
GetContentSummaryError,
|
|
478
|
+
GetContentSummaryResponse,
|
|
479
|
+
DocumentPreview,
|
|
480
|
+
Preview,
|
|
481
|
+
PreviewMedia,
|
|
482
|
+
RenderPreviewUiInvocationContext,
|
|
483
|
+
PublishPreviewUiInvocationContext,
|
|
484
|
+
RenderPreviewUiRequest,
|
|
485
|
+
ContentPublisherIntent
|
|
368
486
|
}
|
|
369
487
|
}
|
|
370
488
|
export { content }
|
|
@@ -375,6 +493,13 @@ export { content }
|
|
|
375
493
|
*/
|
|
376
494
|
declare type ContentMetadata = DesignContentMetadata;
|
|
377
495
|
|
|
496
|
+
/**
|
|
497
|
+
* @beta
|
|
498
|
+
* Describes what kind of content an output type produces. Canva uses this to tailor and improve
|
|
499
|
+
* the publish experience.
|
|
500
|
+
*/
|
|
501
|
+
declare type ContentNoun = 'email' | 'post' | 'schedule' | 'asset' | 'draft' | 'publication' | 'content';
|
|
502
|
+
|
|
378
503
|
/**
|
|
379
504
|
* @public
|
|
380
505
|
* Main interface for implementing the ContentPublisher intent.
|
|
@@ -544,8 +669,31 @@ declare type ContentPublisherIntent = {
|
|
|
544
669
|
*/
|
|
545
670
|
publishContent: (request: PublishContentRequest) => Promise<PublishContentResponse>;
|
|
546
671
|
|
|
672
|
+
/**
|
|
673
|
+
* @beta
|
|
674
|
+
* Extracts a structured summary of the post's content for historical display.
|
|
675
|
+
*
|
|
676
|
+
* Called at `createPost` / `updatePost` time while the app is loaded. The returned
|
|
677
|
+
* snapshot is stored with the post and used to render historical post views in the
|
|
678
|
+
* content planner (calendar, list views, insights) without re-invoking the app.
|
|
679
|
+
*
|
|
680
|
+
* The snapshot is frozen at write time — it reflects what was published, not the
|
|
681
|
+
* app's current rendering logic. If the app's payload shape or output types change
|
|
682
|
+
* later, historical views remain accurate.
|
|
683
|
+
*
|
|
684
|
+
* @param request - The `publishRef` and `outputType` for the post being published.
|
|
685
|
+
* @returns A promise resolving to the `ContentSummary`, or an error.
|
|
686
|
+
*/
|
|
687
|
+
getContentSummary?: (request: GetContentSummaryRequest) => Promise<GetContentSummaryResponse>;
|
|
547
688
|
};
|
|
548
689
|
|
|
690
|
+
/**
|
|
691
|
+
* @beta
|
|
692
|
+
* A structured snapshot of a post's content for historical display.
|
|
693
|
+
* Discriminated by `type`.
|
|
694
|
+
*/
|
|
695
|
+
declare type ContentSummary = PostContentSummary | EmailContentSummary | AssetContentSummary | GenericContentSummary;
|
|
696
|
+
|
|
549
697
|
declare namespace data {
|
|
550
698
|
export {
|
|
551
699
|
prepareDataConnector,
|
|
@@ -966,6 +1114,17 @@ declare type DesignEditorIntent = {
|
|
|
966
1114
|
render: () => void;
|
|
967
1115
|
};
|
|
968
1116
|
|
|
1117
|
+
/**
|
|
1118
|
+
* @beta
|
|
1119
|
+
* The publishing destination when distinct from the connected account.
|
|
1120
|
+
*/
|
|
1121
|
+
declare type Destination = {
|
|
1122
|
+
/** User-facing name (e.g. "Bob's Cool Page", "Product Newsletter"). */
|
|
1123
|
+
displayName: string;
|
|
1124
|
+
/** Avatar or icon URL for the destination. */
|
|
1125
|
+
iconUrl?: string;
|
|
1126
|
+
};
|
|
1127
|
+
|
|
969
1128
|
/**
|
|
970
1129
|
* @public
|
|
971
1130
|
* A set of dimensions.
|
|
@@ -1031,6 +1190,43 @@ declare interface DocumentPreviewLoading extends SizedPreview {
|
|
|
1031
1190
|
status: 'loading';
|
|
1032
1191
|
}
|
|
1033
1192
|
|
|
1193
|
+
/**
|
|
1194
|
+
* @beta
|
|
1195
|
+
* Thumbnail for a single page within a document preview.
|
|
1196
|
+
*/
|
|
1197
|
+
declare interface DocumentPreviewPage {
|
|
1198
|
+
/**
|
|
1199
|
+
* URL to the page thumbnail image.
|
|
1200
|
+
*/
|
|
1201
|
+
url: string;
|
|
1202
|
+
/**
|
|
1203
|
+
* Width of the page thumbnail in pixels.
|
|
1204
|
+
*/
|
|
1205
|
+
widthPx: number;
|
|
1206
|
+
/**
|
|
1207
|
+
* Height of the page thumbnail in pixels.
|
|
1208
|
+
*/
|
|
1209
|
+
heightPx: number;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* @beta
|
|
1214
|
+
* Final state after a document preview has been upgraded. Contains thumbnail
|
|
1215
|
+
* URLs for every selected page in the document.
|
|
1216
|
+
*/
|
|
1217
|
+
declare interface DocumentPreviewReady extends BasePreview {
|
|
1218
|
+
kind: 'document';
|
|
1219
|
+
status: 'ready';
|
|
1220
|
+
/**
|
|
1221
|
+
* Format of the per-page thumbnails.
|
|
1222
|
+
*/
|
|
1223
|
+
format: 'png' | 'jpg';
|
|
1224
|
+
/**
|
|
1225
|
+
* Thumbnail pages for each page. Index corresponds to the page number.
|
|
1226
|
+
*/
|
|
1227
|
+
pages: DocumentPreviewPage[];
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1034
1230
|
/**
|
|
1035
1231
|
* @public
|
|
1036
1232
|
* Document preview with first page thumbnail available.
|
|
@@ -1054,6 +1250,20 @@ declare interface DocumentPreviewThumbnail extends SizedPreview {
|
|
|
1054
1250
|
thumbnailUrl: string;
|
|
1055
1251
|
}
|
|
1056
1252
|
|
|
1253
|
+
/**
|
|
1254
|
+
* @beta
|
|
1255
|
+
* Intermediate state while multi-page document thumbnails are being fetched
|
|
1256
|
+
* via {@link requestPreviewUpgrade}. The single-page thumbnail remains
|
|
1257
|
+
* available for display during the upgrade.
|
|
1258
|
+
*/
|
|
1259
|
+
declare interface DocumentPreviewUpgrading extends SizedPreview {
|
|
1260
|
+
kind: 'document';
|
|
1261
|
+
status: 'upgrading';
|
|
1262
|
+
thumbnailFormat: 'png' | 'jpg';
|
|
1263
|
+
/** The first-page thumbnail URL, available immediately. */
|
|
1264
|
+
thumbnailUrl: string;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1057
1267
|
/**
|
|
1058
1268
|
* @public
|
|
1059
1269
|
* Document file requirements for a media slot.
|
|
@@ -1095,6 +1305,18 @@ declare interface DocumentSelection extends BaseSelection {
|
|
|
1095
1305
|
*/
|
|
1096
1306
|
declare type DocumentSize = 'a4' | 'a3' | 'letter' | 'legal';
|
|
1097
1307
|
|
|
1308
|
+
/**
|
|
1309
|
+
* @beta
|
|
1310
|
+
* Content summary for email sends.
|
|
1311
|
+
*/
|
|
1312
|
+
declare type EmailContentSummary = BaseContentSummary & {
|
|
1313
|
+
type: 'email';
|
|
1314
|
+
/** Subject line. */
|
|
1315
|
+
subject?: string;
|
|
1316
|
+
/** Email body preview or preheader. */
|
|
1317
|
+
body?: string;
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1098
1320
|
/**
|
|
1099
1321
|
* @public
|
|
1100
1322
|
* Exported email file ready for publishing.
|
|
@@ -1194,6 +1416,54 @@ declare type ExactValueRange = {
|
|
|
1194
1416
|
exact: number;
|
|
1195
1417
|
};
|
|
1196
1418
|
|
|
1419
|
+
/**
|
|
1420
|
+
* @beta
|
|
1421
|
+
* Generic content summary for apps that don't fit a more specific type.
|
|
1422
|
+
*/
|
|
1423
|
+
declare type GenericContentSummary = BaseContentSummary & {
|
|
1424
|
+
type: 'content';
|
|
1425
|
+
/** Title or headline. */
|
|
1426
|
+
title?: string;
|
|
1427
|
+
/** Body text or description. */
|
|
1428
|
+
body?: string;
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
/**
|
|
1432
|
+
* @beta
|
|
1433
|
+
* Successful response from getContentSummary.
|
|
1434
|
+
*/
|
|
1435
|
+
declare type GetContentSummaryCompleted = {
|
|
1436
|
+
status: 'completed';
|
|
1437
|
+
contentSummary: ContentSummary;
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* @beta
|
|
1442
|
+
* Error response from getContentSummary.
|
|
1443
|
+
*/
|
|
1444
|
+
declare type GetContentSummaryError = AppError_2;
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* @beta
|
|
1448
|
+
* Request payload for the getContentSummary action.
|
|
1449
|
+
*/
|
|
1450
|
+
declare type GetContentSummaryRequest = {
|
|
1451
|
+
/** The user's saved publish settings. Parse to retrieve app-specific state. */
|
|
1452
|
+
publishRef?: string;
|
|
1453
|
+
/**
|
|
1454
|
+
* The output type selected for this publish operation.
|
|
1455
|
+
*
|
|
1456
|
+
* Use `id` to distinguish between output types.
|
|
1457
|
+
*/
|
|
1458
|
+
outputType: OutputType;
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* @beta
|
|
1463
|
+
* Response from getContentSummary.
|
|
1464
|
+
*/
|
|
1465
|
+
declare type GetContentSummaryResponse = GetContentSummaryCompleted | GetContentSummaryError;
|
|
1466
|
+
|
|
1197
1467
|
/**
|
|
1198
1468
|
* @public
|
|
1199
1469
|
* Successful result from `getDataTable` action.
|
|
@@ -2005,6 +2275,12 @@ declare type OutputType = {
|
|
|
2005
2275
|
* such as a main image, thumbnail, or video.
|
|
2006
2276
|
*/
|
|
2007
2277
|
mediaSlots: MediaSlot[];
|
|
2278
|
+
/**
|
|
2279
|
+
* @beta
|
|
2280
|
+
* The type of content being published. When set, Canva uses this to tailor and improve the
|
|
2281
|
+
* publish experience. When omitted, defaults to `'content'` (generic behavior).
|
|
2282
|
+
*/
|
|
2283
|
+
contentNoun?: ContentNoun;
|
|
2008
2284
|
};
|
|
2009
2285
|
|
|
2010
2286
|
/**
|
|
@@ -2057,6 +2333,26 @@ declare type OutputTypeConfiguration = {
|
|
|
2057
2333
|
* do not provide selection data when defining output types.
|
|
2058
2334
|
*/
|
|
2059
2335
|
mediaSlots: Omit<MediaSlot, 'selection'>[];
|
|
2336
|
+
/**
|
|
2337
|
+
* @beta
|
|
2338
|
+
* The type of content being published. When set, Canva uses this to tailor and improve the
|
|
2339
|
+
* publish experience. When omitted, defaults to `'content'` (generic behavior).
|
|
2340
|
+
*/
|
|
2341
|
+
contentNoun?: ContentNoun;
|
|
2342
|
+
};
|
|
2343
|
+
|
|
2344
|
+
/**
|
|
2345
|
+
* @beta
|
|
2346
|
+
* Content summary for social media posts (e.g. Instagram, Facebook, LinkedIn, YouTube).
|
|
2347
|
+
*/
|
|
2348
|
+
declare type PostContentSummary = BaseContentSummary & {
|
|
2349
|
+
type: 'post';
|
|
2350
|
+
/** Post heading (e.g. YouTube title, LinkedIn article headline). */
|
|
2351
|
+
title?: string;
|
|
2352
|
+
/** Post caption or body text. */
|
|
2353
|
+
body?: string;
|
|
2354
|
+
/** Hashtags without the leading `#` (e.g. `["fashion", "design"]`). */
|
|
2355
|
+
hashtags?: string[];
|
|
2060
2356
|
};
|
|
2061
2357
|
|
|
2062
2358
|
/**
|
|
@@ -2682,9 +2978,47 @@ declare type RenderSettingsUiRequest = {
|
|
|
2682
2978
|
registerOnContextChange: (opts: {
|
|
2683
2979
|
onContextChange: OnContextChange;
|
|
2684
2980
|
}) => Disposer;
|
|
2685
|
-
|
|
2981
|
+
/**
|
|
2982
|
+
* @beta
|
|
2983
|
+
* Function to trigger a request for AI content.
|
|
2984
|
+
*
|
|
2985
|
+
* Use this function to trigger a request for AI content.
|
|
2986
|
+
*
|
|
2987
|
+
* @param request - The request for AI content.
|
|
2988
|
+
* @returns A promise resolving to the AI content response with a status of 'completed' or 'cancelled'.
|
|
2989
|
+
* @example Requesting AI content
|
|
2990
|
+
* ```ts
|
|
2991
|
+
* async function onGenerateCaption() {
|
|
2992
|
+
* const result = await requestAiContent({
|
|
2993
|
+
* type: 'social_caption',
|
|
2994
|
+
* currentValue: settings.caption,
|
|
2995
|
+
* fieldLabel: 'Caption',
|
|
2996
|
+
* hints: {
|
|
2997
|
+
* maxLength: 2200,
|
|
2998
|
+
* },
|
|
2999
|
+
* });
|
|
3000
|
+
*
|
|
3001
|
+
* if (result.status !== 'completed') {
|
|
3002
|
+
* return;
|
|
3003
|
+
* }
|
|
3004
|
+
* const nextSettings = { ...settings, caption: result.value };
|
|
3005
|
+
* // ... set local state
|
|
3006
|
+
* await updatePublishSettings({
|
|
3007
|
+
* publishRef: JSON.stringify(nextSettings),
|
|
3008
|
+
* validityState: 'valid',
|
|
3009
|
+
* });
|
|
3010
|
+
* }
|
|
3011
|
+
* ```
|
|
3012
|
+
*/
|
|
3013
|
+
requestAiContent: RequestAiContent;
|
|
2686
3014
|
};
|
|
2687
3015
|
|
|
3016
|
+
/**
|
|
3017
|
+
* @beta
|
|
3018
|
+
* Function to trigger a request for AI content.
|
|
3019
|
+
*/
|
|
3020
|
+
declare type RequestAiContent = (request: AiContentRequest) => Promise<AiContentResponse>;
|
|
3021
|
+
|
|
2688
3022
|
/**
|
|
2689
3023
|
* @public
|
|
2690
3024
|
* Metadata specific to design content represented by a media selection.
|
|
@@ -2728,6 +3062,23 @@ declare interface SizedPreview extends BasePreview {
|
|
|
2728
3062
|
heightPx: number;
|
|
2729
3063
|
}
|
|
2730
3064
|
|
|
3065
|
+
/**
|
|
3066
|
+
* @beta
|
|
3067
|
+
* Request for social caption generation.
|
|
3068
|
+
*/
|
|
3069
|
+
declare type SocialCaptionRequest = BaseAiContentRequest & {
|
|
3070
|
+
type: 'social_caption';
|
|
3071
|
+
/**
|
|
3072
|
+
* Hints for how the AI should generate the caption.
|
|
3073
|
+
*/
|
|
3074
|
+
hints?: {
|
|
3075
|
+
/**
|
|
3076
|
+
* The maximum length of the caption.
|
|
3077
|
+
*/
|
|
3078
|
+
maxLength?: number;
|
|
3079
|
+
};
|
|
3080
|
+
};
|
|
3081
|
+
|
|
2731
3082
|
/**
|
|
2732
3083
|
* @public
|
|
2733
3084
|
* Cell containing a text value.
|
package/content/beta.d.ts
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beta
|
|
3
|
+
* Cancelled response where the generation was not completed.
|
|
4
|
+
* We use only 'cancelled' since we don't expect app developers to handle any statuses further (e.g. blocked, failed).
|
|
5
|
+
* These will be handled on Canva's AI generation surface.
|
|
6
|
+
*/
|
|
7
|
+
export declare type AiContentCancelledResponse = {
|
|
8
|
+
status: 'cancelled';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @beta
|
|
13
|
+
* Completed response for AI content generation.
|
|
14
|
+
* The value is the AI content generated for the app.
|
|
15
|
+
*/
|
|
16
|
+
export declare type AiContentCompletedResponse = {
|
|
17
|
+
status: 'completed';
|
|
18
|
+
value: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @beta
|
|
23
|
+
* All possible AI content request types.
|
|
24
|
+
*/
|
|
25
|
+
export declare type AiContentRequest = SocialCaptionRequest;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @beta
|
|
29
|
+
* All possible AI content response types.
|
|
30
|
+
*/
|
|
31
|
+
export declare type AiContentResponse = AiContentCompletedResponse | AiContentCancelledResponse;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @beta
|
|
35
|
+
* All possible statuses for an AI content response.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export declare type AiContentResponseStatus = 'completed' | 'cancelled';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @beta
|
|
42
|
+
* Possible content type for AI content generation.
|
|
43
|
+
* Future types will be added here, e.g. 'hashtags'.
|
|
44
|
+
*/
|
|
45
|
+
export declare type AiContentType = 'social_caption';
|
|
46
|
+
|
|
1
47
|
/**
|
|
2
48
|
* @public
|
|
3
49
|
* {@link PublishContentError} indicating a custom error occurred in your app's implementation.
|
|
@@ -54,6 +100,57 @@ export declare type AppError = {
|
|
|
54
100
|
errorCause?: ErrorCause;
|
|
55
101
|
};
|
|
56
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @beta
|
|
105
|
+
* Content summary for file-destination apps (e.g. Google Drive, Dropbox).
|
|
106
|
+
*/
|
|
107
|
+
export declare type AssetContentSummary = BaseContentSummary & {
|
|
108
|
+
type: 'asset';
|
|
109
|
+
/** Asset title or filename. */
|
|
110
|
+
title: string;
|
|
111
|
+
/** Folder path (e.g. "/My Projects/Designs"). */
|
|
112
|
+
path?: string;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @beta
|
|
117
|
+
* Base interface for AI content requests.
|
|
118
|
+
*/
|
|
119
|
+
declare type BaseAiContentRequest = {
|
|
120
|
+
/**
|
|
121
|
+
* The type of AI content generation which determines
|
|
122
|
+
* the kind of content the AI will generate.
|
|
123
|
+
*/
|
|
124
|
+
type: AiContentType;
|
|
125
|
+
/**
|
|
126
|
+
* If a current value exists in the field, the AI content generation
|
|
127
|
+
* will be an edit-first experience.
|
|
128
|
+
* i.e. When the user has already entered a value in the field, the AI will
|
|
129
|
+
* generate a new value using the existing value as a starting point.
|
|
130
|
+
*/
|
|
131
|
+
currentValue?: string;
|
|
132
|
+
/**
|
|
133
|
+
* The label chosen by the app developer for the field.
|
|
134
|
+
* It will be used in the UI to customize the copy.
|
|
135
|
+
* Required since it is essential context for the AI to generate the content.
|
|
136
|
+
*/
|
|
137
|
+
fieldLabel: string;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @beta
|
|
142
|
+
* Base fields shared by all content summary variants.
|
|
143
|
+
*/
|
|
144
|
+
declare type BaseContentSummary = {
|
|
145
|
+
/**
|
|
146
|
+
* The account, page, or list this post was published to.
|
|
147
|
+
*
|
|
148
|
+
* For example, a Facebook Page, a mailing list, or a personal profile.
|
|
149
|
+
* Use the connected account's display name and icon when there is no distinct destination.
|
|
150
|
+
*/
|
|
151
|
+
destination: Destination;
|
|
152
|
+
};
|
|
153
|
+
|
|
57
154
|
/**
|
|
58
155
|
* @public
|
|
59
156
|
* Base file requirement interface.
|
|
@@ -131,7 +228,14 @@ export declare interface BaseSelection {
|
|
|
131
228
|
export declare type ContentMetadata = DesignContentMetadata;
|
|
132
229
|
|
|
133
230
|
/**
|
|
134
|
-
* @
|
|
231
|
+
* @beta
|
|
232
|
+
* Describes what kind of content an output type produces. Canva uses this to tailor and improve
|
|
233
|
+
* the publish experience.
|
|
234
|
+
*/
|
|
235
|
+
export declare type ContentNoun = 'email' | 'post' | 'schedule' | 'asset' | 'draft' | 'publication' | 'content';
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @beta
|
|
135
239
|
* Main interface for implementing the ContentPublisher intent.
|
|
136
240
|
*
|
|
137
241
|
* Implementing the ContentPublisher intent enables apps to publish contents to external platforms.
|
|
@@ -223,13 +327,13 @@ export declare type ContentPublisherIntent = {
|
|
|
223
327
|
* This action is called after the settings UI is rendered. Your UI should display
|
|
224
328
|
* a preview of how the content will appear on the target platform.
|
|
225
329
|
*
|
|
226
|
-
* Previews update dynamically as users modify their content or settings. For videos
|
|
227
|
-
* start with lightweight thumbnails and use `requestPreviewUpgrade`
|
|
228
|
-
*
|
|
330
|
+
* Previews update dynamically as users modify their content or settings. For videos
|
|
331
|
+
* and documents, start with lightweight thumbnails and use `requestPreviewUpgrade`
|
|
332
|
+
* to load full previews on demand to optimize performance.
|
|
229
333
|
*
|
|
230
334
|
* @param request - Configuration and callbacks for the preview UI.
|
|
231
335
|
*
|
|
232
|
-
* @example Rendering a preview UI with
|
|
336
|
+
* @example Rendering a preview UI with media optimization
|
|
233
337
|
* ```ts
|
|
234
338
|
* import { createRoot } from 'react-dom/client';
|
|
235
339
|
* import type { RenderPreviewUiRequest } from '@canva/intents/content';
|
|
@@ -299,8 +403,31 @@ export declare type ContentPublisherIntent = {
|
|
|
299
403
|
*/
|
|
300
404
|
publishContent: (request: PublishContentRequest) => Promise<PublishContentResponse>;
|
|
301
405
|
|
|
406
|
+
/**
|
|
407
|
+
* @beta
|
|
408
|
+
* Extracts a structured summary of the post's content for historical display.
|
|
409
|
+
*
|
|
410
|
+
* Called at `createPost` / `updatePost` time while the app is loaded. The returned
|
|
411
|
+
* snapshot is stored with the post and used to render historical post views in the
|
|
412
|
+
* content planner (calendar, list views, insights) without re-invoking the app.
|
|
413
|
+
*
|
|
414
|
+
* The snapshot is frozen at write time — it reflects what was published, not the
|
|
415
|
+
* app's current rendering logic. If the app's payload shape or output types change
|
|
416
|
+
* later, historical views remain accurate.
|
|
417
|
+
*
|
|
418
|
+
* @param request - The `publishRef` and `outputType` for the post being published.
|
|
419
|
+
* @returns A promise resolving to the `ContentSummary`, or an error.
|
|
420
|
+
*/
|
|
421
|
+
getContentSummary?: (request: GetContentSummaryRequest) => Promise<GetContentSummaryResponse>;
|
|
302
422
|
};
|
|
303
423
|
|
|
424
|
+
/**
|
|
425
|
+
* @beta
|
|
426
|
+
* A structured snapshot of a post's content for historical display.
|
|
427
|
+
* Discriminated by `type`.
|
|
428
|
+
*/
|
|
429
|
+
export declare type ContentSummary = PostContentSummary | EmailContentSummary | AssetContentSummary | GenericContentSummary;
|
|
430
|
+
|
|
304
431
|
/**
|
|
305
432
|
* @public
|
|
306
433
|
* Metadata specific to design content.
|
|
@@ -322,6 +449,17 @@ export declare interface DesignContentMetadata {
|
|
|
322
449
|
|
|
323
450
|
}
|
|
324
451
|
|
|
452
|
+
/**
|
|
453
|
+
* @beta
|
|
454
|
+
* The publishing destination when distinct from the connected account.
|
|
455
|
+
*/
|
|
456
|
+
export declare type Destination = {
|
|
457
|
+
/** User-facing name (e.g. "Bob's Cool Page", "Product Newsletter"). */
|
|
458
|
+
displayName: string;
|
|
459
|
+
/** Avatar or icon URL for the destination. */
|
|
460
|
+
iconUrl?: string;
|
|
461
|
+
};
|
|
462
|
+
|
|
325
463
|
/**
|
|
326
464
|
* @public
|
|
327
465
|
* A function that can be called to dispose of a callback.
|
|
@@ -338,13 +476,14 @@ export declare type Disposer = () => void;
|
|
|
338
476
|
export declare type DocumentOutputFile = BaseOutputFile;
|
|
339
477
|
|
|
340
478
|
/**
|
|
341
|
-
* @
|
|
479
|
+
* @beta
|
|
342
480
|
* Document preview in various states.
|
|
343
481
|
*
|
|
344
|
-
* Documents transition through states: `"loading"` → `"thumbnail"`.
|
|
345
|
-
* Start with a lightweight thumbnail of the first page
|
|
482
|
+
* Documents transition through states: `"loading"` → `"thumbnail"` → `"upgrading"` → `"ready"`.
|
|
483
|
+
* Start with a lightweight thumbnail of the first page, then upgrade to full multi-page
|
|
484
|
+
* preview using `requestPreviewUpgrade`.
|
|
346
485
|
*/
|
|
347
|
-
export declare type DocumentPreview = DocumentPreviewLoading | DocumentPreviewThumbnail | DocumentPreviewError;
|
|
486
|
+
export declare type DocumentPreview = DocumentPreviewLoading | DocumentPreviewThumbnail | DocumentPreviewUpgrading | DocumentPreviewReady | DocumentPreviewError;
|
|
348
487
|
|
|
349
488
|
/**
|
|
350
489
|
* @public
|
|
@@ -372,6 +511,43 @@ export declare interface DocumentPreviewLoading extends SizedPreview {
|
|
|
372
511
|
status: 'loading';
|
|
373
512
|
}
|
|
374
513
|
|
|
514
|
+
/**
|
|
515
|
+
* @beta
|
|
516
|
+
* Thumbnail for a single page within a document preview.
|
|
517
|
+
*/
|
|
518
|
+
export declare interface DocumentPreviewPage {
|
|
519
|
+
/**
|
|
520
|
+
* URL to the page thumbnail image.
|
|
521
|
+
*/
|
|
522
|
+
url: string;
|
|
523
|
+
/**
|
|
524
|
+
* Width of the page thumbnail in pixels.
|
|
525
|
+
*/
|
|
526
|
+
widthPx: number;
|
|
527
|
+
/**
|
|
528
|
+
* Height of the page thumbnail in pixels.
|
|
529
|
+
*/
|
|
530
|
+
heightPx: number;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @beta
|
|
535
|
+
* Final state after a document preview has been upgraded. Contains thumbnail
|
|
536
|
+
* URLs for every selected page in the document.
|
|
537
|
+
*/
|
|
538
|
+
export declare interface DocumentPreviewReady extends BasePreview {
|
|
539
|
+
kind: 'document';
|
|
540
|
+
status: 'ready';
|
|
541
|
+
/**
|
|
542
|
+
* Format of the per-page thumbnails.
|
|
543
|
+
*/
|
|
544
|
+
format: 'png' | 'jpg';
|
|
545
|
+
/**
|
|
546
|
+
* Thumbnail pages for each page. Index corresponds to the page number.
|
|
547
|
+
*/
|
|
548
|
+
pages: DocumentPreviewPage[];
|
|
549
|
+
}
|
|
550
|
+
|
|
375
551
|
/**
|
|
376
552
|
* @public
|
|
377
553
|
* Document preview with first page thumbnail available.
|
|
@@ -395,6 +571,20 @@ export declare interface DocumentPreviewThumbnail extends SizedPreview {
|
|
|
395
571
|
thumbnailUrl: string;
|
|
396
572
|
}
|
|
397
573
|
|
|
574
|
+
/**
|
|
575
|
+
* @beta
|
|
576
|
+
* Intermediate state while multi-page document thumbnails are being fetched
|
|
577
|
+
* via {@link requestPreviewUpgrade}. The single-page thumbnail remains
|
|
578
|
+
* available for display during the upgrade.
|
|
579
|
+
*/
|
|
580
|
+
export declare interface DocumentPreviewUpgrading extends SizedPreview {
|
|
581
|
+
kind: 'document';
|
|
582
|
+
status: 'upgrading';
|
|
583
|
+
thumbnailFormat: 'png' | 'jpg';
|
|
584
|
+
/** The first-page thumbnail URL, available immediately. */
|
|
585
|
+
thumbnailUrl: string;
|
|
586
|
+
}
|
|
587
|
+
|
|
398
588
|
/**
|
|
399
589
|
* @public
|
|
400
590
|
* Document file requirements for a media slot.
|
|
@@ -436,6 +626,18 @@ export declare interface DocumentSelection extends BaseSelection {
|
|
|
436
626
|
*/
|
|
437
627
|
export declare type DocumentSize = 'a4' | 'a3' | 'letter' | 'legal';
|
|
438
628
|
|
|
629
|
+
/**
|
|
630
|
+
* @beta
|
|
631
|
+
* Content summary for email sends.
|
|
632
|
+
*/
|
|
633
|
+
export declare type EmailContentSummary = BaseContentSummary & {
|
|
634
|
+
type: 'email';
|
|
635
|
+
/** Subject line. */
|
|
636
|
+
subject?: string;
|
|
637
|
+
/** Email body preview or preheader. */
|
|
638
|
+
body?: string;
|
|
639
|
+
};
|
|
640
|
+
|
|
439
641
|
/**
|
|
440
642
|
* @public
|
|
441
643
|
* Exported email file ready for publishing.
|
|
@@ -535,6 +737,54 @@ export declare type ExactValueRange = {
|
|
|
535
737
|
exact: number;
|
|
536
738
|
};
|
|
537
739
|
|
|
740
|
+
/**
|
|
741
|
+
* @beta
|
|
742
|
+
* Generic content summary for apps that don't fit a more specific type.
|
|
743
|
+
*/
|
|
744
|
+
export declare type GenericContentSummary = BaseContentSummary & {
|
|
745
|
+
type: 'content';
|
|
746
|
+
/** Title or headline. */
|
|
747
|
+
title?: string;
|
|
748
|
+
/** Body text or description. */
|
|
749
|
+
body?: string;
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* @beta
|
|
754
|
+
* Successful response from getContentSummary.
|
|
755
|
+
*/
|
|
756
|
+
export declare type GetContentSummaryCompleted = {
|
|
757
|
+
status: 'completed';
|
|
758
|
+
contentSummary: ContentSummary;
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* @beta
|
|
763
|
+
* Error response from getContentSummary.
|
|
764
|
+
*/
|
|
765
|
+
export declare type GetContentSummaryError = AppError;
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* @beta
|
|
769
|
+
* Request payload for the getContentSummary action.
|
|
770
|
+
*/
|
|
771
|
+
export declare type GetContentSummaryRequest = {
|
|
772
|
+
/** The user's saved publish settings. Parse to retrieve app-specific state. */
|
|
773
|
+
publishRef?: string;
|
|
774
|
+
/**
|
|
775
|
+
* The output type selected for this publish operation.
|
|
776
|
+
*
|
|
777
|
+
* Use `id` to distinguish between output types.
|
|
778
|
+
*/
|
|
779
|
+
outputType: OutputType;
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* @beta
|
|
784
|
+
* Response from getContentSummary.
|
|
785
|
+
*/
|
|
786
|
+
export declare type GetContentSummaryResponse = GetContentSummaryCompleted | GetContentSummaryError;
|
|
787
|
+
|
|
538
788
|
/**
|
|
539
789
|
* @public
|
|
540
790
|
* Successful response from getting publish configuration.
|
|
@@ -899,6 +1149,12 @@ export declare type OutputType = {
|
|
|
899
1149
|
* such as a main image, thumbnail, or video.
|
|
900
1150
|
*/
|
|
901
1151
|
mediaSlots: MediaSlot[];
|
|
1152
|
+
/**
|
|
1153
|
+
* @beta
|
|
1154
|
+
* The type of content being published. When set, Canva uses this to tailor and improve the
|
|
1155
|
+
* publish experience. When omitted, defaults to `'content'` (generic behavior).
|
|
1156
|
+
*/
|
|
1157
|
+
contentNoun?: ContentNoun;
|
|
902
1158
|
};
|
|
903
1159
|
|
|
904
1160
|
/**
|
|
@@ -951,6 +1207,26 @@ export declare type OutputTypeConfiguration = {
|
|
|
951
1207
|
* do not provide selection data when defining output types.
|
|
952
1208
|
*/
|
|
953
1209
|
mediaSlots: Omit<MediaSlot, 'selection'>[];
|
|
1210
|
+
/**
|
|
1211
|
+
* @beta
|
|
1212
|
+
* The type of content being published. When set, Canva uses this to tailor and improve the
|
|
1213
|
+
* publish experience. When omitted, defaults to `'content'` (generic behavior).
|
|
1214
|
+
*/
|
|
1215
|
+
contentNoun?: ContentNoun;
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* @beta
|
|
1220
|
+
* Content summary for social media posts (e.g. Instagram, Facebook, LinkedIn, YouTube).
|
|
1221
|
+
*/
|
|
1222
|
+
export declare type PostContentSummary = BaseContentSummary & {
|
|
1223
|
+
type: 'post';
|
|
1224
|
+
/** Post heading (e.g. YouTube title, LinkedIn article headline). */
|
|
1225
|
+
title?: string;
|
|
1226
|
+
/** Post caption or body text. */
|
|
1227
|
+
body?: string;
|
|
1228
|
+
/** Hashtags without the leading `#` (e.g. `["fashion", "design"]`). */
|
|
1229
|
+
hashtags?: string[];
|
|
954
1230
|
};
|
|
955
1231
|
|
|
956
1232
|
/**
|
|
@@ -980,9 +1256,9 @@ export declare type PostPublishActionRedirect = {
|
|
|
980
1256
|
};
|
|
981
1257
|
|
|
982
1258
|
/**
|
|
983
|
-
* @
|
|
1259
|
+
* @beta
|
|
984
1260
|
*
|
|
985
|
-
* Prepares a
|
|
1261
|
+
* Prepares a `ContentPublisherIntent`.
|
|
986
1262
|
*
|
|
987
1263
|
* @example
|
|
988
1264
|
* ```tsx
|
|
@@ -1007,8 +1283,8 @@ export declare type PostPublishActionRedirect = {
|
|
|
1007
1283
|
export declare const prepareContentPublisher: (implementation: ContentPublisherIntent) => void;
|
|
1008
1284
|
|
|
1009
1285
|
/**
|
|
1010
|
-
* @
|
|
1011
|
-
* Preview item for an image or
|
|
1286
|
+
* @beta
|
|
1287
|
+
* Preview item for an image, video, document, or email.
|
|
1012
1288
|
*
|
|
1013
1289
|
* Check the `kind` and `status` properties to determine the type and state.
|
|
1014
1290
|
*/
|
|
@@ -1021,10 +1297,10 @@ export declare type Preview = ImagePreview | VideoPreview | DocumentPreview | Em
|
|
|
1021
1297
|
export declare type PreviewKind = 'image' | 'video' | 'document' | 'email';
|
|
1022
1298
|
|
|
1023
1299
|
/**
|
|
1024
|
-
* @
|
|
1300
|
+
* @beta
|
|
1025
1301
|
* Preview media for a specific media slot.
|
|
1026
1302
|
*
|
|
1027
|
-
* Contains preview URLs and metadata for images or
|
|
1303
|
+
* Contains preview URLs and metadata for images, videos, documents, or emails in the design.
|
|
1028
1304
|
*/
|
|
1029
1305
|
export declare type PreviewMedia = {
|
|
1030
1306
|
/**
|
|
@@ -1180,7 +1456,7 @@ export declare type PublishErrorSettingsUiContext = {
|
|
|
1180
1456
|
export declare type PublishFileFormat = 'png' | 'jpg' | 'mp4' | 'pdf_standard' | 'html_bundle' | 'html_standalone';
|
|
1181
1457
|
|
|
1182
1458
|
/**
|
|
1183
|
-
* @
|
|
1459
|
+
* @beta
|
|
1184
1460
|
* Initial payload provided from cache.
|
|
1185
1461
|
*/
|
|
1186
1462
|
export declare type PublishPreviewUiInvocationContext = {
|
|
@@ -1308,21 +1584,21 @@ export declare type RemoteRequestFailedError = {
|
|
|
1308
1584
|
};
|
|
1309
1585
|
|
|
1310
1586
|
/**
|
|
1311
|
-
* @
|
|
1587
|
+
* @beta
|
|
1312
1588
|
* Initial payload provided when the preview UI is rendered.
|
|
1313
1589
|
* Contains the preview data and settings needed to initialize the preview interface.
|
|
1314
1590
|
*/
|
|
1315
1591
|
export declare type RenderPreviewUiInvocationContext = PublishPreviewUiInvocationContext;
|
|
1316
1592
|
|
|
1317
1593
|
/**
|
|
1318
|
-
* @
|
|
1594
|
+
* @beta
|
|
1319
1595
|
* Configuration required for rendering the preview UI.
|
|
1320
1596
|
*
|
|
1321
1597
|
* Provides callbacks for managing preview media and responding to preview updates.
|
|
1322
1598
|
*/
|
|
1323
1599
|
export declare type RenderPreviewUiRequest = {
|
|
1324
1600
|
/**
|
|
1325
|
-
* @
|
|
1601
|
+
* @beta
|
|
1326
1602
|
* The initial preview data and context provided when the preview UI is rendered.
|
|
1327
1603
|
*
|
|
1328
1604
|
* Contains the initial preview media, output type information, and any existing
|
|
@@ -1330,17 +1606,17 @@ export declare type RenderPreviewUiRequest = {
|
|
|
1330
1606
|
*/
|
|
1331
1607
|
invocationContext: RenderPreviewUiInvocationContext;
|
|
1332
1608
|
/**
|
|
1333
|
-
* Callback to upgrade
|
|
1609
|
+
* Callback to upgrade thumbnail previews to their full media variant.
|
|
1334
1610
|
*
|
|
1335
|
-
* Call this function when you need full
|
|
1336
|
-
* This helps optimize performance by deferring full
|
|
1611
|
+
* Call this function when you need full previews instead of lightweight thumbnails.
|
|
1612
|
+
* This helps optimize performance by deferring full media loading until needed.
|
|
1337
1613
|
*
|
|
1338
1614
|
* Upgrades may complete asynchronously; listen to `registerOnPreviewChange` for updates
|
|
1339
|
-
* to receive the upgraded
|
|
1615
|
+
* to receive the upgraded previews.
|
|
1340
1616
|
*
|
|
1341
|
-
* @param previewIds - Array of preview IDs to upgrade from thumbnail to full
|
|
1617
|
+
* @param previewIds - Array of preview IDs to upgrade from thumbnail to full media
|
|
1342
1618
|
*
|
|
1343
|
-
* @example Upgrading
|
|
1619
|
+
* @example Upgrading previews on user interaction
|
|
1344
1620
|
* ```ts
|
|
1345
1621
|
* // When user clicks on a video thumbnail, upgrade to full video
|
|
1346
1622
|
* if (preview.kind === 'video' && preview.status === 'thumbnail') {
|
|
@@ -1356,7 +1632,7 @@ export declare type RenderPreviewUiRequest = {
|
|
|
1356
1632
|
*
|
|
1357
1633
|
* - The design content changes
|
|
1358
1634
|
* - The output type changes
|
|
1359
|
-
* - Preview media is upgraded from thumbnail to full
|
|
1635
|
+
* - Preview media is upgraded from thumbnail to full media
|
|
1360
1636
|
* - Export settings are modified
|
|
1361
1637
|
*
|
|
1362
1638
|
* Use this to update your preview UI in real-time as users modify their design.
|
|
@@ -1476,9 +1752,47 @@ export declare type RenderSettingsUiRequest = {
|
|
|
1476
1752
|
registerOnContextChange: (opts: {
|
|
1477
1753
|
onContextChange: OnContextChange;
|
|
1478
1754
|
}) => Disposer;
|
|
1479
|
-
|
|
1755
|
+
/**
|
|
1756
|
+
* @beta
|
|
1757
|
+
* Function to trigger a request for AI content.
|
|
1758
|
+
*
|
|
1759
|
+
* Use this function to trigger a request for AI content.
|
|
1760
|
+
*
|
|
1761
|
+
* @param request - The request for AI content.
|
|
1762
|
+
* @returns A promise resolving to the AI content response with a status of 'completed' or 'cancelled'.
|
|
1763
|
+
* @example Requesting AI content
|
|
1764
|
+
* ```ts
|
|
1765
|
+
* async function onGenerateCaption() {
|
|
1766
|
+
* const result = await requestAiContent({
|
|
1767
|
+
* type: 'social_caption',
|
|
1768
|
+
* currentValue: settings.caption,
|
|
1769
|
+
* fieldLabel: 'Caption',
|
|
1770
|
+
* hints: {
|
|
1771
|
+
* maxLength: 2200,
|
|
1772
|
+
* },
|
|
1773
|
+
* });
|
|
1774
|
+
*
|
|
1775
|
+
* if (result.status !== 'completed') {
|
|
1776
|
+
* return;
|
|
1777
|
+
* }
|
|
1778
|
+
* const nextSettings = { ...settings, caption: result.value };
|
|
1779
|
+
* // ... set local state
|
|
1780
|
+
* await updatePublishSettings({
|
|
1781
|
+
* publishRef: JSON.stringify(nextSettings),
|
|
1782
|
+
* validityState: 'valid',
|
|
1783
|
+
* });
|
|
1784
|
+
* }
|
|
1785
|
+
* ```
|
|
1786
|
+
*/
|
|
1787
|
+
requestAiContent: RequestAiContent;
|
|
1480
1788
|
};
|
|
1481
1789
|
|
|
1790
|
+
/**
|
|
1791
|
+
* @beta
|
|
1792
|
+
* Function to trigger a request for AI content.
|
|
1793
|
+
*/
|
|
1794
|
+
export declare type RequestAiContent = (request: AiContentRequest) => Promise<AiContentResponse>;
|
|
1795
|
+
|
|
1482
1796
|
/**
|
|
1483
1797
|
* @public
|
|
1484
1798
|
* Metadata specific to design content represented by a media selection.
|
|
@@ -1522,6 +1836,23 @@ export declare interface SizedPreview extends BasePreview {
|
|
|
1522
1836
|
heightPx: number;
|
|
1523
1837
|
}
|
|
1524
1838
|
|
|
1839
|
+
/**
|
|
1840
|
+
* @beta
|
|
1841
|
+
* Request for social caption generation.
|
|
1842
|
+
*/
|
|
1843
|
+
export declare type SocialCaptionRequest = BaseAiContentRequest & {
|
|
1844
|
+
type: 'social_caption';
|
|
1845
|
+
/**
|
|
1846
|
+
* Hints for how the AI should generate the caption.
|
|
1847
|
+
*/
|
|
1848
|
+
hints?: {
|
|
1849
|
+
/**
|
|
1850
|
+
* The maximum length of the caption.
|
|
1851
|
+
*/
|
|
1852
|
+
maxLength?: number;
|
|
1853
|
+
};
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1525
1856
|
/**
|
|
1526
1857
|
* @public
|
|
1527
1858
|
* Successful response from updating the publish settings.
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
Object.defineProperty(exports, "prepareContentPublisher", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return prepareContentPublisher;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
5
11
|
const _version = require("../version");
|
|
6
12
|
_export_star(require("./public"), exports);
|
|
7
13
|
function _export_star(from, to) {
|
|
@@ -17,4 +23,5 @@ function _export_star(from, to) {
|
|
|
17
23
|
});
|
|
18
24
|
return from;
|
|
19
25
|
}
|
|
26
|
+
const prepareContentPublisher = canva_sdk.intents.v1.content.prepareContentPublisher;
|
|
20
27
|
window.__canva__?.sdkRegistration?.registerPackageVersion('intents/content', _version.LATEST_VERSION_BETA, 'beta');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { LATEST_VERSION_BETA } from '../version';
|
|
2
2
|
export * from './public';
|
|
3
|
+
export const prepareContentPublisher = canva_sdk.intents.v1.content.prepareContentPublisher;
|
|
3
4
|
window.__canva__?.sdkRegistration?.registerPackageVersion('intents/content', LATEST_VERSION_BETA, 'beta');
|