@canva/design 1.7.0 → 1.9.0
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 +82 -3
- package/lib/cjs/sdk/design/index.js +18 -16
- package/lib/cjs/sdk/design/public.js +51 -68
- package/lib/esm/sdk/design/index.js +1 -0
- package/lib/esm/sdk/design/public.js +16 -22
- package/package.json +11 -5
package/index.d.ts
CHANGED
|
@@ -99,6 +99,14 @@ export declare type AppElementRenderer<A extends AppElementData> = (
|
|
|
99
99
|
*/
|
|
100
100
|
export declare type AppElementRendererOutput = NativeSimpleElementWithBox[];
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
* A unique identifier that references an app runtime process
|
|
105
|
+
*/
|
|
106
|
+
export declare type AppProcessId = string & {
|
|
107
|
+
__appProcessId: never;
|
|
108
|
+
};
|
|
109
|
+
|
|
102
110
|
/**
|
|
103
111
|
* @public
|
|
104
112
|
* Options for defining the drag-and-drop behavior of audio tracks.
|
|
@@ -205,6 +213,23 @@ export declare type Coordinates = {
|
|
|
205
213
|
y: number;
|
|
206
214
|
};
|
|
207
215
|
|
|
216
|
+
/**
|
|
217
|
+
* @public
|
|
218
|
+
* Provides methods for interacting with design overlay
|
|
219
|
+
*/
|
|
220
|
+
export declare type DesignOverlay = {
|
|
221
|
+
/**
|
|
222
|
+
* Registers a callback that runs when an overlay canOpen status changed on a particular target.
|
|
223
|
+
*
|
|
224
|
+
* @remarks
|
|
225
|
+
* The callback fires immediately
|
|
226
|
+
*/
|
|
227
|
+
registerOnCanOpen<Target extends OverlayTarget>(opts: {
|
|
228
|
+
target: Target;
|
|
229
|
+
onCanOpen(event: OverlayOpenableEvent<Target>): void;
|
|
230
|
+
}): () => void;
|
|
231
|
+
};
|
|
232
|
+
|
|
208
233
|
/**
|
|
209
234
|
* @public
|
|
210
235
|
* Provides methods for interacting with the user's selected content, such as images or text.
|
|
@@ -938,6 +963,51 @@ export declare type NativeVideoElementWithBox = NativeVideoElement & Box;
|
|
|
938
963
|
*/
|
|
939
964
|
declare type ObjectPrimitive = Boolean | String;
|
|
940
965
|
|
|
966
|
+
/**
|
|
967
|
+
* @public
|
|
968
|
+
* An alias for the DesignOverlay interface, providing access to design overlay related functionality
|
|
969
|
+
*/
|
|
970
|
+
export declare const overlay: DesignOverlay;
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* @public
|
|
974
|
+
* Information about whether the overlay can be opened or not on a particular {@link OverlayTarget}
|
|
975
|
+
*/
|
|
976
|
+
export declare type OverlayOpenableEvent<Target extends OverlayTarget> = {
|
|
977
|
+
/**
|
|
978
|
+
* An event indicating whether the overlay can be opened or not when {@link OverlayTarget} is `"image_selection"`
|
|
979
|
+
*/
|
|
980
|
+
["image_selection"]:
|
|
981
|
+
| OverlayUnopenableEvent
|
|
982
|
+
| {
|
|
983
|
+
canOpen: true;
|
|
984
|
+
/**
|
|
985
|
+
* Launch a new app process on an overlay on top of the current selected image fill
|
|
986
|
+
*
|
|
987
|
+
* @remarks
|
|
988
|
+
* `launchParameters` specifies the type of data that are provided to an app process at its launch
|
|
989
|
+
*/
|
|
990
|
+
readonly open: (options: {
|
|
991
|
+
launchParameters?: any;
|
|
992
|
+
}) => Promise<AppProcessId>;
|
|
993
|
+
};
|
|
994
|
+
}[Target];
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* @public
|
|
998
|
+
* The target to check if an overlay can be opened for
|
|
999
|
+
*/
|
|
1000
|
+
export declare type OverlayTarget = "image_selection";
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* @public
|
|
1004
|
+
* Information about the overlay when it can not be opened on a particular {@link OverlayTarget}
|
|
1005
|
+
*/
|
|
1006
|
+
declare type OverlayUnopenableEvent = {
|
|
1007
|
+
canOpen: false;
|
|
1008
|
+
reason: string;
|
|
1009
|
+
};
|
|
1010
|
+
|
|
941
1011
|
/**
|
|
942
1012
|
* @public
|
|
943
1013
|
* The appearance of a page's background.
|
|
@@ -1083,7 +1153,7 @@ export declare interface SelectionEvent<Scope extends SelectionScope> {
|
|
|
1083
1153
|
* @public
|
|
1084
1154
|
* The type of content that apps can detect selection changes on.
|
|
1085
1155
|
*/
|
|
1086
|
-
export declare type SelectionScope = "plaintext" | "image";
|
|
1156
|
+
export declare type SelectionScope = "plaintext" | "image" | "video";
|
|
1087
1157
|
|
|
1088
1158
|
/**
|
|
1089
1159
|
* @public
|
|
@@ -1111,6 +1181,15 @@ export declare type SelectionValue<Scope extends SelectionScope> = {
|
|
|
1111
1181
|
*/
|
|
1112
1182
|
ref: ImageRef;
|
|
1113
1183
|
};
|
|
1184
|
+
/**
|
|
1185
|
+
* The selected content when {@link SelectionScope} is `"video"`.
|
|
1186
|
+
*/
|
|
1187
|
+
["video"]: {
|
|
1188
|
+
/**
|
|
1189
|
+
* A unique identifier that points to an video asset in Canva's backend.
|
|
1190
|
+
*/
|
|
1191
|
+
ref: VideoRef;
|
|
1192
|
+
};
|
|
1114
1193
|
}[Scope];
|
|
1115
1194
|
|
|
1116
1195
|
/**
|
|
@@ -1196,7 +1275,7 @@ export declare type TextAttributes = {
|
|
|
1196
1275
|
* The alignment of the text.
|
|
1197
1276
|
* @defaultValue 'start'
|
|
1198
1277
|
*/
|
|
1199
|
-
textAlign?: "start" | "center" | "end";
|
|
1278
|
+
textAlign?: "start" | "center" | "end" | "justify";
|
|
1200
1279
|
/**
|
|
1201
1280
|
* The color of the text as a hex code.
|
|
1202
1281
|
*
|
|
@@ -1244,7 +1323,7 @@ export declare type TextDragConfig = {
|
|
|
1244
1323
|
* The alignment of the text.
|
|
1245
1324
|
* @defaultValue 'start'
|
|
1246
1325
|
*/
|
|
1247
|
-
textAlign?: "start" | "center" | "end";
|
|
1326
|
+
textAlign?: "start" | "center" | "end" | "justify";
|
|
1248
1327
|
/**
|
|
1249
1328
|
* The weight of the font.
|
|
1250
1329
|
* @defaultValue 'normal'
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
// Copyright 2023 Canva Inc. All Rights Reserved.
|
|
1
2
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
_export_star(require("./public"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
@@ -1,97 +1,80 @@
|
|
|
1
|
+
// Copyright 2023 Canva Inc. All Rights Reserved.
|
|
1
2
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
selection: function() {
|
|
14
|
+
return selection;
|
|
15
|
+
},
|
|
16
|
+
overlay: function() {
|
|
17
|
+
return overlay;
|
|
18
|
+
},
|
|
19
|
+
addPage: function() {
|
|
20
|
+
return addPage;
|
|
21
|
+
},
|
|
22
|
+
setCurrentPageBackground: function() {
|
|
23
|
+
return setCurrentPageBackground;
|
|
24
|
+
},
|
|
25
|
+
getDefaultPageDimensions: function() {
|
|
26
|
+
return getDefaultPageDimensions;
|
|
27
|
+
},
|
|
28
|
+
requestExport: function() {
|
|
29
|
+
return requestExport;
|
|
30
|
+
},
|
|
31
|
+
ui: function() {
|
|
32
|
+
return ui;
|
|
33
|
+
},
|
|
34
|
+
addNativeElement: function() {
|
|
35
|
+
return addNativeElement;
|
|
36
|
+
},
|
|
37
|
+
addAudioTrack: function() {
|
|
38
|
+
return addAudioTrack;
|
|
39
|
+
},
|
|
40
|
+
getCurrentPageContext: function() {
|
|
41
|
+
return getCurrentPageContext;
|
|
42
|
+
},
|
|
43
|
+
initAppElement: function() {
|
|
44
|
+
return initAppElement;
|
|
45
|
+
},
|
|
46
|
+
getDesignToken: function() {
|
|
47
|
+
return getDesignToken;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
4
50
|
const { canva } = window;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* An alias for the DesignSelection interface, providing access to design selection related functionality
|
|
8
|
-
*/
|
|
9
|
-
exports.selection = canva.designInteraction.selection;
|
|
10
|
-
/**
|
|
11
|
-
* @public
|
|
12
|
-
* Adds a new page immediately after the currently selected page.
|
|
13
|
-
* @param opts - Configuration for the new page to be added.
|
|
14
|
-
*/
|
|
51
|
+
const selection = canva.designInteraction.selection;
|
|
52
|
+
const overlay = canva.designInteraction.overlay;
|
|
15
53
|
function addPage(opts) {
|
|
16
54
|
return canva.designInteraction.addPage(opts);
|
|
17
55
|
}
|
|
18
|
-
exports.addPage = addPage;
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
* Updates the background of the user's current page. The background can be a solid color,
|
|
22
|
-
* an image or a video.
|
|
23
|
-
*/
|
|
24
56
|
function setCurrentPageBackground(opts) {
|
|
25
57
|
return canva.designInteraction.setCurrentPageBackground(opts);
|
|
26
58
|
}
|
|
27
|
-
exports.setCurrentPageBackground = setCurrentPageBackground;
|
|
28
|
-
/**
|
|
29
|
-
* @public
|
|
30
|
-
* Gets the default dimensions that a new page will have when it is added to a design.
|
|
31
|
-
* It is possible for a user to resize a page without resizing the entire design, e.g. by clicking
|
|
32
|
-
* "Expand to Whiteboard". However, there will always be a single set of default dimensions for a
|
|
33
|
-
* design that is applied whenever a new page is created.
|
|
34
|
-
*
|
|
35
|
-
* Returns `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
|
|
36
|
-
*/
|
|
37
59
|
function getDefaultPageDimensions() {
|
|
38
60
|
return canva.designInteraction.getDefaultPageDimensions();
|
|
39
61
|
}
|
|
40
|
-
exports.getDefaultPageDimensions = getDefaultPageDimensions;
|
|
41
|
-
/**
|
|
42
|
-
* @public
|
|
43
|
-
* Exports the user's design as one or more static files.
|
|
44
|
-
* @param request - The request object containing configurations of the design export.
|
|
45
|
-
*/
|
|
46
62
|
function requestExport(request) {
|
|
47
63
|
return canva.export.requestExport(request);
|
|
48
64
|
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* An alias for the UI interface, providing access to ui related functionality
|
|
52
|
-
* @public
|
|
53
|
-
*/
|
|
54
|
-
exports.ui = canva.dragAndDrop;
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
* Adds a native element to the user's design.
|
|
58
|
-
* @param element - The element to add to the user's design.
|
|
59
|
-
*/
|
|
65
|
+
const ui = canva.dragAndDrop;
|
|
60
66
|
function addNativeElement(element) {
|
|
61
67
|
return canva.designInteraction.addNativeElement(element);
|
|
62
68
|
}
|
|
63
|
-
exports.addNativeElement = addNativeElement;
|
|
64
|
-
/**
|
|
65
|
-
* Adds an audio track to the user's design.
|
|
66
|
-
* @public
|
|
67
|
-
* @param audioTrack - The audio track to add to the user's design.
|
|
68
|
-
*/
|
|
69
69
|
function addAudioTrack(audioTrack) {
|
|
70
70
|
return canva.designInteraction.addAudioTrack(audioTrack);
|
|
71
71
|
}
|
|
72
|
-
exports.addAudioTrack = addAudioTrack;
|
|
73
|
-
/**
|
|
74
|
-
* Allows to get the context of currently selected page.
|
|
75
|
-
* @public
|
|
76
|
-
* @returns Page context of currently selected page
|
|
77
|
-
*/
|
|
78
72
|
function getCurrentPageContext() {
|
|
79
73
|
return canva.designInteraction.getCurrentPageContext();
|
|
80
74
|
}
|
|
81
|
-
exports.getCurrentPageContext = getCurrentPageContext;
|
|
82
|
-
/**
|
|
83
|
-
* @public
|
|
84
|
-
* @param appElementConfig - Configuration for an AppElementClient
|
|
85
|
-
*/
|
|
86
75
|
function initAppElement(appElementConfig) {
|
|
87
76
|
return canva.designInteraction.initAppElement(appElementConfig);
|
|
88
77
|
}
|
|
89
|
-
exports.initAppElement = initAppElement;
|
|
90
|
-
/**
|
|
91
|
-
* @public
|
|
92
|
-
* Retrieves a signed JWT that contains the Design ID, App ID and User ID.
|
|
93
|
-
*/
|
|
94
78
|
function getDesignToken() {
|
|
95
79
|
return canva.designInteraction.getDesignToken();
|
|
96
80
|
}
|
|
97
|
-
exports.getDesignToken = getDesignToken;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
+
// Copyright 2023 Canva Inc. All Rights Reserved.
|
|
1
2
|
const { canva } = window;
|
|
2
3
|
/**
|
|
3
4
|
* @public
|
|
4
5
|
* An alias for the DesignSelection interface, providing access to design selection related functionality
|
|
5
|
-
*/
|
|
6
|
-
|
|
6
|
+
*/ export const selection = canva.designInteraction.selection;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
* An alias for the DesignOverlay interface, providing access to design overlay related functionality
|
|
10
|
+
*/ export const overlay = canva.designInteraction.overlay;
|
|
7
11
|
/**
|
|
8
12
|
* @public
|
|
9
13
|
* Adds a new page immediately after the currently selected page.
|
|
10
14
|
* @param opts - Configuration for the new page to be added.
|
|
11
|
-
*/
|
|
12
|
-
export function addPage(opts) {
|
|
15
|
+
*/ export function addPage(opts) {
|
|
13
16
|
return canva.designInteraction.addPage(opts);
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* @public
|
|
17
20
|
* Updates the background of the user's current page. The background can be a solid color,
|
|
18
21
|
* an image or a video.
|
|
19
|
-
*/
|
|
20
|
-
export function setCurrentPageBackground(opts) {
|
|
22
|
+
*/ export function setCurrentPageBackground(opts) {
|
|
21
23
|
return canva.designInteraction.setCurrentPageBackground(opts);
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
@@ -28,58 +30,50 @@ export function setCurrentPageBackground(opts) {
|
|
|
28
30
|
* design that is applied whenever a new page is created.
|
|
29
31
|
*
|
|
30
32
|
* Returns `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
|
|
31
|
-
*/
|
|
32
|
-
export function getDefaultPageDimensions() {
|
|
33
|
+
*/ export function getDefaultPageDimensions() {
|
|
33
34
|
return canva.designInteraction.getDefaultPageDimensions();
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* @public
|
|
37
38
|
* Exports the user's design as one or more static files.
|
|
38
39
|
* @param request - The request object containing configurations of the design export.
|
|
39
|
-
*/
|
|
40
|
-
export function requestExport(request) {
|
|
40
|
+
*/ export function requestExport(request) {
|
|
41
41
|
return canva.export.requestExport(request);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* An alias for the UI interface, providing access to ui related functionality
|
|
45
45
|
* @public
|
|
46
|
-
*/
|
|
47
|
-
export const ui = canva.dragAndDrop;
|
|
46
|
+
*/ export const ui = canva.dragAndDrop;
|
|
48
47
|
/**
|
|
49
48
|
* @public
|
|
50
49
|
* Adds a native element to the user's design.
|
|
51
50
|
* @param element - The element to add to the user's design.
|
|
52
|
-
*/
|
|
53
|
-
export function addNativeElement(element) {
|
|
51
|
+
*/ export function addNativeElement(element) {
|
|
54
52
|
return canva.designInteraction.addNativeElement(element);
|
|
55
53
|
}
|
|
56
54
|
/**
|
|
57
55
|
* Adds an audio track to the user's design.
|
|
58
56
|
* @public
|
|
59
57
|
* @param audioTrack - The audio track to add to the user's design.
|
|
60
|
-
*/
|
|
61
|
-
export function addAudioTrack(audioTrack) {
|
|
58
|
+
*/ export function addAudioTrack(audioTrack) {
|
|
62
59
|
return canva.designInteraction.addAudioTrack(audioTrack);
|
|
63
60
|
}
|
|
64
61
|
/**
|
|
65
62
|
* Allows to get the context of currently selected page.
|
|
66
63
|
* @public
|
|
67
64
|
* @returns Page context of currently selected page
|
|
68
|
-
*/
|
|
69
|
-
export function getCurrentPageContext() {
|
|
65
|
+
*/ export function getCurrentPageContext() {
|
|
70
66
|
return canva.designInteraction.getCurrentPageContext();
|
|
71
67
|
}
|
|
72
68
|
/**
|
|
73
69
|
* @public
|
|
74
70
|
* @param appElementConfig - Configuration for an AppElementClient
|
|
75
|
-
*/
|
|
76
|
-
export function initAppElement(appElementConfig) {
|
|
71
|
+
*/ export function initAppElement(appElementConfig) {
|
|
77
72
|
return canva.designInteraction.initAppElement(appElementConfig);
|
|
78
73
|
}
|
|
79
74
|
/**
|
|
80
75
|
* @public
|
|
81
76
|
* Retrieves a signed JWT that contains the Design ID, App ID and User ID.
|
|
82
|
-
*/
|
|
83
|
-
export function getDesignToken() {
|
|
77
|
+
*/ export function getDesignToken() {
|
|
84
78
|
return canva.designInteraction.getDesignToken();
|
|
85
79
|
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canva/design",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "The Canva Apps SDK design library",
|
|
5
5
|
"author": "Canva Pty Ltd.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md FILE",
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@canva/error": "^1.0.0"
|
|
9
9
|
},
|
|
10
|
-
"main": "lib/cjs/sdk/design/index.js",
|
|
11
|
-
"module": "lib/esm/sdk/design/index.js",
|
|
10
|
+
"main": "./lib/cjs/sdk/design/index.js",
|
|
11
|
+
"module": "./lib/esm/sdk/design/index.js",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"require":
|
|
15
|
-
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"default": "./lib/cjs/sdk/design/index.js"
|
|
17
|
+
},
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"default": "./lib/esm/sdk/design/index.js"
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
},
|
|
18
24
|
"typings": "./index.d.ts"
|