@canva/design 2.2.0-beta.1 → 2.2.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.
@@ -10,7 +10,7 @@ export declare const addAudioTrack: (audioTrack: AudioTrack) => Promise<void>;
10
10
  * Add element to responsive documents, which slot things into a text stream
11
11
  */
12
12
  export declare const addElementAtCursor: (
13
- element: ElementAtCursor | TableElement
13
+ element: ElementAtCursor
14
14
  ) => Promise<void>;
15
15
 
16
16
  /**
@@ -18,7 +18,7 @@ export declare const addElementAtCursor: (
18
18
  * Add element to fixed designs, which use a coordinate-based positioning system.
19
19
  */
20
20
  export declare const addElementAtPoint: (
21
- element: DesignElement | ElementAtPoint | TableElement | RichtextElement
21
+ element: DesignElement | ElementAtPoint
22
22
  ) => Promise<void>;
23
23
 
24
24
  /**
@@ -145,7 +145,7 @@ export declare type AppElementRenderer<A extends AppElementData> = (
145
145
  * @public
146
146
  * An array of one or more elements to render as output of an app element.
147
147
  */
148
- export declare type AppElementRendererOutput = NativeSimpleElementWithBox[];
148
+ export declare type AppElementRendererOutput = GroupContentAtPoint[];
149
149
 
150
150
  /**
151
151
  * @public
@@ -225,7 +225,7 @@ export declare type Bounds = {
225
225
  * @remarks
226
226
  * The position and dimensions are relative to the container.
227
227
  */
228
- export declare type Box = Position & (WidthAndHeight | Width | Height);
228
+ export declare type Box = Point & (WidthAndHeight | Width | Height);
229
229
 
230
230
  /**
231
231
  * @public
@@ -328,14 +328,6 @@ export declare interface ContentDraft<T> {
328
328
  */
329
329
  export declare type ContentType = "richtext";
330
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
331
  /**
340
332
  * @public
341
333
  * A set of X and Y coordinates.
@@ -355,747 +347,21 @@ export declare type Coordinates = {
355
347
  * @public
356
348
  * Creates a new RichtextRange object, which contains methods to manipulate text.
357
349
  */
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.
994
- */
995
- export interface GroupElement extends Group<GroupContentElement>, Element {}
996
- /**
997
- * @beta
998
- * An element that embeds rich media, such as a YouTube video.
999
- */
1000
- export interface EmbedElement extends Embed, Element {}
1001
- /**
1002
- * @beta
1003
- * An element that renders text content.
1004
- */
1005
- export interface TextElement extends Text, Element {}
1006
- /**
1007
- * @beta
1008
- * An element that is not supported by the Apps SDK.
1009
- */
1010
- export interface UnsupportedElement extends Unsupported, Element {}
1011
- /**
1012
- * @beta
1013
- * An element that can exist in a group element.
1014
- */
1015
- export type GroupContentElement =
1016
- | RectElement
1017
- | ShapeElement
1018
- | EmbedElement
1019
- | TextElement
1020
- | UnsupportedElement;
1021
- /**
1022
- * @beta
1023
- * An element that can exist on a fixed page.
1024
- */
1025
- export type FixedElement =
1026
- | RectElement
1027
- | ShapeElement
1028
- | GroupElement
1029
- | EmbedElement
1030
- | TextElement
1031
- | UnsupportedElement;
1032
- /**
1033
- * @beta
1034
- * A page with fixed dimensions.
1035
- */
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
- }
1062
- /**
1063
- * @beta
1064
- * A page in a design.
1065
- */
1066
- export type Page = FixedPage | Unsupported;
1067
-
1068
- {
1069
- }
1070
- }
350
+ export declare const createRichtextRange: () => RichtextRange;
1071
351
 
1072
352
  /**
1073
353
  * @public
1074
354
  * An element that's natively supported by the Canva editor.
1075
355
  */
1076
- export declare type DesignElement = NativeElement;
1077
-
1078
- /**
1079
- * @beta
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.
1083
- */
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;
1093
-
1094
- /**
1095
- * @beta
1096
- * Options for configuring which part of a design to read.
1097
- */
1098
- export declare type DesignOpenOptions = DesignContextOptions;
356
+ export declare type DesignElement =
357
+ | ImageElement
358
+ | VideoElement
359
+ | EmbedElement
360
+ | TextElement
361
+ | ShapeElement
362
+ | GroupElement
363
+ | RichtextElement
364
+ | TableElement;
1099
365
 
