@canva/design 1.11.0-beta.1 → 2.0.0-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/beta.d.ts CHANGED
@@ -3,73 +3,89 @@
3
3
  * @public
4
4
  * @param audioTrack - The audio track to add to the user's design.
5
5
  */
6
- export declare function addAudioTrack(audioTrack: AudioTrack): Promise<void>;
6
+ export declare const addAudioTrack: (audioTrack: AudioTrack) => Promise<void>;
7
7
 
8
8
  /**
9
- * @beta
10
- * Adds a native element to the user's design.
11
- * @param element - The element to add to the user's design.
9
+ * @public
10
+ * Add element to responsive documents, which slot things into a text stream
11
+ */
12
+ export declare const addElementAtCursor: (
13
+ element: ElementAtCursor | TableElement
14
+ ) => Promise<void>;
15
+
16
+ /**
17
+ * @public
18
+ * Add element to fixed designs, which use a coordinate-based positioning system.
12
19
  */
13
- export declare function addNativeElement(
14
- element:
15
- | NativeElement
16
- | NativeElementWithBox
17
- | NativeTableElement
18
- | NativeRichtextElement
19
- | NativeRichtextElementWithBox
20
- ): Promise<void>;
20
+ export declare const addElementAtPoint: (
21
+ element: DesignElement | ElementAtPoint | TableElement | RichtextElement
22
+ ) => Promise<void>;
21
23
 
22
24
  /**
25
+ * @deprecated
23
26
  * @public
24
27
  * Adds a native element to the user's design.
25
28
  * @param element - The element to add to the user's design.
26
29
  */
27
- export declare function addNativeElement(
30
+ export declare const addNativeElement: (
28
31
  element: NativeElement | NativeElementWithBox
29
- ): Promise<void>;
32
+ ) => Promise<void>;
30
33
 
31
34
  /**
32
35
  * @public
33
36
  * Adds a new page immediately after the currently selected page.
34
37
  * @param opts - Configuration for the new page to be added.
35
38
  */
36
- export declare function addPage(opts?: {
39
+ export declare const addPage: (opts?: {
37
40
  /** Elements to be added to the page */
38
- elements?: NativeElementWithBox[];
41
+ elements?: ElementAtPoint[];
39
42
  /**
40
43
  * The page background. This can be a solid color, an image or a video.
41
44
  **/
42
45
  background?: PageBackgroundFill;
43
46
  /** A page title which must be no longer than 255 characters */
44
47
  title?: string;
45
- }): Promise<void>;
48
+ }) => Promise<void>;
46
49
 
47
50
  /**
48
51
  * @public
49
- * Describes any alt-text that will be added for a11y.
52
+ * Alternative text for a11y compliance.
50
53
  */
51
54
  export declare type AltText = {
52
55
  /**
53
- * The text that will appear as alt-text.
56
+ * The text content.
54
57
  */
55
58
  text: string;
56
59
  /**
57
- * An optional property that will determine whether text is shown in just the editor or both editor and view mode.
58
- * If set to true, alt-text will only be rendered inside the editor.
59
- * If set to false or omitted, alt-text will be rendered in both the editor and in view only mode.
60
+ * Indicates where the alternative text should be displayed.
61
+ *
62
+ * @remarks
63
+ * - If `true`, the alternative text will only be displayed in the editor.
64
+ * - If `false`, the alternative text will be displayed in the editor and in view-only mode.
60
65
  */
61
66
  decorative: boolean | undefined;
62
67
  };
63
68
 
64
69
  /**
65
70
  * @public
66
- * A callback that runs when an app element's data is created or updated,
67
- * or when the user selects an existing app element.
71
+ * A callback that runs when:
72
+ *
73
+ * - the app element is created
74
+ * - the app element's data is updated
75
+ * - the user selects an existing app element
76
+ *
77
+ * @param appElement - Information about the app element that was changed.
68
78
  */
