@canva/design 0.0.1-rc.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/LICENSE.md +48 -0
- package/index.d.ts +1373 -0
- package/lib/cjs/sdk/design/index.js +17 -0
- package/lib/cjs/sdk/design/public.js +75 -0
- package/lib/esm/sdk/design/index.js +1 -0
- package/lib/esm/sdk/design/public.js +65 -0
- package/package.json +19 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,1373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds an audio track to the user's design.
|
|
3
|
+
* @public
|
|
4
|
+
* @param audioTrack - The audio track to add to the user's design.
|
|
5
|
+
*/
|
|
6
|
+
export declare function addAudioTrack(audioTrack: AudioTrack): Promise<void>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
* Adds a native element to the user's design.
|
|
11
|
+
* @param element - The element to add to the user's design.
|
|
12
|
+
*/
|
|
13
|
+
export declare function addNativeElement(
|
|
14
|
+
element: NativeElement | NativeElementWithBox
|
|
15
|
+
): Promise<void>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
* Adds a new page immediately after the currently selected page.
|
|
20
|
+
* @param opts - Configuration for the new page to be added.
|
|
21
|
+
*/
|
|
22
|
+
export declare function addPage(opts?: {
|
|
23
|
+
/** Elements to be added to the page */
|
|
24
|
+
elements?: NativeElementWithBox[];
|
|
25
|
+
|
|
26
|
+
/** A page title which must be no longer than 255 characters */
|
|
27
|
+
title?: string;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @public
|
|
32
|
+
* A callback that runs when an app element's data is created or updated,
|
|
33
|
+
* or when the user selects an existing app element.
|
|
34
|
+
*/
|
|
35
|
+
export declare type AppElementChangeHandler<A extends AppElementData> = (
|
|
36
|
+
appElement:
|
|
37
|
+
| {
|
|
38
|
+
data: A;
|
|
39
|
+
version: number;
|
|
40
|
+
}
|
|
41
|
+
| undefined
|
|
42
|
+
) => void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
* A client interface for managing app elements and app element data.
|
|
47
|
+
*/
|
|
48
|
+
export declare interface AppElementClient<A extends AppElementData> {
|
|
49
|
+
/**
|
|
50
|
+
* Attaches data to the selected app element or creates a new app element if one is not selected.
|
|
51
|
+
* If data already exists, it's overwritten.
|
|
52
|
+
* @param appElementData - The data to attach to the app element.
|
|
53
|
+
*/
|
|
54
|
+
addOrUpdateElement(appElementData: A, placement?: Placement): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Registers a callback that runs when the app element's data is created or
|
|
57
|
+
* updated and when the user selects an existing app element.
|
|
58
|
+
* @param handler - The callback to run when the app element's data is changed
|
|
59
|
+
* and when the user selects an existing app element.
|
|
60
|
+
*/
|
|
61
|
+
registerOnElementChange(handler: AppElementChangeHandler<A>): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @public
|
|
66
|
+
* Configuration for an AppElementClient
|
|
67
|
+
*/
|
|
68
|
+
export declare type AppElementClientConfiguration<A extends AppElementData> = {
|
|
69
|
+
/**
|
|
70
|
+
* The AppElementRenderer to use when rendering the app element
|
|
71
|
+
*/
|
|
72
|
+
render: AppElementRenderer<A>;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @public
|
|
77
|
+
* The data an app can attach to an app element.
|
|
78
|
+
*/
|
|
79
|
+
export declare type AppElementData = Record<string, Value>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @public
|
|
83
|
+
* A callback that runs when an app's element is changed.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* This callback must return one or more elements to render within the app element.
|
|
87
|
+
*/
|
|
88
|
+
export declare type AppElementRenderer<A extends AppElementData> = (
|
|
89
|
+
appElementData: A
|
|
90
|
+
) => AppElementRendererOutput;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @public
|
|
94
|
+
* A return value of {@link AppElementRenderer} function.
|
|
95
|
+
* It is an array of elements to render within an app element.
|
|
96
|
+
*/
|
|
97
|
+
export declare type AppElementRendererOutput = NativeSimpleElementWithBox[];
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @public
|
|
101
|
+
* Options for defining the drag-and-drop behavior of audio tracks.
|
|
102
|
+
*/
|
|
103
|
+
export declare type AudioDragConfig = {
|
|
104
|
+
/**
|
|
105
|
+
* The type of element.
|
|
106
|
+
*/
|
|
107
|
+
type: "AUDIO";
|
|
108
|
+
/**
|
|
109
|
+
* A function that returns a reference (ref) to an audio asset in Canva's backend.
|
|
110
|
+
*/
|
|
111
|
+
resolveAudioRef: () => Promise<{
|
|
112
|
+
ref: AudioRef;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* The duration of the audio track, in milliseconds.
|
|
116
|
+
*/
|
|
117
|
+
durationMs: number;
|
|
118
|
+
/**
|
|
119
|
+
* A human readable title for the audio track.
|
|
120
|
+
*/
|
|
121
|
+
title: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @public
|
|
126
|
+
* A unique identifier that references an audio asset in Canva's backend.
|
|
127
|
+
*/
|
|
128
|
+
export declare type AudioRef = string & {
|
|
129
|
+
__audioRef: never;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @public
|
|
134
|
+
* An audio track that can be added to a user's design.
|
|
135
|
+
*/
|
|
136
|
+
export declare type AudioTrack = {
|
|
137
|
+
/**
|
|
138
|
+
* A unique identifier that references an audio asset in Canva's backend.
|
|
139
|
+
*/
|
|
140
|
+
ref: AudioRef;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @public
|
|
145
|
+
* The dimensions, position, and rotation of an element.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* Units are relative to the parent container both in terms of position and size
|
|
149
|
+
*/
|
|
150
|
+
declare type Box = Position & (WidthAndHeight | Width | Height);
|
|
151
|
+
|
|
152
|
+
declare type CommonImageDragConfig = {
|
|
153
|
+
/**
|
|
154
|
+
* The type of element.
|
|
155
|
+
*/
|
|
156
|
+
type: "IMAGE";
|
|
157
|
+
/**
|
|
158
|
+
* The dimensions of the preview image.
|
|
159
|
+
*
|
|
160
|
+
* @remarks
|
|
161
|
+
* The preview image is the image that users see under their cursor while dragging
|
|
162
|
+
* it into their design.
|
|
163
|
+
*/
|
|
164
|
+
previewSize: Dimensions;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @public
|
|
169
|
+
* Represents X and Y coordinates.
|
|
170
|
+
*/
|
|
171
|
+
export declare type Coordinates = {
|
|
172
|
+
/**
|
|
173
|
+
* Represents an X coordinate, in pixels.
|
|
174
|
+
*/
|
|
175
|
+
x: number;
|
|
176
|
+
/**
|
|
177
|
+
* Represents a Y coordinate, in pixels.
|
|
178
|
+
*/
|
|
179
|
+
y: number;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @public
|
|
184
|
+
* Represents a width and a height.
|
|
185
|
+
*/
|
|
186
|
+
export declare type Dimensions = {
|
|
187
|
+
/**
|
|
188
|
+
* Represents a width, in pixels.
|
|
189
|
+
*/
|
|
190
|
+
width: number;
|
|
191
|
+
/**
|
|
192
|
+
* Represents a height, in pixels.
|
|
193
|
+
*/
|
|
194
|
+
height: number;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @public
|
|
199
|
+
* Callbacks that run during the lifecycle of a drag-and-drop.
|
|
200
|
+
*/
|
|
201
|
+
export declare type DragCallback = {
|
|
202
|
+
/**
|
|
203
|
+
* A callback that runs when the user starts dragging an element into their design.
|
|
204
|
+
*
|
|
205
|
+
* @param element - The element being dragged into the user's design.
|
|
206
|
+
*/
|
|
207
|
+
onDragStart: (element: HTMLElement) => void;
|
|
208
|
+
/**
|
|
209
|
+
* A callback that runs when the user finishes dragging an element into their design.
|
|
210
|
+
*
|
|
211
|
+
* @param element - The element being dragged into the user's design.
|
|
212
|
+
*/
|
|
213
|
+
onDragEnd: (element: HTMLElement) => void;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @public
|
|
218
|
+
* Options for making an element draggable.
|
|
219
|
+
*/
|
|
220
|
+
export declare type DraggableElementData = ElementData | ImageElementData;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @public
|
|
224
|
+
* Represents a drag start event that occurs when initiating a drag-and-drop behavior inside the app.
|
|
225
|
+
*/
|
|
226
|
+
export declare type DragStartEvent<E extends Element> = Pick<
|
|
227
|
+
DragEvent,
|
|
228
|
+
"dataTransfer" | "currentTarget" | "preventDefault" | "clientX" | "clientY"
|
|
229
|
+
> & {
|
|
230
|
+
currentTarget: E;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @public
|
|
235
|
+
* Options for making an `HTMLElement` draggable.
|
|
236
|
+
*/
|
|
237
|
+
export declare type ElementData = DragCallback & {
|
|
238
|
+
/**
|
|
239
|
+
* The element to be made draggable.
|
|
240
|
+
*/
|
|
241
|
+
node: HTMLElement;
|
|
242
|
+
/**
|
|
243
|
+
* Options for defining the drag-and-drop behavior.
|
|
244
|
+
*
|
|
245
|
+
* @remarks
|
|
246
|
+
* This data is required because it can't be inferred from the `node` property.
|
|
247
|
+
*/
|
|
248
|
+
dragData: UserSuppliedDragData;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @public
|
|
253
|
+
*
|
|
254
|
+
* Options for defining the drag-and-drop behaviour for embeds.
|
|
255
|
+
*/
|
|
256
|
+
export declare type EmbedDragConfig = {
|
|
257
|
+
/**
|
|
258
|
+
* The type of element.
|
|
259
|
+
*/
|
|
260
|
+
type: "EMBED";
|
|
261
|
+
/**
|
|
262
|
+
* The dimensions of the preview image.
|
|
263
|
+
* The preview image is the image that users see under their cursor
|
|
264
|
+
* while dragging it into their design.
|
|
265
|
+
*/
|
|
266
|
+
previewSize: Dimensions;
|
|
267
|
+
/**
|
|
268
|
+
* Represents the preview image of the embed.
|
|
269
|
+
*/
|
|
270
|
+
previewUrl: string;
|
|
271
|
+
/**
|
|
272
|
+
* Represents the embed source url.
|
|
273
|
+
*/
|
|
274
|
+
embedUrl: string;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @public
|
|
279
|
+
* Export aborted response
|
|
280
|
+
*
|
|
281
|
+
* @remarks
|
|
282
|
+
* Ane export flow is considered aborted when a user closes
|
|
283
|
+
* the export options menu.
|
|
284
|
+
*/
|
|
285
|
+
export declare type ExportAborted = {
|
|
286
|
+
/**
|
|
287
|
+
* The status of the export flow when the user has aborted the export menu.
|
|
288
|
+
*/
|
|
289
|
+
status: "ABORTED";
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @public
|
|
294
|
+
* The exported file.
|
|
295
|
+
*/
|
|
296
|
+
export declare type ExportBlob = {
|
|
297
|
+
/**
|
|
298
|
+
* The URL of the exported design.
|
|
299
|
+
*
|
|
300
|
+
* @remarks
|
|
301
|
+
* If the user's design contains multiple pages but is exported in a format that doesn't support multiple pages, the URL will point to a ZIP file that contains each page as a separate file.
|
|
302
|
+
*
|
|
303
|
+
* For example:
|
|
304
|
+
*
|
|
305
|
+
* - If a single-page design is exported as a JPG, the URL will point to a JPG file
|
|
306
|
+
* - If a multi-page design is exported as a JPG, the URL will point to a ZIP file that contains a separate JPG file for each page
|
|
307
|
+
* - If a multi-page design is exported as a PDF, the URL will point to a PDF file that contains all of the pages
|
|
308
|
+
*
|
|
309
|
+
* The following file types support multiple pages:
|
|
310
|
+
*
|
|
311
|
+
* - `"GIF"`
|
|
312
|
+
* - `"PDF_STANDARD"`
|
|
313
|
+
* - `"PPTX"`
|
|
314
|
+
* - `"VIDEO"`
|
|
315
|
+
*
|
|
316
|
+
* The following file types do not support multiple pages:
|
|
317
|
+
*
|
|
318
|
+
* - `"JPG"`
|
|
319
|
+
* - `"PNG"`
|
|
320
|
+
* - `"SVG"`
|
|
321
|
+
*/
|
|
322
|
+
url: string;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @public
|
|
327
|
+
* Export completed response
|
|
328
|
+
*/
|
|
329
|
+
export declare type ExportCompleted = {
|
|
330
|
+
/**
|
|
331
|
+
* The status of the export flow when the user has submitted the export menu.
|
|
332
|
+
*/
|
|
333
|
+
status: "COMPLETED";
|
|
334
|
+
/**
|
|
335
|
+
* The title of the successful export of a design, if it has been set by the user.
|
|
336
|
+
*/
|
|
337
|
+
title?: string;
|
|
338
|
+
/**
|
|
339
|
+
* The exported files.
|
|
340
|
+
*
|
|
341
|
+
* @remarks
|
|
342
|
+
* This array only contains one element. This is because, if a multi-page design is exported as multiple files, the files are exported in a ZIP file. In the future, there'll be an option for each file to be a separate element in the array.
|
|
343
|
+
*/
|
|
344
|
+
exportBlobs: ExportBlob[];
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @public
|
|
349
|
+
* The types of files that Canva supports for exported designs.
|
|
350
|
+
*/
|
|
351
|
+
export declare type ExportFileType =
|
|
352
|
+
| "PNG"
|
|
353
|
+
| "JPG"
|
|
354
|
+
| "PDF_STANDARD"
|
|
355
|
+
| "VIDEO"
|
|
356
|
+
| "GIF"
|
|
357
|
+
| "PPTX"
|
|
358
|
+
| "SVG";
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @public
|
|
362
|
+
* The options for configuring the export of a design.
|
|
363
|
+
*/
|
|
364
|
+
export declare type ExportRequest = {
|
|
365
|
+
/**
|
|
366
|
+
* The types of files the user can export their design as.
|
|
367
|
+
*
|
|
368
|
+
* @remarks
|
|
369
|
+
* You must provide at least one file type.
|
|
370
|
+
*/
|
|
371
|
+
acceptedFileTypes: ExportFileType[];
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* @public
|
|
376
|
+
* The response of an export request.
|
|
377
|
+
*/
|
|
378
|
+
export declare type ExportResponse = ExportCompleted | ExportAborted;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* @public
|
|
382
|
+
*
|
|
383
|
+
* Options for defining the Drag and Drop behaviour for images uploaded
|
|
384
|
+
* via the Content capability.
|
|
385
|
+
*/
|
|
386
|
+
export declare type ExternalImageDragConfig = CommonImageDragConfig & {
|
|
387
|
+
/**
|
|
388
|
+
* The function that resolves an image ref
|
|
389
|
+
* @remarks
|
|
390
|
+
*
|
|
391
|
+
* This function will be run during the drag process in order to fetch the media ref of the
|
|
392
|
+
* external image being fetched. This function should return the result of `upload`
|
|
393
|
+
* from the content capability.
|
|
394
|
+
*/
|
|
395
|
+
resolveImageRef: () => Promise<{
|
|
396
|
+
ref: ImageRef;
|
|
397
|
+
}>;
|
|
398
|
+
/**
|
|
399
|
+
* The URL of the preview image.
|
|
400
|
+
*
|
|
401
|
+
* @remarks
|
|
402
|
+
* The preview image is the image that users see under their cursor while dragging
|
|
403
|
+
* it into their design.
|
|
404
|
+
*/
|
|
405
|
+
previewUrl: string;
|
|
406
|
+
/**
|
|
407
|
+
* The dimensions of the full-size image.
|
|
408
|
+
*
|
|
409
|
+
* @remarks
|
|
410
|
+
* The full-size image is the image that Canva uploads to the user's account and
|
|
411
|
+
* adds to their design.
|
|
412
|
+
*
|
|
413
|
+
* If omitted, the value of the `previewSize` property is used as a fallback.
|
|
414
|
+
*/
|
|
415
|
+
fullSize?: Dimensions;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* @public
|
|
420
|
+
* The appearance of a path's interior.
|
|
421
|
+
*/
|
|
422
|
+
export declare type Fill = {
|
|
423
|
+
/**
|
|
424
|
+
* Boolean defining whether image or video can be dropped on the fill by the user.
|
|
425
|
+
* If set to true, images or videos can be dropped on the fill.
|
|
426
|
+
*/
|
|
427
|
+
dropTarget?: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* The color of the fill as a hex code.
|
|
430
|
+
*
|
|
431
|
+
* @remarks
|
|
432
|
+
* The hex code must include all six characters and be prefixed with a # symbol (e.g. #ff0099).
|
|
433
|
+
* Only one type of fill (color, image or video) can be set.
|
|
434
|
+
*/
|
|
435
|
+
color?: string;
|
|
436
|
+
/**
|
|
437
|
+
* An asset (image or video) that will be used to fill the given path.
|
|
438
|
+
*
|
|
439
|
+
* @remarks
|
|
440
|
+
* Only one type of fill (color, image or video) can be set.
|
|
441
|
+
*/
|
|
442
|
+
asset?: ImageFill | VideoFill;
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Allows to get the context of currently selected page.
|
|
447
|
+
* @public
|
|
448
|
+
* @returns Page context of currently selected page
|
|
449
|
+
*/
|
|
450
|
+
export declare function getCurrentPageContext(): Promise<PageContext>;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* @public
|
|
454
|
+
* Gets the default dimensions that a new page will have when it is added to a design.
|
|
455
|
+
* It is possible for a user to resize a page without resizing the entire design, e.g. by clicking
|
|
456
|
+
* "Expand to Whiteboard". However, there will always be a single set of default dimensions for a
|
|
457
|
+
* design that is applied whenever a new page is created.
|
|
458
|
+
*
|
|
459
|
+
* Returns `undefined` if the design is unbounded (e.g. Whiteboard or Doc).
|
|
460
|
+
*/
|
|
461
|
+
export declare function getDefaultPageDimensions(): Promise<
|
|
462
|
+
Dimensions | undefined
|
|
463
|
+
>;
|
|
464
|
+
|
|
465
|
+
declare type Height = {
|
|
466
|
+
width: "auto";
|
|
467
|
+
height: number;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* @public
|
|
472
|
+
* Options for defining the drag-and-drop behavior of an image element that can be defined by an
|
|
473
|
+
* app developer.
|
|
474
|
+
*/
|
|
475
|
+
export declare type ImageDragConfig = ExternalImageDragConfig;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* @public
|
|
479
|
+
* Options for defining the drag-and-drop behavior for images.
|
|
480
|
+
*/
|
|
481
|
+
export declare type ImageDragConfigForElement<E extends Element> =
|
|
482
|
+
E extends HTMLImageElement
|
|
483
|
+
? Partial<ImageDragConfig> & Pick<ImageDragConfig, "type">
|
|
484
|
+
: ImageDragConfig;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* @public
|
|
488
|
+
* Options for making an `HTMLImageElement` draggable.
|
|
489
|
+
*/
|
|
490
|
+
export declare type ImageElementData = DragCallback & {
|
|
491
|
+
/**
|
|
492
|
+
* The element to be made draggable.
|
|
493
|
+
*/
|
|
494
|
+
node: HTMLImageElement;
|
|
495
|
+
/**
|
|
496
|
+
* Options for defining the drag-and-drop behavior.
|
|
497
|
+
*
|
|
498
|
+
* @remarks
|
|
499
|
+
* If any of this data is omitted, it's inferred from the `node` property.
|
|
500
|
+
*/
|
|
501
|
+
dragData?:
|
|
502
|
+
| Partial<UserSuppliedImageDragData>
|
|
503
|
+
| (Partial<UserSuppliedVideoDragData> &
|
|
504
|
+
Pick<UserSuppliedVideoDragData, "type" | "resolveVideoRef">);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* @public
|
|
509
|
+
* An image asset that will be used to fill the given path.
|
|
510
|
+
*/
|
|
511
|
+
declare type ImageFill = {
|
|
512
|
+
/**
|
|
513
|
+
* Type of an asset that will be used to fill the given path.
|
|
514
|
+
*/
|
|
515
|
+
type: "IMAGE";
|
|
516
|
+
/**
|
|
517
|
+
* A unique identifier that references an image asset in Canva's backend.
|
|
518
|
+
*/
|
|
519
|
+
ref: ImageRef;
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* @public
|
|
524
|
+
* A unique identifier that references an image asset in Canva's backend.
|
|
525
|
+
*/
|
|
526
|
+
export declare type ImageRef = string & {
|
|
527
|
+
__imageRef: never;
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* @public
|
|
532
|
+
* @param appElementConfig - Configuration for an AppElementClient
|
|
533
|
+
*/
|
|
534
|
+
export declare function initAppElement<A extends AppElementData>(
|
|
535
|
+
appElementConfig: AppElementClientConfiguration<A>
|
|
536
|
+
): AppElementClient<A>;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* @public
|
|
540
|
+
* A native element.
|
|
541
|
+
*/
|
|
542
|
+
export declare type NativeElement =
|
|
543
|
+
| NativeImageElement
|
|
544
|
+
| NativeVideoElement
|
|
545
|
+
| NativeEmbedElement
|
|
546
|
+
| NativeTextElement
|
|
547
|
+
| NativeShapeElement
|
|
548
|
+
| NativeGroupElement;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* @public
|
|
552
|
+
* The types of elements an app can add to a user's design.
|
|
553
|
+
*/
|
|
554
|
+
export declare type NativeElementType =
|
|
555
|
+
| "IMAGE"
|
|
556
|
+
| "EMBED"
|
|
557
|
+
| "TEXT"
|
|
558
|
+
| "SHAPE"
|
|
559
|
+
| "VIDEO";
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* @public
|
|
563
|
+
* An element that exists within an app or group element.
|
|
564
|
+
*/
|
|
565
|
+
export declare type NativeElementWithBox =
|
|
566
|
+
| NativeImageElementWithBox
|
|
567
|
+
| NativeVideoElementWithBox
|
|
568
|
+
| NativeEmbedElementWithBox
|
|
569
|
+
| NativeTextElementWithBox
|
|
570
|
+
| NativeShapeElementWithBox
|
|
571
|
+
| NativeGroupElementWithBox;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @public
|
|
575
|
+
* An element that renders an embeddable piece of media, such as a YouTube video.
|
|
576
|
+
*/
|
|
577
|
+
export declare type NativeEmbedElement = {
|
|
578
|
+
/**
|
|
579
|
+
* The type of element.
|
|
580
|
+
*/
|
|
581
|
+
type: "EMBED";
|
|
582
|
+
/**
|
|
583
|
+
* The URL of the embed. This URL must be supported by the Iframely API.
|
|
584
|
+
*/
|
|
585
|
+
url: string;
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* @public
|
|
590
|
+
* An element that renders an embeddable piece of media, such as a YouTube video.
|
|
591
|
+
*
|
|
592
|
+
* @remarks
|
|
593
|
+
* This type includes properties for controlling the position and dimensions of the
|
|
594
|
+
* element.
|
|
595
|
+
* It will be positioned and sized relative to its parent container.
|
|
596
|
+
* The parent container may be an app element, or the current page.
|
|
597
|
+
*/
|
|
598
|
+
export declare type NativeEmbedElementWithBox = {
|
|
599
|
+
/**
|
|
600
|
+
* The type of element.
|
|
601
|
+
*/
|
|
602
|
+
type: "EMBED";
|
|
603
|
+
/**
|
|
604
|
+
* The URL of the embed.
|
|
605
|
+
*
|
|
606
|
+
* @remarks
|
|
607
|
+
* This URL must be supported by the Iframely API.
|
|
608
|
+
*/
|
|
609
|
+
url: string;
|
|
610
|
+
} & Box;
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* @public
|
|
614
|
+
* An element containing two or more {@link NativeElementWithBox}.
|
|
615
|
+
*/
|
|
616
|
+
export declare type NativeGroupElement = {
|
|
617
|
+
/**
|
|
618
|
+
* The type of element.
|
|
619
|
+
*/
|
|
620
|
+
type: "GROUP";
|
|
621
|
+
/**
|
|
622
|
+
* The inner elements contained by the group element. These elements require a Box as they are
|
|
623
|
+
* relatively positioned to the outer boundaries of the group element.
|
|
624
|
+
*/
|
|
625
|
+
children: NativeSimpleElementWithBox[];
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* @public
|
|
630
|
+
* An element containing two or more {@link NativeSimpleElementWithBox}.
|
|
631
|
+
*
|
|
632
|
+
* @remarks
|
|
633
|
+
* This type includes properties for controlling the position and dimensions
|
|
634
|
+
* of the element
|
|
635
|
+
*/
|
|
636
|
+
declare type NativeGroupElementWithBox = {
|
|
637
|
+
/**
|
|
638
|
+
* The type of element.
|
|
639
|
+
*/
|
|
640
|
+
type: "GROUP";
|
|
641
|
+
/**
|
|
642
|
+
* The inner elements contained by the group element. These elements require a Box as they are
|
|
643
|
+
* relatively positioned to the outer boundaries of the group element.
|
|
644
|
+
*/
|
|
645
|
+
children: NativeSimpleElementWithBox[];
|
|
646
|
+
} & Box;
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* @public
|
|
650
|
+
* An element that renders an image in the user's design.
|
|
651
|
+
*/
|
|
652
|
+
export declare type NativeImageElement = {
|
|
653
|
+
/**
|
|
654
|
+
* The type of element.
|
|
655
|
+
*/
|
|
656
|
+
type: "IMAGE";
|
|
657
|
+
} & (
|
|
658
|
+
| {
|
|
659
|
+
/**
|
|
660
|
+
* A data URL that contains the image data.
|
|
661
|
+
* @deprecated Instead, use the `upload` method from the `@canva/asset` package and pass the returned asset reference into the `ref` property.
|
|
662
|
+
*/
|
|
663
|
+
dataUrl: string;
|
|
664
|
+
/**
|
|
665
|
+
* A unique identifier that references an image asset in Canva's backend.
|
|
666
|
+
*/
|
|
667
|
+
ref?: never;
|
|
668
|
+
}
|
|
669
|
+
| {
|
|
670
|
+
/**
|
|
671
|
+
* A data URL that contains the image data.
|
|
672
|
+
*/
|
|
673
|
+
dataUrl?: never;
|
|
674
|
+
/**
|
|
675
|
+
* A unique identifier that references an image asset in Canva's backend.
|
|
676
|
+
*/
|
|
677
|
+
ref: ImageRef;
|
|
678
|
+
}
|
|
679
|
+
);
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* @public
|
|
683
|
+
* An element that renders an image in the user's design.
|
|
684
|
+
*
|
|
685
|
+
* @remarks
|
|
686
|
+
* This type includes properties for controlling the position and dimensions
|
|
687
|
+
* of the element.
|
|
688
|
+
* It will be positioned and sized relative to its parent container.
|
|
689
|
+
* The parent container may be an app element, or the current page.
|
|
690
|
+
*/
|
|
691
|
+
export declare type NativeImageElementWithBox = NativeImageElement & Box;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* @public
|
|
695
|
+
* An element that renders a vector shape.
|
|
696
|
+
*/
|
|
697
|
+
export declare type NativeShapeElement = {
|
|
698
|
+
/**
|
|
699
|
+
* The type of element.
|
|
700
|
+
*/
|
|
701
|
+
type: "SHAPE";
|
|
702
|
+
/**
|
|
703
|
+
* Properties for configuring the scale and cropping of a shape.
|
|
704
|
+
*
|
|
705
|
+
* @remarks
|
|
706
|
+
* This is similar to the `viewBox` attribute of the <svg> element.
|
|
707
|
+
*/
|
|
708
|
+
viewBox: ShapeViewBox;
|
|
709
|
+
/**
|
|
710
|
+
* The paths that define the shape of the element.
|
|
711
|
+
*
|
|
712
|
+
* @remarks
|
|
713
|
+
* There must be between 1 and 30 paths. The maximum combined size of all paths must
|
|
714
|
+
* not exceed 2kb. The maximum numbrer of unique fill colors across all paths is 6.
|
|
715
|
+
*/
|
|
716
|
+
paths: ShapePath[];
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* @public
|
|
721
|
+
* An element that renders a vector shape.
|
|
722
|
+
*
|
|
723
|
+
* @remarks
|
|
724
|
+
* This type includes properties for controlling the position and dimensions of the
|
|
725
|
+
* element.
|
|
726
|
+
* It will be positioned and sized relative to its parent container.
|
|
727
|
+
* The parent container may be an app element, or the current page.
|
|
728
|
+
*/
|
|
729
|
+
export declare type NativeShapeElementWithBox = {
|
|
730
|
+
/**
|
|
731
|
+
* The type of element.
|
|
732
|
+
*/
|
|
733
|
+
type: "SHAPE";
|
|
734
|
+
/**
|
|
735
|
+
* Properties for configuring the scale and cropping of a shape.
|
|
736
|
+
*
|
|
737
|
+
* @remarks
|
|
738
|
+
* This is similar to the `viewBox` attribute of the <svg> element.
|
|
739
|
+
*/
|
|
740
|
+
viewBox: ShapeViewBox;
|
|
741
|
+
/**
|
|
742
|
+
* The paths that define the shape of the element.
|
|
743
|
+
*/
|
|
744
|
+
paths: ShapePath[];
|
|
745
|
+
} & Box;
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* @public
|
|
749
|
+
* An element that exists within a group element.
|
|
750
|
+
*/
|
|
751
|
+
export declare type NativeSimpleElementWithBox = Exclude<
|
|
752
|
+
NativeElementWithBox,
|
|
753
|
+
NativeGroupElementWithBox
|
|
754
|
+
>;
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* @public
|
|
758
|
+
* An element that renders text.
|
|
759
|
+
*/
|
|
760
|
+
export declare type NativeTextElement = {
|
|
761
|
+
/**
|
|
762
|
+
* The type of element.
|
|
763
|
+
*/
|
|
764
|
+
type: "TEXT";
|
|
765
|
+
/**
|
|
766
|
+
* The text to render within the element. In the future, each item in this
|
|
767
|
+
* array will map to a paragraph. At the moment, only one item is supported.
|
|
768
|
+
*/
|
|
769
|
+
children: string[];
|
|
770
|
+
} & TextAttributes;
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* @public
|
|
774
|
+
* An element that renders text.
|
|
775
|
+
*
|
|
776
|
+
* @remarks
|
|
777
|
+
* This type includes properties for controlling the position and dimensions of the
|
|
778
|
+
* element.
|
|
779
|
+
* It will be positioned and sized relative to its parent container.
|
|
780
|
+
* The parent container may be an app element, or the current page.
|
|
781
|
+
*/
|
|
782
|
+
export declare type NativeTextElementWithBox = {
|
|
783
|
+
/**
|
|
784
|
+
* The type of element.
|
|
785
|
+
*/
|
|
786
|
+
type: "TEXT";
|
|
787
|
+
/**
|
|
788
|
+
* The text to render within the element.
|
|
789
|
+
*
|
|
790
|
+
* @remarks
|
|
791
|
+
* In the future, each item in this array will map to a paragraph. At the moment,
|
|
792
|
+
* only one item is supported.
|
|
793
|
+
*/
|
|
794
|
+
children: [string];
|
|
795
|
+
/**
|
|
796
|
+
* The width of the element. This must be an integer between 0 and 32767.
|
|
797
|
+
*/
|
|
798
|
+
width?: number;
|
|
799
|
+
/**
|
|
800
|
+
* The distance from the top edge of the container.
|
|
801
|
+
*
|
|
802
|
+
* @remarks
|
|
803
|
+
* This must be an integer between -32768 and 32767. This property doesn't have
|
|
804
|
+
* any effect if the app element only contains a single element.
|
|
805
|
+
*/
|
|
806
|
+
top: number;
|
|
807
|
+
/**
|
|
808
|
+
* The distance from the left edge of the container.
|
|
809
|
+
*
|
|
810
|
+
* @remarks
|
|
811
|
+
* This must be an integer between -32768 and 32767. This property doesn't have
|
|
812
|
+
* any effect if the app element only contains a single element.
|
|
813
|
+
*/
|
|
814
|
+
left: number;
|
|
815
|
+
/**
|
|
816
|
+
* The rotation of the element, in degrees.
|
|
817
|
+
*
|
|
818
|
+
* @remarks
|
|
819
|
+
* This must be an integer between -180 and 180.
|
|
820
|
+
*/
|
|
821
|
+
rotation?: number;
|
|
822
|
+
} & TextAttributes;
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* @public
|
|
826
|
+
* An element that renders a video in the user's design.
|
|
827
|
+
*/
|
|
828
|
+
export declare type NativeVideoElement = {
|
|
829
|
+
/**
|
|
830
|
+
* The type of element.
|
|
831
|
+
*/
|
|
832
|
+
type: "VIDEO";
|
|
833
|
+
/**
|
|
834
|
+
* A unique identifier that references a video asset in Canva's backend.
|
|
835
|
+
*/
|
|
836
|
+
ref: VideoRef;
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* @public
|
|
841
|
+
* An element that renders a video in the user's design.
|
|
842
|
+
*
|
|
843
|
+
* @remarks
|
|
844
|
+
* This type includes properties for controlling the position and dimensions
|
|
845
|
+
* of the element.
|
|
846
|
+
* It will be positioned and sized relative to its parent container.
|
|
847
|
+
* The parent container may be an app element, or the current page.
|
|
848
|
+
*/
|
|
849
|
+
export declare type NativeVideoElementWithBox = NativeVideoElement & Box;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* The types of object primitive values that can be stored within an app element's data.
|
|
853
|
+
*/
|
|
854
|
+
declare type ObjectPrimitive = Boolean | String;
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* @public
|
|
858
|
+
* Page context
|
|
859
|
+
*/
|
|
860
|
+
export declare type PageContext = {
|
|
861
|
+
/**
|
|
862
|
+
* Page dimensions in px
|
|
863
|
+
*
|
|
864
|
+
* @remarks
|
|
865
|
+
* This value is undefined for Whiteboard and Docs
|
|
866
|
+
*/
|
|
867
|
+
dimensions: PageDimensions | undefined;
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* @public
|
|
872
|
+
* Page Dimensions
|
|
873
|
+
*/
|
|
874
|
+
declare type PageDimensions = {
|
|
875
|
+
width: number;
|
|
876
|
+
height: number;
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* @public
|
|
881
|
+
* The outline of a path.
|
|
882
|
+
*/
|
|
883
|
+
export declare type PathStroke = {
|
|
884
|
+
/**
|
|
885
|
+
* The weight of the stroke. This must be an integer between 0 and 100.
|
|
886
|
+
*/
|
|
887
|
+
weight: number;
|
|
888
|
+
/**
|
|
889
|
+
* The color of the stroke as a hex code.
|
|
890
|
+
*
|
|
891
|
+
* @remarks
|
|
892
|
+
* The hex code must include all six characters and be prefixed with a # symbol (e.g. #ff0099).
|
|
893
|
+
*/
|
|
894
|
+
color: string;
|
|
895
|
+
/**
|
|
896
|
+
* The alignment of the stroke. The only supported value is 'inset'.
|
|
897
|
+
*/
|
|
898
|
+
strokeAlign: "inset";
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* @public
|
|
903
|
+
* The dimensions, position, and rotation of an element.
|
|
904
|
+
*/
|
|
905
|
+
export declare type Placement = Position & (WidthAndHeight | Width | Height);
|
|
906
|
+
|
|
907
|
+
declare type Position = {
|
|
908
|
+
/**
|
|
909
|
+
* The distance from the top edge of the container.
|
|
910
|
+
*
|
|
911
|
+
* @remarks
|
|
912
|
+
* This must be an integer between -32768 and 32767. This property doesn't
|
|
913
|
+
* have any effect if the app element only contains a single element.
|
|
914
|
+
*/
|
|
915
|
+
top: number;
|
|
916
|
+
/**
|
|
917
|
+
* The distance from the left edge of the container.
|
|
918
|
+
*
|
|
919
|
+
* @remarks
|
|
920
|
+
* This must be an integer between -32768 and 32767. This property doesn't
|
|
921
|
+
* have any effect if the app element only contains a single element.
|
|
922
|
+
*/
|
|
923
|
+
left: number;
|
|
924
|
+
/**
|
|
925
|
+
* The rotation of the box, in degrees.
|
|
926
|
+
*
|
|
927
|
+
* @remarks
|
|
928
|
+
* This must be an integer between -180 and 180.
|
|
929
|
+
*/
|
|
930
|
+
rotation?: number;
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* The types of primitive values that can be stored within an app element's data.
|
|
935
|
+
*
|
|
936
|
+
* @remarks
|
|
937
|
+
* All types of primitives are supported except for symbols, bigints and undefined.
|
|
938
|
+
*/
|
|
939
|
+
declare type Primitive = null | number | boolean | string;
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* @public
|
|
943
|
+
* Exports the user's design as one or more static files.
|
|
944
|
+
* @param request - The request object containing configurations of the design export.
|
|
945
|
+
*/
|
|
946
|
+
export declare function requestExport(
|
|
947
|
+
request: ExportRequest
|
|
948
|
+
): Promise<ExportResponse>;
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* @public
|
|
952
|
+
* A path that defines the shape of a shape element.
|
|
953
|
+
*/
|
|
954
|
+
export declare type ShapePath = {
|
|
955
|
+
/**
|
|
956
|
+
* The shape of the path.
|
|
957
|
+
*
|
|
958
|
+
* @remarks
|
|
959
|
+
* This accepts the same value as the `d` attribute of the SVG <path> element,
|
|
960
|
+
* with some limitations.
|
|
961
|
+
*
|
|
962
|
+
* The path must:
|
|
963
|
+
*
|
|
964
|
+
* - start with an M command
|
|
965
|
+
* - not have more than one M command
|
|
966
|
+
* - not use the Q command
|
|
967
|
+
* - be closed, either with a Z command at the end or by having the last
|
|
968
|
+
* coordinate match the first coordinate
|
|
969
|
+
*/
|
|
970
|
+
d: string;
|
|
971
|
+
/**
|
|
972
|
+
* The appearance of the path's interior.
|
|
973
|
+
*/
|
|
974
|
+
fill: Fill;
|
|
975
|
+
/**
|
|
976
|
+
* The outline of the path.
|
|
977
|
+
*/
|
|
978
|
+
stroke?: PathStroke;
|
|
979
|
+
};
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* @public
|
|
983
|
+
* Properties for configuring the scale and cropping of a shape.
|
|
984
|
+
*
|
|
985
|
+
* @remarks
|
|
986
|
+
* This is similar to the `viewBox` attribute of the <svg> element.
|
|
987
|
+
*/
|
|
988
|
+
export declare type ShapeViewBox = {
|
|
989
|
+
/**
|
|
990
|
+
* The distance of the shape from the top edge of the element.
|
|
991
|
+
*/
|
|
992
|
+
top: number;
|
|
993
|
+
/**
|
|
994
|
+
* The distance of the shape from the left edge of the element.
|
|
995
|
+
*/
|
|
996
|
+
left: number;
|
|
997
|
+
/**
|
|
998
|
+
* The width of the view box.
|
|
999
|
+
*/
|
|
1000
|
+
width: number;
|
|
1001
|
+
/**
|
|
1002
|
+
* The height of the view box.
|
|
1003
|
+
*/
|
|
1004
|
+
height: number;
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* @public
|
|
1009
|
+
* Attributes for changing the appearance of text.
|
|
1010
|
+
*/
|
|
1011
|
+
declare type TextAttributes = {
|
|
1012
|
+
/**
|
|
1013
|
+
* The size of the text.
|
|
1014
|
+
*
|
|
1015
|
+
* @remarks
|
|
1016
|
+
* The default value is 16. This must be an integer between 1 and 1000.
|
|
1017
|
+
* This property will be ignored when adding native text elements without specifying placement.
|
|
1018
|
+
*/
|
|
1019
|
+
fontSize?: number;
|
|
1020
|
+
/**
|
|
1021
|
+
* The alignment of the text. The default value is 'start'.
|
|
1022
|
+
*/
|
|
1023
|
+
textAlign?: "start" | "center" | "end";
|
|
1024
|
+
/**
|
|
1025
|
+
* The color of the text as a hex code.
|
|
1026
|
+
*
|
|
1027
|
+
* @remarks
|
|
1028
|
+
* The hex code must include all six characters and be prefixed with a # symbol
|
|
1029
|
+
* (e.g. #ff0099). The default value is #000000.
|
|
1030
|
+
*/
|
|
1031
|
+
color?: string;
|
|
1032
|
+
/**
|
|
1033
|
+
* The weight of the font. The default value is 'normal'.
|
|
1034
|
+
*/
|
|
1035
|
+
fontWeight?: "normal" | "bold";
|
|
1036
|
+
/**
|
|
1037
|
+
* The style of the font. The default value is 'normal'.
|
|
1038
|
+
*/
|
|
1039
|
+
fontStyle?: "normal" | "italic";
|
|
1040
|
+
/**
|
|
1041
|
+
* The decoration of the font. The default value is 'none'.
|
|
1042
|
+
*/
|
|
1043
|
+
decoration?: "none" | "underline";
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* @public
|
|
1048
|
+
* Options for defining the drag-and-drop behavior of a text element.
|
|
1049
|
+
*/
|
|
1050
|
+
export declare type TextDragConfig = {
|
|
1051
|
+
/**
|
|
1052
|
+
* The type of element.
|
|
1053
|
+
*/
|
|
1054
|
+
type: "TEXT";
|
|
1055
|
+
/**
|
|
1056
|
+
* The text content to drag.
|
|
1057
|
+
*/
|
|
1058
|
+
children?: string[];
|
|
1059
|
+
/**
|
|
1060
|
+
* The alignment of the text. The default value is 'start'.
|
|
1061
|
+
*/
|
|
1062
|
+
textAlign?: "start" | "center" | "end";
|
|
1063
|
+
/**
|
|
1064
|
+
* The weight of the font. The default value is 'normal'.
|
|
1065
|
+
*/
|
|
1066
|
+
fontWeight?: "normal" | "bold";
|
|
1067
|
+
/**
|
|
1068
|
+
* The style of the font. The default value is 'normal'.
|
|
1069
|
+
*/
|
|
1070
|
+
fontStyle?: "normal" | "italic";
|
|
1071
|
+
/**
|
|
1072
|
+
* The decoration of the font. The default value is 'none'.
|
|
1073
|
+
*/
|
|
1074
|
+
decoration?: "none" | "underline";
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* @public
|
|
1079
|
+
* The methods for adding drag-and-drop behavior to an app.
|
|
1080
|
+
*/
|
|
1081
|
+
export declare interface UI {
|
|
1082
|
+
/**
|
|
1083
|
+
* @public
|
|
1084
|
+
* Makes the specified node draggable.
|
|
1085
|
+
*
|
|
1086
|
+
* @deprecated use `UI.startDrag` instead
|
|
1087
|
+
*
|
|
1088
|
+
* @param options - Options for making an element draggable.
|
|
1089
|
+
*/
|
|
1090
|
+
makeDraggable(options: DraggableElementData): void;
|
|
1091
|
+
/**
|
|
1092
|
+
* @public
|
|
1093
|
+
* Handles a drag event initiated inside the app to Canva, enables drag-and_drop interactions with elements outside of the app.
|
|
1094
|
+
* @param event - The drag start event.
|
|
1095
|
+
* @param dragData - The data to be passed to the drag handler.
|
|
1096
|
+
*/
|
|
1097
|
+
startDrag<E extends HTMLElement>(
|
|
1098
|
+
event: DragStartEvent<E>,
|
|
1099
|
+
dragData:
|
|
1100
|
+
| TextDragConfig
|
|
1101
|
+
| AudioDragConfig
|
|
1102
|
+
| EmbedDragConfig
|
|
1103
|
+
| VideoDragConfigForElement<E>
|
|
1104
|
+
| ImageDragConfigForElement<E>
|
|
1105
|
+
): Promise<void>;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* An alias for the UI interface, providing access to ui related functionality
|
|
1110
|
+
* @public
|
|
1111
|
+
*/
|
|
1112
|
+
export declare const ui: UI;
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* @deprecated
|
|
1116
|
+
* @public
|
|
1117
|
+
* Options for defining the drag-and-drop behavior of audio tracks.
|
|
1118
|
+
*/
|
|
1119
|
+
export declare type UserSuppliedAudioDragData = AudioDragConfig;
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* @deprecated
|
|
1123
|
+
* @public
|
|
1124
|
+
*
|
|
1125
|
+
* Options for defining the Drag and Drop behaviour for images
|
|
1126
|
+
* which have been supplied as data urls
|
|
1127
|
+
*/
|
|
1128
|
+
export declare type UserSuppliedDataUrlImageDragData = CommonImageDragConfig & {
|
|
1129
|
+
/**
|
|
1130
|
+
* The dimensions of the full-size image.
|
|
1131
|
+
*
|
|
1132
|
+
* @remarks
|
|
1133
|
+
* The full-size image is the image that Canva uploads to the user's account and
|
|
1134
|
+
* adds to their design.
|
|
1135
|
+
*
|
|
1136
|
+
* If omitted, the value of the `previewSize` property is used as a fallback.
|
|
1137
|
+
*/
|
|
1138
|
+
fullSize?: Dimensions;
|
|
1139
|
+
/**
|
|
1140
|
+
* The data URL of the preview image.
|
|
1141
|
+
*
|
|
1142
|
+
* @remarks
|
|
1143
|
+
* The preview image is the image that users see under their cursor while dragging
|
|
1144
|
+
* it into their design.
|
|
1145
|
+
*
|
|
1146
|
+
* If omitted, the value of the `fullSizeSrc` property is used as a fallback.
|
|
1147
|
+
*/
|
|
1148
|
+
previewSrc?: string;
|
|
1149
|
+
/**
|
|
1150
|
+
* The data URL of the full-size image.
|
|
1151
|
+
*
|
|
1152
|
+
* @remarks
|
|
1153
|
+
* The full-size image is the image that Canva uploads to the user's account and
|
|
1154
|
+
* adds to their design.
|
|
1155
|
+
*/
|
|
1156
|
+
fullSizeSrc: string;
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* @deprecated
|
|
1161
|
+
* @public
|
|
1162
|
+
* Options for defining the drag-and-drop behavior that can be defined by an app developer.
|
|
1163
|
+
*/
|
|
1164
|
+
export declare type UserSuppliedDragData =
|
|
1165
|
+
| UserSuppliedImageDragData
|
|
1166
|
+
| UserSuppliedTextDragData
|
|
1167
|
+
| UserSuppliedVideoDragData
|
|
1168
|
+
| UserSuppliedAudioDragData;
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* @deprecated
|
|
1172
|
+
* @public
|
|
1173
|
+
*
|
|
1174
|
+
* Options for defining the Drag and Drop behaviour for images uploaded
|
|
1175
|
+
* via the Content capability.
|
|
1176
|
+
*/
|
|
1177
|
+
export declare type UserSuppliedExternalImageDragData =
|
|
1178
|
+
CommonImageDragConfig & {
|
|
1179
|
+
/**
|
|
1180
|
+
* The function that resolves an image ref
|
|
1181
|
+
* @remarks
|
|
1182
|
+
*
|
|
1183
|
+
* This function will be run during the drag process in order to fetch the media ref of the
|
|
1184
|
+
* external image being fetched. This function should return the result of `upload`
|
|
1185
|
+
* from the content capability.
|
|
1186
|
+
*/
|
|
1187
|
+
resolveImageRef: () => Promise<{
|
|
1188
|
+
ref: ImageRef;
|
|
1189
|
+
}>;
|
|
1190
|
+
/**
|
|
1191
|
+
* The URL of the preview image.
|
|
1192
|
+
*
|
|
1193
|
+
* @remarks
|
|
1194
|
+
* The preview image is the image that users see under their cursor while dragging
|
|
1195
|
+
* it into their design.
|
|
1196
|
+
*/
|
|
1197
|
+
previewSrc: string;
|
|
1198
|
+
/**
|
|
1199
|
+
* The dimensions of the full-size image.
|
|
1200
|
+
*
|
|
1201
|
+
* @remarks
|
|
1202
|
+
* The full-size image is the image that Canva uploads to the user's account and
|
|
1203
|
+
* adds to their design.
|
|
1204
|
+
*
|
|
1205
|
+
* If omitted, the value of the `previewSize` property is used as a fallback.
|
|
1206
|
+
*/
|
|
1207
|
+
fullSize?: Dimensions;
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* @deprecated
|
|
1212
|
+
* @public
|
|
1213
|
+
* Options for defining the drag-and-drop behavior of an image element that can be defined by an
|
|
1214
|
+
* app developer.
|
|
1215
|
+
*/
|
|
1216
|
+
export declare type UserSuppliedImageDragData =
|
|
1217
|
+
| UserSuppliedDataUrlImageDragData
|
|
1218
|
+
| UserSuppliedExternalImageDragData;
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* @deprecated
|
|
1222
|
+
* @public
|
|
1223
|
+
* Options for defining the drag-and-drop behavior of a text element.
|
|
1224
|
+
*/
|
|
1225
|
+
export declare type UserSuppliedTextDragData = TextDragConfig;
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* @deprecated
|
|
1229
|
+
* @public
|
|
1230
|
+
* Options for defining the drag-and-drop behavior for videos.
|
|
1231
|
+
*/
|
|
1232
|
+
export declare type UserSuppliedVideoDragData = {
|
|
1233
|
+
/**
|
|
1234
|
+
* The type of element.
|
|
1235
|
+
*/
|
|
1236
|
+
type: "VIDEO";
|
|
1237
|
+
/**
|
|
1238
|
+
* The function used resolve the video ref.
|
|
1239
|
+
* This is used in conjunction with content import.
|
|
1240
|
+
*/
|
|
1241
|
+
resolveVideoRef: () => Promise<{
|
|
1242
|
+
ref: VideoRef;
|
|
1243
|
+
}>;
|
|
1244
|
+
/**
|
|
1245
|
+
* The dimensions of the preview image.
|
|
1246
|
+
* @remarks
|
|
1247
|
+
* The preview image is the image that users see under their cursor
|
|
1248
|
+
* while dragging it into their design.
|
|
1249
|
+
*/
|
|
1250
|
+
previewSize: Dimensions;
|
|
1251
|
+
/**
|
|
1252
|
+
* The dimensions of the full-size video.
|
|
1253
|
+
* These dimensions are used when adding the video to the design
|
|
1254
|
+
*
|
|
1255
|
+
* If omitted, the value of the `previewSize` property is
|
|
1256
|
+
* used as a fallback.
|
|
1257
|
+
*/
|
|
1258
|
+
fullSize?: Dimensions;
|
|
1259
|
+
/**
|
|
1260
|
+
* The URL of the preview image.
|
|
1261
|
+
*
|
|
1262
|
+
* @remarks
|
|
1263
|
+
* The preview image is the image that users see under their cursor while dragging
|
|
1264
|
+
* it into their design.
|
|
1265
|
+
*/
|
|
1266
|
+
previewSrc: string;
|
|
1267
|
+
};
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* @public
|
|
1271
|
+
* The types of values that can be stored within an app element's data.
|
|
1272
|
+
*/
|
|
1273
|
+
export declare type Value =
|
|
1274
|
+
| Primitive
|
|
1275
|
+
| ObjectPrimitive
|
|
1276
|
+
| Value[]
|
|
1277
|
+
| {
|
|
1278
|
+
[key: string]: Value;
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* @public
|
|
1283
|
+
* Options for defining the drag-and-drop behavior for videos.
|
|
1284
|
+
*/
|
|
1285
|
+
export declare type VideoDragConfig = {
|
|
1286
|
+
/**
|
|
1287
|
+
* The type of element.
|
|
1288
|
+
*/
|
|
1289
|
+
type: "VIDEO";
|
|
1290
|
+
/**
|
|
1291
|
+
* The function used resolve the video ref.
|
|
1292
|
+
* This is used in conjunction with content import.
|
|
1293
|
+
*/
|
|
1294
|
+
resolveVideoRef: () => Promise<{
|
|
1295
|
+
ref: VideoRef;
|
|
1296
|
+
}>;
|
|
1297
|
+
/**
|
|
1298
|
+
* The dimensions of the preview image.
|
|
1299
|
+
* @remarks
|
|
1300
|
+
* The preview image is the image that users see under their cursor
|
|
1301
|
+
* while dragging it into their design.
|
|
1302
|
+
*/
|
|
1303
|
+
previewSize: Dimensions;
|
|
1304
|
+
/**
|
|
1305
|
+
* The dimensions of the full-size video.
|
|
1306
|
+
* These dimensions are used when adding the video to the design
|
|
1307
|
+
*
|
|
1308
|
+
* If omitted, the value of the `previewSize` property is
|
|
1309
|
+
* used as a fallback.
|
|
1310
|
+
*/
|
|
1311
|
+
fullSize?: Dimensions;
|
|
1312
|
+
/**
|
|
1313
|
+
* The URL of the preview image.
|
|
1314
|
+
*
|
|
1315
|
+
* @remarks
|
|
1316
|
+
* The preview image is the image that users see under their cursor while dragging
|
|
1317
|
+
* it into their design.
|
|
1318
|
+
*/
|
|
1319
|
+
previewUrl: string;
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* @public
|
|
1324
|
+
* Options for defining the drag-and-drop behavior for videos.
|
|
1325
|
+
*/
|
|
1326
|
+
export declare type VideoDragConfigForElement<E extends Element> =
|
|
1327
|
+
E extends HTMLImageElement
|
|
1328
|
+
? Partial<VideoDragConfig> &
|
|
1329
|
+
Pick<VideoDragConfig, "type" | "resolveVideoRef">
|
|
1330
|
+
: VideoDragConfig;
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* @public
|
|
1334
|
+
* A video asset that will be used to fill the given path.
|
|
1335
|
+
*/
|
|
1336
|
+
declare type VideoFill = {
|
|
1337
|
+
/**
|
|
1338
|
+
* Type of an asset that will be used to fill the given path.
|
|
1339
|
+
*/
|
|
1340
|
+
type: "VIDEO";
|
|
1341
|
+
/**
|
|
1342
|
+
* A unique identifier that references a video asset in Canva's backend.
|
|
1343
|
+
*/
|
|
1344
|
+
ref: VideoRef;
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* @public
|
|
1349
|
+
* A unique identifier that references a video asset in Canva's backend.
|
|
1350
|
+
*/
|
|
1351
|
+
export declare type VideoRef = string & {
|
|
1352
|
+
__videoRef: never;
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
declare type Width = {
|
|
1356
|
+
width: number;
|
|
1357
|
+
height: "auto";
|
|
1358
|
+
};
|
|
1359
|
+
|
|
1360
|
+
declare type WidthAndHeight = {
|
|
1361
|
+
/**
|
|
1362
|
+
* The width of the box. If height is a number, this can be set to "auto".
|
|
1363
|
+
* Otherwise, it must be an integer between 0 and 32767.
|
|
1364
|
+
*/
|
|
1365
|
+
width: number;
|
|
1366
|
+
/**
|
|
1367
|
+
* The height of the box. If width is a number, this can be set to "auto".
|
|
1368
|
+
* Otherwise, it must be an integer between 0 and 32767.
|
|
1369
|
+
*/
|
|
1370
|
+
height: number;
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
export {};
|