1100
366
  /**
1101
367
  * @public
@@ -1206,14 +472,6 @@ export declare type DragStartEvent<E extends Element> = Pick<
1206
472
  currentTarget: E;
1207
473
  };
1208
474
 
1209
- /**
1210
- * @beta
1211
- * Options for configuring how a design is read.
1212
- */
1213
- export declare type EditContentOptions<T extends ContentType> = {
1214
- contentType: T;
1215
- } & ContextOptions;
1216
-
1217
475
  /**
1218
476
  * @public
1219
477
  * Elements targeting a cursor are a subset of the base Element
@@ -1223,14 +481,20 @@ export declare type ElementAtCursor =
1223
481
  | VideoElement
1224
482
  | EmbedElement
1225
483
  | TextElement
1226
- | RichtextElement;
484
+ | RichtextElement
485
+ | TableElement;
1227
486
 
1228
487
  /**
1229
488
  * @public
1230
489
  * An element that's natively supported by the Canva editor and has positional properties.
1231
490
  */
1232
491
  export declare type ElementAtPoint =
1233
- | NativeElementWithBox
492
+ | ImageElementAtPoint
493
+ | VideoElementAtPoint
494
+ | EmbedElementAtPoint
495
+ | TextElementAtPoint
496
+ | ShapeElementAtPoint
497
+ | GroupElementAtPoint
1234
498
  | RichtextElementAtPoint;
1235
499
 
1236
500
  /**
@@ -1274,13 +538,27 @@ export declare type EmbedDragConfig = {
1274
538
  * @public
1275
539
  * An element that renders rich media, such as a YouTube video.
1276
540
  */
1277
- export declare type EmbedElement = NativeEmbedElement;
541
+ export declare type EmbedElement = {
542
+ /**
543
+ * The type of element.
544
+ */
545
+ type: "embed";
546
+ /**
547
+ * The URL of the rich media.
548
+ *
549
+ * @remarks
550
+ * This URL must be supported by the Iframely API.
551
+ */
552
+ url: string;
553
+ };
1278
554
 
1279
555
  /**
1280
556
  * @public
1281
557
  * An element that renders rich media, such as a YouTube video, and has positional properties.
1282
558
  */
1283
- export declare type EmbedElementAtPoint = NativeEmbedElementWithBox;
559
+ export declare type EmbedElementAtPoint = EmbedElement &
560
+ Point &
561
+ (WidthAndHeight | Width | Height);
1284
562
 
1285
563
  /**
1286
564
  * @public
@@ -1482,25 +760,43 @@ export declare const getDefaultPageDimensions: () => Promise<
1482
760
  * @public
1483
761
  * Retrieves a signed JWT that contains the Design ID, App ID and User ID.
1484
762
  */
1485
- export declare function getDesignToken(): Promise<DesignToken>;
763
+ export declare const getDesignToken: () => Promise<DesignToken>;
1486
764
 
1487
765
  /**
1488
766
  * @public
1489
767
  * An element that's natively supported by the Canva editor, can exist within a group, and has positional properties.
1490
768
  */
1491
- export declare type GroupContentAtPoint = NativeSimpleElementWithBox;
769
+ export declare type GroupContentAtPoint = Exclude<
770
+ ElementAtPoint,
771
+ GroupElementAtPoint
772
+ >;
1492
773
 
1493
774
  /**
1494
775
  * @public
1495
776
  * An element that contains two or more elements.
1496
777
  */
1497
- export declare type GroupElement = NativeGroupElement;
778
+ export declare type GroupElement = {
779
+ /**
780
+ * The type of element.
781
+ */
782
+ type: "group";
783
+ /**
784
+ * The elements to render within the group.
785
+ *
786
+ * @remarks
787
+ * - Each element within a group must have dimensions and a position.
788
+ * - The dimensions and positions are relative to the dimensions and positions of the group.
789
+ */
790
+ children: GroupContentAtPoint[];
791
+ };
1498
792
 
1499
793
  /**
1500
794
  * @public
1501
795
  * An element that contains two or more elements and has positional properties.
1502
796
  */
1503
- export declare type GroupElementAtPoint = NativeGroupElementWithBox;
797
+ export declare type GroupElementAtPoint = GroupElement &
798
+ Point &
799
+ (WidthAndHeight | Width | Height);
1504
800
 
