@canva/design 2.7.6-beta.1 → 2.7.6-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/beta.d.ts +90 -30
- package/lib/cjs/sdk/design/beta.js +4 -8
- package/lib/cjs/sdk/design/fake/create_beta.js +19 -6
- package/lib/cjs/sdk/design/fake/fake_design_interaction_client.js +15 -5
- package/lib/cjs/sdk/design/public.js +8 -0
- package/lib/cjs/sdk/design/version.js +1 -1
- package/lib/esm/sdk/design/beta.js +1 -2
- package/lib/esm/sdk/design/fake/create_beta.js +19 -6
- package/lib/esm/sdk/design/fake/fake_design_interaction_client.js +15 -5
- package/lib/esm/sdk/design/public.js +2 -0
- package/lib/esm/sdk/design/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/beta.d.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beta
|
|
3
|
+
* Information about a page within a design with fixed or unbounded dimensions.
|
|
4
|
+
*/
|
|
5
|
+
export declare type AbsolutePageMetadata = {
|
|
6
|
+
/**
|
|
7
|
+
* The type of page.
|
|
8
|
+
*/
|
|
9
|
+
type: 'absolute';
|
|
10
|
+
/**
|
|
11
|
+
* The dimensions of the page, in pixels.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This may be `undefined` because some types of pages don't have dimensions, such as whiteboards.
|
|
15
|
+
*/
|
|
16
|
+
dimensions?: PageDimensions;
|
|
17
|
+
/**
|
|
18
|
+
* The name of the page.
|
|
19
|
+
* @remarks
|
|
20
|
+
* This is optional and will be empty if the user hasn't set a title.
|
|
21
|
+
*/
|
|
22
|
+
title?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
1
25
|
/**
|
|
2
26
|
* Adds an audio track to the user's design.
|
|
3
27
|
* @public
|
|
@@ -880,18 +904,18 @@ export declare type Bounds = {
|
|
|
880
904
|
export declare type Box = Point & (WidthAndHeight | Width | Height);
|
|
881
905
|
|
|
882
906
|
/**
|
|
883
|
-
* @
|
|
907
|
+
* @public
|
|
884
908
|
* An alias for the BulkCreateLauncher interface, providing access to bulk create related functionality
|
|
885
909
|
*/
|
|
886
910
|
export declare const bulkCreate: BulkCreateLauncher;
|
|
887
911
|
|
|
888
912
|
/**
|
|
889
|
-
* @
|
|
913
|
+
* @public
|
|
890
914
|
* Provides methods for launching the bulk create panel.
|
|
891
915
|
*/
|
|
892
916
|
export declare type BulkCreateLauncher = {
|
|
893
917
|
/**
|
|
894
|
-
* @
|
|
918
|
+
* @public
|
|
895
919
|
* Launches the design bulk create with the data connector intent.
|
|
896
920
|
* @param opts - Options for configuring the bulk create panel.
|
|
897
921
|
* @throws unsupported_surface code if not invoked by the design editor intent.
|
|
@@ -2701,7 +2725,7 @@ export declare namespace DesignEditing {
|
|
|
2701
2725
|
export declare type DesignElement = ImageElement | VideoElement | EmbedElement | TextElement | ShapeElement | GroupElement | RichtextElement | TableElement;
|
|
2702
2726
|
|
|
2703
2727
|
/**
|
|
2704
|
-
* @
|
|
2728
|
+
* @beta
|
|
2705
2729
|
* Information about the design.
|
|
2706
2730
|
*/
|
|
2707
2731
|
export declare type DesignMetadata = {
|
|
@@ -2946,6 +2970,48 @@ export declare type DesignSelection = {
|
|
|
2946
2970
|
* });
|
|
2947
2971
|
* ```
|
|
2948
2972
|
*
|
|
2973
|
+
* @example Edit selected image and upload with parentRef
|
|
2974
|
+
* ```typescript
|
|
2975
|
+
* import { selection } from "@canva/design";
|
|
2976
|
+
* import { getTemporaryUrl, upload } from "@canva/asset";
|
|
2977
|
+
*
|
|
2978
|
+
* selection.registerOnChange({
|
|
2979
|
+
* scope: 'image',
|
|
2980
|
+
* onChange: async (event) => {
|
|
2981
|
+
* if (event.count > 0) {
|
|
2982
|
+
* const draft = await event.read();
|
|
2983
|
+
*
|
|
2984
|
+
* for (const content of draft.contents) {
|
|
2985
|
+
* // Fetch a temporary URL to the original image
|
|
2986
|
+
* const { url } = await getTemporaryUrl({
|
|
2987
|
+
* type: "image",
|
|
2988
|
+
* ref: content.ref
|
|
2989
|
+
* });
|
|
2990
|
+
*
|
|
2991
|
+
* // Apply any edits you want to the image
|
|
2992
|
+
* const processedImageUrl = await applyImageEffect(url);
|
|
2993
|
+
*
|
|
2994
|
+
* // Upload the edited image with parentRef
|
|
2995
|
+
* const asset = await upload({
|
|
2996
|
+
* type: "image",
|
|
2997
|
+
* parentRef: content.ref,
|
|
2998
|
+
* url: processedImageUrl,
|
|
2999
|
+
* mimeType: "image/jpeg",
|
|
3000
|
+
* thumbnailUrl: processedImageUrl,
|
|
3001
|
+
* aiDisclosure: "app_generated"
|
|
3002
|
+
* });
|
|
3003
|
+
*
|
|
3004
|
+
* // Replace the image ref with the new image ref
|
|
3005
|
+
* content.ref = asset.ref;
|
|
3006
|
+
* }
|
|
3007
|
+
*
|
|
3008
|
+
* // Save the changes to the design
|
|
3009
|
+
* await draft.save();
|
|
3010
|
+
* }
|
|
3011
|
+
* }
|
|
3012
|
+
* });
|
|
3013
|
+
* ```
|
|
3014
|
+
*
|
|
2949
3015
|
* @example Handling video selection
|
|
2950
3016
|
* ```typescript
|
|
2951
3017
|
* import { selection } from "@canva/design";
|
|
@@ -3498,17 +3564,8 @@ export declare const getCurrentPageContext: () => Promise<PageContext>;
|
|
|
3498
3564
|
export declare const getDefaultPageDimensions: () => Promise<Dimensions | undefined>;
|
|
3499
3565
|
|
|
3500
3566
|
/**
|
|
3501
|
-
* @
|
|
3567
|
+
* @beta
|
|
3502
3568
|
* Retrieves information about the design.
|
|
3503
|
-
*
|
|
3504
|
-
* @example Get design metadata
|
|
3505
|
-
* ```typescript
|
|
3506
|
-
* import { getDesignMetadata } from "@canva/design";
|
|
3507
|
-
*
|
|
3508
|
-
* const metadata = await getDesignMetadata();
|
|
3509
|
-
*
|
|
3510
|
-
* const { title, defaultPageDimensions, pageMetadata, durationInSeconds } = metadata;
|
|
3511
|
-
* ```
|
|
3512
3569
|
*/
|
|
3513
3570
|
export declare const getDesignMetadata: () => Promise<DesignMetadata>;
|
|
3514
3571
|
|
|
@@ -3779,7 +3836,7 @@ export declare type InlineFormatting = {
|
|
|
3779
3836
|
};
|
|
3780
3837
|
|
|
3781
3838
|
/**
|
|
3782
|
-
* @
|
|
3839
|
+
* @public
|
|
3783
3840
|
* Options for configuring the bulk create panel.
|
|
3784
3841
|
*/
|
|
3785
3842
|
export declare type LaunchBulkCreateOpts = {
|
|
@@ -3790,7 +3847,7 @@ export declare type LaunchBulkCreateOpts = {
|
|
|
3790
3847
|
};
|
|
3791
3848
|
|
|
3792
3849
|
/**
|
|
3793
|
-
* @
|
|
3850
|
+
* @public
|
|
3794
3851
|
* Options for configuring the publish menu.
|
|
3795
3852
|
*/
|
|
3796
3853
|
export declare type LaunchPublishOpts = {
|
|
@@ -4021,18 +4078,10 @@ export declare type PageDimensions = {
|
|
|
4021
4078
|
};
|
|
4022
4079
|
|
|
4023
4080
|
/**
|
|
4024
|
-
* @
|
|
4025
|
-
* Information about a page.
|
|
4081
|
+
* @beta
|
|
4082
|
+
* Information about a page within a design.
|
|
4026
4083
|
*/
|
|
4027
|
-
export declare type PageMetadata =
|
|
4028
|
-
/**
|
|
4029
|
-
* The dimensions of the page, in pixels.
|
|
4030
|
-
*
|
|
4031
|
-
* @remarks
|
|
4032
|
-
* This may be `undefined` because some types of pages don't have dimensions, such as whiteboards.
|
|
4033
|
-
*/
|
|
4034
|
-
dimensions?: PageDimensions;
|
|
4035
|
-
};
|
|
4084
|
+
export declare type PageMetadata = AbsolutePageMetadata | UnsupportedPageMetadata;
|
|
4036
4085
|
|
|
4037
4086
|
/**
|
|
4038
4087
|
* @public
|
|
@@ -4110,18 +4159,18 @@ declare type Point = {
|
|
|
4110
4159
|
declare type Primitive = undefined | null | number | boolean | string;
|
|
4111
4160
|
|
|
4112
4161
|
/**
|
|
4113
|
-
* @
|
|
4162
|
+
* @public
|
|
4114
4163
|
* An alias for the PublishLauncher interface, providing access to design publishing related functionality
|
|
4115
4164
|
*/
|
|
4116
4165
|
export declare const publish: PublishLauncher;
|
|
4117
4166
|
|
|
4118
4167
|
/**
|
|
4119
|
-
* @
|
|
4168
|
+
* @public
|
|
4120
4169
|
* Provides methods for launching the publish menu
|
|
4121
4170
|
*/
|
|
4122
4171
|
export declare type PublishLauncher = {
|
|
4123
4172
|
/**
|
|
4124
|
-
* @
|
|
4173
|
+
* @public
|
|
4125
4174
|
* Launches the design publish with the content publisher intent.
|
|
4126
4175
|
* @param opts - Options for configuring the publish menu.
|
|
4127
4176
|
* @throws unsupported_surface code if not invoked by the design editor intent.
|
|
@@ -5139,6 +5188,17 @@ export declare interface UI {
|
|
|
5139
5188
|
*/
|
|
5140
5189
|
export declare const ui: UI;
|
|
5141
5190
|
|
|
5191
|
+
/**
|
|
5192
|
+
* @beta
|
|
5193
|
+
* Pages that do not have fixed or unbounded dimensions currently do not return metadata.
|
|
5194
|
+
*/
|
|
5195
|
+
export declare type UnsupportedPageMetadata = {
|
|
5196
|
+
/**
|
|
5197
|
+
* The type of page.
|
|
5198
|
+
*/
|
|
5199
|
+
type: 'unsupported';
|
|
5200
|
+
};
|
|
5201
|
+
|
|
5142
5202
|
/**
|
|
5143
5203
|
* @public
|
|
5144
5204
|
* A data type that can be used in app element data.
|
|
@@ -9,20 +9,17 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
get bulkCreate () {
|
|
13
|
-
return bulkCreate;
|
|
14
|
-
},
|
|
15
12
|
get editContent () {
|
|
16
13
|
return editContent;
|
|
17
14
|
},
|
|
15
|
+
get getDesignMetadata () {
|
|
16
|
+
return getDesignMetadata;
|
|
17
|
+
},
|
|
18
18
|
get getDesignTemplateMetadata () {
|
|
19
19
|
return getDesignTemplateMetadata;
|
|
20
20
|
},
|
|
21
21
|
get openDesign () {
|
|
22
22
|
return openDesign;
|
|
23
|
-
},
|
|
24
|
-
get publish () {
|
|
25
|
-
return publish;
|
|
26
23
|
}
|
|
27
24
|
});
|
|
28
25
|
const _version = require("./version");
|
|
@@ -41,8 +38,7 @@ function _export_star(from, to) {
|
|
|
41
38
|
return from;
|
|
42
39
|
}
|
|
43
40
|
const { canva_sdk } = window;
|
|
44
|
-
const
|
|
45
|
-
const bulkCreate = canva_sdk.design.v2.designInteraction.bulkCreate;
|
|
41
|
+
const getDesignMetadata = canva_sdk.design.v2.designInteraction.getDesignMetadata;
|
|
46
42
|
function editContent(options, callback) {
|
|
47
43
|
return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
|
|
48
44
|
}
|
|
@@ -57,12 +57,25 @@ class FakeBetaDesignInteractionClient extends _fake_design_interaction_client.Fa
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
getDesignMetadata() {
|
|
61
|
+
return Promise.resolve({
|
|
62
|
+
title: 'title',
|
|
63
|
+
defaultPageDimensions: {
|
|
64
|
+
width: 800,
|
|
65
|
+
height: 600
|
|
66
|
+
},
|
|
67
|
+
pageMetadata: [
|
|
68
|
+
{
|
|
69
|
+
title: 'title',
|
|
70
|
+
type: 'absolute',
|
|
71
|
+
pageDimensions: {
|
|
72
|
+
width: 800,
|
|
73
|
+
height: 600
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
durationInSeconds: 30
|
|
78
|
+
});
|
|
66
79
|
}
|
|
67
80
|
}
|
|
68
81
|
const fakePageRef = {
|
|
@@ -36,19 +36,23 @@ class FakeDesignInteractionClient {
|
|
|
36
36
|
},
|
|
37
37
|
pageMetadata: [
|
|
38
38
|
{
|
|
39
|
+
type: 'absolute',
|
|
39
40
|
dimensions: {
|
|
40
41
|
width: 800,
|
|
41
42
|
height: 600
|
|
42
|
-
}
|
|
43
|
+
},
|
|
44
|
+
title: 'page1'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'unsupported'
|
|
43
48
|
},
|
|
44
49
|
{
|
|
50
|
+
type: 'absolute',
|
|
45
51
|
dimensions: {
|
|
46
52
|
width: 300,
|
|
47
53
|
height: 900
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
dimensions: undefined
|
|
54
|
+
},
|
|
55
|
+
title: undefined
|
|
52
56
|
}
|
|
53
57
|
],
|
|
54
58
|
durationInSeconds: 30
|
|
@@ -154,6 +158,12 @@ class FakeDesignInteractionClient {
|
|
|
154
158
|
return ()=>{};
|
|
155
159
|
}
|
|
156
160
|
};
|
|
161
|
+
this.publish = {
|
|
162
|
+
launch: ()=>this.delay()
|
|
163
|
+
};
|
|
164
|
+
this.bulkCreate = {
|
|
165
|
+
launch: ()=>this.delay()
|
|
166
|
+
};
|
|
157
167
|
}
|
|
158
168
|
}
|
|
159
169
|
const fakeBounds = {
|
|
@@ -24,6 +24,9 @@ _export(exports, {
|
|
|
24
24
|
get addPage () {
|
|
25
25
|
return addPage;
|
|
26
26
|
},
|
|
27
|
+
get bulkCreate () {
|
|
28
|
+
return bulkCreate;
|
|
29
|
+
},
|
|
27
30
|
get createRichtextRange () {
|
|
28
31
|
return createRichtextRange;
|
|
29
32
|
},
|
|
@@ -51,6 +54,9 @@ _export(exports, {
|
|
|
51
54
|
get overlay () {
|
|
52
55
|
return overlay;
|
|
53
56
|
},
|
|
57
|
+
get publish () {
|
|
58
|
+
return publish;
|
|
59
|
+
},
|
|
54
60
|
get requestExport () {
|
|
55
61
|
return requestExport;
|
|
56
62
|
},
|
|
@@ -83,3 +89,5 @@ const getDesignMetadata = canva_sdk.design.v2.designInteraction.getDesignMetadat
|
|
|
83
89
|
const createRichtextRange = canva_sdk.design.v2.designInteraction.createRichtextRange;
|
|
84
90
|
const editContent = canva_sdk.design.v2.designInteraction.editContent;
|
|
85
91
|
const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
|
|
92
|
+
const publish = canva_sdk.design.v2.designInteraction.publish;
|
|
93
|
+
const bulkCreate = canva_sdk.design.v2.designInteraction.bulkCreate;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LATEST_VERSION_BETA } from './version';
|
|
2
2
|
const { canva_sdk } = window;
|
|
3
|
-
export const
|
|
4
|
-
export const bulkCreate = canva_sdk.design.v2.designInteraction.bulkCreate;
|
|
3
|
+
export const getDesignMetadata = canva_sdk.design.v2.designInteraction.getDesignMetadata;
|
|
5
4
|
export function editContent(options, callback) {
|
|
6
5
|
return canva_sdk.design.v2.designInteraction.editContent(options, (session)=>callback(session));
|
|
7
6
|
}
|
|
@@ -47,12 +47,25 @@ class FakeBetaDesignInteractionClient extends FakeDesignInteractionClient {
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
getDesignMetadata() {
|
|
51
|
+
return Promise.resolve({
|
|
52
|
+
title: 'title',
|
|
53
|
+
defaultPageDimensions: {
|
|
54
|
+
width: 800,
|
|
55
|
+
height: 600
|
|
56
|
+
},
|
|
57
|
+
pageMetadata: [
|
|
58
|
+
{
|
|
59
|
+
title: 'title',
|
|
60
|
+
type: 'absolute',
|
|
61
|
+
pageDimensions: {
|
|
62
|
+
width: 800,
|
|
63
|
+
height: 600
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
durationInSeconds: 30
|
|
68
|
+
});
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
const fakePageRef = {
|
|
@@ -15,19 +15,23 @@ export class FakeDesignInteractionClient {
|
|
|
15
15
|
},
|
|
16
16
|
pageMetadata: [
|
|
17
17
|
{
|
|
18
|
+
type: 'absolute',
|
|
18
19
|
dimensions: {
|
|
19
20
|
width: 800,
|
|
20
21
|
height: 600
|
|
21
|
-
}
|
|
22
|
+
},
|
|
23
|
+
title: 'page1'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'unsupported'
|
|
22
27
|
},
|
|
23
28
|
{
|
|
29
|
+
type: 'absolute',
|
|
24
30
|
dimensions: {
|
|
25
31
|
width: 300,
|
|
26
32
|
height: 900
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
dimensions: undefined
|
|
33
|
+
},
|
|
34
|
+
title: undefined
|
|
31
35
|
}
|
|
32
36
|
],
|
|
33
37
|
durationInSeconds: 30
|
|
@@ -133,6 +137,12 @@ export class FakeDesignInteractionClient {
|
|
|
133
137
|
return ()=>{};
|
|
134
138
|
}
|
|
135
139
|
};
|
|
140
|
+
this.publish = {
|
|
141
|
+
launch: ()=>this.delay()
|
|
142
|
+
};
|
|
143
|
+
this.bulkCreate = {
|
|
144
|
+
launch: ()=>this.delay()
|
|
145
|
+
};
|
|
136
146
|
}
|
|
137
147
|
}
|
|
138
148
|
const fakeBounds = {
|
|
@@ -17,3 +17,5 @@ export const getDesignMetadata = canva_sdk.design.v2.designInteraction.getDesign
|
|
|
17
17
|
export const createRichtextRange = canva_sdk.design.v2.designInteraction.createRichtextRange;
|
|
18
18
|
export const editContent = canva_sdk.design.v2.designInteraction.editContent;
|
|
19
19
|
export const openDesign = canva_sdk.design.v2.designInteraction.openDesign;
|
|
20
|
+
export const publish = canva_sdk.design.v2.designInteraction.publish;
|
|
21
|
+
export const bulkCreate = canva_sdk.design.v2.designInteraction.bulkCreate;
|