69
79
  export declare type AppElementChangeHandler<A extends AppElementData> = (
70
80
  appElement:
71
81
  | {
82
+ /**
83
+ * The app element data in its most recent state.
84
+ */
72
85
  data: A;
86
+ /**
87
+ * The version number of the app.
88
+ */
73
89
  version: number;
74
90
  }
75
91
  | undefined
@@ -77,47 +93,49 @@ export declare type AppElementChangeHandler<A extends AppElementData> = (
77
93
 
78
94
  /**
79
95
  * @public
80
- * A client interface for managing app elements and app element data.
96
+ * A client that provides methods for creating and managing the lifecycle of an app element.
81
97
  */
82
98
  export declare interface AppElementClient<A extends AppElementData> {
83
99
  /**
84
- * Attaches data to the selected app element or creates a new app element if one is not selected.
85
- * If data already exists, it's overwritten.
86
- * @param appElementData - The data to attach to the app element.
100
+ * If an app element is selected, the element's data is overwritten and the element is re-rendered.
101
+ * Otherwise, the provided data is used to create a new app element.
102
+ * @param appElementData - The data to attach to the app element. Existing data will be overwritten.
103
+ * @param placement - The position, dimensions, and rotation of the app element.
87
104
  */
88
105
  addOrUpdateElement(appElementData: A, placement?: Placement): Promise<void>;
89
106
  /**
90
- * Registers a callback that runs when the app element's data is created or
91
- * updated and when the user selects an existing app element.
92
- * @param handler - The callback to run when the app element's data is changed
93
- * and when the user selects an existing app element.
107
+ * A callback that runs when:
108
+ *
109
+ * - the app element is created
110
+ * - the app element's data is updated
111
+ * - the user selects an existing app element
112
+ *
113
+ * @param handler - The callback to run when the app element changes.
94
114
  */
95
115
  registerOnElementChange(handler: AppElementChangeHandler<A>): void;
96
116
  }
97
117
 
98
118
  /**
99
119
  * @public
100
- * Configuration for an AppElementClient
120
+ * Options for creating an app element client.
101
121
  */
102
122
  export declare type AppElementClientConfiguration<A extends AppElementData> = {
103
123
  /**
104
- * The AppElementRenderer to use when rendering the app element
124
+ * Registers a callback that renders an app element based on the data it receives.
105
125
  */
106
126
  render: AppElementRenderer<A>;
107
127
  };
108
128
 
109
129
  /**
110
130
  * @public
111
- * The data an app can attach to an app element.
131
+ * The data associated with an app element.
112
132
  */
113
133
  export declare type AppElementData = Record<string, Value>;
114
134
 
115
135
  /**
116
136
  * @public
117
- * A callback that runs when an app's element is changed.
118
- *
119
- * @remarks
120
- * This callback must return one or more elements to render within the app element.
137
+ * A callback function that renders an app element based on the data it receives.
138
+ * @param appElementData - The data the callback must use to render the app element.
121
139
  */
122
140
  export declare type AppElementRenderer<A extends AppElementData> = (
123
141
  appElementData: A
@@ -125,8 +143,7 @@ export declare type AppElementRenderer<A extends AppElementData> = (
125
143
 
126
144
  /**
127
145
  * @public
128
- * A return value of {@link AppElementRenderer} function.
129
- * It is an array of elements to render within an app element.
146
+ * An array of one or more elements to render as output of an app element.
130
147
  */
131
148
  export declare type AppElementRendererOutput = NativeSimpleElementWithBox[];
132
149
 
@@ -140,13 +157,13 @@ export declare type AppProcessId = string & {
140
157
 
141
158
  /**
142
159
  * @public
143
- * Options for defining the drag-and-drop behavior of audio tracks.
160
+ * Audio track to be added to the design at the end of a drag event.
144
161
  */
145
162
  export declare type AudioDragConfig = {
146
163
  /**
147
164
  * The type of element.
148
165
  */
149
- type: "AUDIO";
166
+ type: "audio";
150
167
  /**
151
168
  * A function that returns a reference (ref) to an audio asset in Canva's backend.
152
169
  */
@@ -173,175 +190,960 @@ export declare type AudioRef = string & {
173
190
 
174
191
  /**
175
192
  * @public
176
- * An audio track that can be added to a user's design.
193
+ * An audio track that can be added to a design.
177
194
  */
178
195
  export declare type AudioTrack = {
179
196
  /**
180
- * A unique identifier that references an audio asset in Canva's backend.
197
+ * A unique identifier that points to an audio asset in Canva's backend.
181
198
  */
182
199
  ref: AudioRef;
183
200
  };
184
201
 
185
202
  /**
186
- * @beta
187
- * The boundaries of a rich text region.
203
+ * @public
204
+ * A segment of a richtext range.
188
205
  */
189
206
  export declare type Bounds = {
190
207
  /**
191
- * The index of the character from which the region starts.
208
+ * The starting position of the segment.
192
209
  *
193
210
  * @remarks
194
- * A value of `0` means the region starts from the first character.
211
+ * This is zero-based, meaning the first character of the range is at index 0.
195
212
  */
196
213
  index: number;
197
214
  /**
198
- * The length of the text region.
215
+ * The number of characters in the segment, starting from the index.
199
216
  */
200
217
  length: number;
201
218
  };
202
219
 
203
220
  /**
221
+ * @deprecated
204
222
  * @public
205
- * The dimensions, position, and rotation of an element.
223
+ * A position, rotation, and set of dimensions.
206
224
  *
207
225
  * @remarks
208
- * Units are relative to the parent container both in terms of position and size
226
+ * The position and dimensions are relative to the container.
209
227
  */
210
228
  export declare type Box = Position & (WidthAndHeight | Width | Height);
211
229
 
212
230
  /**
213
- * @beta
214
- * A cell for a NativeTableElement. Cells can have text content and a background color.
215
- * A cell can also be sized by setting the colSpan and rowSpan values for how many columns
216
- * and rows the cell occupies respectively.
231
+ * @public
232
+ * An individual cell in a table element.
217
233
  */
218
234
  export declare type Cell = {
219
235
  /**
220
- * The text content of the table cell
236
+ * The attributes of the cell.
237
+ */
238
+ attributes?: CellAttributes;
239
+ /**
240
+ * The number of columns that the cell occupies.
241
+ */
242
+ colSpan?: number;
243
+ /**
244
+ * The number of rows that the cell occupies.
245
+ */
246
+ rowSpan?: number;
247
+ } & CellContent;
248
+
249
+ /**
250
+ * @public
251
+ * Additional attributes of table cell.
252
+ */
253
+ declare type CellAttributes = {
254
+ /**
255
+ * The background color of the cell, as a hex code.
256
+ */
257
+ backgroundColor?: string;
258
+ } & TextAttributes;
259
+
260
+ /**
261
+ * @public
262
+ * The content of a table element's cell.
263
+ * Cell only supports plain text.
264
+ */
265
+ declare type CellContent =
266
+ | {
267
+ /**
268
+ * Indicates that the cell doesn't have any content.
269
+ */
270
+ type: "empty";
271
+ }
272
+ | {
273
+ /**
274
+ * Indicates that the cell contains plaintext content.
275
+ */
276
+ type: "string";
277
+ /**
278
+ * The plaintext content of the cell.
279
+ *
280
+ * @remarks
281
+ * If an empty string is provided, the `type` will change to `"empty"`.
282
+ */
283
+ value: string;
284
+ };
285
+
286
+ /**
287
+ * Image element or content to be added to the design at the end of a drag event.
288
+ */
289
+ declare type CommonImageDragConfig = {
290
+ /**
291
+ * The type of element.
292
+ */
293
+ type: "image";
294
+ /**
295
+ * The dimensions of the preview image.
296
+ */
297
+ previewSize: Dimensions;
298
+ };
299
+
300
+ /**
301
+ * @public
302
+ * A snapshot of content from a user's design.
303
+ */
304
+ export declare interface ContentDraft<T> {
305
+ /**
306
+ * The individual content items that exist within the snapshot.
307
+ *
308
+ * @remarks
309
+ * Any changes made to this array won't be reflected in the user's design until the `save` method is called.
310
+ */
311
+ readonly contents: readonly T[];
312
+ /**
313
+ * Saves changes made to the content items in the `contents` array.
314
+ *
315
+ * @remarks
316
+ * Once this method is called:
317
+ *
318
+ * - Any changes the app has made to to the content will be reflected in the user's design.
319
+ * - Any changes the user has made to the content since the snapshot was created may be overwritten.
320
+ * - Only properties that are different from the original state will be written to the design.
321
+ */
322
+ save(): Promise<void>;
323
+ }
324
+
325
+ /**
326
+ * @public
327
+ * A type of content that can be read from a user's design.
328
+ */
329
+ export declare type ContentType = "richtext";
330
+
331
+ /**
332
+ * @beta
333
+ * Options for configuring where content in a design should be queried from.
334
+ */
335
+ declare type ContextOptions = {
336
+ context: "current_page";
337
+ };
338
+
339
+ /**
340
+ * @public
341
+ * A set of X and Y coordinates.
342
+ */
343
+ export declare type Coordinates = {
344
+ /**
345
+ * X coordinate, in pixels.
346
+ */
347
+ x: number;
348
+ /**
349
+ * Y coordinate, in pixels.
350
+ */
351
+ y: number;
352
+ };
353
+
354
+ /**
355
+ * @public
356
+ * Creates a new RichtextRange object, which contains methods to manipulate text.
357
+ */
358
+ export declare function createRichtextRange(): RichtextRange;
359
+
360
+ /**
361
+ * @beta
362
+ * Describes a part of a design.
363
+ */
364
+ export declare type DesignContext = DesignContextOptions["type"];
365
+
366
+ /**
367
+ * @beta
368
+ * Options for configuring which part of a design to read.
369
+ */
370
+ declare type DesignContextOptions = {
371
+ /**
372
+ * The type of context.
373
+ */
374
+ type: "current_page";
375
+ };
376
+
377
+ /**
378
+ * @beta
379
+ * Provides methods for reading and updating the structure and content of a design.
380
+ */
381
+ export declare namespace DesignEditing {
382
+ /**
383
+ * @beta
384
+ * A snapshot containing a fragment of a design's structure and content.
385
+ */
386
+ export type DesignDraft<D> = Readonly<D> & {
387
+ /**
388
+ * Saves any changes made to the draft.
389
+ *
390
+ * @remarks
391
+ * - Any changes to the draft are only reflected in the design after this method is called.
392
+ * - Once this method is called, further changes to the draft are not possible.
393
+ */
394
+ save(): Promise<void>;
395
+ };
396
+ /**
397
+ * @beta
398
+ * Options for creating an image fill in the element builder
399
+ */
400
+ export type ImageFillOpts = Partial<ImageFill> &
401
+ Required<Pick<ImageFill, "type" | "imageRef">>;
402
+ /**
403
+ * @beta
404
+ * Options for creating a video fill in the element builder
405
+ */
406
+ export type VideoFillOpts = Partial<VideoFill> &
407
+ Required<Pick<VideoFill, "type" | "videoRef">>;
408
+ /**
409
+ * @beta
410
+ * Options for creating a media fill in the element builder
411
+ */
412
+ export type MediaFillOpts = ImageFillOpts | VideoFillOpts;
413
+ /**
414
+ * @beta
415
+ * Options for creating a fill in the element builder
416
+ */
417
+ export type FillOpts =
418
+ | {
419
+ color: ColorFillOpts;
420
+ media?: MediaFillOpts;
421
+ }
422
+ | {
423
+ color?: ColorFillOpts;
424
+ media: MediaFillOpts;
425
+ };
426
+ /**
427
+ * @beta
428
+ */
429
+ export type ColorFillOpts = Exclude<ColorFill, Unsupported>;
430
+ /**
431
+ * @beta
432
+ * Options for creating a stroke in the element builder
433
+ */
434
+ export type StrokeOpts = Pick<Stroke, "weight"> & {
435
+ color: ColorFillOpts;
436
+ };
437
+ /**
438
+ * @beta
439
+ * Options for creating a shape path in the element builder
440
+ */
441
+ export type ShapePathOpts = Pick<Path, "d"> & {
442
+ fill?: FillOpts;
443
+ stroke?: StrokeOpts;
444
+ };
445
+ /**
446
+ * @beta
447
+ * Options for creating a rect element.
448
+ */
449
+ export type CreateRectElementOpts = Required<
450
+ Pick<Element, "top" | "left" | "width" | "height">
451
+ > & {
452
+ fill?: FillOpts;
453
+ } & {
454
+ stroke?: StrokeOpts;
455
+ } & Partial<Omit<RectElement, "fill" | "stroke" | "type">>;
456
+ /**
457
+ * @beta
458
+ * Options for creating a shape element.
459
+ */
460
+ export type CreateShapeElementOpts = Required<
461
+ Pick<ShapeElement, "top" | "left" | "width" | "height" | "viewBox">
462
+ > & {
463
+ paths: ShapePathOpts[];
464
+ } & Partial<Omit<ShapeElement, "type" | "paths">>;
465
+ /**
466
+ * @beta
467
+ * Options for creating an embed element.
468
+ */ export type CreateEmbedElementOpts = Required<
469
+ Pick<EmbedElement, "top" | "left" | "width" | "height" | "url">
470
+ > &
471
+ Partial<Omit<EmbedElement, "type">>;
472
+ /**
473
+ * @beta
474
+ * Options for creating a text element.
475
+ */
476
+ export type CreateTextElementOpts = Required<
477
+ Pick<TextElement, "top" | "left" | "width" | "text">
478
+ > &
479
+ Partial<Omit<TextElement, "type" | "height">>;
480
+ /**
481
+ * @beta
482
+ * Provides methods for creating elements.
483
+ *
484
+ * @remarks
485
+ * These methods don't add the elements to the design. They only return elements that can
486
+ * be added to a design, such as with the `insertAfter` method.
487
+ */
488
+ export interface ElementBuilder {
489
+ /**
490
+ * Creates a rect element.
491
+ * @param opts - Options for creating the rect element.
492
+ */
493
+ createRectElement(opts: CreateRectElementOpts): RectElement;
494
+ /**
495
+ * Creates a shape element.
496
+ * @param opts - Options for creating the shape element.
497
+ */
498
+ createShapeElement(opts: CreateShapeElementOpts): ShapeElement;
499
+ /**
500
+ * Creates an embed element.
501
+ * @param opts - Options for creating the embed element.
502
+ */
503
+ createEmbedElement(opts: CreateEmbedElementOpts): EmbedElement;
504
+ /**
505
+ * Creates a text element.
506
+ * @param opts - Options for creating the text element.
507
+ */
508
+ createTextElement(opts: CreateTextElementOpts): TextElement;
509
+ /**
510
+ * Creates a richtext range.
511
+ */
512
+ createRichtextRange(): RichtextRange;
513
+ }
514
+ /**
515
+ * @beta
516
+ * The result of reading part of a design when the context is the current page.
517
+ */
518
+ export type CurrentPageResult = DesignDraft<{
519
+ /**
520
+ * The current page of the design.
521
+ */
522
+ page: FixedPage;
523
+ }>;
524
+ /**
525
+ * @beta
526
+ * The result of reading part of a design.
527
+ */
528
+ export type DesignOpenResult = CurrentPageResult;
529
+ /**
530
+ * A function called for each item in the list.
531
+ *
532
+ * @param item - The current item in the list.
533
+ * @param index - The index of the current item.
534
+ */
535
+ export type ForEachCallback<T> = (item: T, index: number) => void;
536
+ /**
537
+ * A function that determines if an item should be included in the result.
538
+ *
539
+ * @param item - The item to test.
540
+ * @returns `true` if the item should be included, otherwise `false`.
541
+ */
542
+ export type FilterPredicate<T> = (item: T) => boolean;
543
+ /**
544
+ * A type predicate function that determines if an item is of a specific type.
545
+ *
546
+ * @param item - The item to test.
547
+ * @returns `true` if the item is of type `C`, otherwise `false`.
548
+ */
549
+ export type TypeFilterPredicate<T, C extends T> = (item: T) => item is C;
550
+ /**
551
+ * A list that cannot be changed.
552
+ */
553
+ export interface ReadableList<T> {
554
+ /**
555
+ * Gets the number of items in the list.
556
+ *
557
+ * @returns The number of items.
558
+ */
559
+ count(): number;
560
+ /**
561
+ * Converts the list to an array.
562
+ *
563
+ * @returns An array containing all items. The items are the same as in the list.
564
+ */
565
+ toArray(): readonly T[];
566
+ /**
567
+ * Executes a function for each item in the list.
568
+ *
569
+ * @param callback - The function to run for each item.
570
+ */
571
+ forEach(callback: ForEachCallback<T>): void;
572
+ /**
573
+ * Creates a new array with items that match a specific type.
574
+ *
575
+ * @param filter - A function that checks if an item is of type `C`.
576
+ * @returns An array of items that are of type `C`.
577
+ */
578
+ filter<C extends T>(filter: TypeFilterPredicate<T, C>): readonly C[];
579
+ /**
580
+ * Creates a new array with items that pass a test.
581
+ *
582
+ * @param filter - A function that tests each item. Returns `true` to keep the item.
583
+ * @returns An array of items that passed the test.
584
+ */
585
+ filter(filter: FilterPredicate<T>): readonly T[];
586
+ }
587
+ /**
588
+ * @beta
589
+ * A list of items that can be changed.
590
+ */
591
+ export interface MutableList<T> {
592
+ /**
593
+ * Adds a copy of an item to the list and places it right before another item.
594
+ *
595
+ * @param ref - The existing item to place the new item before.
596
+ * If `ref` is `undefined`, the new item is added at the end of the list.
597
+ * If `ref` does not exist in the list, the operation fails.
598
+ *
599
+ * @param item - The item to add. A copy of this item will be inserted.
600
+ *
601
+ * @returns
602
+ * The added item, or `undefined` if the operation failed.
603
+ */
604
+ insertBefore(ref: T | undefined, item: T): T | undefined;
605
+ /**
606
+ * Adds a copy of an item to the list and places it right after another item.
607
+ *
608
+ * @param ref - The existing item to place the new item after.
609
+ * If `ref` is `undefined`, the new item is added at the end of the list.
610
+ * If `ref` does not exist in the list, the operation fails.
611
+ *
612
+ * @param item - The item to add. A copy of this item will be inserted.
613
+ *
614
+ * @returns
615
+ * The added item, or `undefined` if the operation failed.
616
+ */
617
+ insertAfter(ref: T | undefined, item: T): T | undefined;
618
+ /**
619
+ * Moves an existing item to a new position right before another item.
620
+ *
621
+ * @param ref - The existing item to move the item before.
622
+ * If `ref` is `undefined`, the item is moved to the end of the list.
623
+ * If `ref` does not exist in the list, the operation fails.
624
+ *
625
+ * @param item - The item to move.
626
+ * The operation fails if the item is not already in the list.
627
+ */
628
+ moveBefore(ref: T | undefined, item: T): void;
629
+ /**
630
+ * Moves an existing item to a new position right after another item.
631
+ *
632
+ * @param ref - The existing item to move the item after.
633
+ * If `ref` is `undefined`, the item is moved to the end of the list.
634
+ * If `ref` does not exist in the list, the operation fails.
635
+ *
636
+ * @param item - The item to move.
637
+ * The operation fails if the item is not already in the list.
638
+ */
639
+ moveAfter(ref: T | undefined, item: T): void;
640
+ /**
641
+ * Removes an item from the list.
642
+ *
643
+ * @param item - The item to remove from the list.
644
+ */
645
+ delete(item: T): void;
646
+ }
647
+ /**
648
+ * @beta
649
+ * A list of items that can be read and updated.
650
+ */
651
+ export interface List<T> extends ReadableList<T>, MutableList<T> {}
652
+ /**
653
+ * @beta
654
+ * Represents an element that's not supported by the Apps SDK.
655
+ */
656
+ export interface Unsupported {
657
+ /**
658
+ * The type of element.
659
+ */
660
+ readonly type: "unsupported";
661
+ }
662
+ /**
663
+ * @beta
664
+ * A single valid character in a hex code.
665
+ */
666
+ export type Hex = `123456790abcdef`[number];
667
+ /**
668
+ * @beta
669
+ * A six-character hexadecimal color code prefixed with a `#`.
670
+ */
671
+ export type HexCode = `#${Hex}${Hex}${Hex}${Hex}${Hex}${Hex}`;
672
+ /**
673
+ * @beta
674
+ * A set of dimensions.
675
+ */
676
+ export interface Dimensions {
677
+ /**
678
+ * A width, in pixels.
679
+ */
680
+ readonly width: number;
681
+ /**
682
+ * A height, in pixels.
683
+ */
684
+ readonly height: number;
685
+ }
686
+ /**
687
+ * @beta
688
+ * An image that fills the interior of a path.
689
+ */
690
+ export interface ImageFill {
691
+ /**
692
+ * The type of media.
693
+ */
694
+ readonly type: "image";
695
+ /**
696
+ * A unique identifier that points to an image asset in Canva's backend.
697
+ */
698
+ imageRef: string;
699
+ /**
700
+ * If `true`, the image is flipped horizontally.
701
+ */
702
+ flipX: boolean;
703
+ /**
704
+ * If `true`, the image is flipped vertically.
705
+ */
706
+ flipY: boolean;
707
+ }
708
+ /**
709
+ * @beta
710
+ * A video that fills the interior of a path.
711
+ */
712
+ export interface VideoFill {
713
+ /**
714
+ * The type of media.
715
+ */
716
+ readonly type: "video";
717
+ /**
718
+ * A unique identifier that points to a video asset in Canva's backend.
719
+ */
720
+ videoRef: string;
721
+ /**
722
+ * If `true`, the video is flipped horizontally.
723
+ */
724
+ flipX: boolean;
725
+ /**
726
+ * If `true`, the video is flipped vertically.
727
+ */
728
+ flipY: boolean;
729
+ }
730
+ /**
731
+ * @beta
732
+ * A media item that fills the interior of a path.
733
+ */
734
+ export type MediaFill = ImageFill | VideoFill;
735
+ /**
736
+ * @beta
737
+ * A solid color that fills the interior of a path.
738
+ */
739
+ export interface SolidFill {
740
+ /**
741
+ * The type of color.
742
+ */
743
+ readonly type: "solid";
744
+ /**
745
+ * The color of the fill, as a hex code.
746
+ *
747
+ * @remarks
748
+ * - Must be six characters long.
749
+ * - Must start with a `#`.
750
+ * - Must use lowercase letters.
751
+ */
752
+ color: HexCode;
753
+ }
754
+ /**
755
+ * @beta
756
+ * A color that fills the interior of a path.
757
+ */
758
+ export type ColorFill = SolidFill | Unsupported;
759
+ /**
760
+ * @beta
761
+ * Describes how a path is filled with color or media.
762
+ *
763
+ * @remarks
764
+ * If both `media` and `color` are defined, `media` takes precedence.
765
+ */
766
+ export interface Fill {
767
+ /**
768
+ * The media fill for the path, if any.
769
+ */
770
+ media: MediaFill | undefined;
771
+ /**
772
+ * The color fill for the path, if any.
773
+ */
774
+ color: ColorFill | undefined;
775
+ }
776
+ /**
777
+ * @beta
778
+ * The scale and cropping of a shape.
779
+ *
780
+ * @remarks
781
+ * This is similar to the `viewBox` attribute of an `SVGElement`.
782
+ */
783
+ export type AlignedBox = {
784
+ /**
785
+ * The distance of the shape from the top edge of the element, in pixels.
786
+ */
787
+ readonly top: number;
788
+ /**
789
+ * The distance of the shape from the left edge of the element, in pixels.
790
+ */
791
+ readonly left: number;
792
+ /**
793
+ * The width of the view box, in pixels.
794
+ */
795
+ readonly width: number;
796
+ /**
797
+ * The height of the view box, in pixels.
798
+ */
799
+ readonly height: number;
800
+ };
801
+ /**
802
+ * @beta
803
+ * A path that defines the structure of a shape element.
804
+ */
805
+ export interface Path {
806
+ /**
807
+ * The shape of the path.
808
+ *
809
+ * @remarks
810
+ * This is similar to the `d` attribute of an SVG's `path` element, with some limitations:
811
+ *
812
+ * - Must start with an `M` command.
813
+ * - Only one `M` command is allowed.
814
+ * - `Q` and `T` commands are not permitted.
815
+ * - The path must be closed using a `Z` command or matching start and end coordinates.
816
+ */
817
+ readonly d: string;
818
+ /**
819
+ * The appearance of the path's interior.
820
+ */
821
+ readonly fill: Fill;
822
+ /**
823
+ * The stroke (outline) of the path, if any.
824
+ */
825
+ readonly stroke: Stroke | undefined;
826
+ }
827
+ /**
828
+ * @beta
829
+ * Represents an outline, such as the border of an element.
830
+ */
831
+ export interface Stroke {
832
+ /**
833
+ * The weight (thickness) of the stroke.
834
+ *
835
+ * @remarks
836
+ * - Minimum: 0
837
+ * - Maximum: 100
838
+ */
839
+ weight: number;
840
+ /**
841
+ * The color of the stroke.
842
+ */
843
+ color: ColorFill;
844
+ }
845
+ /**
846
+ * @beta
847
+ * The basic properties of an element.
848
+ *
849
+ * @remarks
850
+ * These properties are shared by all elements in a design.
851
+ */
852
+ export interface Element extends Dimensions {
853
+ /**
854
+ * If `true`, the element is locked and cannot be modified.
855
+ */
856
+ readonly locked: boolean;
857
+ /**
858
+ * The distance from the top edge of the container, in pixels.
859
+ *
860
+ * @remarks
861
+ * - The pixels are relative to their container.
862
+ * - Minimum: -32768
863
+ * - Maximum: 32767
864
+ */
865
+ top: number;
866
+ /**
867
+ * The distance from the left edge of the container, in pixels.
868
+ *
869
+ * @remarks
870
+ * - The pixels are relative to their container.
871
+ * - Minimum: -32768
872
+ * - Maximum: 32767
873
+ */
874
+ left: number;
875
+ /**
876
+ * A rotation, in degrees.
877
+ *
878
+ * @remarks
879
+ * - Minimum: -180
880
+ * - Maximum: 180
881
+ */
882
+ rotation: number;
883
+ /**
884
+ * Transparency as a percentage.
885
+ *
886
+ * @remarks
887
+ * - Minimum: 0
888
+ * - Maximum: 1
889
+ */
890
+ transparency: number;
891
+ }
892
+ /**
893
+ * @beta
894
+ * Represents a rectangular element.
895
+ */
896
+ export interface Rect {
897
+ /**
898
+ * The type of content.
899
+ */
900
+ readonly type: "rect";
901
+ /**
902
+ * The appearance of the rectangle's interior.
903
+ */
904
+ readonly fill: Fill;
905
+ /**
906
+ * The outline of the rectangle.
907
+ */
908
+ readonly stroke: Stroke;
909
+ }
910
+ /**
911
+ * @beta
912
+ * Represents a vector shape element.
913
+ */
914
+ export interface Shape {
915
+ /**
916
+ * The type of content.
917
+ */
918
+ readonly type: "shape";
919
+ /**
920
+ * The scale and cropping of the shape.
921
+ */
922
+ viewBox: AlignedBox;
923
+ /**
924
+ * The paths that define the structure of the shape.
925
+ *
926
+ * @remarks
927
+ * - Must have between 1 and 30 paths.
928
+ * - Total size of all paths must not exceed 2kb.
929
+ * - Maximum of 6 unique fill colors across all paths.
930
+ */
931
+ readonly paths: ReadableList<Path>;
932
+ }
933
+ /**
934
+ * @beta
935
+ * Represents group content.
936
+ */
937
+ export interface Group<C> {
938
+ /**
939
+ * The type of content.
940
+ */
941
+ readonly type: "group";
942
+ /**
943
+ * The elements that exist within the group.
944
+ */
945
+ readonly contents: ReadableList<C>;
946
+ }
947
+ /**
948
+ * @beta
949
+ * Represents rich media content.
950
+ */
951
+ export interface Embed {
952
+ /**
953
+ * The type of content.
954
+ */
955
+ readonly type: "embed";
956
+ /**
957
+ * The URL of the rich media.
958
+ *
959
+ * @remarks
960
+ * This URL must be supported by the Iframely API.
961
+ */
962
+ readonly url: string;
963
+ }
964
+ /**
965
+ * @beta
966
+ * Represents text content.
967
+ */
968
+ export interface Text {
969
+ /**
970
+ * The type of content.
971
+ */
972
+ readonly type: "text";
973
+ /**
974
+ * The text content.
975
+ */
976
+ readonly text: RichtextRange;
977
+ }
978
+ /**
979
+ * @beta
980
+ * An element that renders a rectangle.
981
+ *
982
+ * @remarks
983
+ * The rectangle can be filled with image content, video content, or a solid color.
984
+ */
985
+ export interface RectElement extends Rect, Element {}
986
+ /**
987
+ * @beta
988
+ * An element that renders a vector shape.
989
+ */
990
+ export interface ShapeElement extends Shape, Element {}
991
+ /**
992
+ * @beta
993
+ * An element that renders a group of other elements.
221
994
  */
222
- text?: NativeTextElement;
995
+ export interface GroupElement extends Group<GroupContentElement>, Element {}
223
996
  /**
224
- * The background of the table cell
997
+ * @beta
998
+ * An element that embeds rich media, such as a YouTube video.
225
999
  */
226
- fill?: Pick<Fill, "color">;
1000
+ export interface EmbedElement extends Embed, Element {}
227
1001
  /**
228
- * How many columns this cell occupies
1002
+ * @beta
1003
+ * An element that renders text content.
229
1004
  */
230
- colSpan?: number;
1005
+ export interface TextElement extends Text, Element {}
231
1006
  /**
232
- * How many rows this cell occupies
1007
+ * @beta
1008
+ * An element that is not supported by the Apps SDK.
233
1009
  */
234
- rowSpan?: number;
235
- };
236
-
237
- declare type CommonImageDragConfig = {
1010
+ export interface UnsupportedElement extends Unsupported, Element {}
238
1011
  /**
239
- * The type of element.
1012
+ * @beta
1013
+ * An element that can exist in a group element.
240
1014
  */
241
- type: "IMAGE";
1015
+ export type GroupContentElement =
1016
+ | RectElement
1017
+ | ShapeElement
1018
+ | EmbedElement
1019
+ | TextElement
1020
+ | UnsupportedElement;
242
1021
  /**
243
- * The dimensions of the preview image.
244
- *
245
- * @remarks
246
- * The preview image is the image that users see under their cursor while dragging
247
- * it into their design.
1022
+ * @beta
1023
+ * An element that can exist on a fixed page.
248
1024
  */
249
- previewSize: Dimensions;
250
- };
251
-
252
- /**
253
- * @public
254
- * A snapshot of some part of the document content.
255
- *
256
- * @remarks
257
- * You can mutate the values in the `contents` array and then persist those changes with the `save` method.
258
- */
259
- export declare interface ContentDraft<T> {
1025
+ export type FixedElement =
1026
+ | RectElement
1027
+ | ShapeElement
1028
+ | GroupElement
1029
+ | EmbedElement
1030
+ | TextElement
1031
+ | UnsupportedElement;
260
1032
  /**
261
- * The selected content.
1033
+ * @beta
1034
+ * A page with fixed dimensions.
262
1035
  */
263
- readonly contents: readonly T[];
1036
+ export interface FixedPage {
1037
+ /**
1038
+ * The type of page.
1039
+ */
1040
+ readonly type: "fixed";
1041
+ /**
1042
+ * If `true`, the page is locked and cannot be modified.
1043
+ */
1044
+ readonly locked: boolean;
1045
+ /**
1046
+ * The dimensions of the page. `dimensions` is undefined for whiteboard pages.
1047
+ */
1048
+ readonly dimensions: Dimensions | undefined;
1049
+ /**
1050
+ * The background of the page. `background` is undefined for whiteboard pages.
1051
+ */
1052
+ readonly background: Fill | undefined;
1053
+ /**
1054
+ * The elements on the page.
1055
+ *
1056
+ * @remarks
1057
+ * Elements are rendered in the order they appear in the list.
1058
+ * Later elements appear on top of earlier ones.
1059
+ */
1060
+ readonly elements: List<FixedElement>;
1061
+ }
264
1062
  /**
265
- * Saves changes made to items in the `contents` array.
266
- * Once saved, those changes are reflected in the user's design.
267
- *
268
- * @remarks
269
- * Any other changes to the content since calling the `read` method, such as the user editing the content directly, will be overwritten.
270
- * Only properties that are different from the original state are written to the design.
1063
+ * @beta
1064
+ * A page in a design.
271
1065
  */
272
- save(): Promise<void>;
1066
+ export type Page = FixedPage | Unsupported;
1067
+
1068
+ {
1069
+ }
273
1070
  }
274
1071
 
275
1072
  /**
276
- * @beta
277
- * A type of content that can be read from a user's design.
1073
+ * @public
1074
+ * An element that's natively supported by the Canva editor.
278
1075
  */
279
- export declare type ContentType = "richtext";
1076
+ export declare type DesignElement = NativeElement;
280
1077
 
281
1078
  /**
282
1079
  * @beta
283
- * Options for configuring where content in a design should be queried from.
284
- */
285
- declare type ContextOptions = {
286
- context: "current_page";
287
- };
288
-
289
- /**
290
- * @public
291
- * Represents X and Y coordinates.
1080
+ * A callback for reading and updating part of a design.
1081
+ * @param draft - The result of reading part of a design.
1082
+ * @param helpers - Helper methods for reading and updating the design.
292
1083
  */
293
- export declare type Coordinates = {
294
- /**
295
- * Represents an X coordinate, in pixels.
296
- */
297
- x: number;
298
- /**
299
- * Represents a Y coordinate, in pixels.
300
- */
301
- y: number;
302
- };
1084
+ export declare type DesignOpenCallback = (
1085
+ draft: DesignEditing.DesignOpenResult,
1086
+ helpers: {
1087
+ /**
1088
+ * Provides methods for creating elements.
1089
+ */
1090
+ elementBuilder: DesignEditing.ElementBuilder;
1091
+ }
1092
+ ) => Promise<void> | void;
303
1093
 
304
1094
  /**
305
1095
  * @beta
306
- * Creates a new RichtextRange object, which contains methods to manipulate text.
1096
+ * Options for configuring which part of a design to read.
307
1097
  */
308
- export declare function createRichtextRange(): RichtextRange;
1098
+ export declare type DesignOpenOptions = DesignContextOptions;
309
1099
 
310
1100
  /**
311
1101
  * @public
312
- * Provides methods for interacting with design overlay
1102
+ * Provides methods for managing the lifecycle of overlays, such as selected image overlays.
313
1103
  */
314
1104
  export declare type DesignOverlay = {
315
1105
  /**
316
- * Registers a callback that runs when an overlay canOpen status changed on a particular target.
317
- *
318
- * @remarks
319
- * The callback fires immediately
1106
+ * Registers a callback that runs when the `canOpen` state of an overlay target changes.
1107
+ * @param opts - Options for configuring the callback.
320
1108
  */
321
1109
  registerOnCanOpen<Target extends OverlayTarget>(opts: {
1110
+ /**
1111
+ * The target to check the `canOpen` state of.
1112
+ */
322
1113
  target: Target;
1114
+ /**
1115
+ * A callback that runs when the `canOpen` state of the specified target changes.
1116
+ *
1117
+ * @param event - Information about whether or not an overlay can be opened for the specified target.
1118
+ *
1119
+ * @remarks
1120
+ * This callback fires immediately.
1121
+ */
323
1122
  onCanOpen(event: OverlayOpenableEvent<Target>): void;
324
1123
  }): () => void;
325
1124
  };
326
1125
 
327
1126
  /**
328
- * @beta
329
- * Provides methods for interacting with the user's selected content, such as images or text.
1127
+ * @public
1128
+ * Provides methods for interacting with selected content.
330
1129
  */
331
1130
  export declare type DesignSelection = {
332
1131
  /**
333
- * Registers a callback that runs when a user selects an element that contains the specified type of content.
1132
+ * Registers a callback that runs when the specified type of content is selected.
1133
+ *
1134
+ * @param opts - Options for configuring the content selection callback.
334
1135
  *
335
1136
  * @remarks
336
- * The callback fires immediately if content is already selected.
1137
+ * This callback fires immediately if content is already selected when the callback is registered.
337
1138
  */
338
1139
  registerOnChange<Scope extends SelectionScope>(opts: {
339
1140
  /**
340
- * The type of content that, when selected, triggers the `onChange` callback.
1141
+ * The type of content that triggers a selection change event.
341
1142
  */
342
1143
  scope: Scope;
343
1144
  /**
344
- * The callback to run when the selection changes.
1145
+ * The callback to run when the selected content changes.
1146
+ * @param event - Information about the selection change event.
345
1147
  */
346
1148
  onChange(event: SelectionEvent<Scope>): void;
347
1149
  }): () => void;
@@ -357,47 +1159,45 @@ export declare type DesignToken = {
357
1159
 
358
1160
  /**
359
1161
  * @public
360
- * Represents a width and a height.
1162
+ * A set of dimensions.
361
1163
  */
362
1164
  export declare type Dimensions = {
363
1165
  /**
364
- * Represents a width, in pixels.
1166
+ * A width, in pixels.
365
1167
  */
366
1168
  width: number;
367
1169
  /**
368
- * Represents a height, in pixels.
1170
+ * A height, in pixels.
369
1171
  */
370
1172
  height: number;
371
1173
  };
372
1174
 
373
1175
  /**
374
1176
  * @public
375
- * Callbacks that run during the lifecycle of a drag-and-drop.
1177
+ * Callbacks for handling drag and drop events.
376
1178
  */
377
1179
  export declare type DragCallback = {
378
1180
  /**
379
- * A callback that runs when the user starts dragging an element into their design.
380
- *
381
- * @param element - The element being dragged into the user's design.
1181
+ * A callback that runs at the start of a drag event.
1182
+ * @param element - The element being dragged.
382
1183
  */
383
1184
  onDragStart: (element: HTMLElement) => void;
384
1185
  /**
385
- * A callback that runs when the user finishes dragging an element into their design.
386
- *
387
- * @param element - The element being dragged into the user's design.
1186
+ * A callback that runs at the end of a drag event.
1187
+ * @param element - The element being dragged.
388
1188
  */
389
1189
  onDragEnd: (element: HTMLElement) => void;
390
1190
  };
391
1191
 
392
1192
  /**
393
1193
  * @public
394
- * Options for making an element draggable.
1194
+ * Options for adding drag and drop behavior to an `HTMLElement`.
395
1195
  */
396
1196
  export declare type DraggableElementData = ElementData | ImageElementData;
397
1197
 
398
1198
  /**
399
1199
  * @public
400
- * Represents a drag start event that occurs when initiating a drag-and-drop behavior inside the app.
1200
+ * An event that occurs when a user starts dragging an HTML element.
401
1201
  */
402
1202
  export declare type DragStartEvent<E extends Element> = Pick<
403
1203
  DragEvent,
@@ -416,61 +1216,81 @@ export declare type EditContentOptions<T extends ContentType> = {
416
1216
 
417
1217
  /**
418
1218
  * @public
419
- * Options for making an `HTMLElement` draggable.
1219
+ * Elements targeting a cursor are a subset of the base Element
1220
+ **/
1221
+ export declare type ElementAtCursor =
1222
+ | ImageElement
1223
+ | VideoElement
1224
+ | EmbedElement
1225
+ | TextElement
1226
+ | RichtextElement;
1227
+
1228
+ /**
1229
+ * @public
1230
+ * An element that's natively supported by the Canva editor and has positional properties.
1231
+ */
1232
+ export declare type ElementAtPoint =
1233
+ | NativeElementWithBox
1234
+ | RichtextElementAtPoint;
1235
+
1236
+ /**
1237
+ * @public
1238
+ * Options for adding drag and drop behavior to an `HTMLElement`.
420
1239
  */
421
1240
  export declare type ElementData = DragCallback & {
422
1241
  /**
423
- * The element to be made draggable.
1242
+ * The `HTMLElement` to be made draggable.
424
1243
  */
425
1244
  node: HTMLElement;
426
- /**
427
- * Options for defining the drag-and-drop behavior.
428
- *
429
- * @remarks
430
- * This data is required because it can't be inferred from the `node` property.
431
- */
432
- dragData: UserSuppliedDragData;
433
1245
  };
434
1246
 
435
1247
  /**
436
1248
  * @public
437
- *
438
- * Options for defining the drag-and-drop behaviour for embeds.
1249
+ * Embed element to be added to the design at the end of a drag event.
439
1250
  */
440
1251
  export declare type EmbedDragConfig = {
441
1252
  /**
442
1253
  * The type of element.
443
1254
  */
444
- type: "EMBED";
1255
+ type: "embed";
445
1256
  /**
446
1257
  * The dimensions of the preview image.
447
- * The preview image is the image that users see under their cursor
448
- * while dragging it into their design.
449
1258
  */
450
1259
  previewSize: Dimensions;
451
1260
  /**
452
- * Represents the preview image of the embed.
1261
+ * The URL of an image to display under the user's cursor during the drag and drop event.
453
1262
  */
454
1263
  previewUrl: string;
455
1264
  /**
456
- * Represents the embed source url.
1265
+ * The URL of media that can be embedded, such as the URL of a YouTube video.
1266
+ *
1267
+ * @remarks
1268
+ * This URL must be supported by the Iframely API.
457
1269
  */
458
1270
  embedUrl: string;
459
1271
  };
460
1272
 
461
1273
  /**
462
1274
  * @public
463
- * Export aborted response
464
- *
465
- * @remarks
466
- * Ane export flow is considered aborted when a user closes
467
- * the export options menu.
1275
+ * An element that renders rich media, such as a YouTube video.
1276
+ */
1277
+ export declare type EmbedElement = NativeEmbedElement;
1278
+
1279
+ /**
1280
+ * @public
1281
+ * An element that renders rich media, such as a YouTube video, and has positional properties.
1282
+ */
1283
+ export declare type EmbedElementAtPoint = NativeEmbedElementWithBox;
1284
+
1285
+ /**
1286
+ * @public
1287
+ * The result when a user abandons the export flow, such as by closing the export menu.
468
1288
  */
469
1289
  export declare type ExportAborted = {
470
1290
  /**
471
- * The status of the export flow when the user has aborted the export menu.
1291
+ * The status of the export flow.
472
1292
  */
473
- status: "ABORTED";
1293
+ status: "aborted";
474
1294
  };
475
1295
 
476
1296
  /**
@@ -482,13 +1302,14 @@ export declare type ExportBlob = {
482
1302
  * The URL of the exported design.
483
1303
  *
484
1304
  * @remarks
485
- * If the user's design contains multiple pages but is exported in a format that doesn't support multiple pages, the URL will point to a ZIP file that contains each page as a separate file.
1305
+ * If a user's design contains multiple pages but is exported in a format that doesn't support multiple pages,
1306
+ * this URL will point to a ZIP file that contains each page as a separate file.
486
1307
  *
487
1308
  * For example:
488
1309
  *
489
- * - If a single-page design is exported as a JPG, the URL will point to a JPG file
490
- * - If a multi-page design is exported as a JPG, the URL will point to a ZIP file that contains a separate JPG file for each page
491
- * - If a multi-page design is exported as a PDF, the URL will point to a PDF file that contains all of the pages
1310
+ * - If a single-page design is exported as a JPG, the URL will point to a JPG file.
1311
+ * - If a multi-page design is exported as a JPG, the URL will point to a ZIP file that contains a JPG file for each page.
1312
+ * - If a multi-page design is exported as a PDF file, the URL will point to a PDF file.
492
1313
  *
493
1314
  * The following file types support multiple pages:
494
1315
  *
@@ -508,22 +1329,23 @@ export declare type ExportBlob = {
508
1329
 
509
1330
  /**
510
1331
  * @public
511
- * Export completed response
1332
+ * The result when a user successfully completes an export flow.
512
1333
  */
513
1334
  export declare type ExportCompleted = {
514
1335
  /**
515
- * The status of the export flow when the user has submitted the export menu.
1336
+ * The status of the export flow.
516
1337
  */
517
- status: "COMPLETED";
1338
+ status: "completed";
518
1339
  /**
519
- * The title of the successful export of a design, if it has been set by the user.
1340
+ * The title of the design, if set by the user.
520
1341
  */
521
1342
  title?: string;
522
1343
  /**
523
1344
  * The exported files.
524
1345
  *
525
1346
  * @remarks
526
- * This array only contains one element. This is because, if a multi-page design is exported as multiple files, the files are exported in a ZIP file. In the future, there'll be an option for each file to be a separate element in the array.
1347
+ * This array only contains one element. This is because, if a multi-page design is exported as multiple files, the files
1348
+ * are exported in a ZIP file. In the future, there'll be an option for each file to be a separate element in the array.
527
1349
  */
528
1350
  exportBlobs: ExportBlob[];
529
1351
  };
@@ -533,17 +1355,17 @@ export declare type ExportCompleted = {
533
1355
  * The types of files that Canva supports for exported designs.
534
1356
  */
535
1357
  export declare type ExportFileType =
536
- | "PNG"
537
- | "JPG"
538
- | "PDF_STANDARD"
539
- | "VIDEO"
540
- | "GIF"
541
- | "PPTX"
542
- | "SVG";
1358
+ | "png"
1359
+ | "jpg"
1360
+ | "pdf_standard"
1361
+ | "video"
1362
+ | "gif"
1363
+ | "pptx"
1364
+ | "svg";
543
1365
 
544
1366
  /**
545
1367
  * @public
546
- * The options for configuring the export of a design.
1368
+ * Options for configuring the export of a design.
547
1369
  */
548
1370
  export declare type ExportRequest = {
549
1371
  /**
@@ -557,44 +1379,30 @@ export declare type ExportRequest = {
557
1379
 
558
1380
  /**
559
1381
  * @public
560
- * The response of an export request.
1382
+ * The result of exporting a design.
561
1383
  */
562
1384
  export declare type ExportResponse = ExportCompleted | ExportAborted;
563
1385
 
564
1386
  /**
565
1387
  * @public
1388
+ * Image element or content to be added to the design at the end of a drag event.
566
1389
  *
567
- * Options for defining the Drag and Drop behaviour for images uploaded
568
- * via the Content capability.
1390
+ * @remarks
1391
+ * This type is only used when the image data is from an external URL.
569
1392
  */
570
1393
  export declare type ExternalImageDragConfig = CommonImageDragConfig & {
571
1394
  /**
572
- * The function that resolves an image ref
573
- * @remarks
574
- *
575
- * This function will be run during the drag process in order to fetch the media ref of the
576
- * external image being fetched. This function should return the result of `upload`
577
- * from the content capability.
1395
+ * A function that returns a reference (ref) to an audio asset in Canva's backend.
578
1396
  */
579
1397
  resolveImageRef: () => Promise<{
580
1398
  ref: ImageRef;
581
1399
  }>;
582
1400
  /**
583
- * The URL of the preview image.
584
- *
585
- * @remarks
586
- * The preview image is the image that users see under their cursor while dragging
587
- * it into their design.
1401
+ * The URL of an image to display under the user's cursor during the drag and drop event.
588
1402
  */
589
1403
  previewUrl: string;
590
1404
  /**
591
1405
  * The dimensions of the full-size image.
592
- *
593
- * @remarks
594
- * The full-size image is the image that Canva uploads to the user's account and
595
- * adds to their design.
596
- *
597
- * If omitted, the value of the `previewSize` property is used as a fallback.
598
1406
  */
599
1407
  fullSize?: Dimensions;
600
1408
  };
@@ -602,26 +1410,27 @@ export declare type ExternalImageDragConfig = CommonImageDragConfig & {
602
1410
  /**
603
1411
  * @public
604
1412
  * The appearance of a path's interior.
1413
+ *
1414
+ * @remarks
1415
+ * The `color` and `asset` properties are mutually exclusive.
605
1416
  */
606
1417
  export declare type Fill = {
607
1418
  /**
608
- * Boolean defining whether image or video can be dropped on the fill by the user.
609
- * If set to true, images or videos can be dropped on the fill.
1419
+ * If `true`, users can replace a fill by dropping an image or video onto it.
610
1420
  */
611
1421
  dropTarget?: boolean;
612
1422
  /**
613
1423
  * The color of the fill as a hex code.
614
1424
  *
615
1425
  * @remarks
616
- * The hex code must include all six characters and be prefixed with a # symbol (e.g. #ff0099).
617
- * Only one type of fill (color, image or video) can be set.
1426
+ * The hex code must include all six characters and be prefixed with a `#` symbol.
1427
+ *
1428
+ * @example
1429
+ * " #ff0099"
618
1430
  */
619
1431
  color?: string;
620
1432
  /**
621
- * An asset (image or video) that will be used to fill the given path.
622
- *
623
- * @remarks
624
- * Only one type of fill (color, image or video) can be set.
1433
+ * An image or video to use as the fill.
625
1434
  */
626
1435
  asset?: ImageFill | VideoFill;
627
1436
  };
@@ -654,7 +1463,7 @@ export declare type FontWeight =
654
1463
  * @public
655
1464
  * @returns Page context of currently selected page
656
1465
  */
657
- export declare function getCurrentPageContext(): Promise<PageContext>;
1466
+ export declare const getCurrentPageContext: () => Promise<PageContext>;
658
1467
 
659
1468
  /**
660
1469
  * @public
@@ -665,7 +1474,7 @@ export declare function getCurrentPageContext(): Promise<PageContext>;
665
1474
  *
666
1475
  * Returns `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
667
1476
  */
668
- export declare function getDefaultPageDimensions(): Promise<
1477
+ export declare const getDefaultPageDimensions: () => Promise<
669
1478
  Dimensions | undefined
670
1479
  >;
671
1480
 
@@ -675,21 +1484,52 @@ export declare function getDefaultPageDimensions(): Promise<
675
1484
  */
676
1485
  export declare function getDesignToken(): Promise<DesignToken>;
677
1486
 
1487
+ /**
1488
+ * @public
1489
+ * An element that's natively supported by the Canva editor, can exist within a group, and has positional properties.
1490
+ */
1491
+ export declare type GroupContentAtPoint = NativeSimpleElementWithBox;
1492
+
1493
+ /**
1494
+ * @public
1495
+ * An element that contains two or more elements.
1496
+ */
1497
+ export declare type GroupElement = NativeGroupElement;
1498
+
1499
+ /**
1500
+ * @public
1501
+ * An element that contains two or more elements and has positional properties.
1502
+ */
1503
+ export declare type GroupElementAtPoint = NativeGroupElementWithBox;
1504
+
1505
+ /**
1506
+ * A set of dimensions with an auto-calculated width.
1507
+ */
678
1508
  declare type Height = {
1509
+ /**
1510
+ * Indicates that the width should be auto-calculated.
1511
+ */
679
1512
  width: "auto";
1513
+ /**
1514
+ * A height, in pixels.
1515
+ *
1516
+ * @remarks
1517
+ * - The pixels are relative to their container.
1518
+ * - Minimum: 0
1519
+ * - Maximum: 32767
1520
+ */
680
1521
  height: number;
681
1522
  };
682
1523
 
683
1524
  /**
684
1525
  * @public
685
- * Options for defining the drag-and-drop behavior of an image element that can be defined by an
686
- * app developer.
1526
+ * Image element or content to be added to the design at the end of a drag event.
687
1527
  */
688
1528
  export declare type ImageDragConfig = ExternalImageDragConfig;
689
1529
 
690
1530
  /**
691
1531
  * @public
692
- * Options for defining the drag-and-drop behavior for images.
1532
+ * Image element or content to be added to the design at the end of a drag event.
693
1533
  */
694
1534
  export declare type ImageDragConfigForElement<E extends Element> =
695
1535
  E extends HTMLImageElement
@@ -698,36 +1538,38 @@ export declare type ImageDragConfigForElement<E extends Element> =
698
1538
 
699
1539
  /**
700
1540
  * @public
701
- * Options for making an `HTMLImageElement` draggable.
1541
+ * An element that renders image content.
1542
+ */
1543
+ export declare type ImageElement = NativeImageElement;
1544
+
1545
+ /**
1546
+ * @public
1547
+ * An element that renders image content and has positional properties.
1548
+ */
1549
+ export declare type ImageElementAtPoint = NativeImageElementWithBox;
1550
+
1551
+ /**
1552
+ * @public
1553
+ * Options for adding drag and drop behavior to an `HTMLImageElement`.
702
1554
  */
703
1555
  export declare type ImageElementData = DragCallback & {
704
1556
  /**
705
- * The element to be made draggable.
1557
+ * The `HTMLImageElement` to be made draggable.
706
1558
  */
707
1559
  node: HTMLImageElement;
708
- /**
709
- * Options for defining the drag-and-drop behavior.
710
- *
711
- * @remarks
712
- * If any of this data is omitted, it's inferred from the `node` property.
713
- */
714
- dragData?:
715
- | Partial<UserSuppliedImageDragData>
716
- | (Partial<UserSuppliedVideoDragData> &
717
- Pick<UserSuppliedVideoDragData, "type" | "resolveVideoRef">);
718
1560
  };
719
1561
 
720
1562
  /**
721
1563
  * @public
722
- * An image asset that will be used to fill the given path.
1564
+ * An image asset that fills a path's interior.
723
1565
  */
724
1566
  export declare type ImageFill = {
725
1567
  /**
726
- * Type of an asset that will be used to fill the given path.
1568
+ * The type of fill.
727
1569
  */
728
- type: "IMAGE";
1570
+ type: "image";
729
1571
  /**
730
- * A unique identifier that references an image asset in Canva's backend.
1572
+ * A unique identifier that points to an image asset in Canva's backend.
731
1573
  */
732
1574
  ref: ImageRef;
733
1575
  };
@@ -749,17 +1591,18 @@ export declare function initAppElement<A extends AppElementData>(
749
1591
  ): AppElementClient<A>;
750
1592
 
751
1593
  /**
752
- * @beta
753
- *
754
- * Inline formatting values for richtext
1594
+ * @public
1595
+ * Options for formatting inline richtext.
755
1596
  */
756
1597
  export declare type InlineFormatting = {
757
1598
  /**
758
1599
  * The color of the text as a hex code.
759
1600
  *
760
1601
  * @remarks
761
- * The hex code must include all six characters and be prefixed with a # symbol
762
- * (e.g. #ff0099). The default value is #000000.
1602
+ * The hex code must include all six characters and be prefixed with a `#` symbol.
1603
+ *
1604
+ * @example
1605
+ * "#ff0099"
763
1606
  */
764
1607
  color?: string;
765
1608
  /**
@@ -768,33 +1611,34 @@ export declare type InlineFormatting = {
768
1611
  * @remarks
769
1612
  * The available font weights depend on the font.
770
1613
  *
771
- * @defaultValue 'normal'
1614
+ * @defaultValue "normal"
772
1615
  */
773
1616
  fontWeight?: FontWeight;
774
1617
  /**
775
1618
  * The style of the font.
776
- * @defaultValue 'normal'
1619
+ * @defaultValue "normal"
777
1620
  */
778
1621
  fontStyle?: "normal" | "italic";
779
1622
  /**
780
1623
  * The decoration of the text.
781
- * @defaultValue 'none'
1624
+ * @defaultValue "none"
782
1625
  */
783
1626
  decoration?: "none" | "underline";
784
1627
  /**
785
1628
  * The strikethrough of the text.
786
- * @defaultValue 'none'
1629
+ * @defaultValue "none"
787
1630
  */
788
1631
  strikethrough?: "none" | "strikethrough";
789
1632
  /**
790
- * A url that the underlying text will link to
1633
+ * An external URL that the text links to.
791
1634
  */
792
1635
  link?: string;
793
1636
  };
794
1637
 
795
1638
  /**
1639
+ * @deprecated
796
1640
  * @public
797
- * A native element.
1641
+ * An element that's natively supported by the Canva editor.
798
1642
  */
799
1643
  export declare type NativeElement =
800
1644
  | NativeImageElement
@@ -809,15 +1653,16 @@ export declare type NativeElement =
809
1653
  * The types of elements an app can add to a user's design.
810
1654
  */
811
1655
  export declare type NativeElementType =
812
- | "IMAGE"
813
- | "EMBED"
814
- | "TEXT"
815
- | "SHAPE"
816
- | "VIDEO";
1656
+ | "image"
1657
+ | "embed"
1658
+ | "text"
1659
+ | "shape"
1660
+ | "video";
817
1661
 
818
1662
  /**
1663
+ * @deprecated The type has been superseded by `ElementAtPoint`.
819
1664
  * @public
820
- * An element that exists within an app or group element.
1665
+ * An element that's natively supported by the Canva editor and has positional properties.
821
1666
  */
822
1667
  export declare type NativeElementWithBox =
823
1668
  | NativeImageElementWithBox
@@ -828,37 +1673,36 @@ export declare type NativeElementWithBox =
828
1673
  | NativeGroupElementWithBox;
829
1674
 
830
1675
  /**
1676
+ * @deprecated The type has been superseded by `EmbedElement`.
831
1677
  * @public
832
- * An element that renders an embeddable piece of media, such as a YouTube video.
1678
+ * An element that renders rich media, such as a YouTube video.
833
1679
  */
834
1680
  export declare type NativeEmbedElement = {
835
1681
  /**
836
1682
  * The type of element.
837
1683
  */
838
- type: "EMBED";
1684
+ type: "embed";
839
1685
  /**
840
- * The URL of the embed. This URL must be supported by the Iframely API.
1686
+ * The URL of the rich media.
1687
+ *
1688
+ * @remarks
1689
+ * This URL must be supported by the Iframely API.
841
1690
  */
842
1691
  url: string;
843
1692
  };
844
1693
 
845
1694
  /**
1695
+ * @deprecated The type has been superseded by `EmbedElementAtPoint`.
846
1696
  * @public
847
- * An element that renders an embeddable piece of media, such as a YouTube video.
848
- *
849
- * @remarks
850
- * This type includes properties for controlling the position and dimensions of the
851
- * element.
852
- * It will be positioned and sized relative to its parent container.
853
- * The parent container may be an app element, or the current page.
1697
+ * An element that renders rich media, such as a YouTube video, and has positional properties.
854
1698
  */
855
1699
  export declare type NativeEmbedElementWithBox = {
856
1700
  /**
857
1701
  * The type of element.
858
1702
  */
859
- type: "EMBED";
1703
+ type: "embed";
860
1704
  /**
861
- * The URL of the embed.
1705
+ * The URL of the rich media.
862
1706
  *
863
1707
  * @remarks
864
1708
  * This URL must be supported by the Iframely API.
@@ -867,54 +1711,59 @@ export declare type NativeEmbedElementWithBox = {
867
1711
  } & Box;
868
1712
 
869
1713
  /**
1714
+ * @deprecated The type has been superseded by `GroupElement`.
870
1715
  * @public
871
- * An element containing two or more {@link NativeElementWithBox}.
1716
+ * An element that contains two or more elements.
872
1717
  */
873
1718
  export declare type NativeGroupElement = {
874
1719
  /**
875
1720
  * The type of element.
876
1721
  */
877
- type: "GROUP";
1722
+ type: "group";
878
1723
  /**
879
- * The inner elements contained by the group element. These elements require a Box as they are
880
- * relatively positioned to the outer boundaries of the group element.
1724
+ * The elements to render within the group.
1725
+ *
1726
+ * @remarks
1727
+ * - Each element within a group must have dimensions and a position.
1728
+ * - The dimensions and positions are relative to the dimensions and positions of the group.
881
1729
  */
882
1730
  children: NativeSimpleElementWithBox[];
883
1731
  };
884
1732
 
885
1733
  /**
1734
+ * @deprecated The type has been superseded by `GroupElementAtPoint`.
886
1735
  * @public
887
- * An element containing two or more {@link NativeSimpleElementWithBox}.
888
- *
889
- * @remarks
890
- * This type includes properties for controlling the position and dimensions
891
- * of the element
1736
+ * An element that contains two or more elements and has positional properties.
892
1737
  */
893
1738
  export declare type NativeGroupElementWithBox = {
894
1739
  /**
895
1740
  * The type of element.
896
1741
  */
897
- type: "GROUP";
1742
+ type: "group";
898
1743
  /**
899
- * The inner elements contained by the group element. These elements require a Box as they are
900
- * relatively positioned to the outer boundaries of the group element.
1744
+ * The elements to render within the group.
1745
+ *
1746
+ * @remarks
1747
+ * - Each element within a group must have dimensions and a position.
1748
+ * - The dimensions and positions are relative to the dimensions and positions of the group.
901
1749
  */
902
1750
  children: NativeSimpleElementWithBox[];
903
1751
  } & Box;
904
1752
 
905
1753
  /**
1754
+ * @deprecated The type has been superseded by `ImageElement`.
906
1755
  * @public
907
- * An element that renders an image in the user's design.
1756
+ * An element that renders image content.
908
1757
  */
909
1758
  export declare type NativeImageElement = {
910
1759
  /**
911
1760
  * The type of element.
912
1761
  */
913
- type: "IMAGE";
1762
+ type: "image";
914
1763
  /**
915
- * An optional object to describe alt-text that may be applied to an image.
1764
+ * A description of the image content.
916
1765
  */
917
- altText?: AltText;
1766
+ altText: AltText | undefined;
918
1767
  } & (
919
1768
  | {
920
1769
  /**
@@ -922,7 +1771,7 @@ export declare type NativeImageElement = {
922
1771
  */
923
1772
  dataUrl: string;
924
1773
  /**
925
- * A unique identifier that references an image asset in Canva's backend.
1774
+ * A unique identifier that points to an image asset in Canva's backend.
926
1775
  */
927
1776
  ref?: never;
928
1777
  }
@@ -932,53 +1781,21 @@ export declare type NativeImageElement = {
932
1781
  */
933
1782
  dataUrl?: never;
934
1783
  /**
935
- * A unique identifier that references an image asset in Canva's backend.
1784
+ * A unique identifier that points to an image asset in Canva's backend.
936
1785
  */
937
1786
  ref: ImageRef;
938
1787
  }
939
1788
  );
940
1789
 
941
1790
  /**
1791
+ * @deprecated The type has been superseded by `ImageElementAtPoint`.
942
1792
  * @public
943
- * An element that renders an image in the user's design.
944
- *
945
- * @remarks
946
- * This type includes properties for controlling the position and dimensions
947
- * of the element.
948
- * It will be positioned and sized relative to its parent container.
949
- * The parent container may be an app element, or the current page.
1793
+ * An element that renders image content and has positional properties.
950
1794
  */
951
1795
  export declare type NativeImageElementWithBox = NativeImageElement & Box;
952
1796
 
953
1797
  /**
954
- * @beta
955
- * An element that renders richtext.
956
- */
957
- export declare type NativeRichtextElement = {
958
- /**
959
- * The type of element.
960
- */
961
- type: "RICHTEXT";
962
- /**
963
- * An object containing rich text which exposes methods to manipulate the text.
964
- */
965
- range: RichtextRange;
966
- };
967
-
968
- /**
969
- * @beta
970
- * An element that renders richtext.
971
- *
972
- * @remarks
973
- * This type includes properties for controlling the position and dimensions of the
974
- * element.
975
- * It will be positioned and sized relative to its parent container.
976
- * The parent container may be an app element, or the current page.
977
- */
978
- export declare type NativeRichtextElementWithBox = NativeRichtextElement &
979
- TextBox;
980
-
981
- /**
1798
+ * @deprecated The type has been superseded by `ShapeElement`.
982
1799
  * @public
983
1800
  * An element that renders a vector shape.
984
1801
  */
@@ -986,55 +1803,51 @@ export declare type NativeShapeElement = {
986
1803
  /**
987
1804
  * The type of element.
988
1805
  */
989
- type: "SHAPE";
1806
+ type: "shape";
990
1807
  /**
991
- * Properties for configuring the scale and cropping of a shape.
992
- *
993
- * @remarks
994
- * This is similar to the `viewBox` attribute of the <svg> element.
1808
+ * Options for configuring the scale and cropping of the shape.
995
1809
  */
996
1810
  viewBox: ShapeViewBox;
997
1811
  /**
998
- * The paths that define the shape of the element.
1812
+ * The paths that define the structure of the shape.
999
1813
  *
1000
1814
  * @remarks
1001
- * There must be between 1 and 30 paths. The maximum combined size of all paths must
1002
- * not exceed 2kb. The maximum numbrer of unique fill colors across all paths is 6.
1815
+ * - There must be between 1 and 30 paths (inclusive).
1816
+ * - The maximum combined size of all paths must not exceed 2kb.
1817
+ * - The maximum number of unique fill colors across all paths is 6.
1003
1818
  */
1004
1819
  paths: ShapePath[];
1005
1820
  };
1006
1821
 
1007
1822
  /**
1823
+ * @deprecated The type has been superseded by `ShapeElementAtPoint`.
1008
1824
  * @public
1009
- * An element that renders a vector shape.
1010
- *
1011
- * @remarks
1012
- * This type includes properties for controlling the position and dimensions of the
1013
- * element.
1014
- * It will be positioned and sized relative to its parent container.
1015
- * The parent container may be an app element, or the current page.
1825
+ * An element that renders a vector shape and has positional properties.
1016
1826
  */
1017
1827
  export declare type NativeShapeElementWithBox = {
1018
1828
  /**
1019
1829
  * The type of element.
1020
1830
  */
1021
- type: "SHAPE";
1831
+ type: "shape";
1022
1832
  /**
1023
- * Properties for configuring the scale and cropping of a shape.
1024
- *
1025
- * @remarks
1026
- * This is similar to the `viewBox` attribute of the <svg> element.
1833
+ * Options for configuring the scale and cropping of a shape.
1027
1834
  */
1028
1835
  viewBox: ShapeViewBox;
1029
1836
  /**
1030
- * The paths that define the shape of the element.
1837
+ * The paths that define the structure of the shape.
1838
+ *
1839
+ * @remarks
1840
+ * - There must be between 1 and 30 paths (inclusive).
1841
+ * - The maximum combined size of all paths must not exceed 2kb.
1842
+ * - The maximum number of unique fill colors across all paths is 6.
1031
1843
  */
1032
1844
  paths: ShapePath[];
1033
1845
  } & Box;
1034
1846
 
1035
1847
  /**
1848
+ * @deprecated The type has been superseded by `GroupContentAtPoint`.
1036
1849
  * @public
1037
- * An element that exists within a group element.
1850
+ * An element that's natively supported by the Canva editor, can exist within a group, and has positional properties.
1038
1851
  */
1039
1852
  export declare type NativeSimpleElementWithBox = Exclude<
1040
1853
  NativeElementWithBox,
@@ -1042,126 +1855,124 @@ export declare type NativeSimpleElementWithBox = Exclude<
1042
1855
  >;
1043
1856
 
1044
1857
  /**
1045
- * @beta
1046
- * An element that renders a table.
1047
- */
1048
- export declare type NativeTableElement = {
1049
- /**
1050
- * The type of element.
1051
- */
1052
- type: "TABLE";
1053
- /**
1054
- * The rows of the table. Each row contains an array of cells, 1 cell per column in the row.
1055
- */
1056
- rows: {
1057
- cells: Cell[];
1058
- }[];
1059
- };
1060
-
1061
- /**
1858
+ * @deprecated The type has been superseded by `TextElement`.
1062
1859
  * @public
1063
- * An element that renders text.
1860
+ * An element that renders text content.
1064
1861
  */
1065
1862
  export declare type NativeTextElement = {
1066
1863
  /**
1067
1864
  * The type of element.
1068
1865
  */
1069
- type: "TEXT";
1866
+ type: "text";
1070
1867
  /**
1071
- * The text to render within the element. In the future, each item in this
1072
- * array will map to a paragraph. At the moment, only one item is supported.
1868
+ * The text content.
1869
+ *
1870
+ * @remarks
1871
+ * Only the first element in this array is used.
1073
1872
  */
1074
1873
  children: string[];
1075
1874
  } & TextAttributes;
1076
1875
 
1077
1876
  /**
1877
+ * @deprecated The type has been superseded by `TextElementAtPoint`.
1078
1878
  * @public
1079
- * An element that renders text.
1080
- *
1081
- * @remarks
1082
- * This type includes properties for controlling the position and dimensions of the
1083
- * element.
1084
- * It will be positioned and sized relative to its parent container.
1085
- * The parent container may be an app element, or the current page.
1879
+ * An element that renders text content and has positional properties.
1086
1880
  */
1087
1881
  export declare type NativeTextElementWithBox = {
1088
1882
  /**
1089
1883
  * The type of element.
1090
1884
  */
1091
- type: "TEXT";
1885
+ type: "text";
1092
1886
  /**
1093
- * The text to render within the element.
1887
+ * The text content.
1094
1888
  *
1095
1889
  * @remarks
1096
- * In the future, each item in this array will map to a paragraph. At the moment,
1097
- * only one item is supported.
1890
+ * Only the first element in this array is used.
1098
1891
  */
1099
1892
  children: [string];
1100
1893
  /**
1101
- * The width of the element. This must be an integer between 0 and 32767.
1894
+ * The width of the element, in pixels.
1895
+ *
1896
+ * @remarks
1897
+ * - Minimum: 0
1898
+ * - Maximum: 32767
1102
1899
  */
1103
1900
  width?: number;
1104
1901
  /**
1105
- * The distance from the top edge of the container.
1902
+ * The distance from the top edge of the container, in pixels.
1106
1903
  *
1107
1904
  * @remarks
1108
- * This must be an integer between -32768 and 32767. This property doesn't have
1109
- * any effect if the app element only contains a single element.
1905
+ * - Minimum: -32768
1906
+ * - Maximum: 32767
1110
1907
  */
1111
1908
  top: number;
1112
1909
  /**
1113
- * The distance from the left edge of the container.
1910
+ * The distance from the left edge of the container, in pixels.
1114
1911
  *
1115
1912
  * @remarks
1116
- * This must be an integer between -32768 and 32767. This property doesn't have
1117
- * any effect if the app element only contains a single element.
1913
+ * - Minimum: -32768
1914
+ * - Maximum: 32767
1118
1915
  */
1119
1916
  left: number;
1120
1917
  /**
1121
1918
  * The rotation of the element, in degrees.
1122
1919
  *
1123
1920
  * @remarks
1124
- * This must be an integer between -180 and 180.
1921
+ * - Minimum: -180
1922
+ * - Maximum: 180
1125
1923
  */
1126
1924
  rotation?: number;
1127
1925
  } & TextAttributes;
1128
1926
 
1129
1927
  /**
1928
+ * @deprecated The type has been superseded by `VideoElement`.
1130
1929
  * @public
1131
- * An element that renders a video in the user's design.
1930
+ * An element that renders video content.
1132
1931
  */
1133
1932
  export declare type NativeVideoElement = {
1134
1933
  /**
1135
1934
  * The type of element.
1136
1935
  */
1137
- type: "VIDEO";
1936
+ type: "video";
1138
1937
  /**
1139
- * A unique identifier that references a video asset in Canva's backend.
1938
+ * A unique identifier that points to a video asset in Canva's backend.
1140
1939
  */
1141
1940
  ref: VideoRef;
1142
1941
  /**
1143
- * An optional object to describe alt-text that may be applied to a video.
1942
+ * A description of the video content.
1144
1943
  */
1145
- altText?: AltText;
1944
+ altText: AltText | undefined;
1146
1945
  };
1147
1946
 
1148
1947
  /**
1948
+ * @deprecated The type has been superseded by `VideoElementAtPoint`.
1149
1949
  * @public
1150
- * An element that renders a video in the user's design.
1151
- *
1152
- * @remarks
1153
- * This type includes properties for controlling the position and dimensions
1154
- * of the element.
1155
- * It will be positioned and sized relative to its parent container.
1156
- * The parent container may be an app element, or the current page.
1950
+ * An element that renders video content and has positional properties.
1157
1951
  */
1158
1952
  export declare type NativeVideoElementWithBox = NativeVideoElement & Box;
1159
1953
 
1160
1954
  /**
1161
- * The types of object primitive values that can be stored within an app element's data.
1955
+ * An object primitive data type that can be used in app element data.
1162
1956
  */
1163
1957
  declare type ObjectPrimitive = Boolean | String;
1164
1958
 
1959
+ /**
1960
+ * @beta
1961
+ * Reads a specified part of the user's design and returns all elements in that part.
1962
+ *
1963
+ * @param options - Options for configuring how a design is read.
1964
+ * @param callback - A callback for operating on the design.
1965
+ */
1966
+ export declare const openDesign: (
1967
+ options: DesignOpenOptions,
1968
+ callback: (
1969
+ draft: DesignEditing.DesignOpenResult,
1970
+ helpers: {
1971
+ elementBuilder: DesignEditing.ElementBuilder;
1972
+ }
1973
+ ) => Promise<void> | void
1974
+ ) => Promise<void>;
1975
+
1165
1976
  /**
1166
1977
  * @public
1167
1978
  * An alias for the DesignOverlay interface, providing access to design overlay related functionality
@@ -1170,23 +1981,30 @@ export declare const overlay: DesignOverlay;
1170
1981
 
1171
1982
  /**
1172
1983
  * @public
1173
- * Information about whether the overlay can be opened or not on a particular {@link OverlayTarget}
1984
+ * Information about whether or not an overlay can be opened for the specified target.
1174
1985
  */
1175
1986
  export declare type OverlayOpenableEvent<Target extends OverlayTarget> = {
1176
1987
  /**
1177
- * An event indicating whether the overlay can be opened or not when {@link OverlayTarget} is `"image_selection"`
1988
+ * Information about whether or not an overlay can be opened or not for a selected image.
1178
1989
  */
1179
1990
  ["image_selection"]:
1180
1991
  | OverlayUnopenableEvent
1181
1992
  | {
1993
+ /**
1994
+ * Indicates that the overlay can be opened for the selected image.
1995
+ */
1182
1996
  canOpen: true;
1183
1997
  /**
1184
- * Launch a new app process on an overlay on top of the current selected image fill
1185
- *
1186
- * @remarks
1187
- * `launchParameters` specifies the type of data that are provided to an app process at its launch
1998
+ * Opens an overlay for the selected image.
1999
+ * @param opts - Options for launching the process associated with the overlay.
1188
2000
  */
1189
2001
  readonly open: (options: {
2002
+ /**
2003
+ * Parameters to pass to the overlay when it opens.
2004
+ *
2005
+ * @remarks
2006
+ * This can be any type of structured data.
2007
+ */
1190
2008
  launchParameters?: any;
1191
2009
  }) => Promise<AppProcessId>;
1192
2010
  };
@@ -1194,16 +2012,22 @@ export declare type OverlayOpenableEvent<Target extends OverlayTarget> = {
1194
2012
 
1195
2013
  /**
1196
2014
  * @public
1197
- * The target to check if an overlay can be opened for
2015
+ * An entity that an overlay can be opened for.
1198
2016
  */
1199
2017
  export declare type OverlayTarget = "image_selection";
1200
2018
 
1201
2019
  /**
1202
2020
  * @public
1203
- * Information about the overlay when it can not be opened on a particular {@link OverlayTarget}
2021
+ * Information about an overlay that can't be opened for the specified target.
1204
2022
  */
1205
2023
  declare type OverlayUnopenableEvent = {
2024
+ /**
2025
+ * Indicates that the overlay can't be opened for the specified target.
2026
+ */
1206
2027
  canOpen: false;
2028
+ /**
2029
+ * Indicates the reason the overlay can't be opened for the specified target.
2030
+ */
1207
2031
  reason: string;
1208
2032
  };
1209
2033
 
@@ -1215,24 +2039,30 @@ export declare type PageBackgroundFill = Pick<Fill, "asset" | "color">;
1215
2039
 
1216
2040
  /**
1217
2041
  * @public
1218
- * Page context
2042
+ * Information about a page.
1219
2043
  */
1220
2044
  export declare type PageContext = {
1221
2045
  /**
1222
- * Page dimensions in px
2046
+ * The dimensions of the page, in pixels.
1223
2047
  *
1224
2048
  * @remarks
1225
- * This value is undefined for Whiteboard and Docs
2049
+ * This may be `undefined` because some types of pages don't have dimensions, such as whiteboards.
1226
2050
  */
1227
2051
  dimensions: PageDimensions | undefined;
1228
2052
  };
1229
2053
 
1230
2054
  /**
1231
2055
  * @public
1232
- * Page Dimensions
2056
+ * A set of page dimensions, in pixels.
1233
2057
  */
1234
2058
  export declare type PageDimensions = {
2059
+ /**
2060
+ * The width of the page, in pixels.
2061
+ */
1235
2062
  width: number;
2063
+ /**
2064
+ * The height of the page, in pixels.
2065
+ */
1236
2066
  height: number;
1237
2067
  };
1238
2068
 
@@ -1242,59 +2072,73 @@ export declare type PageDimensions = {
1242
2072
  */
1243
2073
  export declare type PathStroke = {
1244
2074
  /**
1245
- * The weight of the stroke. This must be an integer between 0 and 100.
2075
+ * The weight (thickness) of the stroke.
2076
+ *
2077
+ * @remarks
2078
+ * - Minimum: 0
2079
+ * - Maximum: 100
1246
2080
  */
1247
2081
  weight: number;
1248
2082
  /**
1249
2083
  * The color of the stroke as a hex code.
1250
2084
  *
1251
2085
  * @remarks
1252
- * The hex code must include all six characters and be prefixed with a # symbol (e.g. #ff0099).
2086
+ * The hex code must include all six characters and be prefixed with a `#` symbol.
2087
+ *
2088
+ * @example
2089
+ * "#ff0099"
1253
2090
  */
1254
2091
  color: string;
1255
2092
  /**
1256
- * The alignment of the stroke. The only supported value is 'inset'.
2093
+ * The alignment of the stroke.
1257
2094
  */
1258
2095
  strokeAlign: "inset";
1259
2096
  };
1260
2097
 
1261
2098
  /**
1262
2099
  * @public
1263
- * The dimensions, position, and rotation of an element.
2100
+ * A position, set of dimensions, and rotation.
1264
2101
  */
1265
2102
  export declare type Placement = Position & (WidthAndHeight | Width | Height);
1266
2103
 
2104
+ /**
2105
+ * @deprecated
2106
+ * A position and rotation.
2107
+ */
1267
2108
  declare type Position = {
1268
2109
  /**
1269
- * The distance from the top edge of the container.
2110
+ * The distance from the top edge of the container, in pixels.
1270
2111
  *
1271
2112
  * @remarks
1272
- * This must be an integer between -32768 and 32767. This property doesn't
1273
- * have any effect if the app element only contains a single element.
2113
+ * - The pixels are relative to their container.
2114
+ * - Minimum: -32768
2115
+ * - Maximum: 32767
1274
2116
  */
1275
2117
  top: number;
1276
2118
  /**
1277
- * The distance from the left edge of the container.
2119
+ * The distance from the left edge of the container, in pixels.
1278
2120
  *
1279
2121
  * @remarks
1280
- * This must be an integer between -32768 and 32767. This property doesn't
1281
- * have any effect if the app element only contains a single element.
2122
+ * - The pixels are relative to their container.
2123
+ * - Minimum: -32768
2124
+ * - Maximum: 32767
1282
2125
  */
1283
2126
  left: number;
1284
2127
  /**
1285
- * The rotation of the box, in degrees.
2128
+ * A rotation, in degrees.
1286
2129
  *
1287
2130
  * @remarks
1288
- * This must be an integer between -180 and 180.
2131
+ * - Minimum: -180
2132
+ * - Maximum: 180
1289
2133
  */
1290
2134
  rotation?: number;
1291
2135
  };
1292
2136
 
1293
2137
  /**
1294
- * The types of primitive values that can be stored within an app element's data.
2138
+ * A primitive data type that can be used in app element data.
1295
2139
  *
1296
2140
  * @remarks
1297
- * All types of primitives are supported except for symbols and bigints.
2141
+ * All primitive data types are supported except for symbols and bigints.
1298
2142
  */
1299
2143
  declare type Primitive = undefined | null | number | boolean | string;
1300
2144
 
@@ -1337,55 +2181,91 @@ export declare type QueryResult<T extends ContentType> = {
1337
2181
  * @param options - Options for configuring how a design is read.
1338
2182
  * @param callback - A callback for operating on the queried content.
1339
2183
  */
1340
- export declare function readContent<T extends ContentType>(
2184
+ export declare const readContent: <T extends ContentType>(
1341
2185
  options: EditContentOptions<T>,
1342
2186
  callback: (draft: QueryResult<T>) => Promise<void> | void
1343
- ): Promise<void>;
2187
+ ) => Promise<void>;
2188
+
2189
+ /**
2190
+ * @beta
2191
+ * A callback for reading and updating part of a design.
2192
+ * @param draft - The result of reading the content in a design.
2193
+ */
2194
+ export declare type ReadContentCallback<T extends ContentType> = (
2195
+ draft: QueryResult<T>
2196
+ ) => Promise<void> | void;
1344
2197
 
1345
2198
  /**
1346
2199
  * @public
1347
2200
  * Exports the user's design as one or more static files.
1348
2201
  * @param request - The request object containing configurations of the design export.
1349
2202
  */
1350
- export declare function requestExport(
2203
+ export declare const requestExport: (
1351
2204
  request: ExportRequest
1352
- ): Promise<ExportResponse>;
2205
+ ) => Promise<ExportResponse>;
1353
2206
 
1354
2207
  /**
1355
- * @beta
2208
+ * @public
2209
+ * An element that renders richtext content.
2210
+ */
2211
+ export declare type RichtextElement = {
2212
+ /**
2213
+ * The type of element.
2214
+ */
2215
+ type: "richtext";
2216
+ /**
2217
+ * The richtext content.
2218
+ */
2219
+ range: RichtextRange;
2220
+ };
2221
+
2222
+ /**
2223
+ * @public
2224
+ * An element that renders richtext content.
1356
2225
  *
1357
- * Formatting values for richtext
2226
+ * @remarks
2227
+ * This type includes properties for controlling the position and dimensions of the
2228
+ * element.
2229
+ * It will be positioned and sized relative to its parent container.
2230
+ * The parent container may be an app element, or the current page.
2231
+ */
2232
+ export declare type RichtextElementAtPoint = RichtextElement & TextBox;
2233
+
2234
+ /**
2235
+ * @public
2236
+ * Options for formatting richtext.
1358
2237
  */
1359
2238
  export declare type RichtextFormatting = InlineFormatting & {
1360
2239
  /**
1361
2240
  * @public
1362
- * A reference to the font to use for this text element.
2241
+ * A unique identifier that points to a font asset in Canva's backend.
1363
2242
  */
1364
2243
  fontRef?: FontRef;
1365
2244
  /**
1366
2245
  * The size of the text, in pixels.
1367
2246
  *
1368
2247
  * @remarks
1369
- * This must be an integer between 1 and 1000.
1370
- * In the UI of the Canva editor, this number is shown as points (pts), not pixels.
2248
+ * - In the Canva editor, this number is shown as points (pts), not pixels.
2249
+ * - Minimum: 1
2250
+ * - Maximum: 100
1371
2251
  */
1372
2252
  fontSize?: number;
1373
2253
  /**
1374
2254
  * The alignment of the text.
1375
- * @defaultValue 'start'
2255
+ * @defaultValue "start"
1376
2256
  */
1377
2257
  textAlign?: "start" | "center" | "end" | "justify";
1378
2258
  /**
1379
- * The list indentation level of the current paragraph.
2259
+ * The list indentation level of the paragraph.
1380
2260
  */
1381
2261
  listLevel?: number;
1382
2262
  /**
1383
- * The appearance of the marker for list items.
2263
+ * The appearance of list item markers.
1384
2264
  *
1385
2265
  * @remarks
1386
- * This property only has an effect if `listLevel` is a number greater than 0.
2266
+ * This property only has an effect if `listLevel` is greater than 0.
1387
2267
  *
1388
- * @defaultValue 'none'
2268
+ * @defaultValue "none"
1389
2269
  */
1390
2270
  listMarker?:
1391
2271
  | "none"
@@ -1400,33 +2280,34 @@ export declare type RichtextFormatting = InlineFormatting & {
1400
2280
  };
1401
2281
 
1402
2282
  /**
1403
- * @beta
1404
- *
1405
- * An object containing rich text which exposes methods to manipulate the text.
1406
- * This is generated from a selection, with a range created for each instance of text in the selection.
1407
- * For example, if a table is currently selected, a range will be created for each cell.
1408
- * If only part of the text of an element is selected, then only that part will be represented in the range.
2283
+ * @public
2284
+ * Provides methods for interacting with a range of formatted text.
1409
2285
  */
1410
2286
  export declare type RichtextRange = {
1411
2287
  /**
1412
- * Formats all paragraphs that overlap the given bounds. The newline character separates text into
1413
- * distinct paragraphs. Newline separator is treated as the final character of each paragraph.
1414
- * All paragraphs that overlap the given bounds will be formatted in their entirety.
1415
- * @param bounds - The region of text overlapping the paragraphs to apply the formatting.
2288
+ * Formats all of the paragraphs that overlap the given bounds.
2289
+ *
2290
+ * @param bounds - The segment of the range on which to apply the formatting.
1416
2291
  * @param formatting - The formatting to apply to the paragraph(s).
2292
+ *
2293
+ * @remarks
2294
+ * - The `\n` character indicates the end of a paragraph.
2295
+ * - All paragraphs that overlap the provided bounds will be formatted in their entirety.
2296
+ *
1417
2297
  */
1418
2298
  formatParagraph(bounds: Bounds, formatting: RichtextFormatting): void;
1419
2299
  /**
1420
- * Formats a given region of rich text with inline formatting.
1421
- * @param bounds - The region of text to apply the formatting.
1422
- * @param formatting - The inline formatting to apply to the region of text.
2300
+ * Formats a region of text with inline formatting properties.
2301
+ *
2302
+ * @param bounds - The segment of the range on which to apply the formatting.
2303
+ * @param formatting - The formatting to apply to the text.
1423
2304
  */
1424
2305
  formatText(bounds: Bounds, formatting: InlineFormatting): void;
1425
2306
  /**
1426
- * Appends characters to the rich text range.
1427
- * Appended characters can be formatted with inline formatting properties.
1428
- * @param characters - The characters to append to the rich text range.
1429
- * @param formatting - The inline formatting to apply to the appended text.
2307
+ * Appends the specified characters to the end of the range.
2308
+ *
2309
+ * @param characters - The characters to append to the richtext range.
2310
+ * @param fo -
1430
2311
  */
1431
2312
  appendText(
1432
2313
  characters: string,
@@ -1435,44 +2316,41 @@ export declare type RichtextRange = {
1435
2316
  bounds: Bounds;
1436
2317
  };
1437
2318
  /**
1438
- * Replaces a region of the rich text range with the specified characters.
1439
- * Replaced characters can be formatted with inline formatting properties.
1440
- * @param bounds - The region of text to be replaced.
2319
+ * Replaces a region of text with the specified characters.
2320
+ *
2321
+ * @param bounds - The segment of the range to replace.
1441
2322
  * @param characters - The replacement characters.
1442
- * @param formatting - The inline formatting to apply to the replaced text.
2323
+ * @param formatting - The formatting to apply to the replaced text.
1443
2324
  */
1444
2325
  replaceText(
1445
2326
  bounds: Bounds,
1446
2327
  characters: string,
1447
2328
  formatting?: InlineFormatting
1448
2329
  ): {
2330
+ /**
2331
+ * The bounds of the replacement characters within the updated range.
2332
+ */
1449
2333
  bounds: Bounds;
1450
2334
  };
1451
2335
  /**
1452
- * Returns the current state of the rich text range as plain text.
1453
- *
1454
- * @remarks
1455
- * If this range is a draft, this includes any changes to the text that have not been committed.
2336
+ * Returns the current state of the richtext as plaintext.
1456
2337
  */
1457
2338
  readPlaintext(): string;
1458
2339
  /**
1459
- * Returns the current state of the rich text range as an array of text regions.
1460
- * Each region is an object that contains the text itself and its formatting.
1461
- *
1462
- * @remarks
1463
- * If this range is a draft, this array includes any changes to the text that have not been committed.
2340
+ * Returns the current state of the richtext as one or more text regions.
2341
+ * Each region is an object that contains the text content and its formatting.
1464
2342
  */
1465
2343
  readTextRegions(): TextRegion[];
1466
2344
  };
1467
2345
 
1468
2346
  /**
1469
- * @beta
2347
+ * @public
1470
2348
  * An alias for the DesignSelection interface, providing access to design selection related functionality
1471
2349
  */
1472
2350
  export declare const selection: DesignSelection;
1473
2351
 
1474
2352
  /**
1475
- * @beta
2353
+ * @public
1476
2354
  * Information about the user's selection. To access the selected content, call the `read` method.
1477
2355
  */
1478
2356
  export declare interface SelectionEvent<Scope extends SelectionScope> {
@@ -1507,8 +2385,30 @@ export declare interface SelectionEvent<Scope extends SelectionScope> {
1507
2385
  }
1508
2386
 
1509
2387
  /**
1510
- * @beta
1511
- * The type of content that apps can detect selection changes on.
2388
+ * @public
2389
+ * Information about a user's selection.
2390
+ */
2391
+ export declare interface SelectionEvent<Scope extends SelectionScope> {
2392
+ /**
2393
+ * The type of content.
2394
+ */
2395
+ readonly scope: Scope;
2396
+ /**
2397
+ * The number of content items in the user's selection.
2398
+ */
2399
+ readonly count: number;
2400
+ /**
2401
+ * Returns a snapshot of the content in the user's selection.
2402
+ *
2403
+ * @remarks
2404
+ * The snapshot is known as the *draft*.
2405
+ */
2406
+ read(): Promise<ContentDraft<SelectionValue<Scope>>>;
2407
+ }
2408
+
2409
+ /**
2410
+ * @public
2411
+ * A type of content that supports selection events.
1512
2412
  */
1513
2413
  export declare type SelectionScope =
1514
2414
  | "plaintext"
@@ -1517,24 +2417,24 @@ export declare type SelectionScope =
1517
2417
  | "richtext";
1518
2418
 
1519
2419
  /**
1520
- * @beta
1521
- * The selected content.
2420
+ * @public
2421
+ * A piece of selected content.
1522
2422
  *
1523
2423
  * @remarks
1524
- * The value depends on the {@link SelectionScope}.
2424
+ * The available properties depend on the type (scope) of content.
1525
2425
  */
1526
2426
  export declare type SelectionValue<Scope extends SelectionScope> = {
1527
2427
  /**
1528
- * The selected content when {@link SelectionScope} is `"plaintext"`.
2428
+ * A selected range of plaintext.
1529
2429
  */
1530
2430
  ["plaintext"]: {
1531
2431
  /**
1532
- * The text content of the element as plain text.
2432
+ * The text content.
1533
2433
  */
1534
2434
  text: string;
1535
2435
  };
1536
2436
  /**
1537
- * The selected content when {@link SelectionScope} is `"image"`.
2437
+ * A selected image.
1538
2438
  */
1539
2439
  ["image"]: {
1540
2440
  /**
@@ -1543,7 +2443,7 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
1543
2443
  ref: ImageRef;
1544
2444
  };
1545
2445
  /**
1546
- * The selected content when {@link SelectionScope} is `"video"`.
2446
+ * A selected video.
1547
2447
  */
1548
2448
  ["video"]: {
1549
2449
  /**
@@ -1552,7 +2452,7 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
1552
2452
  ref: VideoRef;
1553
2453
  };
1554
2454
  /**
1555
- * The selected content when {@link SelectionScope} is `"richtext"`.
2455
+ * A selected range of formatted text.
1556
2456
  */
1557
2457
  ["richtext"]: RichtextRange;
1558
2458
  }[Scope];
@@ -1562,29 +2462,39 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
1562
2462
  * Updates the background of the user's current page. The background can be a solid color,
1563
2463
  * an image or a video.
1564
2464
  */
1565
- export declare function setCurrentPageBackground(
2465
+ export declare const setCurrentPageBackground: (
1566
2466
  opts: PageBackgroundFill
1567
- ): Promise<void>;
2467
+ ) => Promise<void>;
2468
+
2469
+ /**
2470
+ * @public
2471
+ * An element that renders a vector shape.
2472
+ */
2473
+ export declare type ShapeElement = NativeShapeElement;
2474
+
2475
+ /**
2476
+ * @public
2477
+ * An element that renders a vector shape and has positional properties.
2478
+ */
2479
+ export declare type ShapeElementAtPoint = NativeShapeElementWithBox;
1568
2480
 
1569
2481
  /**
1570
2482
  * @public
1571
- * A path that defines the shape of a shape element.
2483
+ * A path that defines the structure of a shape element.
1572
2484
  */
1573
2485
  export declare type ShapePath = {
1574
2486
  /**
1575
2487
  * The shape of the path.
1576
2488
  *
1577
2489
  * @remarks
1578
- * This accepts the same value as the `d` attribute of the SVG <path> element,
1579
- * with some limitations.
1580
- *
1581
- * The path must:
2490
+ * This is similar to the `d` attribute of an SVG's `path` element, with some limitations:
1582
2491
  *
1583
- * - start with an M command
1584
- * - not have more than one M command
1585
- * - not use the Q command
1586
- * - be closed, either with a Z command at the end or by having the last
1587
- * coordinate match the first coordinate
2492
+ * - The path must start with an M command.
2493
+ * - The path must not have more than one M command.
2494
+ * - The path must not use the Q command.
2495
+ * - The path must be closed, either by:
2496
+ * - Using a Z command at the end of the path
2497
+ * - Having the last coordinate match the first coordinate
1588
2498
  */
1589
2499
  d: string;
1590
2500
  /**
@@ -1599,158 +2509,203 @@ export declare type ShapePath = {
1599
2509
 
1600
2510
  /**
1601
2511
  * @public
1602
- * Properties for configuring the scale and cropping of a shape.
2512
+ * Options for configuring the scale and cropping of a shape.
1603
2513
  *
1604
2514
  * @remarks
1605
- * This is similar to the `viewBox` attribute of the <svg> element.
2515
+ * This is similar to the `viewBox` attribute of an `SVGElement`.
1606
2516
  */
1607
2517
  export declare type ShapeViewBox = {
1608
2518
  /**
1609
- * The distance of the shape from the top edge of the element.
2519
+ * The distance of the shape from the top edge of the element, in pixels.
1610
2520
  */
1611
2521
  top: number;
1612
2522
  /**
1613
- * The distance of the shape from the left edge of the element.
2523
+ * The distance of the shape from the left edge of the element, in pixels.
1614
2524
  */
1615
2525
  left: number;
1616
2526
  /**
1617
- * The width of the view box.
2527
+ * The width of the view box, in pixels.
1618
2528
  */
1619
2529
  width: number;
1620
2530
  /**
1621
- * The height of the view box.
2531
+ * The height of the view box, in pixels.
1622
2532
  */
1623
2533
  height: number;
1624
2534
  };
1625
2535
 
1626
2536
  /**
1627
2537
  * @public
1628
- * Attributes for changing the appearance of text.
2538
+ * An element that renders a table.
2539
+ */
2540
+ export declare type TableElement = {
2541
+ /**
2542
+ * The type of element.
2543
+ */
2544
+ type: "table";
2545
+ /**
2546
+ * The rows of the table.
2547
+ */
2548
+ rows: {
2549
+ /**
2550
+ * The cells (columns) of the row.
2551
+ *
2552
+ * @remarks
2553
+ * Each row must have the same number of cells.
2554
+ */
2555
+ cells: (Cell | null | undefined)[];
2556
+ }[];
2557
+ };
2558
+
2559
+ /**
2560
+ * @public
2561
+ * Options for configuring the appearance of text.
1629
2562
  */
1630
2563
  export declare type TextAttributes = {
1631
2564
  /**
1632
2565
  * The size of the text.
1633
2566
  *
1634
2567
  * @remarks
1635
- * The default value is 16. This must be an integer between 1 and 1000.
1636
- * This property will be ignored when adding native text elements without specifying placement.
2568
+ * - Minimum: 1
2569
+ * - Maximum: 100
2570
+ *
2571
+ * @defaultValue 16
1637
2572
  */
1638
2573
  fontSize?: number;
1639
2574
  /**
1640
2575
  * The alignment of the text.
1641
- * @defaultValue 'start'
2576
+ * @defaultValue "start"
1642
2577
  */
1643
2578
  textAlign?: "start" | "center" | "end" | "justify";
1644
2579
  /**
1645
2580
  * The color of the text as a hex code.
1646
2581
  *
1647
2582
  * @remarks
1648
- * The hex code must include all six characters and be prefixed with a # symbol
1649
- * (e.g. #ff0099). The default value is #000000.
2583
+ * The hex code must include all six characters and be prefixed with a `#` symbol.
2584
+ *
2585
+ * @example
2586
+ * "#ff0099"
1650
2587
  */
1651
2588
  color?: string;
1652
2589
  /**
1653
2590
  * @public
1654
- * A reference to the font to use for this text element.
2591
+ * A unique identifier that points to a font asset in Canva's backend.
1655
2592
  */
1656
2593
  fontRef?: FontRef;
1657
2594
  /**
1658
- * The weight of the font.
1659
- * @defaultValue 'normal'
2595
+ * The weight (thickness) of the font.
2596
+ * @defaultValue "normal"
1660
2597
  */
1661
2598
  fontWeight?: FontWeight;
1662
2599
  /**
1663
2600
  * The style of the font.
1664
- * @defaultValue 'normal'
2601
+ * @defaultValue "normal"
1665
2602
  */
1666
2603
  fontStyle?: "normal" | "italic";
1667
2604
  /**
1668
2605
  * The decoration of the font.
1669
- * @defaultValue 'none'
2606
+ * @defaultValue "none"
1670
2607
  */
1671
2608
  decoration?: "none" | "underline";
1672
2609
  };
1673
2610
 
1674
2611
  /**
1675
- * @beta
2612
+ * @public
2613
+ * The dimensions, position, and rotation of a text element.
1676
2614
  */
1677
2615
  declare type TextBox = {
1678
2616
  /**
1679
- * The width of the element. This must be an integer between 0 and 32767.
2617
+ * The width, in pixels.
2618
+ *
2619
+ * @remarks
2620
+ * - Minimum: 0
2621
+ * - Maximum: 32767
1680
2622
  */
1681
2623
  width?: number;
1682
2624
  /**
1683
- * The distance from the top edge of the container.
2625
+ * The distance from the top edge of the container, in pixels.
1684
2626
  *
1685
2627
  * @remarks
1686
- * This must be an integer between -32768 and 32767. This property doesn't have
1687
- * any effect if the app element only contains a single element.
2628
+ * - Minimum: -32767
2629
+ * - Maximum: 32767
1688
2630
  */
1689
2631
  top: number;
1690
2632
  /**
1691
- * The distance from the left edge of the container.
2633
+ * The distance from the left edge of the container, in pixels.
1692
2634
  *
1693
2635
  * @remarks
1694
- * This must be an integer between -32768 and 32767. This property doesn't have
1695
- * any effect if the app element only contains a single element.
2636
+ * - Minimum: -32767
2637
+ * - Maximum: 32767
1696
2638
  */
1697
2639
  left: number;
1698
2640
  /**
1699
- * The rotation of the element, in degrees.
2641
+ * The rotation, in degrees.
1700
2642
  *
1701
2643
  * @remarks
1702
- * This must be an integer between -180 and 180.
2644
+ * - Minimum: -180
2645
+ * - Maximum: 180
1703
2646
  */
1704
2647
  rotation?: number;
1705
2648
  };
1706
2649
 
1707
2650
  /**
1708
2651
  * @public
1709
- * Options for defining the drag-and-drop behavior of a text element.
2652
+ * Text element or content to be added to the design at the end of a drag event.
1710
2653
  */
1711
2654
  export declare type TextDragConfig = {
1712
2655
  /**
1713
2656
  * The type of element.
1714
2657
  */
1715
- type: "TEXT";
2658
+ type: "text";
1716
2659
  /**
1717
2660
  * The text content to drag.
1718
2661
  */
1719
2662
  children?: string[];
1720
2663
  /**
1721
2664
  * The alignment of the text.
1722
- * @defaultValue 'start'
2665
+ * @defaultValue "start"
1723
2666
  */
1724
2667
  textAlign?: "start" | "center" | "end" | "justify";
1725
2668
  /**
1726
- * The weight of the font.
1727
- * @defaultValue 'normal'
2669
+ * The weight (thickness) of the font.
2670
+ * @defaultValue "normal"
1728
2671
  */
1729
2672
  fontWeight?: FontWeight;
1730
2673
  /**
1731
2674
  * The style of the font.
1732
- * @defaultValue 'normal'
2675
+ * @defaultValue "normal"
1733
2676
  */
1734
2677
  fontStyle?: "normal" | "italic";
1735
2678
  /**
1736
2679
  * The decoration of the font.
1737
- * @defaultValue 'none'
2680
+ * @defaultValue "none"
1738
2681
  */
1739
2682
  decoration?: "none" | "underline";
1740
2683
  /**
1741
2684
  * @beta
1742
- * A unique identifier that references a font asset in Canva's backend.
2685
+ * A unique identifier that points to a font asset in Canva's backend.
1743
2686
  */
1744
2687
  fontRef?: FontRef;
1745
2688
  };
1746
2689
 
1747
2690
  /**
1748
- * @beta
1749
- * A region of rich text.
2691
+ * @public
2692
+ * An element that renders text content.
2693
+ */
2694
+ export declare type TextElement = NativeTextElement;
2695
+
2696
+ /**
2697
+ * @public
2698
+ * An element that renders text content and has positional properties.
2699
+ */
2700
+ export declare type TextElementAtPoint = NativeTextElementWithBox;
2701
+
2702
+ /**
2703
+ * @public
2704
+ * A region of richtext.
1750
2705
  */
1751
2706
  export declare type TextRegion = {
1752
2707
  /**
1753
- * The plain text content of the region.
2708
+ * The plaintext content of the region.
1754
2709
  */
1755
2710
  text: string;
1756
2711
  /**
@@ -1761,23 +2716,16 @@ export declare type TextRegion = {
1761
2716
 
1762
2717
  /**
1763
2718
  * @public
1764
- * The methods for adding drag-and-drop behavior to an app.
2719
+ * Provides methods for adding drag and drop behavior to an app.
1765
2720
  */
1766
2721
  export declare interface UI {
1767
2722
  /**
2723
+ * @deprecated The method has been superseded by `startDragToPoint`.
1768
2724
  * @public
1769
- * Makes the specified node draggable.
2725
+ * Adds the specified element or content to a design at the end of a drag event.
1770
2726
  *
1771
- * @deprecated use `UI.startDrag` instead
1772
- *
1773
- * @param options - Options for making an element draggable.
1774
- */
1775
- makeDraggable(options: DraggableElementData): void;
1776
- /**
1777
- * @public
1778
- * Handles a drag event initiated inside the app to Canva, enables drag-and_drop interactions with elements outside of the app.
1779
- * @param event - The drag start event.
1780
- * @param dragData - The data to be passed to the drag handler.
2727
+ * @param event - A drag start event.
2728
+ * @param dragData - Element or content to be added to the design at the end of the drag event.
1781
2729
  */
1782
2730
  startDrag<E extends HTMLElement>(
1783
2731
  event: DragStartEvent<E>,
@@ -1788,172 +2736,47 @@ export declare interface UI {
1788
2736
  | VideoDragConfigForElement<E>
1789
2737
  | ImageDragConfigForElement<E>
1790
2738
  ): Promise<void>;
1791
- }
1792
-
1793
- /**
1794
- * An alias for the UI interface, providing access to ui related functionality
1795
- * @public
1796
- */
1797
- export declare const ui: UI;
1798
-
1799
- /**
1800
- * @deprecated
1801
- * @public
1802
- * Options for defining the drag-and-drop behavior of audio tracks.
1803
- */
1804
- export declare type UserSuppliedAudioDragData = AudioDragConfig;
1805
-
1806
- /**
1807
- * @deprecated
1808
- * @public
1809
- *
1810
- * Options for defining the Drag and Drop behaviour for images
1811
- * which have been supplied as data urls
1812
- */
1813
- export declare type UserSuppliedDataUrlImageDragData = CommonImageDragConfig & {
1814
- /**
1815
- * The dimensions of the full-size image.
1816
- *
1817
- * @remarks
1818
- * The full-size image is the image that Canva uploads to the user's account and
1819
- * adds to their design.
1820
- *
1821
- * If omitted, the value of the `previewSize` property is used as a fallback.
1822
- */
1823
- fullSize?: Dimensions;
1824
2739
  /**
1825
- * The data URL of the preview image.
1826
- *
1827
- * @remarks
1828
- * The preview image is the image that users see under their cursor while dragging
1829
- * it into their design.
2740
+ * @public
2741
+ * Adds the specified element or content to fixed designs, which use a coordinate-based positioning system at the end of a drag event.
1830
2742
  *
1831
- * If omitted, the value of the `fullSizeSrc` property is used as a fallback.
2743
+ * @param event - A drag start event.
2744
+ * @param dragData - Element or content to be added to the design at the end of the drag event.
1832
2745
  */
1833
- previewSrc?: string;
2746
+ startDragToPoint<E extends HTMLElement>(
2747
+ event: DragStartEvent<E>,
2748
+ dragData:
2749
+ | TextDragConfig
2750
+ | AudioDragConfig
2751
+ | EmbedDragConfig
2752
+ | VideoDragConfigForElement<E>
2753
+ | ImageDragConfigForElement<E>
2754
+ ): Promise<void>;
1834
2755
  /**
1835
- * The data URL of the full-size image.
2756
+ * @public
2757
+ * Adds the specified element or content to responsive documents, which slot things into a text stream at the end of a drag event.
1836
2758
  *
1837
- * @remarks
1838
- * The full-size image is the image that Canva uploads to the user's account and
1839
- * adds to their design.
2759
+ * @param event - A drag start event.
2760
+ * @param dragData - Element or content to be added to the design at the end of the drag event.
1840
2761
  */
1841
- fullSizeSrc: string;
1842
- };
1843
-
1844
- /**
1845
- * @deprecated
1846
- * @public
1847
- * Options for defining the drag-and-drop behavior that can be defined by an app developer.
1848
- */
1849
- export declare type UserSuppliedDragData =
1850
- | UserSuppliedImageDragData
1851
- | UserSuppliedTextDragData
1852
- | UserSuppliedVideoDragData
1853
- | UserSuppliedAudioDragData;
1854
-
1855
- /**
1856
- * @deprecated
1857
- * @public
1858
- *
1859
- * Options for defining the Drag and Drop behaviour for images uploaded
1860
- * via the Content capability.
1861
- */
1862
- export declare type UserSuppliedExternalImageDragData =
1863
- CommonImageDragConfig & {
1864
- /**
1865
- * The function that resolves an image ref
1866
- * @remarks
1867
- *
1868
- * This function will be run during the drag process in order to fetch the media ref of the
1869
- * external image being fetched. This function should return the result of `upload`
1870
- * from the content capability.
1871
- */
1872
- resolveImageRef: () => Promise<{
1873
- ref: ImageRef;
1874
- }>;
1875
- /**
1876
- * The URL of the preview image.
1877
- *
1878
- * @remarks
1879
- * The preview image is the image that users see under their cursor while dragging
1880
- * it into their design.
1881
- */
1882
- previewSrc: string;
1883
- /**
1884
- * The dimensions of the full-size image.
1885
- *
1886
- * @remarks
1887
- * The full-size image is the image that Canva uploads to the user's account and
1888
- * adds to their design.
1889
- *
1890
- * If omitted, the value of the `previewSize` property is used as a fallback.
1891
- */
1892
- fullSize?: Dimensions;
1893
- };
1894
-
1895
- /**
1896
- * @deprecated
1897
- * @public
1898
- * Options for defining the drag-and-drop behavior of an image element that can be defined by an
1899
- * app developer.
1900
- */
1901
- export declare type UserSuppliedImageDragData =
1902
- | UserSuppliedDataUrlImageDragData
1903
- | UserSuppliedExternalImageDragData;
1904
-
1905
- /**
1906
- * @deprecated
1907
- * @public
1908
- * Options for defining the drag-and-drop behavior of a text element.
1909
- */
1910
- export declare type UserSuppliedTextDragData = TextDragConfig;
2762
+ startDragToCursor<E extends HTMLElement>(
2763
+ event: DragStartEvent<E>,
2764
+ dragData:
2765
+ | EmbedDragConfig
2766
+ | VideoDragConfigForElement<E>
2767
+ | ImageDragConfigForElement<E>
2768
+ ): Promise<void>;
2769
+ }
1911
2770
 
1912
2771
  /**
1913
- * @deprecated
2772
+ * An alias for the UI interface, providing access to ui related functionality
1914
2773
  * @public
1915
- * Options for defining the drag-and-drop behavior for videos.
1916
2774
  */
1917
- export declare type UserSuppliedVideoDragData = {
1918
- /**
1919
- * The type of element.
1920
- */
1921
- type: "VIDEO";
1922
- /**
1923
- * The function used resolve the video ref.
1924
- * This is used in conjunction with content import.
1925
- */
1926
- resolveVideoRef: () => Promise<{
1927
- ref: VideoRef;
1928
- }>;
1929
- /**
1930
- * The dimensions of the preview image.
1931
- * @remarks
1932
- * The preview image is the image that users see under their cursor
1933
- * while dragging it into their design.
1934
- */
1935
- previewSize: Dimensions;
1936
- /**
1937
- * The dimensions of the full-size video.
1938
- * These dimensions are used when adding the video to the design
1939
- *
1940
- * If omitted, the value of the `previewSize` property is
1941
- * used as a fallback.
1942
- */
1943
- fullSize?: Dimensions;
1944
- /**
1945
- * The URL of the preview image.
1946
- *
1947
- * @remarks
1948
- * The preview image is the image that users see under their cursor while dragging
1949
- * it into their design.
1950
- */
1951
- previewSrc: string;
1952
- };
2775
+ export declare const ui: UI;
1953
2776
 
1954
2777
  /**
1955
2778
  * @public
1956
- * The types of values that can be stored within an app element's data.
2779
+ * A data type that can be used in app element data.
1957
2780
  */
1958
2781
  export declare type Value =
1959
2782
  | Primitive
@@ -1965,48 +2788,40 @@ export declare type Value =
1965
2788
 
1966
2789
  /**
1967
2790
  * @public
1968
- * Options for defining the drag-and-drop behavior for videos.
2791
+ * Video element or content to be added to the design at the end of a drag event.
1969
2792
  */
1970
2793
  export declare type VideoDragConfig = {
1971
2794
  /**
1972
2795
  * The type of element.
1973
2796
  */
1974
- type: "VIDEO";
2797
+ type: "video";
1975
2798
  /**
1976
- * The function used resolve the video ref.
1977
- * This is used in conjunction with content import.
2799
+ * A function that returns a reference (ref) to a video asset in Canva's backend.
1978
2800
  */
1979
2801
  resolveVideoRef: () => Promise<{
1980
2802
  ref: VideoRef;
1981
2803
  }>;
1982
2804
  /**
1983
2805
  * The dimensions of the preview image.
1984
- * @remarks
1985
- * The preview image is the image that users see under their cursor
1986
- * while dragging it into their design.
1987
2806
  */
1988
2807
  previewSize: Dimensions;
1989
2808
  /**
1990
2809
  * The dimensions of the full-size video.
1991
- * These dimensions are used when adding the video to the design
1992
2810
  *
1993
- * If omitted, the value of the `previewSize` property is
1994
- * used as a fallback.
2811
+ * @remarks
2812
+ * - These dimensions are used when adding the video to the design
2813
+ * - If omitted, the `previewSize` dimensions are used as a fallback.
1995
2814
  */
1996
2815
  fullSize?: Dimensions;
1997
2816
  /**
1998
- * The URL of the preview image.
1999
- *
2000
- * @remarks
2001
- * The preview image is the image that users see under their cursor while dragging
2002
- * it into their design.
2817
+ * The URL of an image to display under the user's cursor during the drag and drop event.
2003
2818
  */
2004
2819
  previewUrl: string;
2005
2820
  };
2006
2821
 
2007
2822
  /**
2008
2823
  * @public
2009
- * Options for defining the drag-and-drop behavior for videos.
2824
+ * Video element or content to be added to the design at the end of a drag event.
2010
2825
  */
2011
2826
  export declare type VideoDragConfigForElement<E extends Element> =
2012
2827
  E extends HTMLImageElement
@@ -2016,15 +2831,27 @@ export declare type VideoDragConfigForElement<E extends Element> =
2016
2831
 
2017
2832
  /**
2018
2833
  * @public
2019
- * A video asset that will be used to fill the given path.
2834
+ * An element that renders video content.
2835
+ */
2836
+ export declare type VideoElement = NativeVideoElement;
2837
+
2838
+ /**
2839
+ * @public
2840
+ * An element that renders video content and has positional properties.
2841
+ */
2842
+ export declare type VideoElementAtPoint = NativeVideoElementWithBox;
2843
+
2844
+ /**
2845
+ * @public
2846
+ * A video asset that fills a path's interior.
2020
2847
  */
2021
2848
  export declare type VideoFill = {
2022
2849
  /**
2023
- * Type of an asset that will be used to fill the given path.
2850
+ * The type of fill.
2024
2851
  */
2025
- type: "VIDEO";
2852
+ type: "video";
2026
2853
  /**
2027
- * A unique identifier that references a video asset in Canva's backend.
2854
+ * A unique identifier that points to a video asset in Canva's backend.
2028
2855
  */
2029
2856
  ref: VideoRef;
2030
2857
  };
@@ -2037,20 +2864,45 @@ export declare type VideoRef = string & {
2037
2864
  __videoRef: never;
2038
2865
  };
2039
2866
 
2867
+ /**
2868
+ * A set of dimensions with an auto-calculated height.
2869
+ */
2040
2870
  declare type Width = {
2871
+ /**
2872
+ * A width, in pixels.
2873
+ *
2874
+ * @remarks
2875
+ * - The pixels are relative to their container.
2876
+ * - Minimum: 0
2877
+ * - Maximum: 32767
2878
+ */
2041
2879
  width: number;
2880
+ /**
2881
+ * Indicates that the height should be auto-calculated.
2882
+ */
2042
2883
  height: "auto";
2043
2884
  };
2044
2885
 
2886
+ /**
2887
+ * A set of dimensions, in pixels.
2888
+ */
2045
2889
  declare type WidthAndHeight = {
2046
2890
  /**
2047
- * The width of the box. If height is a number, this can be set to "auto".
2048
- * Otherwise, it must be an integer between 0 and 32767.
2891
+ * A width, in pixels.
2892
+ *
2893
+ * @remarks
2894
+ * - The pixels are relative to their container.
2895
+ * - Minimum: 0
2896
+ * - Maximum: 32767
2049
2897
  */
2050
2898
  width: number;
2051
2899
  /**
2052
- * The height of the box. If width is a number, this can be set to "auto".
2053
- * Otherwise, it must be an integer between 0 and 32767.
2900
+ * A height, in pixels.
2901
+ *
2902
+ * @remarks
2903
+ * - The pixels are relative to their container.
2904
+ * - Minimum: 0
2905
+ * - Maximum: 32767
2054
2906
  */
2055
2907
  height: number;
2056
2908
  };