1505
801
  /**
1506
802
  * A set of dimensions with an auto-calculated width.
@@ -1540,13 +836,45 @@ export declare type ImageDragConfigForElement<E extends Element> =
1540
836
  * @public
1541
837
  * An element that renders image content.
1542
838
  */
1543
- export declare type ImageElement = NativeImageElement;
839
+ export declare type ImageElement = {
840
+ /**
841
+ * The type of element.
842
+ */
843
+ type: "image";
844
+ /**
845
+ * A description of the image content.
846
+ */
847
+ altText: AltText | undefined;
848
+ } & (
849
+ | {
850
+ /**
851
+ * A data URL that contains the image data.
852
+ */
853
+ dataUrl: string;
854
+ /**
855
+ * A unique identifier that points to an image asset in Canva's backend.
856
+ */
857
+ ref?: never;
858
+ }
859
+ | {
860
+ /**
861
+ * A data URL that contains the image data.
862
+ */
863
+ dataUrl?: never;
864
+ /**
865
+ * A unique identifier that points to an image asset in Canva's backend.
866
+ */
867
+ ref: ImageRef;
868
+ }
869
+ );
1544
870
 
1545
871
  /**
1546
872
  * @public
1547
873
  * An element that renders image content and has positional properties.
1548
874
  */
1549
- export declare type ImageElementAtPoint = NativeImageElementWithBox;
875
+ export declare type ImageElementAtPoint = ImageElement &
876
+ Point &
877
+ (WidthAndHeight | Width | Height);
1550
878
 
1551
879
  /**
1552
880
  * @public
@@ -1586,9 +914,9 @@ export declare type ImageRef = string & {
1586
914
  * @public
1587
915
  * @param appElementConfig - Configuration for an AppElementClient
1588
916
  */
1589
- export declare function initAppElement<A extends AppElementData>(
917
+ export declare const initAppElement: <A extends AppElementData>(
1590
918
  appElementConfig: AppElementClientConfiguration<A>
1591
- ): AppElementClient<A>;
919
+ ) => AppElementClient<A>;
1592
920
 
1593
921
  /**
1594
922
  * @public
@@ -1636,7 +964,7 @@ export declare type InlineFormatting = {
1636
964
  };
1637
965
 
1638
966
  /**
1639
- * @deprecated
967
+ * @deprecated The type has been superseded by `DesignElement`.
1640
968
  * @public
1641
969
  * An element that's natively supported by the Canva editor.
1642
970
  */
@@ -1678,302 +1006,97 @@ export declare type NativeElementWithBox =
1678
1006
  * @public
1679
1007
  * An element that renders rich media, such as a YouTube video.
1680
1008
  */
1681
- export declare type NativeEmbedElement = {
1682
- /**
1683
- * The type of element.
1684
- */
1685
- type: "embed";
1686
- /**
1687
- * The URL of the rich media.
1688
- *
1689
- * @remarks
1690
- * This URL must be supported by the Iframely API.
1691
- */
1692
- url: string;
1693
- };
1009
+ export declare type NativeEmbedElement = EmbedElement;
1694
1010
 
1695
1011
  /**
1696
1012
  * @deprecated The type has been superseded by `EmbedElementAtPoint`.
1697
1013
  * @public
1698
- * An element that renders rich media, such as a YouTube video, and has positional properties.
1699
- */
1700
- export declare type NativeEmbedElementWithBox = {
1701
- /**
1702
- * The type of element.
1703
- */
1704
- type: "embed";
1705
- /**
1706
- * The URL of the rich media.
1707
- *
1708
- * @remarks
1709
- * This URL must be supported by the Iframely API.
1710
- */
1711
- url: string;
1712
- } & Box;
1014
+ * An element that renders rich media, such as a YouTube video, and has positional properties.
1015
+ */
1016
+ export declare type NativeEmbedElementWithBox = EmbedElementAtPoint;
1713
1017
 
1714
1018
  /**
1715
1019
  * @deprecated The type has been superseded by `GroupElement`.
1716
1020
  * @public
1717
1021
  * An element that contains two or more elements.
1718
1022
  */
