@canva/design 2.1.0 → 2.2.1-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.
- package/{index.d.ts → beta.d.ts} +994 -257
- package/lib/cjs/sdk/design/beta.js +37 -0
- package/lib/cjs/sdk/design/public.js +3 -9
- package/lib/esm/sdk/design/beta.js +6 -0
- package/lib/esm/sdk/design/public.js +3 -9
- package/package.json +8 -8
- package/lib/cjs/sdk/design/index.js +0 -21
- package/lib/esm/sdk/design/index.js +0 -4
package/{index.d.ts → beta.d.ts}
RENAMED
|
@@ -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
|
|
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
|
|
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 =
|
|
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 =
|
|
228
|
+
export declare type Box = Point & (WidthAndHeight | Width | Height);
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
231
|
* @public
|
|
@@ -328,6 +328,14 @@ 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
|
+
|
|
331
339
|
/**
|
|
332
340
|
* @public
|
|
333
341
|
* A set of X and Y coordinates.
|
|
@@ -347,13 +355,755 @@ export declare type Coordinates = {
|
|
|
347
355
|
* @public
|
|
348
356
|
* Creates a new RichtextRange object, which contains methods to manipulate text.
|
|
349
357
|
*/
|
|
350
|
-
export declare
|
|
358
|
+
export declare const 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: ImageRef;
|
|
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: VideoRef;
|
|
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
|
+
}
|
|
351
1071
|
|
|
352
1072
|
/**
|
|
353
1073
|
* @public
|
|
354
1074
|
* An element that's natively supported by the Canva editor.
|
|
355
1075
|
*/
|
|
356
|
-
export declare type DesignElement =
|
|
1076
|
+
export declare type DesignElement =
|
|
1077
|
+
| ImageElement
|
|
1078
|
+
| VideoElement
|
|
1079
|
+
| EmbedElement
|
|
1080
|
+
| TextElement
|
|
1081
|
+
| ShapeElement
|
|
1082
|
+
| GroupElement
|
|
1083
|
+
| RichtextElement
|
|
1084
|
+
| TableElement;
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* @beta
|
|
1088
|
+
* A callback for reading and updating part of a design.
|
|
1089
|
+
* @param draft - The result of reading part of a design.
|
|
1090
|
+
* @param helpers - Helper methods for reading and updating the design.
|
|
1091
|
+
*/
|
|
1092
|
+
export declare type DesignOpenCallback = (
|
|
1093
|
+
draft: DesignEditing.DesignOpenResult,
|
|
1094
|
+
helpers: {
|
|
1095
|
+
/**
|
|
1096
|
+
* Provides methods for creating elements.
|
|
1097
|
+
*/
|
|
1098
|
+
elementBuilder: DesignEditing.ElementBuilder;
|
|
1099
|
+
}
|
|
1100
|
+
) => Promise<void> | void;
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* @beta
|
|
1104
|
+
* Options for configuring which part of a design to read.
|
|
1105
|
+
*/
|
|
1106
|
+
export declare type DesignOpenOptions = DesignContextOptions;
|
|
357
1107
|
|
|
358
1108
|
/**
|
|
359
1109
|
* @public
|
|
@@ -464,6 +1214,14 @@ export declare type DragStartEvent<E extends Element> = Pick<
|
|
|
464
1214
|
currentTarget: E;
|
|
465
1215
|
};
|
|
466
1216
|
|
|
1217
|
+
/**
|
|
1218
|
+
* @beta
|
|
1219
|
+
* Options for configuring how a design is read.
|
|
1220
|
+
*/
|
|
1221
|
+
export declare type EditContentOptions<T extends ContentType> = {
|
|
1222
|
+
contentType: T;
|
|
1223
|
+
} & ContextOptions;
|
|
1224
|
+
|
|
467
1225
|
/**
|
|
468
1226
|
* @public
|
|
469
1227
|
* Elements targeting a cursor are a subset of the base Element
|
|
@@ -473,14 +1231,20 @@ export declare type ElementAtCursor =
|
|
|
473
1231
|
| VideoElement
|
|
474
1232
|
| EmbedElement
|
|
475
1233
|
| TextElement
|
|
476
|
-
| RichtextElement
|
|
1234
|
+
| RichtextElement
|
|
1235
|
+
| TableElement;
|
|
477
1236
|
|
|
478
1237
|
/**
|
|
479
1238
|
* @public
|
|
480
1239
|
* An element that's natively supported by the Canva editor and has positional properties.
|
|
481
1240
|
*/
|
|
482
1241
|
export declare type ElementAtPoint =
|
|
483
|
-
|
|
|
1242
|
+
| ImageElementAtPoint
|
|
1243
|
+
| VideoElementAtPoint
|
|
1244
|
+
| EmbedElementAtPoint
|
|
1245
|
+
| TextElementAtPoint
|
|
1246
|
+
| ShapeElementAtPoint
|
|
1247
|
+
| GroupElementAtPoint
|
|
484
1248
|
| RichtextElementAtPoint;
|
|
485
1249
|
|
|
486
1250
|
/**
|
|
@@ -524,13 +1288,27 @@ export declare type EmbedDragConfig = {
|
|
|
524
1288
|
* @public
|
|
525
1289
|
* An element that renders rich media, such as a YouTube video.
|
|
526
1290
|
*/
|
|
527
|
-
export declare type EmbedElement =
|
|
1291
|
+
export declare type EmbedElement = {
|
|
1292
|
+
/**
|
|
1293
|
+
* The type of element.
|
|
1294
|
+
*/
|
|
1295
|
+
type: "embed";
|
|
1296
|
+
/**
|
|
1297
|
+
* The URL of the rich media.
|
|
1298
|
+
*
|
|
1299
|
+
* @remarks
|
|
1300
|
+
* This URL must be supported by the Iframely API.
|
|
1301
|
+
*/
|
|
1302
|
+
url: string;
|
|
1303
|
+
};
|
|
528
1304
|
|
|
529
1305
|
/**
|
|
530
1306
|
* @public
|
|
531
1307
|
* An element that renders rich media, such as a YouTube video, and has positional properties.
|
|
532
1308
|
*/
|
|
533
|
-
export declare type EmbedElementAtPoint =
|
|
1309
|
+
export declare type EmbedElementAtPoint = EmbedElement &
|
|
1310
|
+
Point &
|
|
1311
|
+
(WidthAndHeight | Width | Height);
|
|
534
1312
|
|
|
535
1313
|
/**
|
|
536
1314
|
* @public
|
|
@@ -732,25 +1510,43 @@ export declare const getDefaultPageDimensions: () => Promise<
|
|
|
732
1510
|
* @public
|
|
733
1511
|
* Retrieves a signed JWT that contains the Design ID, App ID and User ID.
|
|
734
1512
|
*/
|
|
735
|
-
export declare
|
|
1513
|
+
export declare const getDesignToken: () => Promise<DesignToken>;
|
|
736
1514
|
|
|
737
1515
|
/**
|
|
738
1516
|
* @public
|
|
739
1517
|
* An element that's natively supported by the Canva editor, can exist within a group, and has positional properties.
|
|
740
1518
|
*/
|
|
741
|
-
export declare type GroupContentAtPoint =
|
|
1519
|
+
export declare type GroupContentAtPoint = Exclude<
|
|
1520
|
+
ElementAtPoint,
|
|
1521
|
+
GroupElementAtPoint
|
|
1522
|
+
>;
|
|
742
1523
|
|
|
743
1524
|
/**
|
|
744
1525
|
* @public
|
|
745
1526
|
* An element that contains two or more elements.
|
|
746
1527
|
*/
|
|
747
|
-
export declare type GroupElement =
|
|
1528
|
+
export declare type GroupElement = {
|
|
1529
|
+
/**
|
|
1530
|
+
* The type of element.
|
|
1531
|
+
*/
|
|
1532
|
+
type: "group";
|
|
1533
|
+
/**
|
|
1534
|
+
* The elements to render within the group.
|
|
1535
|
+
*
|
|
1536
|
+
* @remarks
|
|
1537
|
+
* - Each element within a group must have dimensions and a position.
|
|
1538
|
+
* - The dimensions and positions are relative to the dimensions and positions of the group.
|
|
1539
|
+
*/
|
|
1540
|
+
children: GroupContentAtPoint[];
|
|
1541
|
+
};
|
|
748
1542
|
|
|
749
1543
|
/**
|
|
750
1544
|
* @public
|
|
751
1545
|
* An element that contains two or more elements and has positional properties.
|
|
752
1546
|
*/
|
|
753
|
-
export declare type GroupElementAtPoint =
|
|
1547
|
+
export declare type GroupElementAtPoint = GroupElement &
|
|
1548
|
+
Point &
|
|
1549
|
+
(WidthAndHeight | Width | Height);
|
|
754
1550
|
|
|
755
1551
|
/**
|
|
756
1552
|
* A set of dimensions with an auto-calculated width.
|
|
@@ -790,13 +1586,45 @@ export declare type ImageDragConfigForElement<E extends Element> =
|
|
|
790
1586
|
* @public
|
|
791
1587
|
* An element that renders image content.
|
|
792
1588
|
*/
|
|
793
|
-
export declare type ImageElement =
|
|
1589
|
+
export declare type ImageElement = {
|
|
1590
|
+
/**
|
|
1591
|
+
* The type of element.
|
|
1592
|
+
*/
|
|
1593
|
+
type: "image";
|
|
1594
|
+
/**
|
|
1595
|
+
* A description of the image content.
|
|
1596
|
+
*/
|
|
1597
|
+
altText: AltText | undefined;
|
|
1598
|
+
} & (
|
|
1599
|
+
| {
|
|
1600
|
+
/**
|
|
1601
|
+
* A data URL that contains the image data.
|
|
1602
|
+
*/
|
|
1603
|
+
dataUrl: string;
|
|
1604
|
+
/**
|
|
1605
|
+
* A unique identifier that points to an image asset in Canva's backend.
|
|
1606
|
+
*/
|
|
1607
|
+
ref?: never;
|
|
1608
|
+
}
|
|
1609
|
+
| {
|
|
1610
|
+
/**
|
|
1611
|
+
* A data URL that contains the image data.
|
|
1612
|
+
*/
|
|
1613
|
+
dataUrl?: never;
|
|
1614
|
+
/**
|
|
1615
|
+
* A unique identifier that points to an image asset in Canva's backend.
|
|
1616
|
+
*/
|
|
1617
|
+
ref: ImageRef;
|
|
1618
|
+
}
|
|
1619
|
+
);
|
|
794
1620
|
|
|
795
1621
|
/**
|
|
796
1622
|
* @public
|
|
797
1623
|
* An element that renders image content and has positional properties.
|
|
798
1624
|
*/
|
|
799
|
-
export declare type ImageElementAtPoint =
|
|
1625
|
+
export declare type ImageElementAtPoint = ImageElement &
|
|
1626
|
+
Point &
|
|
1627
|
+
(WidthAndHeight | Width | Height);
|
|
800
1628
|
|
|
801
1629
|
/**
|
|
802
1630
|
* @public
|
|
@@ -836,9 +1664,9 @@ export declare type ImageRef = string & {
|
|
|
836
1664
|
* @public
|
|
837
1665
|
* @param appElementConfig - Configuration for an AppElementClient
|
|
838
1666
|
*/
|
|
839
|
-
export declare
|
|
1667
|
+
export declare const initAppElement: <A extends AppElementData>(
|
|
840
1668
|
appElementConfig: AppElementClientConfiguration<A>
|
|
841
|
-
)
|
|
1669
|
+
) => AppElementClient<A>;
|
|
842
1670
|
|
|
843
1671
|
/**
|
|
844
1672
|
* @public
|
|
@@ -886,7 +1714,7 @@ export declare type InlineFormatting = {
|
|
|
886
1714
|
};
|
|
887
1715
|
|
|
888
1716
|
/**
|
|
889
|
-
* @deprecated
|
|
1717
|
+
* @deprecated The type has been superseded by `DesignElement`.
|
|
890
1718
|
* @public
|
|
891
1719
|
* An element that's natively supported by the Canva editor.
|
|
892
1720
|
*/
|
|
@@ -928,285 +1756,114 @@ export declare type NativeElementWithBox =
|
|
|
928
1756
|
* @public
|
|
929
1757
|
* An element that renders rich media, such as a YouTube video.
|
|
930
1758
|
*/
|
|
931
|
-
export declare type NativeEmbedElement =
|
|
932
|
-
/**
|
|
933
|
-
* The type of element.
|
|
934
|
-
*/
|
|
935
|
-
type: "embed";
|
|
936
|
-
/**
|
|
937
|
-
* The URL of the rich media.
|
|
938
|
-
*
|
|
939
|
-
* @remarks
|
|
940
|
-
* This URL must be supported by the Iframely API.
|
|
941
|
-
*/
|
|
942
|
-
url: string;
|
|
943
|
-
};
|
|
1759
|
+
export declare type NativeEmbedElement = EmbedElement;
|
|
944
1760
|
|
|
945
1761
|
/**
|
|
946
1762
|
* @deprecated The type has been superseded by `EmbedElementAtPoint`.
|
|
947
1763
|
* @public
|
|
948
|
-
* An element that renders rich media, such as a YouTube video, and has positional properties.
|
|
949
|
-
*/
|
|
950
|
-
export declare type NativeEmbedElementWithBox =
|
|
951
|
-
/**
|
|
952
|
-
* The type of element.
|
|
953
|
-
*/
|
|
954
|
-
type: "embed";
|
|
955
|
-
/**
|
|
956
|
-
* The URL of the rich media.
|
|
957
|
-
*
|
|
958
|
-
* @remarks
|
|
959
|
-
* This URL must be supported by the Iframely API.
|
|
960
|
-
*/
|
|
961
|
-
url: string;
|
|
962
|
-
} & Box;
|
|
1764
|
+
* An element that renders rich media, such as a YouTube video, and has positional properties.
|
|
1765
|
+
*/
|
|
1766
|
+
export declare type NativeEmbedElementWithBox = EmbedElementAtPoint;
|
|
963
1767
|
|
|
964
1768
|
/**
|
|
965
1769
|
* @deprecated The type has been superseded by `GroupElement`.
|
|
966
1770
|
* @public
|
|
967
1771
|
* An element that contains two or more elements.
|
|
968
1772
|
*/
|
|
969
|
-
export declare type NativeGroupElement =
|
|
970
|
-
/**
|
|
971
|
-
* The type of element.
|
|
972
|
-
*/
|
|
973
|
-
type: "group";
|
|
974
|
-
/**
|
|
975
|
-
* The elements to render within the group.
|
|
976
|
-
*
|
|
977
|
-
* @remarks
|
|
978
|
-
* - Each element within a group must have dimensions and a position.
|
|
979
|
-
* - The dimensions and positions are relative to the dimensions and positions of the group.
|
|
980
|
-
*/
|
|
981
|
-
children: NativeSimpleElementWithBox[];
|
|
982
|
-
};
|
|
1773
|
+
export declare type NativeGroupElement = GroupElement;
|
|
983
1774
|
|
|
984
1775
|
/**
|
|
985
1776
|
* @deprecated The type has been superseded by `GroupElementAtPoint`.
|
|
986
1777
|
* @public
|
|
987
1778
|
* An element that contains two or more elements and has positional properties.
|
|
988
1779
|
*/
|
|
989
|
-
export declare type NativeGroupElementWithBox =
|
|
990
|
-
/**
|
|
991
|
-
* The type of element.
|
|
992
|
-
*/
|
|
993
|
-
type: "group";
|
|
994
|
-
/**
|
|
995
|
-
* The elements to render within the group.
|
|
996
|
-
*
|
|
997
|
-
* @remarks
|
|
998
|
-
* - Each element within a group must have dimensions and a position.
|
|
999
|
-
* - The dimensions and positions are relative to the dimensions and positions of the group.
|
|
1000
|
-
*/
|
|
1001
|
-
children: NativeSimpleElementWithBox[];
|
|
1002
|
-
} & Box;
|
|
1780
|
+
export declare type NativeGroupElementWithBox = GroupElementAtPoint;
|
|
1003
1781
|
|
|
1004
1782
|
/**
|
|
1005
1783
|
* @deprecated The type has been superseded by `ImageElement`.
|
|
1006
1784
|
* @public
|
|
1007
1785
|
* An element that renders image content.
|
|
1008
1786
|
*/
|
|
1009
|
-
export declare type NativeImageElement =
|
|
1010
|
-
/**
|
|
1011
|
-
* The type of element.
|
|
1012
|
-
*/
|
|
1013
|
-
type: "image";
|
|
1014
|
-
/**
|
|
1015
|
-
* A description of the image content.
|
|
1016
|
-
*/
|
|
1017
|
-
altText: AltText | undefined;
|
|
1018
|
-
} & (
|
|
1019
|
-
| {
|
|
1020
|
-
/**
|
|
1021
|
-
* A data URL that contains the image data.
|
|
1022
|
-
*/
|
|
1023
|
-
dataUrl: string;
|
|
1024
|
-
/**
|
|
1025
|
-
* A unique identifier that points to an image asset in Canva's backend.
|
|
1026
|
-
*/
|
|
1027
|
-
ref?: never;
|
|
1028
|
-
}
|
|
1029
|
-
| {
|
|
1030
|
-
/**
|
|
1031
|
-
* A data URL that contains the image data.
|
|
1032
|
-
*/
|
|
1033
|
-
dataUrl?: never;
|
|
1034
|
-
/**
|
|
1035
|
-
* A unique identifier that points to an image asset in Canva's backend.
|
|
1036
|
-
*/
|
|
1037
|
-
ref: ImageRef;
|
|
1038
|
-
}
|
|
1039
|
-
);
|
|
1787
|
+
export declare type NativeImageElement = ImageElement;
|
|
1040
1788
|
|
|
1041
1789
|
/**
|
|
1042
1790
|
* @deprecated The type has been superseded by `ImageElementAtPoint`.
|
|
1043
1791
|
* @public
|
|
1044
1792
|
* An element that renders image content and has positional properties.
|
|
1045
1793
|
*/
|
|
1046
|
-
export declare type NativeImageElementWithBox =
|
|
1794
|
+
export declare type NativeImageElementWithBox = ImageElementAtPoint;
|
|
1047
1795
|
|
|
1048
1796
|
/**
|
|
1049
1797
|
* @deprecated The type has been superseded by `ShapeElement`.
|
|
1050
1798
|
* @public
|
|
1051
1799
|
* An element that renders a vector shape.
|
|
1052
1800
|
*/
|
|
1053
|
-
export declare type NativeShapeElement =
|
|
1054
|
-
/**
|
|
1055
|
-
* The type of element.
|
|
1056
|
-
*/
|
|
1057
|
-
type: "shape";
|
|
1058
|
-
/**
|
|
1059
|
-
* Options for configuring the scale and cropping of the shape.
|
|
1060
|
-
*/
|
|
1061
|
-
viewBox: ShapeViewBox;
|
|
1062
|
-
/**
|
|
1063
|
-
* The paths that define the structure of the shape.
|
|
1064
|
-
*
|
|
1065
|
-
* @remarks
|
|
1066
|
-
* - There must be between 1 and 30 paths (inclusive).
|
|
1067
|
-
* - The maximum combined size of all paths must not exceed 2kb.
|
|
1068
|
-
* - The maximum number of unique fill colors across all paths is 6.
|
|
1069
|
-
*/
|
|
1070
|
-
paths: ShapePath[];
|
|
1071
|
-
};
|
|
1801
|
+
export declare type NativeShapeElement = ShapeElement;
|
|
1072
1802
|
|
|
1073
1803
|
/**
|
|
1074
1804
|
* @deprecated The type has been superseded by `ShapeElementAtPoint`.
|
|
1075
1805
|
* @public
|
|
1076
1806
|
* An element that renders a vector shape and has positional properties.
|
|
1077
1807
|
*/
|
|
1078
|
-
export declare type NativeShapeElementWithBox =
|
|
1079
|
-
/**
|
|
1080
|
-
* The type of element.
|
|
1081
|
-
*/
|
|
1082
|
-
type: "shape";
|
|
1083
|
-
/**
|
|
1084
|
-
* Options for configuring the scale and cropping of a shape.
|
|
1085
|
-
*/
|
|
1086
|
-
viewBox: ShapeViewBox;
|
|
1087
|
-
/**
|
|
1088
|
-
* The paths that define the structure of the shape.
|
|
1089
|
-
*
|
|
1090
|
-
* @remarks
|
|
1091
|
-
* - There must be between 1 and 30 paths (inclusive).
|
|
1092
|
-
* - The maximum combined size of all paths must not exceed 2kb.
|
|
1093
|
-
* - The maximum number of unique fill colors across all paths is 6.
|
|
1094
|
-
*/
|
|
1095
|
-
paths: ShapePath[];
|
|
1096
|
-
} & Box;
|
|
1808
|
+
export declare type NativeShapeElementWithBox = ShapeElementAtPoint;
|
|
1097
1809
|
|
|
1098
1810
|
/**
|
|
1099
1811
|
* @deprecated The type has been superseded by `GroupContentAtPoint`.
|
|
1100
1812
|
* @public
|
|
1101
1813
|
* An element that's natively supported by the Canva editor, can exist within a group, and has positional properties.
|
|
1102
1814
|
*/
|
|
1103
|
-
export declare type NativeSimpleElementWithBox =
|
|
1104
|
-
NativeElementWithBox,
|
|
1105
|
-
NativeGroupElementWithBox
|
|
1106
|
-
>;
|
|
1815
|
+
export declare type NativeSimpleElementWithBox = GroupContentAtPoint;
|
|
1107
1816
|
|
|
1108
1817
|
/**
|
|
1109
1818
|
* @deprecated The type has been superseded by `TextElement`.
|
|
1110
1819
|
* @public
|
|
1111
1820
|
* An element that renders text content.
|
|
1112
1821
|
*/
|
|
1113
|
-
export declare type NativeTextElement =
|
|
1114
|
-
/**
|
|
1115
|
-
* The type of element.
|
|
1116
|
-
*/
|
|
1117
|
-
type: "text";
|
|
1118
|
-
/**
|
|
1119
|
-
* The text content.
|
|
1120
|
-
*
|
|
1121
|
-
* @remarks
|
|
1122
|
-
* Only the first element in this array is used.
|
|
1123
|
-
*/
|
|
1124
|
-
children: string[];
|
|
1125
|
-
} & TextAttributes;
|
|
1822
|
+
export declare type NativeTextElement = TextElement;
|
|
1126
1823
|
|
|
1127
1824
|
/**
|
|
1128
1825
|
* @deprecated The type has been superseded by `TextElementAtPoint`.
|
|
1129
1826
|
* @public
|
|
1130
1827
|
* An element that renders text content and has positional properties.
|
|
1131
1828
|
*/
|
|
1132
|
-
export declare type NativeTextElementWithBox =
|
|
1133
|
-
/**
|
|
1134
|
-
* The type of element.
|
|
1135
|
-
*/
|
|
1136
|
-
type: "text";
|
|
1137
|
-
/**
|
|
1138
|
-
* The text content.
|
|
1139
|
-
*
|
|
1140
|
-
* @remarks
|
|
1141
|
-
* Only the first element in this array is used.
|
|
1142
|
-
*/
|
|
1143
|
-
children: [string];
|
|
1144
|
-
/**
|
|
1145
|
-
* The width of the element, in pixels.
|
|
1146
|
-
*
|
|
1147
|
-
* @remarks
|
|
1148
|
-
* - Minimum: 0
|
|
1149
|
-
* - Maximum: 32767
|
|
1150
|
-
*/
|
|
1151
|
-
width?: number;
|
|
1152
|
-
/**
|
|
1153
|
-
* The distance from the top edge of the container, in pixels.
|
|
1154
|
-
*
|
|
1155
|
-
* @remarks
|
|
1156
|
-
* - Minimum: -32768
|
|
1157
|
-
* - Maximum: 32767
|
|
1158
|
-
*/
|
|
1159
|
-
top: number;
|
|
1160
|
-
/**
|
|
1161
|
-
* The distance from the left edge of the container, in pixels.
|
|
1162
|
-
*
|
|
1163
|
-
* @remarks
|
|
1164
|
-
* - Minimum: -32768
|
|
1165
|
-
* - Maximum: 32767
|
|
1166
|
-
*/
|
|
1167
|
-
left: number;
|
|
1168
|
-
/**
|
|
1169
|
-
* The rotation of the element, in degrees.
|
|
1170
|
-
*
|
|
1171
|
-
* @remarks
|
|
1172
|
-
* - Minimum: -180
|
|
1173
|
-
* - Maximum: 180
|
|
1174
|
-
*/
|
|
1175
|
-
rotation?: number;
|
|
1176
|
-
} & TextAttributes;
|
|
1829
|
+
export declare type NativeTextElementWithBox = TextElementAtPoint;
|
|
1177
1830
|
|
|
1178
1831
|
/**
|
|
1179
1832
|
* @deprecated The type has been superseded by `VideoElement`.
|
|
1180
1833
|
* @public
|
|
1181
1834
|
* An element that renders video content.
|
|
1182
1835
|
*/
|
|
1183
|
-
export declare type NativeVideoElement =
|
|
1184
|
-
/**
|
|
1185
|
-
* The type of element.
|
|
1186
|
-
*/
|
|
1187
|
-
type: "video";
|
|
1188
|
-
/**
|
|
1189
|
-
* A unique identifier that points to a video asset in Canva's backend.
|
|
1190
|
-
*/
|
|
1191
|
-
ref: VideoRef;
|
|
1192
|
-
/**
|
|
1193
|
-
* A description of the video content.
|
|
1194
|
-
*/
|
|
1195
|
-
altText: AltText | undefined;
|
|
1196
|
-
};
|
|
1836
|
+
export declare type NativeVideoElement = VideoElement;
|
|
1197
1837
|
|
|
1198
1838
|
/**
|
|
1199
1839
|
* @deprecated The type has been superseded by `VideoElementAtPoint`.
|
|
1200
1840
|
* @public
|
|
1201
1841
|
* An element that renders video content and has positional properties.
|
|
1202
1842
|
*/
|
|
1203
|
-
export declare type NativeVideoElementWithBox =
|
|
1843
|
+
export declare type NativeVideoElementWithBox = VideoElementAtPoint;
|
|
1204
1844
|
|
|
1205
1845
|
/**
|
|
1206
1846
|
* An object primitive data type that can be used in app element data.
|
|
1207
1847
|
*/
|
|
1208
1848
|
declare type ObjectPrimitive = Boolean | String;
|
|
1209
1849
|
|
|
1850
|
+
/**
|
|
1851
|
+
* @beta
|
|
1852
|
+
* Reads a specified part of the user's design and returns all elements in that part.
|
|
1853
|
+
*
|
|
1854
|
+
* @param options - Options for configuring how a design is read.
|
|
1855
|
+
* @param callback - A callback for operating on the design.
|
|
1856
|
+
*/
|
|
1857
|
+
export declare const openDesign: (
|
|
1858
|
+
options: DesignOpenOptions,
|
|
1859
|
+
callback: (
|
|
1860
|
+
draft: DesignEditing.DesignOpenResult,
|
|
1861
|
+
helpers: {
|
|
1862
|
+
elementBuilder: DesignEditing.ElementBuilder;
|
|
1863
|
+
}
|
|
1864
|
+
) => Promise<void> | void
|
|
1865
|
+
) => Promise<void>;
|
|
1866
|
+
|
|
1210
1867
|
/**
|
|
1211
1868
|
* @public
|
|
1212
1869
|
* An alias for the DesignOverlay interface, providing access to design overlay related functionality
|
|
@@ -1333,13 +1990,12 @@ export declare type PathStroke = {
|
|
|
1333
1990
|
* @public
|
|
1334
1991
|
* A position, set of dimensions, and rotation.
|
|
1335
1992
|
*/
|
|
1336
|
-
export declare type Placement =
|
|
1993
|
+
export declare type Placement = Point & (WidthAndHeight | Width | Height);
|
|
1337
1994
|
|
|
1338
1995
|
/**
|
|
1339
|
-
* @deprecated
|
|
1340
1996
|
* A position and rotation.
|
|
1341
1997
|
*/
|
|
1342
|
-
declare type
|
|
1998
|
+
declare type Point = {
|
|
1343
1999
|
/**
|
|
1344
2000
|
* The distance from the top edge of the container, in pixels.
|
|
1345
2001
|
*
|
|
@@ -1376,6 +2032,59 @@ declare type Position = {
|
|
|
1376
2032
|
*/
|
|
1377
2033
|
declare type Primitive = undefined | null | number | boolean | string;
|
|
1378
2034
|
|
|
2035
|
+
/**
|
|
2036
|
+
* @beta
|
|
2037
|
+
* A snapshot of content returned by a query.
|
|
2038
|
+
*
|
|
2039
|
+
* @remarks
|
|
2040
|
+
* The snapshot is known as the *draft*.
|
|
2041
|
+
*/
|
|
2042
|
+
export declare interface QueryContentDraft<T> {
|
|
2043
|
+
/**
|
|
2044
|
+
* The individual content items returned by a query.
|
|
2045
|
+
*/
|
|
2046
|
+
readonly contents: readonly T[];
|
|
2047
|
+
/**
|
|
2048
|
+
* Commits any changes made to the items in the `contents` array.
|
|
2049
|
+
*
|
|
2050
|
+
* @remarks
|
|
2051
|
+
* An app must call this method for any changes to be reflected in the user's design.
|
|
2052
|
+
*/
|
|
2053
|
+
sync(): Promise<void>;
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
/**
|
|
2057
|
+
* @beta
|
|
2058
|
+
* The result of querying content in a design.
|
|
2059
|
+
*/
|
|
2060
|
+
export declare type QueryResult<T extends ContentType> = {
|
|
2061
|
+
["richtext"]: QueryContentDraft<
|
|
2062
|
+
RichtextRange & {
|
|
2063
|
+
readonly deleted: boolean;
|
|
2064
|
+
}
|
|
2065
|
+
>;
|
|
2066
|
+
}[T];
|
|
2067
|
+
|
|
2068
|
+
/**
|
|
2069
|
+
* @beta
|
|
2070
|
+
* Reads content of the specified type from the user's design.
|
|
2071
|
+
* @param options - Options for configuring how a design is read.
|
|
2072
|
+
* @param callback - A callback for operating on the queried content.
|
|
2073
|
+
*/
|
|
2074
|
+
export declare const readContent: <T extends ContentType>(
|
|
2075
|
+
options: EditContentOptions<T>,
|
|
2076
|
+
callback: (draft: QueryResult<T>) => Promise<void> | void
|
|
2077
|
+
) => Promise<void>;
|
|
2078
|
+
|
|
2079
|
+
/**
|
|
2080
|
+
* @beta
|
|
2081
|
+
* A callback for reading and updating part of a design.
|
|
2082
|
+
* @param draft - The result of reading the content in a design.
|
|
2083
|
+
*/
|
|
2084
|
+
export declare type ReadContentCallback<T extends ContentType> = (
|
|
2085
|
+
draft: QueryResult<T>
|
|
2086
|
+
) => Promise<void> | void;
|
|
2087
|
+
|
|
1379
2088
|
/**
|
|
1380
2089
|
* @public
|
|
1381
2090
|
* Exports the user's design as one or more static files.
|
|
@@ -1651,13 +2360,33 @@ export declare const setCurrentPageBackground: (
|
|
|
1651
2360
|
* @public
|
|
1652
2361
|
* An element that renders a vector shape.
|
|
1653
2362
|
*/
|
|
1654
|
-
export declare type ShapeElement =
|
|
2363
|
+
export declare type ShapeElement = {
|
|
2364
|
+
/**
|
|
2365
|
+
* The type of element.
|
|
2366
|
+
*/
|
|
2367
|
+
type: "shape";
|
|
2368
|
+
/**
|
|
2369
|
+
* Options for configuring the scale and cropping of the shape.
|
|
2370
|
+
*/
|
|
2371
|
+
viewBox: ShapeViewBox;
|
|
2372
|
+
/**
|
|
2373
|
+
* The paths that define the structure of the shape.
|
|
2374
|
+
*
|
|
2375
|
+
* @remarks
|
|
2376
|
+
* - There must be between 1 and 30 paths (inclusive).
|
|
2377
|
+
* - The maximum combined size of all paths must not exceed 2kb.
|
|
2378
|
+
* - The maximum number of unique fill colors across all paths is 6.
|
|
2379
|
+
*/
|
|
2380
|
+
paths: ShapePath[];
|
|
2381
|
+
};
|
|
1655
2382
|
|
|
1656
2383
|
/**
|
|
1657
2384
|
* @public
|
|
1658
2385
|
* An element that renders a vector shape and has positional properties.
|
|
1659
2386
|
*/
|
|
1660
|
-
export declare type ShapeElementAtPoint =
|
|
2387
|
+
export declare type ShapeElementAtPoint = ShapeElement &
|
|
2388
|
+
Point &
|
|
2389
|
+
(WidthAndHeight | Width | Height);
|
|
1661
2390
|
|
|
1662
2391
|
/**
|
|
1663
2392
|
* @public
|
|
@@ -1793,39 +2522,15 @@ export declare type TextAttributes = {
|
|
|
1793
2522
|
* @public
|
|
1794
2523
|
* The dimensions, position, and rotation of a text element.
|
|
1795
2524
|
*/
|
|
1796
|
-
declare type TextBox = {
|
|
2525
|
+
declare type TextBox = Point & {
|
|
1797
2526
|
/**
|
|
1798
|
-
* The width, in pixels.
|
|
2527
|
+
* The width of the element, in pixels.
|
|
1799
2528
|
*
|
|
1800
2529
|
* @remarks
|
|
1801
2530
|
* - Minimum: 0
|
|
1802
2531
|
* - Maximum: 32767
|
|
1803
2532
|
*/
|
|
1804
2533
|
width?: number;
|
|
1805
|
-
/**
|
|
1806
|
-
* The distance from the top edge of the container, in pixels.
|
|
1807
|
-
*
|
|
1808
|
-
* @remarks
|
|
1809
|
-
* - Minimum: -32767
|
|
1810
|
-
* - Maximum: 32767
|
|
1811
|
-
*/
|
|
1812
|
-
top: number;
|
|
1813
|
-
/**
|
|
1814
|
-
* The distance from the left edge of the container, in pixels.
|
|
1815
|
-
*
|
|
1816
|
-
* @remarks
|
|
1817
|
-
* - Minimum: -32767
|
|
1818
|
-
* - Maximum: 32767
|
|
1819
|
-
*/
|
|
1820
|
-
left: number;
|
|
1821
|
-
/**
|
|
1822
|
-
* The rotation, in degrees.
|
|
1823
|
-
*
|
|
1824
|
-
* @remarks
|
|
1825
|
-
* - Minimum: -180
|
|
1826
|
-
* - Maximum: 180
|
|
1827
|
-
*/
|
|
1828
|
-
rotation?: number;
|
|
1829
2534
|
};
|
|
1830
2535
|
|
|
1831
2536
|
/**
|
|
@@ -1861,19 +2566,36 @@ export declare type TextDragConfig = {
|
|
|
1861
2566
|
* @defaultValue "none"
|
|
1862
2567
|
*/
|
|
1863
2568
|
decoration?: "none" | "underline";
|
|
2569
|
+
/**
|
|
2570
|
+
* @beta
|
|
2571
|
+
* A unique identifier that points to a font asset in Canva's backend.
|
|
2572
|
+
*/
|
|
2573
|
+
fontRef?: FontRef;
|
|
1864
2574
|
};
|
|
1865
2575
|
|
|
1866
2576
|
/**
|
|
1867
2577
|
* @public
|
|
1868
2578
|
* An element that renders text content.
|
|
1869
2579
|
*/
|
|
1870
|
-
export declare type TextElement =
|
|
2580
|
+
export declare type TextElement = {
|
|
2581
|
+
/**
|
|
2582
|
+
* The type of element.
|
|
2583
|
+
*/
|
|
2584
|
+
type: "text";
|
|
2585
|
+
/**
|
|
2586
|
+
* The text content.
|
|
2587
|
+
*
|
|
2588
|
+
* @remarks
|
|
2589
|
+
* Only the first element in this array is used.
|
|
2590
|
+
*/
|
|
2591
|
+
children: string[];
|
|
2592
|
+
} & TextAttributes;
|
|
1871
2593
|
|
|
1872
2594
|
/**
|
|
1873
2595
|
* @public
|
|
1874
2596
|
* An element that renders text content and has positional properties.
|
|
1875
2597
|
*/
|
|
1876
|
-
export declare type TextElementAtPoint =
|
|
2598
|
+
export declare type TextElementAtPoint = TextElement & TextAttributes & TextBox;
|
|
1877
2599
|
|
|
1878
2600
|
/**
|
|
1879
2601
|
* @public
|
|
@@ -2009,13 +2731,28 @@ export declare type VideoDragConfigForElement<E extends Element> =
|
|
|
2009
2731
|
* @public
|
|
2010
2732
|
* An element that renders video content.
|
|
2011
2733
|
*/
|
|
2012
|
-
export declare type VideoElement =
|
|
2734
|
+
export declare type VideoElement = {
|
|
2735
|
+
/**
|
|
2736
|
+
* The type of element.
|
|
2737
|
+
*/
|
|
2738
|
+
type: "video";
|
|
2739
|
+
/**
|
|
2740
|
+
* A unique identifier that points to a video asset in Canva's backend.
|
|
2741
|
+
*/
|
|
2742
|
+
ref: VideoRef;
|
|
2743
|
+
/**
|
|
2744
|
+
* A description of the video content.
|
|
2745
|
+
*/
|
|
2746
|
+
altText: AltText | undefined;
|
|
2747
|
+
};
|
|
2013
2748
|
|
|
2014
2749
|
/**
|
|
2015
2750
|
* @public
|
|
2016
2751
|
* An element that renders video content and has positional properties.
|
|
2017
2752
|
*/
|
|
2018
|
-
export declare type VideoElementAtPoint =
|
|
2753
|
+
export declare type VideoElementAtPoint = VideoElement &
|
|
2754
|
+
Point &
|
|
2755
|
+
(WidthAndHeight | Width | Height);
|
|
2019
2756
|
|
|
2020
2757
|
/**
|
|
2021
2758
|
* @public
|