@canva/design 2.4.1 → 2.6.0-beta.1

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.
@@ -348,54 +348,1628 @@ export declare interface ContentDraft<T> {
348
348
  save(): Promise<void>;
349
349
  }
350
350
 
351
+ /**
352
+ * @beta
353
+ * Object for interacting with fill content (images/videos).
354
+ */
355
+ export declare type ContentFill = (
356
+ | Omit<ImageFill, "altText">
357
+ | Omit<VideoFill, "altText">
358
+ ) & {
359
+ /**
360
+ * Indicates whether the fill object has been deleted.
361
+ */
362
+ deleted: boolean;
363
+ };
364
+
365
+ /**
366
+ * @beta
367
+ * Session for reading and updating fill content in a user's design.
368
+ */
369
+ export declare interface ContentFillSession {
370
+ readonly contents: readonly ContentFill[];
371
+ sync(): Promise<void>;
372
+ }
373
+
374
+ /**
375
+ * @beta
376
+ */
377
+ export declare type ContentType = "richtext" | "fill";
378
+
351
379
  /**
352
380
  * @public
353
381
  * A type of content that can be read from a user's design.
354
382
  */
355
- export declare type ContentType = "richtext";
383
+ declare type ContentType_2 = "richtext";
384
+
385
+ /**
386
+ * @public
387
+ * Options for configuring where content in a design should be queried from.
388
+ */
389
+ export declare type ContextOptions = {
390
+ target: "current_page";
391
+ };
392
+
393
+ /**
394
+ * @public
395
+ * A set of X and Y coordinates.
396
+ */
397
+ export declare type Coordinates = {
398
+ /**
399
+ * X coordinate, in pixels.
400
+ */
401
+ x: number;
402
+ /**
403
+ * Y coordinate, in pixels.
404
+ */
405
+ y: number;
406
+ };
407
+
408
+ /**
409
+ * @public
410
+ * Creates a new RichtextRange object, which contains methods to manipulate text.
411
+ */
412
+ export declare const createRichtextRange: () => RichtextRange;
413
+
414
+ /**
415
+ * @public
416
+ * Describes a part of a design.
417
+ */
418
+ export declare type DesignContext = DesignContextOptions["type"];
419
+
420
+ /**
421
+ * @public
422
+ * Options for configuring which part of a design to read.
423
+ */
424
+ declare type DesignContextOptions = {
425
+ /**
426
+ * The type of context.
427
+ */
428
+ type: "current_page";
429
+ };
430
+
431
+ /**
432
+ * @public
433
+ * Provides methods for reading and updating the structure and content of a design.
434
+ */
435
+ export declare namespace DesignEditing {
436
+ /**
437
+ * @public
438
+ * Options for creating an image fill in the element state builder
439
+ */
440
+ export type ImageFillOpts = {
441
+ /**
442
+ * The type of media.
443
+ */
444
+ type: "image";
445
+ /**
446
+ * A unique identifier that points to an image asset in Canva's backend.
447
+ */
448
+ imageRef: ImageRef;
449
+ /**
450
+ * If `true`, the image is flipped horizontally.
451
+ */
452
+ flipX?: boolean;
453
+ /**
454
+ * If `true`, the image is flipped vertically.
455
+ */
456
+ flipY?: boolean;
457
+ };
458
+ /**
459
+ * @public
460
+ * Options for creating a video fill in the element state builder
461
+ */
462
+ export type VideoFillOpts = {
463
+ /**
464
+ * The type of media.
465
+ */
466
+ type: "video";
467
+ /**
468
+ * A unique identifier that points to a video asset in Canva's backend.
469
+ */
470
+ videoRef: VideoRef;
471
+ /**
472
+ * If `true`, the video is flipped horizontally.
473
+ */
474
+ flipX?: boolean;
475
+ /**
476
+ * If `true`, the video is flipped vertically.
477
+ */
478
+ flipY?: boolean;
479
+ };
480
+ /**
481
+ * @public
482
+ * Options for creating a media fill in the element state builder
483
+ */
484
+ export type MediaContainerOpts = ImageFillOpts | VideoFillOpts;
485
+ /**
486
+ * @public
487
+ * Options for creating a fill in the element state builder
488
+ */
489
+ export type FillOpts =
490
+ | {
491
+ colorContainer: ColorContainerOpts;
492
+ mediaContainer?: MediaContainerOpts;
493
+ }
494
+ | {
495
+ colorContainer?: ColorContainerOpts;
496
+ mediaContainer: MediaContainerOpts;
497
+ };
498
+ /**
499
+ * @public
500
+ * Options for creating a fill of a shape in the element state builder
501
+ */
502
+ export type PathFillOpts =
503
+ | {
504
+ colorContainer: ColorContainerOpts;
505
+ mediaContainer?: MediaContainerOpts;
506
+ isMediaEditable?: boolean;
507
+ }
508
+ | {
509
+ colorContainer?: ColorContainerOpts;
510
+ mediaContainer: MediaContainerOpts;
511
+ isMediaEditable?: boolean;
512
+ };
513
+ /**
514
+ * @public
515
+ */
516
+ export type ColorContainerOpts = SolidFillState;
517
+ /**
518
+ * @public
519
+ * Options for creating a stroke in the element state builder
520
+ */
521
+ export type StrokeOpts = {
522
+ /**
523
+ * The weight (thickness) of the stroke.
524
+ *
525
+ * @remarks
526
+ * - Minimum: 0
527
+ * - Maximum: 100
528
+ */
529
+ weight: number;
530
+ /**
531
+ * The color of the stroke.
532
+ */
533
+ colorContainer: ColorContainerOpts;
534
+ };
535
+ /**
536
+ * @public
537
+ * Options for creating a shape path in the element state builder
538
+ */
539
+ export type PathOpts = {
540
+ d: string;
541
+ /**
542
+ * Describes how a fill is filled with color or media.
543
+ *
544
+ * @remarks
545
+ * If both `media` and `color` are defined, `media` takes precedence.
546
+ */
547
+ fill?: PathFillOpts;
548
+ /**
549
+ * The outline of the path.
550
+ */
551
+ stroke?: StrokeOpts;
552
+ };
553
+ /**
554
+ * @public
555
+ * Options for creating a rect element.
556
+ */
557
+ export type CreateRectElementOpts = {
558
+ /**
559
+ * The distance from the top edge of the container, in pixels.
560
+ *
561
+ * @remarks
562
+ * - The pixels are relative to their container.
563
+ * - Minimum: -32768
564
+ * - Maximum: 32767
565
+ */
566
+ top: number;
567
+ /**
568
+ * The distance from the left edge of the container, in pixels.
569
+ *
570
+ * @remarks
571
+ * - The pixels are relative to their container.
572
+ * - Minimum: -32768
573
+ * - Maximum: 32767
574
+ */
575
+ left: number;
576
+ /**
577
+ * A rotation, in degrees.
578
+ *
579
+ * @remarks
580
+ * - Minimum: -180
581
+ * - Maximum: 180
582
+ */
583
+ rotation?: number;
584
+ /**
585
+ * Transparency as a percentage.
586
+ *
587
+ * @remarks
588
+ * - Minimum: 0
589
+ * - Maximum: 1
590
+ */
591
+ transparency?: number;
592
+ /**
593
+ * A width, in pixels.
594
+ */
595
+ width: number;
596
+ /**
597
+ * A height, in pixels.
598
+ */
599
+ height: number;
600
+ /**
601
+ * Describes how a fill is filled with color or media.
602
+ *
603
+ * @remarks
604
+ * If both `media` and `color` are defined, `media` takes precedence.
605
+ */
606
+ fill?: FillOpts;
607
+ /**
608
+ * The outline of the rect.
609
+ */
610
+ stroke?: StrokeOpts;
611
+ };
612
+ /**
613
+ * @public
614
+ * Options for creating a shape element.
615
+ */
616
+ export type CreateShapeElementOpts = {
617
+ /**
618
+ * The distance from the top edge of the container, in pixels.
619
+ *
620
+ * @remarks
621
+ * - The pixels are relative to their container.
622
+ * - Minimum: -32768
623
+ * - Maximum: 32767
624
+ */
625
+ top: number;
626
+ /**
627
+ * The distance from the left edge of the container, in pixels.
628
+ *
629
+ * @remarks
630
+ * - The pixels are relative to their container.
631
+ * - Minimum: -32768
632
+ * - Maximum: 32767
633
+ */
634
+ left: number;
635
+ /**
636
+ * A rotation, in degrees.
637
+ *
638
+ * @remarks
639
+ * - Minimum: -180
640
+ * - Maximum: 180
641
+ */
642
+ rotation?: number;
643
+ /**
644
+ * Transparency as a percentage.
645
+ *
646
+ * @remarks
647
+ * - Minimum: 0
648
+ * - Maximum: 1
649
+ */
650
+ transparency?: number;
651
+ /**
652
+ * A width, in pixels.
653
+ */
654
+ width: number;
655
+ /**
656
+ * A height, in pixels.
657
+ */
658
+ height: number;
659
+ /**
660
+ * The scale and cropping of the shape.
661
+ */
662
+ readonly viewBox: AlignedBoxState;
663
+ /**
664
+ * The paths that define the structure of the shape.
665
+ *
666
+ * @remarks
667
+ * - Must have between 1 and 30 paths.
668
+ * - Total size of all paths must not exceed 2kb.
669
+ * - Maximum of 6 unique fill colors across all paths.
670
+ */
671
+ paths: PathOpts[];
672
+ };
673
+ /**
674
+ * @public
675
+ * Options for creating an embed element.
676
+ */
677
+ export type CreateEmbedElementOpts = {
678
+ /**
679
+ * The distance from the top edge of the container, in pixels.
680
+ *
681
+ * @remarks
682
+ * - The pixels are relative to their container.
683
+ * - Minimum: -32768
684
+ * - Maximum: 32767
685
+ */
686
+ top: number;
687
+ /**
688
+ * The distance from the left edge of the container, in pixels.
689
+ *
690
+ * @remarks
691
+ * - The pixels are relative to their container.
692
+ * - Minimum: -32768
693
+ * - Maximum: 32767
694
+ */
695
+ left: number;
696
+ /**
697
+ * A rotation, in degrees.
698
+ *
699
+ * @remarks
700
+ * - Minimum: -180
701
+ * - Maximum: 180
702
+ */
703
+ rotation?: number;
704
+ /**
705
+ * Transparency as a percentage.
706
+ *
707
+ * @remarks
708
+ * - Minimum: 0
709
+ * - Maximum: 1
710
+ */
711
+ transparency?: number;
712
+ /**
713
+ * A width, in pixels.
714
+ */
715
+ width: number;
716
+ /**
717
+ * A height, in pixels.
718
+ */
719
+ height: number;
720
+ /**
721
+ * The URL of the rich media.
722
+ *
723
+ * @remarks
724
+ * This URL must be supported by the Iframely API.
725
+ */
726
+ url: string;
727
+ };
728
+ /**
729
+ * @public
730
+ * Options for creating a text element.
731
+ */
732
+ export type CreateTextElementOpts = {
733
+ /**
734
+ * The distance from the top edge of the container, in pixels.
735
+ *
736
+ * @remarks
737
+ * - The pixels are relative to their container.
738
+ * - Minimum: -32768
739
+ * - Maximum: 32767
740
+ */
741
+ top: number;
742
+ /**
743
+ * The distance from the left edge of the container, in pixels.
744
+ *
745
+ * @remarks
746
+ * - The pixels are relative to their container.
747
+ * - Minimum: -32768
748
+ * - Maximum: 32767
749
+ */
750
+ left: number;
751
+ /**
752
+ * A width, in pixels.
753
+ */
754
+ width: number;
755
+ /**
756
+ * The text content.
757
+ */
758
+ text: {
759
+ regions: readonly TextRegion[];
760
+ };
761
+ /**
762
+ * A rotation, in degrees.
763
+ *
764
+ * @remarks
765
+ * - Minimum: -180
766
+ * - Maximum: 180
767
+ */
768
+ rotation?: number;
769
+ /**
770
+ * Transparency as a percentage.
771
+ *
772
+ * @remarks
773
+ * - Minimum: 0
774
+ * - Maximum: 1
775
+ */
776
+ transparency?: number;
777
+ };
778
+ /**
779
+ * @public
780
+ * Provides methods for creating element states.
781
+ *
782
+ * @remarks
783
+ * These methods don't add the elements to the design. They only return elements that can
784
+ * be added to a design, such as with the `insertAfter` method.
785
+ *
786
+ * @preventInline
787
+ */
788
+ export interface ElementStateBuilder {
789
+ /**
790
+ * Creates a rect element state.
791
+ * @param opts - Options for creating the rect element.
792
+ */
793
+ createRectElement(opts: CreateRectElementOpts): RectElementState;
794
+ /**
795
+ * Creates a shape element state.
796
+ * @param opts - Options for creating the shape element.
797
+ */
798
+ createShapeElement(opts: CreateShapeElementOpts): ShapeElementState;
799
+ /**
800
+ * Creates an embed element state.
801
+ * @param opts - Options for creating the embed element.
802
+ */
803
+ createEmbedElement(opts: CreateEmbedElementOpts): EmbedElementState;
804
+ /**
805
+ * Creates a text element state.
806
+ * @param opts - Options for creating the text element.
807
+ */
808
+ createTextElement(opts: CreateTextElementOpts): TextElementState;
809
+ /**
810
+ * Creates a richtext range.
811
+ */
812
+ createRichtextRange(): RichtextRange;
813
+ }
814
+ /**
815
+ * @public
816
+ * Async methods for handling more complex operations.
817
+ */
818
+ export interface AsyncOperations {
819
+ /**
820
+ * Group specified elements.
821
+ *
822
+ * @param opts - Options for grouping elements.
823
+ *
824
+ * @returns a new group element containing all the given elements.
825
+ */
826
+ group(opts: AsyncOperationsGroupOpts): Promise<GroupElement>;
827
+ /**
828
+ * Ungroup a group element.
829
+ *
830
+ * @param opts - Options for ungrouping a group element.
831
+ *
832
+ * @returns new elements that are ungrouped from the given group.
833
+ */
834
+ ungroup(
835
+ opts: AsyncOperationsUngroupOpts,
836
+ ): Promise<readonly AbsoluteElement[]>;
837
+ }
838
+ /**
839
+ * @public
840
+ * Options for `group` operation.
841
+ */
842
+ export interface AsyncOperationsGroupOpts {
843
+ /**
844
+ * Elements to be grouped.
845
+ */
846
+ elements: readonly Exclude<GroupContentElement, UnsupportedElement>[];
847
+ }
848
+ /**
849
+ * @public
850
+ * Options for `ungroup` operation.
851
+ */
852
+ export interface AsyncOperationsUngroupOpts {
853
+ /**
854
+ * Group element to be ungroup.
855
+ */
856
+ element: GroupElement;
857
+ }
858
+ /**
859
+ * @public
860
+ * Helpers for use with supported pages.
861
+ *
862
+ * @remarks
863
+ * Not applicable to unsupported pages.
864
+ *
865
+ * @preventInline
866
+ */
867
+ export type PageHelpers = AsyncOperations & {
868
+ /**
869
+ * Build an element state that can be used to create an element with the `insert` methods of
870
+ * the page's element list
871
+ */
872
+ elementStateBuilder: DesignEditing.ElementStateBuilder;
873
+ };
874
+ /**
875
+ * @public
876
+ * The result of reading part of a design when the context is the current page.
877
+ */
878
+ export type CurrentPageResult<
879
+ Page = DesignEditing.Page,
880
+ Helpers = DesignEditing.PageHelpers,
881
+ > = Readonly<{
882
+ /**
883
+ * The current page of the design.
884
+ */
885
+ page: Page;
886
+ /**
887
+ * These are various utilities that allow apps to do more complex operations on the page.
888
+ */
889
+ helpers: Helpers;
890
+ /**
891
+ * Saves any changes made during the session while keeping the transaction open.
892
+ *
893
+ * @remarks
894
+ * - Any changes in the session are only reflected in the design after this method is called.
895
+ * - Once this method is called, further changes in the session can still be made.
896
+ */
897
+ sync(): Promise<void>;
898
+ }>;
899
+ /**
900
+ * A function called for each item in the list.
901
+ *
902
+ * @param item - The current item in the list.
903
+ * @param index - The index of the current item.
904
+ */
905
+ export type ForEachCallback<M> = (item: M, index: number) => void;
906
+ /**
907
+ * A function that determines if an item should be included in the result.
908
+ *
909
+ * @param item - The item to test.
910
+ * @returns `true` if the item should be included, otherwise `false`.
911
+ */
912
+ export type FilterPredicate<M> = (item: M) => boolean;
913
+ /**
914
+ * A type predicate function that determines if an item is of a specific type.
915
+ *
916
+ * @param item - The item to test.
917
+ * @returns `true` if the item is of type `C`, otherwise `false`.
918
+ */
919
+ export type TypeFilterPredicate<M, C extends M> = (item: M) => item is C;
920
+ /**
921
+ * @public
922
+ * A list that cannot be changed.
923
+ *
924
+ * @preventInline
925
+ */
926
+ export interface ReadableList<M> {
927
+ /**
928
+ * Gets the number of items in the list.
929
+ *
930
+ * @returns The number of items.
931
+ */
932
+ count(): number;
933
+ /**
934
+ * Converts the list to an array.
935
+ *
936
+ * @returns An array containing all items. The items are the same as in the list.
937
+ */
938
+ toArray(): readonly M[];
939
+ /**
940
+ * Executes a function for each item in the list.
941
+ *
942
+ * @param callback - The function to run for each item.
943
+ */
944
+ forEach(callback: ForEachCallback<M>): void;
945
+ /**
946
+ * Creates a new array with items that match a specific type.
947
+ *
948
+ * @param filter - A function that checks if an item is of type `C`.
949
+ * @returns An array of items that are of type `C`.
950
+ */
951
+ filter<C extends M>(filter: TypeFilterPredicate<M, C>): readonly C[];
952
+ /**
953
+ * Creates a new array with items that pass a test.
954
+ *
955
+ * @param filter - A function that tests each item. Returns `true` to keep the item.
956
+ * @returns An array of items that passed the test.
957
+ */
958
+ filter(filter: FilterPredicate<M>): readonly M[];
959
+ }
960
+ /**
961
+ * @public
962
+ * A list of items that can be read.
963
+ *
964
+ * @preventInline
965
+ */
966
+ export interface ListState<T> extends Iterable<T | undefined> {
967
+ join(separator?: string): string;
968
+ slice(start?: number, end?: number): EditableListState<T>;
969
+ indexOf(searchElement: T, fromIndex?: number): number;
970
+ lastIndexOf(searchElement: T, fromIndex?: number): number;
971
+ every<S extends T>(
972
+ predicate: (value: T, index: number) => value is S,
973
+ ): this is ListState<S>;
974
+ every(predicate: (value: T, index: number) => unknown): boolean;
975
+ some(predicate: (value: T, index: number) => unknown): boolean;
976
+ forEach(callbackFn: (value: T, index: number) => void): void;
977
+ map<U>(callbackFn: (value: T, index: number) => U): EditableListState<U>;
978
+ filter<S extends T>(
979
+ predicate: (value: T, index: number) => value is S,
980
+ ): S[];
981
+ filter(predicate: (value: T, index: number) => unknown): T[];
982
+ reduce(
983
+ callbackFn: (
984
+ previousValue: T,
985
+ currentValue: T,
986
+ currentIndex: number,
987
+ ) => T,
988
+ initialValue?: T,
989
+ ): T;
990
+ reduce<U>(
991
+ callbackFn: (
992
+ previousValue: U,
993
+ currentValue: T,
994
+ currentIndex: number,
995
+ ) => U,
996
+ initialValue: U,
997
+ ): U;
998
+ reduceRight(
999
+ callbackFn: (
1000
+ previousValue: T,
1001
+ currentValue: T,
1002
+ currentIndex: number,
1003
+ ) => T,
1004
+ initialValue?: T,
1005
+ ): T;
1006
+ reduceRight<U>(
1007
+ callbackFn: (
1008
+ previousValue: U,
1009
+ currentValue: T,
1010
+ currentIndex: number,
1011
+ ) => U,
1012
+ initialValue: U,
1013
+ ): U;
1014
+ find<S extends T>(
1015
+ predicate: (value: T | undefined, index: number) => value is S,
1016
+ ): S | undefined;
1017
+ find(
1018
+ predicate: (value: T | undefined, index: number) => unknown,
1019
+ ): T | undefined;
1020
+ flatMap<U>(
1021
+ callback: (value: T, index: number, array: T[]) => U | readonly U[],
1022
+ ): U[];
1023
+ readonly length: number;
1024
+ readonly [n: number]: T;
1025
+ }
1026
+ /**
1027
+ * @public
1028
+ * A list of items that can be read and updated.
1029
+ */
1030
+ export type EditableListState<T> = ListState<T> & {
1031
+ length: number;
1032
+ pop(): T | undefined;
1033
+ push(...items: T[]): number;
1034
+ shift(): T | undefined;
1035
+ splice(start: number, deleteCount?: number): EditableListState<T>;
1036
+ splice(
1037
+ start: number,
1038
+ deleteCount: number,
1039
+ ...items: T[]
1040
+ ): EditableListState<T>;
1041
+ unshift(...items: T[]): number;
1042
+ [n: number]: T;
1043
+ };
1044
+ /**
1045
+ * @public
1046
+ * A list of items that can be read and updated.
1047
+ *
1048
+ * @preventInline
1049
+ */
1050
+ export interface List<S, M> extends ReadableList<M> {
1051
+ /**
1052
+ * Adds a copy of an item to the list and places it right before another item.
1053
+ *
1054
+ * @param ref - The existing item to place the new item before.
1055
+ * If `ref` is `undefined`, the new item is added at the end of the list.
1056
+ * If `ref` does not exist in the list, the operation fails.
1057
+ *
1058
+ * @param item - The item to add. A copy of this item will be inserted.
1059
+ *
1060
+ * @returns
1061
+ * The added item, or `undefined` if the operation failed.
1062
+ */
1063
+ insertBefore(ref: M | undefined, item: S): M | undefined;
1064
+ /**
1065
+ * Adds a copy of an item to the list and places it right after another item.
1066
+ *
1067
+ * @param ref - The existing item to place the new item after.
1068
+ * If `ref` is `undefined`, the new item is added at the end of the list.
1069
+ * If `ref` does not exist in the list, the operation fails.
1070
+ *
1071
+ * @param item - The item to add. A copy of this item will be inserted.
1072
+ *
1073
+ * @returns
1074
+ * The added item, or `undefined` if the operation failed.
1075
+ */
1076
+ insertAfter(ref: M | undefined, item: S): M | undefined;
1077
+ /**
1078
+ * Moves an existing item to a new position right before another item.
1079
+ *
1080
+ * @param ref - The existing item to move the item before.
1081
+ * If `ref` is `undefined`, the item is moved to the end of the list.
1082
+ * If `ref` does not exist in the list, the operation fails.
1083
+ *
1084
+ * @param item - The item to move.
1085
+ * The operation fails if the item is not already in the list.
1086
+ */
1087
+ moveBefore(ref: M | undefined, item: M): void;
1088
+ /**
1089
+ * Moves an existing item to a new position right after another item.
1090
+ *
1091
+ * @param ref - The existing item to move the item after.
1092
+ * If `ref` is `undefined`, the item is moved to the end of the list.
1093
+ * If `ref` does not exist in the list, the operation fails.
1094
+ *
1095
+ * @param item - The item to move.
1096
+ * The operation fails if the item is not already in the list.
1097
+ */
1098
+ moveAfter(ref: M | undefined, item: M): void;
1099
+ /**
1100
+ * Removes an item from the list.
1101
+ *
1102
+ * @param item - The item to remove from the list.
1103
+ */
1104
+ delete(item: M): void;
1105
+ }
1106
+ /**
1107
+ * @public
1108
+ * Represents something that's not supported by the Apps SDK.
1109
+ */
1110
+ export interface Unsupported {
1111
+ readonly type: "unsupported";
1112
+ }
1113
+ /**
1114
+ * @public
1115
+ * A state that creates a set of dimensions.
1116
+ */
1117
+ export interface DimensionsState {
1118
+ /**
1119
+ * A width, in pixels.
1120
+ */
1121
+ readonly width: number;
1122
+ /**
1123
+ * A height, in pixels.
1124
+ */
1125
+ readonly height: number;
1126
+ }
1127
+ /**
1128
+ * @public
1129
+ * A set of dimensions.
1130
+ */
1131
+ export type Dimensions = DimensionsState;
1132
+ /**
1133
+ * @public
1134
+ * A state that creates an image fill.
1135
+ */
1136
+ export interface ImageFillState {
1137
+ /**
1138
+ * The type of media.
1139
+ */
1140
+ readonly type: "image";
1141
+ /**
1142
+ * A unique identifier that points to an image asset in Canva's backend.
1143
+ */
1144
+ readonly imageRef: ImageRef;
1145
+ /**
1146
+ * If `true`, the image is flipped horizontally.
1147
+ */
1148
+ flipX: boolean;
1149
+ /**
1150
+ * If `true`, the image is flipped vertically.
1151
+ */
1152
+ flipY: boolean;
1153
+ }
1154
+ /**
1155
+ * @public
1156
+ * An image that fills the interior of a media.
1157
+ */
1158
+ export type ImageFill = ImageFillState;
1159
+ /**
1160
+ * @public
1161
+ * A state that creates a video fill.
1162
+ */
1163
+ export interface VideoFillState {
1164
+ /**
1165
+ * The type of media.
1166
+ */
1167
+ readonly type: "video";
1168
+ /**
1169
+ * A unique identifier that points to a video asset in Canva's backend.
1170
+ */
1171
+ readonly videoRef: VideoRef;
1172
+ /**
1173
+ * If `true`, the video is flipped horizontally.
1174
+ */
1175
+ flipX: boolean;
1176
+ /**
1177
+ * If `true`, the video is flipped vertically.
1178
+ */
1179
+ flipY: boolean;
1180
+ }
1181
+ /**
1182
+ * @public
1183
+ * A video that fills the interior of a media.
1184
+ */
1185
+ export type VideoFill = VideoFillState;
1186
+ /**
1187
+ * @public
1188
+ * A state that creates a media fill.
1189
+ */
1190
+ export type MediaFillState = ImageFillState | VideoFillState;
1191
+ /**
1192
+ * @public
1193
+ * A media item that fills an interior.
1194
+ */
1195
+ export type MediaFill = ImageFill | VideoFill;
1196
+ /**
1197
+ * @public
1198
+ * A state that creates a solid color fill.
1199
+ */
1200
+ export interface SolidFillState {
1201
+ /**
1202
+ * The type of color.
1203
+ */
1204
+ readonly type: "solid";
1205
+ /**
1206
+ * The color of the fill.
1207
+ * This must be a valid, six-digit hex code, prefixed with a `#` symbol.
1208
+ *
1209
+ * @remarks
1210
+ * - Must be six characters long.
1211
+ * - Must start with a `#`.
1212
+ * - Must use lowercase letters.
1213
+ * @example "#ff0099"
1214
+ */
1215
+ color: string;
1216
+ }
1217
+ /**
1218
+ * @public
1219
+ * A solid color that fills an interior.
1220
+ */
1221
+ export type SolidFill = SolidFillState;
1222
+ /**
1223
+ * @public
1224
+ * A state that creates a color fill.
1225
+ */
1226
+ export type ColorFillState = SolidFillState | Unsupported;
1227
+ /**
1228
+ * @public
1229
+ * A color that fills an interior.
1230
+ */
1231
+ export type ColorFill = SolidFill | Unsupported;
1232
+ /**
1233
+ * @public
1234
+ * A state that creates a fill with color or media.
1235
+ *
1236
+ * @remarks
1237
+ * If both `media` and `color` are defined, `media` takes precedence.
1238
+ */
1239
+ export interface FillState {
1240
+ /**
1241
+ * The media fill for the path, if any.
1242
+ */
1243
+ mediaContainer: MediaFillState | undefined;
1244
+ /**
1245
+ * The color fill for the path, if any.
1246
+ */
1247
+ colorContainer: ColorFillState | undefined;
1248
+ }
1249
+ /**
1250
+ * @public
1251
+ * A state that creates a shape path fill with color or media.
1252
+ *
1253
+ * @remarks
1254
+ * If both `media` and `color` are defined, `media` takes precedence.
1255
+ */
1256
+ export interface PathFillState {
1257
+ /**
1258
+ * Defines whether the media fill is editable.
1259
+ */
1260
+ isMediaEditable: boolean;
1261
+ /**
1262
+ * The media fill for the path, if any.
1263
+ */
1264
+ mediaContainer: MediaFillState | undefined;
1265
+ /**
1266
+ * The color fill for the path, if any.
1267
+ */
1268
+ colorContainer: ColorFillState | undefined;
1269
+ }
1270
+ /**
1271
+ * @public
1272
+ * Describes how a fill of a shape path is filled with color or media.
1273
+ *
1274
+ * @remarks
1275
+ * If both `media` and `color` are defined, `media` takes precedence.
1276
+ */
1277
+ export type PathFill =
1278
+ | PathFillWithEditableMedia
1279
+ | PathFillWithNonEditableMedia;
1280
+ export interface PathFillWithEditableMedia {
1281
+ readonly isMediaEditable: true;
1282
+ /**
1283
+ * A media fill, if any.
1284
+ */
1285
+ readonly mediaContainer: {
1286
+ set(state: MediaFillState | undefined): void;
1287
+ ref: MediaFill | undefined;
1288
+ };
1289
+ /**
1290
+ * A color fill, if any.
1291
+ */
1292
+ readonly colorContainer: {
1293
+ set(state: SolidFillState | undefined): void;
1294
+ ref: ColorFill | undefined;
1295
+ };
1296
+ }
1297
+ export interface PathFillWithNonEditableMedia {
1298
+ readonly isMediaEditable: false;
1299
+ /**
1300
+ * A media fill, if any.
1301
+ * MediaFill is not editable
1302
+ */
1303
+ readonly mediaContainer: {
1304
+ ref: MediaFill | undefined;
1305
+ };
1306
+ /**
1307
+ * A color fill, if any.
1308
+ */
1309
+ readonly colorContainer: {
1310
+ set(state: SolidFillState | undefined): void;
1311
+ ref: ColorFill | undefined;
1312
+ };
1313
+ }
1314
+ /**
1315
+ * @public
1316
+ * Describes how a fill is filled with color or media.
1317
+ *
1318
+ * @remarks
1319
+ * If both `media` and `color` are defined, `media` takes precedence.
1320
+ *
1321
+ * @preventInline
1322
+ */
1323
+ export interface Fill {
1324
+ /**
1325
+ * A media fill, if any.
1326
+ */
1327
+ readonly mediaContainer: {
1328
+ set(state: MediaFillState | undefined): void;
1329
+ ref: MediaFill | undefined;
1330
+ };
1331
+ /**
1332
+ * A color fill, if any.
1333
+ */
1334
+ readonly colorContainer: {
1335
+ set(state: SolidFillState | undefined): void;
1336
+ ref: ColorFill | undefined;
1337
+ };
1338
+ }
1339
+ /**
1340
+ * @public
1341
+ * A state that creates the scale and cropping of a shape.
1342
+ *
1343
+ * @remarks
1344
+ * This is similar to the `viewBox` attribute of an `SVGElement`.
1345
+ */
1346
+ export interface AlignedBoxState {
1347
+ /**
1348
+ * The distance of the shape from the top edge of the element, in pixels.
1349
+ */
1350
+ readonly top: number;
1351
+ /**
1352
+ * The distance of the shape from the left edge of the element, in pixels.
1353
+ */
1354
+ readonly left: number;
1355
+ /**
1356
+ * The width of the view box, in pixels.
1357
+ */
1358
+ readonly width: number;
1359
+ /**
1360
+ * The height of the view box, in pixels.
1361
+ */
1362
+ readonly height: number;
1363
+ }
1364
+ /**
1365
+ * @public
1366
+ * The scale and cropping of a shape.
1367
+ *
1368
+ * @remarks
1369
+ * This is similar to the `viewBox` attribute of an `SVGElement`.
1370
+ */
1371
+ export type AlignedBox = AlignedBoxState;
1372
+ /**
1373
+ * @public
1374
+ * A state that creates a path that defines the structure of a shape element.
1375
+ */
1376
+ export interface PathState {
1377
+ /**
1378
+ * The shape of the path.
1379
+ *
1380
+ * @remarks
1381
+ * This is similar to the `d` attribute of an SVG's `path` element, with some limitations:
1382
+ *
1383
+ * - Must start with an `M` command.
1384
+ * - Only one `M` command is allowed.
1385
+ * - `Q` and `T` commands are not permitted.
1386
+ * - The path must be closed using a `Z` command or matching start and end coordinates.
1387
+ */
1388
+ readonly d: string;
1389
+ /**
1390
+ * The appearance of the path's interior.
1391
+ */
1392
+ readonly fill: PathFillState;
1393
+ /**
1394
+ * The stroke (outline) of the path, if any.
1395
+ */
1396
+ readonly stroke: StrokeState | undefined;
1397
+ }
1398
+ /**
1399
+ * @public
1400
+ * A path that defines the structure of a shape element.
1401
+ *
1402
+ * @preventInline
1403
+ */
1404
+ export type Path = {
1405
+ /**
1406
+ * The shape of the path.
1407
+ *
1408
+ * @remarks
1409
+ * This is similar to the `d` attribute of an SVG's `path` element, with some limitations:
1410
+ *
1411
+ * - Must start with an `M` command.
1412
+ * - Only one `M` command is allowed.
1413
+ * - `Q` and `T` commands are not permitted.
1414
+ * - The path must be closed using a `Z` command or matching start and end coordinates.
1415
+ */
1416
+ readonly d: string;
1417
+ /**
1418
+ * The appearance of the path's interior.
1419
+ */
1420
+ readonly fill: PathFill;
1421
+ /**
1422
+ * The stroke (outline) of the path, if any.
1423
+ */
1424
+ readonly stroke: Stroke | undefined;
1425
+ };
1426
+ /**
1427
+ * @public
1428
+ * A state that creates an outline, such as the border of an element.
1429
+ */
1430
+ export interface StrokeState {
1431
+ /**
1432
+ * The weight (thickness) of the stroke.
1433
+ *
1434
+ * @remarks
1435
+ * - Minimum: 0
1436
+ * - Maximum: 100
1437
+ */
1438
+ weight: number;
1439
+ /**
1440
+ * The color of the stroke.
1441
+ */
1442
+ colorContainer: ColorFillState;
1443
+ }
1444
+ /**
1445
+ * @public
1446
+ * Represents an outline, such as the border of an element.
1447
+ *
1448
+ * @preventInline
1449
+ */
1450
+ export type Stroke = {
1451
+ /**
1452
+ * The weight (thickness) of the stroke.
1453
+ *
1454
+ * @remarks
1455
+ * - Minimum: 0
1456
+ * - Maximum: 100
1457
+ */
1458
+ weight: number;
1459
+ /**
1460
+ * The color of the stroke.
1461
+ */
1462
+ readonly colorContainer: {
1463
+ ref: ColorFill;
1464
+ set(state: SolidFillState): void;
1465
+ };
1466
+ };
1467
+ /**
1468
+ * @public
1469
+ * The basic properties of the state of an element.
1470
+ *
1471
+ * @remarks
1472
+ * These properties are shared by all elements in a design.
1473
+ */
1474
+ export interface ElementState extends DimensionsState {
1475
+ /**
1476
+ * If `true`, the element is locked and cannot be modified.
1477
+ */
1478
+ readonly locked: boolean;
1479
+ /**
1480
+ * The distance from the top edge of the container, in pixels.
1481
+ *
1482
+ * @remarks
1483
+ * - The pixels are relative to their container.
1484
+ * - Minimum: -32768
1485
+ * - Maximum: 32767
1486
+ */
1487
+ readonly top: number;
1488
+ /**
1489
+ * The distance from the left edge of the container, in pixels.
1490
+ *
1491
+ * @remarks
1492
+ * - The pixels are relative to their container.
1493
+ * - Minimum: -32768
1494
+ * - Maximum: 32767
1495
+ */
1496
+ readonly left: number;
1497
+ /**
1498
+ * A rotation, in degrees.
1499
+ *
1500
+ * @remarks
1501
+ * - Minimum: -180
1502
+ * - Maximum: 180
1503
+ */
1504
+ readonly rotation: number;
1505
+ /**
1506
+ * Transparency as a percentage.
1507
+ *
1508
+ * @remarks
1509
+ * - Minimum: 0
1510
+ * - Maximum: 1
1511
+ */
1512
+ readonly transparency: number;
1513
+ }
1514
+ /**
1515
+ * @public
1516
+ * The basic properties of an element.
1517
+ *
1518
+ * @remarks
1519
+ * These properties are shared by all elements in a design.
1520
+ */
1521
+ export type Element = DimensionsState & {
1522
+ /**
1523
+ * If `true`, the element is locked and cannot be modified.
1524
+ */
1525
+ readonly locked: boolean;
1526
+ /**
1527
+ * The distance from the top edge of the container, in pixels.
1528
+ *
1529
+ * @remarks
1530
+ * - The pixels are relative to their container.
1531
+ * - Minimum: -32768
1532
+ * - Maximum: 32767
1533
+ */
1534
+ top: number;
1535
+ /**
1536
+ * The distance from the left edge of the container, in pixels.
1537
+ *
1538
+ * @remarks
1539
+ * - The pixels are relative to their container.
1540
+ * - Minimum: -32768
1541
+ * - Maximum: 32767
1542
+ */
1543
+ left: number;
1544
+ /**
1545
+ * A rotation, in degrees.
1546
+ *
1547
+ * @remarks
1548
+ * - Minimum: -180
1549
+ * - Maximum: 180
1550
+ */
1551
+ rotation: number;
1552
+ /**
1553
+ * Transparency as a percentage.
1554
+ *
1555
+ * @remarks
1556
+ * - Minimum: 0
1557
+ * - Maximum: 1
1558
+ */
1559
+ transparency: number;
1560
+ };
1561
+ /**
1562
+ * @public
1563
+ * A state that creates a rectangular element.
1564
+ */
1565
+ export interface RectState {
1566
+ /**
1567
+ * The type of content.
1568
+ */
1569
+ readonly type: "rect";
1570
+ /**
1571
+ * The appearance of the rectangle's interior.
1572
+ */
1573
+ readonly fill: FillState;
1574
+ /**
1575
+ * The outline of the rectangle.
1576
+ */
1577
+ readonly stroke: StrokeState;
1578
+ }
1579
+ /**
1580
+ * @public
1581
+ * Represents a rectangular element.
1582
+ */
1583
+ export type Rect = {
1584
+ /**
1585
+ * The element type
1586
+ */
1587
+ readonly type: "rect";
1588
+ readonly fill: Fill;
1589
+ /**
1590
+ * The outline of the rectangle.
1591
+ */
1592
+ readonly stroke: Stroke;
1593
+ };
1594
+ /**
1595
+ * @public
1596
+ * A state that creates a vector shape element.
1597
+ */
1598
+ export interface ShapeState {
1599
+ /**
1600
+ * The type of content.
1601
+ */
1602
+ readonly type: "shape";
1603
+ /**
1604
+ * The scale and cropping of the shape.
1605
+ */
1606
+ readonly viewBox: AlignedBoxState;
1607
+ /**
1608
+ * The paths that define the structure of the shape.
1609
+ *
1610
+ * @remarks
1611
+ * - Must have between 1 and 30 paths.
1612
+ * - Total size of all paths must not exceed 2kb.
1613
+ * - Maximum of 6 unique fill colors across all paths.
1614
+ */
1615
+ readonly paths: ListState<PathState>;
1616
+ }
1617
+ /**
1618
+ * @public
1619
+ * Represents a vector shape element.
1620
+ */
1621
+ export type Shape = {
1622
+ /**
1623
+ * The type of content.
1624
+ */
1625
+ readonly type: "shape";
1626
+ /**
1627
+ * The scale and cropping of the shape.
1628
+ */
1629
+ readonly viewBox: AlignedBox;
1630
+ /**
1631
+ * The paths that define the structure of the shape.
1632
+ */
1633
+ readonly paths: ReadableList<Path>;
1634
+ };
1635
+ /**
1636
+ * @public
1637
+ * A state that creates group content.
1638
+ */
1639
+ export interface GroupState {
1640
+ /**
1641
+ * The type of content.
1642
+ */
1643
+ readonly type: "group";
1644
+ /**
1645
+ * The elements that exist within the group.
1646
+ */
1647
+ readonly contents: ListState<GroupContentElementState>;
1648
+ }
1649
+ /**
1650
+ * @public
1651
+ * Represents group content.
1652
+ */
1653
+ export type Group = {
1654
+ /**
1655
+ * The type of content.
1656
+ */
1657
+ readonly type: "group";
1658
+ /**
1659
+ * The elements that exist within the group.
1660
+ */
1661
+ readonly contents: ReadableList<GroupContentElement>;
1662
+ };
1663
+ /**
1664
+ * @public
1665
+ * A state that creates rich media content.
1666
+ */
1667
+ export interface EmbedState {
1668
+ /**
1669
+ * The type of content.
1670
+ */
1671
+ readonly type: "embed";
1672
+ /**
1673
+ * The URL of the rich media.
1674
+ *
1675
+ * @remarks
1676
+ * This URL must be supported by the Iframely API.
1677
+ */
1678
+ readonly url: string;
1679
+ }
1680
+ /**
1681
+ * @public
1682
+ * Represents rich media content.
1683
+ */
1684
+ export type Embed = EmbedState;
1685
+ /**
1686
+ * @public
1687
+ * A state that creates text content.
1688
+ */
1689
+ export interface TextState {
1690
+ /**
1691
+ * The type of content.
1692
+ */
1693
+ readonly type: "text";
1694
+ /**
1695
+ * The text content.
1696
+ */
1697
+ readonly text: {
1698
+ regions: ListState<TextRegion>;
1699
+ };
1700
+ }
1701
+ /**
1702
+ * @public
1703
+ * Represents text content.
1704
+ */
1705
+ export type Text = {
1706
+ readonly type: "text";
1707
+ readonly text: RichtextRange;
1708
+ };
1709
+ /**
1710
+ * @public
1711
+ * A state that creates a rectangle element.
1712
+ *
1713
+ * @remarks
1714
+ * The rectangle can be filled with image content, video content, or a solid color.
1715
+ */
1716
+ export type RectElementState = RectState & ElementState;
1717
+ /**
1718
+ * @public
1719
+ * An element that renders a rectangle.
1720
+ *
1721
+ * @remarks
1722
+ * The rectangle can be filled with image content, video content, or a solid color.
1723
+ */
1724
+ export type RectElement = Rect & Element;
1725
+ /**
1726
+ * @public
1727
+ * A state that creates a vector shape element.
1728
+ */
1729
+ export type ShapeElementState = ShapeState & ElementState;
1730
+ /**
1731
+ * @public
1732
+ * An element that renders a vector shape.
1733
+ */
1734
+ export type ShapeElement = Shape & Element;
1735
+ /**
1736
+ * @public
1737
+ * A state that creates a group element.
1738
+ */
1739
+ export type GroupElementState = GroupState & ElementState;
1740
+ /**
1741
+ * @public
1742
+ * An element that renders a group of other elements.
1743
+ */
1744
+ export type GroupElement = Group & Element;
1745
+ /**
1746
+ * @public
1747
+ * A state that creates an embed element, such as a YouTube video.
1748
+ */
1749
+ export type EmbedElementState = EmbedState & ElementState;
1750
+ /**
1751
+ * @public
1752
+ * An element that embeds rich media, such as a YouTube video.
1753
+ */
1754
+ export type EmbedElement = Embed & Element;
1755
+ /**
1756
+ * @public
1757
+ * A state that creates a text element.
1758
+ */
1759
+ export type TextElementState = TextState & ElementState;
1760
+ /**
1761
+ * @public
1762
+ * An element that renders text content.
1763
+ */
1764
+ export type TextElement = Text & Element;
1765
+ /**
1766
+ * @public
1767
+ * An element state that is not supported by the Apps SDK.
1768
+ */
1769
+ export type UnsupportedElementState = Unsupported & ElementState;
1770
+ /**
1771
+ * @public
1772
+ * An element that is not supported by the Apps SDK.
1773
+ */
1774
+ export type UnsupportedElement = Unsupported & Readonly<Element>;
1775
+ /**
1776
+ * @public
1777
+ * An element state that can exist in a group content state.
1778
+ */
1779
+ export type GroupContentElementState =
1780
+ | RectElementState
1781
+ | ShapeElementState
1782
+ | EmbedElementState
1783
+ | TextElementState
1784
+ | UnsupportedElementState;
1785
+ /**
1786
+ * @public
1787
+ * An element that can exist in a group element.
1788
+ *
1789
+ * @preventInline
1790
+ */
1791
+ export type GroupContentElement =
1792
+ | RectElement
1793
+ | ShapeElement
1794
+ | EmbedElement
1795
+ | TextElement
1796
+ | UnsupportedElement;
1797
+ /**
1798
+ * @public
1799
+ * An element state that can exist on an absolute page state.
1800
+ *
1801
+ * @preventInline
1802
+ */
1803
+ export type AbsoluteElementState =
1804
+ | RectElementState
1805
+ | ShapeElementState
1806
+ | GroupElementState
1807
+ | EmbedElementState
1808
+ | TextElementState
1809
+ | UnsupportedElementState;
1810
+ /**
1811
+ * @public
1812
+ * An element that can exist on an absolute page.
1813
+ *
1814
+ * @preventInline
1815
+ */
1816
+ export type AbsoluteElement =
1817
+ | RectElement
1818
+ | ShapeElement
1819
+ | GroupElement
1820
+ | EmbedElement
1821
+ | TextElement
1822
+ | UnsupportedElement;
1823
+ /**
1824
+ * @public
1825
+ * A list of elements.
1826
+ *
1827
+ * @preventInline
1828
+ */
1829
+ export interface ElementList
1830
+ extends List<AbsoluteElementState, AbsoluteElement> {
1831
+ insertBefore(
1832
+ ref: AbsoluteElement | undefined,
1833
+ state: EmbedElementState,
1834
+ ): EmbedElement;
1835
+ insertBefore(
1836
+ ref: AbsoluteElement | undefined,
1837
+ state: TextElementState,
1838
+ ): TextElement;
1839
+ insertBefore(
1840
+ ref: AbsoluteElement | undefined,
1841
+ state: ShapeElementState,
1842
+ ): ShapeElement;
1843
+ insertBefore(
1844
+ ref: AbsoluteElement | undefined,
1845
+ state: RectElementState,
1846
+ ): RectElement;
1847
+ insertAfter(
1848
+ ref: AbsoluteElement | undefined,
1849
+ state: EmbedElementState,
1850
+ ): EmbedElement;
1851
+ insertAfter(
1852
+ ref: AbsoluteElement | undefined,
1853
+ state: TextElementState,
1854
+ ): TextElement;
1855
+ insertAfter(
1856
+ ref: AbsoluteElement | undefined,
1857
+ state: ShapeElementState,
1858
+ ): ShapeElement;
1859
+ insertAfter(
1860
+ ref: AbsoluteElement | undefined,
1861
+ state: RectElementState,
1862
+ ): RectElement;
1863
+ }
1864
+
1865
+ /**
1866
+ * @public
1867
+ * A page with either fixed or unbounded dimensions.
1868
+ *
1869
+ * @preventInline
1870
+ */
1871
+ export type AbsolutePage = {
1872
+ /**
1873
+ * The type of page.
1874
+ */
1875
+ readonly type: "absolute";
1876
+ /**
1877
+ * If `true`, the page is locked and cannot be modified.
1878
+ */
1879
+ readonly locked: boolean;
1880
+ /**
1881
+ * The dimensions of the page. `dimensions` is undefined for whiteboard pages.
1882
+ */
1883
+ readonly dimensions: Dimensions | undefined;
1884
+ /**
1885
+ * The background of the page. `background` is undefined for whiteboard pages.
1886
+ */
1887
+ readonly background: Fill | undefined;
1888
+ /**
1889
+ * The elements on the page.
1890
+ *
1891
+ * @remarks
1892
+ * Elements are rendered in the order they appear in the list.
1893
+ * Later elements appear on top of earlier ones.
1894
+ */
1895
+ readonly elements: ElementList;
1896
+ };
1897
+ /**
1898
+ * @public
1899
+ * A page in a design.
1900
+ *
1901
+ * @remarks
1902
+ * - Currently, only absolute pages are supported.
1903
+ * - Other page types are represented as `Unsupported`.
1904
+ * - Additional page types may be supported in future releases.
1905
+ */
1906
+ export type Page = AbsolutePage | Unsupported;
1907
+ {
1908
+ }
1909
+ }
356
1910
 