1719
- export declare type NativeGroupElement = {
1720
- /**
1721
- * The type of element.
1722
- */
1723
- type: "group";
1724
- /**
1725
- * The elements to render within the group.
1726
- *
1727
- * @remarks
1728
- * - Each element within a group must have dimensions and a position.
1729
- * - The dimensions and positions are relative to the dimensions and positions of the group.
1730
- */
1731
- children: NativeSimpleElementWithBox[];
1732
- };
1023
+ export declare type NativeGroupElement = GroupElement;
1733
1024
 
1734
1025
  /**
1735
1026
  * @deprecated The type has been superseded by `GroupElementAtPoint`.
1736
1027
  * @public
1737
1028
  * An element that contains two or more elements and has positional properties.
1738
1029
  */
1739
- export declare type NativeGroupElementWithBox = {
1740
- /**
1741
- * The type of element.
1742
- */
1743
- type: "group";
1744
- /**
1745
- * The elements to render within the group.
1746
- *
1747
- * @remarks
1748
- * - Each element within a group must have dimensions and a position.
1749
- * - The dimensions and positions are relative to the dimensions and positions of the group.
1750
- */
1751
- children: NativeSimpleElementWithBox[];
1752
- } & Box;
1030
+ export declare type NativeGroupElementWithBox = GroupElementAtPoint;
1753
1031
 
1754
1032
  /**
1755
1033
  * @deprecated The type has been superseded by `ImageElement`.
1756
1034
  * @public
1757
1035
  * An element that renders image content.
1758
1036
  */
1759
- export declare type NativeImageElement = {
1760
- /**
1761
- * The type of element.
1762
- */
1763
- type: "image";
1764
- /**
1765
- * A description of the image content.
1766
- */
1767
- altText: AltText | undefined;
1768
- } & (
1769
- | {
1770
- /**
1771
- * A data URL that contains the image data.
1772
- */
1773
- dataUrl: string;
1774
- /**
1775
- * A unique identifier that points to an image asset in Canva's backend.
1776
- */
1777
- ref?: never;
1778
- }
1779
- | {
1780
- /**
1781
- * A data URL that contains the image data.
1782
- */
1783
- dataUrl?: never;
1784
- /**
1785
- * A unique identifier that points to an image asset in Canva's backend.
1786
- */
1787
- ref: ImageRef;
1788
- }
1789
- );
1037
+ export declare type NativeImageElement = ImageElement;
1790
1038
 
1791
1039
  /**
1792
1040
  * @deprecated The type has been superseded by `ImageElementAtPoint`.
1793
1041
  * @public
1794
1042
  * An element that renders image content and has positional properties.
1795
1043
  */
1796
- export declare type NativeImageElementWithBox = NativeImageElement & Box;
1044
+ export declare type NativeImageElementWithBox = ImageElementAtPoint;
1797
1045
 
1798
1046
  /**
1799
1047
  * @deprecated The type has been superseded by `ShapeElement`.
1800
1048
  * @public
1801
1049
  * An element that renders a vector shape.
1802
1050
  */
1803
- export declare type NativeShapeElement = {
1804
- /**
1805
- * The type of element.
1806
- */
1807
- type: "shape";
1808
- /**
1809
- * Options for configuring the scale and cropping of the shape.
1810
- */
1811
- viewBox: ShapeViewBox;
1812
- /**
1813
- * The paths that define the structure of the shape.
1814
- *
1815
- * @remarks
1816
- * - There must be between 1 and 30 paths (inclusive).
1817
- * - The maximum combined size of all paths must not exceed 2kb.
1818
- * - The maximum number of unique fill colors across all paths is 6.
1819
- */
1820
- paths: ShapePath[];
1821
- };
1051
+ export declare type NativeShapeElement = ShapeElement;
1822
1052
 
1823
1053
  /**
1824
1054
  * @deprecated The type has been superseded by `ShapeElementAtPoint`.
1825
1055
  * @public
1826
1056
  * An element that renders a vector shape and has positional properties.
1827
1057
  */
1828
- export declare type NativeShapeElementWithBox = {
1829
- /**
1830
- * The type of element.
1831
- */
1832
- type: "shape";
1833
- /**
1834
- * Options for configuring the scale and cropping of a shape.
1835
- */
1836
- viewBox: ShapeViewBox;
1837
- /**
1838
- * The paths that define the structure of the shape.
1839
- *
1840
- * @remarks
1841
- * - There must be between 1 and 30 paths (inclusive).
1842
- * - The maximum combined size of all paths must not exceed 2kb.
1843
- * - The maximum number of unique fill colors across all paths is 6.
1844
- */
1845
- paths: ShapePath[];
1846
- } & Box;
1058
+ export declare type NativeShapeElementWithBox = ShapeElementAtPoint;
1847
1059
 
