@canva/design 2.2.1 → 2.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index.d.ts → beta.d.ts} +888 -58
- package/lib/cjs/sdk/design/{index.js → beta.js} +19 -2
- package/lib/cjs/sdk/design/fake/create.js +27 -0
- package/lib/cjs/sdk/design/fake/fake_design_interaction_client.js +217 -0
- package/lib/cjs/sdk/design/fake/fake_drag_and_drop_client.js +24 -0
- package/lib/cjs/sdk/design/fake/fake_export_client.js +34 -0
- package/lib/cjs/sdk/design/public.js +4 -0
- package/lib/cjs/sdk/design/test/beta.js +18 -0
- package/lib/cjs/sdk/design/test/index.js +16 -0
- package/lib/cjs/sdk/utils/canva_sdk.js +41 -0
- package/lib/cjs/sdk/utils/synthetic_delay.js +13 -0
- package/lib/esm/sdk/design/{index.js → beta.js} +4 -1
- package/lib/esm/sdk/design/fake/create.js +17 -0
- package/lib/esm/sdk/design/fake/fake_design_interaction_client.js +207 -0
- package/lib/esm/sdk/design/fake/fake_drag_and_drop_client.js +14 -0
- package/lib/esm/sdk/design/fake/fake_export_client.js +24 -0
- package/lib/esm/sdk/design/public.js +1 -0
- package/lib/esm/sdk/design/test/beta.js +1 -0
- package/lib/esm/sdk/design/test/index.js +6 -0
- package/lib/esm/sdk/utils/canva_sdk.js +20 -0
- package/lib/esm/sdk/utils/synthetic_delay.js +3 -0
- package/package.json +12 -12
- package/test/beta.d.ts +11 -0
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
|
/**
|
|
@@ -28,7 +28,7 @@ export declare const addElementAtPoint: (
|
|
|
28
28
|
* @param element - The element to add to the user's design.
|
|
29
29
|
*/
|
|
30
30
|
export declare const addNativeElement: (
|
|
31
|
-
element: NativeElement | NativeElementWithBox
|
|
31
|
+
element: NativeElement | NativeElementWithBox,
|
|
32
32
|
) => Promise<void>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -87,8 +87,13 @@ export declare type AppElementChangeHandler<A extends AppElementData> = (
|
|
|
87
87
|
* The version number of the app.
|
|
88
88
|
*/
|
|
89
89
|
version: number;
|
|
90
|
+
/**
|
|
91
|
+
* @beta
|
|
92
|
+
* Function to update the app element data.
|
|
93
|
+
*/
|
|
94
|
+
update: (opts: AppElementOptions<A>) => Promise<void>;
|
|
90
95
|
}
|
|
91
|
-
| undefined
|
|
96
|
+
| undefined,
|
|
92
97
|
) => void;
|
|
93
98
|
|
|
94
99
|
/**
|
|
@@ -103,6 +108,12 @@ export declare interface AppElementClient<A extends AppElementData> {
|
|
|
103
108
|
* @param placement - The position, dimensions, and rotation of the app element.
|
|
104
109
|
*/
|
|
105
110
|
addOrUpdateElement(appElementData: A, placement?: Placement): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* @beta
|
|
113
|
+
* Adds a new app element to the design.
|
|
114
|
+
* @param opts - The data and placement of the app element.
|
|
115
|
+
*/
|
|
116
|
+
addElement(opts: AppElementOptions<A>): Promise<void>;
|
|
106
117
|
/**
|
|
107
118
|
* A callback that runs when:
|
|
108
119
|
*
|
|
@@ -132,13 +143,29 @@ export declare type AppElementClientConfiguration<A extends AppElementData> = {
|
|
|
132
143
|
*/
|
|
133
144
|
export declare type AppElementData = Record<string, Value>;
|
|
134
145
|
|
|
146
|
+
/**
|
|
147
|
+
* @beta
|
|
148
|
+
* Used to add or update an app element to the design.
|
|
149
|
+
* The update function is provided in the AppElementChangeHandler callback (registerOnElementChange).
|
|
150
|
+
*/
|
|
151
|
+
export declare type AppElementOptions<A extends AppElementData> = {
|
|
152
|
+
/**
|
|
153
|
+
* The data to attach to the app element.
|
|
154
|
+
*/
|
|
155
|
+
data: A;
|
|
156
|
+
/**
|
|
157
|
+
* The position, dimensions, and rotation of the app element.
|
|
158
|
+
*/
|
|
159
|
+
placement?: Placement;
|
|
160
|
+
};
|
|
161
|
+
|
|
135
162
|
/**
|
|
136
163
|
* @public
|
|
137
164
|
* A callback function that renders an app element based on the data it receives.
|
|
138
165
|
* @param appElementData - The data the callback must use to render the app element.
|
|
139
166
|
*/
|
|
140
167
|
export declare type AppElementRenderer<A extends AppElementData> = (
|
|
141
|
-
appElementData: A
|
|
168
|
+
appElementData: A,
|
|
142
169
|
) => AppElementRendererOutput;
|
|
143
170
|
|
|
144
171
|
/**
|
|
@@ -328,6 +355,14 @@ export declare interface ContentDraft<T> {
|
|
|
328
355
|
*/
|
|
329
356
|
export declare type ContentType = "richtext";
|
|
330
357
|
|
|
358
|
+
/**
|
|
359
|
+
* @public
|
|
360
|
+
* Options for configuring where content in a design should be queried from.
|
|
361
|
+
*/
|
|
362
|
+
declare type ContextOptions = {
|
|
363
|
+
target: "current_page";
|
|
364
|
+
};
|
|
365
|
+
|
|
331
366
|
/**
|
|
332
367
|
* @public
|
|
333
368
|
* A set of X and Y coordinates.
|
|
@@ -349,6 +384,730 @@ export declare type Coordinates = {
|
|
|
349
384
|
*/
|
|
350
385
|
export declare const createRichtextRange: () => RichtextRange;
|
|
351
386
|
|
|
387
|
+
/**
|
|
388
|
+
* @beta
|
|
389
|
+
* Describes a part of a design.
|
|
390
|
+
*/
|
|
391
|
+
export declare type DesignContext = DesignContextOptions["type"];
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* @beta
|
|
395
|
+
* Options for configuring which part of a design to read.
|
|
396
|
+
*/
|
|
397
|
+
declare type DesignContextOptions = {
|
|
398
|
+
/**
|
|
399
|
+
* The type of context.
|
|
400
|
+
*/
|
|
401
|
+
type: "current_page";
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @beta
|
|
406
|
+
* Provides methods for reading and updating the structure and content of a design.
|
|
407
|
+
*/
|
|
408
|
+
export declare namespace DesignEditing {
|
|
409
|
+
/**
|
|
410
|
+
* @beta
|
|
411
|
+
* A snapshot containing a fragment of a design's structure and content.
|
|
412
|
+
*/
|
|
413
|
+
export type DesignDraft<D> = Readonly<D> & {
|
|
414
|
+
/**
|
|
415
|
+
* Saves any changes made to the draft.
|
|
416
|
+
*
|
|
417
|
+
* @remarks
|
|
418
|
+
* - Any changes to the draft are only reflected in the design after this method is called.
|
|
419
|
+
* - Once this method is called, further changes to the draft are not possible.
|
|
420
|
+
*/
|
|
421
|
+
save(): Promise<void>;
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* @beta
|
|
425
|
+
* Options for creating an image fill in the element builder
|
|
426
|
+
*/
|
|
427
|
+
export type ImageFillOpts = Partial<ImageFill> &
|
|
428
|
+
Required<Pick<ImageFill, "type" | "imageRef">>;
|
|
429
|
+
/**
|
|
430
|
+
* @beta
|
|
431
|
+
* Options for creating a video fill in the element builder
|
|
432
|
+
*/
|
|
433
|
+
export type VideoFillOpts = Partial<VideoFill> &
|
|
434
|
+
Required<Pick<VideoFill, "type" | "videoRef">>;
|
|
435
|
+
/**
|
|
436
|
+
* @beta
|
|
437
|
+
* Options for creating a media fill in the element builder
|
|
438
|
+
*/
|
|
439
|
+
export type MediaFillOpts = ImageFillOpts | VideoFillOpts;
|
|
440
|
+
/**
|
|
441
|
+
* @beta
|
|
442
|
+
* Options for creating a fill in the element builder
|
|
443
|
+
*/
|
|
444
|
+
export type FillOpts =
|
|
445
|
+
| {
|
|
446
|
+
color: ColorFillOpts;
|
|
447
|
+
media?: MediaFillOpts;
|
|
448
|
+
}
|
|
449
|
+
| {
|
|
450
|
+
color?: ColorFillOpts;
|
|
451
|
+
media: MediaFillOpts;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* @beta
|
|
455
|
+
*/
|
|
456
|
+
export type ColorFillOpts = Exclude<ColorFill, Unsupported>;
|
|
457
|
+
/**
|
|
458
|
+
* @beta
|
|
459
|
+
* Options for creating a stroke in the element builder
|
|
460
|
+
*/
|
|
461
|
+
export type StrokeOpts = Pick<Stroke, "weight"> & {
|
|
462
|
+
color: ColorFillOpts;
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* @beta
|
|
466
|
+
* Options for creating a shape path in the element builder
|
|
467
|
+
*/
|
|
468
|
+
export type PathOpts = Pick<Path, "d"> & {
|
|
469
|
+
fill?: FillOpts;
|
|
470
|
+
stroke?: StrokeOpts;
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* @beta
|
|
474
|
+
* Options for creating a rect element.
|
|
475
|
+
*/
|
|
476
|
+
export type CreateRectElementOpts = Required<
|
|
477
|
+
Pick<RectElement, "top" | "left" | "width" | "height">
|
|
478
|
+
> & {
|
|
479
|
+
fill?: FillOpts;
|
|
480
|
+
} & {
|
|
481
|
+
stroke?: StrokeOpts;
|
|
482
|
+
} & Partial<Omit<RectElement, "fill" | "stroke" | "type">>;
|
|
483
|
+
/**
|
|
484
|
+
* @beta
|
|
485
|
+
* Options for creating a shape element.
|
|
486
|
+
*/
|
|
487
|
+
export type CreateShapeElementOpts = Required<
|
|
488
|
+
Pick<ShapeElement, "top" | "left" | "width" | "height" | "viewBox">
|
|
489
|
+
> & {
|
|
490
|
+
paths: PathOpts[];
|
|
491
|
+
} & Partial<Omit<ShapeElement, "type" | "paths">>;
|
|
492
|
+
/**
|
|
493
|
+
* @beta
|
|
494
|
+
* Options for creating an embed element.
|
|
495
|
+
*/
|
|
496
|
+
export type CreateEmbedElementOpts = Required<
|
|
497
|
+
Pick<EmbedElement, "top" | "left" | "width" | "height" | "url">
|
|
498
|
+
> &
|
|
499
|
+
Partial<Omit<EmbedElement, "type">>;
|
|
500
|
+
/**
|
|
501
|
+
* @beta
|
|
502
|
+
* Options for creating a text element.
|
|
503
|
+
*/
|
|
504
|
+
export type CreateTextElementOpts = Required<
|
|
505
|
+
Pick<TextElement, "top" | "left" | "width" | "text">
|
|
506
|
+
> &
|
|
507
|
+
Partial<Omit<TextElement, "type" | "height">>;
|
|
508
|
+
/**
|
|
509
|
+
* @beta
|
|
510
|
+
* Provides methods for creating elements.
|
|
511
|
+
*
|
|
512
|
+
* @remarks
|
|
513
|
+
* These methods don't add the elements to the design. They only return elements that can
|
|
514
|
+
* be added to a design, such as with the `insertAfter` method.
|
|
515
|
+
*/
|
|
516
|
+
export interface ElementBuilder {
|
|
517
|
+
/**
|
|
518
|
+
* Creates a rect element.
|
|
519
|
+
* @param opts - Options for creating the rect element.
|
|
520
|
+
*/
|
|
521
|
+
createRectElement(opts: CreateRectElementOpts): RectElement;
|
|
522
|
+
/**
|
|
523
|
+
* Creates a shape element.
|
|
524
|
+
* @param opts - Options for creating the shape element.
|
|
525
|
+
*/
|
|
526
|
+
createShapeElement(opts: CreateShapeElementOpts): ShapeElement;
|
|
527
|
+
/**
|
|
528
|
+
* Creates an embed element.
|
|
529
|
+
* @param opts - Options for creating the embed element.
|
|
530
|
+
*/
|
|
531
|
+
createEmbedElement(opts: CreateEmbedElementOpts): EmbedElement;
|
|
532
|
+
/**
|
|
533
|
+
* Creates a text element.
|
|
534
|
+
* @param opts - Options for creating the text element.
|
|
535
|
+
*/
|
|
536
|
+
createTextElement(opts: CreateTextElementOpts): TextElement;
|
|
537
|
+
/**
|
|
538
|
+
* Creates a richtext range.
|
|
539
|
+
*/
|
|
540
|
+
createRichtextRange(): RichtextRange;
|
|
541
|
+
/**
|
|
542
|
+
* Creates a clone of an element.
|
|
543
|
+
* @returns a new element with the same properties as the argument.
|
|
544
|
+
*/
|
|
545
|
+
cloneElement(element: RectElement): RectElement;
|
|
546
|
+
cloneElement(element: ShapeElement): ShapeElement;
|
|
547
|
+
cloneElement(element: EmbedElement): EmbedElement;
|
|
548
|
+
cloneElement(element: TextElement): TextElement;
|
|
549
|
+
cloneElement(
|
|
550
|
+
element: RectElement | ShapeElement | EmbedElement | TextElement,
|
|
551
|
+
): RectElement | ShapeElement | EmbedElement | TextElement;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* @beta
|
|
555
|
+
* The result of reading part of a design when the context is the current page.
|
|
556
|
+
*/
|
|
557
|
+
export type CurrentPageResult = DesignDraft<{
|
|
558
|
+
/**
|
|
559
|
+
* The current page of the design.
|
|
560
|
+
*/
|
|
561
|
+
page: FixedPage;
|
|
562
|
+
}>;
|
|
563
|
+
/**
|
|
564
|
+
* @beta
|
|
565
|
+
* The result of reading part of a design.
|
|
566
|
+
*/
|
|
567
|
+
export type DesignOpenResult = CurrentPageResult;
|
|
568
|
+
/**
|
|
569
|
+
* A function called for each item in the list.
|
|
570
|
+
*
|
|
571
|
+
* @param item - The current item in the list.
|
|
572
|
+
* @param index - The index of the current item.
|
|
573
|
+
*/
|
|
574
|
+
export type ForEachCallback<T> = (item: T, index: number) => void;
|
|
575
|
+
/**
|
|
576
|
+
* A function that determines if an item should be included in the result.
|
|
577
|
+
*
|
|
578
|
+
* @param item - The item to test.
|
|
579
|
+
* @returns `true` if the item should be included, otherwise `false`.
|
|
580
|
+
*/
|
|
581
|
+
export type FilterPredicate<T> = (item: T) => boolean;
|
|
582
|
+
/**
|
|
583
|
+
* A type predicate function that determines if an item is of a specific type.
|
|
584
|
+
*
|
|
585
|
+
* @param item - The item to test.
|
|
586
|
+
* @returns `true` if the item is of type `C`, otherwise `false`.
|
|
587
|
+
*/
|
|
588
|
+
export type TypeFilterPredicate<T, C extends T> = (item: T) => item is C;
|
|
589
|
+
/**
|
|
590
|
+
* A list that cannot be changed.
|
|
591
|
+
*/
|
|
592
|
+
export interface ReadableList<T> {
|
|
593
|
+
/**
|
|
594
|
+
* Gets the number of items in the list.
|
|
595
|
+
*
|
|
596
|
+
* @returns The number of items.
|
|
597
|
+
*/
|
|
598
|
+
count(): number;
|
|
599
|
+
/**
|
|
600
|
+
* Converts the list to an array.
|
|
601
|
+
*
|
|
602
|
+
* @returns An array containing all items. The items are the same as in the list.
|
|
603
|
+
*/
|
|
604
|
+
toArray(): readonly T[];
|
|
605
|
+
/**
|
|
606
|
+
* Executes a function for each item in the list.
|
|
607
|
+
*
|
|
608
|
+
* @param callback - The function to run for each item.
|
|
609
|
+
*/
|
|
610
|
+
forEach(callback: ForEachCallback<T>): void;
|
|
611
|
+
/**
|
|
612
|
+
* Creates a new array with items that match a specific type.
|
|
613
|
+
*
|
|
614
|
+
* @param filter - A function that checks if an item is of type `C`.
|
|
615
|
+
* @returns An array of items that are of type `C`.
|
|
616
|
+
*/
|
|
617
|
+
filter<C extends T>(filter: TypeFilterPredicate<T, C>): readonly C[];
|
|
618
|
+
/**
|
|
619
|
+
* Creates a new array with items that pass a test.
|
|
620
|
+
*
|
|
621
|
+
* @param filter - A function that tests each item. Returns `true` to keep the item.
|
|
622
|
+
* @returns An array of items that passed the test.
|
|
623
|
+
*/
|
|
624
|
+
filter(filter: FilterPredicate<T>): readonly T[];
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* @beta
|
|
628
|
+
* A list of items that can be changed.
|
|
629
|
+
*/
|
|
630
|
+
export interface MutableList<T> {
|
|
631
|
+
/**
|
|
632
|
+
* Adds a copy of an item to the list and places it right before another item.
|
|
633
|
+
*
|
|
634
|
+
* @param ref - The existing item to place the new item before.
|
|
635
|
+
* If `ref` is `undefined`, the new item is added at the end of the list.
|
|
636
|
+
* If `ref` does not exist in the list, the operation fails.
|
|
637
|
+
*
|
|
638
|
+
* @param item - The item to add. A copy of this item will be inserted.
|
|
639
|
+
*
|
|
640
|
+
* @returns
|
|
641
|
+
* The added item, or `undefined` if the operation failed.
|
|
642
|
+
*/
|
|
643
|
+
insertBefore(ref: T | undefined, item: T): T | undefined;
|
|
644
|
+
/**
|
|
645
|
+
* Adds a copy of an item to the list and places it right after another item.
|
|
646
|
+
*
|
|
647
|
+
* @param ref - The existing item to place the new item after.
|
|
648
|
+
* If `ref` is `undefined`, the new item is added at the end of the list.
|
|
649
|
+
* If `ref` does not exist in the list, the operation fails.
|
|
650
|
+
*
|
|
651
|
+
* @param item - The item to add. A copy of this item will be inserted.
|
|
652
|
+
*
|
|
653
|
+
* @returns
|
|
654
|
+
* The added item, or `undefined` if the operation failed.
|
|
655
|
+
*/
|
|
656
|
+
insertAfter(ref: T | undefined, item: T): T | undefined;
|
|
657
|
+
/**
|
|
658
|
+
* Moves an existing item to a new position right before another item.
|
|
659
|
+
*
|
|
660
|
+
* @param ref - The existing item to move the item before.
|
|
661
|
+
* If `ref` is `undefined`, the item is moved to the end of the list.
|
|
662
|
+
* If `ref` does not exist in the list, the operation fails.
|
|
663
|
+
*
|
|
664
|
+
* @param item - The item to move.
|
|
665
|
+
* The operation fails if the item is not already in the list.
|
|
666
|
+
*/
|
|
667
|
+
moveBefore(ref: T | undefined, item: T): void;
|
|
668
|
+
/**
|
|
669
|
+
* Moves an existing item to a new position right after another item.
|
|
670
|
+
*
|
|
671
|
+
* @param ref - The existing item to move the item after.
|
|
672
|
+
* If `ref` is `undefined`, the item is moved to the end of the list.
|
|
673
|
+
* If `ref` does not exist in the list, the operation fails.
|
|
674
|
+
*
|
|
675
|
+
* @param item - The item to move.
|
|
676
|
+
* The operation fails if the item is not already in the list.
|
|
677
|
+
*/
|
|
678
|
+
moveAfter(ref: T | undefined, item: T): void;
|
|
679
|
+
/**
|
|
680
|
+
* Removes an item from the list.
|
|
681
|
+
*
|
|
682
|
+
* @param item - The item to remove from the list.
|
|
683
|
+
*/
|
|
684
|
+
delete(item: T): void;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* @beta
|
|
688
|
+
* A list of items that can be read and updated.
|
|
689
|
+
*/
|
|
690
|
+
export interface List<T> extends ReadableList<T>, MutableList<T> {}
|
|
691
|
+
/**
|
|
692
|
+
* @beta
|
|
693
|
+
* Represents an element that's not supported by the Apps SDK.
|
|
694
|
+
*/
|
|
695
|
+
export interface Unsupported {
|
|
696
|
+
/**
|
|
697
|
+
* The type of element.
|
|
698
|
+
*/
|
|
699
|
+
readonly type: "unsupported";
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* @beta
|
|
703
|
+
* A single valid character in a hex code.
|
|
704
|
+
*/
|
|
705
|
+
export type Hex = `123456790abcdef`[number];
|
|
706
|
+
/**
|
|
707
|
+
* @beta
|
|
708
|
+
* A six-character hexadecimal color code prefixed with a `#`.
|
|
709
|
+
*/
|
|
710
|
+
export type HexCode = `#${Hex}${Hex}${Hex}${Hex}${Hex}${Hex}`;
|
|
711
|
+
/**
|
|
712
|
+
* @beta
|
|
713
|
+
* A set of dimensions.
|
|
714
|
+
*/
|
|
715
|
+
export interface Dimensions {
|
|
716
|
+
/**
|
|
717
|
+
* A width, in pixels.
|
|
718
|
+
*/
|
|
719
|
+
readonly width: number;
|
|
720
|
+
/**
|
|
721
|
+
* A height, in pixels.
|
|
722
|
+
*/
|
|
723
|
+
readonly height: number;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* @beta
|
|
727
|
+
* An image that fills the interior of a path.
|
|
728
|
+
*/
|
|
729
|
+
export interface ImageFill {
|
|
730
|
+
/**
|
|
731
|
+
* The type of media.
|
|
732
|
+
*/
|
|
733
|
+
readonly type: "image";
|
|
734
|
+
/**
|
|
735
|
+
* A unique identifier that points to an image asset in Canva's backend.
|
|
736
|
+
*/
|
|
737
|
+
imageRef: ImageRef;
|
|
738
|
+
/**
|
|
739
|
+
* If `true`, the image is flipped horizontally.
|
|
740
|
+
*/
|
|
741
|
+
flipX: boolean;
|
|
742
|
+
/**
|
|
743
|
+
* If `true`, the image is flipped vertically.
|
|
744
|
+
*/
|
|
745
|
+
flipY: boolean;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* @beta
|
|
749
|
+
* A video that fills the interior of a path.
|
|
750
|
+
*/
|
|
751
|
+
export interface VideoFill {
|
|
752
|
+
/**
|
|
753
|
+
* The type of media.
|
|
754
|
+
*/
|
|
755
|
+
readonly type: "video";
|
|
756
|
+
/**
|
|
757
|
+
* A unique identifier that points to a video asset in Canva's backend.
|
|
758
|
+
*/
|
|
759
|
+
videoRef: VideoRef;
|
|
760
|
+
/**
|
|
761
|
+
* If `true`, the video is flipped horizontally.
|
|
762
|
+
*/
|
|
763
|
+
flipX: boolean;
|
|
764
|
+
/**
|
|
765
|
+
* If `true`, the video is flipped vertically.
|
|
766
|
+
*/
|
|
767
|
+
flipY: boolean;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* @beta
|
|
771
|
+
* A media item that fills the interior of a path.
|
|
772
|
+
*/
|
|
773
|
+
export type MediaFill = ImageFill | VideoFill;
|
|
774
|
+
/**
|
|
775
|
+
* @beta
|
|
776
|
+
* A solid color that fills the interior of a path.
|
|
777
|
+
*/
|
|
778
|
+
export interface SolidFill {
|
|
779
|
+
/**
|
|
780
|
+
* The type of color.
|
|
781
|
+
*/
|
|
782
|
+
readonly type: "solid";
|
|
783
|
+
/**
|
|
784
|
+
* The color of the fill, as a hex code.
|
|
785
|
+
*
|
|
786
|
+
* @remarks
|
|
787
|
+
* - Must be six characters long.
|
|
788
|
+
* - Must start with a `#`.
|
|
789
|
+
* - Must use lowercase letters.
|
|
790
|
+
*/
|
|
791
|
+
color: HexCode;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* @beta
|
|
795
|
+
* A color that fills the interior of a path.
|
|
796
|
+
*/
|
|
797
|
+
export type ColorFill = SolidFill | Unsupported;
|
|
798
|
+
/**
|
|
799
|
+
* @beta
|
|
800
|
+
* Describes how a path is filled with color or media.
|
|
801
|
+
*
|
|
802
|
+
* @remarks
|
|
803
|
+
* If both `media` and `color` are defined, `media` takes precedence.
|
|
804
|
+
*/
|
|
805
|
+
export interface Fill {
|
|
806
|
+
/**
|
|
807
|
+
* The media fill for the path, if any.
|
|
808
|
+
*/
|
|
809
|
+
media: MediaFill | undefined;
|
|
810
|
+
/**
|
|
811
|
+
* The color fill for the path, if any.
|
|
812
|
+
*/
|
|
813
|
+
color: ColorFill | undefined;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* @beta
|
|
817
|
+
* The scale and cropping of a shape.
|
|
818
|
+
*
|
|
819
|
+
* @remarks
|
|
820
|
+
* This is similar to the `viewBox` attribute of an `SVGElement`.
|
|
821
|
+
*/
|
|
822
|
+
export type AlignedBox = {
|
|
823
|
+
/**
|
|
824
|
+
* The distance of the shape from the top edge of the element, in pixels.
|
|
825
|
+
*/
|
|
826
|
+
readonly top: number;
|
|
827
|
+
/**
|
|
828
|
+
* The distance of the shape from the left edge of the element, in pixels.
|
|
829
|
+
*/
|
|
830
|
+
readonly left: number;
|
|
831
|
+
/**
|
|
832
|
+
* The width of the view box, in pixels.
|
|
833
|
+
*/
|
|
834
|
+
readonly width: number;
|
|
835
|
+
/**
|
|
836
|
+
* The height of the view box, in pixels.
|
|
837
|
+
*/
|
|
838
|
+
readonly height: number;
|
|
839
|
+
};
|
|
840
|
+
/**
|
|
841
|
+
* @beta
|
|
842
|
+
* A path that defines the structure of a shape element.
|
|
843
|
+
*/
|
|
844
|
+
export interface Path {
|
|
845
|
+
/**
|
|
846
|
+
* The shape of the path.
|
|
847
|
+
*
|
|
848
|
+
* @remarks
|
|
849
|
+
* This is similar to the `d` attribute of an SVG's `path` element, with some limitations:
|
|
850
|
+
*
|
|
851
|
+
* - Must start with an `M` command.
|
|
852
|
+
* - Only one `M` command is allowed.
|
|
853
|
+
* - `Q` and `T` commands are not permitted.
|
|
854
|
+
* - The path must be closed using a `Z` command or matching start and end coordinates.
|
|
855
|
+
*/
|
|
856
|
+
readonly d: string;
|
|
857
|
+
/**
|
|
858
|
+
* The appearance of the path's interior.
|
|
859
|
+
*/
|
|
860
|
+
readonly fill: Fill;
|
|
861
|
+
/**
|
|
862
|
+
* The stroke (outline) of the path, if any.
|
|
863
|
+
*/
|
|
864
|
+
readonly stroke: Stroke | undefined;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* @beta
|
|
868
|
+
* Represents an outline, such as the border of an element.
|
|
869
|
+
*/
|
|
870
|
+
export interface Stroke {
|
|
871
|
+
/**
|
|
872
|
+
* The weight (thickness) of the stroke.
|
|
873
|
+
*
|
|
874
|
+
* @remarks
|
|
875
|
+
* - Minimum: 0
|
|
876
|
+
* - Maximum: 100
|
|
877
|
+
*/
|
|
878
|
+
weight: number;
|
|
879
|
+
/**
|
|
880
|
+
* The color of the stroke.
|
|
881
|
+
*/
|
|
882
|
+
color: ColorFill;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* @beta
|
|
886
|
+
* The basic properties of an element.
|
|
887
|
+
*
|
|
888
|
+
* @remarks
|
|
889
|
+
* These properties are shared by all elements in a design.
|
|
890
|
+
*/
|
|
891
|
+
export interface Element extends Dimensions {
|
|
892
|
+
/**
|
|
893
|
+
* If `true`, the element is locked and cannot be modified.
|
|
894
|
+
*/
|
|
895
|
+
readonly locked: boolean;
|
|
896
|
+
/**
|
|
897
|
+
* The distance from the top edge of the container, in pixels.
|
|
898
|
+
*
|
|
899
|
+
* @remarks
|
|
900
|
+
* - The pixels are relative to their container.
|
|
901
|
+
* - Minimum: -32768
|
|
902
|
+
* - Maximum: 32767
|
|
903
|
+
*/
|
|
904
|
+
top: number;
|
|
905
|
+
/**
|
|
906
|
+
* The distance from the left edge of the container, in pixels.
|
|
907
|
+
*
|
|
908
|
+
* @remarks
|
|
909
|
+
* - The pixels are relative to their container.
|
|
910
|
+
* - Minimum: -32768
|
|
911
|
+
* - Maximum: 32767
|
|
912
|
+
*/
|
|
913
|
+
left: number;
|
|
914
|
+
/**
|
|
915
|
+
* A rotation, in degrees.
|
|
916
|
+
*
|
|
917
|
+
* @remarks
|
|
918
|
+
* - Minimum: -180
|
|
919
|
+
* - Maximum: 180
|
|
920
|
+
*/
|
|
921
|
+
rotation: number;
|
|
922
|
+
/**
|
|
923
|
+
* Transparency as a percentage.
|
|
924
|
+
*
|
|
925
|
+
* @remarks
|
|
926
|
+
* - Minimum: 0
|
|
927
|
+
* - Maximum: 1
|
|
928
|
+
*/
|
|
929
|
+
transparency: number;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* @beta
|
|
933
|
+
* Represents a rectangular element.
|
|
934
|
+
*/
|
|
935
|
+
export interface Rect {
|
|
936
|
+
/**
|
|
937
|
+
* The type of content.
|
|
938
|
+
*/
|
|
939
|
+
readonly type: "rect";
|
|
940
|
+
/**
|
|
941
|
+
* The appearance of the rectangle's interior.
|
|
942
|
+
*/
|
|
943
|
+
readonly fill: Fill;
|
|
944
|
+
/**
|
|
945
|
+
* The outline of the rectangle.
|
|
946
|
+
*/
|
|
947
|
+
readonly stroke: Stroke;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* @beta
|
|
951
|
+
* Represents a vector shape element.
|
|
952
|
+
*/
|
|
953
|
+
export interface Shape {
|
|
954
|
+
/**
|
|
955
|
+
* The type of content.
|
|
956
|
+
*/
|
|
957
|
+
readonly type: "shape";
|
|
958
|
+
/**
|
|
959
|
+
* The scale and cropping of the shape.
|
|
960
|
+
*/
|
|
961
|
+
viewBox: AlignedBox;
|
|
962
|
+
/**
|
|
963
|
+
* The paths that define the structure of the shape.
|
|
964
|
+
*
|
|
965
|
+
* @remarks
|
|
966
|
+
* - Must have between 1 and 30 paths.
|
|
967
|
+
* - Total size of all paths must not exceed 2kb.
|
|
968
|
+
* - Maximum of 6 unique fill colors across all paths.
|
|
969
|
+
*/
|
|
970
|
+
readonly paths: ReadableList<Path>;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* @beta
|
|
974
|
+
* Represents group content.
|
|
975
|
+
*/
|
|
976
|
+
export interface Group<C> {
|
|
977
|
+
/**
|
|
978
|
+
* The type of content.
|
|
979
|
+
*/
|
|
980
|
+
readonly type: "group";
|
|
981
|
+
/**
|
|
982
|
+
* The elements that exist within the group.
|
|
983
|
+
*/
|
|
984
|
+
readonly contents: ReadableList<C>;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* @beta
|
|
988
|
+
* Represents rich media content.
|
|
989
|
+
*/
|
|
990
|
+
export interface Embed {
|
|
991
|
+
/**
|
|
992
|
+
* The type of content.
|
|
993
|
+
*/
|
|
994
|
+
readonly type: "embed";
|
|
995
|
+
/**
|
|
996
|
+
* The URL of the rich media.
|
|
997
|
+
*
|
|
998
|
+
* @remarks
|
|
999
|
+
* This URL must be supported by the Iframely API.
|
|
1000
|
+
*/
|
|
1001
|
+
readonly url: string;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* @beta
|
|
1005
|
+
* Represents text content.
|
|
1006
|
+
*/
|
|
1007
|
+
export interface Text {
|
|
1008
|
+
/**
|
|
1009
|
+
* The type of content.
|
|
1010
|
+
*/
|
|
1011
|
+
readonly type: "text";
|
|
1012
|
+
/**
|
|
1013
|
+
* The text content.
|
|
1014
|
+
*/
|
|
1015
|
+
readonly text: RichtextRange;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* @beta
|
|
1019
|
+
* An element that renders a rectangle.
|
|
1020
|
+
*
|
|
1021
|
+
* @remarks
|
|
1022
|
+
* The rectangle can be filled with image content, video content, or a solid color.
|
|
1023
|
+
*/
|
|
1024
|
+
export interface RectElement extends Rect, Element {}
|
|
1025
|
+
/**
|
|
1026
|
+
* @beta
|
|
1027
|
+
* An element that renders a vector shape.
|
|
1028
|
+
*/
|
|
1029
|
+
export interface ShapeElement extends Shape, Element {}
|
|
1030
|
+
/**
|
|
1031
|
+
* @beta
|
|
1032
|
+
* An element that renders a group of other elements.
|
|
1033
|
+
*/
|
|
1034
|
+
export interface GroupElement extends Group<GroupContentElement>, Element {}
|
|
1035
|
+
/**
|
|
1036
|
+
* @beta
|
|
1037
|
+
* An element that embeds rich media, such as a YouTube video.
|
|
1038
|
+
*/
|
|
1039
|
+
export interface EmbedElement extends Embed, Element {}
|
|
1040
|
+
/**
|
|
1041
|
+
* @beta
|
|
1042
|
+
* An element that renders text content.
|
|
1043
|
+
*/
|
|
1044
|
+
export interface TextElement extends Text, Element {}
|
|
1045
|
+
/**
|
|
1046
|
+
* @beta
|
|
1047
|
+
* An element that is not supported by the Apps SDK.
|
|
1048
|
+
*/
|
|
1049
|
+
export interface UnsupportedElement extends Unsupported, Element {}
|
|
1050
|
+
/**
|
|
1051
|
+
* @beta
|
|
1052
|
+
* An element that can exist in a group element.
|
|
1053
|
+
*/
|
|
1054
|
+
export type GroupContentElement =
|
|
1055
|
+
| RectElement
|
|
1056
|
+
| ShapeElement
|
|
1057
|
+
| EmbedElement
|
|
1058
|
+
| TextElement
|
|
1059
|
+
| UnsupportedElement;
|
|
1060
|
+
/**
|
|
1061
|
+
* @beta
|
|
1062
|
+
* An element that can exist on a fixed page.
|
|
1063
|
+
*/
|
|
1064
|
+
export type FixedElement =
|
|
1065
|
+
| RectElement
|
|
1066
|
+
| ShapeElement
|
|
1067
|
+
| GroupElement
|
|
1068
|
+
| EmbedElement
|
|
1069
|
+
| TextElement
|
|
1070
|
+
| UnsupportedElement;
|
|
1071
|
+
/**
|
|
1072
|
+
* @beta
|
|
1073
|
+
* A page with fixed dimensions.
|
|
1074
|
+
*/
|
|
1075
|
+
export interface FixedPage {
|
|
1076
|
+
/**
|
|
1077
|
+
* The type of page.
|
|
1078
|
+
*/
|
|
1079
|
+
readonly type: "fixed";
|
|
1080
|
+
/**
|
|
1081
|
+
* If `true`, the page is locked and cannot be modified.
|
|
1082
|
+
*/
|
|
1083
|
+
readonly locked: boolean;
|
|
1084
|
+
/**
|
|
1085
|
+
* The dimensions of the page. `dimensions` is undefined for whiteboard pages.
|
|
1086
|
+
*/
|
|
1087
|
+
readonly dimensions: Dimensions | undefined;
|
|
1088
|
+
/**
|
|
1089
|
+
* The background of the page. `background` is undefined for whiteboard pages.
|
|
1090
|
+
*/
|
|
1091
|
+
readonly background: Fill | undefined;
|
|
1092
|
+
/**
|
|
1093
|
+
* The elements on the page.
|
|
1094
|
+
*
|
|
1095
|
+
* @remarks
|
|
1096
|
+
* Elements are rendered in the order they appear in the list.
|
|
1097
|
+
* Later elements appear on top of earlier ones.
|
|
1098
|
+
*/
|
|
1099
|
+
readonly elements: List<FixedElement>;
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* @beta
|
|
1103
|
+
* A page in a design.
|
|
1104
|
+
*/
|
|
1105
|
+
export type Page = FixedPage | Unsupported;
|
|
1106
|
+
|
|
1107
|
+
{
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
352
1111
|
/**
|
|
353
1112
|
* @public
|
|
354
1113
|
* An element that's natively supported by the Canva editor.
|
|
@@ -363,6 +1122,28 @@ export declare type DesignElement =
|
|
|
363
1122
|
| RichtextElement
|
|
364
1123
|
| TableElement;
|
|
365
1124
|
|
|
1125
|
+
/**
|
|
1126
|
+
* @beta
|
|
1127
|
+
* A callback for reading and updating part of a design.
|
|
1128
|
+
* @param draft - The result of reading part of a design.
|
|
1129
|
+
* @param helpers - Helper methods for reading and updating the design.
|
|
1130
|
+
*/
|
|
1131
|
+
export declare type DesignOpenCallback = (
|
|
1132
|
+
draft: DesignEditing.DesignOpenResult,
|
|
1133
|
+
helpers: {
|
|
1134
|
+
/**
|
|
1135
|
+
* Provides methods for creating elements.
|
|
1136
|
+
*/
|
|
1137
|
+
elementBuilder: DesignEditing.ElementBuilder;
|
|
1138
|
+
},
|
|
1139
|
+
) => Promise<void> | void;
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* @beta
|
|
1143
|
+
* Options for configuring which part of a design to read.
|
|
1144
|
+
*/
|
|
1145
|
+
export declare type DesignOpenOptions = DesignContextOptions;
|
|
1146
|
+
|
|
366
1147
|
/**
|
|
367
1148
|
* @public
|
|
368
1149
|
* Provides methods for managing the lifecycle of overlays, such as selected image overlays.
|
|
@@ -440,37 +1221,55 @@ export declare type Dimensions = {
|
|
|
440
1221
|
|
|
441
1222
|
/**
|
|
442
1223
|
* @public
|
|
443
|
-
*
|
|
1224
|
+
* An event that occurs when a user starts dragging an HTML element.
|
|
444
1225
|
*/
|
|
445
|
-
export declare type
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
onDragStart: (element: HTMLElement) => void;
|
|
451
|
-
/**
|
|
452
|
-
* A callback that runs at the end of a drag event.
|
|
453
|
-
* @param element - The element being dragged.
|
|
454
|
-
*/
|
|
455
|
-
onDragEnd: (element: HTMLElement) => void;
|
|
1226
|
+
export declare type DragStartEvent<E extends Element> = Pick<
|
|
1227
|
+
DragEvent,
|
|
1228
|
+
"dataTransfer" | "currentTarget" | "preventDefault" | "clientX" | "clientY"
|
|
1229
|
+
> & {
|
|
1230
|
+
currentTarget: E;
|
|
456
1231
|
};
|
|
457
1232
|
|
|
458
1233
|
/**
|
|
459
1234
|
* @public
|
|
460
|
-
*
|
|
1235
|
+
* Reads and edits content of the specified type from the user's design.
|
|
1236
|
+
* @param options - Options for configuring how a design is read.
|
|
1237
|
+
* @param callback - A callback for operating on the read content.
|
|
461
1238
|
*/
|
|
462
|
-
export declare
|
|
1239
|
+
export declare const editContent: (
|
|
1240
|
+
options: EditContentOptions,
|
|
1241
|
+
callback: EditContentCallback,
|
|
1242
|
+
) => Promise<void>;
|
|
463
1243
|
|
|
464
1244
|
/**
|
|
465
1245
|
* @public
|
|
466
|
-
*
|
|
1246
|
+
* A callback for reading and updating the requested design content.
|
|
1247
|
+
* @param session - The result of reading the content in the design.
|
|
467
1248
|
*/
|
|
468
|
-
export declare type
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
1249
|
+
export declare type EditContentCallback = (session: {
|
|
1250
|
+
/**
|
|
1251
|
+
* The individual content items returned by a query.
|
|
1252
|
+
*/
|
|
1253
|
+
readonly contents: readonly RichtextContentRange[];
|
|
1254
|
+
/**
|
|
1255
|
+
* Commits any changes made to the items in the `contents` array.
|
|
1256
|
+
*
|
|
1257
|
+
* @remarks
|
|
1258
|
+
* An app must call this method for any changes to be reflected in the user's design.
|
|
1259
|
+
*/
|
|
1260
|
+
sync(): Promise<void>;
|
|
1261
|
+
}) => Promise<void> | void;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* @public
|
|
1265
|
+
* Options for configuring how the design content is read.
|
|
1266
|
+
*/
|
|
1267
|
+
export declare type EditContentOptions = {
|
|
1268
|
+
/**
|
|
1269
|
+
* The type of content to edit from the user's design
|
|
1270
|
+
*/
|
|
1271
|
+
contentType: ContentType;
|
|
1272
|
+
} & ContextOptions;
|
|
474
1273
|
|
|
475
1274
|
/**
|
|
476
1275
|
* @public
|
|
@@ -497,17 +1296,6 @@ export declare type ElementAtPoint =
|
|
|
497
1296
|
| GroupElementAtPoint
|
|
498
1297
|
| RichtextElementAtPoint;
|
|
499
1298
|
|
|
500
|
-
/**
|
|
501
|
-
* @public
|
|
502
|
-
* Options for adding drag and drop behavior to an `HTMLElement`.
|
|
503
|
-
*/
|
|
504
|
-
export declare type ElementData = DragCallback & {
|
|
505
|
-
/**
|
|
506
|
-
* The `HTMLElement` to be made draggable.
|
|
507
|
-
*/
|
|
508
|
-
node: HTMLElement;
|
|
509
|
-
};
|
|
510
|
-
|
|
511
1299
|
/**
|
|
512
1300
|
* @public
|
|
513
1301
|
* Embed element to be added to the design at the end of a drag event.
|
|
@@ -843,6 +1631,9 @@ export declare type ImageElement = {
|
|
|
843
1631
|
type: "image";
|
|
844
1632
|
/**
|
|
845
1633
|
* A description of the image content.
|
|
1634
|
+
*
|
|
1635
|
+
* @remarks
|
|
1636
|
+
* Use `undefined` for content with no description.
|
|
846
1637
|
*/
|
|
847
1638
|
altText: AltText | undefined;
|
|
848
1639
|
} & (
|
|
@@ -876,17 +1667,6 @@ export declare type ImageElementAtPoint = ImageElement &
|
|
|
876
1667
|
Point &
|
|
877
1668
|
(WidthAndHeight | Width | Height);
|
|
878
1669
|
|
|
879
|
-
/**
|
|
880
|
-
* @public
|
|
881
|
-
* Options for adding drag and drop behavior to an `HTMLImageElement`.
|
|
882
|
-
*/
|
|
883
|
-
export declare type ImageElementData = DragCallback & {
|
|
884
|
-
/**
|
|
885
|
-
* The `HTMLImageElement` to be made draggable.
|
|
886
|
-
*/
|
|
887
|
-
node: HTMLImageElement;
|
|
888
|
-
};
|
|
889
|
-
|
|
890
1670
|
/**
|
|
891
1671
|
* @public
|
|
892
1672
|
* An image asset that fills a path's interior.
|
|
@@ -900,6 +1680,13 @@ export declare type ImageFill = {
|
|
|
900
1680
|
* A unique identifier that points to an image asset in Canva's backend.
|
|
901
1681
|
*/
|
|
902
1682
|
ref: ImageRef;
|
|
1683
|
+
/**
|
|
1684
|
+
* A description of the image content.
|
|
1685
|
+
*
|
|
1686
|
+
* @remarks
|
|
1687
|
+
* Use `undefined` for content with no description.
|
|
1688
|
+
*/
|
|
1689
|
+
altText?: AltText;
|
|
903
1690
|
};
|
|
904
1691
|
|
|
905
1692
|
/**
|
|
@@ -911,11 +1698,11 @@ export declare type ImageRef = string & {
|
|
|
911
1698
|
};
|
|
912
1699
|
|
|
913
1700
|
/**
|
|
914
|
-
* @
|
|
1701
|
+
* @beta
|
|
915
1702
|
* @param appElementConfig - Configuration for an AppElementClient
|
|
916
1703
|
*/
|
|
917
1704
|
export declare const initAppElement: <A extends AppElementData>(
|
|
918
|
-
appElementConfig: AppElementClientConfiguration<A
|
|
1705
|
+
appElementConfig: AppElementClientConfiguration<A>,
|
|
919
1706
|
) => AppElementClient<A>;
|
|
920
1707
|
|
|
921
1708
|
/**
|
|
@@ -1097,6 +1884,23 @@ export declare type NativeVideoElementWithBox = VideoElementAtPoint;
|
|
|
1097
1884
|
*/
|
|
1098
1885
|
declare type ObjectPrimitive = Boolean | String;
|
|
1099
1886
|
|
|
1887
|
+
/**
|
|
1888
|
+
* @beta
|
|
1889
|
+
* Reads a specified part of the user's design and returns all elements in that part.
|
|
1890
|
+
*
|
|
1891
|
+
* @param options - Options for configuring how the design is read.
|
|
1892
|
+
* @param callback - A callback for operating on the design.
|
|
1893
|
+
*/
|
|
1894
|
+
export declare const openDesign: (
|
|
1895
|
+
options: DesignOpenOptions,
|
|
1896
|
+
callback: (
|
|
1897
|
+
draft: DesignEditing.DesignOpenResult,
|
|
1898
|
+
helpers: {
|
|
1899
|
+
elementBuilder: DesignEditing.ElementBuilder;
|
|
1900
|
+
},
|
|
1901
|
+
) => Promise<void> | void,
|
|
1902
|
+
) => Promise<void>;
|
|
1903
|
+
|
|
1100
1904
|
/**
|
|
1101
1905
|
* @public
|
|
1102
1906
|
* An alias for the DesignOverlay interface, providing access to design overlay related functionality
|
|
@@ -1271,9 +2075,20 @@ declare type Primitive = undefined | null | number | boolean | string;
|
|
|
1271
2075
|
* @param request - The request object containing configurations of the design export.
|
|
1272
2076
|
*/
|
|
1273
2077
|
export declare const requestExport: (
|
|
1274
|
-
request: ExportRequest
|
|
2078
|
+
request: ExportRequest,
|
|
1275
2079
|
) => Promise<ExportResponse>;
|
|
1276
2080
|
|
|
2081
|
+
/**
|
|
2082
|
+
* @public
|
|
2083
|
+
* Provides methods for interacting with a range of formatted text.
|
|
2084
|
+
*/
|
|
2085
|
+
export declare interface RichtextContentRange extends RichtextRange {
|
|
2086
|
+
/**
|
|
2087
|
+
* Indicates whether the object containing this richtext range has been deleted.
|
|
2088
|
+
*/
|
|
2089
|
+
readonly deleted: boolean;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
1277
2092
|
/**
|
|
1278
2093
|
* @public
|
|
1279
2094
|
* An element that renders richtext content.
|
|
@@ -1381,7 +2196,7 @@ export declare type RichtextRange = {
|
|
|
1381
2196
|
*/
|
|
1382
2197
|
appendText(
|
|
1383
2198
|
characters: string,
|
|
1384
|
-
formatting?: InlineFormatting
|
|
2199
|
+
formatting?: InlineFormatting,
|
|
1385
2200
|
): {
|
|
1386
2201
|
bounds: Bounds;
|
|
1387
2202
|
};
|
|
@@ -1395,7 +2210,7 @@ export declare type RichtextRange = {
|
|
|
1395
2210
|
replaceText(
|
|
1396
2211
|
bounds: Bounds,
|
|
1397
2212
|
characters: string,
|
|
1398
|
-
formatting?: InlineFormatting
|
|
2213
|
+
formatting?: InlineFormatting,
|
|
1399
2214
|
): {
|
|
1400
2215
|
/**
|
|
1401
2216
|
* The bounds of the replacement characters within the updated range.
|
|
@@ -1533,7 +2348,7 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
|
|
|
1533
2348
|
* an image or a video.
|
|
1534
2349
|
*/
|
|
1535
2350
|
export declare const setCurrentPageBackground: (
|
|
1536
|
-
opts: PageBackgroundFill
|
|
2351
|
+
opts: PageBackgroundFill,
|
|
1537
2352
|
) => Promise<void>;
|
|
1538
2353
|
|
|
1539
2354
|
/**
|
|
@@ -1746,6 +2561,11 @@ export declare type TextDragConfig = {
|
|
|
1746
2561
|
* @defaultValue "none"
|
|
1747
2562
|
*/
|
|
1748
2563
|
decoration?: "none" | "underline";
|
|
2564
|
+
/**
|
|
2565
|
+
* @beta
|
|
2566
|
+
* A unique identifier that points to a font asset in Canva's backend.
|
|
2567
|
+
*/
|
|
2568
|
+
fontRef?: FontRef;
|
|
1749
2569
|
};
|
|
1750
2570
|
|
|
1751
2571
|
/**
|
|
@@ -1770,7 +2590,7 @@ export declare type TextElement = {
|
|
|
1770
2590
|
* @public
|
|
1771
2591
|
* An element that renders text content and has positional properties.
|
|
1772
2592
|
*/
|
|
1773
|
-
export declare type TextElementAtPoint = TextElement &
|
|
2593
|
+
export declare type TextElementAtPoint = TextElement & TextBox;
|
|
1774
2594
|
|
|
1775
2595
|
/**
|
|
1776
2596
|
* @public
|
|
@@ -1807,7 +2627,7 @@ export declare interface UI {
|
|
|
1807
2627
|
| AudioDragConfig
|
|
1808
2628
|
| EmbedDragConfig
|
|
1809
2629
|
| VideoDragConfigForElement<E>
|
|
1810
|
-
| ImageDragConfigForElement<E
|
|
2630
|
+
| ImageDragConfigForElement<E>,
|
|
1811
2631
|
): Promise<void>;
|
|
1812
2632
|
/**
|
|
1813
2633
|
* @public
|
|
@@ -1823,7 +2643,7 @@ export declare interface UI {
|
|
|
1823
2643
|
| AudioDragConfig
|
|
1824
2644
|
| EmbedDragConfig
|
|
1825
2645
|
| VideoDragConfigForElement<E>
|
|
1826
|
-
| ImageDragConfigForElement<E
|
|
2646
|
+
| ImageDragConfigForElement<E>,
|
|
1827
2647
|
): Promise<void>;
|
|
1828
2648
|
/**
|
|
1829
2649
|
* @public
|
|
@@ -1837,7 +2657,7 @@ export declare interface UI {
|
|
|
1837
2657
|
dragData:
|
|
1838
2658
|
| EmbedDragConfig
|
|
1839
2659
|
| VideoDragConfigForElement<E>
|
|
1840
|
-
| ImageDragConfigForElement<E
|
|
2660
|
+
| ImageDragConfigForElement<E>,
|
|
1841
2661
|
): Promise<void>;
|
|
1842
2662
|
}
|
|
1843
2663
|
|
|
@@ -1917,6 +2737,9 @@ export declare type VideoElement = {
|
|
|
1917
2737
|
ref: VideoRef;
|
|
1918
2738
|
/**
|
|
1919
2739
|
* A description of the video content.
|
|
2740
|
+
*
|
|
2741
|
+
* @remarks
|
|
2742
|
+
* Use `undefined` for content with no description.
|
|
1920
2743
|
*/
|
|
1921
2744
|
altText: AltText | undefined;
|
|
1922
2745
|
};
|
|
@@ -1942,6 +2765,13 @@ export declare type VideoFill = {
|
|
|
1942
2765
|
* A unique identifier that points to a video asset in Canva's backend.
|
|
1943
2766
|
*/
|
|
1944
2767
|
ref: VideoRef;
|
|
2768
|
+
/**
|
|
2769
|
+
* A description of the image content.
|
|
2770
|
+
*
|
|
2771
|
+
* @remarks
|
|
2772
|
+
* Use `undefined` for content with no description.
|
|
2773
|
+
*/
|
|
2774
|
+
altText?: AltText;
|
|
1945
2775
|
};
|
|
1946
2776
|
|
|
1947
2777
|
/**
|