357
1911
  /**
358
1912
  * @public
359
- * Options for configuring where content in a design should be queried from.
1913
+ * An element that's natively supported by the Canva editor.
360
1914
  */
361
- declare type ContextOptions = {
362
- target: "current_page";
363
- };
1915
+ export declare type DesignElement =
1916
+ | ImageElement
1917
+ | VideoElement
1918
+ | EmbedElement
1919
+ | TextElement
1920
+ | ShapeElement
1921
+ | GroupElement
1922
+ | RichtextElement
1923
+ | TableElement;
364
1924
 
365
1925
  /**
366
- * @public
367
- * A set of X and Y coordinates.
1926
+ * @beta
1927
+ * Information about the design.
368
1928
  */
369
- export declare type Coordinates = {
1929
+ export declare type DesignMetadata = {
370
1930
  /**
371
- * X coordinate, in pixels.
1931
+ * The title of the user's design.
1932
+ * @remarks
1933
+ * This is optional and will be `undefined` if the user hasn't set a title.
372
1934
  */
373
- x: number;
1935
+ title?: string;
374
1936
  /**
375
- * Y coordinate, in pixels.
1937
+ * The default dimensions that a new page will have when it is added to a design.
1938
+ * It is possible for a user to resize a page without resizing the entire design, e.g. by clicking
1939
+ * "Expand to Whiteboard". However, there will always be a single set of default dimensions for a
1940
+ * design that is applied whenever a new page is created.
1941
+ * @remarks
1942
+ * This is optional and will be `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
376
1943
  */
377
- y: number;
1944
+ defaultPageDimensions?: PageDimensions;
1945
+ /**
1946
+ * The information associated with each page of the design.
1947
+ * @remarks
1948
+ * The order of pages is not guaranteed.
1949
+ */
1950
+ pageMetadata: Iterable<PageContext>;
1951
+ /**
1952
+ * The duration of the whole design in seconds.
1953
+ * @remarks
1954
+ * This is the precise value, which differs from what is displayed in the UI as duration in Canva UI is formatted differently.
1955
+ */
1956
+ durationInSeconds: number;
378
1957
  };
379
1958
 
380
1959
  /**
381
1960
  * @public
382
- * Creates a new RichtextRange object, which contains methods to manipulate text.
1961
+ * A callback for reading and updating part of a design.
1962
+ * @param session - The result of reading part of a design.
383
1963
  */
384
- export declare const createRichtextRange: () => RichtextRange;
1964
+ export declare type DesignOpenCallback = (
1965
+ session: DesignEditing.CurrentPageResult,
1966
+ ) => Promise<void>;
385
1967
 
386
1968
  /**
387
1969
  * @public
388
- * An element that's natively supported by the Canva editor.
1970
+ * Options for configuring which part of a design to read.
389
1971
  */
390
- export declare type DesignElement =
391
- | ImageElement
392
- | VideoElement
393
- | EmbedElement
394
- | TextElement
395
- | ShapeElement
396
- | GroupElement
397
- | RichtextElement
398
- | TableElement;
1972
+ export declare type DesignOpenOptions = DesignContextOptions;
399
1973
 
400
1974
  /**
401
1975
  * @public
@@ -490,38 +2064,48 @@ export declare type DragStartEvent<E extends Element> = Pick<
490
2064
  * @param callback - A callback for operating on the read content.
491
2065
  */
492
2066
  export declare const editContent: (
493
- options: EditContentOptions,
494
- callback: EditContentCallback,
2067
+ options: EditContentOptions_2,
2068
+ callback: EditContentCallback_2,
495
2069
  ) => Promise<void>;
496
2070
 
2071
+ /**
2072
+ * @beta
2073
+ * A callback for reading and updating the requested design content.
2074
+ * @param session - The result of reading the content in the design.
2075
+ */
2076
+ export declare type EditContentCallback = (
2077
+ session: RichtextContentSession | ContentFillSession,
2078
+ ) => Promise<void> | void;
2079
+
497
2080
  /**
498
2081
  * @public
499
2082
  * A callback for reading and updating the requested design content.
500
2083
  * @param session - The result of reading the content in the design.
501
2084
  */
502
- export declare type EditContentCallback = (session: {
503
- /**
504
- * The individual content items returned by a query.
505
- */
506
- readonly contents: readonly RichtextContentRange[];
2085
+ declare type EditContentCallback_2 = (
2086
+ session: RichtextContentSession,
2087
+ ) => Promise<void> | void;
2088
+
2089
+ /**
2090
+ * @beta
2091
+ * Options for configuring how the design content is read.
2092
+ */
2093
+ export declare type EditContentOptions = {
507
2094
  /**
508
- * Commits any changes made to the items in the `contents` array.
509
- *
510
- * @remarks
511
- * An app must call this method for any changes to be reflected in the user's design.
2095
+ * The type of content to edit from the user's design
512
2096
  */
513
- sync(): Promise<void>;
514
- }) => Promise<void> | void;
2097
+ contentType: ContentType;
2098
+ } & ContextOptions;
515
2099
 
516
2100
  /**
517
2101
  * @public
518
2102
  * Options for configuring how the design content is read.
519
2103
  */
520
- export declare type EditContentOptions = {
2104
+ declare type EditContentOptions_2 = {
521
2105
  /**
522
2106
  * The type of content to edit from the user's design
523
2107
  */
524
- contentType: ContentType;
2108
+ contentType: ContentType_2;
525
2109
  } & ContextOptions;
526
2110
 
527
2111
  /**
@@ -797,6 +2381,12 @@ export declare const getDefaultPageDimensions: () => Promise<
797
2381
  Dimensions | undefined
798
2382
  >;
799
2383
 
2384
+ /**
2385
+ * @beta
2386
+ * Retrieves information about the design.
2387
+ */
2388
+ export declare const getDesignMetadata: () => Promise<DesignMetadata>;
2389
+
800
2390
  /**
801
2391
  * @public
802
2392
  * Retrieves a signed JWT that contains the Design ID, App ID and User ID.
@@ -1137,6 +2727,19 @@ export declare type NativeVideoElementWithBox = VideoElementAtPoint;
1137
2727
  */
1138
2728
  declare type ObjectPrimitive = Boolean | String;
1139
2729
 
2730
+ /**
2731
+ * @public
2732
+ *
2733
+ * Reads a specified part of the user's design and returns all elements in that part.
2734
+ *
2735
+ * @param options - Options for configuring how the design is read.
2736
+ * @param callback - A callback for operating on the design.
2737
+ */
2738
+ export declare const openDesign: (
2739
+ options: DesignOpenOptions,
2740
+ callback: DesignOpenCallback,
2741
+ ) => Promise<void>;
2742
+
1140
2743
  /**
1141
2744
  * @public
1142
2745
  * An alias for the DesignOverlay interface, providing access to design overlay related functionality
@@ -1325,6 +2928,15 @@ export declare interface RichtextContentRange extends RichtextRange {
1325
2928
  readonly deleted: boolean;
1326
2929
  }
1327
2930
 
2931
+ /**
2932
+ * @public
2933
+ * Session for reading and updating richtext content in a user's design.
2934
+ */
2935
+ export declare interface RichtextContentSession {
2936
+ readonly contents: readonly RichtextContentRange[];
2937
+ sync(): Promise<void>;
2938
+ }
2939
+
1328
2940
  /**
1329
2941
  * @public
1330
2942
  * An element that renders richtext content.
@@ -1797,6 +3409,11 @@ export declare type TextDragConfig = {
1797
3409
  * @defaultValue "none"
1798
3410
  */
1799
3411
  decoration?: "none" | "underline";
3412
+ /**
3413
+ * @beta
3414
+ * A unique identifier that points to a font asset in Canva's backend.
3415
+ */
3416
+ fontRef?: FontRef;
1800
3417
  };
1801
3418
 
1802
3419
  /**