1848
1060
  /**
1849
1061
  * @deprecated The type has been superseded by `GroupContentAtPoint`.
1850
1062
  * @public
1851
1063
  * An element that's natively supported by the Canva editor, can exist within a group, and has positional properties.
1852
1064
  */
1853
- export declare type NativeSimpleElementWithBox = Exclude<
1854
- NativeElementWithBox,
1855
- NativeGroupElementWithBox
1856
- >;
1065
+ export declare type NativeSimpleElementWithBox = GroupContentAtPoint;
1857
1066
 
1858
1067
  /**
1859
1068
  * @deprecated The type has been superseded by `TextElement`.
1860
1069
  * @public
1861
1070
  * An element that renders text content.
1862
1071
  */
1863
- export declare type NativeTextElement = {
1864
- /**
1865
- * The type of element.
1866
- */
1867
- type: "text";
1868
- /**
1869
- * The text content.
1870
- *
1871
- * @remarks
1872
- * Only the first element in this array is used.
1873
- */
1874
- children: string[];
1875
- } & TextAttributes;
1072
+ export declare type NativeTextElement = TextElement;
1876
1073
 
1877
1074
  /**
1878
1075
  * @deprecated The type has been superseded by `TextElementAtPoint`.
1879
1076
  * @public
1880
1077
  * An element that renders text content and has positional properties.
1881
1078
  */
1882
- export declare type NativeTextElementWithBox = {
1883
- /**
1884
- * The type of element.
1885
- */
1886
- type: "text";
1887
- /**
1888
- * The text content.
1889
- *
1890
- * @remarks
1891
- * Only the first element in this array is used.
1892
- */
1893
- children: [string];
1894
- /**
1895
- * The width of the element, in pixels.
1896
- *
1897
- * @remarks
1898
- * - Minimum: 0
1899
- * - Maximum: 32767
1900
- */
1901
- width?: number;
1902
- /**
1903
- * The distance from the top edge of the container, in pixels.
1904
- *
1905
- * @remarks
1906
- * - Minimum: -32768
1907
- * - Maximum: 32767
1908
- */
1909
- top: number;
1910
- /**
1911
- * The distance from the left edge of the container, in pixels.
1912
- *
1913
- * @remarks
1914
- * - Minimum: -32768
1915
- * - Maximum: 32767
1916
- */
1917
- left: number;
1918
- /**
1919
- * The rotation of the element, in degrees.
1920
- *
1921
- * @remarks
1922
- * - Minimum: -180
1923
- * - Maximum: 180
1924
- */
1925
- rotation?: number;
1926
- } & TextAttributes;
1079
+ export declare type NativeTextElementWithBox = TextElementAtPoint;
1927
1080
 
1928
1081
  /**
1929
1082
  * @deprecated The type has been superseded by `VideoElement`.
1930
1083
  * @public
1931
1084
  * An element that renders video content.
1932
1085
  */
1933
- export declare type NativeVideoElement = {
1934
- /**
1935
- * The type of element.
1936
- */
1937
- type: "video";
1938
- /**
1939
- * A unique identifier that points to a video asset in Canva's backend.
1940
- */
1941
- ref: VideoRef;
1942
- /**
1943
- * A description of the video content.
1944
- */
1945
- altText: AltText | undefined;
1946
- };
1086
+ export declare type NativeVideoElement = VideoElement;
1947
1087
 
1948
1088
  /**
1949
1089
  * @deprecated The type has been superseded by `VideoElementAtPoint`.
1950
1090
  * @public
1951
1091
  * An element that renders video content and has positional properties.
1952
1092
  */
1953
- export declare type NativeVideoElementWithBox = NativeVideoElement & Box;
1093
+ export declare type NativeVideoElementWithBox = VideoElementAtPoint;
1954
1094
 
1955
1095
  /**
1956
1096
  * An object primitive data type that can be used in app element data.
1957
1097
  */
1958
1098
  declare type ObjectPrimitive = Boolean | String;
1959
1099
 
1960
- /**
1961
- * @beta
1962
- * Reads a specified part of the user's design and returns all elements in that part.
1963
- *
1964
- * @param options - Options for configuring how a design is read.
1965
- * @param callback - A callback for operating on the design.
1966
- */
1967
- export declare const openDesign: (
1968
- options: DesignOpenOptions,
1969
- callback: (
1970
- draft: DesignEditing.DesignOpenResult,
1971
- helpers: {
1972
- elementBuilder: DesignEditing.ElementBuilder;
1973
- }
1974
- ) => Promise<void> | void
1975
- ) => Promise<void>;
1976
-
1977
1100
  /**
1978
1101
  * @public
1979
1102
  * An alias for the DesignOverlay interface, providing access to design overlay related functionality
@@ -2100,13 +1223,12 @@ export declare type PathStroke = {
2100
1223
  * @public
2101
1224
  * A position, set of dimensions, and rotation.
2102
1225
  */
2103
- export declare type Placement = Position & (WidthAndHeight | Width | Height);
1226
+ export declare type Placement = Point & (WidthAndHeight | Width | Height);
2104
1227
 
2105
1228
  /**
2106
- * @deprecated
2107
1229
  * A position and rotation.
2108
1230
  */
2109
- declare type Position = {
1231
+ declare type Point = {
2110
1232
  /**
2111
1233
  * The distance from the top edge of the container, in pixels.
2112
1234
  *
@@ -2143,59 +1265,6 @@ declare type Position = {
2143
1265
  */
2144
1266
  declare type Primitive = undefined | null | number | boolean | string;
2145
1267
 
2146
- /**
2147
- * @beta
2148
- * A snapshot of content returned by a query.
2149
- *
2150
- * @remarks
2151
- * The snapshot is known as the *draft*.
2152
- */
2153
- export declare interface QueryContentDraft<T> {
2154
- /**
2155
- * The individual content items returned by a query.
2156
- */
2157
- readonly contents: readonly T[];
2158
- /**
2159
- * Commits any changes made to the items in the `contents` array.
2160
- *
2161
- * @remarks
2162
- * An app must call this method for any changes to be reflected in the user's design.
2163
- */
2164
- sync(): Promise<void>;
2165
- }
2166
-
2167
- /**
2168
- * @beta
2169
- * The result of querying content in a design.
2170
- */
2171
- export declare type QueryResult<T extends ContentType> = {
2172
- ["richtext"]: QueryContentDraft<
2173
- RichtextRange & {
2174
- readonly deleted: boolean;
2175
- }
2176
- >;
2177
- }[T];
2178
-
2179
- /**
2180
- * @beta
2181
- * Reads content of the specified type from the user's design.
2182
- * @param options - Options for configuring how a design is read.
2183
- * @param callback - A callback for operating on the queried content.
2184
- */
2185
- export declare const readContent: <T extends ContentType>(
2186
- options: EditContentOptions<T>,
2187
- callback: (draft: QueryResult<T>) => Promise<void> | void
2188
- ) => Promise<void>;
2189
-
2190
- /**
2191
- * @beta
2192
- * A callback for reading and updating part of a design.
2193
- * @param draft - The result of reading the content in a design.
2194
- */
2195
- export declare type ReadContentCallback<T extends ContentType> = (
2196
- draft: QueryResult<T>
2197
- ) => Promise<void> | void;
2198
-
2199
1268
  /**
2200
1269
  * @public
2201
1270
  * Exports the user's design as one or more static files.
@@ -2471,13 +1540,33 @@ export declare const setCurrentPageBackground: (
2471
1540
  * @public
2472
1541
  * An element that renders a vector shape.
2473
1542
  */
2474
- export declare type ShapeElement = NativeShapeElement;
1543
+ export declare type ShapeElement = {
1544
+ /**
1545
+ * The type of element.
1546
+ */
1547
+ type: "shape";
1548
+ /**
1549
+ * Options for configuring the scale and cropping of the shape.
1550
+ */
1551
+ viewBox: ShapeViewBox;
1552
+ /**
1553
+ * The paths that define the structure of the shape.
1554
+ *
1555
+ * @remarks
1556
+ * - There must be between 1 and 30 paths (inclusive).
1557
+ * - The maximum combined size of all paths must not exceed 2kb.
1558
+ * - The maximum number of unique fill colors across all paths is 6.
1559
+ */
1560
+ paths: ShapePath[];
1561
+ };
2475
1562
 
2476
1563
  /**
2477
1564
  * @public
2478
1565
  * An element that renders a vector shape and has positional properties.
2479
1566
  */
2480
- export declare type ShapeElementAtPoint = NativeShapeElementWithBox;
1567
+ export declare type ShapeElementAtPoint = ShapeElement &
1568
+ Point &
1569
+ (WidthAndHeight | Width | Height);
2481
1570
 
2482
1571
  /**
2483
1572
  * @public
@@ -2613,39 +1702,15 @@ export declare type TextAttributes = {
2613
1702
  * @public
2614
1703
  * The dimensions, position, and rotation of a text element.
2615
1704
  */
2616
- declare type TextBox = {
1705
+ declare type TextBox = Point & {
2617
1706
  /**
2618
- * The width, in pixels.
1707
+ * The width of the element, in pixels.
2619
1708
  *
2620
1709
  * @remarks
2621
1710
  * - Minimum: 0
2622
1711
  * - Maximum: 32767
2623
1712
  */
2624
1713
  width?: number;
2625
- /**
2626
- * The distance from the top edge of the container, in pixels.
2627
- *
2628
- * @remarks
2629
- * - Minimum: -32767
2630
- * - Maximum: 32767
2631
- */
2632
- top: number;
2633
- /**
2634
- * The distance from the left edge of the container, in pixels.
2635
- *
2636
- * @remarks
2637
- * - Minimum: -32767
2638
- * - Maximum: 32767
2639
- */
2640
- left: number;
2641
- /**
2642
- * The rotation, in degrees.
2643
- *
2644
- * @remarks
2645
- * - Minimum: -180
2646
- * - Maximum: 180
2647
- */
2648
- rotation?: number;
2649
1714
  };
2650
1715
 
2651
1716
  /**
@@ -2681,24 +1746,31 @@ export declare type TextDragConfig = {
2681
1746
  * @defaultValue "none"
2682
1747
  */
2683
1748
  decoration?: "none" | "underline";
2684
- /**
2685
- * @beta
2686
- * A unique identifier that points to a font asset in Canva's backend.
2687
- */
2688
- fontRef?: FontRef;
2689
1749
  };
2690
1750
 
2691
1751
  /**
2692
1752
  * @public
2693
1753
  * An element that renders text content.
2694
1754
  */
2695
- export declare type TextElement = NativeTextElement;
1755
+ export declare type TextElement = {
1756
+ /**
1757
+ * The type of element.
1758
+ */
1759
+ type: "text";
1760
+ /**
1761
+ * The text content.
1762
+ *
1763
+ * @remarks
1764
+ * Only the first element in this array is used.
1765
+ */
1766
+ children: string[];
1767
+ } & TextAttributes;
2696
1768
 
2697
1769
  /**
2698
1770
  * @public
2699
1771
  * An element that renders text content and has positional properties.
2700
1772
  */
2701
- export declare type TextElementAtPoint = NativeTextElementWithBox;
1773
+ export declare type TextElementAtPoint = TextElement & TextAttributes & TextBox;
2702
1774
 
2703
1775
  /**
2704
1776
  * @public
@@ -2834,13 +1906,28 @@ export declare type VideoDragConfigForElement<E extends Element> =
2834
1906
  * @public
2835
1907
  * An element that renders video content.
2836
1908
  */
2837
- export declare type VideoElement = NativeVideoElement;
1909
+ export declare type VideoElement = {
1910
+ /**
1911
+ * The type of element.
1912
+ */
1913
+ type: "video";
1914
+ /**
1915
+ * A unique identifier that points to a video asset in Canva's backend.
1916
+ */
1917
+ ref: VideoRef;
1918
+ /**
1919
+ * A description of the video content.
1920
+ */
1921
+ altText: AltText | undefined;
1922
+ };
2838
1923
 
2839
1924
  /**
2840
1925
  * @public
2841
1926
  * An element that renders video content and has positional properties.
2842
1927
  */
2843
- export declare type VideoElementAtPoint = NativeVideoElementWithBox;
1928
+ export declare type VideoElementAtPoint = VideoElement &
1929
+ Point &
1930
+ (WidthAndHeight | Width | Height);
2844
1931
 
2845
1932
  /**
2846
1933
  * @public